diff options
-rw-r--r-- | src/ChangeLog | 23 | ||||
-rw-r--r-- | src/include/sockio.h | 17 | ||||
-rw-r--r-- | src/interp/server.boot | 1 | ||||
-rw-r--r-- | src/interp/sys-constants.boot | 7 | ||||
-rw-r--r-- | src/interp/sys-os.boot | 4 | ||||
-rw-r--r-- | src/lib/sockio-c.c | 89 |
6 files changed, 49 insertions, 92 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 15964ef5..3a458968 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,26 @@ +2012-08-26 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * include/sockio.h (init_purpose_table): Remove declaration. + (redirect_stdio): Likewise. + (init_socks): Likewise. + (flush_stdout): Likewise. + (print_line): Likewise. + (BaloonServer): Remove. + (DebugWindow): Likewise. + (Forker): Likewise. + (AV): Likewise. + * interp/server.boot (serverReadLine): Do not flushOutput. + * interp/sys-constants.boot ($MessageServer): Remove. + ($DebugWindow): Likewise. + ($Forker): Likewise. + * interp/sys-os.boot (printLine): Remove associated foreign import. + * lib/sockio-c.c (init_purpose_table): Do not export. + (init_socks): Likewise. + (get_socket_type): Simplify. Remove dead code. + (redirect_stdio): Remove. + (flush_stdio): Likewise. + (print_line): Likewise. + 2012-08-25 Gabriel Dos Reis <gdr@cs.tamu.edu> * interp/br-saturn.boot: Replace TERPRI with finishLine. diff --git a/src/include/sockio.h b/src/include/sockio.h index a62bda86..14b06cd8 100644 --- a/src/include/sockio.h +++ b/src/include/sockio.h @@ -120,7 +120,7 @@ OPENAXIOM_C_EXPORT int wait_for_client_write(openaxiom_sio*, const char*); OPENAXIOM_C_EXPORT int make_server_name(char*, const char*); -OPENAXIOM_C_EXPORT int make_server_number(void); +OPENAXIOM_C_EXPORT int make_server_number(); OPENAXIOM_C_EXPORT openaxiom_sio* connect_to_local_server(const char*, int, int); OPENAXIOM_C_EXPORT int open_server(const char*); OPENAXIOM_C_EXPORT int accept_connection(openaxiom_sio*); @@ -169,14 +169,9 @@ OPENAXIOM_C_EXPORT int sock_send_signal(int, int); OPENAXIOM_C_EXPORT int send_wakeup(openaxiom_sio*); OPENAXIOM_C_EXPORT int sock_send_wakeup(int); OPENAXIOM_C_EXPORT void remote_stdio(openaxiom_sio*); -OPENAXIOM_C_EXPORT void init_purpose_table(void); OPENAXIOM_C_EXPORT void get_socket_type(openaxiom_sio*); OPENAXIOM_C_EXPORT int sock_accept_connection(int); -OPENAXIOM_C_EXPORT void redirect_stdio(openaxiom_sio*); -OPENAXIOM_C_EXPORT void init_socks(void); -OPENAXIOM_C_EXPORT int server_switch(void); -OPENAXIOM_C_EXPORT void flush_stdout(void); -OPENAXIOM_C_EXPORT void print_line(const char*); +OPENAXIOM_C_EXPORT int server_switch(); #define MaxClients 150 @@ -186,12 +181,8 @@ OPENAXIOM_C_EXPORT void print_line(const char*); #define ViewportServer 2 #define MenuServer 3 #define SessionIO 4 -#define BaloonServer 5 -#define InterpWindow 6 -#define KillSpad 7 -#define DebugWindow 8 /* used for nagman */ -#define Forker 9 -#define AV 10 /*Simon's algebraic viewer */ +#define InterpWindow 5 +#define KillSpad 6 #define Acknowledge 255 diff --git a/src/interp/server.boot b/src/interp/server.boot index e989fe80..0b206263 100644 --- a/src/interp/server.boot +++ b/src/interp/server.boot @@ -48,7 +48,6 @@ $sockBufferLength := 9217 serverReadLine(stream) == -- used in place of READ-LINE in a scratchpad server system. - flushOutput() not $SpadServer or not ioTerminal? stream => line := readLine stream line ~= %nothing => line diff --git a/src/interp/sys-constants.boot b/src/interp/sys-constants.boot index 017e5bb8..9f7d5223 100644 --- a/src/interp/sys-constants.boot +++ b/src/interp/sys-constants.boot @@ -662,11 +662,8 @@ $SessionManager == 1 $ViewportServer == 2 $MenuServer == 3 $SessionIO == 4 -$MessageServer == 5 -$InterpWindow == 6 -$KillSpad == 7 -$DebugWindow == 8 -$Forker == 9 +$InterpWindow == 5 +$KillSpad == 6 $CreateFrame == 1 $SwitchFrames == 2 diff --git a/src/interp/sys-os.boot b/src/interp/sys-os.boot index f4d4658f..2095c14e 100644 --- a/src/interp/sys-os.boot +++ b/src/interp/sys-os.boot @@ -1,4 +1,4 @@ --- Copyright (C) 2007-2011 Gabriel Dos Reis. +-- Copyright (C) 2007-2012 Gabriel Dos Reis. -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -179,8 +179,6 @@ import flush__stdout: () -> int for flushStdout import sock__send__signal: (int,int) -> int for sockSendSignal -import print__line: string -> int for printLine - --% import oa__system: string -> int for runCommand diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c index 21ef5504..662768f2 100644 --- a/src/lib/sockio-c.c +++ b/src/lib/sockio-c.c @@ -110,7 +110,7 @@ static int openaxiom_socket_module_loaded = 0; we can even think about talking about sockets. */ static void -openaxiom_unload_socket_module(void) +openaxiom_unload_socket_module() { WSACleanup(); openaxiom_socket_module_loaded = 0; @@ -119,7 +119,7 @@ openaxiom_unload_socket_module(void) static void -openaxiom_load_socket_module(void) +openaxiom_load_socket_module() { if (!openaxiom_socket_module_loaded) { #ifdef __WIN32__ @@ -426,7 +426,7 @@ oa_socket_write_byte(openaxiom_socket sock, Byte byte) /* Return 1 is the last call was cancelled. */ static inline int -openaxiom_syscall_was_cancelled(void) +openaxiom_syscall_was_cancelled() { #ifdef __WIN32__ return WSAGetLastError() == WSAEINTR; @@ -438,7 +438,7 @@ openaxiom_syscall_was_cancelled(void) /* Return 1 is last connect() was refused. */ static inline int -openaxiom_connection_refused(void) +openaxiom_connection_refused() { #ifdef __WIN32__ return WSAGetLastError() == WSAECONNREFUSED; @@ -1111,8 +1111,8 @@ remote_stdio(openaxiom_sio *sock) } /* initialize the table of dedicated sockets */ -OPENAXIOM_C_EXPORT void -init_purpose_table(void) +static void +init_purpose_table() { int i; for(i=0; i<TotalMaxPurposes; i++) { @@ -1122,7 +1122,7 @@ init_purpose_table(void) OPENAXIOM_C_EXPORT int -make_server_number(void) +make_server_number() { spad_server_number = oa_getpid(); return spad_server_number; @@ -1154,6 +1154,17 @@ make_server_name(char *name, const char* base) return 0; } +static void +init_socks() +{ + int i; + FD_ZERO(&socket_mask); + FD_ZERO(&server_mask); + init_purpose_table(); + for(i=0; i<2; i++) server[i].socket = 0; + for(i=0; i<MaxClients; i++) clients[i].socket = 0; +} + /* client Spad server sockets. Two sockets are created: server[0] is the internet server socket, and server[1] is a local domain socket. */ OPENAXIOM_C_EXPORT int @@ -1252,17 +1263,6 @@ get_socket_type(openaxiom_sio *sock) send_int(sock, oa_getpid()); send_int(sock, sock->socket); purpose_table[sock->purpose] = sock; - switch (sock->purpose) { - case SessionManager: - break; - case ViewportServer: - break; - case MenuServer: - break; - case SessionIO: -/* redirect_stdio(sock); */ - break; - } } OPENAXIOM_C_EXPORT int @@ -1288,41 +1288,10 @@ sock_accept_connection(int purpose) } } -/* direct stdin and stdout from the given socket */ -OPENAXIOM_C_EXPORT void -redirect_stdio(openaxiom_sio *sock) -{ - int fd; -/* setbuf(stdout, NULL); */ - fd = dup2(sock->socket, 1); - if (fd != 1) { - fprintf(stderr, "Error connecting stdout to socket\n"); - return; - } - fd = dup2(sock->socket, 0); - if (fd != 0) { - fprintf(stderr, "Error connecting stdin to socket\n"); - return; - } - fprintf(stderr, "Redirected standard IO\n"); - FD_CLR(sock->socket, &socket_mask); -} - -OPENAXIOM_C_EXPORT void -init_socks(void) -{ - int i; - FD_ZERO(&socket_mask); - FD_ZERO(&server_mask); - init_purpose_table(); - for(i=0; i<2; i++) server[i].socket = 0; - for(i=0; i<MaxClients; i++) clients[i].socket = 0; -} - /* Socket I/O selection called from the BOOT serverLoop function */ OPENAXIOM_C_EXPORT int -server_switch(void) +server_switch() { int ret_val, i, cmd = 0; fd_set rd, wr, ex, fds_mask; @@ -1368,24 +1337,4 @@ server_switch(void) } } -OPENAXIOM_C_EXPORT void -flush_stdout(void) -{ - static FILE *fp = NULL; - if (fp == NULL) { - fp = fdopen(purpose_table[SessionIO]->socket, "w"); - if (fp == NULL) { - perror("fdopen"); - return; - } - } - fflush(fp); -} - -OPENAXIOM_C_EXPORT void -print_line(const char* s) -{ - printf("%s\n", s); -} - } |