From: Jean-Marc Pigeon (Delson) Date: Wed, 25 Jun 2025 14:26:20 +0000 (-0400) Subject: Able to extract email field from emails table X-Git-Tag: tag-0.10~35 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=03961cd29d5ecff34a1264f02b3142f6a45b61f7;p=jmp%2Fmailleur Able to extract email field from emails table --- diff --git a/lib/devsql.c b/lib/devsql.c index 34dc284..632a1d1 100644 --- a/lib/devsql.c +++ b/lib/devsql.c @@ -68,6 +68,70 @@ return rs; */ /********************************************************/ /* */ +/* Procedure to get the ASCII form of field located*/ +/* in a specific tuple + name in sqlresult. */ +/* */ +/********************************************************/ +static char *getvalue(SQLTYP *sql,SQLRES *rs,int tuple,const char *fieldname) + +{ +#define OPEP "devsql.c:getvalue," + +char *value; + +value=(char *)0; +switch(sql->sqldb) { + case db_postgres : + value=pos_getvalue((POSRES *)rs,tuple,fieldname); + break; + case db_maria : + value=mar_getvalue((MARRES *)rs,tuple,fieldname); + break; + default : + (void) rou_alert(0,"%s Unexpected type='%d' (BUG!?)", + OPEP,(int)sql->sqldb); + break; + } +return value; +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to get the ASCII form of field located*/ +/* in a specific tuple + position in sqlresult. */ +/* */ +/********************************************************/ +static char *getfield(SQLTYP *sql,SQLRES *rs,int tuple,int position) + +{ +#define OPEP "devsql.c:getfield," + +char *value; + +value=(char *)0; +switch(sql->sqldb) { + case db_postgres : + value=pos_getfield((POSRES *)rs,tuple,position); + break; + case db_maria : + value=mar_getfield((MARRES *)rs,tuple,position); + break; + default : + (void) rou_alert(0,"%s Unexpected type='%d' (BUG!?)", + OPEP,(int)sql->sqldb); + break; + } +return value; +#undef OPEP +} +/* + +*/ +/********************************************************/ +/* */ /* Procedure to the number of tupple within a */ /* result issued by a successfull command. */ /* */ @@ -416,8 +480,11 @@ while (proceed==true) { case 4 : //getting user information int nbr; - if ((nbr=nbrtupple(sql,rs))>0) { - (void) rou_alert(0,"%s jmpdbg NBR='%d'",OPEP,nbr); + if ((nbr=nbrtupple(sql,rs))==1) { + char *rcpt; + + rcpt=getvalue(sql,rs,0,"email"); + (void) rou_alert(0,"%s JMPDBG db_rcpt=<%s>",OPEP,rcpt); } rs=dropresult(sql,rs); break; diff --git a/lib/unimar.c b/lib/unimar.c index cff1460..8dfa2e5 100644 --- a/lib/unimar.c +++ b/lib/unimar.c @@ -169,6 +169,88 @@ return (MARRES *)0; */ /********************************************************/ /* */ +/* procedure to retrieve specific field value in */ +/* tupple under fieldname. */ +/* */ +/********************************************************/ +PUBLIC char *mar_getvalue(MARRES *rs,int tuple,const char *fieldname) + +{ +#define OPEP "unimar.c:pos_getfield," +register char *got; + +got=(char *)0; +#ifdef DB_MYSQL + { + register int position; + + register uint numfields; + MYSQL_FIELD *fields; + + position=-1; + numfields=mysql_num_fields((MYSQL_RES *)rs); + fields=mysql_fetch_fields((MYSQL_RES *)rs); + for (int i=0;i