From 38bffe333f26c083c495cbb24dee7130cd5f394a Mon Sep 17 00:00:00 2001 From: Michael Hampton Date: Mon, 15 Mar 2004 16:36:51 +0000 Subject: [PATCH] * Multiple files: Convert most remaining client code to use new Citadel IPC functions. A few bits remain and will be converted when the chat system is rewritten. --- citadel/ChangeLog | 6 +++- citadel/citadel.c | 20 +++++++------ citadel/citadel_ipc.c | 8 +++--- citadel/client_chat.c | 34 +++++++++++----------- citadel/commands.c | 6 ++-- citadel/rooms.c | 36 ++++++++++++----------- citadel/routines.c | 8 +++--- citadel/routines2.c | 67 +++++++++++++++++++++++++++---------------- citadel/sendcommand.c | 12 ++++---- citadel/userlist.c | 2 +- citadel/whobbs.c | 2 +- 11 files changed, 114 insertions(+), 87 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 7525d25c4..7231819aa 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 614.77 2004/03/15 16:36:50 error + * Multiple files: Convert most remaining client code to use new Citadel IPC + functions. A few bits remain and will be converted when the chat system + is rewritten. + Revision 614.76 2004/03/14 06:35:46 ajc * Cache IMAP "BODY" fetches in an already-converted format. This speeds up clients like Mozilla and Thunderbird that request big messages in @@ -5505,4 +5510,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.c b/citadel/citadel.c index 22171d57a..d400ca56c 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -1151,7 +1151,7 @@ int main(int argc, char **argv) #endif ipc_for_signal_handlers = ipc; /* KLUDGE cover your eyes */ - CtdlIPC_getline(ipc, aaa); + CtdlIPC_chat_recv(ipc, aaa); if (aaa[0] != '2') { scr_printf("%s\n", &aaa[4]); logoff(ipc, atoi(aaa)); @@ -1408,14 +1408,16 @@ NEWUSR: if (strlen(rc_password) == 0) { entmsg(ipc, 0, 2); break; case 78: - newprompt("What do you want your username to be? ", aaa, 32); - snprintf(bbb, sizeof bbb, "ENT0 2|0|0|0|%s", aaa); - CtdlIPC_putline(ipc, bbb); - CtdlIPC_getline(ipc, aaa); - if (strncmp("200", aaa, 3)) - scr_printf("\n%s\n", aaa); - else - entmsg(ipc, 0, 0); + { + /* Only m.author is used */ + struct ctdlipcmessage m; + newprompt("What do you want your username to be? ", m.author, USERNAME_SIZE - 1); + r = CtdlIPCPostMessage(ipc, 2, &m, aaa); + if (r / 100 != 2) + scr_printf("%s\n", aaa); + else + entmsg(ipc, 0, 0); + } break; case 5: /* oto */ updatels(ipc); diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index 7163617f1..8e6c45c3d 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -77,8 +77,8 @@ static void endtls(SSL *ssl); static unsigned long id_callback(void); #endif /* THREADED_CLIENT */ #endif /* HAVE_OPENSSL */ -/* static */ void CtdlIPC_getline(CtdlIPC* ipc, char *buf); -/* static */ void CtdlIPC_putline(CtdlIPC *ipc, const char *buf); +static void CtdlIPC_getline(CtdlIPC* ipc, char *buf); +static void CtdlIPC_putline(CtdlIPC *ipc, const char *buf); /* @@ -2802,7 +2802,7 @@ static unsigned long id_callback(void) { /* * input string from socket - implemented in terms of serv_read() */ -/* static */ void CtdlIPC_getline(CtdlIPC* ipc, char *buf) +static void CtdlIPC_getline(CtdlIPC* ipc, char *buf) { int i; @@ -2831,7 +2831,7 @@ void CtdlIPC_chat_recv(CtdlIPC* ipc, char* buf) /* * send line to server - implemented in terms of serv_write() */ -/* static */ void CtdlIPC_putline(CtdlIPC *ipc, const char *buf) +static void CtdlIPC_putline(CtdlIPC *ipc, const char *buf) { /* error_printf("< %s\n", buf); */ serv_write(ipc, buf, strlen(buf)); diff --git a/citadel/client_chat.c b/citadel/client_chat.c index 5b1351f72..cf559526a 100644 --- a/citadel/client_chat.c +++ b/citadel/client_chat.c @@ -71,8 +71,8 @@ void chatmode(CtdlIPC *ipc) struct timeval tv; int retval; - CtdlIPC_putline(ipc, "CHAT"); - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_send(ipc, "CHAT"); + CtdlIPC_chat_recv(ipc, buf); if (buf[0] != '8') { scr_printf("%s\n", &buf[4]); return; @@ -102,7 +102,7 @@ void chatmode(CtdlIPC *ipc) /* If there's data from the server... */ if (FD_ISSET(CtdlIPC_getsockfd(ipc), &rfds)) { - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_recv(ipc, buf); recv_complete_line = 1; goto RCL; /* ugly, but we've gotta get out! */ } @@ -126,7 +126,7 @@ void chatmode(CtdlIPC *ipc) /* if the user hit return, send the line */ RCL: if (send_complete_line) { - CtdlIPC_putline(ipc, wbuf); + CtdlIPC_chat_send(ipc, wbuf); last_transmit = time(NULL); strcpy(wbuf, ""); send_complete_line = 0; @@ -140,13 +140,13 @@ RCL: if (send_complete_line) { pos = a; } if (pos == 0) { - CtdlIPC_putline(ipc, wbuf); + CtdlIPC_chat_send(ipc, wbuf); last_transmit = time(NULL); strcpy(wbuf, ""); send_complete_line = 0; } else { wbuf[pos] = 0; - CtdlIPC_putline(ipc, wbuf); + CtdlIPC_chat_send(ipc, wbuf); last_transmit = time(NULL); strcpy(wbuf, &wbuf[pos + 1]); } @@ -165,9 +165,9 @@ RCL: if (send_complete_line) { * exiting chat. This little dialog forces * everything to be hunky-dory. */ - CtdlIPC_putline(ipc, "ECHO __ExitingChat__"); + CtdlIPC_chat_send(ipc, "ECHO __ExitingChat__"); do { - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_recv(ipc, buf); } while (strcmp(buf, "200 __ExitingChat__")); return; } @@ -217,7 +217,7 @@ RCL: if (send_complete_line) { * server to prevent session timeout. */ if ((time(NULL) - last_transmit) >= S_KEEPALIVE) { - CtdlIPC_putline(ipc, "NOOP"); + CtdlIPC_chat_send(ipc, "NOOP"); last_transmit = time(NULL); } @@ -239,8 +239,8 @@ void page_user(CtdlIPC *ipc) if (ipc->ServInfo.paging_level == 0) { newprompt("Message: ", msg, 69); snprintf(buf, sizeof buf, "SEXP %s|%s", touser, msg); - CtdlIPC_putline(ipc, buf); - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_send(ipc, buf); + CtdlIPC_chat_recv(ipc, buf); if (!strncmp(buf, "200", 3)) { strcpy(last_paged, touser); } @@ -250,8 +250,8 @@ void page_user(CtdlIPC *ipc) /* new server -- use extended paging */ else if (ipc->ServInfo.paging_level >= 1) { snprintf(buf, sizeof buf, "SEXP %s||", touser); - CtdlIPC_putline(ipc, buf); - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_send(ipc, buf); + CtdlIPC_chat_recv(ipc, buf); if (buf[0] != '2') { scr_printf("%s\n", &buf[4]); return; @@ -263,16 +263,16 @@ void page_user(CtdlIPC *ipc) pagefp = fopen(temp, "r"); unlink(temp); snprintf(buf, sizeof buf, "SEXP %s|-", touser); - CtdlIPC_putline(ipc, buf); - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_send(ipc, buf); + CtdlIPC_chat_recv(ipc, buf); if (buf[0] == '4') { strcpy(last_paged, touser); while (fgets(buf, sizeof buf, pagefp) != NULL) { buf[strlen(buf) - 1] = 0; - CtdlIPC_putline(ipc, buf); + CtdlIPC_chat_send(ipc, buf); } fclose(pagefp); - CtdlIPC_putline(ipc, "000"); + CtdlIPC_chat_send(ipc, "000"); scr_printf("Message sent.\n"); } else { scr_printf("%s\n", &buf[4]); diff --git a/citadel/commands.c b/citadel/commands.c index 26128b995..149f09581 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -377,7 +377,7 @@ static void really_do_keepalive(void) { */ if ( (keepalives_enabled == KA_HALF) && (ipc_for_signal_handlers->ServInfo.supports_qnop > 0) ) { - CtdlIPC_putline(ipc_for_signal_handlers, "QNOP"); + CtdlIPC_chat_send(ipc_for_signal_handlers, "QNOP"); } } @@ -1631,7 +1631,7 @@ char keymenu(char *menuprompt, char *menustring) { scr_printf(" "); } } - scr_printf(" -> "); + scr_printf("-> "); display_prompt = 0; } ch = lkey(); @@ -1660,7 +1660,7 @@ char keymenu(char *menuprompt, char *menustring) { scr_putc(buf[a]); } } - scr_printf("\n\n"); + scr_printf("\n"); return ch; } } diff --git a/citadel/rooms.c b/citadel/rooms.c index 91220fedd..3125a0874 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -845,19 +845,23 @@ void roomdir(CtdlIPC *ipc) char flsz[32]; char comment[SIZ]; char buf[SIZ]; + char *listing = NULL; /* Returned directory listing */ + int r; - CtdlIPC_putline(ipc, "RDIR"); - CtdlIPC_getline(ipc, buf); - if (buf[0] != '1') { - pprintf("%s\n", &buf[4]); + r = CtdlIPCReadDirectory(ipc, &listing, buf); + if (r / 100 != 1) { + pprintf("%s\n", buf); return; } - extract(comment, &buf[4], 0); - extract(flnm, &buf[4], 1); + extract(comment, buf, 0); + extract(flnm, buf, 1); pprintf("\nDirectory of %s on %s\n", flnm, comment); pprintf("-----------------------\n"); - while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) { + while (*listing && strlen(listing)) { + extract_token(buf, listing, 0, '\n'); + remove_token(listing, 0, '\n'); + extract(flnm, buf, 0); extract(flsz, buf, 1); extract(comment, buf, 2); @@ -1107,19 +1111,19 @@ void do_edit(CtdlIPC *ipc, fp = fopen(temp, "w"); fclose(fp); - CtdlIPC_putline(ipc, check_cmd); - CtdlIPC_getline(ipc, cmd); + CtdlIPC_chat_send(ipc, check_cmd); + CtdlIPC_chat_recv(ipc, cmd); if (cmd[0] != '2') { scr_printf("%s\n", &cmd[4]); return; } if (strlen(editor_paths[0]) > 0) { - CtdlIPC_putline(ipc, read_cmd); - CtdlIPC_getline(ipc, cmd); + CtdlIPC_chat_send(ipc, read_cmd); + CtdlIPC_chat_recv(ipc, cmd); if (cmd[0] == '1') { fp = fopen(temp, "w"); - while (CtdlIPC_getline(ipc, cmd), strcmp(cmd, "000")) { + while (CtdlIPC_chat_recv(ipc, cmd), strcmp(cmd, "000")) { fprintf(fp, "%s\n", cmd); } fclose(fp); @@ -1163,8 +1167,8 @@ void do_edit(CtdlIPC *ipc, } else { - CtdlIPC_putline(ipc, write_cmd); - CtdlIPC_getline(ipc, cmd); + CtdlIPC_chat_send(ipc, write_cmd); + CtdlIPC_chat_recv(ipc, cmd); if (cmd[0] != '4') { scr_printf("%s\n", &cmd[4]); return; @@ -1173,10 +1177,10 @@ void do_edit(CtdlIPC *ipc, fp = fopen(temp, "r"); while (fgets(cmd, SIZ - 1, fp) != NULL) { cmd[strlen(cmd) - 1] = 0; - CtdlIPC_putline(ipc, cmd); + CtdlIPC_chat_send(ipc, cmd); } fclose(fp); - CtdlIPC_putline(ipc, "000"); + CtdlIPC_chat_send(ipc, "000"); } unlink(temp); diff --git a/citadel/routines.c b/citadel/routines.c index cfae5d183..cb002dd5c 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -493,12 +493,12 @@ void locate_host(CtdlIPC* ipc, char *hbuf) void misc_server_cmd(CtdlIPC *ipc, char *cmd) { char buf[SIZ]; - CtdlIPC_putline(ipc, cmd); - CtdlIPC_getline(ipc, buf); + CtdlIPC_chat_send(ipc, cmd); + CtdlIPC_chat_recv(ipc, buf); scr_printf("%s\n",buf); if (buf[0]=='1') { set_keepalives(KA_HALF); - while (CtdlIPC_getline(ipc, buf), strcmp(buf,"000")) { + while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf,"000")) { scr_printf("%s\n",buf); } set_keepalives(KA_YES); @@ -507,7 +507,7 @@ void misc_server_cmd(CtdlIPC *ipc, char *cmd) { if (buf[0]=='4') { do { newprompt("> ",buf,255); - CtdlIPC_putline(ipc, buf); + CtdlIPC_chat_send(ipc, buf); } while(strcmp(buf,"000")); return; } diff --git a/citadel/routines2.c b/citadel/routines2.c index 6b280dd0f..b5ee17f19 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -908,6 +908,7 @@ void do_internet_configuration(CtdlIPC *ipc) int badkey; int i, j; int quitting = 0; + int modified = 0; int r; r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf); @@ -959,6 +960,7 @@ void do_internet_configuration(CtdlIPC *ipc) &buf[strlen(buf)]); recs[num_recs-1] = strdup(buf); } + modified = 1; break; case 'd': i = intprompt("Delete which one", @@ -967,6 +969,7 @@ void do_internet_configuration(CtdlIPC *ipc) --num_recs; for (j=i; jdd|elete|ave|uit"); switch(ch) { @@ -1212,6 +1220,7 @@ void do_ignet_configuration(CtdlIPC *ipc) { strprompt("Enter port number : ", &buf[strlen(buf)-3], 5); recs[num_recs-1] = strdup(buf); + modified = 1; break; case 'd': i = intprompt("Delete which one", @@ -1220,6 +1229,7 @@ void do_ignet_configuration(CtdlIPC *ipc) { --num_recs; for (j=i; j