From: Jean-Marc Pigeon (Delson) Date: Wed, 13 Aug 2025 19:24:36 +0000 (-0400) Subject: Code to update event tables seems to be working X-Git-Tag: tag-0.15~14 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=95bb690df8e521e2fa0108ff9578fcce19c056fb;p=jmp%2Fmailleur Code to update event tables seems to be working --- diff --git a/lib/devlog.c b/lib/devlog.c index 8918a84..c58aa14 100644 --- a/lib/devlog.c +++ b/lib/devlog.c @@ -126,7 +126,6 @@ while (proceed==true) { case 5 : //Setting file position (void) fseek(fevent,(long)0,SEEK_END); *debut=ftell(fevent); //First char position - (void) rou_alert(0,"%s JMPDBG debut='%d'",OPEP,*debut); break; case 6 : { //merging file char ch; @@ -137,7 +136,6 @@ while (proceed==true) { case 7 : //unlocking file (void) flock(fileno(fevent),LOCK_UN); *fin=ftell(fevent)-1; //Last char Position - (void) rou_alert(0,"%s JMPDBG fin='%d'",OPEP,*fin); (void) fclose(fevent); (void) fclose(flog); } diff --git a/lib/gessql.c b/lib/gessql.c index 9721157..24d6f6e 100644 --- a/lib/gessql.c +++ b/lib/gessql.c @@ -17,6 +17,7 @@ #define RMTTBL "remotes" //Table about remotes site #define ACTTBL "actions" //action tables #define SESTBL "sessions" //session tables +#define EVTTBL "events" //events tables //field available in table "remotes" static const FLDTYP usrfield[]={ @@ -831,7 +832,6 @@ return isok; #undef OPEP } - /* */ @@ -900,3 +900,32 @@ return rmtip; #undef DATLIM #undef OPEP } +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to add an event reference within the */ +/* data-base event table. */ +/* */ +/********************************************************/ +PUBLIC int sql_addevent(SQLPTR *sqlptr,char *session,int debut,int fin) + +{ +static char *ins="INSERT INTO "EVTTBL" (sessid,start,stop) values(%s)"; + +int done; + +done=-1; +if (sqlptr!=(SQLPTR *)0) { + char *goodses; + char *values; + + goodses=sql_gooddata(sqlptr,session); + (void) rou_asprintf(&values,"%s,%d,%d",goodses,debut,fin); + done=sql_request(sqlptr,ins,values); + values=rou_freestr(values); + goodses=rou_freestr(goodses); + } +return done; +} diff --git a/lib/gessql.h b/lib/gessql.h index a0e224b..0454130 100644 --- a/lib/gessql.h +++ b/lib/gessql.h @@ -32,4 +32,8 @@ extern _Bool sql_mngremote(SQLPTR *sqlptr,SQLENUM action,char *key,SRVTYP **srv) //procedure to collect a list of "to be checked" remote IP extern char **sql_getnewrmtip(SQLPTR *sqlptr,int frequency); + +//procedure to create a new event entry +extern int sql_addevent(SQLPTR *sqlptr,char *session,int debut,int fin); + #endif diff --git a/lib/lvleml.c b/lib/lvleml.c index 24cc377..7824c28 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -113,9 +113,10 @@ if (contact!=(CONTYP *)0) { debut=0; fin=0; (void) freesessid(contact); - contact->termend=rou_freestr(contact->termend); contact->logptr=log_closelog(contact->logptr,&debut,&fin); + (void) sql_addevent(contact->sqlptr,contact->mainsesid,debut,fin); contact->sqlptr=sql_closesql(contact->sqlptr); + contact->termend=rou_freestr(contact->termend); contact->relayok=(AFNTYP **)rou_freelist((void **)contact->relayok, (genfree_t)afn_freeipnum); contact->recipients=(RCPTYP **)rou_freelist((void **)contact->recipients,