/[hyperestraier]/upstream/0.5.3/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

Contents of /upstream/0.5.3/example/nodeexample002.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations)
Wed Aug 3 15:25:48 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1584 byte(s)
import of upstream 0.5.3

1 #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 connection 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 printf("%s", est_resdoc_snippet(rdoc));
39 }
40 /* delete the node result object */
41 est_noderes_delete(nres);
42 } else {
43 fprintf(stderr, "error: %d\n", est_node_status(node));
44 }
45 /* destroy the search condition object */
46 est_cond_delete(cond);
47 /* destroy the node object */
48 est_node_delete(node);
49 /* free the networking environment */
50 est_free_net_env();
51 return 0;
52 }

  ViewVC Help
Powered by ViewVC 1.1.26