kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 1686ec22e61a3ef8de7fd3260b7ea0940a995c03
parent ff7c85460c7272e8ddba2643d6aa751677ac2440
Author: Joris Vink <joris@coders.se>
Date:   Sat,  1 Jun 2019 23:14:50 +0200

Some C pgsql api improvements.

Diffstat:
include/kore/pgsql.h | 12++++++++----
src/pgsql.c | 8++++----
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/kore/pgsql.h b/include/kore/pgsql.h @@ -26,6 +26,10 @@ #define KORE_PGSQL_ASYNC 0x0002 #define KORE_PGSQL_SCHEDULED 0x0004 +#define KORE_PGSQL_PARAM_BINARY(v, l) v, l, 1 +#define KORE_PGSQL_PARAM_TEXT_LEN(v, l) v, l, 0 +#define KORE_PGSQL_PARAM_TEXT(v) v, strlen(v), 0 + #if defined(__cplusplus) extern "C" { #endif @@ -81,12 +85,12 @@ int kore_pgsql_setup(struct kore_pgsql *, const char *, int); void kore_pgsql_handle(void *, int); void kore_pgsql_cleanup(struct kore_pgsql *); void kore_pgsql_continue(struct kore_pgsql *); -int kore_pgsql_query(struct kore_pgsql *, const char *); +int kore_pgsql_query(struct kore_pgsql *, const void *); int kore_pgsql_query_params(struct kore_pgsql *, - const char *, int, int, ...); + const void *, int, int, ...); int kore_pgsql_v_query_params(struct kore_pgsql *, - const char *, int, int, va_list); -int kore_pgsql_query_param_fields(struct kore_pgsql *, const char *, + const void *, int, int, va_list); +int kore_pgsql_query_param_fields(struct kore_pgsql *, const void *, int, int, const char **, int *, int *); int kore_pgsql_register(const char *, const char *); int kore_pgsql_ntuples(struct kore_pgsql *); diff --git a/src/pgsql.c b/src/pgsql.c @@ -172,7 +172,7 @@ kore_pgsql_bind_callback(struct kore_pgsql *pgsql, } int -kore_pgsql_query(struct kore_pgsql *pgsql, const char *query) +kore_pgsql_query(struct kore_pgsql *pgsql, const void *query) { if (pgsql->conn == NULL) { pgsql_set_error(pgsql, "no connection was set before query"); @@ -202,7 +202,7 @@ kore_pgsql_query(struct kore_pgsql *pgsql, const char *query) int kore_pgsql_v_query_params(struct kore_pgsql *pgsql, - const char *query, int binary, int count, va_list args) + const void *query, int binary, int count, va_list args) { int i; const char **values; @@ -240,7 +240,7 @@ kore_pgsql_v_query_params(struct kore_pgsql *pgsql, } int -kore_pgsql_query_param_fields(struct kore_pgsql *pgsql, const char *query, +kore_pgsql_query_param_fields(struct kore_pgsql *pgsql, const void *query, int binary, int count, const char **values, int *lengths, int *formats) { if (pgsql->conn == NULL) { @@ -275,7 +275,7 @@ kore_pgsql_query_param_fields(struct kore_pgsql *pgsql, const char *query, int kore_pgsql_query_params(struct kore_pgsql *pgsql, - const char *query, int binary, int count, ...) + const void *query, int binary, int count, ...) { int ret; va_list args;