diff options
author | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-27 15:34:12 +0000 |
---|---|---|
committer | Christophe Genevey Metat <genevey.christophe@gmail.com> | 2016-06-27 15:34:12 +0000 |
commit | 3a4870624812ac4286624d3946981cac6aef4e67 (patch) | |
tree | 08b05f2d1354b68a466973c177774479484cae1f /src/my | |
parent | 4450e34453501e9449de830d48e1421590181ef7 (diff) | |
download | gnunet-3a4870624812ac4286624d3946981cac6aef4e67.tar.gz gnunet-3a4870624812ac4286624d3946981cac6aef4e67.zip |
add function conv param string
Diffstat (limited to 'src/my')
-rw-r--r-- | src/my/my_query_helper.c | 34 |
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 | */ | ||
99 | static int | ||
100 | my_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, | |||
96 | struct GNUNET_MY_QueryParam | 119 | struct GNUNET_MY_QueryParam |
97 | GNUNET_MY_query_param_string (const char *ptr) | 120 | GNUNET_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 | ||