[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37403 - in gnunet/src: my regex
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37403 - in gnunet/src: my regex |
Date: |
Mon, 27 Jun 2016 17:34:12 +0200 |
Author: christophe.genevey
Date: 2016-06-27 17:34:12 +0200 (Mon, 27 Jun 2016)
New Revision: 37403
Modified:
gnunet/src/my/my_query_helper.c
gnunet/src/regex/gnunet-regex-simulation-profiler.c
Log:
add function conv param string
Modified: gnunet/src/my/my_query_helper.c
===================================================================
--- gnunet/src/my/my_query_helper.c 2016-06-27 15:03:17 UTC (rev 37402)
+++ gnunet/src/my/my_query_helper.c 2016-06-27 15:34:12 UTC (rev 37403)
@@ -89,6 +89,29 @@
/**
+ * Function called to convert input argument into SQL parameters.
+ *
+ * @param cls closure
+ * @param pq data about the query
+ * @param qbind array of parameters to initialize
+ * @return -1 on error
+ */
+static int
+my_conv_string (void *cls,
+ const struct GNUNET_MY_QueryParam *qp,
+ MYSQL_BIND *qbind)
+{
+ GNUNET_assert (1 == qp->num_params);
+
+ qbind->buffer = (void *) qp->data;
+ qbind->buffer_length = qp->data_len;
+ qbind->buffer_type = MYSQL_TYPE_STRING;
+
+ return 1;
+}
+
+
+/**
* Generate query parameter for a string
*
* @param ptr pointer to the string query parameter to pass
@@ -96,8 +119,15 @@
struct GNUNET_MY_QueryParam
GNUNET_MY_query_param_string (const char *ptr)
{
- return GNUNET_MY_query_param_fixed_size (ptr,
- strlen(ptr));
+ struct GNUNET_MY_QueryParam qp = {
+ .conv = &my_conv_string,
+ .cleaner = NULL,
+ .conv_cls = NULL,
+ .num_params = 1,
+ .data = ptr,
+ .data_len = strlen (ptr)
+ };
+ return qp;
}
Modified: gnunet/src/regex/gnunet-regex-simulation-profiler.c
===================================================================
--- gnunet/src/regex/gnunet-regex-simulation-profiler.c 2016-06-27 15:03:17 UTC
(rev 37402)
+++ gnunet/src/regex/gnunet-regex-simulation-profiler.c 2016-06-27 15:34:12 UTC
(rev 37403)
@@ -316,10 +316,10 @@
*/
static void
regex_iterator (void *cls,
- const struct GNUNET_HashCode *key,
- const char *proof,
+ const struct GNUNET_HashCode *key,
+ const char *proof,
int accepting,
- unsigned int num_edges,
+ unsigned int num_edges,
const struct REGEX_BLOCK_Edge *edges)
{
unsigned int i;
@@ -334,7 +334,7 @@
{
struct GNUNET_MY_QueryParam params_select[] = {
GNUNET_MY_query_param_auto_from_type (key),
- GNUNET_MY_query_param_fixed_size(edges[i].label, strlen
(edges[i].label)),
+ GNUNET_MY_query_param_string (edges[i].label),
GNUNET_MY_query_param_end
};
@@ -370,13 +370,14 @@
if (-1 != total && total > 0)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total: %llu (%s, %s)\n", (unsigned
long long)total,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Total: %llu (%s, %s)\n",
+ (unsigned long long)total,
GNUNET_h2s (key), edges[i].label);
}
struct GNUNET_MY_QueryParam params_stmt[] = {
GNUNET_MY_query_param_auto_from_type (&key),
- GNUNET_MY_query_param_fixed_size (edges[i].label, strlen
(edges[i].label)),
+ GNUNET_MY_query_param_string (edges[i].label),
GNUNET_MY_query_param_auto_from_type (&edges[i].destination),
GNUNET_MY_query_param_uint32 (&iaccepting),
GNUNET_MY_query_param_end
@@ -392,8 +393,12 @@
char *key_str = GNUNET_strdup (GNUNET_h2s (key));
char *to_key_str = GNUNET_strdup (GNUNET_h2s (&edges[i].destination));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Merged (%s, %s, %s, %i)\n",
key_str,
- edges[i].label, to_key_str, accepting);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Merged (%s, %s, %s, %i)\n",
+ key_str,
+ edges[i].label,
+ to_key_str,
+ accepting);
+
GNUNET_free (key_str);
GNUNET_free (to_key_str);
num_merged_transitions++;
@@ -416,7 +421,7 @@
{
struct GNUNET_MY_QueryParam params_stmt[] = {
GNUNET_MY_query_param_auto_from_type (key),
- GNUNET_MY_query_param_fixed_size (NULL, 0),
+ GNUNET_MY_query_param_string (""),
GNUNET_MY_query_param_auto_from_type (NULL),
GNUNET_MY_query_param_uint32 (&iaccepting),
GNUNET_MY_query_param_end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37403 - in gnunet/src: my regex,
gnunet <=