Changeset 7938 for trunk/Ohana/src/opihi/pantasks
- Timestamp:
- Jul 19, 2006, 10:26:59 AM (20 years ago)
- Location:
- trunk/Ohana/src/opihi/pantasks
- Files:
-
- 1 deleted
- 4 edited
-
ListenClients.c (modified) (4 diffs)
-
Makefile (modified) (1 diff)
-
SocketOps.c (deleted)
-
client_shell.c (modified) (3 diffs)
-
pantasks_client.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/ListenClients.c
r7929 r7938 6 6 static int *clients; 7 7 static IOBuffer *buffers; 8 9 /* outline of functions we need here */10 8 11 9 void InitClients () { … … 17 15 } 18 16 17 /* add this client to the client table, create an IOBuffer for it */ 19 18 void AddNewClient (int client) { 20 21 /* add this client to the client table */22 /* need to create an IOBuffer for each possible client?23 we may not read a complete line in one pass. have to24 wait until we get the complete lines...25 */26 19 27 20 if (DEBUG) gprint (GP_LOG, "adding a new client (%d)\n", client); … … 36 29 } 37 30 31 /* select for messages from the current clients; wait for 0.5s before updating client list */ 38 32 void *ListenClients (void *data) { 39 33 … … 48 42 gprintInit (); // each thread needs to init the printing system 49 43 50 while (0) {51 52 Ncurrent = Nclients;53 for (i = 0; i < Ncurrent; i++) {54 ExpectMessage (clients[i], 0.25, &buffers[i]);55 if (DEBUG) gprint (GP_ERR, "read %d from client %d\n", buffers[i].Nbuffer, i);56 if (buffers[i].Nbuffer) {57 if (DEBUG) gprint (GP_ERR, "%s\n", buffers[i].buffer);58 }59 }60 usleep (250000);61 }62 63 44 while (1) { 64 45 65 46 /* Wait up to 0.5 second - need to timeout to update client list */ 66 47 /* timeout gets mucked: need to reset before each select */ 67 timeout.tv_sec = 1;68 timeout.tv_usec = 000000;48 timeout.tv_sec = 0; 49 timeout.tv_usec = 500000; 69 50 70 51 /* place all of the clients in the fdSet */ -
trunk/Ohana/src/opihi/pantasks/Makefile
r7929 r7938 70 70 $(SDIR)/client_shell.$(ARCH).o \ 71 71 $(SDIR)/invalid.$(ARCH).o \ 72 $(SDIR)/init_client.$(ARCH).o \ 73 $(SDIR)/SocketOps.$(ARCH).o 72 $(SDIR)/init_client.$(ARCH).o 74 73 75 74 server = \ 76 75 $(SDIR)/pantasks_server.$(ARCH).o \ 77 76 $(SDIR)/ListenClients.$(ARCH).o \ 78 $(SDIR)/CheckPassword.$(ARCH).o \ 79 $(SDIR)/SocketOps.$(ARCH).o 77 $(SDIR)/CheckPassword.$(ARCH).o 80 78 81 79 libs = \ -
trunk/Ohana/src/opihi/pantasks/client_shell.c
r7929 r7938 5 5 6 6 int i, Nbad, status, server; 7 char *line, *outline, *prompt, *history; 8 char hostname[256], PASSWORD[256]; 7 char *line, *prompt, *history; 9 8 pid_t ppid; 10 IOBuffer message;11 9 12 10 general_init (&argc, argv); … … 17 15 welcome (); 18 16 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 (); 25 19 26 /* here we can perform the security handshaking */27 VarConfig ("PASSWORD", "%s", PASSWORD);28 SendCommand (server, strlen(PASSWORD), PASSWORD);29 30 20 Nbad = 0; 31 21 while (1) { /** must exit with command "exit" or "quit" */ … … 50 40 51 41 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 us56 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);61 42 43 if (*line) { 44 status = multicommand (line); 45 add_history (line); 46 append_history (1, history); 47 } 62 48 free (line); 63 49 } 64 50 } 65 66 # if 067 /* 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 stdout75 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 stdout88 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 # endif94 51 95 52 /* -
trunk/Ohana/src/opihi/pantasks/pantasks_client.c
r7929 r7938 10 10 void program_init (int *argc, char **argv) { 11 11 12 auto_break = TRUE; 13 12 14 /* load the commands used by this implementation */ 13 15 InitBasic (); 14 16 InitData (); 17 InitAstro (); 15 18 InitPantasksClient (); 16 19 … … 19 22 rl_readline_name = opihi_name; 20 23 rl_attempted_completion_function = command_completer; 21 rl_event_hook = NULL;22 rl_set_keyboard_input_timeout (100000);23 24 24 25 set_str_variable ("HISTORY", opihi_history); … … 26 27 set_str_variable ("RCFILE", opihi_rcfile); 27 28 28 /* should we trap some commands and exec them locally? */29 /* help would be an obvious example... */30 29 # ifdef HELPDIR_DEFAULT 31 30 set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT)); … … 45 44 46 45 /* add program-dependent exit functions here */ 47 /* unclear what we should do with the plotting functions:48 do we keep the data only on the server, with all plotting49 taking place on the server? or what? */50 46 void cleanup () { 51 //QuitImage ();52 //QuitGraph ();47 QuitImage (); 48 QuitGraph (); 53 49 return; 54 50 } … … 60 56 } 61 57 62 /* call to opihi shell */ 58 /* call to client_shell: this opihi tool uses a slightly different 59 shell function from the standard tools */ 63 60 int main (int argc, char **argv) { 64 61 int status;
Note:
See TracChangeset
for help on using the changeset viewer.
