]> code.citadel.org Git - citadel.git/commitdiff
* Completed the "search for all of these words" functionality. All we need
authorArt Cancro <ajc@citadel.org>
Wed, 18 May 2005 04:02:54 +0000 (04:02 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 18 May 2005 04:02:54 +0000 (04:02 +0000)
  to do now is genericize its calling syntax so it can be called from the
  IMAP service.

citadel/ChangeLog
citadel/serv_fulltext.c
citadel/serv_fulltext.o

index e33dff34956d1d1b77363ad25d6c2c875cc71ce4..c4420cdf06f9081d5b6b9b55729681c80b624f10 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 647.9  2005/05/18 04:02:54  ajc
+ * Completed the "search for all of these words" functionality.  All we need
+   to do now is genericize its calling syntax so it can be called from the
+   IMAP service.
+
  Revision 647.8  2005/05/18 03:22:27  ajc
  * Finished the indexer and the first part of the search function...
 
@@ -6712,3 +6717,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 0b29872d596c81b393d806798bb7dfe7fca4efda..4edff35dc10663afae41bee893e8d5055a638e5a 100644 (file)
@@ -257,6 +257,8 @@ void cmd_srch(char *argbuf) {
        struct cdbdata *cdb_bucket;
        int num_msgs;
        long *msgs;
+       int num_all_msgs = 0;
+       long *all_msgs = NULL;
 
        if (CtdlAccessCheck(ac_logged_in)) return;
        extract_token(search_string, argbuf, 0, '|', sizeof search_string);
@@ -271,14 +273,29 @@ void cmd_srch(char *argbuf) {
                        if (cdb_bucket != NULL) {
                                num_msgs = cdb_bucket->len / sizeof(long);
                                msgs = (long *)cdb_bucket->ptr;
-                               for (j=0; j<num_msgs; ++j) {
-                                       cprintf("Token <%d> is in msg <%ld>\n", tokens[i], msgs[j]);
-                               }
+
+                               num_all_msgs += num_msgs;
+                               all_msgs = realloc(all_msgs, num_all_msgs*sizeof(long) );
+                               memcpy(&all_msgs[num_all_msgs - num_msgs], msgs, num_msgs*sizeof(long) );
+
                                cdb_free(cdb_bucket);
                        }
 
                }
                free(tokens);
+               qsort(all_msgs, num_all_msgs, sizeof(long), longcmp);
+
+               /*
+                * At this point, if a message appears num_tokens times in the
+                * list, then it contains all of the search tokens.
+                */
+               if (num_all_msgs >= num_tokens) for (j=0; j<(num_all_msgs-num_tokens+1); ++j) {
+                       if (all_msgs[j] == all_msgs[j+num_tokens-1]) {
+                               cprintf("%ld\n", all_msgs[j]);
+                       }
+               }
+
+               free(all_msgs);
        }
        cprintf("000\n");
 }
index d5444317a3346b6380a5a4eab90a99def2d93333..14c526891b28c40ebdd150861514c70beca83b9d 100644 (file)
Binary files a/citadel/serv_fulltext.o and b/citadel/serv_fulltext.o differ