* Moved num_parms() and all the extract() type functions into tools.c
authorArt Cancro <ajc@citadel.org>
Sun, 22 Nov 1998 17:08:58 +0000 (17:08 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 22 Nov 1998 17:08:58 +0000 (17:08 +0000)
          and removed them from all other files.  Linked in tools.[o|ro] there.

26 files changed:
citadel/ChangeLog
citadel/Makefile.in
citadel/citadel.c
citadel/citserver.c
citadel/control.c
citadel/file_ops.c
citadel/msgbase.c
citadel/netpoll.c
citadel/netproc.c
citadel/policy.c
citadel/room_ops.c
citadel/rooms.c
citadel/routines.c
citadel/routines.h
citadel/routines2.c
citadel/serv_chat.c
citadel/serv_expire.c
citadel/serv_upgrade.c
citadel/support.c
citadel/support.h
citadel/sysdep.c
citadel/tools.c
citadel/tools.h
citadel/user_ops.c
citadel/userlist.c
citadel/whobbs.c

index b3e8253d654c7ecaa0094c8b6271e113b94690cb..1d411e0400c26acf6555e5623725d7844ef72c2c 100644 (file)
@@ -6,6 +6,8 @@ Sat Nov 21 16:53:30 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * 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 <ajc@uncnsrd.mt-kisco.ny.us>
        * setup.c: removed all prompts that can be configured from within the
index c3d643fc16f4eacb50357b000b612950b34a4014..58dc75c83e415030e292d84b3e7c1a530ade9253 100644 (file)
@@ -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
index d02182bae15ae639baeb106f993298e939bd43c0..f2000fd767135c763fa669093cd9ea992b0eca2f 100644 (file)
@@ -32,6 +32,7 @@
 #include "ipc.h"
 #include "client_chat.h"
 #include "citadel_decls.h"
+#include "tools.h"
 
 struct march {
        struct march *next;
index 69a12725699a07c35b53caf15214e4234c3c1bd2..8a967629826e288d5196a5ed6a2cb105365ae6df 100644 (file)
@@ -29,6 +29,7 @@
 #include "dynloader.h"
 #include "policy.h"
 #include "control.h"
+#include "tools.h"
 
 struct CitContext *ContextList = NULL;
 int ScheduledShutdown = 0;
index 79a155526d0115642c7c44deaf46ff558050e729..a4069b1122b54661da078f56a17d48871dff8fe7 100644 (file)
@@ -25,6 +25,7 @@
 #include "support.h"
 #include "config.h"
 #include "msgbase.h"
+#include "tools.h"
 
 struct CitControl CitControl;
 struct config config;
index 965c45b103966a261fa6c41c14dcb3b1373d7efd..3043737d4e4c4b19bb23cb26f580798b665a90f7 100644 (file)
@@ -19,6 +19,7 @@
 #include "support.h"
 #include "room_ops.h"
 #include "msgbase.h"
+#include "tools.h"
 
 void cmd_delf(char *filename)
 {
index ab0ba507c74b46f86b12c2595e8dee5e14fffa46..8ab426acf20dff824bbb3c9694692768efa0aae0 100644 (file)
@@ -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
index 2a25d12c512bd1f19d67beb14142275fab5a351e..1874ecb610ca674e4fdafb2270d15b7b0e2cb45e 100644 (file)
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <errno.h>
 #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<strlen(source); ++a) 
-               if (source[a]=='|') ++count;
-       return(count);
-       }
-
-
-/*
- * extract()  -  extract a parameter from a series of "|" separated...
- */
-void extract(char *dest, char *source, int parmnum)
-{
-       char buf[256];
-       int count = 0;
-       int n;
-
-       n = num_parms(source);
-
-       if (parmnum >= 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<strlen(buf); ++count)
-               if (buf[count] == '|') buf[count] = 0;
-       strcpy(dest,buf);
-       }
-
-/*
- * extract_int()  -  extract an int parm w/o supplying a buffer
- */
-int extract_int(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atoi(buf));
-       }
-
-/*
- * extract_long()  -  extract a long parm w/o supplying a buffer
- */
-long extract_long(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atol(buf));
-       }
-
-
 void logoff(int code)
 {
        exit(code);
index a91b0473b5dd398dae776e5bddaae43f68814fc5..2966715e6ee14705759d2325985c3c509f80dde6 100644 (file)
@@ -39,6 +39,7 @@
 #include <signal.h>
 #include <errno.h>
 #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;
        }
