From 8cec6efca9817eb0585cdcf55f80406453e262b0 Mon Sep 17 00:00:00 2001 From: kcwu Date: Sat, 9 Jun 2007 15:18:51 +0000 Subject: delete obsolete utilities. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3535 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/Makefile | 2 +- util/kenben.c | 44 ----------------------- util/merge_passwd.c | 100 ---------------------------------------------------- 3 files changed, 1 insertion(+), 145 deletions(-) delete mode 100644 util/kenben.c delete mode 100644 util/merge_passwd.c diff --git a/util/Makefile b/util/Makefile index 33f3726b..f768c106 100644 --- a/util/Makefile +++ b/util/Makefile @@ -34,7 +34,7 @@ CPROG_WITHOUT_UTIL= \ uhash_loader showboard \ countalldice bbsrf initbbs \ userlist merge_passwd \ - merge_board bbsmail gamble_fix + merge_board bbsmail # 下面這些程式會被 install PROGS= ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \ diff --git a/util/kenben.c b/util/kenben.c deleted file mode 100644 index 67b1e9bd..00000000 --- a/util/kenben.c +++ /dev/null @@ -1,44 +0,0 @@ -#include - - -void main() -{ - FILE * fin, * fout; - char line[255], line2[255]; - int i; - char genbuf[255], tok[20]; - fin = fopen("M.1006277896.A","r"); - while(!feof(fin)) - { - fgets(line,255,fin); - line[12] = '\0'; - - sprintf(genbuf, "cd "BBSHOME"/boards/%c/%s;grep " - "超過一個月無廣告以外的本站文章發表。" - " *.A > "BBSHOME"/pttbbs/util/kenken.txt", line[0], line); - system(genbuf); - - fout = fopen("kenken.txt","r"); - while(!feof(fout)) - { - line2[0] = '\0'; - fgets(line2,255,fout); - if(strlen(line2) <= 10) break; - sscanf(line2,"%s:",tok); - for(i = 0; i < 20;i++) - { - if(tok[i] == ':') - { - tok[i] = '\0'; - break; - } - } - sprintf(genbuf, "cd "BBSHOME"/boards/%c/%s;rm %s", line[0], line, tok); -// printf("%s \n", genbuf); - system(genbuf); - } - } - - fclose(fin); - -} diff --git a/util/merge_passwd.c b/util/merge_passwd.c deleted file mode 100644 index 7221e384..00000000 --- a/util/merge_passwd.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $Id$ */ -#include "bbs.h" - -typedef struct hash_t { - char *userid; - struct hash_t *next; -} hash_t; - -FILE *fout; -hash_t *hash_tbl[65536]; -int counter; - -void usage() { - fprintf(stderr, "Usage:\n\n" - "merge_passwd [input file1] [input file2] ...\n"); -} - -unsigned int string_hash(unsigned char *s) { - unsigned int v=0; - - while(*s) { - v = (v << 8) | (v >> 24); - v ^= toupper(*s++); /* note this is case insensitive */ - } - return (v * 2654435769U) >> (32 - 16); -} - -int is_exist(char *userid) { - int i; - hash_t *n; - - i = string_hash(userid); - for(n = hash_tbl[i]; n != NULL; n = n->next) - if(strcasecmp(userid, n->userid) == 0) - return 1; - return 0; -} - -void add_hash(char *userid) { - int i; - hash_t *n; - - i = string_hash(userid); - - n = malloc(sizeof(*n)); - n->userid = strdup(userid); - n->next = hash_tbl[i]; - hash_tbl[i] = n; -} - -void merge_user(userec_t *u) { - if(!is_exist(u->userid)) { - fwrite(u, sizeof(*u), 1, fout); - add_hash(u->userid); - ++counter; - } -} - -void merge_file(char *fname) { - FILE *fin; - userec_t u; - - if((fin = fopen(fname, "r")) == NULL) { - perror(fname); - return; - } - - counter = 0; - while(fread(&u, sizeof(u), 1, fin) == 1) - if(u.userid[0]) - merge_user(&u); - - printf("merge from %s: %d users\n", fname, counter); - - fclose(fin); -} - -int main(int argc, char **argv) { - int i; - - if(argc < 2) { - usage(); - return 1; - } - - bzero(hash_tbl, sizeof(hash_tbl)); - - if((fout = fopen(argv[1], "w")) == NULL) { - perror(argv[1]); - return 2; - } - - for(i = 2; i < argc; ++i) - merge_file(argv[i]); - - fclose(fout); - printf("Done\n"); - - return 0; -} -- cgit v1.2.3