Changeset 4462 for trunk/Ohana/src/opihi/lib.shell/multicommand.c
- Timestamp:
- Jul 6, 2005, 10:29:08 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/multicommand.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/multicommand.c
r2598 r4462 1 1 # include "opihi.h" 2 2 3 char **multicommand (char *line, int *nlist) { 3 /* take input line and split into multiple lines 4 at the semi-colons. send these to 'command' */ 4 5 5 char **list; 6 int Nlist, NLIST; 6 int multicommand (char *line) { 7 8 int done, status; 9 char *p, *q, *tmpline, *outline; 7 10 8 Nlist = 0; 9 NLIST = 10; 10 ALLOCATE (list, char *, NLIST); 11 12 list[0] = strcreate (line); 13 *nlist = 1; 14 return (list); 11 p = line; 12 done = FALSE; 13 while (!done) { 14 q = strchr (p, ';'); 15 if (q == NULL) { 16 q = p + strlen(p); 17 done = TRUE; 18 } 19 tmpline = strncreate (p, q - p); 20 stripwhite (tmpline); 21 if (*tmpline) { 22 status = command (tmpline, &outline); 23 if (outline != NULL) free (outline); 24 if (!status && auto_break) done = TRUE; 25 } 26 p = q + 1; 27 } 28 return (status); 15 29 } 16 30 31 /* should skip ; surrounded by "" */
Note:
See TracChangeset
for help on using the changeset viewer.
