gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37186 - gnunet/src/include


From: gnunet
Subject: [GNUnet-SVN] r37186 - gnunet/src/include
Date: Thu, 19 May 2016 15:30:49 +0200

Author: grothoff
Date: 2016-05-19 15:30:48 +0200 (Thu, 19 May 2016)
New Revision: 37186

Modified:
   gnunet/src/include/gnunet_my_lib.h
Log:
extending MY api to cover result extraction

Modified: gnunet/src/include/gnunet_my_lib.h
===================================================================
--- gnunet/src/include/gnunet_my_lib.h  2016-05-19 13:15:51 UTC (rev 37185)
+++ gnunet/src/include/gnunet_my_lib.h  2016-05-19 13:30:48 UTC (rev 37186)
@@ -64,12 +64,7 @@
                            const struct GNUNET_MY_QueryParam *qp,
                             MYSQL_BIND *qbind);
 
-/****** CREATE A NEW STRUCTURE ? *****/
-struct GNUNET_MY_Result
-{
 
-};
-
 /**
  * Information we pass to #GNUNET_MY_exec_prepared() to
  * initialize the arguments of the prepared statement.
@@ -106,7 +101,7 @@
 
 
 /**
- * End of result parameter specification.
+ * End of query parameter specification.
  *
  * @return array last entry for the result specification to use
  */
@@ -140,8 +135,103 @@
                          const struct GNUNET_MY_QueryParam *params);
 
 
-static int extract_result(MYSQL * result, int row) ;
+/**
+ * Information we pass to #GNUNET_MY_extract_result() to
+ * initialize the arguments of the prepared statement.
+ */
+struct GNUNET_MY_ResultParam;
 
+
+/**
+ * Function called to convert input argument into SQL parameters.
+ *
+ * @param cls closure
+ * @param pq data about the query
+ * @return -1 on error
+ */
+typedef int
+(*GNUNET_MY_ResultConverter)(void *cls,
+                             struct GNUNET_MY_QueryParam *qp,
+                             MYSQL_BIND *results);
+
+
+/**
+ * Information we pass to #GNUNET_MY_extract_result() to
+ * initialize the arguments of the prepared statement.
+ */
+struct GNUNET_MY_ResultSpec
+{
+
+  /**
+   * Function to call for the type conversion.
+   */
+  GNUNET_MY_ResultConverter conv;
+
+  /**
+   * Closure for @e conv.
+   */
+  void *conv_cls;
+
+  /**
+   * Destination for the data.
+   */
+  void *dst;
+
+  /**
+   * Allowed size for the data, 0 for variable-size
+   * (in this case, the type of @e dst is a `void **`
+   * and we need to allocate a buffer of the right size).
+   */
+  size_t dst_size;
+
+  /**
+   * Where to store actual size of the result.
+   */
+  size_t *result_size;
+
+};
+
+
+/**
+ * End of result speceter specification.
+ *
+ * @return array last entry for the result specification to use
+ */
+#define GNUNET_MY_result_spec_end { NULL, NULL, NULL, 0, NULL }
+
+
+
+/**
+ * Obtain fixed size result of @a ptr_size bytes from
+ * MySQL, store in already allocated buffer at @a ptr.
+ *
+ * @spec ptr where to write the result
+ * @oaran ptr_size number of bytes available at @a ptr
+ */
+struct GNUNET_MY_ResultSpec
+GNUNET_MY_result_spec_fixed_size (void *ptr,
+                                  size_t ptr_size);
+
+
+/**
+ * We expect a fixed-size result, with size determined by the type of `* dst`
+ *
+ * @spec name name of the field in the table
+ * @spec dst point to where to store the result, type fits expected result size
+ * @return array entry for the result specification to use
+ */
+#define GNUNET_MY_result_spec_auto_from_type(dst) 
GNUNET_MY_result_spec_fixed_size ((dst), sizeof (*(dst)))
+
+
+/**
+ * FIXME.
+ */
+int
+GNUNET_MY_extract_result (struct GNUNET_MYSQL_Context *mc,
+                          struct GNUNET_MYSQL_StatementHandle *stmt,
+                          int row,
+                          struct GNUNET_MY_ResultSpec *specs);
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]