-
index 961a41012b1d51cd4814f14dbf9c5846a11d2cdb..2b29ffe35481e0f772d4834cbefe7d577de25d7a 100644 (file)
@@ -18,6 +18,7 @@
 #include "msgbase.h"
 #include "serv_chat.h"
 #include "citserver.h"
+#include "tools.h"
 
 
 /*
index bf47e76ecbb126c5832f12147aa928f7ae6de567..9f6bc5d5297060c5aa990a10e734dfa03874e747 100644 (file)
@@ -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
index 7f38460f19b66abc8646d41b368d1231138a78ed..aef5738a0e4b5ccfa933942bbb26961dab0ac617 100644 (file)
 
 
 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);
index 08051a136baf0f95e65cf4f73fc9521b045ca150..c74732a9188dbd9d404599fbcd2b2fb8cd009b0d 100644 (file)
@@ -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<strlen(source); ++a) 
-               if (source[a]=='|') ++count;
-       return(count);
-       }
-
-/*
- * extract()  -  extract a parameter from a series of "|" separated...
- */
-void extract(char *dest, char *source, int parmnum)
-{
-       char buf[256];
-       int count = 0;
-       int n;
-
-       n = num_parms(source);
-
-       if (parmnum >= 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<strlen(buf); ++count)
-               if (buf[count] == '|') buf[count] = 0;
-       strcpy(dest,buf);
-       }
-
-/*
- * extract_int()  -  extract an int parm w/o supplying a buffer
- */
-int extract_int(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atoi(buf));
-       }
-
-/*
- * extract_long()  -  extract a long parm w/o supplying a buffer
- */
-long extract_long(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atol(buf));
-       }
-
 void back(int spaces) /* Destructive backspace */
             {
 int a;
index c8e373e168410de1374c8f5ff66271cbc3fe4f1b..d176a232f4074e6d414dfe0783d7a86e4c6a7430 100644 (file)
@@ -1,13 +1,9 @@
 /* $Id$ */
 void edituser(void);
-void extract(char *dest, char *source, int parmnum);
-long extract_long(char *source, int parmnum);
-int extract_int(char *source, int parmnum);
 void interr(int errnum);
 int struncmp(char *lstr, char *rstr, int len);
 int checkpagin(int lp, int pagin, int height);
 int pattern(char *search, char *patn);
-int num_parms(char *source);
 void enter_config(int mode);
 void locate_host(char *hbuf);
 void misc_server_cmd(char *cmd);
index 9e39b825e308a33be16b6983c44755a6960dc34e..658392e7820d0e65a5cc7af6267d89435faa119d 100644 (file)
@@ -20,6 +20,7 @@
 #include "routines2.h"
 #include "routines.h"
 #include "commands.h"
+#include "tools.h"
 
 void interr(int errnum);
 void strprompt(char *prompt, char *str, int len);
index 022ce07aaaa92d76734b13a130e326cc049fbce1..8325d768207122d86183a4e0cf75f983f578d386 100644 (file)
@@ -24,6 +24,7 @@
 #include "support.h"
 #include "config.h"
 #include "dynloader.h"
+#include "tools.h"
 
 struct ChatLine *ChatQueue = NULL;
 int ChatLastMsg = 0;
index a2694a953c131e07c31798a6ddebaaaaf1d444b9..817a8af2f7d71979a8d83070ece6f9b86f524541 100644 (file)
@@ -51,6 +51,7 @@
 #include "msgbase.h"
 #include "user_ops.h"
 #include "control.h"
+#include "tools.h"
 
 
 struct oldvisit {
index 85bc2a518849688b29318bd833da67c2ae542a53..1b72a88580311e166ff72271dd82bf12cbc79017 100644 (file)
@@ -32,6 +32,7 @@
 #include "user_ops.h"
 #include "database.h"
 #include "control.h"
+#include "tools.h"
 
 extern struct CitContext *ContextList;
 FILE *imfp, *exfp;
index 6bcf9c4852cc3cb9c6f96a7493806425aeea16f2..2ff3ba7fbc45b9e3342d51769f7a267d8549c572 100644 (file)
@@ -53,80 +53,6 @@ void strproc(char *string)
 
 
 
-/*
- * num_parms()  -  discover number of parameters...
- */
-int num_parms(char *source)
-{
-       int a;
-       int count = 1;
-
-       for (a=0; a<strlen(source); ++a) 
-               if (source[a]=='|') ++count;
-       return(count);
-       }
-
-/*
- * extract()  -  extract a parameter from a series of "|" separated...
- */
-void extract(char *dest, char *source, int parmnum)
-{
-       char buf[256];
-       int count = 0;
-       int n;
-
-       if (strlen(source)==0) {
-               strcpy(dest,"");
-               return;
-               }
-
-       n = num_parms(source);
-
-       if (parmnum >= n) {
-               strcpy(dest,"");
-               return;
-               }
-       strcpy(buf,source);
-       if ( (parmnum == 0) && (n == 1) ) {
-               strcpy(dest,buf);
-               for (n=0; n<strlen(dest); ++n)
-                       if (dest[n]=='|') dest[n] = 0;
-               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<strlen(buf); ++count)
-               if (buf[count] == '|') buf[count] = 0;
-       strcpy(dest,buf);
-       }
-
-/*
- * extract_int()  -  extract an int parm w/o supplying a buffer
- */
-int extract_int(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atoi(buf));
-       }
-
-/*
- * extract_long()  -  extract an long parm w/o supplying a buffer
- */
-long extract_long(char *source, long int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atol(buf));
-       }
-
-
-
 /*
  * get a line of text from a file
  * ignores lines starting with #
index 97d4bbbc159a24d52a739fe4eec3b48cd3c333a6..582e9c3360618131cfc6fedf6e800c5a13884bdc 100644 (file)
@@ -1,9 +1,5 @@
 /* $Id$ */
 void strproc (char *string);
