summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-12-19 14:18:17 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-12-19 14:18:17 +0800
commit3de97b6c59cd333758305445294256b8868ae587 (patch)
tree1c03321b9bc21a6e7b7acada177282bd028ee148 /mbbsd
parent353cdec0dd828be7587e7fbacbe493e23835565f (diff)
downloadpttbbs-3de97b6c59cd333758305445294256b8868ae587.tar
pttbbs-3de97b6c59cd333758305445294256b8868ae587.tar.gz
pttbbs-3de97b6c59cd333758305445294256b8868ae587.tar.bz2
pttbbs-3de97b6c59cd333758305445294256b8868ae587.tar.lz
pttbbs-3de97b6c59cd333758305445294256b8868ae587.tar.xz
pttbbs-3de97b6c59cd333758305445294256b8868ae587.tar.zst
pttbbs-3de97b6c59cd333758305445294256b8868ae587.zip
more quick code in Ptt_prints()
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1421 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/kaede.c105
1 files changed, 55 insertions, 50 deletions
diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c
index 4f091b12..fd3de9ac 100644
--- a/mbbsd/kaede.c
+++ b/mbbsd/kaede.c
@@ -4,56 +4,61 @@
char *
Ptt_prints(char *str, int mode)
{
- char *po, strbuf[256];
-
- while ((po = strstr(str, "\033*s"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf), "%s%s%s", str, cuser.userid, po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*t"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf), "%s%s%s", str, Cdate(&now), po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*u"))) {
- int attempts;
-
- attempts = SHM->UTMPnumber;
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf), "%s%d%s", str, attempts, po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*b"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf),
- "%s%d/%d%s", str, cuser.month, cuser.day, po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*l"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf),
- "%s%d%s", str, cuser.numlogins, po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*p"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf),
- "%s%d%s", str, cuser.numposts, po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*n"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf),
- "%s%s%s", str, cuser.username, po + 3);
- strcpy(str, strbuf);
- }
- while ((po = strstr(str, "\033*m"))) {
- po[0] = 0;
- snprintf(strbuf, sizeof(strbuf),
- "%s%d%s", str, cuser.money, po + 3);
- strcpy(str, strbuf);
- }
+ char strbuf[256];
+ int r, w;
+ for( r = w = 0 ; str[r] != 0 && w < (sizeof(strbuf) - 1) ; ++r )
+ if( str[r] != '\033' )
+ strbuf[w++] = str[r];
+ else{
+ if( str[++r] != '*' ){
+ strbuf[w++] = '\033';
+ strbuf[w++] = str[r];
+ }
+ else{
+ switch( str[++r] ){
+ case 's':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%s", cuser.userid);
+ break;
+ case 't':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%s", Cdate(&now));
+ break;
+ case 'u':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%d", SHM->UTMPnumber);
+ break;
+ case 'b':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%d/%d", cuser.month, cuser.day);
+ break;
+ case 'l':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%d", cuser.numlogins);
+ break;
+ case 'p':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%d", cuser.numposts);
+ break;
+ case 'n':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%s", cuser.username);
+ break;
+ case 'm':
+ w += snprintf(&strbuf[w], sizeof(strbuf) - w,
+ "%d", cuser.money);
+ break;
+ default:
+ strbuf[w++] = '\033';
+ strbuf[w++] = '*';
+ strbuf[w++] = str[r];
+ ++w; /* «á­±¦³ --w */
+ }
+ --w;
+ }
+ }
+ strbuf[w] = 0;
+ strcpy(str, strbuf);
strip_ansi(str, str, mode);
return str;
}