1 |
dpavlin |
2 |
/************************************************************************************************* |
2 |
|
|
* The node API of Hyper Estraier |
3 |
|
|
* Copyright (C) 2004-2005 Mikio Hirabayashi |
4 |
|
|
* This file is part of Hyper Estraier. |
5 |
|
|
* Hyper Estraier is free software; you can redistribute it and/or modify it under the terms of |
6 |
|
|
* the GNU Lesser General Public License as published by the Free Software Foundation; either |
7 |
|
|
* version 2.1 of the License or any later version. Hyper Estraier is distributed in the hope |
8 |
|
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
10 |
|
|
* License for more details. |
11 |
|
|
* You should have received a copy of the GNU Lesser General Public License along with Hyper |
12 |
|
|
* Estraier; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
13 |
|
|
* Boston, MA 02111-1307 USA. |
14 |
|
|
*************************************************************************************************/ |
15 |
|
|
|
16 |
|
|
|
17 |
|
|
#ifndef _ESTNODE_H /* duplication check */ |
18 |
|
|
#define _ESTNODE_H |
19 |
|
|
|
20 |
|
|
#if defined(__cplusplus) /* export for C++ */ |
21 |
|
|
extern "C" { |
22 |
|
|
#endif |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include <estraier.h> |
26 |
|
|
#include <estmtdb.h> |
27 |
|
|
#include <cabin.h> |
28 |
|
|
#include <pthread.h> |
29 |
|
|
#include <stdlib.h> |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
/************************************************************************************************* |
34 |
|
|
* API for the network environment |
35 |
|
|
*************************************************************************************************/ |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
/* Initialize the networking environment. |
39 |
|
|
The return value is true if success, else it is false. */ |
40 |
|
|
int est_init_net_env(void); |
41 |
|
|
|
42 |
|
|
|
43 |
|
|
/* Free the networking environment. */ |
44 |
|
|
void est_free_net_env(void); |
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
/************************************************************************************************* |
49 |
|
|
* API for search result of node |
50 |
|
|
*************************************************************************************************/ |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
typedef struct { /* type of structure for a document in result */ |
54 |
|
|
const char *uri; /* URI */ |
55 |
|
|
CBMAP *attrs; /* attributes */ |
56 |
|
|
char *snippet; /* snippet */ |
57 |
|
|
} ESTRESDOC; |
58 |
|
|
|
59 |
|
|
typedef struct { /* type of structure for search result */ |
60 |
|
|
ESTRESDOC *docs; /* array of documents */ |
61 |
|
|
int top; /* offset number of the top element */ |
62 |
|
|
int max; /* maximum number of allcated elements */ |
63 |
|
|
int dnum; /* number of effective elements */ |
64 |
|
|
CBMAP *hints; /* map object for hints */ |
65 |
|
|
} ESTNODERES; |
66 |
|
|
|
67 |
|
|
|
68 |
|
|
/* Delete a node result object. |
69 |
|
|
`nres' specifies a node result object. */ |
70 |
|
|
void est_noderes_delete(ESTNODERES *nres); |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
/* Get a map object for hints of a node result object. |
74 |
|
|
`nres' specifies a node result object. |
75 |
|
|
The return value is a map object for hints. Keys of the map are "VERSION", "NODE", "HIT", |
76 |
|
|
"HINT#n", "DOCNUM", "WORDNUM", "TIME", "LINK#n", and "VIEW". The life duration of the |
77 |
|
|
returned object is synchronous with the one of the node result object. */ |
78 |
|
|
CBMAP *est_noderes_hints(ESTNODERES *nres); |
79 |
|
|
|
80 |
|
|
|
81 |
|
|
/* Get the number of documents in a node result object. |
82 |
|
|
`nres' specifies a node result object. |
83 |
|
|
The return value is the number of documents in a node result object. */ |
84 |
|
|
int est_noderes_doc_num(ESTNODERES *nres); |
85 |
|
|
|
86 |
|
|
|
87 |
|
|
/* Refer a result document object in a node result object. |
88 |
|
|
`nres' specifies a node result object. |
89 |
|
|
`index' specifies the index of a document. |
90 |
|
|
The return value is a result document object or `NULL' if `index' is equal to or more than |
91 |
|
|
the number of documents. The life duration of the returned object is synchronous with the |
92 |
|
|
one of the node result object. */ |
93 |
|
|
ESTRESDOC *est_noderes_get_doc(ESTNODERES *nres, int index); |
94 |
|
|
|
95 |
|
|
|
96 |
|
|
/* Get the URI of a result document object. |
97 |
|
|
`doc' specifies a result document object. |
98 |
|
|
The return value is the URI of the result document object. The life duration of the returned |
99 |
|
|
string is synchronous with the one of the result document object. */ |
100 |
|
|
const char *est_resdoc_uri(ESTRESDOC *rdoc); |
101 |
|
|
|
102 |
|
|
|
103 |
|
|
/* Get a list of attribute names of a result document object. |
104 |
|
|
`rdoc' specifies a result document object. |
105 |
|
|
The return value is a new list object of attribute names of the result document object. |
106 |
|
|
Because the object of the return value is opened with the function `cblistopen', it should be |
107 |
|
|
closed with the function `cblistclose' if it is no longer in use. */ |
108 |
|
|
CBLIST *est_resdoc_attr_names(ESTRESDOC *rdoc); |
109 |
|
|
|
110 |
|
|
|
111 |
|
|
/* Get the value of an attribute of a result document object. |
112 |
|
|
`rdoc' specifies a result document object. |
113 |
|
|
`name' specifies the name of an attribute. |
114 |
|
|
The return value is the value of the attribute or `NULL' if it does not exist. The life |
115 |
|
|
duration of the returned string is synchronous with the one of the result document object. */ |
116 |
|
|
const char *est_resdoc_attr(ESTRESDOC *rdoc, const char *name); |
117 |
|
|
|
118 |
|
|
|
119 |
|
|
/* Get the snippet of a result document object. |
120 |
|
|
`rdoc' specifies a result document object. |
121 |
|
|
The return value is the snippet of the result document object. There are tab separated |
122 |
|
|
values. Each line is a string to be shown. Though most lines have only one field, some |
123 |
|
|
lines have two fields. If the second field exists, the first field is to be shown with |
124 |
|
|
highlighted, and the second field means its normalized form. The life duration of the |
125 |
|
|
returned string is synchronous with the one of the result document object. */ |
126 |
|
|
const char *est_resdoc_snippet(ESTRESDOC *rdoc); |
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
/************************************************************************************************* |
131 |
|
|
* API for node |
132 |
|
|
*************************************************************************************************/ |
133 |
|
|
|
134 |
|
|
|
135 |
|
|
typedef struct { /* type of structure for a node object */ |
136 |
|
|
char *url; /* URL */ |
137 |
|
|
char *pxhost; /* host name of the proxy */ |
138 |
|
|
int pxport; /* port number of the proxy */ |
139 |
|
|
int timeout; /* timeout in seconds */ |
140 |
|
|
char *auth; /* authority */ |
141 |
|
|
char *name; /* name */ |
142 |
|
|
char *label; /* label */ |
143 |
|
|
int dnum; /* number of documents */ |
144 |
|
|
int wnum; /* number of words */ |
145 |
|
|
double size; /* size of the database */ |
146 |
|
|
int status; /* last status code */ |
147 |
|
|
CBMAP *heads; /* extention headers */ |
148 |
|
|
} ESTNODE; |
149 |
|
|
|
150 |
|
|
|
151 |
|
|
/* Create a node connection object. |
152 |
|
|
`url' specifies the URL of a node. |
153 |
|
|
The return value is a node connection object. */ |
154 |
|
|
ESTNODE *est_node_new(const char *url); |
155 |
|
|
|
156 |
|
|
|
157 |
|
|
/* Destroy a node connection object. |
158 |
|
|
`node' specifies a node connection object. */ |
159 |
|
|
void est_node_delete(ESTNODE *node); |
160 |
|
|
|
161 |
|
|
|
162 |
|
|
/* Get the status code of the last request of a node. |
163 |
|
|
`node' specifies a node connection object. |
164 |
|
|
The return value is the status code of the last request of the node. -1 means failure of |
165 |
|
|
connection. */ |
166 |
|
|
int est_node_status(ESTNODE *node); |
167 |
|
|
|
168 |
|
|
|
169 |
|
|
/* Set the proxy information of a node connection object. |
170 |
|
|
`node' specifies a node connection object. |
171 |
|
|
`host' specifies the host name of a proxy server. |
172 |
|
|
`port' specifies the port number of the proxy server. */ |
173 |
|
|
void est_node_set_proxy(ESTNODE *node, const char *host, int port); |
174 |
|
|
|
175 |
|
|
|
176 |
|
|
/* Set timeout of a connection. |
177 |
|
|
`node' specifies a node connection object. |
178 |
|
|
`sec' specifies timeout of the connection in seconds. */ |
179 |
|
|
void est_node_set_timeout(ESTNODE *node, int sec); |
180 |
|
|
|
181 |
|
|
|
182 |
|
|
/* Set the authoririty information of a node connection object. |
183 |
|
|
`node' specifies a node connection object. |
184 |
|
|
`name' specifies the name of an authority. |
185 |
|
|
`passwd' specifies the password of the authority. */ |
186 |
|
|
void est_node_set_auth(ESTNODE *node, const char *name, const char *passwd); |
187 |
|
|
|
188 |
|
|
|
189 |
|
|
/* Add a document to a node. |
190 |
|
|
`node' specifies a node connection object. |
191 |
|
|
`doc' specifies a document object. The document object should have the URI attribute. |
192 |
|
|
The return value is true if success, else it is false. |
193 |
|
|
If the URI attribute is same with an existing document in the node, the existing one is |
194 |
|
|
deleted. */ |
195 |
|
|
int est_node_put_doc(ESTNODE *node, ESTDOC *doc); |
196 |
|
|
|
197 |
|
|
|
198 |
|
|
/* Remove a document from a node. |
199 |
|
|
`node' specifies a node connection object. |
200 |
|
|
`id' specifies the ID number of a registered document. |
201 |
|
|
The return value is true if success, else it is false. */ |
202 |
|
|
int est_node_out_doc(ESTNODE *node, int id); |
203 |
|
|
|
204 |
|
|
|
205 |
|
|
/* Remove a document specified by URI from a node. |
206 |
|
|
`node' specifies a node connection object. |
207 |
|
|
`uri' specifies the URI of a registered document. |
208 |
|
|
The return value is true if success, else it is false. */ |
209 |
|
|
int est_node_out_doc_by_uri(ESTNODE *node, const char *uri); |
210 |
|
|
|
211 |
|
|
|
212 |
|
|
/* Retrieve a document in a node. |
213 |
|
|
`node' specifies a node connection object. |
214 |
|
|
`id' specifies the ID number of a registered document. |
215 |
|
|
The return value is a document object. It should be deleted with `est_doc_delete' if it is |
216 |
|
|
no longer in use. On error, `NULL' is returned. */ |
217 |
|
|
ESTDOC *est_node_get_doc(ESTNODE *node, int id); |
218 |
|
|
|
219 |
|
|
|
220 |
|
|
/* Retrieve a document specified by URI in a node. |
221 |
|
|
`node' specifies a node connection object. |
222 |
|
|
`uri' specifies the URI of a registered document. |
223 |
|
|
The return value is a document object. It should be deleted with `est_doc_delete' if it is |
224 |
|
|
no longer in use. On error, `NULL' is returned. */ |
225 |
|
|
ESTDOC *est_node_get_doc_by_uri(ESTNODE *node, const char *uri); |
226 |
|
|
|
227 |
|
|
|
228 |
|
|
/* Retrieve the value of an attribute of a document in a node. |
229 |
|
|
`node' specifies a node connection object. |
230 |
|
|
`id' specifies the ID number of a registered document. |
231 |
|
|
`name' specifies the name of an attribute. |
232 |
|
|
The return value is the value of the attribute or `NULL' if it does not exist. Because the |
233 |
|
|
region of the return value is allocated with the `malloc' call, it should be released with |
234 |
|
|
the `free' call if it is no longer in use. */ |
235 |
|
|
char *est_node_get_doc_attr(ESTNODE *node, int id, const char *name); |
236 |
|
|
|
237 |
|
|
|
238 |
|
|
/* Retrieve the value of an attribute of a document specified by URI in a node. |
239 |
|
|
`node' specifies a node connection object. |
240 |
|
|
`uri' specifies the URI of a registered document. |
241 |
|
|
`name' specifies the name of an attribute. |
242 |
|
|
The return value is the value of the attribute or `NULL' if it does not exist. Because the |
243 |
|
|
region of the return value is allocated with the `malloc' call, it should be released with |
244 |
|
|
the `free' call if it is no longer in use. */ |
245 |
|
|
char *est_node_get_doc_attr_by_uri(ESTNODE *node, const char *uri, const char *name); |
246 |
|
|
|
247 |
|
|
|
248 |
|
|
/* Get the ID of a document spacified by URI. |
249 |
|
|
`node' specifies a node connection object. |
250 |
|
|
`uri' specifies the URI of a registered document. |
251 |
|
|
The return value is the ID of the document. On error, -1 is returned. */ |
252 |
|
|
int est_node_uri_to_id(ESTNODE *node, const char *uri); |
253 |
|
|
|
254 |
|
|
|
255 |
|
|
/* Get the name of a node. |
256 |
|
|
`node' specifies a node connection object. |
257 |
|
|
The return value is the name of the node. On error, `NULL' is returned. The life duration |
258 |
|
|
of the returned string is synchronous with the one of the node object. */ |
259 |
|
|
const char *est_node_name(ESTNODE *node); |
260 |
|
|
|
261 |
|
|
|
262 |
|
|
/* Get the label of a node. |
263 |
|
|
`node' specifies a node connection object. |
264 |
|
|
The return value is the label of the node. On error, `NULL' is returned. The life duration |
265 |
|
|
of the returned string is synchronous with the one of the node object. */ |
266 |
|
|
const char *est_node_label(ESTNODE *node); |
267 |
|
|
|
268 |
|
|
|
269 |
|
|
/* Get the number of documents in a node. |
270 |
|
|
`node' specifies a node connection object. |
271 |
|
|
The return value is the number of documents in the node. On error, -1 is returned. */ |
272 |
|
|
int est_node_doc_num(ESTNODE *node); |
273 |
|
|
|
274 |
|
|
|
275 |
|
|
/* Get the number of unique words in a node. |
276 |
|
|
`node' specifies a node connection object. |
277 |
|
|
The return value is the number of unique words in the node. On error, -1 is returned. */ |
278 |
|
|
int est_node_word_num(ESTNODE *node); |
279 |
|
|
|
280 |
|
|
|
281 |
|
|
/* Get the size of the datbase of a node. |
282 |
|
|
`node' specifies a node connection object. |
283 |
|
|
The return value is the size of the datbase of the node. On error, -1.0 is returned. */ |
284 |
|
|
double est_node_size(ESTNODE *node); |
285 |
|
|
|
286 |
|
|
|
287 |
|
|
/* Search documents corresponding a condition for a node. |
288 |
|
|
`node' specifies a node connection object. |
289 |
|
|
`cond' specifies a condition object. |
290 |
|
|
`depth' specifies the depth of meta search. |
291 |
|
|
The return value is a node result object. It should be deleted with `est_noderes_delete' if |
292 |
|
|
it is no longer in use. On error, `NULL' is returned. */ |
293 |
|
|
ESTNODERES *est_node_search(ESTNODE *node, ESTCOND *cond, int depth); |
294 |
|
|
|
295 |
|
|
|
296 |
|
|
/* Manage a user account of a node. |
297 |
|
|
`node' specifies a node connection object. |
298 |
|
|
`name' specifies the name of a user. |
299 |
|
|
`mode' specifies the operation mode. 0 means to delete the account. 1 means to set the |
300 |
|
|
account as an administrator. 2 means to set the account as a normal user. |
301 |
|
|
The return value is true if success, else it is false. */ |
302 |
|
|
int est_node_set_user(ESTNODE *node, const char *name, int mode); |
303 |
|
|
|
304 |
|
|
|
305 |
|
|
/* Manage a link of a node. |
306 |
|
|
`node' specifies a node connection object. |
307 |
|
|
`url' specifies the URL of the target node of a link. |
308 |
|
|
`label' specifies the label of the link. |
309 |
|
|
`credit' specifies the credit of the link. If it is negative, the link is removed. |
310 |
|
|
The return value is true if success, else it is false. */ |
311 |
|
|
int est_node_set_link(ESTNODE *node, const char *url, const char *label, int credit); |
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
/************************************************************************************************* |
316 |
|
|
* features for experts |
317 |
|
|
*************************************************************************************************/ |
318 |
|
|
|
319 |
|
|
|
320 |
|
|
#define ESTAGENTNAME "HyperEstraier" /* name of the user agent */ |
321 |
|
|
#define ESTFORMTYPE "application/x-www-form-urlencoded" /* media type of docuemnt draft */ |
322 |
|
|
#define ESTINFORMTYPE "text/x-estraier-nodeinfo" /* media type of node information */ |
323 |
|
|
#define ESTRESULTTYPE "text/x-estraier-result" /* media type of search result */ |
324 |
|
|
#define ESTDRAFTTYPE "text/x-estraier-draft" /* media type of docuemnt draft */ |
325 |
|
|
#define ESTHTHVIA "X-Estraier-Via" /* header to escape from looping route */ |
326 |
|
|
|
327 |
|
|
|
328 |
|
|
/* Get the name of this host. |
329 |
|
|
The return value is the name of this host. */ |
330 |
|
|
const char *est_get_host_name(void); |
331 |
|
|
|
332 |
|
|
|
333 |
|
|
/* Get the address of a host. |
334 |
|
|
`name' specifies the name of a host. |
335 |
|
|
The return value is the address of a host or `NULL' if failure. Because the region of the |
336 |
|
|
return value is allocated with the `malloc' call, it should be released with the `free' call |
337 |
|
|
if it is no longer in use. */ |
338 |
|
|
char *est_get_host_addr(const char *name); |
339 |
|
|
|
340 |
|
|
|
341 |
|
|
/* Get a server socket of an address and a port. |
342 |
|
|
`addr' specifies an address of a host. If it is `NULL', every network address is binded. |
343 |
|
|
`port' specifies a port number. |
344 |
|
|
The return value is the socket of the address and the port or -1 if failure. */ |
345 |
|
|
int est_get_server_sock(const char *addr, int port); |
346 |
|
|
|
347 |
|
|
|
348 |
|
|
/* Accept a connection from a client. |
349 |
|
|
`sock' specifies a server socket. |
350 |
|
|
`abuf' specifies a buffer into which the address of a connected client is written. The size of |
351 |
|
|
the buffer should be more than 32. If it is `NULL', it is ignored. |
352 |
|
|
`pp' specifies the pointer to a variable to which the port of the client is assigned. If it |
353 |
|
|
is `NULL', it is ignored. |
354 |
|
|
The return value is a socket connected to the client, or 0 if intterupted, or -1 if failure. |
355 |
|
|
The thread blocks until the connection is established. */ |
356 |
|
|
int est_accept_conn(int sock, char *abuf, int *pp); |
357 |
|
|
|
358 |
|
|
|
359 |
|
|
/* Get a client socket to an address and a port. |
360 |
|
|
`addr' specifies an address of a host. |
361 |
|
|
`port' specifies a port number. |
362 |
|
|
The return value is the socket to the address and the port or -1 if failure. */ |
363 |
|
|
int est_get_client_sock(const char *addr, int port); |
364 |
|
|
|
365 |
|
|
|
366 |
|
|
/* Shutdown and close a socket. |
367 |
|
|
`sock' specifies a socket. */ |
368 |
|
|
void est_sock_down(int sock); |
369 |
|
|
|
370 |
|
|
|
371 |
|
|
/* Receive all data from a socket. |
372 |
|
|
`sock' specifies a socket. |
373 |
|
|
`len' specifies the length of data to be read. |
374 |
|
|
The return value is the pointer to the region of an allocated region containing the received |
375 |
|
|
data. |
376 |
|
|
Because an additional zero code is appended at the end of the region of the return value, the |
377 |
|
|
return value can be treated as a character string. Because the region of the return value is |
378 |
|
|
allocated with the `malloc' call, it should be released with the `free' call if it is no |
379 |
|
|
longer in use. */ |
380 |
|
|
char *est_sock_recv_all(int sock, int len); |
381 |
|
|
|
382 |
|
|
|
383 |
|
|
/* Receive a line from a socket. |
384 |
|
|
`sock' specifies a socket. |
385 |
|
|
`buf' specifies a buffer to store read data. |
386 |
|
|
`max' specifies the maximum length to read. It should be more than 0. |
387 |
|
|
The return value is the size of received data. |
388 |
|
|
Because an additional zero code is appended at the end of the region of the buffer, it can be |
389 |
|
|
treated as a character string. */ |
390 |
|
|
int est_sock_recv_line(int sock, char *buf, int max); |
391 |
|
|
|
392 |
|
|
|
393 |
|
|
/* Receive void data from a socket. |
394 |
|
|
`sock' specifies a socket. */ |
395 |
|
|
void est_sock_recv_void(int sock); |
396 |
|
|
|
397 |
|
|
|
398 |
|
|
/* Send all data into a socket. |
399 |
|
|
`sock' specifies a socket. |
400 |
|
|
`buf' specifies a buffer of data to write. |
401 |
|
|
`len' specifies the length of the data. */ |
402 |
|
|
void est_sock_send_all(int sock, const char *buf, int len); |
403 |
|
|
|
404 |
|
|
|
405 |
|
|
/* Perform formatted output into a datum object. |
406 |
|
|
`format' specifies a printf-like format string. |
407 |
|
|
The conversion character `%' can be used with such flag characters as `s', `d', `o', `u', |
408 |
|
|
`x', `X', `c', `e', `E', `f', `g', `G', `@', `?', `%'. `@' works as with `s' but escapes |
409 |
|
|
meta characters of XML. `?' works as with `s' but escapes meta characters of URL. The other |
410 |
|
|
conversion character work as with each original. */ |
411 |
|
|
void est_datum_printf(CBDATUM *datum, const char *format, ...); |
412 |
|
|
|
413 |
|
|
|
414 |
|
|
/* Perform an interaction of a URL. |
415 |
|
|
`url' specifies a URL. |
416 |
|
|
`pxhost' specifies the host name of a proxy. If it is `NULL', it is not used. |
417 |
|
|
`pxport' specifies the port number of the proxy. |
418 |
|
|
`outsec' specifies timeout in seconds. If it is negative, it is not used. |
419 |
|
|
`auth' specifies an authority information in such form as "user:pass". If it is `NULL', it is |
420 |
|
|
not used. |
421 |
|
|
`reqheads' specifies a list object of extension headers. If it is `NULL' it is ignored. |
422 |
|
|
`reqbody' specifies the pointer of the entitiy body of request. If it is `NULL', "GET" |
423 |
|
|
method is used. |
424 |
|
|
`rbsiz' specifies the size of the entity body. |
425 |
|
|
`rescodep' specifies the pointer to a variable to which the status code of respnese is |
426 |
|
|
assigned. If it is `NULL', it is not used. |
427 |
|
|
`resheads' specifies a map object into which headers of response is stored. The value of each |
428 |
|
|
header is recorded as an attribute whose name is converted from the header name into lower |
429 |
|
|
cases. The top header for the status code is recorded with the key of an empty string. If it |
430 |
|
|
is `NULL', it is not used. |
431 |
|
|
`reqbody' specifies a datum object into which the entity body of response is stored. If it is |
432 |
|
|
`NULL', it is not used. |
433 |
|
|
The return value is true if success, else it is false. |
434 |
|
|
Headers of "Host", "Connection", "User-Agent", "Authorization", and "Content-Length" are sent |
435 |
|
|
implicitly. */ |
436 |
|
|
int est_url_shuttle(const char *url, const char *pxhost, int pxport, int outsec, |
437 |
|
|
const char *auth, const CBLIST *reqheads, const char *reqbody, int rbsiz, |
438 |
|
|
int *rescodep, CBMAP *resheads, CBDATUM *resbody); |
439 |
|
|
|
440 |
|
|
|
441 |
|
|
/* Add a header to a node connection object. |
442 |
|
|
`node' specifies a node connection object. |
443 |
|
|
`name' specifies the name of a header. |
444 |
|
|
`value' specifies the value of the header. If it is `NULL', the header is removed. |
445 |
|
|
If the specified header is already added, the value is concatenated at the end. */ |
446 |
|
|
void est_node_add_header(ESTNODE *node, const char *name, const char *value); |
447 |
|
|
|
448 |
|
|
|
449 |
|
|
/* Create a node result object. |
450 |
|
|
The return value is a node result object. */ |
451 |
|
|
ESTNODERES *est_noderes_new(void); |
452 |
|
|
|
453 |
|
|
|
454 |
|
|
/* Add a document information to a node result object. |
455 |
|
|
`nres' specifies a node result object. |
456 |
|
|
`attrs' specifies a map object of attributes of the document. The object is closed internally. |
457 |
|
|
`snippet' specifies the snippet of the document. The region is released internally. */ |
458 |
|
|
void est_noderes_add_doc(ESTNODERES *nres, CBMAP *attrs, char *snippet); |
459 |
|
|
|
460 |
|
|
|
461 |
|
|
/* Remove the top of result document objects in a node result object. |
462 |
|
|
`nres' specifies a node result object. |
463 |
|
|
`attrp' specifies the pointer to a variable to which reference of the map object of attribute |
464 |
|
|
is assigned. The object should be deleted with the function `cbmapclose'. |
465 |
|
|
`snippetp' specifies the pointer to a variable to which reference of the snippet string is |
466 |
|
|
assigned. The region should be released with the function `free'. |
467 |
|
|
The return value is true if success, else it is false. */ |
468 |
|
|
int est_noderes_shift(ESTNODERES *nres, CBMAP **attrp, char **snippetp); |
469 |
|
|
|
470 |
|
|
|
471 |
|
|
|
472 |
|
|
#if defined(__cplusplus) /* export for C++ */ |
473 |
|
|
} |
474 |
|
|
#endif |
475 |
|
|
|
476 |
|
|
#endif /* duplication check */ |
477 |
|
|
|
478 |
|
|
|
479 |
|
|
/* END OF FILE */ |