tizen 2.3 release
[kernel/api/system-resource.git] / src / utils / database.c
1 #include <glib.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include "app-stat.h"
6 #include "macro.h"
7 #include "storage.h"
8
9 int main(int argc, char **argv)
10 {
11         struct application_stat requests[] = {
12                 {"emacs", 24, 42},
13                 {"vim", 43, 49},
14                 {"emacs", 52, 56}
15         };/*It's not standards compliant, but more robust */
16
17         int index;
18         struct application_stat_tree *app_tree = create_app_stat_tree();
19
20         init_database("./base.db");
21
22         for (index = 0; index != ARRAY_SIZE(requests); ++index)
23                 g_tree_insert((GTree *) app_tree->tree,
24                         (gpointer)index, (gpointer)(requests + index));
25
26         store_result(app_tree, 0); /*0 time period means alway perform storing*/
27         close_database();
28         free_app_stat_tree(app_tree);
29         return 0;
30 }