aboutsummaryrefslogtreecommitdiff
path: root/src/sq/sq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sq/sq.c')
-rw-r--r--src/sq/sq.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/sq/sq.c b/src/sq/sq.c
index 524014b0f..74ab7beb5 100644
--- a/src/sq/sq.c
+++ b/src/sq/sq.c
@@ -33,6 +33,28 @@ int
33GNUNET_SQ_bind (sqlite3_stmt *stmt, 33GNUNET_SQ_bind (sqlite3_stmt *stmt,
34 const struct GNUNET_SQ_QueryParam *params) 34 const struct GNUNET_SQ_QueryParam *params)
35{ 35{
36 unsigned int j;
37
38 j = 1;
39 for (unsigned int i=0;NULL != params[i].conv; i++)
40 {
41 if (GNUNET_OK !=
42 params[i].conv (params[i].conv_cls,
43 params[i].data,
44 params[i].size,
45 stmt,
46 j))
47 {
48 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
49 "sq",
50 _("Failure to bind %u-th SQL parameter\n"),
51 i);
52 return GNUNET_SYSERR;
53 }
54 GNUNET_assert (0 != params[i].num_params);
55 j += params[i].num_params;
56 }
57 return GNUNET_OK;
36} 58}
37 59
38 60
@@ -43,7 +65,7 @@ GNUNET_SQ_bind (sqlite3_stmt *stmt,
43 * @param[in,out] rs result specification to extract for 65 * @param[in,out] rs result specification to extract for
44 * @param row row from the result to extract 66 * @param row row from the result to extract
45 * @return 67 * @return
46 * #GNUNET_YES if all results could be extracted 68 * #GNUNET_OK if all results could be extracted
47 * #GNUNET_SYSERR if a result was invalid (non-existing field) 69 * #GNUNET_SYSERR if a result was invalid (non-existing field)
48 */ 70 */
49int 71int
@@ -51,6 +73,22 @@ GNUNET_SQ_extract_result (sqlite3_stmt *result,
51 struct GNUNET_SQ_ResultSpec *rs, 73 struct GNUNET_SQ_ResultSpec *rs,
52 int row) 74 int row)
53{ 75{
76 unsigned int j = 0;
77
78 for (unsigned int i=0;NULL != rs[i].conv; i++)
79 {
80 if (GNUNET_OK !=
81 rs[i].conv (rs[i].cls,
82 result,
83 row,
84 j,
85 rs[i].result_size,
86 rs[i].dst))
87 return GNUNET_SYSERR;
88 GNUNET_assert (0 != rs[i].num_params);
89 j += rs[i].num_params;
90 }
91 return GNUNET_OK;
54} 92}
55 93
56 94
@@ -63,6 +101,9 @@ GNUNET_SQ_extract_result (sqlite3_stmt *result,
63void 101void
64GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs) 102GNUNET_SQ_cleanup_result (struct GNUNET_SQ_ResultSpec *rs)
65{ 103{
104 for (unsigned int i=0;NULL != rs[i].conv; i++)
105 if (NULL != rs[i].cleaner)
106 rs[i].cleaner (rs[i].cls);
66} 107}
67 108
68/* end of sq.c */ 109/* end of sq.c */