aboutsummaryrefslogtreecommitdiff
path: root/src/my
diff options
context:
space:
mode:
authorChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-27 15:34:12 +0000
committerChristophe Genevey Metat <genevey.christophe@gmail.com>2016-06-27 15:34:12 +0000
commit3a4870624812ac4286624d3946981cac6aef4e67 (patch)
tree08b05f2d1354b68a466973c177774479484cae1f /src/my
parent4450e34453501e9449de830d48e1421590181ef7 (diff)
downloadgnunet-3a4870624812ac4286624d3946981cac6aef4e67.tar.gz
gnunet-3a4870624812ac4286624d3946981cac6aef4e67.zip
add function conv param string
Diffstat (limited to 'src/my')
-rw-r--r--src/my/my_query_helper.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index 436860691..17ade5a92 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -89,6 +89,29 @@ GNUNET_MY_query_param_fixed_size (const void *ptr,
89 89
90 90
91/** 91/**
92 * Function called to convert input argument into SQL parameters.
93 *
94 * @param cls closure
95 * @param pq data about the query
96 * @param qbind array of parameters to initialize
97 * @return -1 on error
98 */
99static int
100my_conv_string (void *cls,
101 const struct GNUNET_MY_QueryParam *qp,
102 MYSQL_BIND *qbind)
103{
104 GNUNET_assert (1 == qp->num_params);
105
106 qbind->buffer = (void *) qp->data;
107 qbind->buffer_length = qp->data_len;
108 qbind->buffer_type = MYSQL_TYPE_STRING;
109
110 return 1;
111}
112
113
114/**
92 * Generate query parameter for a string 115 * Generate query parameter for a string
93 * 116 *
94 * @param ptr pointer to the string query parameter to pass 117 * @param ptr pointer to the string query parameter to pass
@@ -96,8 +119,15 @@ GNUNET_MY_query_param_fixed_size (const void *ptr,
96struct GNUNET_MY_QueryParam 119struct GNUNET_MY_QueryParam
97GNUNET_MY_query_param_string (const char *ptr) 120GNUNET_MY_query_param_string (const char *ptr)
98{ 121{
99 return GNUNET_MY_query_param_fixed_size (ptr, 122 struct GNUNET_MY_QueryParam qp = {
100 strlen(ptr)); 123 .conv = &my_conv_string,
124 .cleaner = NULL,
125 .conv_cls = NULL,
126 .num_params = 1,
127 .data = ptr,
128 .data_len = strlen (ptr)
129 };
130 return qp;
101} 131}
102 132
103 133