merge from head
authorMiloš Mulač <mulac@civ.zcu.cz>
Wed, 6 Jun 2007 15:13:27 +0000 (15:13 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Wed, 6 Jun 2007 15:13:27 +0000 (15:13 +0000)
- remove dependency on option order

org.glite.lb.client/examples/job_reg.c

index b9300eb..f8dd497 100644 (file)
@@ -14,7 +14,7 @@ extern int opterr,optind;
 
 static void usage(char *me)
 {
-       fprintf(stderr,"usage: %s [-m bkserver] [-x] [-j dg_jobid] [-s source_id] [-n num_subjobs [-S][-C]] [-l jdl_file] [-e seed]\n", me);
+       fprintf(stderr,"usage: %s [-m bkserver] [-x] [-j dg_jobid] [-s source_id] [-n num_subjobs [-S][-C]] [-P] [-l jdl_file] [-e seed]\n", me);
 }
 
 int main(int argc, char *argv[])
@@ -36,8 +36,8 @@ int main(int argc, char *argv[])
                        case 'j': job = (char *) strdup(optarg); break;
                        case 'm': server = strdup(optarg); break;
                        case 'n': num_subjobs = atoi(optarg); break;
-                       case 'S': if (num_subjobs>0) { reg_subjobs = 1; break; }
-                       case 'C': if (num_subjobs>0) { collection = 1; break; }
+                       case 'S': reg_subjobs = 1; break;
+                       case 'C': collection = 1; break;
                        case 'P': pbs = 1; break;
                        case 'l': jdl = (char *) strdup(optarg); break;
                        case 'e': seed = strdup(optarg); break;
@@ -46,6 +46,11 @@ int main(int argc, char *argv[])
                }
        } while (!done);
 
+       if ((num_subjobs <= 0) && (reg_subjobs || collection) ) {
+               usage(argv[0]);
+               exit(EINVAL);
+       }       
+
        if (!job && !server) {
                fprintf(stderr,"%s: either -m server or -j jobid has to be specified\n",argv[0]);
                exit(1);