Changeset 42082 for trunk/Ohana/src/opihi/cmd.data/queueload.c
- Timestamp:
- Feb 28, 2022, 12:17:32 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/queueload.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/queueload.c
r12332 r42082 3 3 int queueload (int argc, char **argv) { 4 4 5 char *A, *B, *val; 6 int i, status; 7 int Nread, Nbytes, NBYTES; 8 FILE *f; 9 Queue *queue; 5 int N; 6 7 // variable name to save the value 8 int TrapFailure = FALSE; 9 if ((N = get_argument (argc, argv, "-trap-failure"))) { 10 remove_argument (N, &argc, argv); 11 TrapFailure = TRUE; 12 } 13 if ((N = get_argument (argc, argv, "-trap"))) { 14 remove_argument (N, &argc, argv); 15 TrapFailure = TRUE; 16 } 10 17 11 18 if (argc != 4) goto usage; … … 13 20 14 21 /* will create a queue if none exists */ 15 queue = CreateQueue (argv[1]);22 Queue *queue = CreateQueue (argv[1]); 16 23 17 24 /* val will hold the result of the command */ 18 NBYTES = 1024;19 ALLOCATE (val, char, NBYTES);25 int NBYTES = 1024; 26 ALLOCATE_PTR (val, char, NBYTES); 20 27 21 28 /* loop until command produces no more output, REALLOCATE as needed. */ 22 f = popen (argv[3], "r"); 23 Nbytes = 0; 24 Nread = 1; 29 FILE *f = popen (argv[3], "r"); 30 31 int Nbytes = 0; 32 int Nread = 1; 25 33 while (Nread > 0) { 26 34 Nread = fread (&val[Nbytes], 1, 1023, f); … … 35 43 } 36 44 val[Nbytes] = 0; 37 status = pclose (f);45 int status = pclose (f); 38 46 47 // XXX 39 48 if (status) { 40 49 gprint (GP_ERR, "warning: exit status of command %d\n", status); 50 if (TrapFailure) { free (val); return FALSE; } 41 51 } 42 52 43 A =B = val;44 for (i = 0; B != (char *) NULL;) {53 char *A = val, *B = val; 54 for (int i = 0; B != (char *) NULL;) { 45 55 while (isspace (*A) && (*A != 0)) A++; 46 56 B = strchr (A, '\n');
Note:
See TracChangeset
for help on using the changeset viewer.
