diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-08-15 14:13:29 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-08-15 14:13:29 +0800 |
commit | 3650a80bc5adbf783393f9f479c9dfd71e2f6dc5 (patch) | |
tree | 3cb2e60fd0dfc0d516b243142ffba12d5a273500 | |
parent | 25ac9df6116c1e90f768374b71f1a1b54b0df430 (diff) | |
download | pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.tar pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.tar.gz pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.tar.bz2 pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.tar.lz pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.tar.xz pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.tar.zst pttbbs-3650a80bc5adbf783393f9f479c9dfd71e2f6dc5.zip |
merge util_record.c to mbbsd/record.c
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1096 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | util/BM_money.c | 4 | ||||
-rw-r--r-- | util/Makefile | 6 | ||||
-rw-r--r-- | util/account.c | 2 | ||||
-rw-r--r-- | util/antispam.c | 2 | ||||
-rw-r--r-- | util/bbsmail.c | 4 | ||||
-rw-r--r-- | util/bbsrf.c | 2 | ||||
-rw-r--r-- | util/birth.c | 2 | ||||
-rw-r--r-- | util/buildir.c | 2 | ||||
-rw-r--r-- | util/countalldice.c | 2 | ||||
-rw-r--r-- | util/deluserfile.c | 2 | ||||
-rw-r--r-- | util/descrypt.c | 2 | ||||
-rw-r--r-- | util/expire.c | 2 | ||||
-rw-r--r-- | util/horoscope.c | 4 | ||||
-rw-r--r-- | util/indexuser.c | 4 | ||||
-rw-r--r-- | util/initbbs.c | 2 | ||||
-rw-r--r-- | util/jungo.c | 4 | ||||
-rw-r--r-- | util/mandex.c | 2 | ||||
-rw-r--r-- | util/merge_board.c | 2 | ||||
-rw-r--r-- | util/merge_passwd.c | 2 | ||||
-rw-r--r-- | util/openticket.c | 4 | ||||
-rw-r--r-- | util/openvice.c | 2 | ||||
-rw-r--r-- | util/parse_news.c | 2 | ||||
-rw-r--r-- | util/post.c | 2 | ||||
-rw-r--r-- | util/reaper.c | 4 | ||||
-rw-r--r-- | util/rmuid.c | 2 | ||||
-rw-r--r-- | util/showboard.c | 2 | ||||
-rw-r--r-- | util/toplazyBBM.c | 4 | ||||
-rw-r--r-- | util/toplazyBM.c | 2 | ||||
-rw-r--r-- | util/topusr.c | 4 | ||||
-rw-r--r-- | util/tunepasswd.c | 2 | ||||
-rw-r--r-- | util/uhash_loader.c | 2 | ||||
-rw-r--r-- | util/util_passwd.c | 2 | ||||
-rw-r--r-- | util/util_record.c | 246 | ||||
-rw-r--r-- | util/webgrep.c | 2 | ||||
-rw-r--r-- | util/xchatd.c | 2 | ||||
-rw-r--r-- | util/yearsold.c | 4 |
36 files changed, 47 insertions, 293 deletions
diff --git a/util/BM_money.c b/util/BM_money.c index 075f53ae..09e66257 100644 --- a/util/BM_money.c +++ b/util/BM_money.c @@ -1,4 +1,4 @@ -/* $Id: BM_money.c,v 1.7 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 給板主錢的程式 */ @@ -36,7 +36,7 @@ int main(int argc, char **argv) attach_SHM(); resolve_boards(); - if(passwd_mmap()) + if(passwd_init()) exit(1); if (!fp) return 0; diff --git a/util/Makefile b/util/Makefile index d1a80835..6b847752 100644 --- a/util/Makefile +++ b/util/Makefile @@ -9,7 +9,7 @@ UTIL_OBJS= \ # 用來從 ../mbbsd/xxx.c 產生 util_xxx.o MBBSD_OBJS= \ var stuff cache osdep \ - args + args passwd # 下面這些程式, 會被 compile 並且和 $(UTIL_OBJS) 聯結 CPROG_WITH_UTIL= \ @@ -40,7 +40,7 @@ all: ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${PROGS} .for fn in ${CPROG_WITH_UTIL} ${fn}: ${fn}.c ${UTIL_OBJS} - ${CC} ${CFLAGS} -o ${fn} ${UTIL_OBJS} ${fn}.c + ${CC} ${CFLAGS} ${LDFLAGS} -o ${fn} ${UTIL_OBJS} ${fn}.c .endfor .for fn in ${MBBSD_OBJS} @@ -49,7 +49,7 @@ util_${fn}.o: ../mbbsd/${fn}.c .endfor xchatd: xchatd.c $(UTIL_OBJS) descrypt.c - $(CC) $(CFLAGS) -o $@ $@.c $(UTIL_OBJS) descrypt.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $@.c $(UTIL_OBJS) descrypt.c install: $(PROGS) install -d $(BBSHOME)/bin/ diff --git a/util/account.c b/util/account.c index 827eefb4..b3f65f82 100644 --- a/util/account.c +++ b/util/account.c @@ -1,4 +1,4 @@ -/* $Id: account.c,v 1.9 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #include "bbs.h" #define MAX_LINE 16 diff --git a/util/antispam.c b/util/antispam.c index e29549aa..e5b2ed59 100644 --- a/util/antispam.c +++ b/util/antispam.c @@ -1,4 +1,4 @@ -/* $Id: antispam.c,v 1.2 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 抓廣告信的程式 */ #include <stdio.h> #include <string.h> diff --git a/util/bbsmail.c b/util/bbsmail.c index 7ef9435d..f2390254 100644 --- a/util/bbsmail.c +++ b/util/bbsmail.c @@ -1,4 +1,4 @@ -/* $Id: bbsmail.c,v 1.8 2003/07/21 07:11:50 in2 Exp $ */ +/* $Id$ */ #define _UTIL_C_ #include "bbs.h" @@ -252,7 +252,7 @@ main(int argc, char* argv[]) (void) setgid(BBSGID); (void) setuid(BBSUID); attach_SHM(); - if( passwd_mmap() ) + if( passwd_init() ) return 0; chdir(BBSHOME); diff --git a/util/bbsrf.c b/util/bbsrf.c index 66f6cee0..c527d761 100644 --- a/util/bbsrf.c +++ b/util/bbsrf.c @@ -1,4 +1,4 @@ -/* $Id: bbsrf.c,v 1.1 2002/03/07 15:13:45 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <string.h> diff --git a/util/birth.c b/util/birth.c index b7f65761..20bd65c0 100644 --- a/util/birth.c +++ b/util/birth.c @@ -49,7 +49,7 @@ int main(argc, argv) now = time(NULL); /* back to ancent */ ptime = localtime(&now); - if(passwd_mmap()) + if(passwd_init()) exit(1); printf("*製表\n"); diff --git a/util/buildir.c b/util/buildir.c index 38573e7f..e6b7f9d2 100644 --- a/util/buildir.c +++ b/util/buildir.c @@ -1,4 +1,4 @@ -/* $Id: buildir.c,v 1.2 2002/03/09 17:44:30 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <stdlib.h> #include <dirent.h> diff --git a/util/countalldice.c b/util/countalldice.c index badd4bad..63354668 100644 --- a/util/countalldice.c +++ b/util/countalldice.c @@ -1,4 +1,4 @@ -/* $Id: countalldice.c,v 1.1 2002/03/07 15:13:45 in2 Exp $ */ +/* $Id$ */ /**********************************************/ /*這個程式是用來計算賭骰子賺得錢跟賠的錢的程式 */ diff --git a/util/deluserfile.c b/util/deluserfile.c index 543048d0..73f3750a 100644 --- a/util/deluserfile.c +++ b/util/deluserfile.c @@ -1,4 +1,4 @@ -/* $Id: deluserfile.c,v 1.3 2002/06/06 21:34:14 in2 Exp $ */ +/* $Id$ */ /* 自動砍user目錄檔案程式 */ #include "bbs.h" diff --git a/util/descrypt.c b/util/descrypt.c index 97475c1a..6ea6dbe8 100644 --- a/util/descrypt.c +++ b/util/descrypt.c @@ -1,4 +1,4 @@ -/* $Id: descrypt.c,v 1.1 2002/03/07 15:13:45 in2 Exp $ */ +/* $Id$ */ /* * FreeSec: libcrypt for NetBSD diff --git a/util/expire.c b/util/expire.c index b75c85b8..4335ca16 100644 --- a/util/expire.c +++ b/util/expire.c @@ -1,4 +1,4 @@ -/* $Id: expire.c,v 1.7 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 自動砍信工具程式 */ #include "bbs.h" diff --git a/util/horoscope.c b/util/horoscope.c index b47634aa..04479108 100644 --- a/util/horoscope.c +++ b/util/horoscope.c @@ -1,4 +1,4 @@ -/* $Id: horoscope.c,v 1.4 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #define _UTIL_C_ #include "bbs.h" @@ -34,7 +34,7 @@ int main() { attach_SHM(); memset(act, 0, sizeof(act)); - if(passwd_mmap()) + if(passwd_init()) exit(1); for(k = 1; k <= MAX_USERS; k++) { passwd_query(k, &cuser); diff --git a/util/indexuser.c b/util/indexuser.c index e0975130..8dde8f06 100644 --- a/util/indexuser.c +++ b/util/indexuser.c @@ -1,4 +1,4 @@ -/* $Id: indexuser.c,v 1.6 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #define _UTIL_C_ #include "bbs.h" #define INDEXPATH BBSHOME"/index" @@ -22,7 +22,7 @@ int main(int argc, char **argv) char buf[256]; attach_SHM(); - if(passwd_mmap()) + if(passwd_init()) { printf("Sorry, the data is not ready.\n"); exit(0); diff --git a/util/initbbs.c b/util/initbbs.c index 72988353..e093fe02 100644 --- a/util/initbbs.c +++ b/util/initbbs.c @@ -1,4 +1,4 @@ -/* $Id: initbbs.c,v 1.6 2003/05/23 00:58:32 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/util/jungo.c b/util/jungo.c index 4f038efe..c0723c61 100644 --- a/util/jungo.c +++ b/util/jungo.c @@ -1,4 +1,4 @@ -/* $Id: jungo.c,v 1.7 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #define _UTIL_C_ #include "bbs.h" @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) attach_SHM(); resolve_boards(); - if(passwd_mmap()) + if(passwd_init()) exit(1); memcpy(allbrd,bcache,numboards*sizeof(boardheader_t)); diff --git a/util/mandex.c b/util/mandex.c index f1059f68..ed8ee9c9 100644 --- a/util/mandex.c +++ b/util/mandex.c @@ -1,4 +1,4 @@ -/* $Id: mandex.c,v 1.10 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 'mandex -h' to help */ diff --git a/util/merge_board.c b/util/merge_board.c index 743ffc14..12f41346 100644 --- a/util/merge_board.c +++ b/util/merge_board.c @@ -1,4 +1,4 @@ -/* $Id: merge_board.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> diff --git a/util/merge_passwd.c b/util/merge_passwd.c index d27c473b..20f59aae 100644 --- a/util/merge_passwd.c +++ b/util/merge_passwd.c @@ -1,4 +1,4 @@ -/* $Id: merge_passwd.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> diff --git a/util/openticket.c b/util/openticket.c index 5d7584bc..bcc58d0a 100644 --- a/util/openticket.c +++ b/util/openticket.c @@ -1,4 +1,4 @@ -/* $Id: openticket.c,v 1.10 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 開獎的 utility */ #define _UTIL_C_ #include "bbs.h" @@ -32,7 +32,7 @@ int main(int argc, char **argv) nice(10); attach_SHM(); - if(passwd_mmap()) + if(passwd_init()) exit(1); rename(BBSHOME "/etc/" FN_TICKET_RECORD, diff --git a/util/openvice.c b/util/openvice.c index 41c146ab..abc08272 100644 --- a/util/openvice.c +++ b/util/openvice.c @@ -1,4 +1,4 @@ -/* $Id: openvice.c,v 1.3 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 發票開獎小程式 */ #include "bbs.h" diff --git a/util/parse_news.c b/util/parse_news.c index b1f0ad25..6ea75454 100644 --- a/util/parse_news.c +++ b/util/parse_news.c @@ -1,4 +1,4 @@ -/* $Id: parse_news.c,v 1.5 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #include "bbs.h" #define NEWSDIRECT BBSHOME "/boards/n/newspaper" diff --git a/util/post.c b/util/post.c index ba6ee1d7..c3af5269 100644 --- a/util/post.c +++ b/util/post.c @@ -1,4 +1,4 @@ -/* $Id: post.c,v 1.5 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #include "bbs.h" void keeplog(FILE *fin, char *fpath, char *board, char *title, char *owner) { diff --git a/util/reaper.c b/util/reaper.c index 633a4c78..03f7a694 100644 --- a/util/reaper.c +++ b/util/reaper.c @@ -1,4 +1,4 @@ -/* $Id: reaper.c,v 1.4 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #define _UTIL_C_ #include "bbs.h" @@ -53,7 +53,7 @@ int main(int argc, char **argv) chdir(BBSHOME); attach_SHM(); - if(passwd_mmap()) + if(passwd_init()) exit(1); passwd_apply2(check); diff --git a/util/rmuid.c b/util/rmuid.c index 2bd1017a..01898721 100644 --- a/util/rmuid.c +++ b/util/rmuid.c @@ -1,4 +1,4 @@ -/* $Id: rmuid.c,v 1.4 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #include "bbs.h" extern int numboards; diff --git a/util/showboard.c b/util/showboard.c index 91593b12..7dee4002 100644 --- a/util/showboard.c +++ b/util/showboard.c @@ -1,4 +1,4 @@ -/* $Id: showboard.c,v 1.2 2002/04/05 14:36:25 in2 Exp $ */ +/* $Id$ */ /* 看板一覽表(sorted) */ #include <stdio.h> diff --git a/util/toplazyBBM.c b/util/toplazyBBM.c index 0e5b078b..97cb62ae 100644 --- a/util/toplazyBBM.c +++ b/util/toplazyBBM.c @@ -1,4 +1,4 @@ -/* $Id: toplazyBBM.c,v 1.7 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #define _UTIL_C_ #include "bbs.h" @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) attach_SHM(); resolve_boards(); - if(passwd_mmap()) + if(passwd_init()) exit(1); memcpy(allbrd,bcache,numboards*sizeof(boardheader_t)); diff --git a/util/toplazyBM.c b/util/toplazyBM.c index 55267927..bf31be58 100644 --- a/util/toplazyBM.c +++ b/util/toplazyBM.c @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) attach_SHM(); resolve_boards(); - if(passwd_mmap()) + if(passwd_init()) exit(1); memcpy(allbrd,bcache,numboards*sizeof(boardheader_t)); diff --git a/util/topusr.c b/util/topusr.c index 37b051d9..5aa2eb7a 100644 --- a/util/topusr.c +++ b/util/topusr.c @@ -1,4 +1,4 @@ -/* $Id: topusr.c,v 1.4 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 使用者 上站記錄/文章篇數 排行榜 */ #define _UTIL_C_ #include "bbs.h" @@ -123,7 +123,7 @@ int main(int argc, char **argv) num = 30; attach_SHM(); - if(passwd_mmap()) + if(passwd_init()) { printf("Sorry, the data is not ready.\n"); exit(0); diff --git a/util/tunepasswd.c b/util/tunepasswd.c index 15a3fe1f..1d575dcc 100644 --- a/util/tunepasswd.c +++ b/util/tunepasswd.c @@ -1,4 +1,4 @@ -/* $Id: tunepasswd.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <string.h> #include <unistd.h> diff --git a/util/uhash_loader.c b/util/uhash_loader.c index 7d066ab9..d5171d56 100644 --- a/util/uhash_loader.c +++ b/util/uhash_loader.c @@ -1,4 +1,4 @@ -/* $Id: uhash_loader.c,v 1.4 2003/05/15 08:27:23 in2 Exp $ */ +/* $Id$ */ /* standalone uhash loader -- jochang */ #include <stdio.h> #include <stdlib.h> diff --git a/util/util_passwd.c b/util/util_passwd.c index d7f1cea2..6fdf136c 100644 --- a/util/util_passwd.c +++ b/util/util_passwd.c @@ -1,4 +1,4 @@ -/* $Id: util_passwd.c,v 1.4 2003/05/15 08:27:23 in2 Exp $ */ +/* $Id$ */ #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/util/util_record.c b/util/util_record.c deleted file mode 100644 index 80a7ff56..00000000 --- a/util/util_record.c +++ /dev/null @@ -1,246 +0,0 @@ -/* $Id: util_record.c,v 1.4 2003/05/15 08:27:23 in2 Exp $ */ -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <time.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/file.h> -#include "config.h" -#include "pttstruct.h" -#include "modes.h" -#include "proto.h" - -#undef HAVE_MMAP -#define BUFSIZE 512 - -extern char *str_reply; - -static void PttLock(int fd, int size, int mode) { - static struct flock lock_it; - int ret; - - lock_it.l_whence = SEEK_CUR; /* from current point */ - lock_it.l_start = 0; /* -"- */ - lock_it.l_len = size; /* length of data */ - lock_it.l_type = mode; /* set exclusive/write lock */ - lock_it.l_pid = 0; /* pid not actually interesting */ - while((ret = fcntl(fd, F_SETLKW, &lock_it)) < 0 && errno == EINTR); -} - -#define safewrite write - -int get_num_records(char *fpath, int size) { - struct stat st; - if(stat(fpath, &st) == -1) - return 0; - return st.st_size / size; -} - -int get_sum_records(char* fpath, int size) { - struct stat st; - long ans = 0; - FILE* fp; - fileheader_t fhdr; - char buf[200], *p; - - if(!(fp = fopen(fpath, "r"))) - return -1; - - strcpy(buf, fpath); - p = strrchr(buf, '/') + 1; - - while(fread(&fhdr, size, 1, fp) == 1) { - strcpy(p, fhdr.filename); - if(stat(buf, &st) == 0 && S_ISREG(st.st_mode) && st.st_nlink == 1) - ans += st.st_size; - } - fclose(fp); - return ans / 1024; -} - -int get_record(char *fpath, void *rptr, int size, int id) { - int fd = -1; - - if(id < 1 || (fd = open(fpath, O_RDONLY, 0)) != -1) { - if(lseek(fd, (off_t)(size * (id - 1)), SEEK_SET) != -1) { - if(read(fd, rptr, size) == size) { - close(fd); - return 0; - } - } - close(fd); - } - return -1; -} - -int get_records(char *fpath, void *rptr, int size, int id, int number) { - int fd; - - if(id < 1 || (fd = open(fpath, O_RDONLY, 0)) == -1) - return -1; - - if(lseek(fd, (off_t)(size * (id - 1)), SEEK_SET) == -1) { - close(fd); - return 0; - } - if((id = read(fd, rptr, size * number)) == -1) { - close(fd); - return -1; - } - close(fd); - return id / size; -} - -int substitute_record(char *fpath, void *rptr, int size, int id) { - int fd; - -#ifdef POSTBUG - if(size == sizeof(fileheader) && (id > 1) && ((id - 1) % 4 == 0)) - saverecords(fpath, size, id); -#endif - - if(id < 1 || (fd = open(fpath, O_WRONLY | O_CREAT, 0644)) == -1) - return -1; - -#ifdef HAVE_REPORT - if(lseek(fd, (off_t)(size * (id - 1)), SEEK_SET) == -1) - report("substitute_record failed!!! (lseek)"); - PttLock(fd, size, F_WRLCK); - if(safewrite(fd, rptr, size) != size) - report("substitute_record failed!!! (safewrite)"); - PttLock(fd, size, F_UNLCK); -#else - lseek(fd, (off_t) (size * (id - 1)), SEEK_SET); - PttLock(fd, size, F_WRLCK); - safewrite(fd, rptr, size); - PttLock(fd, size, F_UNLCK); -#endif - close(fd); - -#ifdef POSTBUG - if(size == sizeof(fileheader) && (id > 1) && ((id - 1) % 4 == 0)) - restorerecords(fpath, size, id); -#endif - - return 0; -} - -int apply_record(char *fpath, int (*fptr)(), int size) { - char abuf[BUFSIZE]; - FILE* fp; - - if(!(fp = fopen(fpath, "r"))) - return -1; - - while(fread(abuf, 1, size, fp) == (unsigned)size) - if((*fptr) (abuf) == QUIT) { - fclose(fp); - return QUIT; - } - fclose(fp); - return 0; -} - -/* mail / post 時,依據時間建立檔案,加上郵戳 */ -int stampfile(char *fpath, fileheader_t *fh) { - register char *ip = fpath; - time_t dtime; - struct tm *ptime; - int fp = 0; - - if(access(fpath, X_OK | R_OK | W_OK)) - mkdir(fpath, 0755); - - time(&dtime); - while (*(++ip)); - *ip++ = '/'; - do { - sprintf(ip, "M.%ld.A.%3.3X", ++dtime, rand()&0xfff ); - if(fp == -1 && errno != EEXIST) - return -1; - } while((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1); - close(fp); - memset(fh, 0, sizeof(fileheader_t)); - strcpy(fh->filename, ip); - ptime = localtime(&dtime); - sprintf(fh->date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); - return 0; -} - -void stampdir(char *fpath, fileheader_t *fh) { - register char *ip = fpath; - time_t dtime; - struct tm *ptime; - - if(access(fpath, X_OK | R_OK | W_OK)) - mkdir(fpath, 0755); - - time(&dtime); - while(*(++ip)); - *ip++ = '/'; - do { - sprintf(ip, "D%lX", ++dtime & 07777); - } while(mkdir(fpath, 0755) == -1); - memset(fh, 0, sizeof(fileheader_t)); - strcpy(fh->filename, ip); - ptime = localtime(&dtime); - sprintf(fh->date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); -} - -void stamplink(char *fpath, fileheader_t *fh) { - register char *ip = fpath; - time_t dtime; - struct tm *ptime; - - if(access(fpath, X_OK | R_OK | W_OK)) - mkdir(fpath, 0755); - - time(&dtime); - while(*(++ip)); - *ip++ = '/'; - do { - sprintf(ip, "S%lX", ++dtime ); - } while(symlink("temp", fpath) == -1); - memset(fh, 0, sizeof(fileheader_t)); - strcpy(fh->filename, ip); - ptime = localtime(&dtime); - sprintf(fh->date, "%2d/%02d", ptime->tm_mon + 1, ptime->tm_mday); -} - -int do_append(char *fpath, fileheader_t *record, int size) { - int fd; - - if((fd = open(fpath, O_WRONLY | O_CREAT, 0644)) == -1) { - perror("open"); - return -1; - } - flock(fd, LOCK_EX); - lseek(fd, 0, SEEK_END); - - safewrite(fd, record, size); - - flock(fd, LOCK_UN); - close(fd); - return 0; -} - -int append_record(char *fpath, fileheader_t *record, int size) { -#ifdef POSTBUG - int numrecs = (int)get_num_records(fpath, size); - - bug_possible = 1; - if(size == sizeof(fileheader) && numrecs && (numrecs % 4 == 0)) - saverecords(fpath, size, numrecs + 1); -#endif - do_append(fpath,record,size); - -#ifdef POSTBUG - if(size == sizeof(fileheader) && numrecs && (numrecs % 4 == 0)) - restorerecords(fpath, size, numrecs + 1); - bug_possible = 0; -#endif - return 0; -} diff --git a/util/webgrep.c b/util/webgrep.c index d3d7304f..d101e035 100644 --- a/util/webgrep.c +++ b/util/webgrep.c @@ -1,4 +1,4 @@ -/* $Id: webgrep.c,v 1.2 2002/06/19 13:38:01 lwms Exp $ */ +/* $Id$ */ #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/util/xchatd.c b/util/xchatd.c index b4aef8a6..906bded0 100644 --- a/util/xchatd.c +++ b/util/xchatd.c @@ -1,4 +1,4 @@ -/* $Id: xchatd.c,v 1.3 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ #include "bbs.h" #include "xchatd.h" diff --git a/util/yearsold.c b/util/yearsold.c index 3229b709..f93134a6 100644 --- a/util/yearsold.c +++ b/util/yearsold.c @@ -1,4 +1,4 @@ -/* $Id: yearsold.c,v 1.5 2003/07/20 00:55:34 in2 Exp $ */ +/* $Id$ */ /* 站上年齡統計 */ #define _UTIL_C_ #include "bbs.h" @@ -38,7 +38,7 @@ int main(int argc, char **argv) ptime = localtime(&now); attach_SHM(); - if(passwd_mmap()) + if(passwd_init()) exit(1); memset(act, 0, sizeof(act)); |