diff options
-rw-r--r-- | util/Makefile | 35 | ||||
-rw-r--r-- | util/outmail.c | 72 |
2 files changed, 17 insertions, 90 deletions
diff --git a/util/Makefile b/util/Makefile index 4929a5a2..d1a80835 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,9 +1,15 @@ -# $Id: Makefile,v 1.37 2003/07/21 09:27:00 in2 Exp $ +# $Id$ .include "../pttbbs.mk" UTIL_OBJS= \ - util_cache.o util_record.o util_passwd.o util_var.o util_stuff.o + util_cache.o util_record.o util_passwd.o util_var.o util_stuff.o\ + util_osdep.o util_args.o + +# 用來從 ../mbbsd/xxx.c 產生 util_xxx.o +MBBSD_OBJS= \ + var stuff cache osdep \ + args # 下面這些程式, 會被 compile 並且和 $(UTIL_OBJS) 聯結 CPROG_WITH_UTIL= \ @@ -12,14 +18,15 @@ CPROG_WITH_UTIL= \ expire mandex rmuid horoscope \ openvice parse_news openticket topusr \ indexuser yearsold toplazyBM toplazyBBM \ - reaper buildAnnounce inndBM shmctl + reaper buildAnnounce inndBM shmctl \ + outmail bbsmail # 下面這些程式, 會直接被 compile CPROG_WITHOUT_UTIL= \ shmsweep uhash_loader showboard antispam \ countalldice webgrep bbsrf initbbs \ userlist tunepasswd buildir merge_passwd \ - merge_board xchatd outmail bbsmail + merge_board xchatd # 下面這些程式會被 install PROGS= ${UTIL_OBJS} ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \ @@ -36,23 +43,13 @@ ${fn}: ${fn}.c ${UTIL_OBJS} ${CC} ${CFLAGS} -o ${fn} ${UTIL_OBJS} ${fn}.c .endfor -util_var.o: ../mbbsd/var.c - ${CC} ${CFLAGS} -D_BBS_UTIL_C_ -c -o util_var.o ../mbbsd/var.c - -util_stuff.o: ../mbbsd/stuff.c - ${CC} ${CFLAGS} -D_BBS_UTIL_C_ -c -o util_stuff.o ../mbbsd/stuff.c - -util_cache.o: ../mbbsd/cache.c - ${CC} ${CFLAGS} -D_BBS_UTIL_C_ -c -o util_cache.o ../mbbsd/cache.c - -bbsmail: bbsmail.c ${UTIL_OBJS} ../mbbsd/osdep.o - ${CC} ${CFLAGS} -o bbsmail bbsmail.c ${UTIL_OBJS} ../mbbsd/osdep.o ${LDFLAGS} +.for fn in ${MBBSD_OBJS} +util_${fn}.o: ../mbbsd/${fn}.c + ${CC} ${CFLAGS} -D_BBS_UTIL_C_ -c -o $@ ../mbbsd/${fn}.c +.endfor xchatd: xchatd.c $(UTIL_OBJS) descrypt.c - $(CC) $(CFLAGS) -o $@ $@.c $(UTIL_OBJS) descrypt.c $(LIBCHAT) - -outmail: outmail.c - $(CC) $(CFLAGS) -o $@ $@.c $(LIBMAIL) + $(CC) $(CFLAGS) -o $@ $@.c $(UTIL_OBJS) descrypt.c install: $(PROGS) install -d $(BBSHOME)/bin/ diff --git a/util/outmail.c b/util/outmail.c index d8efb526..f818d2c6 100644 --- a/util/outmail.c +++ b/util/outmail.c @@ -1,4 +1,4 @@ -/* $Id: outmail.c,v 1.5 2003/04/19 18:36:10 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -16,76 +16,6 @@ #include "pttstruct.h" -#ifdef HAVE_SETPROCTITLE - -#include <sys/types.h> -#include <libutil.h> - -void initsetproctitle(int argc, char **argv, char **envp) { -} - -#else - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> - -char **Argv = NULL; /* pointer to argument vector */ -char *LastArgv = NULL; /* end of argv */ -extern char **environ; - -void initsetproctitle(int argc, char **argv, char **envp) { - register int i; - - /* Move the environment so setproctitle can use the space at - the top of memory. */ - for(i = 0; envp[i]; i++); - environ = malloc(sizeof(char *) * (i + 1)); - for(i = 0; envp[i]; i++) - environ[i] = strdup(envp[i]); - environ[i] = NULL; - - /* Save start and extent of argv for setproctitle. */ - Argv = argv; - if(i > 0) - LastArgv = envp[i - 1] + strlen(envp[i - 1]); - else - LastArgv = argv[argc - 1] + strlen(argv[argc - 1]); -} - -static void do_setproctitle(const char *cmdline) { - char buf[256], *p; - int i; - - strncpy(buf, cmdline, 256); - buf[255] = '\0'; - i = strlen(buf); - if(i > LastArgv - Argv[0] - 2) { - i = LastArgv - Argv[0] - 2; - } - strcpy(Argv[0], buf); - p = &Argv[0][i]; - while(p < LastArgv) - *p++='\0'; - Argv[1] = NULL; -} - -void setproctitle(const char* format, ...) { - char buf[256]; - - va_list args; - va_start(args, format); - vsprintf(buf, format,args); - do_setproctitle(buf); - va_end(args); -} -#endif - - - - - #define SPOOL BBSHOME "/out" #define INDEX SPOOL "/.DIR" #define NEWINDEX SPOOL "/.DIR.sending" |