*/
#include "../../ctdl_module.h"
-
-
#include "../../sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include "imap_fetch.h"
#include "imap_search.h"
#include "../../genstamp.h"
+#include "../fulltext/serv_fulltext.h"
/*
void imap_do_search(int num_items, ConstStr *itemlist, int is_uid) {
citimap *Imap = IMAP;
int i, j, k;
- int fts_num_msgs = 0;
- long *fts_msgs = NULL;
int is_in_list = 0;
int num_results = 0;
+ Array *fts = NULL;
/* Strip parentheses. We realize that this method will not work
* in all cases, but it seems to work with all currently available
*/
if (CtdlGetConfigInt("c_enable_fulltext")) for (i=0; i<(num_items-1); ++i) {
if (!strcasecmp(itemlist[i].Key, "BODY")) {
- CtdlModuleDoSearch(&fts_num_msgs, &fts_msgs, itemlist[i+1].Key, "fulltext");
- if (fts_num_msgs > 0) {
+ fts = CtdlFullTextSearch(itemlist[i+1].Key);
+ if ((fts) && (array_len(fts) > 0)) {
for (j=0; j < Imap->num_msgs; ++j) {
if (Imap->flags[j] & IMAP_SELECTED) {
is_in_list = 0;
- for (k=0; k<fts_num_msgs; ++k) {
- if (Imap->msgids[j] == fts_msgs[k]) {
+ for (k=0; k<array_len(fts); ++k) {
+ long smsgnum;
+ memcpy(&smsgnum, array_get_element_at(fts, k), sizeof(long));
+ if (Imap->msgids[j] == smsgnum) {
++is_in_list;
}
}
Imap->flags[j] = Imap->flags[j] & ~IMAP_SELECTED;
}
}
- if (fts_msgs) {
- free(fts_msgs);
+ if (fts) {
+ array_free(fts);
}
}
}