unidns.h \
devlog.h devsoc.h
+gessql.h: \
+ unieml.h \
+ devsql.h
+
gesspf.h: \
subafn.h
+
devsoc.h: \
unitls.h
*/
/********************************************************/
/* */
-/* Procedure to free memory used by a TRATYP record*/
-/* */
-/********************************************************/
-static TRATYP *eml_freetra(TRATYP *tra)
-
-{
-if (tra!=(TRATYP *)0) {
- (void) eml_freetra_resp(tra);
- tra->rcptto=rou_freestr(tra->rcptto);
- tra->mailfrom=rou_freestr(tra->mailfrom);
- tra->sessid=rou_freestr(tra->sessid);
- (void) free(tra);
- tra=(TRATYP *)0;
- }
-return tra;
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
/* Procedure to display/debug TRATYP record content*/
/* */
/********************************************************/
*/
/********************************************************/
/* */
-/* Procedure to free memory used by the TRATYP */
-/* response part. */
-/* */
-/********************************************************/
-PUBLIC void eml_freetra_resp(TRATYP *tra)
-
-{
-if (tra!=(TRATYP *)0) {
- tra->resp=(char **)rou_freelist((void **)tra->resp,(genfree_t)rou_freestr);
- }
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
/* Procedure to duplicate an resp list within a tra*/
/* record. */
/* */
*/
/********************************************************/
/* */
-/* Procedure to free memory used by a tra list */
-/* */
-/********************************************************/
-PUBLIC TRATYP **eml_freeall_tra(TRATYP **tra)
-
-{
-(void) eml_update_tradb(tra);
-tra=(TRATYP **)rou_freelist((void **)tra,(genfree_t)eml_freetra);
-return tra;
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
/* Procedure to scan the a qfile and build a */
/* list of email transport directive. */
/* */
#undef OPEP
}
-/*
-^L
-*/
-/********************************************************/
-/* */
-/* Procedure to update the database with respond */
-/* Record associated with TRA. */
-/* Return the number of record stored within the */
-/* database. */
-/* */
-/********************************************************/
-PUBLIC int eml_update_tradb(TRATYP **tra)
-
-{
-#define OPEP "geseml.c:eml_update_tradb,"
-
-int num;
-
-num=0;
-if (tra!=(TRATYP **)0) {
- SQLPTR *sqlptr;
- int phase;
- _Bool proceed;
-
- sqlptr=(SQLPTR *)0;
- phase=0;
- proceed=(*tra!=(TRATYP *)0);
- while (proceed==true) {
- switch (phase) {
- case 0 : //opening the database
- if ((sqlptr=sql_opensql())==(SQLPTR *)0) {
- (void) rou_alert(0,"%s Unable to open database (system?)",OPEP);
- phase=999;
- }
- break;
- case 1 : //checking all transation
- while (*tra!=(TRATYP *)0) {
- if ((*tra)->resp!=(char **)0) {
- ACTTYP action;
-
- action.sessid=(*tra)->sessid;
- action.code=(*tra)->code;
- action.rcptto=(*tra)->rcptto;
- action.resp=(*tra)->resp;
- (void) sql_mngact(sqlptr,sql_delete,&action);
- num++;
- }
- tra++;
- }
- break;
- case 2 : //closing the database
- sqlptr=sql_closesql(sqlptr);
- break;
- default : //SAFE Guard
- proceed=false;
- break;
- }
- phase++;
- }
- }
-return num;
-
-#undef OPEP
-}
#include "unisql.h"
-//structure to define an email transport directive
-typedef struct {
- char code; //Transaction code
- time_t date; //Transaction date
- u_int delay; //Transaction execution delay
- char *sessid; //session id
- char *mailfrom; //Email Originator
- char *rcptto; //Email Recipient
- int sendcode; //Email sending status;
- char **resp; //Transfer response status
- }TRATYP;
-
//procedure to dump a list of transfert record
extern _Bool eml_dump_one_tra(FILE *out,TRATYP *tra);
//procedure to dump a list of transfert record
extern _Bool eml_dump_list_tra(FILE *out,TRATYP **tra);
-//procedure to fee memory used by the resp record within TRATYP structure
-extern void eml_freetra_resp(TRATYP *tra);
-
//procedure to fee memory used to duplicate a resp list to tra resp
extern void eml_duptra_resp(TRATYP *tra,char **resp);
extern TRATYP *eml_duptra(TRATYP *tra);
//procedure to fee memory used by a TRATYP structure
-extern TRATYP **eml_freeall_tra(TRATYP **tra);
+//extern TRATYP **eml_freeall_tra(TRATYP **tra);
//procedure to open a specific qfile
extern TRATYP **eml_scanqfile(TRATYP **list,FILE *qfile);
#define ACTTBL "actions" //action tables
#define SESTBL "sessions" //session tables
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to update database information about */
+/* emails echange current and last status. */
+/* */
+/********************************************************/
+PUBLIC _Bool mngact(SQLPTR *sqlptr,ACTTYP *act)
+
+{
+#define OPEP "gessql.c:sql_mngact,"
+
+static const char *del="DELETE FROM "ACTTBL" WHERE sessid=%s AND rcptto=%s";
+static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%d,%s)";
+
+_Bool isok;
+
+isok=false;
+if (act!=(ACTTYP *)0) {
+ char strcode[10];
+ char *goodid;
+ char *goodrcpt;
+ char *goodcode;
+
+ (void) memset(strcode,'\000',sizeof(strcode));
+ strcode[0]=act->code;
+ goodid=sql_gooddata(sqlptr,act->sessid);
+ goodrcpt=sql_gooddata(sqlptr,act->rcptto);
+ goodcode=sql_gooddata(sqlptr,strcode);
+ if (act->resp!=(char **)0) {
+ char *field;
+
+ field="code,sessid,rcptto,numline,info";
+ (void) sql_request(sqlptr,del,goodid,goodrcpt);
+ if (act->resp!=(char **)0) {
+ char **resp;
+ int num;
+
+ resp=act->resp;
+ num=1;
+ while (*resp!=(char *)0) {
+ char *goodinfo;
+
+ goodinfo=sql_gooddata(sqlptr,*resp);
+ (void) sql_request(sqlptr,ins,field,goodcode,goodid,goodrcpt,num,goodinfo);
+ goodinfo=rou_freestr(goodinfo);
+ resp++;
+ num++;
+ }
+ }
+ }
+ goodcode=rou_freestr(goodcode);
+ goodrcpt=rou_freestr(goodrcpt);
+ goodid=rou_freestr(goodid);
+ isok=true;
+ }
+return isok;
+
+#undef OPEP
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to update the database with respond */
+/* Record associated with TRA. */
+/* Return the number of record stored within the */
+/* database. */
+/* */
+/********************************************************/
+PUBLIC int sql_update_tradb(SQLPTR *sqlptr,TRATYP **tralist)
+
+{
+#define OPEP "gesql.c:qlupdate_tradb,"
+
+int num;
+
+num=0;
+if (tralist!=(TRATYP **)0) {
+ while (*tralist!=(TRATYP *)0) {
+ if ((*tralist)->resp!=(char **)0) {
+ ACTTYP action;
+
+ action.sessid=(*tralist)->sessid;
+ action.code=(*tralist)->code;
+ action.rcptto=(*tralist)->rcptto;
+ action.resp=(*tralist)->resp;
+ (void) mngact(sqlptr,&action);
+ num++;
+ }
+ tralist++;
+ }
+ }
+return num;
+
+#undef OPEP
+}
/*
\f
*/
}
return isok;
-#undef OPEP
-}
-/*
-\f
-*/
-/********************************************************/
-/* */
-/* Procedure to update database information about */
-/* emails echange current and last status. */
-/* */
-/********************************************************/
-PUBLIC _Bool sql_mngact(SQLPTR *sqlptr,SQLENUM action,ACTTYP *act)
-
-{
-#define OPEP "gessql.c:sql_mngact,"
-
-static const char *del="DELETE FROM "ACTTBL" WHERE sessid=%s AND rcptto=%s";
-static const char *ins="INSERT INTO "ACTTBL" (%s) VALUES(%s,%s,%s,%d,%s)";
-
-_Bool isok;
-
-isok=false;
-if (act!=(ACTTYP *)0) {
- char strcode[10];
- char *goodid;
- char *goodrcpt;
- char *goodcode;
-
- (void) memset(strcode,'\000',sizeof(strcode));
- strcode[0]=act->code;
- goodid=sql_gooddata(sqlptr,act->sessid);
- goodrcpt=sql_gooddata(sqlptr,act->rcptto);
- goodcode=sql_gooddata(sqlptr,strcode);
- if (act->resp!=(char **)0) {
- char *field;
-
- field="code,sessid,rcptto,numline,info";
- (void) sql_request(sqlptr,del,goodid,goodrcpt);
- if (act->resp!=(char **)0) {
- char **resp;
- int num;
-
- resp=act->resp;
- num=1;
- while (*resp!=(char *)0) {
- char *goodinfo;
-
- goodinfo=sql_gooddata(sqlptr,*resp);
- (void) sql_request(sqlptr,ins,field,goodcode,goodid,goodrcpt,num,goodinfo);
- goodinfo=rou_freestr(goodinfo);
- resp++;
- num++;
- }
- }
- }
- goodcode=rou_freestr(goodcode);
- goodrcpt=rou_freestr(goodrcpt);
- goodid=rou_freestr(goodid);
- isok=true;
- }
-return isok;
-
#undef OPEP
}
/*
#include <stdbool.h>
+#include "unieml.h"
#include "devsql.h"
+//procedure to update transaction information
+extern int sql_update_tradb(SQLPTR *sqlptr,TRATYP **tralist);
+
//procedure to manage information on exiting user
extern _Bool sql_mngusr(SQLPTR *sqlptr,SQLENUM action,char *key,USRTYP **usr);
-//procedure to manage action stats on email exhange status
-extern _Bool sql_mngact(SQLPTR *sqlptr,SQLENUM action,ACTTYP *act);
-
//procedure to manage information on email exchange session
extern _Bool sql_mngses(SQLPTR *sqlptr,SQLENUM action,SESTYP **ses);
#include "unieml.h"
#include "devlog.h"
#include "gestcp.h"
+#include "gessql.h"
#include "geseml.h"
#include "lvleml.h"
ptr++;
}
(void) eml_dump_list_tra(qfile,tralist);
- tralist=eml_freeall_tra(tralist);
+ (void) sql_update_tradb(contact->sqlptr,tralist);
+ tralist=(TRATYP **)rou_freelist((void **)tralist,(genfree_t)eml_freetra);
}
return status;
#undef OPEP
return info;
}
/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to free memory used by the TRATYP */
+/* response part. */
+/* */
+/********************************************************/
+PUBLIC void eml_freetra_resp(TRATYP *tra)
+
+{
+if (tra!=(TRATYP *)0) {
+ tra->resp=(char **)rou_freelist((void **)tra->resp,(genfree_t)rou_freestr);
+ }
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to free memory used by a TRATYP record*/
+/* */
+/********************************************************/
+PUBLIC TRATYP *eml_freetra(TRATYP *tra)
+
+{
+if (tra!=(TRATYP *)0) {
+ (void) eml_freetra_resp(tra);
+ tra->rcptto=rou_freestr(tra->rcptto);
+ tra->mailfrom=rou_freestr(tra->mailfrom);
+ tra->sessid=rou_freestr(tra->sessid);
+ (void) free(tra);
+ tra=(TRATYP *)0;
+ }
+return tra;
+}
+/*
^L
*/
/********************************************************/
//list of keyword
typedef enum { //list of SMTP protocol keyword
- c_auth, //Requesting authentication
- c_data, //DATA email contents transfer request
- c_ehlo, //EHLO command
- c_helo, //Basic Helo command
- c_mail, //'mail from:' sequence detected
- c_noop, //No Operation request
- c_quit, //quit exchange
- c_rcpt, //'rcpt to:' sequence detected
- c_rset, //resetting session
- c_starttls, //Starting a TLS crypted link
- c_unknown //key word unknown
- }CODTYP;
+ c_auth, //Requesting authentication
+ c_data, //DATA email contents transfer request
+ c_ehlo, //EHLO command
+ c_helo, //Basic Helo command
+ c_mail, //'mail from:' sequence detected
+ c_noop, //No Operation request
+ c_quit, //quit exchange
+ c_rcpt, //'rcpt to:' sequence detected
+ c_rset, //resetting session
+ c_starttls, //Starting a TLS crypted link
+ c_unknown //key word unknown
+ }CODTYP;
typedef struct { //*definition of recipient
char code; //'L' rcipient local, 'R' recipient remote
char *userid; //recipient email userid
}RCPTYP;
+//structure to define an email transport directive
+typedef struct {
+ char code; //Transaction code
+ time_t date; //Transaction date
+ u_int delay; //Transaction execution delay
+ char *sessid; //session id
+ char *mailfrom; //Email Originator
+ char *rcptto; //Email Recipient
+ int sendcode; //Email sending status;
+ char **resp; //Transfer response status
+ }TRATYP;
+
//procedure to Free one recipient info
extern RCPTYP *eml_freerecipient(RCPTYP *info);
+//procedure to fee memory used by the resp record within TRATYP structure
+extern void eml_freetra_resp(TRATYP *tra);
+
+//procedure to Free one transaction inf
+extern TRATYP *eml_freetra(TRATYP *tra);
+
//procedure to add recipient to a recipient list
extern _Bool eml_addrecipient(RCPTYP ***list,RCPTYP *rcpt);