Changeset 3203 for trunk/Ohana/src/opihi/pcontrol/pclient.c
- Timestamp:
- Feb 12, 2005, 9:34:34 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/pclient.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/pclient.c
r3187 r3203 4 4 # define PCLIENT_PROMPT "pclient:" 5 5 6 # define DOWN 07 # define HUNG -18 9 6 int PclientCommand (Host *host, char *command, IOBuffer *buffer) { 10 7 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); 14 20 15 21 /* watch for response - wait up to 1 second */ 16 p= NULL;22 line = NULL; 17 23 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++) { 19 25 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); 21 27 } 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); 25 31 } 32 33 /* memstr returns a view, not an allocated string : don't free */
Note:
See TracChangeset
for help on using the changeset viewer.
