/* Log management implementation module */
/* */
/********************************************************/
+#include <linux/limits.h>
#include <sys/file.h>
#include <errno.h>
#include <malloc.h>
#include "devlog.h"
#define JRLDIR "/var/spool/"APPNAME
-#define IJRLDIR JRLDIR"/receiver-logs/"
-#define OJRLDIR JRLDIR"/sender-logs/"
-
typedef struct {
char *filename; //the log filename
/* return a NULL file pointeur if trouble. */
/* */
/********************************************************/
-PUBLIC LOGPTR *log_openlog(char *logname,_Bool inlog,const char *cmt)
+PUBLIC LOGPTR *log_openlog(char *logname,const char *cmt)
{
#define OPEP "devlog.c:log_openlog"
LOGTYP *log;
-const char *logdir;
+char logdir[PATH_MAX];
int phase;
int proceed;
log=(LOGTYP *)0;
-logdir=OJRLDIR;
-if (inlog==true)
- logdir=IJRLDIR;
+(void) snprintf(logdir,sizeof(logdir),"%s/%s-logs/",JRLDIR,execname);
phase=0;
proceed=true;
while (proceed==true) {
typedef void LOGPTR;
//procedure to open a session log
-extern LOGPTR *log_openlog(char *logname,_Bool inlog,const char *cmt);
+extern LOGPTR *log_openlog(char *logname,const char *cmt);
//procedure to close a previously open session log
extern LOGPTR *log_closelog(LOGPTR *logptr);
}
contact->peername=soc_getaddrinfo(contact->socptr,false,true);
contact->peerip=soc_getaddrinfo(contact->socptr,false,false);
- contact->logptr=log_openlog(contact->mainsesid,true,(const char *)0);
+ contact->logptr=log_openlog(contact->mainsesid,(const char *)0);
contact->localafn=afn_getipnum(contact->locip);
(void) rou_alert(0,"Contact from peer <%s> to port <%s> started",
contact->peerip,contact->locserv);
if (ptr!=(char *)0)
*ptr='\000';
(void) snprintf(cmt,sizeof(cmt),"main-session-id=%s",mainsesid);
- logptr=log_openlog(mainsesid,false,cmt);
+ logptr=log_openlog(mainsesid,cmt);
mainsesid=rou_freestr(mainsesid);
break;
case 3 : //sending all email within transaction
PUBLIC char *rootdir=(char *)0;//working directory (debugging)
PUBLIC char *appname; //application "official" name
+//application binary name
+PUBLIC char execname[20]=APPNAME;
+
//static variables
static _Bool modopen; //boolean module open/close
return name;
}
/*
+^L
+*/
+/********************************************************/
+/* */
+/* Returne set a new exec/binary name. */
+/* logs. */
+/* */
+/********************************************************/
+PUBLIC const char *rou_setexecname(const char *newexecname)
+
+{
+(void) memset(execname,'\000',sizeof(execname));
+(void) strncpy(execname,newexecname,sizeof(execname)-1);
+return execname;
+}
+/*
\f
*/
/********************************************************/
extern char *rootdir; //application root directory
extern char *appname; //application "official" name
+extern char execname[]; ///Application exec/binary name
//--- Routines implemented within subrou.c ---------
//change the application name
extern char *rou_setappname(const char *newname);
+//change the execname name
+extern const char *rou_setexecname(const char *newexecname);
+
//to compute an application path with the root directory
extern char *rou_apppath(const char *path);
shortname=argv[0];
else
shortname++;
+(void) rou_setexecname(shortname);
opterr=0; //no error message from getopt library routine
while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
switch(c) {