-int num_parms (char *source);
-void extract (char *dest, char *source, int parmnum);
-int extract_int (char *source, int parmnum);
-long int extract_long (char *source, long int parmnum);
 int getstring (FILE *fp, char *string);
 int pattern2 (char *search, char *patn);
 void mesg_locate (char *targ, char *searchfor, int numdirs, char **dirs);
index cfc686aba4f7f9fd79a0765988c16956107be2b0..53497e2ea5cbeb8a527425fa28881d8be8089e3f 100644 (file)
@@ -42,6 +42,7 @@
 #include "database.h"
 #include "housekeeping.h"
 #include "dynloader.h"
+#include "tools.h"
 
 #ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
index c2d216ada2ed1879ed0b83fbedb091ac2f41fddc..9335cbe98ee6628650aad1bb1d526c6d58fc520c 100644 (file)
@@ -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<strlen(source); ++a) 
+               if (source[a]=='|') ++count;
+       return(count);
+       }
+
+/*
+ * extract()  -  extract a parameter from a series of "|" separated...
+ */
+void extract(char *dest, char *source, int parmnum)
+{
+       char buf[256];
+       int count = 0;
+       int n;
+
+       if (strlen(source)==0) {
+               strcpy(dest,"");
+               return;
+               }
+
+       n = num_parms(source);
+
+       if (parmnum >= n) {
+               strcpy(dest,"");
+               return;
+               }
+       strcpy(buf,source);
+       if ( (parmnum == 0) && (n == 1) ) {
+               strcpy(dest,buf);
+               for (n=0; n<strlen(dest); ++n)
+                       if (dest[n]=='|') dest[n] = 0;
+               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<strlen(buf); ++count)
+               if (buf[count] == '|') buf[count] = 0;
+       strcpy(dest,buf);
+       }
+
+/*
+ * extract_int()  -  extract an int parm w/o supplying a buffer
+ */
+int extract_int(char *source, int parmnum)
+{
+       char buf[256];
+       
+       extract(buf,source,parmnum);
+       return(atoi(buf));
+       }
+
+/*
+ * extract_long()  -  extract an long parm w/o supplying a buffer
+ */
+long extract_long(char *source, long int parmnum)
+{
+       char buf[256];
+       
+       extract(buf,source,parmnum);
+       return(atol(buf));
+       }
+
+
+
index 5387f2606213993addfcceab2db6708e4c05c451..68e1dc8b58e6effa9681f7164c10b329b18f2841 100644 (file)
@@ -1,2 +1,6 @@
 /* $Id$ */
 char *safestrncpy(char *dest, const char *src, size_t n);
