Namazu-devel-ja(旧)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multiple "subquery" in namazu.cgi
- From: Jun Kuriyama <kuriyama@xxxxxxxxxxxx>
- Date: Tue, 16 May 2000 12:41:32 +0900
- X-ml-name: namazu-devel-ja
- X-mail-count: 00486
namazu の設計思想的に受け入れられるかどうかわからないので、BTS ではな
くこちらに流してみます。
社内のメーリングリストなどを検索するために namazu を使わせて頂いている
のですが、メーリングリストを絞り込むための検索インターフェイスに
<input type="checkbox"> を使うようにしています。
で、このようなインターフェイスで subquery として渡そうとしても、
namazu.cgi では subquery は一つしか扱ってくれない様子です。それを、CGI
経由で複数の subquery が渡ってきた場合にそれらを merge するようにしてみ
ました。
merge する際に、デフォルトでは " " で繋ぐのですが、うちの場合にはいく
つかのメーリングリストを検索対象にしたい、という状況のため、.namazurc に
SubQueryCond " or "
としていすることで " or " で繋ぐこともできるようにしました。
とりあえずはこんな感じになってます(CVS Repository からの diff)。
# あ、namazu 的 indent style policy と違ってしまってるかも……。
Index: nmz/libnamazu.c
===================================================================
RCS file: /storage/cvsroot/namazu/nmz/libnamazu.c,v
retrieving revision 1.34
diff -u -r1.34 libnamazu.c
--- nmz/libnamazu.c 2000/05/03 23:56:58 1.34
+++ nmz/libnamazu.c 2000/05/16 02:24:38
@@ -63,6 +63,8 @@
static enum nmz_sortorder sortorder = DESCENDING;
static int maxhit = 10000; /* Ignore if pages matched more than this. */
static int maxmatch = 1000; /* Ignore if words matched more than this. */
+static char subquerycond[BUFSIZE] = " ";
+ /* Insert this between multiple subqueries. */
static int debugmode = 0;
static int loggingmode = 1; /* do logging with NMZ.slog */
static char dyingmsg[BUFSIZE] = "";
@@ -138,6 +140,18 @@
nmz_set_debugmode(int mode)
{
debugmode = mode;
+}
+
+void
+nmz_set_subquerycond(const char *cond)
+{
+ strcpy(subquerycond, cond);
+}
+
+char *
+nmz_get_subquerycond(void)
+{
+ return subquerycond;
}
int
Index: nmz/libnamazu.h
===================================================================
RCS file: /storage/cvsroot/namazu/nmz/libnamazu.h,v
retrieving revision 1.44
diff -u -r1.44 libnamazu.h
--- nmz/libnamazu.h 2000/05/03 23:56:58 1.44
+++ nmz/libnamazu.h 2000/05/16 02:24:38
@@ -235,6 +235,8 @@
extern int nmz_get_maxhit ( void );
extern void nmz_set_maxmatch ( int max );
extern int nmz_get_maxmatch ( void );
+extern void nmz_set_subquerycond(const char *cond);
+extern char *nmz_get_subquerycond(void);
extern void nmz_set_debugmode ( int mode );
extern int nmz_is_debugmode ( void );
extern void nmz_set_loggingmode ( int mode );
Index: src/cgi.c
===================================================================
RCS file: /storage/cvsroot/namazu/src/cgi.c,v
retrieving revision 1.60
diff -u -r1.60 cgi.c
--- src/cgi.c 2000/04/04 22:22:40 1.60
+++ src/cgi.c 2000/05/16 02:24:38
@@ -348,7 +348,15 @@
}
#endif /* MSIE4MACFIX */
- strcpy(ca->subquery, value);
+ if (strlen(ca->subquery) == 0) {
+ strcpy(ca->subquery, value);
+ } else {
+ if (strlen(ca->subquery)
+ + strlen(nmz_get_subquerycond()) + strlen(value) + 1 < BUFSIZE) {
+ strcat(ca->subquery, nmz_get_subquerycond());
+ strcat(ca->subquery, value);
+ }
+ }
}
/*
Index: src/namazu.c
===================================================================
RCS file: /storage/cvsroot/namazu/src/namazu.c,v
retrieving revision 1.102
diff -u -r1.102 namazu.c
--- src/namazu.c 2000/03/04 11:11:39 1.102
+++ src/namazu.c 2000/05/16 02:24:38
@@ -113,7 +113,7 @@
enum nmz_stat
namazu_core(char * query, char *subquery)
{
- char query_with_subquery[BUFSIZE * 2];
+ char query_with_subquery[BUFSIZE * 2 + 6]; /* +6 for " ( ) " */
NmzResult hlist;
/* Make full-pathname of NMZ.{head,foot,msg,body,slog}.?? */
@@ -130,8 +130,9 @@
*/
strcpy(query_with_subquery, query);
if (strlen(subquery) > 0) {
- strcat(query_with_subquery, " ");
+ strcat(query_with_subquery, " ( ");
strcat(query_with_subquery, subquery);
+ strcat(query_with_subquery, " ) ");
}
/*
Index: src/rcfile.c
===================================================================
RCS file: /storage/cvsroot/namazu/src/rcfile.c,v
retrieving revision 1.26
diff -u -r1.26 rcfile.c
--- src/rcfile.c 2000/05/08 23:38:43 1.26
+++ src/rcfile.c 2000/05/16 02:24:38
@@ -113,6 +113,7 @@
static enum nmz_stat process_rc_scoring ( const char *directive, const StrList *args );
static enum nmz_stat process_rc_lang ( const char *directive, const StrList *args );
static enum nmz_stat process_rc_emphasistags ( const char *directive, const StrList *args );
+static enum nmz_stat process_rc_subquerycond ( const char *directive, const StrList *args );
static enum nmz_stat process_rc_template ( const char *directive, const StrList *args );
static enum nmz_stat process_rc_maxhit ( const char *directive, const StrList *args );
static enum nmz_stat process_rc_maxmatch ( const char *directive, const StrList *args );
@@ -135,6 +136,7 @@
{ "SCORING", 1, 0, process_rc_scoring },
{ "LANG", 1, 0, process_rc_lang },
{ "EMPHASISTAGS", 2, 0, process_rc_emphasistags },
+ { "SUBQUERYCOND", 1, 0, process_rc_subquerycond },
{ "TEMPLATE", 1, 0, process_rc_template },
{ "MAXHIT", 1, 0, process_rc_maxhit },
{ "MAXMATCH", 1, 0, process_rc_maxmatch },
@@ -254,6 +256,16 @@
char *arg2 = args->next->value;
set_emphasis_tags(arg1, arg2); /* order: start, end */
+ return SUCCESS;
+}
+
+static enum nmz_stat
+process_rc_subquerycond(const char *directive, const StrList *args)
+{
+ char *arg1 = args->value;
+ char *arg2 = args->next->value;
+
+ nmz_set_subquerycond(arg1);
return SUCCESS;
}
--
Jun Kuriyama <kuriyama@xxxxxxxxxxxx> // IMG SRC, Inc.
<kuriyama@xxxxxxxxxxx> // FreeBSD Project