1
0
mirror of https://git.kore.io/kore.git synced 2024-11-12 13:19:12 +01:00

Merge pull request #127 from raphaelmonrouzeau/master

Added new function kore_pgsql_v_query_params().
This commit is contained in:
Joris Vink 2016-06-07 13:37:00 +02:00
commit 2b97d371f5
2 changed files with 22 additions and 8 deletions

View File

@ -67,6 +67,8 @@ void kore_pgsql_continue(struct http_request *, struct kore_pgsql *);
int kore_pgsql_query(struct kore_pgsql *, const char *);
int kore_pgsql_query_params(struct kore_pgsql *,
const char *, int, u_int8_t, ...);
int kore_pgsql_v_query_params(struct kore_pgsql *,
const char *, int, u_int8_t, va_list);
int kore_pgsql_register(const char *, const char *);
int kore_pgsql_ntuples(struct kore_pgsql *);
void kore_pgsql_logerror(struct kore_pgsql *);

View File

@ -150,11 +150,10 @@ kore_pgsql_query(struct kore_pgsql *pgsql, const char *query)
}
int
kore_pgsql_query_params(struct kore_pgsql *pgsql,
const char *query, int result, u_int8_t count, ...)
kore_pgsql_v_query_params(struct kore_pgsql *pgsql,
const char *query, int result, u_int8_t count, va_list args)
{
u_int8_t i;
va_list args;
char **values;
int *lengths, *formats, ret;
@ -164,8 +163,6 @@ kore_pgsql_query_params(struct kore_pgsql *pgsql,
}
if (count > 0) {
va_start(args, count);
lengths = kore_calloc(count, sizeof(int));
formats = kore_calloc(count, sizeof(int));
values = kore_calloc(count, sizeof(char *));
@ -208,9 +205,6 @@ kore_pgsql_query_params(struct kore_pgsql *pgsql,
ret = KORE_RESULT_OK;
cleanup:
if (count > 0)
va_end(args);
kore_mem_free(values);
kore_mem_free(lengths);
kore_mem_free(formats);
@ -218,6 +212,24 @@ cleanup:
return (ret);
}
int
kore_pgsql_query_params(struct kore_pgsql *pgsql,
const char *query, int result, u_int8_t count, ...)
{
int ret;
va_list args;
if (count > 0)
va_start(args, count);
ret = kore_pgsql_v_query_params(pgsql, query, result, count, args);
if (count > 0)
va_end(args);
return (ret);
}
int
kore_pgsql_register(const char *dbname, const char *connstring)
{