diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-07-06 01:10:28 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-07-06 01:10:28 +0800 |
commit | 1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch) | |
tree | e6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/lovepaper.c | |
parent | 10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff) | |
download | pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2 pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip |
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/lovepaper.c')
-rw-r--r-- | mbbsd/lovepaper.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c index d4757ecf..c2f4459c 100644 --- a/mbbsd/lovepaper.c +++ b/mbbsd/lovepaper.c @@ -1,53 +1,54 @@ -/* $Id: lovepaper.c,v 1.6 2002/06/19 13:32:23 lwms Exp $ */ +/* $Id: lovepaper.c,v 1.7 2002/07/05 17:10:27 in2 Exp $ */ #include "bbs.h" #define DATA "etc/lovepaper.dat" -int x_love() { - char buf1[200], save_title[TTLEN + 1]; - char receiver[61], path[STRLEN] = "home/"; - int x, y = 0, tline = 0, poem = 0; - FILE *fp, *fpo; - struct tm *gtime; - fileheader_t mhdr; - +int +x_love() +{ + char buf1[200], save_title[TTLEN + 1]; + char receiver[61], path[STRLEN] = "home/"; + int x, y = 0, tline = 0, poem = 0; + FILE *fp, *fpo; + struct tm *gtime; + fileheader_t mhdr; + setutmpmode(LOVE); gtime = localtime(&now); - sprintf(buf1,"%c/%s/love%d%d", - cuser.userid[0], cuser.userid,gtime->tm_sec,gtime->tm_min); - strcat(path,buf1); - move(1,0); + sprintf(buf1, "%c/%s/love%d%d", + cuser.userid[0], cuser.userid, gtime->tm_sec, gtime->tm_min); + strcat(path, buf1); + move(1, 0); clrtobot(); - + outs("\n歡迎使用情書產生器 v0.00 板 \n"); outs("有何難以啟齒的話,交由系統幫你說吧.\n爸爸說 : 濫情不犯法.\n"); - - if(!getdata(7, 0, "收信人:", receiver, sizeof(receiver), DOECHO)) + + if (!getdata(7, 0, "收信人:", receiver, sizeof(receiver), DOECHO)) return 0; - if(receiver[0] && !(searchuser(receiver) && - getdata(8, 0, "主 題:", save_title, - sizeof(save_title), DOECHO))) { + if (receiver[0] && !(searchuser(receiver) && + getdata(8, 0, "主 題:", save_title, + sizeof(save_title), DOECHO))) { move(10, 0); outs("收信人或主題不正確, 情書無法傳遞. "); pressanykey(); return 0; } - fpo = fopen(path, "w"); fprintf(fpo, "\n"); - if((fp = fopen(DATA, "r"))) { - while(fgets(buf1,100, fp)) { - switch(buf1[0]) { + if ((fp = fopen(DATA, "r"))) { + while (fgets(buf1, 100, fp)) { + switch (buf1[0]) { case '#': break; case '@': - if(!strncmp(buf1, "@begin", 6) || !strncmp(buf1, "@end", 4)) - tline=3; - else if(!strncmp(buf1,"@poem",5)) { + if (!strncmp(buf1, "@begin", 6) || !strncmp(buf1, "@end", 4)) + tline = 3; + else if (!strncmp(buf1, "@poem", 5)) { poem = 1; tline = 1; fprintf(fpo, "\n\n"); } else - tline=2; + tline = 2; break; case '1': case '2': @@ -58,32 +59,32 @@ int x_love() { case '7': case '8': case '9': - sscanf(buf1,"%d",&x); - y = (rand() % (x - 1)) * tline; + sscanf(buf1, "%d", &x); + y = (rand() % (x - 1)) * tline; break; default: - if(!poem) { - if(y > 0) + if (!poem) { + if (y > 0) y = y - 1; else { - if(tline > 0) { + if (tline > 0) { fprintf(fpo, "%s", buf1); tline--; } } } else { - if(buf1[0] == '$') + if (buf1[0] == '$') y--; - else if(y == 0) - fprintf(fpo,"%s",buf1); + else if (y == 0) + fprintf(fpo, "%s", buf1); } - } + } } - + fclose(fp); fclose(fpo); - if(vedit(path, YEA, NULL) == -1) { + if (vedit(path, YEA, NULL) == -1) { unlink(path); clear(); outs("\n\n 放棄寄情書\n"); @@ -95,8 +96,8 @@ int x_love() { Rename(path, buf1); strncpy(mhdr.title, save_title, TTLEN); strcpy(mhdr.owner, cuser.userid); - sethomedir(path, receiver ); - if(append_record(path, &mhdr, sizeof(mhdr)) == -1) + sethomedir(path, receiver); + if (append_record(path, &mhdr, sizeof(mhdr)) == -1) return -1; hold_mail(buf1, receiver); return 1; |