*/
/********************************************************/
/* */
+/* procedure to can a list of todo file. */
+/* */
+/********************************************************/
+static void sending(int argc,char *argv[])
+
+{
+#define OPEP "sender.c:sending,"
+#define TODO "todo"
+
+unsigned long cycle;
+char **list;
+int delay;
+int phase;
+_Bool proceed;
+
+cycle=0;
+list=(char **)0;
+delay=20;
+if (debug>0)
+ delay/=10;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //Build list from argv;
+ if (argc>0) {
+ for (int i=0;i<argc;i++)
+ list=(char **)rou_addlist((void **)list,(void *)strdup(argv[i]));
+ phase++; //No nee to build list
+ foreground=true;//on pass only
+ }
+ break;
+ case 1 : //building the list according directory contents
+ list=eml_getqfilelist(list,TODO);
+ break;
+ case 2 : //do we have a list
+ if (list!=(char **)0) {
+ int num;
+ char **scan;
+
+ num=0;
+ scan=list;
+ while (*scan!=(char *)0) {
+ char *fname;
+ char *ptr;
+
+ fname=*scan;
+ (void) prc_settitle("%s sending <%s>",appname,fname);
+ (void) rou_alert(0,"%s fname file <%s>",OPEP,fname);
+ if ((ptr=strrchr(fname,'.'))==(char *)0) {
+ (void) rou_alert(0,"%s unable to find <%s> extension",OPEP,fname);
+ break;
+ }
+ *ptr='\000';
+ ptr++;
+ if (strcmp(ptr,EXTODO)!=0) {
+ (void) rou_alert(0,"%s wrong extension for file <%s.%s>",
+ OPEP,fname,ptr);
+ break;
+ }
+ (void) rou_alert(0,"%s scanning file <%s>",appname,fname);
+ if (scantodo(fname)==false)
+ break;
+ scan++;
+ num++;
+ }
+ list=(char **)rou_freelist((void **)list,(genfree_t)rou_freestr);
+ (void) rou_alert(0,"%s Scanned '%d' files",OPEP,num);
+ (void) usleep(10000);
+ phase=0;
+ }
+ break;
+ case 3 : //do we need to loop again
+ phase=0; //Lets say looping requested
+ cycle++;
+ (void) prc_settitle("%s sleeping mode (cycle=%08d)",appname,cycle);
+ (void) sleep(delay);
+ if ((hangup==true)||((reload==true))) {
+ (void) rou_alert(0,"%s got hangup or reload signal",OPEP);
+ phase=999;
+ }
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+
+#undef TODO
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Main routine */
/* Start a channel to a remote ip.port */
/* read file and transmit contecnts to */
proceed=false; //no need to go further
}
break;
- case 1 : //do we have a parameter
- if (params->argc<=0) {
- (void) rou_alert(0,"%s todo filename missing (exiting)",SENDER);
- proceed=false; //no need to go further
- }
- break;
- case 2 : //Preparing scan
+ case 1 : //Preparing scan
+ (void) prc_preptitle(argc,argv,environ);
(void) rou_setappname(SENDER);
(void) rou_modesubrou(true);
(void) sig_modeunisig(true);
phase=999; //direct exit
}
break;
- case 3 : //scanning parameters list
- if (params!=(ARGTYP *)0) { //always
- int num;
-
- num=0;
- while (num<params->argc) {
- char *fname;
- char *ptr;
-
- fname=params->argv[num];
- (void) rou_alert(0,"%s fname file <%s>",OPEP,fname);
- if ((hangup==true)||(reload==true))
- break;
- if ((ptr=strrchr(fname,'.'))==(char *)0) {
- (void) rou_alert(0,"%s unable to find <%s> extension",OPEP,fname);
- break;
- }
- *ptr='\000';
- ptr++;
- if (strcmp(ptr,EXTODO)!=0) {
- (void) rou_alert(0,"%s wrong extension for file <%s.%s>",
- OPEP,fname,ptr);
- break;
- }
- (void) rou_alert(0,"%s scanning file <%s>",appname,fname);
- if (scantodo(fname)==false)
- break;
- num++;
- }
+ case 2 : //locking process
+ if (prc_locking(appname,true,5)==false) {
+ (void) rou_alert(0,"%s Unable to lock %s exclusif acccess (system?)",
+ OPEP,appname);
+ proceed=false;
}
break;
+ case 3 : //sending email
+ (void) sending(params->argc,params->argv);
+ break;
+ case 4 : //Unlocking access
+ (void) prc_locking(appname,false,1);
+ break;
default : //end of task
+ (void) prc_cleantitle();
params=par_freeparams(params);
(void) rou_loadconfig(config,false);
(void) sig_modeunisig(false);