diff options
-rw-r--r-- | src/include/gnunet_my_lib.h | 7 | ||||
-rw-r--r-- | src/my/my.c | 44 |
2 files changed, 47 insertions, 4 deletions
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h index b63ee9218..9a26022c8 100644 --- a/src/include/gnunet_my_lib.h +++ b/src/include/gnunet_my_lib.h | |||
@@ -95,7 +95,7 @@ struct GNUNET_MY_QueryParam | |||
95 | /** | 95 | /** |
96 | * Information to pass to @e conv. Size of @a data. | 96 | * Information to pass to @e conv. Size of @a data. |
97 | */ | 97 | */ |
98 | unsigned long data_len; | 98 | unsigned long data_len ; |
99 | 99 | ||
100 | }; | 100 | }; |
101 | 101 | ||
@@ -222,13 +222,12 @@ GNUNET_MY_result_spec_fixed_size (void *ptr, | |||
222 | */ | 222 | */ |
223 | #define GNUNET_MY_result_spec_auto_from_type(dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof (*(dst))) | 223 | #define GNUNET_MY_result_spec_auto_from_type(dst) GNUNET_MY_result_spec_fixed_size ((dst), sizeof (*(dst))) |
224 | 224 | ||
225 | |||
226 | /** | 225 | /** |
227 | * FIXME. | 226 | * FIXME. |
227 | * | ||
228 | */ | 228 | */ |
229 | int | 229 | int |
230 | GNUNET_MY_extract_result (struct GNUNET_MYSQL_Context *mc, | 230 | GNUNET_MY_extract_result (MYSQL_BIND * result, |
231 | struct GNUNET_MYSQL_StatementHandle *stmt, | ||
232 | int row, | 231 | int row, |
233 | struct GNUNET_MY_ResultSpec *specs); | 232 | struct GNUNET_MY_ResultSpec *specs); |
234 | 233 | ||
diff --git a/src/my/my.c b/src/my/my.c index 62b1ede09..71d30dd16 100644 --- a/src/my/my.c +++ b/src/my/my.c | |||
@@ -90,5 +90,49 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | |||
90 | return GNUNET_OK; | 90 | return GNUNET_OK; |
91 | } | 91 | } |
92 | 92 | ||
93 | /** | ||
94 | * Extract results from a query result according | ||
95 | * to the given specification. If colums are NULL, | ||
96 | * the destination is not modified, and #GNUNET_NO is returned | ||
97 | * | ||
98 | * | ||
99 | * @param result | ||
100 | * @param row, the row from the result to extract | ||
101 | * @param result specificatio to extract for | ||
102 | * @return | ||
103 | #GNUNET_YES if all results could be extracted | ||
104 | #GNUNET_NO if at least one result was NULL | ||
105 | #GNUNET_SYSERR if a result was invalid | ||
106 | */ | ||
107 | int | ||
108 | GNUNET_MY_extract_result (MYSQL_BIND * result, | ||
109 | int row, | ||
110 | struct GNUNET_MY_ResultSpec *specs) | ||
111 | { | ||
112 | unsigned int i ; | ||
113 | int had_null = GNUNET_NO ; | ||
114 | int ret ; | ||
115 | |||
116 | for(i = 0 ; NULL != specs[i].conv ; i++) | ||
117 | { | ||
118 | struct GNUNET_MY_ResultSpec * spec ; | ||
119 | |||
120 | spec = &specs[i] ; | ||
121 | ret = spec->conv(spec->conv_cls, | ||
122 | NULL, //wait GNUNET_MY_QueryParam | ||
123 | result); | ||
124 | |||
125 | if(ret == GNUNET_SYSERR) | ||
126 | return GNUNET_SYSERR ; | ||
127 | |||
128 | if(spec->result_size != NULL) | ||
129 | *spec->result_size = spec->dst_size; | ||
130 | } | ||
131 | |||
132 | if(GNUNET_YES == had_null) | ||
133 | return GNUNET_NO ; | ||
134 | |||
135 | return GNUNET_OK ; | ||
136 | } | ||
93 | 137 | ||
94 | /* end of my.c */ | 138 | /* end of my.c */ |