From 57a5be6e350c332dbb60f48f3d040171e6918277 Mon Sep 17 00:00:00 2001 From: in2 Date: Sat, 11 May 2002 16:42:45 +0000 Subject: generalnamecomplete, userlist complete git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@161 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/proto.h | 5 ++++- mbbsd/bbs.c | 4 +++- mbbsd/name.c | 24 +++++++++++++++++++++++- mbbsd/talk.c | 18 +++++++++++++----- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/include/proto.h b/include/proto.h index 52de7513..66267a52 100644 --- a/include/proto.h +++ b/include/proto.h @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.13 2002/05/10 19:34:50 in2 Exp $ */ +/* $Id: proto.h,v 1.14 2002/05/11 16:42:43 in2 Exp $ */ #ifndef INCLUDE_PROTO_H #define INCLUDE_PROTO_H @@ -302,6 +302,9 @@ void generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, int completeboard_compar(int where, char *str, int len); int completeboard_permission(int where); char *completeboard_getname(int where); +int completeutmp_compar(int where, char *str, int len); +int completeutmp_permission(int where); +char *completeutmp_getname(int where); /* osdep */ int cpuload(char *str); diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 97796674..bc853662 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1,4 +1,4 @@ -/* $Id: bbs.c,v 1.7 2002/05/10 19:34:51 in2 Exp $ */ +/* $Id: bbs.c,v 1.8 2002/05/11 16:42:45 in2 Exp $ */ #include #include #include @@ -115,10 +115,12 @@ int save_violatelaw() { return 0; } +/* void make_blist() { CreateNameList(); apply_boards(g_board_names); } +*/ extern int currbid; extern char currBM[]; diff --git a/mbbsd/name.c b/mbbsd/name.c index aafac786..a16e89e6 100644 --- a/mbbsd/name.c +++ b/mbbsd/name.c @@ -1,4 +1,4 @@ -/* $Id: name.c,v 1.3 2002/05/10 19:34:51 in2 Exp $ */ +/* $Id: name.c,v 1.4 2002/05/11 16:42:45 in2 Exp $ */ #include #include #include @@ -9,8 +9,11 @@ #include "pttstruct.h" #include "common.h" #include "proto.h" +#include "perm.h" extern struct bcache_t *brdshm; +extern struct utmpfile_t *utmpshm; +extern userec_t cuser; extern char *str_space; extern int p_lines; /* a Page of Screen line numbers: tlines-4 */ extern int b_lines; /* Screen bottom line number: t_lines-1 */ @@ -645,6 +648,7 @@ void generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, } } +/* general complete functions (brdshm) */ int completeboard_compar(int where, char *str, int len) { return strncasecmp(brdshm->sorted[0][where]->brdname, str, len); @@ -660,3 +664,21 @@ char *completeboard_getname(int where) return brdshm->sorted[0][where]->brdname; } +/* general complete functions (utmpshm) */ +int completeutmp_compar(int where, char *str, int len) +{ + return strncasecmp(utmpshm->sorted[utmpshm->currsorted][0][where]->userid, + str, len); +} + +int completeutmp_permission(int where) +{ + return (HAS_PERM(PERM_SYSOP) || HAS_PERM(PERM_SEECLOAK) || + !utmpshm->sorted[utmpshm->currsorted][0][where]->invisible); +} + +char *completeutmp_getname(int where) +{ + return utmpshm->sorted[utmpshm->currsorted][0][where]->userid; +} + diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 114668c0..e7245351 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.30 2002/05/11 15:30:31 in2 Exp $ */ +/* $Id: talk.c,v 1.31 2002/05/11 16:42:45 in2 Exp $ */ #include #include #include @@ -1425,6 +1425,7 @@ static void t_showhelp() { pressanykey(); } +/* static int listcuent(userinfo_t * uentp) { if((!uentp->invisible || HAS_PERM(PERM_SYSOP) || HAS_PERM(PERM_SEECLOAK))) @@ -1437,14 +1438,18 @@ static void creat_list() CreateNameList(); apply_ulist(listcuent); } +*/ static int search_pickup(int num, int actor, pickup_t pklist[]) { char genbuf[IDLEN + 2]; move(1, 0); - creat_list(); - namecomplete(msg_uid, genbuf); + generalnamecomplete(msg_uid, genbuf, sizeof(genbuf), + utmpshm->number, + completeutmp_compar, + completeutmp_permission, + completeutmp_getname); if (genbuf[0]){ int n = (num + 1) % actor; while (n != num){ @@ -2306,8 +2311,11 @@ int t_talk() { } */ stand_title("¥´¶}¸Ü§X¤l"); - creat_list(); - namecomplete(msg_uid, uident); + generalnamecomplete(msg_uid, genbuf, sizeof(genbuf), + utmpshm->number, + completeutmp_compar, + completeutmp_permission, + completeutmp_getname); if (uident[0] == '\0') return 0; -- cgit v1.2.3