]> SAFE projects GIT repository - jmp/mailleur/commitdiff
clarified the foreground mode usage
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 9 Jul 2024 05:49:01 +0000 (01:49 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 9 Jul 2024 05:49:01 +0000 (01:49 -0400)
app/maild.c
lib/subrou.c
lib/subrou.h
lib/unipar.c

index a90cfad1beeb9ab09861bd85f0fcb643ff03640d..6666fd876c52a2b06938e03c690c8fb6aa7a3aad 100644 (file)
@@ -42,15 +42,15 @@ phase=0;
 proceed=true;
 while (proceed==true) {
   switch (phase) {
-    case 0      :       //initialising process
-      (void) rou_modesubrou(true);
-      (void) uni_modeunipar(true);
-      break;
-    case 1      :       //checking parameters
-      if ((params=par_getparams(argc,argv,"d:hr:v"))==(ARGTYP *)0) {
+    case 0      :       //checking parameters
+      if ((params=par_getparams(argc,argv,"d:fhr:v"))==(ARGTYP *)0) {
         phase=999;      //no need to go further
         }
       break;
+    case 1      :       //initialising process
+      (void) rou_modesubrou(true);
+      (void) uni_modeunipar(true);
+      break;
     default     :       //end of task
       (void) uni_modeunipar(false);
       (void) rou_modesubrou(false);
index 0414c097900e3a544025d582ba3f1f4c3968586b..4dfdcaeb8771d3571e56cd98a13507ecee25a665 100644 (file)
@@ -14,7 +14,7 @@
 
 //version definition 
 #define VERSION "0.1"
-#define RELEASE "7"
+#define RELEASE "8"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level
@@ -153,8 +153,6 @@ if (mode!=modopen) {
   switch ((int)mode) {
     case true     :
       debug=0;
-      //application started in background mode by default
-      foreground=false;
       off64_time=(time_t)0;
       off_date=(time_t)0;
       if (appname!=(char *)0)
index 5444a60e461243a34613cedb875ac07d4dc257fe..316319af40a8bf2f5090d294e231f43e8a33d32a 100644 (file)
@@ -12,7 +12,7 @@
 #include       <stdarg.h>
 
 
-#define APPNAME "mailled"        //application name
+#define APPNAME "maild"         //application name
 
 //---   Variables defined within subrou.c       ---------
 extern int             debug;  //application debug mode
index 8ad1745a99b65dcab8d1a0f6c6bcc70e840d03b0..551387ca3133d8abd65cba43cee43cebea95c6c8 100644 (file)
@@ -44,91 +44,22 @@ return params;
 static void usage_aid(char *name)
 
 {
-(void) fprintf(stderr,"%s-%s\n",name,rou_getversion());
 (void) fprintf(stderr,"usage:\n  ");
 (void) fprintf(stderr,"%s\t"
                  "[-d debug] "
+                 "[-f] "
                  "[-h] "
                  "[-r root] "
                  "[-v] "
                   "\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-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");
 (void) fprintf(stderr,"\t\t-v\t\t: Print program version number\n");
 }
 /*
-\f
-*/
-/********************************************************/
-/*                                                     */
-/*     Display aidobj usage parameter                  */
-/*                                                     */
-/********************************************************/
-static void usage_obj(char *name)
-
-{
-(void) fprintf(stderr,"%s-%s\n",name,rou_getversion());
-(void) fprintf(stderr,"usage:\n  ");
-(void) fprintf(stderr,"%s\t"
-                 "[-d debug] "
-                 "[-h] "
-                 "[-r root] "
-                 "[-v] "
-                  "\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-h\t\t: print this help message\n");
-(void) fprintf(stderr,"\t\t-r root\t\t: root working directory\n");
-(void) fprintf(stderr,"\t\t-v\t\t: Print program version number\n");
-}
-/*
-\f
-*/
-/********************************************************/
-/*                                                     */
-/*     Display a list of parameters available according*/
-/*     the name used to call the backd program         */
-/*                                                     */
-/********************************************************/
-static int usage(char *name)
-
-{
-static  char *prg[]={
-                    "aid",
-                    "aidhud",
-                    "aidobj",
-                    (char *)0
-                    };
-int status;
-int seq;
-char *shortname;
-
-status=0;
-if ((shortname=strrchr(name,'/'))==(char *)0) 
-  shortname=name;
-else
-  shortname++;
-for (seq=0;prg[seq]!=(char *)0;seq++) {
-  if (strcmp(prg[seq],shortname)==0)
-    break;
-  }
-switch (seq) {
-  case  0       :       //aid
-  case  1       :       //aidhud
-    (void) usage_aid(name);
-    break;
-  case  2       :       //aidobj
-    (void) usage_obj(name);
-    break;
-  default       :
-    (void) usage_aid(name);     //unexpected default!
-    break;
-  }
-return status;
-}
-/*
 ^L
 */
 /********************************************************/
@@ -171,9 +102,14 @@ ARGTYP *par_getparams(int argc,char * const argv[],const char *optstring)
 
 {
 ARGTYP *params;
+char *shortname;
 int c;
 
 params=initparams();
+if ((shortname=strrchr(argv[0],'/'))==(char *)0) 
+  shortname=argv[0];
+else
+  shortname++;
 opterr=0;               //no error message from getopt library routine
 while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
   switch(c) {
@@ -181,11 +117,13 @@ while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
       debug=atoi(optarg);
       (void) rou_alert(1,"debug level is now '%d'",debug);
       break;
-    case 'f'   :       //foreground mode
+    case 'f'   :       //background/daemon mode
       foreground=true;
+      (void) fprintf(stderr,"%s-%s, foreground mode requested\n",shortname,rou_getversion());
       break;
     case 'h'   :       //requestion program help
-      (void) usage(argv[0]);
+      (void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion());
+      (void) usage_aid(shortname);
       params=par_freeparams(params);
       break;
     case 'r'   :
@@ -194,12 +132,14 @@ while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
       rootdir=strdup(optarg);
       break;
     case 'v'   :
-      (void) fprintf(stderr,"%s Version <%s>\n",argv[0],rou_getversion());
+      (void) fprintf(stderr,"%s:\tVersion <%s>\n",shortname,rou_getversion());
       (void) exit(0);           //just display version
       break;
     default    :
-      (void) usage(argv[0]);
-      (void) rou_alert(0,"\"%s\" unexpected argument designator",argv[optind-1]);
+      (void) fprintf(stderr,"%s-%s\n",shortname,rou_getversion());
+      (void) fprintf(stderr,"\"%s\" unexpected argument designator\n\n",
+                            argv[optind-1]);
+      (void) usage_aid(shortname);
       params=par_freeparams(params);
       break;
     }