Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / include / gnunet_pq_lib.h
index dd41406d306582b5a85347cbccc2a41fae3d2c71..756370b7401297aa9e6ea57ae91c464364c26d96 100644 (file)
 */
 /**
  * @file include/gnunet_pq_lib.h
- * @brief helper functions for DB interactions
+ * @brief helper functions for Postgres DB interactions
  * @author Christian Grothoff
  */
-#ifndef GNUNET_PQ_LIB_H_
-#define GNUNET_PQ_LIB_H_
+#ifndef GNUNET_PQ_LIB_H
+#define GNUNET_PQ_LIB_H
 
 #include <libpq-fe.h>
 #include "gnunet_util_lib.h"
@@ -58,8 +58,7 @@ struct GNUNET_PQ_QueryParam
 {
 
   /**
-   * Format of the rest of the entry, determines the data
-   * type that is being added to the query.
+   * Function for how to handle this type of entry.
    */
   GNUNET_PQ_QueryConverter conv;
 
@@ -103,6 +102,16 @@ GNUNET_PQ_query_param_fixed_size (const void *ptr,
                                  size_t ptr_size);
 
 
+
+/**
+ * Generate query parameter for a string.
+ *
+ * @param ptr pointer to the string query parameter to pass
+ */
+struct GNUNET_PQ_QueryParam
+GNUNET_PQ_query_param_string (const char *ptr);
+
+
 /**
  * Generate fixed-size query parameter with size determined
  * by variable type.
@@ -119,7 +128,7 @@ GNUNET_PQ_query_param_fixed_size (const void *ptr,
  * @param x the query parameter to pass.
  */
 struct GNUNET_PQ_QueryParam
-GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_rsa_PublicKey *x);
+GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x);
 
 
 /**
@@ -129,7 +138,7 @@ GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_rsa_PublicKey *
  * @param x the query parameter to pass
  */
 struct GNUNET_PQ_QueryParam
-GNUNET_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_rsa_Signature *x);
+GNUNET_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x);
 
 
 /**
@@ -190,8 +199,7 @@ GNUNET_PQ_query_param_uint64 (const uint64_t *x);
  * @param[out] dst where to store the result
  * @return
  *   #GNUNET_YES if all results could be extracted
- *   #GNUNET_NO if at least one result was NULL
- *   #GNUNET_SYSERR if a result was invalid (non-existing field)
+ *   #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
  */
 typedef int
 (*GNUNET_PQ_ResultConverter)(void *cls,
@@ -309,17 +317,15 @@ GNUNET_PQ_result_spec_fixed_size (const char *name,
 
 
 /**
- * Variable-size result expected.
+ * 0-terminated string expected.
  *
  * @param name name of the field in the table
  * @param[out] dst where to store the result, allocated
- * @param[out] sptr where to store the size of @a dst
  * @return array entry for the result specification to use
  */
 struct GNUNET_PQ_ResultSpec
-GNUNET_PQ_result_spec_variable_size (const char *name,
-                                    void **dst,
-                                    size_t *sptr);
+GNUNET_PQ_result_spec_string (const char *name,
+                              char **dst);
 
 
 /**
@@ -331,7 +337,7 @@ GNUNET_PQ_result_spec_variable_size (const char *name,
  */
 struct GNUNET_PQ_ResultSpec
 GNUNET_PQ_result_spec_rsa_public_key (const char *name,
-                                     struct GNUNET_CRYPTO_rsa_PublicKey **rsa);
+                                     struct GNUNET_CRYPTO_RsaPublicKey **rsa);
 
 
 /**
@@ -343,7 +349,7 @@ GNUNET_PQ_result_spec_rsa_public_key (const char *name,
  */
 struct GNUNET_PQ_ResultSpec
 GNUNET_PQ_result_spec_rsa_signature (const char *name,
-                                    struct GNUNET_CRYPTO_rsa_Signature **sig);
+                                    struct GNUNET_CRYPTO_RsaSignature **sig);
 
 
 /**
@@ -422,15 +428,12 @@ GNUNET_PQ_exec_prepared (PGconn *db_conn,
 
 /**
  * Extract results from a query result according to the given specification.
- * If colums are NULL, the destination is not modified, and #GNUNET_NO
- * is returned.
  *
  * @param result result to process
  * @param[in,out] rs result specification to extract for
  * @param row row from the result to extract
  * @return
  *   #GNUNET_YES if all results could be extracted
- *   #GNUNET_NO if at least one result was NULL
  *   #GNUNET_SYSERR if a result was invalid (non-existing field)
  */
 int