diff options
-rw-r--r-- | src/include/gnunet_my_lib.h | 6 | ||||
-rw-r--r-- | src/my/test_my.c | 77 |
2 files changed, 75 insertions, 8 deletions
diff --git a/src/include/gnunet_my_lib.h b/src/include/gnunet_my_lib.h index dbd9f87f5..43c66e751 100644 --- a/src/include/gnunet_my_lib.h +++ b/src/include/gnunet_my_lib.h | |||
@@ -141,6 +141,12 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | |||
141 | struct GNUNET_MY_ResultParam; | 141 | struct GNUNET_MY_ResultParam; |
142 | 142 | ||
143 | /** | 143 | /** |
144 | * Information we pass to #GNUNET_MY_extract_result() to | ||
145 | * initialize the arguments of the prepared statement. | ||
146 | */ | ||
147 | struct GNUNET_MY_ResultSpec; | ||
148 | |||
149 | /** | ||
144 | * Function called to convert input argument into SQL parameters. | 150 | * Function called to convert input argument into SQL parameters. |
145 | * | 151 | * |
146 | * @param cls closure | 152 | * @param cls closure |
diff --git a/src/my/test_my.c b/src/my/test_my.c index 29c60f68d..b20dbdc3a 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -136,7 +136,7 @@ run_queries (MYSQL * mysql) | |||
136 | u32 = 32; | 136 | u32 = 32; |
137 | u64 = 64; | 137 | u64 = 64; |
138 | 138 | ||
139 | struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL; | 139 | // struct GNUNET_CONFIGURATION_Handle * configuration_handle = NULL; |
140 | // configuration_handle = GNUNET_CONFIGURATION_create(); | 140 | // configuration_handle = GNUNET_CONFIGURATION_create(); |
141 | 141 | ||
142 | /* char *query1 = "INSERT INTO test_my (" | 142 | /* char *query1 = "INSERT INTO test_my (" |
@@ -291,15 +291,78 @@ run_queries (MYSQL * mysql) | |||
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | /** OK **/ | 294 | /** REWRITTEN THIS FUNCTION **/ |
295 | int | 295 | int |
296 | main (int argc, const char * const argv[]) | 296 | main (int argc, const char * const argv[]) |
297 | { | 297 | { |
298 | return GNUNET_OK; | 298 | //CREATE A CONTEXTE |
299 | // MYSQL mysql ; | 299 | struct GNUNET_DATASTORE_PluginEnvironment *env; |
300 | // MYSQL_RES *result; | 300 | struct GNUNET_MYSQL_Context *context; |
301 | |||
302 | GNUNET_log_setup ( "test-my", | ||
303 | "WARNING", | ||
304 | NULL); | ||
305 | |||
306 | context = GNUNET_MYSQL_context_create (NULL /* TO FIXE ***/, | ||
307 | "datastore-mysql"); | ||
308 | |||
309 | struct GNUNET_MYSQL_StatementHandle *statements_handle; | ||
310 | |||
311 | statements_handle = GNUNET_MYSQL_statement_prepare (context, | ||
312 | "CREATE TABLE test_my(" | ||
313 | "pub INT" | ||
314 | ", sig INT" | ||
315 | ", abs_time BIGINT" | ||
316 | ", forever BIGINT" | ||
317 | ", hash INT" | ||
318 | ", vsize VARCHAR" | ||
319 | ", u16 SMALLINT" | ||
320 | ", u32 INT" | ||
321 | ", u64 BIGINT" | ||
322 | ")"); | ||
323 | |||
324 | //USE GNUNET_MY_exec_prepared | ||
325 | GNUNET_MY_exec_prepared(context, | ||
326 | statements_handle, | ||
327 | NULL); | ||
328 | |||
329 | if (GNUNET_OK != GNUNET_MYSQL_context_destroy (context)) | ||
330 | { | ||
331 | //ERROR | ||
332 | } | ||
333 | |||
334 | return GNUNET_OK; | ||
335 | |||
336 | /* NEW VERSION TO FIXE if (GNUNET_OK != | ||
337 | mysql_prepare (&mysql)) | ||
338 | { | ||
339 | GNUNET_break (0) ; | ||
340 | mysql_close (&mysql); | ||
341 | return 1; | ||
342 | } | ||
343 | |||
344 | int ret; | ||
345 | ret = run_queries (&mysql); | ||
346 | |||
347 | |||
348 | if (mysql_query (&mysql, | ||
349 | "DROP TABLE test_my;")) | ||
350 | { | ||
351 | fprintf (stderr, "Failed to drop table : %s\n", | ||
352 | mysql_error (&mysql)); | ||
353 | mysql_close (&mysql); | ||
354 | return 1; | ||
355 | } | ||
356 | |||
357 | */ | ||
358 | /* OLD VERSION (use SQL basic function) | ||
359 | |||
360 | ret = run_queries (); | ||
361 | |||
362 | MYSQL mysql ; | ||
363 | MYSQL_RES *result; | ||
301 | 364 | ||
302 | /* int ret; | 365 | int ret; |
303 | 366 | ||
304 | char *hote = ""; | 367 | char *hote = ""; |
305 | char *pseudo = ""; | 368 | char *pseudo = ""; |
@@ -375,6 +438,4 @@ main (int argc, const char * const argv[]) | |||
375 | 438 | ||
376 | return ret; | 439 | return ret; |
377 | */ | 440 | */ |
378 | // mysql_close (&mysql); | ||
379 | // return GNUNET_OK; | ||
380 | } | 441 | } |