$Log$
+ Revision 647.10 2005/05/18 22:09:01 ajc
+ * Finished the indexer *and* deindexer! The search API is now working
+ flawlessly too. Now all we have to do is glue it to IMAP and other
+ user-facing functionality. (The SRCH command is for testing only.)
+
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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
*/
if (smi.meta_refcount == 0) {
lprintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
- /* ft_index_message(msgnum, 0); remove from fulltext index */
+
+ /* Remove from fulltext index */
+ ft_index_message(msgnum, 0);
+
+ /* Remove from message base */
delnum = msgnum;
cdb_delete(CDB_MSGMAIN, &delnum, (int)sizeof(long));
cdb_delete(CDB_BIGMSGS, &delnum, (int)sizeof(long));
- /* We have to delete the metadata record too! */
+ /* Remove metadata record */
delnum = (0L - msgnum);
cdb_delete(CDB_MSGMAIN, &delnum, (int)sizeof(long));
}
}
if (op == 0) { /* remove from index */
- /* FIXME do this */
+ if (num_msgs >= 1) {
+ msgs = (long *) cdb_bucket->ptr;
+ for (j=0; j<num_msgs; ++j) {
+ if (msgs[j] == msgnum) {
+ lprintf(CTDL_DEBUG, "nix0ring %ld\n", msgs[j]);
+ memmove(&msgs[j], &msgs[j+1],
+ ((num_msgs - j - 1)*sizeof(long)));
+ --num_msgs;
+ }
+ }
+ }
}
/* sort and purge dups */
- if (num_msgs > 1) {
+ if ( (op == 1) && (num_msgs > 1) ) {
+ msgs = (long *) cdb_bucket->ptr;
qsort(msgs, num_msgs, sizeof(long), longcmp);
for (j=0; j<(num_msgs-1); ++j) {
if (msgs[j] == msgs[j+1]) {
memmove(&msgs[j], &msgs[j+1],
- ((num_msgs - j)*sizeof(long)));
+ ((num_msgs - j - 1)*sizeof(long)));
--num_msgs;
}
}
for (i=0; i<(ft_num_msgs-1); ++i) { /* purge dups */
if (ft_newmsgs[i] == ft_newmsgs[i+1]) {
memmove(&ft_newmsgs[i], &ft_newmsgs[i+1],
- ((ft_num_msgs - i)*sizeof(long)));
+ ((ft_num_msgs - i - 1)*sizeof(long)));
--ft_num_msgs;
}
}
msgs = (long *)cdb_bucket->ptr;
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) );
+ if (num_all_msgs > 0) {
+ 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);
}