* Server-side LIST command now accepts a search string.
authorArt Cancro <ajc@citadel.org>
Thu, 21 Jul 2005 15:02:28 +0000 (15:02 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 21 Jul 2005 15:02:28 +0000 (15:02 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/techdoc/protocol.txt
citadel/user_ops.c
citadel/user_ops.h

index c42858bebf871dd7fa0b4cf2613387943408c84f..9ec6b3fede5b4960f096cfe711c043cfeb840d1a 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 653.6  2005/07/21 15:02:27  ajc
+* Server-side LIST command now accepts a search string.
+
 Revision 653.5  2005/07/19 20:04:31  ajc
 * MSG4 command now outputs content type *and* charset
 
@@ -6938,3 +6941,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 85f593641318e9bfdc56e7f1c72cf0ea5401ce6d..b076e274b19918089430a8ff2e0e7b158f838c7e 100644 (file)
@@ -1059,7 +1059,7 @@ void do_command_loop(void) {
        }
 
        else if (!strncasecmp(cmdbuf,"LIST",4)) {
-               cmd_list();
+               cmd_list(&cmdbuf[5]);
        }
 
        else if (!strncasecmp(cmdbuf,"CHEK",4)) {
index 2145c815ed6c646930e06a979c03058512d97297..a15d74478bff86d5fcce0c313a34853eff798cb7 100644 (file)
@@ -1068,6 +1068,12 @@ fields on each line are as follows:
 
  Unlisted entries will also be listed to Aides logged into the server, but
 not to ordinary users.
+ The LIST command accepts an optional single argument, which is a simple,
+case-insensitive search string.  If this argument is present, only usernames
+in which the search string is present will be returned.  It is a simple
+substring search, not a regular expression search.  If this string is empty
+or not present, all users will be returned.
 
 
  REGI   (send REGIstration)
index a826165464ed801db2009d621777296c8db67e91..9f9588238fa82c0003e09b55e427cde86196ab20 100644 (file)
@@ -1355,6 +1355,13 @@ void ForEachUser(void (*CallBack) (struct ctdluser * EachUser, void *out_data),
  */
 void ListThisUser(struct ctdluser *usbuf, void *data)
 {
+       char *searchstring;
+
+       searchstring = (char *)data;
+       if (bmstrstr(usbuf->fullname, searchstring, strncasecmp) == NULL) {
+               return;
+       }
+
        if (usbuf->axlevel > 0) {
                if ((CC->user.axlevel >= 6)
                    || ((usbuf->flags & US_UNLISTED) == 0)
@@ -1374,12 +1381,15 @@ void ListThisUser(struct ctdluser *usbuf, void *data)
 }
 
 /* 
- *  List users
+ *  List users (searchstring may be empty to list all users)
  */
-void cmd_list(void)
+void cmd_list(char *cmdbuf)
 {
+       char searchstring[256];
+       extract_token(searchstring, cmdbuf, 0, '|', sizeof searchstring);
+       striplt(searchstring);
        cprintf("%d \n", LISTING_FOLLOWS);
-       ForEachUser(ListThisUser, NULL);
+       ForEachUser(ListThisUser, (void *)searchstring );
        cprintf("000\n");
 }
 
index 9d4e8aa015fdbe86f0a3f7817902ab045c6d16f8..734118b790b0999bbbb160f4cc46a79b8ad99b19 100644 (file)
@@ -28,7 +28,7 @@ void cmd_vali (char *v_args);
 void ForEachUser(void (*CallBack)(struct ctdluser *EachUser, void *out_data),
        void *in_data);
 void ListThisUser(struct ctdluser *usbuf, void *data);
-void cmd_list (void);
+void cmd_list (char *);
 void cmd_chek (void);
 void cmd_qusr (char *who);
 void cmd_agup (char *cmdbuf);