Skip to content

Commit

Permalink
Make it compile with new clucene support
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Oct 28, 2010
1 parent 3ffe075 commit f62eed1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion bot/include/clucene.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void clucene_init(int clear);
void clucene_add( int chanid, char *nick, char *text,
unsigned long timestamp );
#endif
SearchResults_t *clucene_search( int chanid, char *text, int *count, int max );
SearchResults_t *clucene_search( int chanid, char *text, uint32 *count,
uint32 max );

#ifdef __cplusplus
}
Expand Down
11 changes: 8 additions & 3 deletions bot/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ CFLAGS_main += -DLDFLAGS="\"${LDFLAGS}\""
CXXFLAGS = -O6 -g -Wall -Werror -I../include -pedantic -Wno-long-long
CXXFLAGS += -Wno-variadic-macros
CXXFLAGS += $(shell ${MYSQLCFG} --cflags)
CXXFLAGS_clucene = -DCLUCENE_INDEX_DIR=\"${indexdir}\"
CXXFLAGS_clucene = -DCLUCENE_INDEX_DIR=\"${indexdir}\" -I./clucene/src/core
CXXFLAGS_clucene += -I./clucene/src/shared

LDFLAGS = -g -rdynamic

LIBS = $(shell ${MYSQLCFG} @MYSQL_LIBS@)
LIBS += $(shell ${BOTNETCFG} --libs-static)
LIBS += $(shell ${PCRECFG} --libs)
LIBS += $(shell ${CURLCFG} --libs)
LIBS += -ldl -L../lib -lopie -lmenu -lform -lncurses -lclucene
LIBS += -ldl -L../lib -lopie -lmenu -lform -lncurses -lstdc++ -lz
LIBS += -lclucene-core-static -lclucene-shared-static
LIBS += -lclucene-contribs-lib-static

SRCS = main.c plugin_api.c bot.c bot_cmds.c mysql.c linked_list.c regexp.c
SRCS += balanced_btree.c protected_data.c mysql_upgrade.c queue.c notice.c
Expand All @@ -48,7 +51,9 @@ IMPORTEROBJS = ${IMPORTERSRCS:.c=.o} ${IMPORTERSRCCS:.cc=.o}
DEPS += import.d
IMPORTER = importdb${EXEEXT}
IMPORTERLIBS = $(shell ${MYSQLCFG} @MYSQL_LIBS@)
IMPORTERLIBS += -lclucene
IMPORTERLIBS += -lstdc++ -lz -L../lib
IMPORTERLIBS += -lclucene-core-static -lclucene-shared-static
IMPORTERLIBS += -lclucene-contribs-lib-static

DESTDIR =
prefix = @prefix@
Expand Down
17 changes: 11 additions & 6 deletions bot/src/clucene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "clucene.h"
#include <CLucene.h>
#include <CLucene/config/repl_tchar.h>
#include <CLucene/util/Misc.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
Expand Down Expand Up @@ -124,8 +125,8 @@ extern "C" {
}
#endif

SearchResults_t *clucene_search( int chanid, char *text, int *count,
int max )
SearchResults_t *clucene_search( int chanid, char *text, uint32 *count,
uint32 max )
{
IndexReader *reader;
WhitespaceAnalyzer an;
Expand All @@ -136,7 +137,7 @@ extern "C" {
static TCHAR query[MAX_STRING_LEN];
char *esctext;
SearchResults_t *results;
int i;
uint32 i;
char *ts;

reader = IndexReader::open(CLUCENE_INDEX_DIR);
Expand Down Expand Up @@ -250,10 +251,11 @@ int loadLogentry( Document *doc, unsigned long tb )
Query *q;
Hits *h;
Document *d;
DocumentFieldEnumeration *fields;
Document::FieldsType *fields;
Field *field;
static TCHAR query[80];
int len;
Document::FieldsType::iterator itr;

reader = IndexReader::open(CLUCENE_INDEX_DIR);
s = _CLNEW IndexSearcher(reader);
Expand All @@ -274,12 +276,15 @@ int loadLogentry( Document *doc, unsigned long tb )
return( 0 );
}
d = &h->doc(0);
fields = d->fields();
fields = (Document::FieldsType *)d->getFields();
doc->clear();
/* Recreate the current document */
while( (field = fields->nextElement()) ) {
itr = fields->begin();
while( itr != fields->end() ) {
field = *itr;
doc->add( *_CLNEW Field( field->name(), field->stringValue(),
Field::STORE_YES | Field::INDEX_TOKENIZED ) );
itr++;
}
LogPrint( LOG_INFO, "Deleting document %lld", (uint64)(h->id(0)) );
reader->deleteDocument( h->id(0) );
Expand Down
2 changes: 1 addition & 1 deletion bot/src/plugins/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void lucene_search_text( IRCServer_t *server, IRCChannel_t *channel, char *who,
char *text )
{
SearchResults_t *results;
int count;
uint32 count;
int i;
int len;
char *value = NULL;
Expand Down

0 comments on commit f62eed1

Please sign in to comment.