From 91d90470f1c9eb465a5ea7799263af90212fcfce Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 17 Jul 2003 03:27:29 +0000 Subject: random signature git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1056 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/proto.h | 4 ++-- include/pttstruct.h | 6 +++--- mbbsd/edit.c | 19 +++++++++++-------- mbbsd/user.c | 16 ++++++++-------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/include/proto.h b/include/proto.h index a460650d..f02f7c1d 100644 --- a/include/proto.h +++ b/include/proto.h @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.44 2003/05/26 05:23:13 in2 Exp $ */ +/* $Id: proto.h,v 1.45 2003/07/17 03:27:27 victor Exp $ */ #ifndef INCLUDE_PROTO_H #define INCLUDE_PROTO_H @@ -524,7 +524,7 @@ int topsong(); int u_editcalendar(); void user_display(userec_t *u, int real); void uinfo_query(userec_t *u, int real, int unum); -int showsignature(char *fname); +int showsignature(char *fname, int *j); void mail_violatelaw(char* crime, char* police, char* reason, char* result); void showplans(char *uid); int u_info(); diff --git a/include/pttstruct.h b/include/pttstruct.h index 64f2bd90..d34e8f3a 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -1,4 +1,4 @@ -/* $Id: pttstruct.h,v 1.41 2003/07/17 01:33:14 in2 Exp $ */ +/* $Id: pttstruct.h,v 1.42 2003/07/17 03:27:27 victor Exp $ */ #ifndef INCLUDE_STRUCT_H #define INCLUDE_STRUCT_H @@ -75,10 +75,10 @@ typedef struct userec_t { char mind[4]; char ident[11]; unsigned int uflag2; - char pad[72]; + unsigned char signature; + char pad[71]; } userec_t; /* these are flags in userec_t.uflag */ -#define SIG_FLAG 0x3 /* signature number, 2 bits */ #define PAGER_FLAG 0x4 /* true if pager was OFF last session */ #define CLOAK_FLAG 0x8 /* true if cloak was ON last session */ #define FRIEND_FLAG 0x10 /* true if show friends only */ diff --git a/mbbsd/edit.c b/mbbsd/edit.c index c3e2fdc5..81fc73da 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -1,4 +1,4 @@ -/* $Id: edit.c,v 1.36 2003/06/28 08:47:45 kcwu Exp $ */ +/* $Id: edit.c,v 1.37 2003/07/17 03:27:29 victor Exp $ */ /* edit.c, 用來提供 bbs上的文字編輯器, 即 ve. * 現在這一個是惡搞過的版本, 比較不穩定, 用比較多的 cpu, 但是可以省下許多 * 的記憶體 (以 Ptt為例, 在九千人上站的時候, 約可省下 50MB 的記憶體) @@ -895,11 +895,11 @@ void addsignature(FILE * fp, int ifuseanony) { FILE *fs; - int i; + int i, num; char buf[WRAPMARGIN + 1]; char fpath[STRLEN]; - static char msg[] = "請選擇簽名檔 (1-9, 0=不加)[0]: "; + static char msg[] = "請選擇簽名檔 (1-9, 0=不加 X=隨機)[X]: "; char ch; if (!strcmp(cuser.userid, STR_GUEST)) { @@ -908,13 +908,16 @@ addsignature(FILE * fp, int ifuseanony) return; } if (!ifuseanony) { - i = showsignature(fpath); - msg[27] = ch = '0' | (cuser.uflag & SIG_FLAG); + num = showsignature(fpath, &i); + msg[34] = ch = isdigit(cuser.signature) ? cuser.signature : 'X'; getdata(0, 0, msg, buf, 4, DOECHO); - if (ch != buf[0] && buf[0] >= '0' && buf[0] <= '9') { - ch = buf[0]; - cuser.uflag = (cuser.uflag & ~SIG_FLAG) | (ch & SIG_FLAG); + if (buf[0] == 0 || buf[0] == 'x' || isdigit(buf[0])) { + if (isdigit(buf[0])) + ch = buf[0]; + else + ch = '1' + rand() % num; + cuser.signature = buf[0]; } if (ch != '0') { fpath[i] = ch; diff --git a/mbbsd/user.c b/mbbsd/user.c index c706b741..4e12167d 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -1,4 +1,4 @@ -/* $Id: user.c,v 1.69 2003/07/17 00:57:21 in2 Exp $ */ +/* $Id: user.c,v 1.70 2003/07/17 03:27:29 victor Exp $ */ #include "bbs.h" static char *sex[8] = { @@ -712,29 +712,29 @@ showplans(char *uid) } int -showsignature(char *fname) +showsignature(char *fname, int *j) { FILE *fp; char buf[256]; - int i, j; + int i, num = 0; char ch; clear(); move(2, 0); setuserfile(fname, "sig.0"); - j = strlen(fname) - 1; + *j = strlen(fname) - 1; for (ch = '1'; ch <= '9'; ch++) { - fname[j] = ch; + fname[*j] = ch; if ((fp = fopen(fname, "r"))) { prints("\033[36m【 簽名檔.%c 】\033[m\n", ch); for (i = 0; i < MAX_SIGLINES && fgets(buf, sizeof(buf), fp); i++) outs(buf); - + num++; fclose(fp); } } - return j; + return num; } int @@ -745,7 +745,7 @@ u_editsig() int j; char genbuf[200]; - j = showsignature(genbuf); + showsignature(genbuf, &j); getdata(0, 0, "簽名檔 (E)編輯 (D)刪除 (Q)取消?[Q] ", ans, sizeof(ans), LCECHO); -- cgit v1.2.3