本文描述的修改在 FireBird 2.5 和 2.6 上均可使用.
本站使用 /g 指令进行聊天室的上线好友查询操作.
修改代码我不太清楚是在什么时候由水木清华站的哪位站长开发并运行的.
可能是 Alex 或者 snow,或者其他哪一位吧.修改的时间很早了.
下列代码用于在聊天室中,察看当前上线的好友:
============================================================================
1.在 bbs_src/chat.c 的 chat_users 函数定义后,添加下列两个函数:
int
print_friend_ent(uentp) /* print one user & status if he is a friend*/
struct user_info *uentp;
{
static char uline[256];
static int cnt;
char pline[50];
if (!uentp)
{
if (cnt)
printchatline(uline);
bzero(uline, 256);
cnt = 0;
return 0;
}
if (!uentp->active || !uentp->pid)
return 0;
if (!HAS_PERM(PERM_SEECLOAK) && uentp->invisible)
return 0;
#if 0
if (kill(uentp->pid, 0) == -1)
return 0;
#endif
/*if (!myfriend(uentp->userid)) Leeward 99.02.01 */
if (!myfriend(uentp->uid))
return 0;
sprintf(pline, " %-13s%c%-10s",
uentp->userid, uentp->invisible ? '#' : ' ',
modestring(uentp->mode, uentp->destuid, 0, NULL));
if (cnt < 2)
strcat(pline, "│");
strcat(uline, pline);
if (++cnt == 3)
{
printchatline(uline);
memset(uline, 0, 256);
cnt = 0;
}
return 0;
}
void
chat_friends()
{
printchatline("");
sprintf(genbuf,"^[[1m【 当前线上的好友列表 】^[[m");
printchatline(genbuf);
printchatline(msg_shortulist);
if (apply_ulist(print_friend_ent) == -1)
{
printchatline("^[[1m没有朋友在线上^[[m");
}
print_friend_ent(NULL);
}
2.在 bbs_src/chat.c 的尾部,
struct chat_command chat_cmdtbl[] 的定义中,
加入 /g 指令的定义:
struct chat_command chat_cmdtbl[] = {
{"pager",setpager},
{"help", chat_help},
{"clear", chat_clear},
{"date", chat_date},
{"g", chat_friends},
{"users", chat_users},
... 中间的部分定义此处略去 ...
{NULL, NULL}
};
特别说明两点:
1. ^[[1m 的输入方式是(在 vi 中):Esc i Ctrl-V Ctrl-[ [ 1 m 一共七次击键
2. 标有 "Leeward 99.02.01" 的地方, 可能不同的版本需要不同的代码.
具体说, 请察看 bbs_src/list.c 中对 myfriend 函数的参数接口定义.
在 2.6 版中, 这里的参数应该是个 unsigned short
而 2.5 版中, 这里的参数可能是个 char *
需要根据具体的代码中对调用参数的类型定义, 来修改 myfriend 函数的调用参数:
如果参数类型定义为 unsigned short, 实际的调用参数用 uentp->uid 就可以;
如果参数类型定义为 char *, 实际的调用参数用 uentp->userid 就可以.
--
修改:Leeward FROM bbs.huizhou.gd.
FROM 202.101.112.202