--- jud_search.c.orig Sat May 12 10:56:20 2001 +++ jud_search.c Sat May 12 11:39:03 2001 @@ -28,6 +28,14 @@ * * --------------------------------------------------------------------------*/ +/* Chris Pile - 12/05/2001 + * Patched to allow quick searching of all users in a JUD. + * + * Depending on the Jabber client, you can either just press the search button, + * or enter a single asterisk (*) in one of the search fields, then press the + * search button to display a complete list of users in the JUD. + */ + #include "jud.h" void jud_search_walk(xht h, const char *key, void *val, void *arg) @@ -39,20 +47,34 @@ int flag_searched = 0; int flag_mismatch = 0; char *data; + const char *wildcard = "*"; - for(term = xmlnode_get_firstchild(p->iq); term != NULL; term = xmlnode_get_nextsibling(term)) + /* First do a pattern match, but fall back to a complete list of all users if no pattern matching is provided */ + if(xmlnode_get_firstchild(p->iq)) { - if((data = xmlnode_get_data(term)) == NULL) continue; + for(term = xmlnode_get_firstchild(p->iq); term != NULL; term = xmlnode_get_nextsibling(term)) + { + if((data = xmlnode_get_data(term)) == NULL) continue; - flag_searched = 1; + flag_searched = 1; - if(j_strncasecmp(data,xmlnode_get_tag_data(cur,xmlnode_get_name(term)),strlen(data)) != 0) - flag_mismatch = 1; + if(j_strncasecmp(data,xmlnode_get_tag_data(cur,xmlnode_get_name(term)),strlen(data)) != 0 && + strncmp(data,wildcard,strlen(data)) != 0) + flag_mismatch = 1; - } + /* + log_debug(ZONE,"\n\n\nDEBUG - strncasecmp: %d\n\n\n",strncasecmp(data,wildcard,strlen(data))); + */ + } - if(flag_searched && !flag_mismatch) + if(flag_searched && !flag_mismatch) + xmlnode_insert_tag_node(q,cur); + } + else + { + /* No pattern match was given, so display all users */ xmlnode_insert_tag_node(q,cur); + } } void jud_search(ji j, jpacket p)