and removed them from all other files. Linked in tools.[o|ro] there.
* 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
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
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 $<
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:
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 "*"
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
#include "ipc.h"
#include "client_chat.h"
#include "citadel_decls.h"
+#include "tools.h"
struct march {
struct march *next;
#include "dynloader.h"
#include "policy.h"
#include "control.h"
+#include "tools.h"
struct CitContext *ContextList = NULL;
int ScheduledShutdown = 0;
#include "support.h"
#include "config.h"
#include "msgbase.h"
+#include "tools.h"
struct CitControl CitControl;
struct config config;
#include "support.h"
#include "room_ops.h"
#include "msgbase.h"
+#include "tools.h"
void cmd_delf(char *filename)
{
#include "user_ops.h"
#include "control.h"
#include "dynloader.h"
+#include "tools.h"
#define MSGS_ALL 0
#define MSGS_OLD 1
#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
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);
#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
/*
* 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;
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");
cleanup(0);
return 0;
}
-
#include "msgbase.h"
#include "serv_chat.h"
#include "citserver.h"
+#include "tools.h"
/*
#include "serv_chat.h"
#include "citserver.h"
#include "control.h"
+#include "tools.h"
/*
* Generic routine for determining user access to rooms
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);
#include "citadel.h"
#include "routines.h"
#include "commands.h"
+#include "tools.h"
void sttybbs(int cmd);
void newprompt(char *prompt, char *str, int len);
}
-/*
- * 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;
/* $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);
#include "routines2.h"
#include "routines.h"
#include "commands.h"
+#include "tools.h"
void interr(int errnum);
void strprompt(char *prompt, char *str, int len);
#include "support.h"
#include "config.h"
#include "dynloader.h"
+#include "tools.h"
struct ChatLine *ChatQueue = NULL;
int ChatLastMsg = 0;
#include "msgbase.h"
#include "user_ops.h"
#include "control.h"
+#include "tools.h"
struct oldvisit {
#include "user_ops.h"
#include "database.h"
#include "control.h"
+#include "tools.h"
extern struct CitContext *ContextList;
FILE *imfp, *exfp;
-/*
- * 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 #
/* $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);
#include "database.h"
#include "housekeeping.h"
#include "dynloader.h"
+#include "tools.h"
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
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));
+ }
+
+
+
/* $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);
#include "config.h"
#include "dynloader.h"
#include "sysdep.h"
+#include "tools.h"
/*
#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)
{
#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)
{