作者itoc.bbs@cpu.tfcis.org (核心動力) 看板: itoc
標題Re: 如何警告使用者本頁有控制碼?
時間動力核心 (2007/08/31 Fri 01:07:29)
※ 引述《honor (dino)》之銘言:
> 如題,像在ptt用控制碼都會在該文章上註明本頁有控制碼,
: maple.p
- void outx(uschar *str);
+ int outx(uschar *str);
: visio.c:outx()
- void
+ int
outx(str)
uschar *str;
{
int ch;
+ int control = 0;
...
...
case 's': /* **s 顯示 ID */
outs(cuser.userid);
str += 3;
+ control = 1;
continue;
case 'n': /* **n 顯示暱稱 */
outs(cuser.username);
str += 3;
+ control = 1;
continue;
...
...
}
+ return control;
}
: theme.h
#define FOOTER_MORE \
COLOR1 " 瀏覽 P.%d (%d%%) " COLOR2 " ... (C)暫存 (←q)結束 "
+ #define FOOTER_MORE2 \
+ COLOR1 " 瀏覽 P.%d (%d%%) " COLOR2 "此頁包括控制碼,會顯示個人資訊 ... "
// 上面的 ... 是空格,到和 FOOTER_MORE 一樣長
: more.c:outs_footer()
static inline void
- outs_footer(buf, lino, fsize)
+ outs_footer(buf, lino, fsize, control)
char *buf;
int lino;
int fsize;
+ int control;
{
...
...
+ if (control)
+ sprintf(buf, FOOTER_MORE2,
+ (lino - 2) / PAGE_SCROLL + 1, ((foff - fimage) * 100) / fsize);
+ else
sprintf(buf, FOOTER_MORE,
(lino - 2) / PAGE_SCROLL + 1, ((foff - fimage) * 100) / fsize);
outs(buf);
: more.c:outs_line()
- static void
+ static int
outs_line(str)
char *str;
{
int ch1, ch2, ansi;
+ int control;
...
...
if (!hunt[0])
{
- outx(str);
+ control = outx(str);
}
...
...
- outx(buf);
+ control = outx(buf);
}
if (ansi)
outs(str_ransi);
+ return control;
}
: more.c:outs_header()
- static void
+ static int
outs_header(str, header_len)
char *str;
int header_len;
{
...
...
/* 少看板這欄 */
prints(COLOR5 " %s " COLOR6 "%-*.*s\033[m",
header1[0], d_cols + 72, d_cols + 72, word);
}
- return;
+ return 0;
...
...
/* 其他檔頭都只有一欄 */
word = str + header_len;
prints(COLOR5 " %s " COLOR6 "%-*.*s\033[m",
header1[i], d_cols + 72, d_cols + 72, word);
- return;
+ return 0;
...
...
- outs_line(str);
+ return outs_line(str);
}
: more.c:more()
int fsize; /* 檔案大小 */
+ int control; /* 本頁是否含有控制碼 */
...
...
lino = cmd = 0;
block[0] = 0;
+ control = 0;
...
...
if (foff <= headend)
- outs_header(buf, header_len);
+ control += outs_header(buf, header_len);
else
- outs_line(buf);
+ control += outs_line(buf);
...
...
- outs_footer(buf, lino, fsize);
+ outs_footer(buf, lino, fsize, control);
+ control = 0;
--
=[﹎:�摃�◣��:﹎Origin ]|[ ���O���� cpu.tfcis.org ]|[�搟說�﹎:]=
=[﹊:�摃�╱��:﹊Author ]|[218-168-188-90.dynamic.hin]|[���插�﹊:]=
= ▊▌▎▎Modify ▎▌▋▊▊≡: Fri, 31 Aug 2007 01:08:48 CST :≡:]=