devsoc.h devsql.h \
geseml.h gestcp.h
+geseml.h: \
+ unisql.h
+
gestcp.h: \
subrou.h \
unidns.h \
//field available in table "sessions"
const char *sesfield[]={
"sessid",
+ "sesstitle",
"sessfrom",
"emailfrom",
"taille",
+ "duration",
(char *)0
};
#define OPEP "devseql.c:insert_ses,"
#define INSSES "INSERT INTO "SESSIONS" (sessid) VALUES(%s)"
-_Bool isok;
-
-isok=true;
-(void) rou_alert(0,"%s JMPDBG Inserting session <%s>",OPEP,seskey);
-isok=(sqlrequest(sql,INSSES,seskey)==1);
-return isok;
+return (sqlrequest(sql,INSSES,seskey)==1);
#undef INSSES
#undef OPEP
switch (i) {
case 0 : //session ID
break; //nothing to do
- case 1 : //sfrom
+ case 1 : //title
+ data=sql_gooddata(sql,(*ses)->title);
+ break; //nothing to do
+ case 2 : //sfrom
data=sql_gooddata(sql,(*ses)->sfrom);
break; //nothing to do
- case 2 : //efrom
- data=sql_gooddata(sql,(*ses)->efrom);
+ case 3 : //efrom
+ data=sql_gooddata(sql,(*ses)->hfrom);
break;
- case 3 : //taille
+ case 4 : //taille
(void) rou_asprintf(&data,"%lu",(*ses)->taille);
break;
+ case 5 : //duration
+ data=sql_gooddata(sql,(*ses)->duration);
+ break;
default :
isok=false;
(void) rou_alert(0,"%s Unexpected field <%s> (Bug?)",OPEP,sesfield[i]);
if (strlen(cmtset)>0)
sep=",";
(void) rou_asprintf(&newset,"%s%s%s=%s",cmtset,sep,sesfield[i],data);
- data=rou_freestr(data);
cmtset=rou_freestr(cmtset);
cmtset=newset;
+ data=rou_freestr(data);
}
}
if (isok==true)
}
break;
case 1 : //Preparing attachement email
- (void) fprintf(qout,"%s%s Email daemon <%s>\n",EFROM,APPNAME,orig);
+ (void) fprintf(qout,"%s%s Email daemon <%s>\n",HFROM,APPNAME,orig);
(void) fprintf(qout,"To: <%s>\n",tra->mailfrom);
(void) fprintf(qout,"Date: %s\n",rou_ascsysstamp(time((time_t *)0)));
- (void) fprintf(qout,"Subject: %s\n",*(tra->resp)+4);
+ (void) fprintf(qout,"%s%s\n",HTITLE,*(tra->resp)+4);
break;
case 2 : //attaching (200 line at most) from email itself
done=eml_attache(qout,tra->sessid,tra->resp,200);
#undef OPEP
}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to check email header and extract */
+/* session data. */
+/* Return true if data was extracted. */
+/* */
+/********************************************************/
+PUBLIC _Bool eml_scan_headerline(SESTYP *session,const char *line)
+
+{
+#define OPEP "geseml.c:eml_scan_headerline,"
+_Bool extracted;
+
+const char *look[]={HFROM,HTITLE,(char *)0};
+
+extracted=false;
+if ((line!=(char *)0)&&(strlen(line)>0)) {
+ for (int i=0;(extracted==false)&&(look[i]!=(char *)0);i++) {
+ int max;
+
+ max=strlen(look[i]);
+ if (strncasecmp(line,look[i],max)==0) {
+ extracted=true;
+ switch (i) {
+ case 0 : //Inserting the header from in session
+ session->hfrom=rou_freestr(session->hfrom);
+ session->hfrom=strdup(line+max);
+ break;
+ case 1 : //Inserting the header from in session
+ session->title=rou_freestr(session->title);
+ session->title=strdup(line+max);
+ break;
+ default :
+ (void) rou_alert(0,"%s Code missing for Head entrey <%s> (Bug?!)",
+ OPEP,look[i]);
+ break;
+ }
+ }
+ }
+ }
+return extracted;
+
+#undef OPEP
+}
#include <stdio.h>
#include <time.h>
+#include "unisql.h"
+
//structure to define an email transport directive
typedef struct {
char code; //Transaction code
//procedure to build a warning/reply from the transfer record
extern _Bool eml_do_warning(TRATYP *tra);
+//procedure to scan on line from email header
+extern _Bool eml_scan_headerline(SESTYP *session,const char *line);
+
#endif
}
total+=got;
if (inheader==true) {
+ (void) eml_scan_headerline(contact->session,line);
if (strlen(line)==0)
inheader=false;
- else { //extracting the sfrom
- int max;
-
- max=strlen(EFROM);
- if (strncasecmp(line,EFROM,max)==0) {
- contact->session->efrom=rou_freestr(contact->session->efrom);
- contact->session->efrom=strdup(line+max);
- }
- }
}
if (strcmp(line,".")==0) {
completed=true;
case 8 : //everything fine
const char *fmt;
unsigned int delta;
+ char duration[40];
total+=1023;
total/=1024; //KBytes
delta=rou_getdifftime(&start);
+ (void) snprintf(duration,sizeof(duration),"%d.%03d",delta/1000,delta%1000);
+ contact->session->duration=strdup(duration);;
fmt="%d-3.5.3 Session ID=<%s>";
(void) transmit(contact,false,fmt,CMDOK,contact->session->sessid);
- fmt="%d-3.5.3 data stream received: %d Kbytes within %d.%03d seconds)";
- (void) transmit(contact,false,fmt,CMDOK,total,delta/1000,delta%1000);
+ fmt="%d-3.5.3 data stream received: %d Kbytes within %s seconds)";
+ (void) transmit(contact,false,fmt,CMDOK,total,duration);
fmt="%d 3.5.3 Message accepted for delivery";
(void) transmit(contact,true,fmt,CMDOK,contact->session->sessid);
done=true;
#include <stdio.h>
-#define EFROM "From: " //Then email header from
+#define HFROM "From: " //Then email header header from
+#define HTITLE "Subject: " //Then email subject entry
#define MXMSIZE 52428800 //52 Megabytes
#define CRLF "\r\n" //EOL within SMTP protocol
{
if (ses!=(SESTYP *)0) {
- ses->efrom=rou_freestr(ses->efrom);
+ ses->duration=rou_freestr(ses->duration);
+ ses->hfrom=rou_freestr(ses->hfrom);
ses->sfrom=rou_freestr(ses->sfrom);
ses->sessid=rou_freestr(ses->sessid);
(void) free(ses);
//with a remote server
typedef struct {
char *sessid; //session id
+ char *title; //the email title
char *sfrom; //the "mail from" comming from SMTP exchange
- char *efrom; //the "mail from" as within the email itself
+ char *hfrom; //the "mail from" as within the email header
+ char *duration; //Session duration un millisec
u_long taille; //Email size
}SESTYP;
//table about session
CREATE TABLE sessions (
sessid TEXTUNIQUE, //Session id
+ sesstitle TEXT, //The session email title
sessfrom TEXT, //The session from
emailfrom TEXT, //The from within the email itself
taille INTEGER //The email size
- DFLT 0
+ DFLT 0,
+ duration TEXT //email transfer duration
+ DFLT 'NULL'
);
GRANT SELECT ON sessions TO mailapache;