*/
/********************************************************/
/* */
+/* 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
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* 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
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to the number of tupple within a */
/* result issued by a successfull command. */
/* */
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;
*/
/********************************************************/
/* */
+/* 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<numfields;i++) {
+ if (strcmp(fields[i].name,fieldname)==0) {
+ position=i;
+ break;
+ }
+ }
+ if (position<0)
+ (void) rou_alert(0,"%s field '%s' unknown (Bug?)",OPEP,fieldname);
+ else {
+ register MYSQL_ROW row;
+
+ (void) mysql_data_seek((MYSQL_RES *)rs,tuple);
+ if ((row=mysql_fetch_row((MYSQL_RES *)rs))!=(MYSQL_ROW)0)
+ got=row[position];
+ }
+ }
+#endif
+return got;
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to extract data from the database. */
+/* Return POSRES status pointer (can be NULL is not*/
+/* successfull. */
+/* */
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* procedure to retrieve specific field in specific*/
+/* row, accessed with the column number. */
+/* */
+/********************************************************/
+PUBLIC char *mar_getfield(MARRES *rs,int tuple,int position)
+
+{
+register char *got;
+
+got=(char *)0;
+#ifdef DB_MYSQL
+ {
+ MYSQL_ROW row;
+
+ (void) mysql_data_seek((MYSQL_RES *)rs,tuple);
+ if ((row=mysql_fetch_row((MYSQL_RES *)rs))!=(MYSQL_ROW)0) {
+ got=row[position];
+ }
+ }
+#endif
+return got;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to extract data from the database. */
/* Return POSRES status pointer (can be NULL is not*/
/* successfull. */
//procedure to drop/free all result information
extern MARRES *mar_dropresult(MARRES *rs);
+//procedure to extract specific field within database
+extern char *mar_getfield(MARRES *rs,int tuple,int position);
+
+//procedure to extract specific field value within database
+extern char *mar_getvalue(MARRES *rs,int tuple,const char *fieldname);
+
//procedure to extract data from database
extern MARRES *mar_gettupple(MARPTR *marptr,char *command);
*/
/********************************************************/
/* */
+/* procedure to retrieve specific field value in */
+/* tupple, accessed at position */
+/* */
+/********************************************************/
+PUBLIC char *pos_getfield(POSRES *rs,int tuple,int position)
+
+{
+register char *got;
+
+got=(char *)0;
+#ifdef DB_POSTGRESQL
+got=PQgetvalue((PGresult *)rs,tuple,position);
+#endif
+return got;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* procedure to retrieve specific field value in */
+/* tupple under fieldname. */
+/* */
+/********************************************************/
+PUBLIC char *pos_getvalue(POSRES *rs,int tuple,const char *fieldname)
+
+{
+#define OPEP "unipos.c:pos_getfield,"
+register char *got;
+
+got=(char *)0;
+#ifdef DB_POSTGRESQL
+ {
+ int position;
+
+ if ((position=PQfnumber((PGresult *)rs,fieldname))<0)
+ (void) rou_alert(0,"%s field '%s' unknown (BUG?)",OPEP,fieldname);
+ else {
+ if (PQgetisnull((PGresult *)rs,tuple,position)==false)
+ got=PQgetvalue((PGresult *)rs,tuple,position);
+ }
+ }
+#endif
+return got;
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to extract data from the database. */
/* Return POSRES status pointer (can be NULL is not*/
/* successfull. */
//procedure to drop/free all result information
extern POSRES *pos_dropresult(POSRES *rs);
+//procedure to extract specific field within database
+extern char *pos_getfield(POSRES *rs,int tuple,int position);
+
+//procedure to extract specific field value within database
+extern char *pos_getvalue(POSRES *rs,int tuple,const char *fieldname);
+
//procedure to extract data from database
extern POSRES *pos_gettupple(POSPTR *posptr,char *command);
/* */
/********************************************************/
CREATE TABLE emails (
- email TEXT, //user email
+ email TEXTUNIQUE, //user email
space INTEGER //space used by user email
DFLT 0,
mxspace INTEGER //Maximun space available