IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2005, 9:34:34 AM (21 years ago)
Author:
eugene
Message:

pcontrol dev

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/pclient.c

    r3187 r3203  
    44# define PCLIENT_PROMPT "pclient:"
    55
    6 # define DOWN  0
    7 # define HUNG -1
    8 
    96int PclientCommand (Host *host, char *command, IOBuffer *buffer) {
    107
    11   /* send command to client */
    12   status = write (host[0].stdin, command, strlen(command));
    13   if ((status == -1) && (errno == EPIPE)) return (DOWN);
     8  int i;
     9  int status;
     10  char *line;
     11 
     12  /* send command to client (adding on \n) */
     13  ALLOCATE (line, char, MAX (1, strlen(command)));
     14  sprintf (line, "%s\n", command);
     15  status = write (host[0].stdin, line, strlen(line));
     16  free (line);
     17
     18  /* is pipe still open? */
     19  if ((status == -1) && (errno == EPIPE)) return (PCLIENT_DOWN);
    1420 
    1521  /* watch for response - wait up to 1 second */
    16   p = NULL;
     22  line = NULL;
    1723  status = -1;
    18   for (i = 0; (i < PCLIENT_TIMEOUT) && (status == -1) && (p == NULL); i++) {
     24  for (i = 0; (i < PCLIENT_TIMEOUT) && (status == -1) && (line == NULL); i++) {
    1925    status = ReadtoIOBuffer (buffer, host[0].stdout);
    20     p = memstr (buffer[0].buffer, PCLIENT_PROMPT, buffer[0].Nbuffer);
     26    line = memstr (buffer[0].buffer, PCLIENT_PROMPT, buffer[0].Nbuffer);
    2127  }
    22   if (status ==  0) return (DOWN);
    23   if (status == -1) return (HUNG);
    24   return (TRUE);
     28  if (status ==  0) return (PCLIENT_DOWN);
     29  if (status == -1) return (PCLIENT_HUNG);
     30  return (PCLIENT_GOOD);
    2531}
     32
     33/* memstr returns a view, not an allocated string : don't free */
Note: See TracChangeset for help on using the changeset viewer.