#testing feed
FEEDPAR = \
-d3 \
+ -c ./conf/feeder.conf.dvl \
$(TESTIP) \
$(TESTPORT) \
$(TESTDIR)/$(DATATST)/feed*.tst \
EMLPAR = \
-r $(TESTDIR) \
+ -c ./conf/$(APPNAME).conf.dvl \
-d 3 \
$(TESTPROT):$(TESTIP):$(TESTPORT):
while (proceed==true) {
switch (phase) {
case 0 : //checking parameters
- if ((params=par_getparams(argc,argv,"d:fh:r:v"))==(ARGTYP *)0) {
+ if ((params=par_getparams(argc,argv,"c:d:fh:r:v"))==(ARGTYP *)0) {
phase=999; //no need to go further
}
break;
case 1 : //initialising process
(void) prc_preptitle(argc,argv,environ);
(void) rou_setappname(RECNAME);
+ (void) rou_loadconfig(config,true);
(void) rou_modesubrou(true);
(void) prc_modeuniprc(true);
(void) sig_modeunisig(true);
(void) sig_modeunisig(false);
(void) prc_modeuniprc(false);
(void) rou_modesubrou(false);
+ (void) rou_loadconfig(config,false);
break;
default : //end of task
proceed=false;
--- /dev/null
+#file used to set environement configuration
#file used to set environement configuration
+#------------------------------------------------
+#Defining Certificate for the application
+CA_ROOT = "/etc/pki/mailleur/certs/root-safe_CA.pem"
+CA_CERT = "/etc/pki/mailleur/mailleur-chain-cert_x509.pem"
+CA_KEY = "/etc/pki/mailleur/mailleur-key.pem"
+#------------------------------------------------
--- /dev/null
+#file used to set environment configuration
+#Used for developpement purpose ONLY
+#------------------------------------------------
+#Defining Certificate
+CA_ROOT = "./certs/root-safe_CA.pem"
+CA_CERT = "./certs/mailleur_server-chain-cert_x509.pem"
+CA_KEY = "./certs/mailleur_server-key.pem"
+#------------------------------------------------
#undef COREDELAY
}
/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to load the configuartion file */
+/* message and terminate application */
+/* */
+/********************************************************/
+PUBLIC void rou_loadconfig(char *conffile,_Bool load)
+
+{
+FILE *fichier;
+char line[200];
+char *name;
+char *value;
+char *ptr;
+int phase;
+_Bool proceed;
+
+fichier=(FILE *)0;
+(void) memset(line,'\000',sizeof(line));
+name=(char *)0;
+value=(char *)0;
+ptr=(char *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //Opening the config file
+ if ((fichier=fopen(conffile,"r"))==(FILE *)0) {
+ (void) fprintf(stdout,"exiting!, Unable to open file <%s> (error=<%s>)\n",
+ conffile,strerror(errno));
+ (void) exit(-1);//Big Trouble
+ }
+ break;
+ case 1 : //scanning file
+ (void) memset(line,'\000',sizeof(line));
+ if ((ptr=fgets(line,sizeof(line)-1,fichier))==(char *)0)
+ phase=999; //scan terminated
+ break;
+ case 2 : //trimming line
+ if ((ptr=strchr(line,'#'))!=(char *)0)
+ *ptr='\000';
+ if ((ptr=strrchr(line,'\n'))!=(char *)0)
+ *ptr='\000';
+ if (strlen(line)==0)
+ phase=0; //next line
+ break;
+ case 3 : //Spliting data
+ if ((ptr=strchr(line,'='))==(char *)0)
+ phase=0; //line without '='
+ break;
+ case 4 : //set name and value
+ name=line;
+ value=ptr+1;
+ *ptr='\000';
+ while ((ptr=strrchr(name,' '))!=(char *)0)
+ *ptr='\000';
+ while ((ptr=strrchr(name,'\t'))!=(char *)0)
+ *ptr='\000';
+ while ((value[0]==' ')||(value[0]=='\t'))
+ value++;
+ //removing quote if present
+ if (value[0]=='"')
+ value++;
+ if ((ptr=strrchr(value,'"'))!=(char *)0)
+ *ptr='\000';
+ //make sure we have data to set
+ if ((strlen(name)==0)||(strlen(value)==0))
+ phase=0; //No name or value??
+ break;
+ case 5 : //set name and value
+ if (load==true)
+ (void) setenv(name,value,true);
+ else
+ (void) unsetenv(name);
+ phase=0;
+ break;
+ default : //SAFE Guard
+ (void) fclose(fichier);
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+}
+/*
^L
*/
/********************************************************/
//with an explication message
extern void rou_core_dump(const char *fmt,...);
+//load/unload environement configuration
+extern void rou_loadconfig(char *conffile,_Bool load);
+
//homework to be done before starting/stoping module.
extern int rou_modesubrou(_Bool mode);
#include "subrou.h"
#include "unipar.h"
+//application default config file
+PUBLIC char config[200]="/etc/"APPNAME"/"APPNAME".conf";
+
/*
^L
*/
(void) fprintf(stderr,"usage:\n ");
(void) fprintf(stderr,"%s\t"
"[-d debug] "
+ "[-c config] "
"[-f] "
"[-h] "
"[-r root] "
"\n",name);
(void) fprintf(stderr,"\twhere:\n");
(void) fprintf(stderr,"\t\t-d level\t: debug level [1-10]\n");
+(void) fprintf(stderr,"\t\t-c config\t: set config file\n");
(void) fprintf(stderr,"\t\t-f\t\t: start program in foreground (CLI) mode\n");
(void) fprintf(stderr,"\t\t-h\t\t: print this help message\n");
(void) fprintf(stderr,"\t\t-r root\t\t: root working directory\n");
opterr=0; //no error message from getopt library routine
while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
switch(c) {
+ case 'c' : //config file
+ (void) memset(config,'\000',sizeof(config));
+ (void) strncpy(config,optarg,sizeof(config)-1);
case 'd' : //debug level
debug=atoi(optarg);
(void) rou_alert(1,"debug level is now '%d'",debug);
char **argv; //list of argument
}ARGTYP;
+extern char config[]; //Application config file
+
//free allocated memory used by a ARGTYP structure
extern ARGTYP *par_freeparams(ARGTYP *params);