aboutsummaryrefslogtreecommitdiff
path: root/src/sq
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-27 01:18:50 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-27 01:18:50 +0100
commit3112e64ef06f71b06e9f047f2c6dd1be0941a565 (patch)
treec5eed6bcdbb0c24d72466c6f052bece931307cc6 /src/sq
parentbefd2f9fc787c2ac75790b06e1601f2f65305375 (diff)
downloadgnunet-3112e64ef06f71b06e9f047f2c6dd1be0941a565.tar.gz
gnunet-3112e64ef06f71b06e9f047f2c6dd1be0941a565.zip
skeleton for libgnunetsq implementation
Diffstat (limited to 'src/sq')
-rw-r--r--src/sq/Makefile.am40
-rw-r--r--src/sq/sq.c68
-rw-r--r--src/sq/sq_query_helper.c129
-rw-r--r--src/sq/sq_result_helper.c164
4 files changed, 401 insertions, 0 deletions
diff --git a/src/sq/Makefile.am b/src/sq/Makefile.am
new file mode 100644
index 000000000..7197e7ab4
--- /dev/null
+++ b/src/sq/Makefile.am
@@ -0,0 +1,40 @@
1# This Makefile.am is in the public domain
2AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS)
3
4if MINGW
5 WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
6endif
7
8if USE_COVERAGE
9 AM_CFLAGS = --coverage
10endif
11
12if HAVE_POSTGRESQL
13lib_LTLIBRARIES = libgnunetsq.la
14endif
15
16libgnunetsq_la_SOURCES = \
17 sq.c \
18 sq_query_helper.c \
19 sq_result_helper.c
20libgnunetsq_la_LIBADD = -lsq \
21 $(top_builddir)/src/util/libgnunetutil.la
22libgnunetsq_la_LDFLAGS = \
23 $(POSTGRESQL_LDFLAGS) \
24 $(GN_LIB_LDFLAGS) \
25 -version-info 0:0:0
26
27if ENABLE_TEST_RUN
28TESTS = \
29 test_sq
30endif
31
32check_PROGRAMS= \
33 test_sq
34
35test_sq_SOURCES = \
36 test_sq.c
37test_sq_LDADD = \
38 libgnunetsq.la \
39 $(top_builddir)/src/util/libgnunetutil.la \
40 -lsqlite3 $(XLIB)
diff --git a/src/sq/sq.c b/src/sq/sq.c
new file mode 100644
index 000000000..524014b0f
--- /dev/null
+++ b/src/sq/sq.c
@@ -0,0 +1,68 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2017 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/
16/**
17 * @file sq/sq.c
18 * @brief helper functions for Sqlite3 DB interactions
19 * @author Christian Grothoff
20 */
21#include "platform.h"
22#include "gnunet_sq_lib.h"
23
24
25/**
26 * Execute a prepared statement.
27 *
28 * @param db_conn database connection
29 * @param params parameters to the statement
30 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
31 */
32int
33GNUNET_SQ_bind (sqlite3_stmt *stmt,
34 const struct GNUNET_SQ_QueryParam *params)
35{
36}
37
38
39/**
40 * Extract results from a query result according to the given specification.
41 *
42 * @param result result to process
43 * @param[in,out] rs result specification to extract for
44 * @param row row from the result to extract
45 * @return
46 * #GNUNET_YES if all results could be extracted
47 * #GNUNET_SYSERR if a result was invalid (non-existing field)
48 */
49int
50GNUNET_SQ_extract_result (sqlite3_stmt *result,
51 struct GNUNET_SQ_ResultSpec *rs,
52 int row)
53{
54}
55
56
57/**
58 * Free all memory that was allocated in @a rs during
59 * #GNUNET_SQ_extract_result().
60 *
61 * @param rs reult specification to clean up
62 */
63void
64GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs)
65{
66}
67
68/* end of sq.c */
diff --git a/src/sq/sq_query_helper.c b/src/sq/sq_query_helper.c
new file mode 100644
index 000000000..613a0c746
--- /dev/null
+++ b/src/sq/sq_query_helper.c
@@ -0,0 +1,129 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2017 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/
16/**
17 * @file sq/sq_query_helper.c
18 * @brief helper functions for queries
19 * @author Christian Grothoff
20 */
21#include "gnunet_sq_lib.h"
22
23
24/**
25 * Generate query parameter for a buffer @a ptr of
26 * @a ptr_size bytes.
27 *
28 * @param ptr pointer to the query parameter to pass
29 * @oaran ptr_size number of bytes in @a ptr
30 */
31struct GNUNET_SQ_QueryParam
32GNUNET_SQ_query_param_fixed_size (const void *ptr,
33 size_t ptr_size)
34{
35}
36
37
38/**
39 * Generate query parameter for a string.
40 *
41 * @param ptr pointer to the string query parameter to pass
42 */
43struct GNUNET_SQ_QueryParam
44GNUNET_SQ_query_param_string (const char *ptr)
45{
46}
47
48
49/**
50 * Generate query parameter for an RSA public key. The
51 * database must contain a BLOB type in the respective position.
52 *
53 * @param x the query parameter to pass.
54 */
55struct GNUNET_SQ_QueryParam
56GNUNET_SQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x)
57{
58}
59
60
61/**
62 * Generate query parameter for an RSA signature. The
63 * database must contain a BLOB type in the respective position.
64 *
65 * @param x the query parameter to pass
66 */
67struct GNUNET_SQ_QueryParam
68GNUNET_SQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x)
69{
70}
71
72
73/**
74 * Generate query parameter for an absolute time value.
75 * The database must store a 64-bit integer.
76 *
77 * @param x pointer to the query parameter to pass
78 */
79struct GNUNET_SQ_QueryParam
80GNUNET_SQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x)
81{
82}
83
84
85/**
86 * Generate query parameter for an absolute time value.
87 * The database must store a 64-bit integer.
88 *
89 * @param x pointer to the query parameter to pass
90 */
91struct GNUNET_SQ_QueryParam
92GNUNET_SQ_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x)
93{
94}
95
96
97/**
98 * Generate query parameter for an uint16_t in host byte order.
99 *
100 * @param x pointer to the query parameter to pass
101 */
102struct GNUNET_SQ_QueryParam
103GNUNET_SQ_query_param_uint16 (const uint16_t *x)
104{
105}
106
107
108/**
109 * Generate query parameter for an uint32_t in host byte order.
110 *
111 * @param x pointer to the query parameter to pass
112 */
113struct GNUNET_SQ_QueryParam
114GNUNET_SQ_query_param_uint32 (const uint32_t *x)
115{
116}
117
118
119/**
120 * Generate query parameter for an uint16_t in host byte order.
121 *
122 * @param x pointer to the query parameter to pass
123 */
124struct GNUNET_SQ_QueryParam
125GNUNET_SQ_query_param_uint64 (const uint64_t *x)
126{
127}
128
129/* end of sq_query_helper.c */
diff --git a/src/sq/sq_result_helper.c b/src/sq/sq_result_helper.c
new file mode 100644
index 000000000..361fea7bf
--- /dev/null
+++ b/src/sq/sq_result_helper.c
@@ -0,0 +1,164 @@
1
2/*
3 This file is part of GNUnet
4 Copyright (C) 2017 GNUnet e.V.
5
6 GNUnet is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 3, or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
16*/
17/**
18 * @file sq/sq_result_helper.c
19 * @brief helper functions for queries
20 * @author Christian Grothoff
21 */
22#include "platform.h"
23#include "gnunet_sq_lib.h"
24
25
26/**
27 * Variable-size result expected.
28 *
29 * @param[out] dst where to store the result, allocated
30 * @param[out] sptr where to store the size of @a dst
31 * @return array entry for the result specification to use
32 */
33struct GNUNET_SQ_ResultSpec
34GNUNET_SQ_result_spec_variable_size (void **dst,
35 size_t *sptr)
36{
37}
38
39
40/**
41 * Fixed-size result expected.
42 *
43 * @param[out] dst where to store the result
44 * @param dst_size number of bytes in @a dst
45 * @return array entry for the result specification to use
46 */
47struct GNUNET_SQ_ResultSpec
48GNUNET_SQ_result_spec_fixed_size (void *dst,
49 size_t dst_size)
50{
51}
52
53
54/**
55 * Variable-size result expected.
56 *
57 * @param[out] dst where to store the result, allocated
58 * @param[out] sptr where to store the size of @a dst
59 * @return array entry for the result specification to use
60 */
61struct GNUNET_SQ_ResultSpec
62GNUNET_SQ_result_spec_variable_size (void **dst,
63 size_t *sptr)
64{
65}
66
67
68/**
69 * 0-terminated string expected.
70 *
71 * @param[out] dst where to store the result, allocated
72 * @return array entry for the result specification to use
73 */
74struct GNUNET_SQ_ResultSpec
75GNUNET_SQ_result_spec_string (char **dst)
76{
77}
78
79
80/**
81 * RSA public key expected.
82 *
83 * @param[out] rsa where to store the result
84 * @return array entry for the result specification to use
85 */
86struct GNUNET_SQ_ResultSpec
87GNUNET_SQ_result_spec_rsa_public_key (struct GNUNET_CRYPTO_RsaPublicKey **rsa)
88{
89}
90
91
92/**
93 * RSA signature expected.
94 *
95 * @param[out] sig where to store the result;
96 * @return array entry for the result specification to use
97 */
98struct GNUNET_SQ_ResultSpec
99GNUNET_SQ_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig)
100{
101}
102
103
104/**
105 * Absolute time expected.
106 *
107 * @param[out] at where to store the result
108 * @return array entry for the result specification to use
109 */
110struct GNUNET_SQ_ResultSpec
111GNUNET_SQ_result_spec_absolute_time (struct GNUNET_TIME_Absolute *at)
112{
113}
114
115
116/**
117 * Absolute time expected.
118 *
119 * @param[out] at where to store the result
120 * @return array entry for the result specification to use
121 */
122struct GNUNET_SQ_ResultSpec
123GNUNET_SQ_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at)
124{
125}
126
127
128/**
129 * uint16_t expected.
130 *
131 * @param[out] u16 where to store the result
132 * @return array entry for the result specification to use
133 */
134struct GNUNET_SQ_ResultSpec
135GNUNET_SQ_result_spec_uint16 (uint16_t *u16)
136{
137}
138
139
140/**
141 * uint32_t expected.
142 *
143 * @param[out] u32 where to store the result
144 * @return array entry for the result specification to use
145 */
146struct GNUNET_SQ_ResultSpec
147GNUNET_SQ_result_spec_uint32 (uint32_t *u32)
148{
149}
150
151
152/**
153 * uint64_t expected.
154 *
155 * @param[out] u64 where to store the result
156 * @return array entry for the result specification to use
157 */
158struct GNUNET_SQ_ResultSpec
159GNUNET_SQ_result_spec_uint64 (uint64_t *u64)
160{
161}
162
163
164/* end of sq_result_helper.c */