glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / psycstore / plugin_psycstore_postgres.c
index de4b6e43f28497dc8a9b4215ba7168a083078c8c..bf3f9f29e20987b4783a32a6913cbe0c3699153a 100644 (file)
@@ -2,20 +2,15 @@
  * This file is part of GNUnet
  * Copyright (C) 2016 GNUnet e.V.
  *
- * GNUnet is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 3, or (at your
- * option) any later version.
+ * GNUnet is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
  *
  * GNUnet is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNUnet; see the file COPYING.  If not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * Affero General Public License for more details.
  */
 
 /**
@@ -391,7 +386,7 @@ exec_channel (struct Plugin *plugin, const char *stmt,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params))
     return GNUNET_SYSERR;
 
@@ -409,7 +404,7 @@ transaction_begin (struct Plugin *plugin, enum Transactions transaction)
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_begin", params))
     return GNUNET_SYSERR;
 
@@ -428,7 +423,7 @@ transaction_commit (struct Plugin *plugin)
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_commit", params))
     return GNUNET_SYSERR;
 
@@ -447,7 +442,7 @@ transaction_rollback (struct Plugin *plugin)
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_rollback", params))
     return GNUNET_SYSERR;
 
@@ -465,8 +460,10 @@ channel_key_store (struct Plugin *plugin,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
-      GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_channel_key", params))
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+      GNUNET_PQ_eval_prepared_non_select (plugin->dbh,
+                                         "insert_channel_key",
+                                         params))
     return GNUNET_SYSERR;
 
   return GNUNET_OK;
@@ -482,7 +479,7 @@ slave_key_store (struct Plugin *plugin,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_slave_key", params))
     return GNUNET_SYSERR;
 
@@ -508,21 +505,22 @@ postgres_membership_store (void *cls,
                            uint64_t group_generation)
 {
   struct Plugin *plugin = cls;
-
-  uint32_t idid_join = (uint32_t)did_join;
+  uint32_t idid_join = (uint32_t) did_join;
 
   GNUNET_assert (TRANSACTION_NONE == plugin->transaction);
 
-  if (announced_at > INT64_MAX ||
-      effective_since > INT64_MAX ||
-      group_generation > INT64_MAX)
+  if ( (announced_at > INT64_MAX) ||
+       (effective_since > INT64_MAX) ||
+       (group_generation > INT64_MAX) )
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
 
-  if (GNUNET_OK != channel_key_store (plugin, channel_key)
-      || GNUNET_OK != slave_key_store (plugin, slave_key))
+  if ( (GNUNET_OK !=
+       channel_key_store (plugin, channel_key)) ||
+       (GNUNET_OK !=
+       slave_key_store (plugin, slave_key)) )
     return GNUNET_SYSERR;
 
   struct GNUNET_PQ_QueryParam params[] = {
@@ -535,8 +533,10 @@ postgres_membership_store (void *cls,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
-      GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_membership", params))
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+      GNUNET_PQ_eval_prepared_non_select (plugin->dbh,
+                                         "insert_membership",
+                                         params))
     return GNUNET_SYSERR;
 
   return GNUNET_OK;
@@ -572,7 +572,7 @@ membership_test (void *cls,
     GNUNET_PQ_result_spec_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
       GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, "select_membership", 
                                                 params_select, results_select))
      return GNUNET_SYSERR;
@@ -635,7 +635,7 @@ fragment_store (void *cls,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_fragment", params_insert))
     return GNUNET_SYSERR;
 
@@ -664,7 +664,7 @@ message_add_flags (void *cls,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "update_message_flags", params_update))
     return GNUNET_SYSERR;
 
@@ -994,7 +994,7 @@ counters_message_get (void *cls,
     GNUNET_PQ_result_spec_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
       GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt, 
                                                 params_select, results_select))
      return GNUNET_SYSERR;
@@ -1028,7 +1028,7 @@ counters_state_get (void *cls,
     GNUNET_PQ_result_spec_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
       GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt, 
                                                 params_select, results_select))
      return GNUNET_SYSERR;
@@ -1054,7 +1054,7 @@ state_assign (struct Plugin *plugin, const char *stmt,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params))
     return GNUNET_SYSERR;
 
@@ -1074,7 +1074,7 @@ update_message_id (struct Plugin *plugin,
     GNUNET_PQ_query_param_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS !=
+  if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
       GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params))
     return GNUNET_SYSERR;
 
@@ -1305,7 +1305,7 @@ state_get (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key,
     GNUNET_PQ_result_spec_end
   };
 
-  if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT !=
+  if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
       GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt, 
                                                 params_select, results_select))
      return GNUNET_SYSERR;