/[hyperestraier]/upstream/0.5.2/example/coreexample001.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/coreexample001.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: 1126 byte(s)
import upstream version 0.5.2

1 dpavlin 9 #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     ESTDOC *doc;
9     int ecode;
10    
11     /* open the database */
12     if(!(db = est_db_open("casket", ESTDBWRITER | ESTDBCREAT, &ecode))){
13     fprintf(stderr, "error: %s\n", est_err_msg(ecode));
14     return 1;
15     }
16    
17     /* create a document object */
18     doc = est_doc_new();
19    
20     /* add attributes to the document object */
21     est_doc_add_attr(doc, "@uri", "http://estraier.gov/example.txt");
22     est_doc_add_attr(doc, "@title", "Over the Rainbow");
23    
24     /* add the body text to the document object */
25     est_doc_add_text(doc, "Somewhere over the rainbow. Way up high.");
26     est_doc_add_text(doc, "There's a land that I heard of once in a lullaby.");
27    
28     /* register the document object to the database */
29     if(!est_db_put_doc(db, doc, ESTPDCLEAN))
30     fprintf(stderr, "error: %s\n", est_err_msg(est_db_error(db)));
31    
32     /* destroy the document object */
33     est_doc_delete(doc);
34    
35     /* close the database */
36     if(!est_db_close(db, &ecode)){
37     fprintf(stderr, "error: %s\n", est_err_msg(ecode));
38     return 1;
39     }
40    
41     return 0;
42     }

  ViewVC Help
Powered by ViewVC 1.1.26