From 8b3286e953a80cf069271957ec817485ebe5b14e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 27 Feb 2017 02:08:21 +0100 Subject: implement sq_query_helper.c --- src/include/gnunet_pq_lib.h | 14 -------------- src/include/gnunet_sq_lib.h | 23 +++++++++++++++++------ 2 files changed, 17 insertions(+), 20 deletions(-) (limited to 'src/include') diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index e8180f286..756370b74 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h @@ -316,20 +316,6 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, #define GNUNET_PQ_result_spec_auto_from_type(name, dst) GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof (*(dst))) -/** - * Variable-size result expected. - * - * @param name name of the field in the table - * @param[out] dst where to store the result, allocated - * @param[out] sptr where to store the size of @a dst - * @return array entry for the result specification to use - */ -struct GNUNET_PQ_ResultSpec -GNUNET_PQ_result_spec_variable_size (const char *name, - void **dst, - size_t *sptr); - - /** * 0-terminated string expected. * diff --git a/src/include/gnunet_sq_lib.h b/src/include/gnunet_sq_lib.h index a068650ac..1606d1129 100644 --- a/src/include/gnunet_sq_lib.h +++ b/src/include/gnunet_sq_lib.h @@ -21,7 +21,7 @@ #ifndef GNUNET_SQ_LIB_H #define GNUNET_SQ_LIB_H -#include +#include #include "gnunet_util_lib.h" @@ -186,7 +186,8 @@ GNUNET_SQ_query_param_uint64 (const uint64_t *x); * * @param cls closure * @param result where to extract data from - * @param int row to extract data from + * @param row row to extract data from + * @param column column to extract data from * @param[in,out] dst_size where to store size of result, may be NULL * @param[out] dst where to store the result * @return @@ -197,20 +198,25 @@ typedef int (*GNUNET_SQ_ResultConverter)(void *cls, sqlite3_stmt *result, int row, + unsigned int column, size_t *dst_size, void *dst); +/** + * @brief Description of a DB result cell. + */ +struct GNUNET_SQ_ResultSpec; + + /** * Function called to clean up memory allocated * by a #GNUNET_SQ_ResultConverter. * * @param cls closure - * @param rd result data to clean up */ typedef void -(*GNUNET_SQ_ResultCleanup)(void *cls, - void *rd); +(*GNUNET_SQ_ResultCleanup)(void *cls); /** @@ -252,6 +258,11 @@ struct GNUNET_SQ_ResultSpec */ size_t *result_size; + /** + * Number of parameters (columns) eaten by this operation. + */ + unsigned int num_params; + }; @@ -407,7 +418,7 @@ GNUNET_SQ_bind (sqlite3_stmt *stmt, * @param[in,out] rs result specification to extract for * @param row row from the result to extract * @return - * #GNUNET_YES if all results could be extracted + * #GNUNET_OK if all results could be extracted * #GNUNET_SYSERR if a result was invalid (non-existing field) */ int -- cgit v1.2.3