OBJS= \
modrec.o \
lvleml.o \
- gesspf.o gestcp.o geseml.o \
+ geseml.o gestcp.o gesspf.o gessql.o \
devlog.o devsoc.o devsql.o \
unidig.o unidns.o unieml.o unipar.o \
uniprc.o unisig.o unisql.o unitls.o \
lvleml.o: \
subcnv.h subrou.h \
unidig.h unidns.h unieml.h \
+ gestcp.h gessql.h \
lvleml.h lvleml.c
gesspf.o: \
unisig.h \
gestcp.h gestcp.c
+gessql.o: \
+ devsql.h \
+ gessql.h gessql.c
+
devlog.o: \
subrou.h \
uniprc.h \
#undef DELACT
#undef OPEP
}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to lock access to a table. */
+/* */
+/********************************************************/
+PUBLIC _Bool sql_locktable(SQLPTR *sqlptr,char *tblname,_Bool action)
+
+{
+return action;
+}
//procedure to manage action stats on email exhange status
extern _Bool sql_mngact(SQLPTR *sqlptr,SQLENUM action,ACTTYP *act);
+//procedure to locak access to a full table
+extern _Bool sql_locktable(SQLPTR *sqlptr,char *tblname,_Bool action);
+
#endif
--- /dev/null
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/* */
+/* Module to manage complexe SQL request */
+/* */
+/********************************************************/
+
+#include "subrou.h"
+#include "gessql.h"
+
+#define REMOTES "remotes" //Table about remotes site
+
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to increase (of decrease the remote */
+/* IP connection number. */
+/* */
+/********************************************************/
+PUBLIC int sql_newconnect(SQLPTR *sqlptr,char *rmtip,int delta)
+
+{
+#define OPEP "gessql.c:sql_newconnect,"
+
+int links;
+_Bool locked;
+SMTTYP *smtpdata;
+int phase;
+_Bool proceed;
+
+links=0;
+locked=false;
+smtpdata=(SMTTYP *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //Locking table
+ if ((locked=sql_locktable(sqlptr,REMOTES,true))==false) {
+ (void) rou_alert(0,"%s Unable to lock %s table (Bug?)",
+ OPEP,REMOTES);
+ phase=999; //Trouble trouble
+ }
+ break;
+ case 1 : //loading record
+ break;
+ case 2 : //creating record if not exiting
+ break;
+ case 3 : //updating record
+ smtpdata->links+=delta;
+ links=smtpdata->links;
+ smtpdata=sql_freesmtp(smtpdata);
+ break;
+ default : //SAFE Guard
+ if (locked==true)
+ (void) sql_locktable(sqlptr,REMOTES,false);
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return links;
+#undef OPEP
+}
--- /dev/null
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/************************************************/
+/* */
+/* gestion level fto manage sql request */
+/* */
+/************************************************/
+#ifndef GESSQL
+#define GESSQL
+
+#include <stdbool.h>
+
+#include "devsql.h"
+
+//Procedure to increment (or decrement) the remoteip
+//connection number
+extern int sql_newconnect(SQLPTR *sqlptr,char *rmtip,int delta);
+#endif
// vim: smarttab tabstop=8 shiftwidth=2 expandtab
/********************************************************/
/* */
-/* Module to handle TCP communication */
+/* Module to manage TCP communication */
/* */
/********************************************************/
#include <sys/wait.h>
// vim: smarttab tabstop=8 shiftwidth=2 expandtab
/************************************************/
/* */
-/* Unit level to handle TCP communication */
+/* gestion level to handle TCP */
+/* communication */
/* */
/************************************************/
#ifndef GESTCP
#include "unieml.h"
#include "unisig.h"
#include "devsoc.h"
+#include "gessql.h"
#include "gestcp.h"
#include "lvleml.h"
#include "modrec.h"
//(void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
switch (phase) {
case 0 : //waiting contact
- (void) rou_checkleak(true);
if ((contact=eml_getcontact(socptr,pos))==(CONTYP *)0)
phase=999; //No contact!
break;
case 1 : //within forked process
(void) prc_settitle("%s, incoming contact from [%s] on [%s:%s]",
- appname,contact->peerip,contact->locname,contact->locserv);
+ appname,contact->peerip,
+ contact->locname,contact->locserv);
+ if (sql_newconnect(contact->sqlptr,contact->peerip,1)>1) {
+ phase=999; //need to explain no contact;
+ }
break;
case 2 : //do contact
intstat=eml_docontact(contact);
}
break;
case 4 : //connection terminated
- contact=eml_dropcontact(contact);
- (void) rou_checkleak(false);
break;
default : //SAFE guard
+ if (contact!=(CONTYP *)0)
+ contact=eml_dropcontact(contact);
proceed=false;
break;
}
*/
/********************************************************/
/* */
-/* Procedure to free memory used by a usesion */
+/* Procedure to free memory used by a session */
/* definition. */
/* */
/********************************************************/
/*
\f
*/
+/********************************************************/
+/* */
+/* Procedure to free memory used by a remote SMTP */
+/* data record definition. */
+/* */
+/********************************************************/
+PUBLIC SMTTYP *sql_freesmtp(SMTTYP *smtpdata)
+
+{
+if (smtpdata!=(SMTTYP *)0) {
+ smtpdata->status=rou_freestr(smtpdata->status);
+ smtpdata->rmtip=rou_freestr(smtpdata->rmtip);
+ (void) free(smtpdata);
+ smtpdata=(SMTTYP *)0;
+ }
+return smtpdata;
+}
+/*
+\f
+*/
/************************************************/
/* */
/* Routine to check if string is properly */
u_long taille; //Email size
}SESTYP;
-//Tructure about email action status (managing email)
+//Structure about email action status (managing email)
typedef struct {
char *sessid; //session id
char code; //Email status code
char **resp; //Multiline status
}ACTTYP;
+//Structure about remotes SMTP server
+typedef struct {
+ time_t lupdate; //last update time
+ char *rmtip; //Remote IP number
+ int links; //Number of connection from this remote
+ int credit; //Remote credit number
+ char *status; //Remote record current status
+ }SMTTYP;
+
//procedure to free space used by an USRTYP
extern USRTYP *sql_freeusr(USRTYP *usr);
//procedure to free memory used by a SESTYP
extern SESTYP *sql_freeses(SESTYP *ses);
+//procedure to free memory used by a SMTTYP
+extern SMTTYP *sql_freesmtp(SMTTYP *smtpdata);
+
//Procedure to check if string is properly coded according DB_LANG
extern char *sql_checkencoding(char *strencoded);
lastupdate DBTIMESTAMP //record creation
DFLT NOW(),
remoteip TEXTUNIQUE, //remote IP number
- connections INTEGER
- DFLT 1, //how many time the remote connected
+ links INTEGER
+ DFLT 0, //how many time the remote connected
credit INTEGER //Remote IP current credit (-100..+100)
DFLT -100,
status TEXT //'toscan','inscan','valide'