#include <mysql/mysql.h>
#include "gnunet_my_lib.h"
-
/**
* Function called to convert input argument into SQL parameters.
*
MYSQL_BIND *qbind)
{
GNUNET_assert (1 == qp->num_params);
+
qbind->buffer = (void *) qp->data;
qbind->buffer_length = qp->data_len;
- qbind->length = (unsigned long *) &qp->data_len;
qbind->buffer_type = 1;
- return 0;
+
+ //return 0;
+ return 1;
}
const uint16_t *u_hbo = qp->data;
uint16_t *u_nbo;
+ fprintf(stderr, "input data : %u\n", (unsigned)u_hbo);
+
GNUNET_assert (1 == qp->num_params);
+
u_nbo = GNUNET_new (uint16_t);
*u_nbo = htons (*u_hbo);
+
+ fprintf(stderr, "output data : %u\n", (unsigned)u_nbo);
qbind->buffer = (void *) u_nbo;
qbind->buffer_length = sizeof(uint16_t);
qbind->buffer_type = 1;
uint32_t u32;
uint64_t u64;
-// struct GNUNET_MYSQL_StatementHandle *statements_handle_insert;
- struct GNUNET_MYSQL_StatementHandle *statements_handle_select;
+ struct GNUNET_MYSQL_StatementHandle *statements_handle_insert;
+// struct GNUNET_MYSQL_StatementHandle *statements_handle_select;
struct GNUNET_CRYPTO_RsaPrivateKey *priv;
struct GNUNET_HashCode hmsg;
u32 = 32;
u64 = 64;
-/* FIXE THE INSERT QUERY
+// FIXE THE INSERT QUERY
statements_handle_insert = GNUNET_MYSQL_statement_prepare (context,
"INSERT INTO test_my ("
" pub"
",u32"
",u64"
") VALUES "
- "(@1, @2, @3, @4, @5, @6,"
- "@7, @8, @9);");
+ "(?, ?, ?, ?, ?, ?,"
+ "?, ?, ?)");
if (NULL == statements_handle_insert)
{
- fprintf(stderr, "Failed to prepared statement INSERT\n");
+ fprintf (stderr, "Failed to prepared statement INSERT\n");
return 1;
}
+ //ERROR WITH MSG
struct GNUNET_MY_QueryParam params_insert[] = {
GNUNET_MY_query_param_rsa_public_key (pub),
GNUNET_MY_query_param_rsa_signature (sig),
GNUNET_MY_query_param_end
};
+ fprintf(stderr, " u16 : %u\n", (unsigned)params_insert[6].data);
+ fprintf(stderr, " &u16 : %u\n", (unsigned)&u16);
+
//FAIL HERE
if (GNUNET_OK != GNUNET_MY_exec_prepared (context,
statements_handle_insert,
"Failed to execute prepared statement\n");
return 22;
}
-*/
+
+/* NOT THE GOOD FUNCTION -> TO FIXE
statements_handle_select = GNUNET_MYSQL_statement_prepare (context,
"SELECT"
" pub"
fprintf (stderr, "Failed to execute prepared statement\n");
return 22;
}
-
+*/
return 0;
}