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 |
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://estraie.gov/example001.c"); |
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 |
} |