summaryrefslogtreecommitdiff
path: root/src/pq/pq.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/pq/pq.c
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
uncrustify as demanded.
Diffstat (limited to 'src/pq/pq.c')
-rw-r--r--src/pq/pq.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/src/pq/pq.c b/src/pq/pq.c
index df5ef17ad..a581b4277 100644
--- a/src/pq/pq.c
+++ b/src/pq/pq.c
@@ -1,22 +1,22 @@
/*
- This file is part of GNUnet
- Copyright (C) 2014, 2015, 2016 GNUnet e.V.
+ This file is part of GNUnet
+ Copyright (C) 2014, 2015, 2016 GNUnet e.V.
- 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 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
- Affero General Public License for more details.
+ 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
+ Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
-*/
+ */
/**
* @file pq/pq.c
* @brief helper functions for libpq (PostGres) interactions
@@ -38,20 +38,20 @@
* @return postgres result
*/
PGresult *
-GNUNET_PQ_exec_prepared (PGconn *db_conn,
- const char *name,
- const struct GNUNET_PQ_QueryParam *params)
+GNUNET_PQ_exec_prepared(PGconn *db_conn,
+ const char *name,
+ const struct GNUNET_PQ_QueryParam *params)
{
unsigned int len;
unsigned int i;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Running prepared statement `%s' on %p\n",
- name,
- db_conn);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Running prepared statement `%s' on %p\n",
+ name,
+ db_conn);
/* count the number of parameters */
len = 0;
- for (i=0;0 != params[i].num_params;i++)
+ for (i = 0; 0 != params[i].num_params; i++)
len += params[i].num_params;
/* new scope to allow stack allocation without alloca */
@@ -70,42 +70,42 @@ GNUNET_PQ_exec_prepared (PGconn *db_conn,
off = 0;
soff = 0;
- for (i=0;0 != params[i].num_params;i++)
- {
- const struct GNUNET_PQ_QueryParam *x = &params[i];
-
- ret = x->conv (x->conv_cls,
- x->data,
- x->size,
- &param_values[off],
- &param_lengths[off],
- &param_formats[off],
- x->num_params,
- &scratch[soff],
- len - soff);
- if (ret < 0)
+ for (i = 0; 0 != params[i].num_params; i++)
{
- for (off = 0; off < soff; off++)
- GNUNET_free (scratch[off]);
- return NULL;
+ const struct GNUNET_PQ_QueryParam *x = &params[i];
+
+ ret = x->conv(x->conv_cls,
+ x->data,
+ x->size,
+ &param_values[off],
+ &param_lengths[off],
+ &param_formats[off],
+ x->num_params,
+ &scratch[soff],
+ len - soff);
+ if (ret < 0)
+ {
+ for (off = 0; off < soff; off++)
+ GNUNET_free(scratch[off]);
+ return NULL;
+ }
+ soff += ret;
+ off += x->num_params;
}
- soff += ret;
- off += x->num_params;
- }
- GNUNET_assert (off == len);
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "pq",
- "Executing prepared SQL statement `%s'\n",
- name);
- res = PQexecPrepared (db_conn,
- name,
- len,
- (const char **) param_values,
- param_lengths,
- param_formats,
- 1);
+ GNUNET_assert(off == len);
+ GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG,
+ "pq",
+ "Executing prepared SQL statement `%s'\n",
+ name);
+ res = PQexecPrepared(db_conn,
+ name,
+ len,
+ (const char **)param_values,
+ param_lengths,
+ param_formats,
+ 1);
for (off = 0; off < soff; off++)
- GNUNET_free (scratch[off]);
+ GNUNET_free(scratch[off]);
return res;
}
}
@@ -118,14 +118,14 @@ GNUNET_PQ_exec_prepared (PGconn *db_conn,
* @param rs reult specification to clean up
*/
void
-GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs)
+GNUNET_PQ_cleanup_result(struct GNUNET_PQ_ResultSpec *rs)
{
unsigned int i;
- for (i=0; NULL != rs[i].conv; i++)
+ for (i = 0; NULL != rs[i].conv; i++)
if (NULL != rs[i].cleaner)
- rs[i].cleaner (rs[i].cls,
- rs[i].dst);
+ rs[i].cleaner(rs[i].cls,
+ rs[i].dst);
}
@@ -141,32 +141,32 @@ GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs)
* #GNUNET_SYSERR if a result was invalid (non-existing field)
*/
int
-GNUNET_PQ_extract_result (PGresult *result,
- struct GNUNET_PQ_ResultSpec *rs,
- int row)
+GNUNET_PQ_extract_result(PGresult *result,
+ struct GNUNET_PQ_ResultSpec *rs,
+ int row)
{
unsigned int i;
int ret;
- for (i=0; NULL != rs[i].conv; i++)
- {
- struct GNUNET_PQ_ResultSpec *spec;
-
- spec = &rs[i];
- ret = spec->conv (spec->cls,
- result,
- row,
- spec->fname,
- &spec->dst_size,
- spec->dst);
- if (GNUNET_OK != ret)
+ for (i = 0; NULL != rs[i].conv; i++)
{
- GNUNET_PQ_cleanup_result (rs);
- return GNUNET_SYSERR;
+ struct GNUNET_PQ_ResultSpec *spec;
+
+ spec = &rs[i];
+ ret = spec->conv(spec->cls,
+ result,
+ row,
+ spec->fname,
+ &spec->dst_size,
+ spec->dst);
+ if (GNUNET_OK != ret)
+ {
+ GNUNET_PQ_cleanup_result(rs);
+ return GNUNET_SYSERR;
+ }
+ if (NULL != spec->result_size)
+ *spec->result_size = spec->dst_size;
}
- if (NULL != spec->result_size)
- *spec->result_size = spec->dst_size;
- }
return GNUNET_OK;
}