00001
00002
00003
00004
00005
00006
00033 #ifndef SEARCHM_H
00034 #define SEARCHM_H
00035
00036 #if defined (SEARCHM_DBM)
00037 #elif defined(SEARCHM_BDB)
00038 #else
00039 #error One of SEARCHM_DBM must be defined.
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef SEARCHM_PURGE_TIME
00054 # define SEARCHM_PURGE_TIME (120)
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifndef SEARCHM_INVALIDATE_TIME
00065 # define SEARCHM_INVALIDATE_TIME (10)
00066 #endif
00067
00068
00069
00070
00071
00072
00073 #define SEARCHM_KEY_PURGETIME "SEARCHMTIME"
00074
00075
00076 #define SEARCHM_CACHE_SIZE (1 * 1024)
00077
00078
00079 #define SEARCHM_TAG_BEGIN '<'
00080
00081
00082
00083 #define SEARCHM_TAG_ID "<SEARCHM:"
00084
00085
00086 #define SEARCHM_TAG_END '>'
00087
00093 #define SEARCHM_DEFAULT_COOKIE_NAME "SEARCHM"
00094
00100 #define SEARCHM_DESC_HTML_HILITE_BEGIN "<b><i>"
00101
00102
00103
00104
00110 #define SEARCHM_DESC_HTML_HILITE_END "</i></b>"
00111
00112
00113
00114
00120 #define SEARCHM_AND_WORD "and"
00121
00127 #define SEARCHM_OR_WORD "or"
00128
00134 #define SEARCHM_NOT_WORD "not"
00135
00141 #define SEARCHM_DEFAULT_RULE SEARCHM_AND_RULE
00142
00147 #define SEARCHM_DEFAULT_METANAME "swishdefault"
00148
00149
00150 #define SEARCHM_ENC_GB "%28"
00151
00152
00153 #define SEARCHM_ENC_GE "%29"
00154
00155
00156 #define SEARCHM_ENC_BOL "%5e"
00157
00158
00159 #define SEARCHM_ENC_EOL "%24"
00160
00161
00162 #define SEARCHM_ENC_AL "%7c"
00163
00164
00165 #define SEARCHM_ENC_ZOM "%2a"
00166
00167
00168 #define SEARCHM_ENC_OOM "%2b"
00169
00170
00171 #define SEARCHM_ENC_AC "%2e"
00172
00173
00174
00175
00176 #define SEARCHM_ENC_SP "%5b%5b%3aspace%3a%5d%5d"
00177 #define SEARCHM_RE_SPACE "[[:space:]]"
00178 #define SEARCHM_RE_NOT_SPACE "[^[:space:]]"
00179 #define SEARCHM_ENC_NOT_SP "%5b" SEARCHM_ENC_BOL "%5b%3aspace%3a%5d%5d"
00180
00181
00182 #define SEARCHM_RE_START "(^|" SEARCHM_RE_SPACE ")("
00183 #define SEARCHM_ENC_RE_START SEARCHM_ENC_GB SEARCHM_ENC_BOL SEARCHM_ENC_AL SEARCHM_ENC_SP SEARCHM_ENC_GE SEARCHM_ENC_GB
00184
00185 #define SEARCHM_RE_END ")(" SEARCHM_RE_SPACE "|$)"
00186 #define SEARCHM_ENC_RE_END SEARCHM_ENC_GE SEARCHM_ENC_GB SEARCHM_ENC_SP SEARCHM_ENC_AL SEARCHM_ENC_EOL SEARCHM_ENC_GE
00187
00188 #define NULL_STRCMP_CASE 0
00189 #define NULL_STRCMP_NOCASE 1
00190
00191
00192
00193 #define SEARCHM_NUM_SUB_MATCHES 4
00194
00195
00196 #define SEARCHM_USE_SUB_MATCH 2
00197
00198
00199 #define SEARCHM_SUCCESS APR_SUCCESS
00200 #define SEARCHM_ERROR_ (APR_OS_START_USEERR + 1)
00201 #define SEARCHM_ERROR_METHOD_NOT_ALLOWED (APR_OS_START_USEERR + 2)
00202 #define SEARCHM_ERROR_BAD_REQUEST (APR_OS_START_USEERR + 3)
00203 #define SEARCHM_INTERNAL_SERVER_ERROR (APR_OS_START_USEERR + 4)
00204 #define SEARCHM_UNAUTHORIZED (APR_OS_START_USEERR + 5)
00205 #define SEARCHM_ERROR_DOC (APR_OS_START_USEERR + 6)
00206 #define SEARCHM_ERROR_NOHITS (APR_OS_START_USEERR + 7)
00207
00208 #define SEARCHM_ERROR_BUFFEROVERFLOW -1
00209 #define SEARCHM_ERROR_MALLOC -2
00210 #define SEARCHM_ERROR_INVALID_INDEX -3
00211 #define SEARCHM_ERROR_TAG_CACHE_SYNC -4
00212 #define SEARCHM_ERROR_FILE -5
00213 #define SEARCHM_ERROR_INVALID_QUERY -6
00214 #define SEARCHM_ERROR_INVALID_CONTENT_TYPE -8
00215 #define SEARCHM_ERROR_ABSOLUTE -10
00216 #define SEARCHM_ERROR_RELATIVE -11
00217 #define SEARCHM_ERROR_STRICT -12
00218 #define SEARCHM_ERROR_SWISH -13
00219 #define SEARCHM_ENDOFFILE -15
00220
00228 #define SEARCHM_MAX_SUBQUERIES 10
00229
00234 #define SEARCHM_PARAMETER_METATAG "metatag"
00235
00240 #define SEARCHM_PARAMETER_QUERY "query"
00241
00246 #define SEARCHM_PARAMETER_CONJ "conj"
00247
00253 #define SEARCHM_MAX_SORTPAIRS 4
00254
00259 #define SEARCHM_PARAMETER_SORT "sort"
00260
00265 #define SEARCHM_PARAMETER_ORDER "order"
00266
00272 #define SEARCHM_MAX_INDEX 4
00273
00278 #define SEARCHM_PARAMETER_INDEX "index"
00279
00284 #define SEARCHM_PARAMETER_DISPLAY "display"
00285
00290 #define SEARCHM_PARAMETER_PAGE "page"
00291
00296 #define SEARCHM_PARAMETER_WITHIN "within"
00297
00302 #define SEARCHM_PARAMETER_REQID "reqid"
00303
00309 #define SEARCHM_ITEMLIST_UNIQUE 0
00310
00316 #define SEARCHM_ITEMLIST_NONUNIQUE 1
00317
00322 #define SEARCHM_ITEMLIST_EMPTY (-INT_MAX)
00323
00328 #define SEARCHM_MAX_TERMS_LIST 32
00329
00334 #define SEARCHM_ERROR_NOTES "error-notes"
00335
00341 #define SEARCHM_LIMIT_STRING "limit"
00342
00347 #define SEARCHM_LIMIT_MAX 2
00348
00353 #define SEARCHM_LIMIT_MAX_SUB 7
00354
00355
00356 #define SEARCHM_IN_ALL (1<<8)
00357
00362 #define SEARCHM_BUFFER_CHUNK 1024
00363
00368 #define SEARCHM_UNIQUEID_SIZE (APR_MD5_DIGESTSIZE * 2)
00369
00375 #define SEARCHM_BDB_MAX_ENV 32
00376
00383 #define SEARCHM_BDB_MAX_DB 32
00384
00391
00392 #define SEARCHM_CONFIG_ICASE 0
00393
00398 #define DB_SEARCHM "DB_SEARCHM"
00399
00404 #define SEARCHM_BDB_MASTERLOCK "SEARCHM_BDB_MASETERLOCK"
00405
00406 #if !defined(OS2) && !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
00407 #include <unixd.h>
00408 #define MOD_SEARCHM_SET_MUTEX_PERMS
00409 #endif
00410
00415 typedef enum searchm_state {
00416 searchm_state_notdef=0,
00417 searchm_state_off,
00418 searchm_state_on
00419 } searchm_state_e;
00420
00425 typedef enum searchm_termtype {
00426 tt_equal,
00427 tt_quote,
00428 tt_left,
00429 tt_right,
00430 tt_meta,
00431 tt_term,
00432 tt_none,
00433 tt_and,
00434 tt_or,
00435 tt_not,
00436 tt_null
00437 } searchm_termtype_e;
00438
00445 typedef struct searchm_nodeelem {
00446 char * t;
00447 int i;
00448 struct searchm_nodeelem * next;
00449 struct searchm_nodeelem * prev;
00450 } searchm_nodeelem_t, * p_searchm_nodeelem_t;
00451
00457 typedef struct searchm_metaelem {
00458 char * n;
00459 struct searchm_metaelem * next;
00460 struct searchm_metaelem * prev;
00461 p_searchm_nodeelem_t l;
00462 int i;
00463 } searchm_metaelem_t, * p_searchm_metaelem_t;
00464
00470 typedef struct searchm_metalist {
00471 p_searchm_metaelem_t ml;
00472 int i;
00473 } searchm_metalist_t, * p_searchm_metalist_t;
00474
00480 typedef struct searchm_termitem {
00481 char * t;
00482 char * re;
00483 char * enc;
00484 regex_t * preg;
00485 regmatch_t * pmatch;
00486 regmatch_t * match;
00487 int nmatch;
00488 int usematch;
00489 int bDone;
00490 unsigned int pos;
00491 unsigned int mpos_b;
00492 unsigned int mpos_e;
00493 } searchm_termitem_t, * p_searchm_termitem_t;
00494
00500 typedef struct searchm_termlist {
00501 p_searchm_termitem_t tl;
00502 int n;
00503 int t;
00504 } searchm_termlist_t, * p_searchm_termlist_t;
00505
00515 typedef enum searchm_tag_ids {
00516 searchm_qpage=0,
00517 searchm_tag_ids_start=searchm_qpage,
00518 searchm_qdisplay,
00519 searchm_display,
00520 searchm_qcmdstring,
00521 searchm_reqid,
00522 searchm_page,
00523 searchm_header_names,
00524 searchm_hv,
00525 searchm_hits,
00526 searchm_error,
00527 searchm_pagenext,
00528 searchm_pageprev,
00529 searchm_hilitem_string,
00530 searchm_parsed_words,
00531 searchm_removed_words,
00532 searchm_date,
00533 searchm_subquery,
00534 searchm_total_pages,
00535 searchm_full_pages,
00536 searchm_start,
00537 searchm_end,
00538 searchm_sort,
00539 searchm_qconj,
00540 searchm_qquery,
00541 searchm_query,
00542 searchm_qmetatag,
00543 searchm_within,
00544 searchm_qorder,
00545 searchm_qsort,
00546 searchm_qindex,
00547 searchm_index,
00548 searchm_last_page,
00549 searchm_limit,
00550 searchm_low_limit,
00551 searchm_up_limit,
00552 searchm_prop_limit,
00553 searchm_cabsolute,
00554 searchm_crelative,
00555 searchm_cstrict,
00556 searchm_cindexdir,
00557 searchm_dbname,
00558 searchm_dbdesc,
00559 searchm_dbpointer,
00560 searchm_dbadmin,
00561 searchm_cbegin,
00562 searchm_cresult,
00563 searchm_cend,
00564 searchm_cnohits,
00565 searchm_invalid,
00566 searchm_tag_ids_total=searchm_invalid
00567 } searchm_tag_ids_e;
00568
00573 typedef enum searchm_auto_tags {
00574 searchm_auto_reccount=0,
00575 searchm_auto_tags_start=searchm_auto_reccount,
00576 searchm_auto_title,
00577 searchm_auto_rank,
00578 searchm_auto_docpath,
00579 searchm_auto_docsize,
00580 searchm_auto_lastmodified,
00581 searchm_auto_description,
00582 searchm_auto_sdescription,
00583 searchm_auto_dbfile,
00584 searchm_auto_tags_total
00585 } searchm_auto_tags_e;
00586
00587
00588
00589
00590
00591 typedef enum searchm_itemlist {
00592 searchm_itemlist_index=0,
00593 searchm_itemlist_start=searchm_itemlist_index,
00594 searchm_itemlist_subquery,
00595 searchm_itemlist_sortpair,
00596 searchm_itemlist_total
00597 } searchm_itemlist_e;
00598
00603 typedef enum searchm_limit_attr_type {
00604 searchm_limit_attr_type_date,
00605 searchm_limit_attr_type_integer,
00606 searchm_limit_attr_type_string
00607 } searchm_limit_attr_type_e, * p_searchm_limit_attr_type_e;
00608
00613 typedef enum searchm_limit_attr {
00614 searchm_limit_attr_name,
00615 searchm_limit_attr_start=searchm_limit_attr_name,
00616 searchm_limit_attr_active,
00617 searchm_limit_attr_type,
00618 searchm_limit_attr_hi,
00619 searchm_limit_attr_low,
00620 searchm_limit_attr_total,
00621 } searchm_limit_attr_e, * p_searchm_limit_attr_e;
00622
00627 typedef struct searchm_limit_data {
00628 const char * name;
00629 const char * active;
00630 const char * type;
00631 const char * hi[SEARCHM_LIMIT_MAX_SUB];
00632 const char * low[SEARCHM_LIMIT_MAX_SUB];
00633 int bEntries;
00634 int bValid;
00635 char * limit_hi;
00636 char * limit_low;
00637 searchm_limit_attr_type_e e_type;
00638 } searchm_limit_data_t, * p_searchm_limit_data_t;
00639
00645 typedef struct searchm_config {
00646 char * sza_indexdir;
00647 int bSetIndexDir;
00648 char * sza_lockfile;
00649 int bSetLockFile;
00650 int bActivate;
00651 int bSetActivate;
00652 #if defined(SEARCHM_DBM)
00653 char * sza_dbm;
00654 int bSetDBM;
00655 #elif defined(SEARCHM_BDB)
00656 char * sza_home;
00657 int bSetHome;
00658 char * sza_file;
00659 int bSetFile;
00660 int i_env;
00661 int i_db;
00662 searchm_state_e bdb_state;
00663 #endif
00664 } searchm_config_t, * p_searchm_config_t;
00665
00670 typedef struct searchm_dir_config {
00671 int bAbsolute;
00672 int bRelative;
00673 int bStrict;
00674 char * sza_begin;
00675 char * sza_result;
00676 char * sza_end;
00677 char * sza_nohits;
00678 char * sza_usertrack_cookie_name;
00679 int bSetAbsolute;
00680 int bSetRelative;
00681 int bSetStrict;
00682 int bSetBegin;
00683 int bSetResult;
00684 int bSetEnd;
00685 int bSetNoHits;
00686 int bUsertrackCookie;
00687 int bSetUserTrackCookieName;
00688 } searchm_dir_config_t, * p_searchm_dir_config_t;
00689
00690 #define INITIALIZE_SEARCHM_DIR_CONFIG {\
00691 .bAbsolute=0,\
00692 .bRelative=0,\
00693 .bStrict=1,\
00694 .sza_begin=NULL,\
00695 .sza_result=NULL,\
00696 .sza_end=NULL,\
00697 .sza_nohits=NULL,\
00698 .sza_usertrack_cookie_name=NULL,\
00699 .bSetAbsolute=0,\
00700 .bSetRelative=0,\
00701 .bSetStrict=0,\
00702 .bSetBegin=0,\
00703 .bSetResult=0,\
00704 .bSetEnd=0,\
00705 .bSetNoHits=0,\
00706 .bSetUserTrackCookieName=0,\
00707 .bUsertrackCookie=0\
00708 }
00709
00714 typedef struct searchm_sub_query {
00715 int weight;
00716 char * metatag;
00717 char * query;
00718 char * conj;
00719 char * sub_query;
00720 } searchm_sub_query_t, * p_searchm_sub_query_t;
00721
00726 typedef struct searchm_sortpair {
00727 int weight;
00728 char * sort;
00729 char * order;
00730 } searchm_sortpair_t, * p_searchm_sortpair_t;
00731
00736 typedef struct searchm_indexfile {
00737 int weight;
00738 char * index;
00739 char * fname;
00740 char * dbname;
00741 char * dbdesc;
00742 char * dbpointer;
00743 char * dbadmin;
00744 } searchm_indexfile_t, * p_searchm_indexfile_t;
00745
00750 typedef struct searchm_cmd_line {
00751 int structure;
00752 int cmd_structure;
00753 int page;
00754 int display;
00755 int bRequery;
00756 int bReqID;
00757 unsigned char reqid[SEARCHM_UNIQUEID_SIZE+1];
00758 searchm_sub_query_t sq[SEARCHM_MAX_SUBQUERIES];
00759 searchm_sortpair_t sp[SEARCHM_MAX_SORTPAIRS];
00760 int i_limit;
00761 searchm_limit_data_t limit[SEARCHM_LIMIT_MAX];
00762 int i_index;
00763 searchm_indexfile_t index[SEARCHM_MAX_INDEX];
00764 int i_within;
00765 } searchm_cmd_line_t, * p_searchm_cmd_line_t;
00766
00771 typedef struct searchm_tags {
00772 char * tag[searchm_tag_ids_total];
00773 char * cache;
00774 int i_cache;
00775 int i_cache_size;
00776 } searchm_tags_t, * p_searchm_tags_t;
00777
00782 typedef struct query_info {
00783 request_rec * p_rr;
00784 SW_HANDLE sw_handle;
00785 SW_SEARCH sw_search;
00786 SW_RESULTS sw_results;
00787 SW_RESULT sw_result_item;
00788 searchm_cmd_line_t cmd;
00789 const char * querystring;
00790 char delimiter;
00791 char * within;
00792 char * swishsort;
00793 char * swishquery;
00794 char * swishindex;
00795 const char ** stopwords_list;
00796 const char ** removed_list;
00797 apr_pool_t * ptemp;
00798 int hits;
00799 int page;
00800 int display;
00801 int pagenext;
00802 int pageprev;
00803 int i_start;
00804 int i_end;
00805 int i_full_pages;
00806 int i_total_pages;
00807 int i_last_page;
00808 searchm_tags_t st;
00809 int tag[searchm_tag_ids_total];
00810 p_searchm_config_t p_sc;
00811 p_searchm_dir_config_t p_sdc;
00812 char * p_cbegin;
00813 char * p_cresult;
00814 char * p_cend;
00815 char * p_cnohits;
00816 apr_file_t * fp_begin;
00817 apr_file_t * fp_result;
00818 apr_file_t * fp_end;
00819 apr_file_t * fp_nohits;
00820 unsigned long ul_bytes_sent;
00821 const char * p_cookie;
00822 int bRemoteCookie;
00823 const char * p_dbcookie;
00824 searchm_metalist_t ml;
00825 searchm_termlist_t tl;
00826 int bInDbase;
00827 int bForcePurge;
00828 #if defined(SEARCHM_DBM)
00829 apr_dbm_t * dbm;
00830 #elif defined(SEARCHM_BDB)
00831 u_int32_t lockid;
00832 DB_LOCK req_lock;
00833 int bReqLock;
00834 int bMasterLock;
00835 #endif
00836 } query_info_t, * p_query_info_t;
00837
00844 typedef struct searchm_dbpkt {
00845 int structure;
00846 int display;
00847 int bCookie;
00848 int bSort;
00849 int index;
00850 int limit;
00851 apr_time_t time;
00852 } searchm_dbpkt_t, * p_searchm_dbpkt_t;
00853
00858 typedef struct searchm_buffer {
00859 void * b;
00860 unsigned int pos;
00861 unsigned int size;
00862 } searchm_buffer_t, * p_searchm_buffer_t;
00863
00868 typedef struct searchm_cleanup_data {
00869 apr_pool_t * p;
00870 int bSS;
00871 } searchm_cleanup_data_t, * p_searchm_cleanup_data_t;
00872
00873
00874 #if defined(SEARCHM_BDB)
00875
00876
00877
00883 typedef struct searchm_bdb_env {
00884 DB_ENV * db_env;
00885 char * name;
00886 u_int32_t lock_id;
00887 char * lock_object;
00888 DB_LOCK lock;
00889 } searchm_bdb_env_t, * p_searchm_bdb_env_t;
00890
00891 #define INITIALIZE_SEARCHM_BDB_ENV {\
00892 .db_env=NULL,\
00893 .name=NULL,\
00894 .lock_id=0,\
00895 .lock_object=NULL\
00896 }
00897
00902 typedef struct searchm_bdb_db {
00903 DB * db;
00904 char * name;
00905 int i_env;
00906 } searchm_bdb_db_t, * p_searchm_bdb_db_t;
00907
00908 #define INITIALIZE_SEARCHM_BDB_DB {\
00909 .db=NULL,\
00910 .name=NULL,\
00911 .i_env=0\
00912 }
00913
00918 typedef struct searchm_bdb {
00919 searchm_bdb_env_t env[SEARCHM_BDB_MAX_ENV];
00920 searchm_bdb_db_t db[SEARCHM_BDB_MAX_DB];
00921 } searchm_bdb_t, * p_searchm_bdb_t;
00922
00923 #endif
00924
00925
00926
00927 static apr_global_mutex_t * searchm_global_lock=NULL;
00928
00929 #if APR_HAS_THREADS
00930 static apr_thread_mutex_t * lib_lock;
00931 #endif
00932
00933 #if defined (SEARCHM_BDB)
00934
00938 static searchm_bdb_db_t bdb_db_init=INITIALIZE_SEARCHM_BDB_DB;
00942 static searchm_bdb_env_t bdb_env_init=INITIALIZE_SEARCHM_BDB_ENV;
00943
00947 static const u_int32_t bdb_flags=0;
00948 static const u_int32_t bdb_set_flags=0;
00953 static const u_int32_t bdb_env_flags=DB_INIT_MPOOL|DB_INIT_LOCK;
00954 static const u_int32_t bdb_env_set_flags=0;
00959 static u_int32_t bdbthreaded=0;
00964 static searchm_bdb_t bdb;
00965
00971 static const db_lockmode_t bdb_lockmode=DB_LOCK_READ;
00972 #endif
00973
00974 static void * searchm_per_server_config(apr_pool_t *p, server_rec *s);
00975 static int searchm_hook_post_config(apr_pool_t *p, apr_pool_t * plog,
00976 apr_pool_t *ptemp, server_rec *s);
00977 static apr_status_t searchm_pool_post_config_cleanup(void * data);
00978 static void searchm_hook_child_init(apr_pool_t *p, server_rec *s);
00979 static void searchm_hook_child_init(apr_pool_t *p, server_rec *s);
00980 static apr_status_t searchm_pool_child_init_cleanup(void * parm);
00981 static void searchm_process_init(int bSS, apr_pool_t * p);
00982 static void searchm_process_cleanup(int bSS, apr_pool_t * p);
00983 static int searchm_method_handler(request_rec *r);
00984 static apr_status_t searchm_get_querystring(p_query_info_t p_qi);
00985 static apr_status_t searchm_tags_cache_cmdline(p_query_info_t p_qi);
00986 static apr_status_t searchm_tags_cache_add(p_query_info_t p_qi, char * s, searchm_tag_ids_e tag_id, int bDel);
00987 static searchm_tag_ids_e searchm_tagid(char * t, int * p_rval, char ** p_str);
00988 static searchm_auto_tags_e searchm_tagid_auto(char * tag);
00989 static unsigned int searchm_desc_trim_begin(const char * desc, unsigned int mpos, int * bStart);
00990 static unsigned int searchm_desc_trim_end(const char * desc, unsigned int mpos, int * bEnd);
00991 static char * searchm_description_handler(apr_pool_t * pool, apr_pool_t * ptemp, const char * desc, const char ** stopword_list, const char ** removed_list, p_searchm_termlist_t const p_tl);
00992 static apr_status_t searchm_replace_file(p_query_info_t p_qi, apr_file_t * fp);
00993 static char * searchm_replace_searchm_tag(p_query_info_t p_qi, searchm_tag_ids_e tag_id, int tval, char * p_str);
00994 static int searchm_parse_cmdline(p_query_info_t p_qi);
00995 static apr_status_t searchm_parse_cmdline_display(p_query_info_t p_qi, const char * p_value);
00996 static apr_status_t searchm_parse_cmdline_page(p_query_info_t p_qi, const char * p_value);
00997 static apr_status_t searchm_parse_cmdline_reqid(p_query_info_t p_qi, const char * p_value);
00998 static apr_status_t searchm_process_requestinfo(p_query_info_t p_qi);
00999 static apr_status_t searchm_parse_cmdline_within(p_query_info_t p_qi, const char * p_value);
01000 static apr_status_t searchm_parse_cmdline_index(p_query_info_t p_qi, const char * p_value, int nval);
01001 static apr_status_t searchm_parse_cmdline_conj(p_query_info_t p_qi, const char * p_value, int nval);
01002 static apr_status_t searchm_parse_cmdline_query(p_query_info_t p_qi, const char * p_value, int nval);
01003 static apr_status_t searchm_parse_cmdline_metatag(p_query_info_t p_qi, const char * p_value, int nval);
01004 static apr_status_t searchm_parse_cmdline_order(p_query_info_t p_qi, const char * p_value, int nval);
01005 static apr_status_t searchm_parse_cmdline_sort(p_query_info_t p_qi, const char * p_value, int nval);
01006 static apr_status_t searchm_parse_cmdline_limit(p_query_info_t p_qi, const char * value, int n, searchm_limit_attr_e ltype, int lstype);
01007 static int searchm_limit_process_date(const char * const ld[SEARCHM_LIMIT_MAX_SUB], apr_time_t * t);
01008 static int searchm_limit_process_string(const char * const ld[SEARCHM_LIMIT_MAX_SUB], char ** str, apr_pool_t * p);
01009 static int searchm_limit_process_integer(const char * const ld[SEARCHM_LIMIT_MAX_SUB], char ** str, apr_pool_t * p);
01010 static int searchm_limit_process(p_query_info_t p_qi);
01011 static int searchm_create_filepath(p_query_info_t p_qi);
01012 static int searchm_cmp_weighted(char * p, char * t, int * v);
01013 static int searchm_cmp_stringed(char * p, char * t, char ** p_str);
01014 static int searchm_cmp_limit(const char * param, int * n, p_searchm_limit_attr_e ltype, int * lstype, apr_pool_t * p);
01015 static apr_status_t searchm_itemlist_add(p_query_info_t p_qi, void * list, void * item, searchm_itemlist_e listtype, searchm_tag_ids_e itemtype);
01016 static apr_status_t searchm_pre_query(p_query_info_t p_qi);
01017 static apr_status_t searchm_create_within(p_query_info_t p_qi);
01018 static int searchm_structure_to_id(char * p_value);
01019 static int searchm_error_to_api(int i);
01020 static const char * searchm_set_absolute(cmd_parms *parms, void *dummy,
01021 const int arg);
01022 static const char * searchm_set_relative(cmd_parms *parms, void *dummy,
01023 const int arg);
01024 static const char * searchm_set_strict(cmd_parms *parms, void *dummy,
01025 const int arg);
01026 static const char * searchm_set_indexdir(cmd_parms *parms, void *dummy,
01027 const char *arg);
01028 static const char * searchm_set_lockfile(cmd_parms *parms, void *dummy, const char *arg);
01029 #if defined(SEARCHM_DBM)
01030 static const char * searchm_set_dbm(cmd_parms *parms, void *dummy, const char *arg);
01031 #elif defined(SEARCHM_BDB)
01032 static const char * searchm_set_bdb(cmd_parms *parms, void *dummy, const char *arg1, const char * arg2);
01033 #endif
01034 static const char * searchm_set_begin(cmd_parms *parms, void *dummy,
01035 const char *arg);
01036 static const char * searchm_set_result(cmd_parms *parms, void *dummy,
01037 const char *arg);
01038 static const char * searchm_set_end(cmd_parms *parms, void *dummy,
01039 const char *arg);
01040 static const char * searchm_set_nohits(cmd_parms *parms, void *dummy,
01041 const char *arg);
01042 static const char * searchm_set_activate(cmd_parms *parms, void *dummy, int bool);
01043 static void * searchm_per_dir_config(apr_pool_t * p, char * dir);
01044 static apr_status_t searchm_qi_setup(p_query_info_t p_qi, request_rec * r, p_searchm_config_t p_sc, p_searchm_dir_config_t p_sdc);
01045 static int searchm_metalist_process(p_query_info_t p_qi);
01046 static apr_status_t searchm_subquery_process(p_searchm_metalist_t const p_ml, const char ** sl, unsigned int * index_sl, const char * meta_def, apr_pool_t * p);
01047 static searchm_termtype_e searchm_gettermtype(const char * t);
01048 static searchm_termtype_e searchm_conjtype(const char * const t);
01049 static apr_status_t searchm_addterm(p_searchm_metalist_t p_ml, const char ** sl, int * index_sl, const char * m, int bP, int nterms, apr_pool_t * p);
01050 static apr_status_t searchm_metalist_add(p_searchm_metalist_t const p_ml, const char * mn, p_searchm_metaelem_t * pp_me, apr_pool_t * p);
01051 static p_searchm_metaelem_t searchm_metalist_get(p_searchm_metalist_t p_ml, const char * mn, int * bFound);
01052 static apr_status_t searchm_nodelist_add(p_searchm_metaelem_t const p_me, const char ** sl, int * index_sl, int bP, int nterms, apr_pool_t * p);
01053 static void searchm_metalist_destroy(p_searchm_metalist_t const p_ml);
01054 static int searchm_nullstrcmp(const char * const t1, const char * const t2, const int bCase);
01055 static apr_status_t searchm_nodelist_match(p_searchm_metaelem_t const me, const char ** sl, const int index_sl, const int bP, const int nterms, int * bResult, apr_pool_t * p);
01056 static apr_status_t searchm_phrase_match(p_searchm_metaelem_t const me, const char ** sl, const int index_sl, const int bP, const int nterms, int * bResult, apr_pool_t * p);
01057 static apr_status_t searchm_single_match(const char * t1, const char * t2, const int bWay, int * Result, apr_pool_t * p);
01058 static apr_status_t searchm_termlist_create(p_searchm_metalist_t const p_ml, const char * mn, int bUseNull, p_searchm_termlist_t const p_tl, int * bResult, apr_pool_t * p);
01059 static void searchm_termlist_destroy(p_searchm_termlist_t const p_tl, apr_pool_t * p);
01060 static int searchm_nextmatch(p_searchm_termlist_t const p_tl, const char * desc, unsigned int * pos, int * i_match, unsigned int * mpos_b);
01061 static apr_status_t searchm_cookie_process(p_query_info_t p_qi);
01062 static apr_status_t searchm_swishexecute(p_query_info_t p_qi);
01063 static apr_status_t searchm_phases(p_query_info_t p_qi);
01064 static apr_status_t searchm_phases_nohits(p_query_info_t p_qi);
01065 static void searchm_error_doc(p_query_info_t p_qi) ;
01066 static void searchm_test(p_query_info_t p_qi);
01067 static apr_status_t searchm_generate_reqid(p_query_info_t p_qi);
01068 static apr_status_t searchm_packet_make(p_query_info_t p_qi, void ** pkt, unsigned int * psize);
01069 static apr_status_t searchm_next_string(char ** s, void * v, unsigned int * pos, apr_pool_t * p);
01070 static apr_status_t searchm_packet_split(p_query_info_t p_qi, void * pkt, unsigned int psize);
01071 static apr_status_t searchm_buffer_expand(p_searchm_buffer_t pb, unsigned int min, apr_pool_t * p);
01072 static apr_status_t searchm_buffer_expand(p_searchm_buffer_t pb, unsigned int min, apr_pool_t * p);
01073 static apr_status_t searchm_buffer_add_string(const char * s, p_searchm_buffer_t pb, apr_pool_t * p);
01074 static apr_status_t searchm_buffer_add(void * pv, unsigned int size, p_searchm_buffer_t pb, apr_pool_t * p);
01075 static int searchm_absolute_path(const char * path);
01076 static int searchm_check_filename(const char * file);
01077 static int searchm_strcmp(const char * s1, const char * s2);
01078 static apr_status_t searchm_dbase_open(p_query_info_t p_qi);
01079 static apr_status_t searchm_dbase_close(p_query_info_t p_qi);
01080 static apr_status_t searchm_dbase_get(p_query_info_t p_qi);
01081 static apr_status_t searchm_dbase_put(p_query_info_t p_qi);
01082 static apr_status_t searchm_dbase_purge(p_query_info_t p_qi);
01083 #if defined(SEARCHM_DBM)
01084 static apr_status_t searchm_dbm_open(p_query_info_t p_qi);
01085 static apr_status_t searchm_dbm_close(p_query_info_t p_qi);
01086 static apr_status_t searchm_dbm_get(p_query_info_t p_qi, const char * p_key, void ** pkt, unsigned int * psize);
01087 static apr_status_t searchm_dbm_fetch(p_query_info_t p_qi, const char * p_key, void ** pkt, unsigned int * psize);
01088 static apr_status_t searchm_dbm_put(p_query_info_t p_qi, const char * p_key, void * pkt, unsigned int psize);
01089 static apr_status_t searchm_dbm_store(p_query_info_t p_qi, const char * p_key, void * pkt, unsigned int psize);
01090 static apr_status_t searchm_dbm_delete(p_query_info_t p_qi, const char * p_key);
01091 static apr_status_t searchm_dbm_firstkey(p_query_info_t p_qi, char ** p_key);
01092 static apr_status_t searchm_dbm_nextkey(p_query_info_t p_qi, char ** p_key);
01093 static apr_status_t searchm_dbm_purge(p_query_info_t p_qi);
01094 #elif defined(SEARCHM_BDB)
01095 static int searchm_version_check(apr_pool_t * p);
01096 static apr_status_t searchm_bdb_get(p_query_info_t p_qi, const char * p_key, void ** pkt, unsigned int * psize);
01097 static apr_status_t searchm_bdb_put(p_query_info_t p_qi, const char * p_key, void * pkt, unsigned int psize);
01098 static int searchm_bdb_del(p_query_info_t p_qi, const char * p_key, int * bFound);
01099 static int searchm_bdb_env_close(int env_index, apr_pool_t * p);
01100 static apr_status_t searchm_bdb_env_open(p_query_info_t p_qi);
01101 static apr_status_t searchm_bdb_db_open(p_query_info_t p_qi);
01102 static int searchm_bdb_db_close(int db_index, apr_pool_t * p);
01103 static apr_status_t searchm_bdb_reqlock_get(p_query_info_t p_qi);
01104 static apr_status_t searchm_bdb_masterlock_get(p_query_info_t p_qi, u_int32_t ltype);
01105 static apr_status_t searchm_bdb_reqlock_free(p_query_info_t p_qi);
01106 static apr_status_t searchm_bdb_masterlock_free(p_query_info_t p_qi);
01107 static apr_status_t searchm_bdb_open(p_query_info_t p_qi);
01108 static apr_status_t searchm_bdb_close(p_query_info_t p_qi);
01109 static apr_status_t searchm_bdb_purge(p_query_info_t p_qi);
01110 static apr_status_t searchm_bdb_purge_check(p_query_info_t p_qi, int * bPurge);
01111
01112 #endif
01113 #endif