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 |
ESTDOC *doc; |
10 |
/* initialize the network environment */ |
11 |
if(!est_init_net_env()){ |
12 |
fprintf(stderr, "error: network is unavailable\n"); |
13 |
return 1; |
14 |
} |
15 |
/* create and configure the node connection object */ |
16 |
node = est_node_new("http://localhost:1978/node/test1"); |
17 |
est_node_set_auth(node, "admin", "admin"); |
18 |
/* create a document object */ |
19 |
doc = est_doc_new(); |
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 |
/* add the body text to the document object */ |
24 |
est_doc_add_text(doc, "Somewhere over the rainbow. Way up high."); |
25 |
est_doc_add_text(doc, "There's a land that I heard of once in a lullaby."); |
26 |
/* register the document object to the node */ |
27 |
if(!est_node_put_doc(node, doc)) |
28 |
fprintf(stderr, "error: %d\n", est_node_status(node)); |
29 |
/* destroy the document object */ |
30 |
est_doc_delete(doc); |
31 |
/* destroy the node object */ |
32 |
est_node_delete(node); |
33 |
/* free the networking environment */ |
34 |
est_free_net_env(); |
35 |
return 0; |
36 |
} |