From 2fe2098b829651c53c6880e6e6489ace09ba1b9e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 22 Nov 1998 17:08:58 +0000 Subject: [PATCH] * Moved num_parms() and all the extract() type functions into tools.c and removed them from all other files. Linked in tools.[o|ro] there. --- citadel/ChangeLog | 2 ++ citadel/Makefile.in | 29 ++++++++-------- citadel/citadel.c | 1 + citadel/citserver.c | 1 + citadel/control.c | 1 + citadel/file_ops.c | 1 + citadel/msgbase.c | 1 + citadel/netpoll.c | 68 +------------------------------------ citadel/netproc.c | 27 +++++++++++---- citadel/policy.c | 1 + citadel/room_ops.c | 1 + citadel/rooms.c | 3 -- citadel/routines.c | 66 +----------------------------------- citadel/routines.h | 4 --- citadel/routines2.c | 1 + citadel/serv_chat.c | 1 + citadel/serv_expire.c | 1 + citadel/serv_upgrade.c | 1 + citadel/support.c | 74 ---------------------------------------- citadel/support.h | 4 --- citadel/sysdep.c | 1 + citadel/tools.c | 76 ++++++++++++++++++++++++++++++++++++++++++ citadel/tools.h | 4 +++ citadel/user_ops.c | 1 + citadel/userlist.c | 69 +------------------------------------- citadel/whobbs.c | 57 +------------------------------ 26 files changed, 136 insertions(+), 360 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index b3e8253d6..1d411e040 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -6,6 +6,8 @@ Sat Nov 21 16:53:30 EST 1998 Art Cancro * serv_expire.c: finished the code to purge stale visits * sysdep.c: strip trailing nonprintables in client_gets() * routines2.c: fixed <.AS> command; all configs now work properly + * Moved num_parms() and all the extract() type functions into tools.c + and removed them from all other files. Linked in tools.[o|ro] there. Fri Nov 20 20:29:07 EST 1998 Art Cancro * setup.c: removed all prompts that can be configured from within the diff --git a/citadel/Makefile.in b/citadel/Makefile.in index c3d643fc1..58dc75c83 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -52,7 +52,7 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.c \ housekeeping.c internetmail.c ipc_c_tcp.c locate_host.c \ logging.c mailinglist.c messages.c msgbase.c msgform.c netmailer.c \ netpoll.c netproc.c netsetup.c policy.c proxy.c rcit.c readlog.c \ - room_ops.c rooms.c roomutil.c routines.c routines2.c serv_chat.c \ + room_ops.c rooms.c routines.c routines2.c serv_chat.c \ serv_info.c serv_test.c serv_upgrade.c setup.c snprintf.c stats.c \ support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \ whobbs.c @@ -73,11 +73,12 @@ serv_modules: $(SERV_MODULES) citadel: ipc_c_tcp.o citadel.o rooms.o routines.o routines2.o messages.o \ commands.o client_chat.o serv_info.o tools.o $(SNPRINTF) $(CC) ipc_c_tcp.o citadel.o rooms.o routines.o routines2.o messages.o \ - commands.o client_chat.o serv_info.o tools.o $(SNPRINTF) $(LDFLAGS) \ - -o citadel + commands.o client_chat.o serv_info.o tools.o $(SNPRINTF) $(LDFLAGS) \ + -o citadel -netpoll: netpoll.o config.o ipc_c_tcp.o $(SNPRINTF) - $(CC) netpoll.o config.o ipc_c_tcp.o $(SNPRINTF) $(LDFLAGS) -o netpoll +netpoll: netpoll.o config.o ipc_c_tcp.o tools.o $(SNPRINTF) + $(CC) netpoll.o config.o ipc_c_tcp.o tools.o \ + $(SNPRINTF) $(LDFLAGS) -o netpoll .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $< @@ -88,12 +89,12 @@ netpoll: netpoll.o config.o ipc_c_tcp.o $(SNPRINTF) citserver: citserver.ro user_ops.ro support.ro room_ops.ro file_ops.ro \ msgbase.ro config.ro sysdep.ro locate_host.ro \ housekeeping.ro database.ro control.ro logging.ro \ - policy.ro dynloader.ro $(SNPRINTF:.o=.ro) + policy.ro dynloader.ro tools.ro $(SNPRINTF:.o=.ro) $(CC) \ citserver.ro user_ops.ro room_ops.ro file_ops.ro support.ro \ msgbase.ro config.ro sysdep.ro locate_host.ro \ housekeeping.ro database.ro control.ro logging.ro \ - policy.ro dynloader.ro $(SNPRINTF:.o=.ro)\ + policy.ro dynloader.ro tools.ro $(SNPRINTF:.o=.ro)\ $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) -o citserver .c.ro: @@ -125,8 +126,9 @@ aidepost: aidepost.o config.o $(SNPRINTF) netmailer: netmailer.o internetmail.o config.o $(CC) netmailer.o config.o internetmail.o $(LDFLAGS) -o netmailer -netproc: netproc.o config.o ipc_c_tcp.o $(SNPRINTF) - $(CC) netproc.o config.o ipc_c_tcp.o $(SNPRINTF) $(LDFLAGS) -o netproc +netproc: netproc.o config.o ipc_c_tcp.o tools.o $(SNPRINTF) + $(CC) netproc.o config.o ipc_c_tcp.o tools.o \ + $(SNPRINTF) $(LDFLAGS) -o netproc citmail: citmail.o config.o internetmail.o $(SNPRINTF) @echo "*" @@ -148,11 +150,12 @@ netsetup: netsetup.o config.o proxy: proxy.o ipc_c_tcp.o $(CC) proxy.o ipc_c_tcp.o $(LDFLAGS) -o proxy -whobbs: whobbs.o ipc_c_tcp.o $(SNPRINTF) - $(CC) whobbs.o ipc_c_tcp.o $(SNPRINTF) $(LDFLAGS) -o whobbs +whobbs: whobbs.o ipc_c_tcp.o tools.o $(SNPRINTF) + $(CC) whobbs.o ipc_c_tcp.o tools.o $(SNPRINTF) $(LDFLAGS) -o whobbs -userlist: userlist.o ipc_c_tcp.o $(SNPRINTF) - $(CC) userlist.o ipc_c_tcp.o $(SNPRINTF) $(LDFLAGS) -o userlist +userlist: userlist.o ipc_c_tcp.o tools.o $(SNPRINTF) + $(CC) userlist.o ipc_c_tcp.o tools.o \ + $(SNPRINTF) $(LDFLAGS) -o userlist msgform: msgform.o $(CC) msgform.o $(LDFLAGS) -o msgform diff --git a/citadel/citadel.c b/citadel/citadel.c index d02182bae..f2000fd76 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -32,6 +32,7 @@ #include "ipc.h" #include "client_chat.h" #include "citadel_decls.h" +#include "tools.h" struct march { struct march *next; diff --git a/citadel/citserver.c b/citadel/citserver.c index 69a127256..8a9676298 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -29,6 +29,7 @@ #include "dynloader.h" #include "policy.h" #include "control.h" +#include "tools.h" struct CitContext *ContextList = NULL; int ScheduledShutdown = 0; diff --git a/citadel/control.c b/citadel/control.c index 79a155526..a4069b112 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -25,6 +25,7 @@ #include "support.h" #include "config.h" #include "msgbase.h" +#include "tools.h" struct CitControl CitControl; struct config config; diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 965c45b10..3043737d4 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -19,6 +19,7 @@ #include "support.h" #include "room_ops.h" #include "msgbase.h" +#include "tools.h" void cmd_delf(char *filename) { diff --git a/citadel/msgbase.c b/citadel/msgbase.c index ab0ba507c..8ab426acf 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -20,6 +20,7 @@ #include "user_ops.h" #include "control.h" #include "dynloader.h" +#include "tools.h" #define MSGS_ALL 0 #define MSGS_OLD 1 diff --git a/citadel/netpoll.c b/citadel/netpoll.c index 2a25d12c5..1874ecb61 100644 --- a/citadel/netpoll.c +++ b/citadel/netpoll.c @@ -6,6 +6,7 @@ #include #include #include "citadel.h" +#include "tools.h" /* * This variable defines the amount of network spool data that may be carried @@ -24,73 +25,6 @@ void get_config(void); struct config config; -/* - * num_parms() - discover number of parameters... - */ -int num_parms(char *source) -{ - int a; - int count = 1; - - for (a=0; a= n) { - strcpy(dest,""); - return; - } - strcpy(buf,source); - if ( (parmnum == 0) && (n == 1) ) { - strcpy(dest,buf); - return; - } - - while (count++ < parmnum) do { - strcpy(buf,&buf[1]); - } while( (strlen(buf)>0) && (buf[0]!='|') ); - if (buf[0]=='|') strcpy(buf,&buf[1]); - for (count = 0; count #include #include "citadel.h" +#include "tools.h" /* A list of users you wish to filter out of incoming traffic can be kept * in ./network/filterlist -- messages from these users will be automatically @@ -556,13 +557,12 @@ void ship_to(char *filenm, char *sysnm) /* send spool file filenm to system sysn /* * proc_file_transfer() - handle a simple file transfer packet * - * FIX This shouldn't be like this. What it needs to do is begin - * FIX an upload and transmit the file to the server. */ void proc_file_transfer(char *tname) { /* name of temp file containing the whole message */ - char buf[128]; - char dest_room[32]; + char buf[256]; + char dest_room[ROOMNAMELEN]; + char subdir_name[256]; FILE *tfp,*uud; int a; @@ -586,7 +586,23 @@ void proc_file_transfer(char *tname) return; } - sprintf(buf,"cd %s/files/%s; exec %s",bbs_home_directory,config.c_bucket_dir,UUDECODE); + strcpy(subdir_name, "---xxx---"); + sprintf(buf, "GOTO %s", dest_room); + serv_puts(buf); + serv_gets(buf); + if (buf[0]=='2') { + extract(subdir_name, &buf[4], 2); + if (strlen(subdir_name) == 0) strcpy(subdir_name, "--xxx--"); + } + + /* Change to the room's directory; if that fails, change to the + * bitbucket directory. Then run uudecode. + */ + sprintf(buf,"(cd %s/files/%s || cd %s/files/%s ) ; exec %s", + bbs_home_directory, subdir_name, + bbs_home_directory, config.c_bucket_dir, + UUDECODE); + uud=(FILE *)popen(buf,"w"); if (uud==NULL) { printf("netproc: cannot open uudecode pipe\n"); @@ -1271,4 +1287,3 @@ int main(int argc, char **argv) cleanup(0); return 0; } - diff --git a/citadel/policy.c b/citadel/policy.c index 961a41012..2b29ffe35 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -18,6 +18,7 @@ #include "msgbase.h" #include "serv_chat.h" #include "citserver.h" +#include "tools.h" /* diff --git a/citadel/room_ops.c b/citadel/room_ops.c index bf47e76ec..9f6bc5d52 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -19,6 +19,7 @@ #include "serv_chat.h" #include "citserver.h" #include "control.h" +#include "tools.h" /* * Generic routine for determining user access to rooms diff --git a/citadel/rooms.c b/citadel/rooms.c index 7f38460f1..aef5738a0 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -24,15 +24,12 @@ void sttybbs(int cmd); -void extract(char *dest, char *source, int parmnum); -int extract_int(char *source, int parmnum); void hit_any_key(void); int yesno(void); void strprompt(char *prompt, char *str, int len); void newprompt(char *prompt, char *str, int len); int struncmp(char *lstr, char *rstr, int len); void dotgoto(char *towhere, int display_name); -long extract_long(char *source, int parmnum); void serv_read(char *buf, int bytes); void formout(char *name); int inkey(void); diff --git a/citadel/routines.c b/citadel/routines.c index 08051a136..c74732a91 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -22,6 +22,7 @@ #include "citadel.h" #include "routines.h" #include "commands.h" +#include "tools.h" void sttybbs(int cmd); void newprompt(char *prompt, char *str, int len); @@ -71,71 +72,6 @@ int haschar(char *st, int ch) } -/* - * num_parms() - discover number of parameters... - */ -int num_parms(char *source) -{ - int a; - int count = 1; - - for (a=0; a= n) { - strcpy(dest,""); - return; - } - strcpy(buf,source); - if ( (parmnum == 0) && (n == 1) ) { - strcpy(dest,buf); - return; - } - - while (count++ < parmnum) do { - strcpy(buf,&buf[1]); - } while( (strlen(buf)>0) && (buf[0]!='|') ); - if (buf[0]=='|') strcpy(buf,&buf[1]); - for (count = 0; count= n) { - strcpy(dest,""); - return; - } - strcpy(buf,source); - if ( (parmnum == 0) && (n == 1) ) { - strcpy(dest,buf); - for (n=0; n0) && (buf[0]!='|') ); - if (buf[0]=='|') strcpy(buf,&buf[1]); - for (count = 0; count diff --git a/citadel/tools.c b/citadel/tools.c index c2d216ada..9335cbe98 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -19,3 +19,79 @@ char *safestrncpy(char *dest, const char *src, size_t n) dest[n - 1] = 0; return dest; } + + +/* + * num_parms() - discover number of parameters... + */ +int num_parms(char *source) +{ + int a; + int count = 1; + + for (a=0; a= n) { + strcpy(dest,""); + return; + } + strcpy(buf,source); + if ( (parmnum == 0) && (n == 1) ) { + strcpy(dest,buf); + for (n=0; n0) && (buf[0]!='|') ); + if (buf[0]=='|') strcpy(buf,&buf[1]); + for (count = 0; count #include "ipc.h" - -/* - * num_parms() - discover number of parameters... - */ -int num_parms(char *source) -{ - int a; - int count = 1; - - for (a=0; a= n) { - strcpy(dest,""); - return; - } - strcpy(buf,source); - if ( (parmnum == 0) && (n == 1) ) { - strcpy(dest,buf); - return; - } - - while (count++ < parmnum) do { - strcpy(buf,&buf[1]); - } while( (strlen(buf)>0) && (buf[0]!='|') ); - if (buf[0]=='|') strcpy(buf,&buf[1]); - for (count = 0; count #include "citadel.h" #include "ipc.h" - -/* - * num_parms() - discover number of parameters... - */ -int num_parms(char *source) -{ - int a; - int count = 1; - - for (a=0; a= n) { - strcpy(dest,""); - return; - } - strcpy(buf,source); - if ( (parmnum == 0) && (n == 1) ) { - strcpy(dest,buf); - return; - } - - while (count++ < parmnum) do { - strcpy(buf,&buf[1]); - } while( (strlen(buf)>0) && (buf[0]!='|') ); - if (buf[0]=='|') strcpy(buf,&buf[1]); - for (count = 0; count