#include "postgres_fe.h"
#include "libpq-fe.h"
#include "libpq-int.h"
Go to the source code of this file.
Functions | |
int | PQregisterEventProc (PGconn *conn, PGEventProc proc, const char *name, void *passThrough) |
int | PQsetInstanceData (PGconn *conn, PGEventProc proc, void *data) |
void * | PQinstanceData (const PGconn *conn, PGEventProc proc) |
int | PQresultSetInstanceData (PGresult *result, PGEventProc proc, void *data) |
void * | PQresultInstanceData (const PGresult *result, PGEventProc proc) |
int | PQfireResultCreateEvents (PGconn *conn, PGresult *res) |
Definition at line 185 of file libpq-events.c.
References PGEventResultCreate::conn, pg_result::events, FALSE, i, pg_result::nEvents, PGEvent::passThrough, PGEVT_RESULTCREATE, PGEvent::proc, PGEventResultCreate::result, and PGEvent::resultInitialized.
{ int i; if (!res) return FALSE; for (i = 0; i < res->nEvents; i++) { if (!res->events[i].resultInitialized) { PGEventResultCreate evt; evt.conn = conn; evt.result = res; if (!res->events[i].proc(PGEVT_RESULTCREATE, &evt, res->events[i].passThrough)) return FALSE; res->events[i].resultInitialized = TRUE; } } return TRUE; }
void* PQinstanceData | ( | const PGconn * | conn, | |
PGEventProc | proc | |||
) |
Definition at line 121 of file libpq-events.c.
References PGEvent::data, pg_conn::events, i, pg_conn::nEvents, and PGEvent::proc.
int PQregisterEventProc | ( | PGconn * | conn, | |
PGEventProc | proc, | |||
const char * | name, | |||
void * | passThrough | |||
) |
Definition at line 40 of file libpq-events.c.
References PGEventRegister::conn, PGEvent::data, pg_conn::eventArraySize, pg_conn::events, free, i, malloc, PGEvent::name, pg_conn::nEvents, PGEvent::passThrough, PGEVT_REGISTER, PGEvent::proc, realloc, and PGEvent::resultInitialized.
{ int i; PGEventRegister regevt; if (!proc || !conn || !name || !*name) return FALSE; /* bad arguments */ for (i = 0; i < conn->nEvents; i++) { if (conn->events[i].proc == proc) return FALSE; /* already registered */ } if (conn->nEvents >= conn->eventArraySize) { PGEvent *e; int newSize; newSize = conn->eventArraySize ? conn->eventArraySize * 2 : 8; if (conn->events) e = (PGEvent *) realloc(conn->events, newSize * sizeof(PGEvent)); else e = (PGEvent *) malloc(newSize * sizeof(PGEvent)); if (!e) return FALSE; conn->eventArraySize = newSize; conn->events = e; } conn->events[conn->nEvents].proc = proc; conn->events[conn->nEvents].name = strdup(name); if (!conn->events[conn->nEvents].name) return FALSE; conn->events[conn->nEvents].passThrough = passThrough; conn->events[conn->nEvents].data = NULL; conn->events[conn->nEvents].resultInitialized = FALSE; conn->nEvents++; regevt.conn = conn; if (!proc(PGEVT_REGISTER, ®evt, passThrough)) { conn->nEvents--; free(conn->events[conn->nEvents].name); return FALSE; } return TRUE; }
void* PQresultInstanceData | ( | const PGresult * | result, | |
PGEventProc | proc | |||
) |
Definition at line 165 of file libpq-events.c.
References PGEvent::data, pg_result::events, i, pg_result::nEvents, and PGEvent::proc.
int PQresultSetInstanceData | ( | PGresult * | result, | |
PGEventProc | proc, | |||
void * | data | |||
) |
Definition at line 142 of file libpq-events.c.
References PGEvent::data, pg_result::events, i, pg_result::nEvents, and PGEvent::proc.
int PQsetInstanceData | ( | PGconn * | conn, | |
PGEventProc | proc, | |||
void * | data | |||
) |
Definition at line 98 of file libpq-events.c.
References PGEvent::data, pg_conn::events, i, pg_conn::nEvents, and PGEvent::proc.