/[hyperestraier]/upstream/0.5.2/example/nodeexample002.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /upstream/0.5.2/example/nodeexample002.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (hide annotations)
Wed Aug 3 15:21:15 2005 UTC (18 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 1604 byte(s)
import upstream version 0.5.2

1 dpavlin 9 #include <estraier.h>
2     #include <estnode.h>
3     #include <cabin.h>
4     #include <stdlib.h>
5     #include <stdio.h>
6    
7     int main(int argc, char **argv){
8     ESTNODE *node;
9     ESTCOND *cond;
10     ESTNODERES *nres;
11     ESTRESDOC *rdoc;
12     int i;
13     const char *value;
14     /* initialize the network environment */
15     if(!est_init_net_env()){
16     fprintf(stderr, "error: network is unavailable\n");
17     return 1;
18     }
19     /* create the node connecton object */
20     node = est_node_new("http://localhost:1978/node/test1");
21     /* create a search condition object */
22     cond = est_cond_new();
23     /* set the search phrase to the search condition object */
24     est_cond_set_phrase(cond, "rainbow AND lullaby");
25     /* get the result of search */
26     nres = est_node_search(node, cond, 0);
27     if(nres){
28     /* for each document in the result */
29     for(i = 0; i < est_noderes_doc_num(nres); i++){
30     /* get a result document object */
31     rdoc = est_noderes_get_doc(nres, i);
32     /* display attributes */
33     if((value = est_resdoc_attr(rdoc, "@uri")) != NULL)
34     printf("URI: %s\n", value);
35     if((value = est_resdoc_attr(rdoc, "@title")) != NULL)
36     printf("Title: %s\n", value);
37     /* display the snippet text */
38     value = est_resdoc_snippet(rdoc);
39     printf("%s", value);
40     }
41     /* delete the node result object */
42     est_noderes_delete(nres);
43     } else {
44     fprintf(stderr, "error: %d\n", est_node_status(node));
45     }
46     /* destroy the search condition object */
47     est_cond_delete(cond);
48     /* destroy the node object */
49     est_node_delete(node);
50     /* free the networking environment */
51     est_free_net_env();
52     return 0;
53     }

  ViewVC Help
Powered by ViewVC 1.1.26