7 static char *rcsid_dispatch_c = "$Header$";
15 #include "sms_update_int.h"
22 extern int auth_001(), exec_001(), inst_001(), xfer_001();
23 extern int xfer_002(), exec_002();
25 extern int sync_proc(), quit();
27 extern void gdb_debug();
28 extern int exit(), abort(), errno;
35 (_send_int=(n),send_object(conn,(char *)&_send_int,INTEGER_T))
41 } dispatch_table[] = {
42 { "INST_001", inst_001 },
43 { "AUTH_001", auth_001 },
44 { "XFER_001", xfer_001 },
45 { "EXEC_001", exec_001 },
46 { "XFER_002", xfer_002 },
47 { "EXEC_002", exec_002 },
49 { (char *)NULL, abort }
53 * general scratch space -- useful for building
54 * error messages et al...
61 sprintf(buf, fmt, error_message(code));
73 gdb_debug(GDB_NOFORK);
76 whoami = rindex(argv[0], '/');
82 /* interpret arguments here */
84 fprintf(stderr, "Usage: %s\n", whoami);
87 /* well, sort of... */
90 sms_update_initialize();
93 /* wait for connection */
95 conn = create_forking_server(SERVICE_NAME, 0);
97 err(errno, "%s: can't get connection");
100 if (connection_status(conn) == CON_STOPPED) {
101 com_err(whoami, connection_errno(conn), ": can't get connection");
105 sms_log_info("got connection");
106 /* got a connection; loop forever */
109 code = receive_object(conn, (char *)&str, STRING_T);
111 err(connection_errno(conn), "%s: receiving command");
112 sever_connection(conn);
115 cp = index(STRING_DATA(str), ' ');
118 for (d = dispatch_table; d->str; d++) {
119 if (!strcmp(d->str, STRING_DATA(str))) {
123 printf("got request: %s\n", STRING_DATA(str));
125 (void)(d->proc)(STRING_DATA(str));
129 sprintf(buf, "unknown request received: %s\n", STRING_DATA(str));
131 code = send_int(SMSU_UNKNOWN_PROC);
133 err(connection_errno(conn), "%s: sending UNKNOWN_PROC");
144 return((code = send_object(conn, (char *)&zero, INTEGER_T)));