/[hyperestraier]/upstream/0.5.1/example/example002.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.1/example/example002.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Fri Jul 29 21:56:53 2005 UTC (18 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 1566 byte(s)
import of HyperEstraier 0.5.1

1 #include <estraier.h>
2 #include <cabin.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5
6 int main(int argc, char **argv){
7 ESTDB *db;
8 ESTCOND *cond;
9 ESTDOC *doc;
10 const CBLIST *texts;
11 int ecode, *result, resnum, i, j;
12 const char *value;
13
14 /* open the database */
15 if(!(db = est_db_open("casket", ESTDBREADER, &ecode))){
16 fprintf(stderr, "error: %s\n", est_err_msg(ecode));
17 return 1;
18 }
19
20 /* create a search condition object */
21 cond = est_cond_new();
22
23 /* set the search phrase to the search condition object */
24 est_cond_set_phrase(cond, "rainbow AND lullaby");
25
26 /* get the result of search */
27 result = est_db_search(db, cond, &resnum, NULL);
28
29 /* for each document in the result */
30 for(i = 0; i < resnum; i++){
31
32 /* retrieve the document object */
33 if(!(doc = est_db_get_doc(db, result[i], 0))) continue;
34
35 /* display attributes */
36 if((value = est_doc_attr(doc, "@uri")) != NULL)
37 printf("URI: %s\n", value);
38 if((value = est_doc_attr(doc, "@title")) != NULL)
39 printf("Title: %s\n", value);
40
41 /* display the body text */
42 texts = est_doc_texts(doc);
43 for(j = 0; j < cblistnum(texts); j++){
44 value = cblistval(texts, j, NULL);
45 printf("%s\n", value);
46 }
47
48 /* destloy the document object */
49 est_doc_delete(doc);
50
51 }
52
53 /* free the result of search */
54 free(result);
55
56 /* destroy the search condition object */
57 est_cond_delete(cond);
58
59 /* close the database */
60 if(!est_db_close(db, &ecode)){
61 fprintf(stderr, "error: %s\n", est_err_msg(ecode));
62 return 1;
63 }
64
65 return 0;
66 }

  ViewVC Help
Powered by ViewVC 1.1.26