diff options
author | Safey A.Halim <safey.allah@gmail.com> | 2010-11-22 20:48:49 +0000 |
---|---|---|
committer | Safey A.Halim <safey.allah@gmail.com> | 2010-11-22 20:48:49 +0000 |
commit | 7e15c040dabbee86294d521c8966e2f6aedbcf2f (patch) | |
tree | 98f093b6a08031c7b995d976f42f2305d2803abd /src/monkey | |
parent | 53fb6a2228fc0189680851745c8a810a6442da97 (diff) | |
download | gnunet-7e15c040dabbee86294d521c8966e2f6aedbcf2f.tar.gz gnunet-7e15c040dabbee86294d521c8966e2f6aedbcf2f.zip |
Monkey Expression Database API
Diffstat (limited to 'src/monkey')
-rw-r--r-- | src/monkey/Makefile.am | 3 | ||||
-rw-r--r-- | src/monkey/edb_api.c | 96 |
2 files changed, 98 insertions, 1 deletions
diff --git a/src/monkey/Makefile.am b/src/monkey/Makefile.am index 04f951635..39e5f8d5d 100644 --- a/src/monkey/Makefile.am +++ b/src/monkey/Makefile.am | |||
@@ -39,7 +39,8 @@ gnunet_monkey_SOURCES = \ | |||
39 | gdbmi_thread.c \ | 39 | gdbmi_thread.c \ |
40 | gdbmi_var_obj.c \ | 40 | gdbmi_var_obj.c \ |
41 | gnunet-monkey.c \ | 41 | gnunet-monkey.c \ |
42 | mail_sender.c | 42 | mail_sender.c \ |
43 | edb_api.c | ||
43 | 44 | ||
44 | gnunet_monkey_LDADD = \ | 45 | gnunet_monkey_LDADD = \ |
45 | $(top_builddir)/src/util/libgnunetutil.la \ | 46 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/monkey/edb_api.c b/src/monkey/edb_api.c new file mode 100644 index 000000000..32fc0bc41 --- /dev/null +++ b/src/monkey/edb_api.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file monkey/edb_api.c | ||
23 | * @brief Monkey API for accessing the Expression Database (edb) | ||
24 | */ | ||
25 | |||
26 | #include "platform.h" | ||
27 | #include "gnunet_common.h" | ||
28 | #include "gnunet_monkey_edb.h" | ||
29 | #include <sqlite3.h> | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Context for Database connection and Expressions | ||
34 | */ | ||
35 | struct GNUNET_MONKEY_EDB_Context | ||
36 | { | ||
37 | /** | ||
38 | * Database connection | ||
39 | */ | ||
40 | sqlite3 *db_handle; | ||
41 | }; | ||
42 | |||
43 | |||
44 | /** | ||
45 | * Establish a connection to the Expression Database | ||
46 | * | ||
47 | * @param db_file_name path the Expression Database file | ||
48 | * @return context to use for Accessing the Expression Database, NULL on error | ||
49 | */ | ||
50 | struct GNUNET_MONKEY_EDB_Context * | ||
51 | GNUNET_MONKEY_EDB_connect (const char *db_file_name) | ||
52 | { | ||
53 | /* TODO: Implementation */ | ||
54 | return NULL; | ||
55 | } | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Disconnect from Database, and cleanup resources | ||
60 | * | ||
61 | * @param cfg configuration to use (used to know the path of the .db file). | ||
62 | * @param service service that *this* process is implementing/providing, can be NULL | ||
63 | * @return GNUNET_OK on success, GNUNET_NO on failure | ||
64 | */ | ||
65 | int | ||
66 | GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *context) | ||
67 | { | ||
68 | /* TODO: Implementation */ | ||
69 | return GNUNET_OK; | ||
70 | } | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Update the context with a list of expressions. | ||
75 | * The list is the initializations of sub-expressions | ||
76 | * of the expression pointed to by start_line_no and end_line_no | ||
77 | * | ||
78 | * @param context the returned expessions will be available in it. | ||
79 | * expression_list_head, and expression_list_tail must be null, | ||
80 | * otherwise GNUNET_NO will be returned | ||
81 | * @param file_name path to the file in which the expression in question exists | ||
82 | * @param start_line_no expression beginning line | ||
83 | * @param end_line_no expression end line | ||
84 | * @param iter callback function, iterator for expressions returned from the Database | ||
85 | * @param iter_cls closure for the expression iterator | ||
86 | * @return GNUNET_OK success, GNUNET_NO failure | ||
87 | */ | ||
88 | int | ||
89 | GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *context, | ||
90 | const char *file_name, int start_line_no, | ||
91 | int end_line_no, | ||
92 | GNUNET_MONKEY_ExpressionIterator iter, void *iter_cls) | ||
93 | { | ||
94 | /* TODO: Implementation */ | ||
95 | return GNUNET_OK; | ||
96 | } | ||