~ubuntu-branches/ubuntu/trusty/hyperestraier/trusty-proposed

« back to all changes in this revision

Viewing changes to mastermod.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2006-11-14 05:28:32 UTC
  • mfrom: (2.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061114052832-0lzqzcefn8mt4yqe
Tags: 1.4.9-1.1
* Non-maintainer upload.
* High-urgency upload for RC bugfix.
* Set HOME=$(CURDIR)/junkhome when building, otherwise the package build
  will incorrectly look for headers there -- and fail when the directory
  exists and is unreadable, as happens sometimes on sudo-using
  autobuilders!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*************************************************************************************************
2
2
 * Common modules related to estmaster
3
 
 *                                                      Copyright (C) 2004-2005 Mikio Hirabayashi
 
3
 *                                                      Copyright (C) 2004-2006 Mikio Hirabayashi
4
4
 * This file is part of Hyper Estraier.
5
5
 * Hyper Estraier is free software; you can redistribute it and/or modify it under the terms of
6
6
 * the GNU Lesser General Public License as published by the Free Software Foundation; either
21
21
#include "estmtdb.h"
22
22
#include "estnode.h"
23
23
#include "myconf.h"
 
24
#include "mymorph.h"
24
25
 
25
26
 
26
27
 
31
32
 
32
33
#define NUMBUFSIZ      32                /* size of a buffer for a number */
33
34
#define URIBUFSIZ      8192              /* size of a buffer for an URI */
 
35
#define IOBUFSIZ       8192              /* size of a buffer for I/O */
34
36
#define HOSTBUFSIZ     256               /* size of a buffer for a host name */
35
37
#define ADDRBUFSIZ     48                /* size of a buffer for an address */
36
38
#define NODENAMEMAX    128               /* maximum length of node name  */
37
39
#define MINIBNUM       31                /* bucket number of a small map */
38
40
#define KWORDNUM       32                /* number of shown keywords */
 
41
#define CONDATTRMAX    9                 /* maximum number of attribute conditions */
 
42
#define DEFMAXSRCH     10                /* default max number of retrieved documents */
 
43
#define SELFCREDIT     10000             /* credit of the node itself */
39
44
 
40
45
#define CONFFILE       "_conf"           /* name of the configuration file */
41
46
#define USERFILE       "_user"           /* name of the user list file */
48
53
#define SESSDIR        "_sess"           /* name of the session directory */
49
54
#define NULLDEV        "/dev/null"       /* path of null device */
50
55
 
 
56
#define INFORMHELPER   "estbutler inform"    /* command name of the inform helper */
 
57
#define SEARCHHELPER   "estbutler search"    /* command name of the search helper */
 
58
#define GETDOCHELPER   "estbutler getdoc"    /* command name of the get_doc helper */
 
59
#define GETDOCATTRHELPER  "estbutler getdocattr"  /* command name of the get_doc helper */
 
60
#define ETCHDOCHELPER  "estbutler etchdoc"   /* command name of the etch_doc helper */
 
61
#define URITOIDHELPER  "estbutler uritoid"   /* command name of the uri_to_id helper */
 
62
 
51
63
#define MMKMAGIC       "magic"           /* meta key of the magic number of meta DB */
52
64
#define MMKMAGVAL      "[ESTMASTER]"     /* value of the magic number of meta DB */
53
65
#define NMKNAME        "name"            /* meta key of the name of node DB */
56
68
#define NMKUSERS       "users"           /* meta key of the users of node DB */
57
69
#define NMKLINKS       "links"           /* meta key of the links of node DB */
58
70
 
 
71
#define DATTRNDURL     "#nodeurl"        /* name of the pseudo-attribute of the node URL */
 
72
#define DATTRNDLABEL   "#nodelabel"      /* name of the pseudo-attribute of the node label */
 
73
#define DATTRNDSCORE   "#nodescore"      /* name of the pseudo-attribute of the node score */
 
74
#define DATTRLFILE     "_lfile"          /* name of the attribute of the file name */
 
75
 
59
76
enum {                                   /* enumeration for running modes */
60
77
  RM_NORMAL = 1,                         /* normal */
61
78
  RM_RDONLY = 2                          /* read only */
76
93
  LL_CHECK = 6                           /* check to open */
77
94
};
78
95
 
 
96
enum {                                   /* enumeration for scale prediction */
 
97
  SP_SMALL = 1,                          /* small */
 
98
  SP_MEDIUM = 2,                         /* medium */
 
99
  SP_LARGE = 3,                          /* large */
 
100
  SP_HUGE = 4                            /* huge */
 
101
};
 
102
 
 
103
enum {                                   /* enumeration for scoring expression modes */
 
104
  SE_VOID = 1,                           /* void */
 
105
  SE_CHAR = 2,                           /* char */
 
106
  SE_INT = 3,                            /* int */
 
107
  SE_ASIS = 4                            /* asis */
 
108
};
 
109
 
 
110
enum {                                   /* enumeration for UI operations */
 
111
  MM_SCORE = 1,                          /* score */
 
112
  MM_SCRK = 2,                           /* score and rank */
 
113
  MM_RANK = 3                            /* rank */
 
114
};
 
115
 
 
116
enum {                                   /* enumeration for phrase mode */
 
117
  PM_USUAL = 1,                          /* usual phrase */
 
118
  PM_SIMPLE = 2,                         /* simplified phrase */
 
119
  PM_ROUGH = 3,                          /* rough phrase */
 
120
  PM_UNION = 4,                          /* union phrase */
 
121
  PM_ISECT = 5                           /* intersection phrase */
 
122
};
 
123
 
79
124
typedef struct {                         /* type of structure for a user object */
80
125
  char *name;                            /* unique name */
81
126
  char *passwd;                          /* encrypted password */
107
152
typedef struct {                         /* type of structure for a node manager object */
108
153
  char *rootdir;                         /* path of the root directory */
109
154
  CBMAP *nodes;                          /* map of names and entities */
 
155
  CBMAP *aidxs;                          /* map of attribute indexes */
110
156
} NMGR;
111
157
 
112
158
typedef struct {                         /* type of structure for a read/write lock object */
142
188
   `rootdir' specifies the path of the root directory.
143
189
   `path' specifies the path of the log file.
144
190
   `level' specifies the leve of logging.
 
191
   `trunc' specifies whether to truncate the log file.
145
192
   The return value is true if success, else it is false. */
146
 
int log_open(const char *rootdir, const char *path, int level);
 
193
int log_open(const char *rootdir, const char *path, int level, int trunc);
147
194
 
148
195
 
149
196
/* Print formatted string into the log file. */
150
197
void log_print(int level, const char *format, ...);
151
198
 
152
199
 
 
200
/* Rotete the log file.
 
201
   `rootdir' specifies the path of the root directory.
 
202
   `path' specifies the path of the log file.
 
203
   The return value is true if success, else it is false. */
 
204
int log_rotate(const char *rootdir, const char *path);
 
205
 
 
206
 
153
207
/* Initialize the root directory.
154
208
   `rootdir' specifies the path of the root directory.
155
209
   The return value is true if success, else it is false. */
277
331
int nmgr_sync(NMGR *nmgr, int phis);
278
332
 
279
333
 
 
334
/* Add an attribute index to a node manager object.
 
335
   `nmgr' specifies a node manager object.
 
336
   `name' specifies the name of a target attribute.
 
337
   `type' specifies the expression of a data type. */
 
338
void nmgr_add_aidx(NMGR *nmgr, const char *name, const char *type);
 
339
 
 
340
 
280
341
/* Add a node to a node manager object.
281
342
   `nmgr' specifies a node manager object.
282
343
   `name' specifies the unique name of a node.
283
344
   `wmode' specifies whether the node is a writer or a reader.
 
345
   `options' specifies options for the database of the node.
284
346
   The return value is true if success, else it is false. */
285
 
int nmgr_put(NMGR *nmgr, const char *name, int wmode);
 
347
int nmgr_put(NMGR *nmgr, const char *name, int wmode, int options);
286
348
 
287
349
 
288
350
/* Remove a node from a node manager object.
292
354
int nmgr_out(NMGR *nmgr, const char *name);
293
355
 
294
356
 
 
357
/* Clear registered documents in a node in a node manager object.
 
358
   `nmgr' specifies a node manager object.
 
359
   `name' specifies the unique name of a node.
 
360
   `options' specifies options for the database of the node.
 
361
   The return value is true if success, else it is false. */
 
362
int nmgr_clear(NMGR *nmgr, const char *name, int options);
 
363
 
 
364
 
295
365
/* Get a list of names of nodes in a noder manager object.
296
366
   `nmgr' specifies a node manager object.
297
367
   The return value is a list object of names of nodes in a node manager object.
376
446
   assigned.
377
447
   `order' specifies an expression for the order.  If it is `NULL', the order is by score
378
448
   descending.
 
449
   `distinct' specifies the name of the distinct attribute.  If it is `NULL', no filter is used.
379
450
   The return value is an array whose elements are result document objects.  Because the region
380
451
   of the return value is allocated with the `malloc' call, it should be released with the `free'
381
452
   call if it is no longer in use. */
382
 
RESDOC **resmap_list(RESMAP *resmap, int *nump, const char *order);
 
453
RESDOC **resmap_list(RESMAP *resmap, int *nump, const char *order, const char *distinct);
383
454
 
384
455
 
385
456
/* Be a daemon process.