IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 19, 2006, 10:26:59 AM (20 years ago)
Author:
eugene
Message:

unified the client/standalone command functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/client_shell.c

    r7929 r7938  
    55
    66  int i, Nbad, status, server;
    7   char *line, *outline, *prompt, *history;
    8   char hostname[256], PASSWORD[256];
     7  char *line, *prompt, *history;
    98  pid_t ppid;
    10   IOBuffer message;
    119
    1210  general_init (&argc, argv);
     
    1715  welcome ();
    1816
    19   /* connect to the server */
    20   if (VarConfig ("PANTASKS_SERVER", "%s", hostname) == NULL) {
    21     gprint (GP_ERR, "pantasks server host undefined\n");
    22     exit (2);
    23   }
    24   server = GetClientSocket (hostname);
     17  /* attempt to connect to the pantasks server (exit on failure) */
     18  multicommand_InitServer ();
    2519
    26   /* here we can perform the security handshaking */
    27   VarConfig ("PASSWORD", "%s", PASSWORD);
    28   SendCommand (server, strlen(PASSWORD), PASSWORD);
    29  
    3020  Nbad = 0;
    3121  while (1) {  /** must exit with command "exit" or "quit" */
     
    5040
    5141    stripwhite (line);
    52    
    53     /* check for commands to be caught by client */
    54     /* use the standard command parser? */
    55     /* XXX the exit status of command does not allow us
    56        to distinguish 'failed command' and 'command not found' */
    57     /* XXX eventually replace this with a multicommand parsing */
    58     status = multicommand_client (line, server);
    59     add_history (line);
    60     append_history (1, history);
    6142
     43    if (*line) {
     44        status = multicommand (line);
     45        add_history (line);
     46        append_history (1, history);
     47    }
    6248    free (line);
    6349  }
    6450}
    65 
    66 # if 0
    67     /* command was not caught by client, send to server */
    68     if (*outline && !status ) {
    69       gprint (GP_ERR, "sending message to %d: %s\n", server, outline);
    70       SendMessage (server, outline);
    71       add_history (outline);
    72       append_history (1, history);
    73 
    74       // XXX add this in and print to stdout
    75       status = ExpectMessage (server, 2.0, &message);
    76       // fprintf (stderr, "got stdout message: %d bytes\n", message.Nbuffer);
    77       fwrite (message.buffer, 1, message.Nbuffer, stderr);
    78       // fprintf (stderr, "end message\n");
    79 
    80       // fprintf (stderr, "got message: %d bytes\n", message.Nbuffer);
    81       // for (i = 0; i < message.Nbuffer; i++) {
    82       // fprintf (stderr, "%d %d %c\n", i, message.buffer[i], message.buffer[i]);
    83       // }
    84       // fwrite (message.buffer, 1, message.Nbuffer, stderr);
    85       // fprintf (stderr, "end message\n");
    86 
    87       // XXX add this in and print to stdout
    88       status = ExpectMessage (server, 2.0, &message);
    89       // fprintf (stderr, "got stderr message: %d bytes\n", message.Nbuffer);
    90       fwrite (message.buffer, 1, message.Nbuffer, stderr);
    91       // fprintf (stderr, "end message\n");
    92     }
    93 # endif
    9451
    9552/*
Note: See TracChangeset for help on using the changeset viewer.