summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-06-04 15:08:34 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-06-04 15:08:34 +0800
commitf0d604f8f201acd2360bceb8db3cfef99164a4a5 (patch)
tree24ad22960929252b1c6e8a0843b46e1b6e008332 /util
parent5293cd268cdcb31fd1bcd3ca819bb2ccc65fb2b1 (diff)
downloadpttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.tar
pttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.tar.gz
pttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.tar.bz2
pttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.tar.lz
pttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.tar.xz
pttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.tar.zst
pttbbs-f0d604f8f201acd2360bceb8db3cfef99164a4a5.zip
Log angel changing action and report every week
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3532 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/angel.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/util/angel.c b/util/angel.c
index e434a46b..c12cb555 100644
--- a/util/angel.c
+++ b/util/angel.c
@@ -26,6 +26,7 @@ int RejCmp(const void * a, const void * b){
void readData();
void sendResult();
+void slurp(FILE* to, FILE* from);
int main(int argc, char* argv[]){
if (argc > 1)
@@ -109,7 +110,7 @@ int mailalertuser(char* userid)
if (userid[0] && (uentp = search_ulist_userid(userid)))
uentp->alerts|=ALERT_NEW_MAIL;
return 0;
-}
+}
void sendResult(){
int i;
@@ -164,6 +165,17 @@ void sendResult(){
}
if (i % 4 != 0) fputc('\n', fp);
+ {
+ FILE* changefp = fopen(BBSHOME "/log/changeangel.log", "r");
+ if (changefp) {
+ remove(BBSHOME "/log/changeangel.log");
+
+ fputs("\n== 本周更換小天使紀錄 ==\n", fp);
+ slurp(fp, changefp);
+ fclose(changefp);
+ }
+ }
+
fputs("\n--\n\n 本資料由 angel 程式產生\n\n", fp);
fclose(fp);
@@ -174,4 +186,22 @@ void sendResult(){
mailalertuser(mailto);
}
+void slurp(FILE* to, FILE* from)
+{
+ char buf[4096]; // 4K block
+ int count;
+
+ while ((count = fread(buf, 1, sizeof(buf), from)) > 0) {
+ char * p = buf;
+ while (count > 0) {
+ int i = fwrite(p, 1, count, to);
+
+ if (i <= 0) return;
+
+ p += i;
+ count -= i;
+ }
+ }
+}
+
#endif /* defined PLAY_ANGEL */