FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour New function For check email
Posts: 80
Joined: Tue Nov 15, 2005 03:38 PM

New function For check email

Posted: Fri Mar 18, 2016 04:52 PM

Hello
Now verify the e-mail before saving in the database.
function returns zero if the mail is wrong or if one is true.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// check email
// check_em.prg

include "FiveWin.ch"

func main()
local e_mail_ok="LIVESYSTEM_NET@HOTMAIL.COM"
local e_mail_error="LIVESYSTEM_NET#HOTMAIL.COM"
? C_CHECK_EMAIL(ALLTRIM(e_mail_ok))
? C_CHECK_EMAIL(ALLTRIM(e_mail_error))
return .t.
// ***********************************************

pragma BEGINDUMP

include "windows.h"

include "hbapiitm.h"

include "hbvm.h"

include "hbstack.h"

include "item.api"

include "hbpcode.h"

include "hbvmpub.h"

// --------- function check email --------------

include <string.h>

int spc_email_isvalid(const char *address) {
int count = 0;
const char *c, *domain;
static char *rfc822_specials = "()<>@,;:\\"[]";

/* first we validate the name portion (name@domain) */
for (c = address; *c; c++) {
if (*c == '\"' && (c == address || *(c - 1) == '.' || (c - 1) ==
'\"')) {
while (
++c) {
if (*c == '\"') break;
if (c == '\' && (++c == ' ')) continue;
if (*c <= ' ' || *c >= 127) return 0;
}
if (!*c++) return 0;
if (*c == '@') break;
if (*c != '.') return 0;
continue;
}
if (*c == '@') break;
if (*c <= ' ' || *c >= 127) return 0;
if (strchr(rfc822_specials, *c)) return 0;
}
if (c == address || *(c - 1) == '.') return 0;

/* next we validate the domain portion (name@domain) /
if (!
(domain = ++c)) return 0;
do {
if (*c == '.') {
if (c == domain || *(c - 1) == '.') return 0;
count++;
}
if (*c <= ' ' || *c >= 127) return 0;
if (strchr(rfc822_specials, c)) return 0;
} while (
++c);

return (count >= 1);
}
// ------------------------
//------------- function check email -----------
HB_FUNC ( C_CHECK_EMAIL )
{
int RET_N=0;
char far *URL_EMAIL;
URL_EMAIL = hb_parc(1);
RET_N=spc_email_isvalid((const char *)URL_EMAIL);
hb_retni(RET_N);
}
// *************************
#pragma ENDDUMP
++++++++++++++++++++++++
greetings to you all.
Hathal.

:D

Posts: 44508
Joined: Thu Oct 06, 2005 05:47 PM

Re: New function For check email

Posted: Fri Mar 18, 2016 06:00 PM

Hathal,

Thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3382
Joined: Fri Oct 07, 2005 08:20 PM

Re: New function For check email

Posted: Fri Mar 18, 2016 06:48 PM

Hathal:

Nice job and very usefull.

Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 8716
Joined: Tue Dec 20, 2005 07:36 PM

Re: New function For check email

Posted: Fri Apr 15, 2016 03:14 PM
Code (fw): Select all Collapse
check_em.c:
Warning W8075 check_em.prg 80: Suspicious pointer conversion in function HB_FUN_C_CHECK_EMAIL

Warning W8004 check_em.prg 78: 'RET_N' is assigned a value that is never used in function HB_FUN_C_CHECK_EMAIL


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion