From 566333bb962ea14c19352749d9211a87f05daef9 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 4 Dec 1999 22:16:05 +0000 Subject: [PATCH] * Moved all diagnostic output to stderr * Moved "HTTP/1.0 200 OK" output to output_headers() --- webcit/ChangeLog | 5 +++++ webcit/auth.c | 5 ----- webcit/context_loop.c | 2 +- webcit/graphics.c | 2 -- webcit/mainmenu.c | 5 ----- webcit/messages.c | 7 ------- webcit/netconf.c | 10 ---------- webcit/paging.c | 3 --- webcit/roomops.c | 13 ++----------- webcit/siteconfig.c | 1 - webcit/sysmsgs.c | 3 --- webcit/userlist.c | 2 -- webcit/webcit.c | 5 ++--- webcit/webserver.c | 24 +++++++++++------------- webcit/who.c | 3 --- 15 files changed, 21 insertions(+), 69 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index c4a2470a8..6f9c2f88c 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 1.113 1999/12/04 22:16:05 ajc +* Moved all diagnostic output to stderr +* Moved "HTTP/1.0 200 OK" output to output_headers() + Revision 1.112 1999/12/04 21:56:59 ajc * Finished the overhaul. Now to tune... @@ -334,3 +338,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/auth.c b/webcit/auth.c index e449c9629..117ba611c 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -47,7 +47,6 @@ void display_login(char *mesg) { char buf[256]; - wprintf("HTTP/1.0 200 OK\n"); output_headers(3); /* Da banner */ @@ -184,7 +183,6 @@ void do_logout(void) strcpy(WC->wc_password, ""); strcpy(WC->wc_roomname, ""); - wprintf("HTTP/1.0 200 OK\n"); output_headers(2); /* note "2" causes cookies to be unset */ wprintf("
"); @@ -218,7 +216,6 @@ void validate(void) char buf[256]; int a; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); strcpy(buf, bstr("user")); @@ -297,7 +294,6 @@ void display_reg(int during_login) char buf[256]; int a; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -401,7 +397,6 @@ void display_changepw(void) { char buf[256]; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 3f6055a9a..d98f8935f 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -287,7 +287,7 @@ void context_loop(int sock) * Create a new session if we have to */ if (TheSession == NULL) { - printf("Creating a new session\n"); + fprintf(stderr, "Creating a new session\n"); TheSession = (struct wcsession *) malloc(sizeof(struct wcsession)); memset(TheSession, 0, sizeof(struct wcsession)); diff --git a/webcit/graphics.c b/webcit/graphics.c index 3e8ebc617..043c96c53 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -30,7 +30,6 @@ void display_graphics_upload(char *description, char *check_cmd, char *uplurl) display_error(&buf[4]); return; } - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); wprintf("
"); diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index 0cdc6ebc5..c48e60b68 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -207,7 +207,6 @@ void embed_advanced_menu(void) */ void display_main_menu(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); embed_main_menu(); wDumpContent(2); @@ -216,7 +215,6 @@ void display_main_menu(void) void display_advanced_menu(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); embed_advanced_menu(); embed_main_menu(); @@ -229,7 +227,6 @@ void display_advanced_menu(void) */ void display_generic(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -269,7 +266,6 @@ void do_generic(void) return; } - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); serv_printf("%s", bstr("g_cmd")); @@ -332,7 +328,6 @@ void display_menubar(int as_single_page) { char buf[256]; if (as_single_page) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(0); wprintf("\n" "\n" diff --git a/webcit/messages.c b/webcit/messages.c index 7966e9c41..e93b50729 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -240,7 +240,6 @@ void readloop(char *oper) int a; int nummsgs; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
%s - ", WC->wc_roomname); @@ -293,7 +292,6 @@ void post_message(void) char buf[256]; static long dont_post = (-1L); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf(""); @@ -358,7 +356,6 @@ void display_enter(void) long now; struct tm *tm; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf(""); @@ -427,7 +424,6 @@ void confirm_delete_msg(void) msgid = atol(bstr("msgid")); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -459,7 +455,6 @@ void delete_msg(void) msgid = atol(bstr("msgid")); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); if (!strcasecmp(bstr("yesno"), "Yes")) { @@ -488,7 +483,6 @@ void confirm_move_msg(void) msgid = atol(bstr("msgid")); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -536,7 +530,6 @@ void move_msg(void) msgid = atol(bstr("msgid")); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); if (!strcasecmp(bstr("yesno"), "Move")) { diff --git a/webcit/netconf.c b/webcit/netconf.c index 6b2d763cd..e069fe6ac 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -41,7 +41,6 @@ void display_edit_node(void) strcpy(node, bstr("node")); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); wprintf("
"); wprintf("
"); wprintf("
"); wprintf("Back to menu\n"); @@ -210,7 +205,6 @@ void unshare(void) serv_puts(buf); serv_gets(buf); if (buf[0] == '1') { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); server_to_text(); wprintf("Back to menu\n"); @@ -225,7 +219,6 @@ void unshare(void) void display_add_node(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); wprintf("Back to menu\n"); @@ -285,7 +277,6 @@ void display_share(void) strcpy(node, bstr("node")); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); wprintf("Back to menu\n"); diff --git a/webcit/paging.c b/webcit/paging.c index 51611c2ea..553a872ff 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -30,7 +30,6 @@ void display_page(void) char buf[256]; char user[256]; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -80,7 +79,6 @@ void page_user(void) char sc[256]; char buf[256]; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); strcpy(recp, bstr("recp")); @@ -112,7 +110,6 @@ void page_user(void) void do_chat(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); diff --git a/webcit/roomops.c b/webcit/roomops.c index e4ec0bc72..6e8cc0898 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -250,7 +250,6 @@ void list_all_rooms_by_floor(void) load_floorlist(); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf(""); @@ -297,7 +296,6 @@ void list_all_rooms_by_floor(void) */ void zapped_list(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
Floor
"); wprintf("\n" "\n" @@ -647,7 +644,6 @@ void display_editroom(void) er_floor = extract_int(&buf[4], 4); - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -964,7 +960,6 @@ void display_entroom(void) display_error(&buf[4]); return; } - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -1046,7 +1041,6 @@ void entroom(void) void display_private(char *rname, int req_pass) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -1109,7 +1103,6 @@ void goto_private(void) display_private(bstr("gr_name"), 1); return; } - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("%s\n", &buf[4]); wDumpContent(1); @@ -1122,7 +1115,6 @@ void goto_private(void) */ void display_zap(void) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -1189,7 +1181,6 @@ void confirm_delete_room(void) display_error(&buf[4]); return; } - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); wprintf("
"); @@ -80,7 +79,6 @@ void save_edit(char *description, char *enter_cmd, int regoto) char buf[256]; if (strcmp(bstr("sc"), "Save")) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("Cancelled. %s was not saved.
\n", description); wDumpContent(1); @@ -98,7 +96,6 @@ void save_edit(char *description, char *enter_cmd, int regoto) if (regoto) { smart_goto(WC->wc_roomname); } else { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("%s has been saved.\n", description); wDumpContent(1); diff --git a/webcit/userlist.c b/webcit/userlist.c index 44e60a056..ca2fb3864 100644 --- a/webcit/userlist.c +++ b/webcit/userlist.c @@ -49,7 +49,6 @@ void userlist(void) strcpy(bptr->name, buf); bio = bptr; } - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); serv_puts("LIST"); @@ -114,7 +113,6 @@ void showuser(void) char buf[256]; int have_pic; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); diff --git a/webcit/webcit.c b/webcit/webcit.c index 7cede653d..ede8a7ec8 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -295,6 +295,8 @@ void output_headers(int print_standard_html_head) static char *unset = "; expires=28-May-1971 18:10:00 GMT"; char cookie[256]; + wprintf("HTTP/1.0 200 OK\n"); + if (print_standard_html_head > 0) { wprintf("Content-type: text/html\n"); wprintf("Server: %s\n", SERVER); @@ -409,7 +411,6 @@ void output_static(char *what) wprintf("\n"); wprintf("Cannot open %s: %s\n", what, strerror(errno)); } else { - wprintf("HTTP/1.0 200 OK\n"); output_headers(0); if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4)) @@ -456,7 +457,6 @@ void output_image() serv_gets(buf); if (buf[0] == '2') { bytes = extract_long(&buf[4], 0); - wprintf("HTTP/1.0 200 OK\n"); output_headers(0); wprintf("Content-type: image/gif\n"); wprintf("Content-length: %ld\n", (long) bytes); @@ -874,7 +874,6 @@ void session_loop(struct httprequest *req) } else if (!strcasecmp(action, "display_menubar")) { display_menubar(1); } else if (!strcasecmp(action, "diagnostics")) { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("You're in session %d
\n", WC->wc_session); diff --git a/webcit/webserver.c b/webcit/webserver.c index a163ef47d..eb1b3b074 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -70,14 +70,15 @@ int ig_tcp_server(int port_number, int queue_len) sin.sin_addr.s_addr = INADDR_ANY; if (port_number == 0) { - printf("webcit: Cannot start: no port number specified.\n"); + fprintf(stderr, + "webcit: Cannot start: no port number specified.\n"); exit(1); } sin.sin_port = htons((u_short) port_number); s = socket(PF_INET, SOCK_STREAM, (getprotobyname("tcp")->p_proto)); if (s < 0) { - printf("webcit: Can't create a socket: %s\n", + fprintf(stderr, "webcit: Can't create a socket: %s\n", strerror(errno)); exit(errno); } @@ -86,11 +87,11 @@ int ig_tcp_server(int port_number, int queue_len) setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - printf("webcit: Can't bind: %s\n", strerror(errno)); + fprintf(stderr, "webcit: Can't bind: %s\n", strerror(errno)); exit(errno); } if (listen(s, queue_len) < 0) { - printf("webcit: Can't listen: %s\n", strerror(errno)); + fprintf(stderr, "webcit: Can't listen: %s\n", strerror(errno)); exit(errno); } return (s); @@ -108,9 +109,8 @@ void client_write(int sock, char *buf, int nbytes) retval = write(sock, &buf[bytes_written], nbytes - bytes_written); if (retval < 1) { - printf("client_write() failed: %s\n", + fprintf(stderr, "client_write() failed: %s\n", strerror(errno)); - pthread_exit(NULL); } bytes_written = bytes_written + retval; } @@ -161,9 +161,8 @@ int client_read_to(int sock, char *buf, int bytes, int timeout) } rlen = read(sock, &buf[len], bytes - len); if (rlen < 1) { - printf("client_read() failed: %s\n", + fprintf(stderr, "client_read() failed: %s\n", strerror(errno)); - pthread_exit(NULL); } len = len + rlen; } @@ -288,9 +287,9 @@ int main(int argc, char **argv) * There is no need to check for errors, because ig_tcp_server() * exits if it doesn't succeed. */ - printf("Attempting to bind to port %d...\n", port); + fprintf(stderr, "Attempting to bind to port %d...\n", port); msock = ig_tcp_server(port, 5); - printf("Listening on socket %d\n", msock); + fprintf(stderr, "Listening on socket %d\n", msock); signal(SIGPIPE, SIG_IGN); pthread_mutex_init(&SessionListMutex, NULL); @@ -317,7 +316,7 @@ int main(int argc, char **argv) if (pthread_create(&SessThread, &attr, (void *(*)(void *)) worker_entry, NULL) != 0) { - printf("webcit: can't create thread: %s\n", + fprintf(stderr, "webcit: can't create thread: %s\n", strerror(errno)); } } @@ -344,9 +343,8 @@ void worker_entry(void) { ssock = accept(msock, (struct sockaddr *) &fsin, &alen); pthread_mutex_unlock(&AcceptQueue); - printf("New connection on socket %d\n", ssock); if (ssock < 0) { - printf("webcit: accept() failed: %s\n", + fprintf(stderr, "webcit: accept() failed: %s\n", strerror(errno)); } else { /* Set the SO_REUSEADDR socket option */ diff --git a/webcit/who.c b/webcit/who.c index 8afc9d081..67fe43c64 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -49,7 +49,6 @@ void whobbs(void) char buf[256], sess, user[256], room[256], host[256]; int foundit; - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); @@ -168,7 +167,6 @@ void terminate_session(void) display_error(&buf[4]); } } else { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); wprintf("Confirm session termination"); @@ -217,7 +215,6 @@ void edit_me(void) whobbs(); } else { - wprintf("HTTP/1.0 200 OK\n"); output_headers(1); wprintf("
"); -- 2.30.2