From eefc275d2541b5146dbeb8c1afdc241c4118799f Mon Sep 17 00:00:00 2001 From: scw Date: Sat, 5 Feb 2005 15:40:30 +0000 Subject: * In generalnamecomplete(), complete as more as possible when space (' ') is pressed. (As what does in most shell) * In all three completing functions (namecomplete, usercomplete and generalnamecomplete), return null string instead of partial matched name which makes users able to talk/annoy those they are not supposed to talk to (admins or cloaks). * Type of parameters of generalnamecomplete has typedefed and should be clearer. * New macro CompleteBoard and CompleteOnlineUser are defined since most of the usage of generalnamecomplete are the same. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2468 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/proto.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/proto.h b/include/proto.h index ab551ae6..4678b40a 100644 --- a/include/proto.h +++ b/include/proto.h @@ -367,6 +367,10 @@ void m_sob_brd(char *bname,char *fromdir); int more(char *fpath, int promptend); /* name */ +typedef int (*gnc_comp_func)(int, char*, int); +typedef int (*gnc_perm_func)(int); +typedef char* (*gnc_getname_func)(int); + void usercomplete(char *prompt, char *data); void namecomplete(char *prompt, char *data); void AddNameList(char *name); @@ -378,8 +382,8 @@ void ShowNameList(int row, int column, char *prompt); int RemoveNameList(char *name); void ToggleNameList(int *reciper, char *listfile, char *msg); int generalnamecomplete(char *prompt, char *data, int len, size_t nmemb, - int (*compar)(int, char *, int), - int (*permission)(int), char* (*getname)(int)); + gnc_comp_func compar, gnc_perm_func permission, + gnc_getname_func getname); int completeboard_compar(int where, char *str, int len); int completeboard_permission(int where); char *completeboard_getname(int where); @@ -387,6 +391,14 @@ int completeutmp_compar(int where, char *str, int len); int completeutmp_permission(int where); char *completeutmp_getname(int where); +#define CompleteBoard(MSG,BUF) \ + generalnamecomplete(MSG, BUF, sizeof(BUF), SHM->Bnumber, \ + &completeboard_compar, &completeboard_permission, \ + &completeboard_getname) +#define CompleteOnlineUser(MSG,BUF) \ + generalnamecomplete(MSG, BUF, sizeof(BUF), SHM->UTMPnumber, \ + &completeutmp_compar, &completeutmp_permission, \ + &completeutmp_getname) /* osdep */ int cpuload(char *str); -- cgit v1.2.3