From e66641d118d32c1cbb202b4e18198b502fe627a5 Mon Sep 17 00:00:00 2001 From: scw Date: Wed, 15 Sep 2004 09:11:54 +0000 Subject: Ignore the ones whose PERM_ANGEL have been removed in angel.c. Using $(MAKE) instead of 'make' in util/Makefile. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2195 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/Makefile | 4 ++-- util/angel.c | 49 ++++++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/util/Makefile b/util/Makefile index e4e88871..70c3387f 100644 --- a/util/Makefile +++ b/util/Makefile @@ -44,7 +44,7 @@ PROGS= ${UTIL_OBJS} ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \ all: ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} ${PROGS} ../include/var.h: ../mbbsd/var.c - cd ../mbbsd; make ../include/var.h + cd ../mbbsd; $(MAKE) ../include/var.h .for fn in ${CPROG_WITH_UTIL} ${fn}: ${BBSBASE} ${fn}.c ${UTIL_OBJS} @@ -68,7 +68,7 @@ install: $(PROGS) install -c -m 755 $(PROGS) $(BBSHOME)/bin/ chmod 4755 $(BBSHOME)/bin/post .if defined(WITHFILTERMAIL) - make installfiltermail + $(MAKE) installfiltermail .endif clean: diff --git a/util/angel.c b/util/angel.c index 8ffcb994..fca4c0d7 100644 --- a/util/angel.c +++ b/util/angel.c @@ -28,9 +28,9 @@ void readData(); void sendResult(); int main(int argc, char* argv[]){ - if(argc > 1) + if (argc > 1) mailto = argv[1]; - if(argc > 2) + if (argc > 2) nReport = atoi(argv[2]); readData(); @@ -47,36 +47,39 @@ void readData(){ attach_SHM(); fp = fopen(BBSHOME "/.Angel", "rb"); - if(fp != 0){ + if (fp != 0) { fread(reject, 1, sizeof(reject), fp); fclose(fp); } fp = fopen(BBSHOME "/.PASSWDS", "rb"); j = count = 0; - while(fread(&user, sizeof(userec_t), 1, fp) == 1){ + while (fread(&user, sizeof(userec_t), 1, fp) == 1) { ++j; /* j == uid */ - if(user.myangel[0]){ + if (user.myangel[0]) { i = searchuser(user.myangel); - if(i) + if (i) ++total[i]; } - if(user.userlevel & PERM_ANGEL){ + if (user.userlevel & PERM_ANGEL) { ++count; ++nReject[((user.uflag2 & ANGEL_MASK) >> 12)]; ++total[j]; /* make all angel have total > 0 */ - if(user.uflag2 & REJ_QUESTION){ + if (user.uflag2 & REJ_QUESTION) { ++rej_question; - if(++reject[j] >= 2) + if (++reject[j] >= 2) ++double_rej; - }else + } else reject[j] = 0; + } else { /* don't have PERM_ANGEL */ + total[j] = INT_MIN; + reject[j] = 0; } } fclose(fp); fp = fopen(BBSHOME "/.Angel", "wb"); - if(fp != NULL){ + if (fp != NULL) { fwrite(reject, sizeof(reject), 1, fp); fclose(fp); } @@ -87,12 +90,12 @@ void readData(){ list = (int(*)[2]) malloc(count * sizeof(int[2])); rej_list = (int*) malloc(double_rej * sizeof(int)); k = j = 0; - for(i = 0; i < MAX_USERS; ++i) - if(total[i]){ + for (i = 0; i < MAX_USERS; ++i) + if (total[i] > 0) { list[j][0] = total[i] - 1; list[j][1] = i; ++j; - if(reject[i]) + if (reject[i]) rej_list[k++] = i; } @@ -103,7 +106,7 @@ void readData(){ int mailalertuser(char* userid) { userinfo_t *uentp=NULL; - if(userid[0] && (uentp = search_ulist_userid(userid)) ) + if (userid[0] && (uentp = search_ulist_userid(userid))) uentp->mailalert=1; return 0; } @@ -117,20 +120,20 @@ void sendResult(){ char filename[512]; sprintf(filename, BBSHOME "/home/%c/%s", mailto[0], mailto); - if( stat(filename, &st) == -1 ){ - if( mkdir(filename, 0755) == -1 ){ + if (stat(filename, &st) == -1) { + if (mkdir(filename, 0755) == -1) { fprintf(stderr, "mail box create error %s \n", filename); return; } } - else if( !(st.st_mode & S_IFDIR) ){ + else if (!(st.st_mode & S_IFDIR)) { fprintf(stderr, "mail box error\n"); return; } stampfile(filename, &header); fp = fopen(filename, "w"); - if(fp == NULL){ + if (fp == NULL) { fprintf(stderr, "Cannot open file %s\n", filename); return; } @@ -142,7 +145,7 @@ void sendResult(){ "\n現在全站小天使有 %d 位\n" "\n小主人人數最多的 %d 位小天使:\n", ctime(&t), count, nReport); - for(i = 0; i < nReport; ++i) + for (i = 0; i < nReport; ++i) fprintf(fp, "%15s %5d 人\n", SHM->userid[list[i][1] - 1], list[i][0]); fprintf(fp, "\n現在男女皆收的小天使有 %d 位\n" "只收女生的有 %d 位 (共 %d 位收女生)\n" @@ -154,12 +157,12 @@ void sendResult(){ "不開放的有 %d 位\n" "連續兩次統計都不開放的有 %d 位:\n", count - rej_question, rej_question, double_rej); - for(i = 0; i < double_rej; ++i){ + for (i = 0; i < double_rej; ++i) { fprintf(fp, "%13s %d 次", SHM->userid[rej_list[i] - 1], reject[rej_list[i]]); - if(i % 4 == 3) fputc('\n', fp); + if (i % 4 == 3) fputc('\n', fp); } - if(i % 4 != 0) fputc('\n', fp); + if (i % 4 != 0) fputc('\n', fp); fputs("\n--\n\n 本資料由 angel 程式產生\n\n", fp); fclose(fp); -- cgit v1.2.3