+int num_parms (char *source);
+void extract (char *dest, char *source, int parmnum);
+int extract_int (char *source, int parmnum);
+long int extract_long (char *source, long int parmnum);
index bec8751edb44dc36975dc9b7b14edf978c1255d3..bbe373baaf5f7d3b22cc2ff83f5c5b3fa9d099d6 100644 (file)
@@ -33,6 +33,7 @@
 #include "config.h"
 #include "dynloader.h"
 #include "sysdep.h"
+#include "tools.h"
 
 
 /*
index effccf59ff1682feab7e61bf87b8ed66e6872032..41d313b59ee92aad4e6d6eae15784954b78ecddd 100644 (file)
@@ -7,74 +7,7 @@
 #include "citadel.h"
 #include <unistd.h>
 #include "ipc.h"
-
-/*
- * num_parms()  -  discover number of parameters...
- */
-int num_parms(char *source)
-{
-       int a;
-       int count = 1;
-
-       for (a=0; a<strlen(source); ++a) 
-               if (source[a]=='|') ++count;
-       return(count);
-       }
-
-
-/*
- * extract()  -  extract a parameter from a series of "|" separated...
- */
-void extract(char *dest, char *source, int parmnum)
-{
-       char buf[256];
-       int count = 0;
-       int n;
-
-       n = num_parms(source);
-
-       if (parmnum >= 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<strlen(buf); ++count)
-               if (buf[count] == '|') buf[count] = 0;
-       strcpy(dest,buf);
-       }
-
-/*
- * extract_int()  -  extract an int parm w/o supplying a buffer
- */
-int extract_int(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atoi(buf));
-       }
-
-
-/*
- * extract_long()  -  extract an long parm w/o supplying a buffer
- */
-long extract_long(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atol(buf));
-       }
-
+#include "tools.h"
 
 void logoff(int code)
 {
index 0dfaef948ff6ff6265cef61eeb2fa7c0984c343b..f0d59e2c09322d02ba478e7e3a5c8d7256bc3ad9 100644 (file)
@@ -5,62 +5,7 @@
 #include <string.h>
 #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<strlen(source); ++a) 
-               if (source[a]=='|') ++count;
-       return(count);
-       }
-
-
-/*
- * extract()  -  extract a parameter from a series of "|" separated...
- */
-void extract(char *dest, char *source, int parmnum)
-{
-       char buf[256];
-       int count = 0;
-       int n;
-
-       n = num_parms(source);
-
-       if (parmnum >= 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<strlen(buf); ++count)
-               if (buf[count] == '|') buf[count] = 0;
-       strcpy(dest,buf);
-       }
-
-/*
- * extract_int()  -  extract an int parm w/o supplying a buffer
- */
-int extract_int(char *source, int parmnum)
-{
-       char buf[256];
-       
-       extract(buf,source,parmnum);
-       return(atoi(buf));
-       }
-
+#include "tools.h"
 
 void logoff(int code)
 {