IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 6, 2005, 10:29:08 AM (21 years ago)
Author:
eugene
Message:

fixed multicommand to parse subcommands sequentially, added modulus operator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/multicommand.c

    r2598 r4462  
    11# include "opihi.h"
    22
    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' */
    45
    5   char **list;
    6   int Nlist, NLIST;
     6int multicommand (char *line) {
     7 
     8  int done, status;
     9  char *p, *q, *tmpline, *outline;
    710
    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);
    1529}
    1630
     31/* should skip ; surrounded by "" */
Note: See TracChangeset for help on using the changeset viewer.