IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 18, 2006, 6:58:54 AM (20 years ago)
Author:
eugene
Message:

updates to fix comm problems with buffers (motivated by opihi gprint)

File:
1 edited

Legend:

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

    r7892 r7929  
    22# define VERBOSE 0
    33
    4 /* this function acts like the standard command parser,
    5    but skips the expansion of variables and vectors */
     4// this function is identical to the normal command.c function,
     5// but it returns -1 for a missing command and does not echo the
     6// 'missing command' error message
     7
    68int command_client (char *line, char **outline) {
    79
     
    1719  }
    1820
     21  /* expand anything of the form $fred or $fred$sam, etc */
     22  line = expand_vars (line);     /* line is freed here, new one allocated */
     23  /* expand anything of the form fred[N] */
     24  line = expand_vectors (line);  /* line is freed here, new one allocated */
     25  /* solve math expresions, assign variable, if needed */
     26  line = parse (line);        /* line is freed here, new one allocated */
     27  /* any entry in line of the form {foo} returns value or tmp vector / buffer */
     28
    1929  /* we may have reallocated line, return new pointer */
    2030  *outline = line;
     
    2737  for (i = 0; i < argc; i++) targv[i] = argv[i];
    2838
    29   cmd = MatchCommand (argv[0], TRUE, FALSE);
     39  // use non-verbose mode to skip 'missing command' error message
     40  cmd = MatchCommand (argv[0], FALSE, FALSE);
    3041  if (cmd == NULL) {
    31     status = FALSE;
     42    status = -1;
    3243  } else {
    3344    free (argv[0]);
     
    4051  free (argv);
    4152
     53  if (!status) {
     54    char *msg;
     55    msg = get_variable_ptr ("ERRORMSG");
     56    if (msg != (char *) NULL) gprint (GP_ERR, "%s\n", msg);
     57  }
     58
     59  set_int_variable ("STATUS", status);
     60  if (VERBOSE) gprint (GP_ERR, "command: %s, status: %d\n", line, status);
    4261  return (status);
    4362}
Note: See TracChangeset for help on using the changeset viewer.