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 723c99b65ea756e403174d98e4f377cad43a38d5
parent dbd74c455194b473506ac163c9764564a36a0fd3
Author: Joris Vink <joris@coders.se>
Date:   Mon, 30 Jun 2014 08:42:18 +0200

Move kore_pgsql.h into includes/ directly.

Much like kore_tasks.h

Diffstat:
contrib/modules/pgsql_test/src/pgsql_test.c | 2+-
contrib/postgres/kore_pgsql.c | 2+-
includes/contrib/postgres/kore_pgsql.h | 77-----------------------------------------------------------------------------
includes/kore_pgsql.h | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/bsd.c | 4++--
src/http.c | 2+-
src/linux.c | 2+-
src/worker.c | 2+-
8 files changed, 84 insertions(+), 84 deletions(-)

diff --git a/contrib/modules/pgsql_test/src/pgsql_test.c b/contrib/modules/pgsql_test/src/pgsql_test.c @@ -16,7 +16,7 @@ #include "kore.h" #include "http.h" -#include "contrib/postgres/kore_pgsql.h" +#include "kore_pgsql.h" #include "static.h" diff --git a/contrib/postgres/kore_pgsql.c b/contrib/postgres/kore_pgsql.c @@ -21,7 +21,7 @@ #include "kore.h" #include "http.h" -#include "contrib/postgres/kore_pgsql.h" +#include "kore_pgsql.h" struct pgsql_job { u_int8_t idx; diff --git a/includes/contrib/postgres/kore_pgsql.h b/includes/contrib/postgres/kore_pgsql.h @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Joris Vink <joris@coders.se> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _H_KORE_PGSQL -#define _H_KORE_PGSQL - -#include <libpq-fe.h> - -struct kore_pgsql { - u_int8_t state; - char *error; - PGresult *result; - void *conn; -}; - -extern char *pgsql_conn_string; - -void kore_pgsql_init(void); -void kore_pgsql_handle(void *, int); -void kore_pgsql_cleanup(struct http_request *); -void kore_pgsql_continue(struct http_request *, int); -int kore_pgsql_query(struct http_request *, char *, int); - -int kore_pgsql_ntuples(struct kore_pgsql *); -void kore_pgsql_logerror(struct kore_pgsql *); -char *kore_pgsql_getvalue(struct kore_pgsql *, int, int); - -#define KORE_PGSQL_STATE_INIT 1 -#define KORE_PGSQL_STATE_WAIT 2 -#define KORE_PGSQL_STATE_RESULT 3 -#define KORE_PGSQL_STATE_ERROR 4 -#define KORE_PGSQL_STATE_DONE 5 -#define KORE_PGSQL_STATE_COMPLETE 6 - -#define KORE_PGSQL(r, q, i, s) \ - do { \ - if (r->pgsql[i] == NULL) \ - if (!kore_pgsql_query(r, q, i)) { \ - if (r->pgsql[i] == NULL) \ - return (KORE_RESULT_RETRY); \ - s; \ - r->pgsql[i]->state = \ - KORE_PGSQL_STATE_COMPLETE; \ - } \ - if (r->pgsql[i] == NULL) \ - return (KORE_RESULT_RETRY); \ - switch (r->pgsql[i]->state) { \ - case KORE_PGSQL_STATE_ERROR: \ - case KORE_PGSQL_STATE_RESULT: \ - s; \ - case KORE_PGSQL_STATE_COMPLETE: \ - break; \ - default: \ - kore_pgsql_continue(r, i); \ - return (KORE_RESULT_RETRY); \ - } \ - if (r->pgsql[i]->state == KORE_PGSQL_STATE_ERROR || \ - r->pgsql[i]->state == KORE_PGSQL_STATE_RESULT) { \ - kore_pgsql_continue(r, i); \ - return (KORE_RESULT_RETRY); \ - } \ - } while (0); - -#endif diff --git a/includes/kore_pgsql.h b/includes/kore_pgsql.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Joris Vink <joris@coders.se> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _H_KORE_PGSQL +#define _H_KORE_PGSQL + +#include <libpq-fe.h> + +struct kore_pgsql { + u_int8_t state; + char *error; + PGresult *result; + void *conn; +}; + +extern char *pgsql_conn_string; + +void kore_pgsql_init(void); +void kore_pgsql_handle(void *, int); +void kore_pgsql_cleanup(struct http_request *); +void kore_pgsql_continue(struct http_request *, int); +int kore_pgsql_query(struct http_request *, char *, int); + +int kore_pgsql_ntuples(struct kore_pgsql *); +void kore_pgsql_logerror(struct kore_pgsql *); +char *kore_pgsql_getvalue(struct kore_pgsql *, int, int); + +#define KORE_PGSQL_STATE_INIT 1 +#define KORE_PGSQL_STATE_WAIT 2 +#define KORE_PGSQL_STATE_RESULT 3 +#define KORE_PGSQL_STATE_ERROR 4 +#define KORE_PGSQL_STATE_DONE 5 +#define KORE_PGSQL_STATE_COMPLETE 6 + +#define KORE_PGSQL(r, q, i, s) \ + do { \ + if (r->pgsql[i] == NULL) \ + if (!kore_pgsql_query(r, q, i)) { \ + if (r->pgsql[i] == NULL) \ + return (KORE_RESULT_RETRY); \ + s; \ + r->pgsql[i]->state = \ + KORE_PGSQL_STATE_COMPLETE; \ + } \ + if (r->pgsql[i] == NULL) \ + return (KORE_RESULT_RETRY); \ + switch (r->pgsql[i]->state) { \ + case KORE_PGSQL_STATE_ERROR: \ + case KORE_PGSQL_STATE_RESULT: \ + s; \ + case KORE_PGSQL_STATE_COMPLETE: \ + break; \ + default: \ + kore_pgsql_continue(r, i); \ + return (KORE_RESULT_RETRY); \ + } \ + if (r->pgsql[i]->state == KORE_PGSQL_STATE_ERROR || \ + r->pgsql[i]->state == KORE_PGSQL_STATE_RESULT) { \ + kore_pgsql_continue(r, i); \ + return (KORE_RESULT_RETRY); \ + } \ + } while (0); + +#endif diff --git a/src/bsd.c b/src/bsd.c @@ -18,13 +18,13 @@ #include <sys/event.h> #ifdef __MACH__ - #include <sys/sysctl.h> +#include <sys/sysctl.h> #endif #include "kore.h" #if defined(KORE_USE_PGSQL) -#include "contrib/postgres/kore_pgsql.h" +#include "kore_pgsql.h" #endif static int kfd = -1; diff --git a/src/http.c b/src/http.c @@ -24,7 +24,7 @@ #include "http.h" #if defined(KORE_USE_PGSQL) -#include "contrib/postgres/kore_pgsql.h" +#include "kore_pgsql.h" #endif #if defined(KORE_USE_TASKS) diff --git a/src/linux.c b/src/linux.c @@ -22,7 +22,7 @@ #include "kore.h" #if defined(KORE_USE_PGSQL) -#include "contrib/postgres/kore_pgsql.h" +#include "kore_pgsql.h" #endif #if defined(KORE_USE_TASKS) diff --git a/src/worker.c b/src/worker.c @@ -26,7 +26,7 @@ #include "http.h" #if defined(KORE_USE_PGSQL) -#include "contrib/postgres/kore_pgsql.h" +#include "kore_pgsql.h" #endif #if defined(KORE_USE_TASKS)