void db_results(struct kore_pgsql *pgsql, struct connection *c) { char *name; int i, rows; rows = kore_pgsql_ntuples(pgsql); for (i = 0; i < rows; i++) { name = kore_pgsql_getvalue(pgsql, i, 0); net_send_queue(c, name, strlen(name)); } net_send_flush(c); kore_pgsql_continue(pgsql); }
/* * Called when there's an actual result to be gotten. After we handle the * entire result, we'll drop back into REQ_STATE_DB_WAIT (above) in order * to continue until the pgsql API returns KORE_PGSQL_STATE_COMPLETE. */ int request_db_read(struct http_request *req) { char *name; int i, rows; struct rstate *state = req->hdlr_extra; /* We have sql data to read! */ rows = kore_pgsql_ntuples(&state->sql); for (i = 0; i < rows; i++) { name = kore_pgsql_getvalue(&state->sql, i, 0); kore_log(LOG_NOTICE, "name: '%s'", name); } /* Continue processing our query results. */ kore_pgsql_continue(req, &state->sql); /* Back to our DB waiting state. */ req->fsm_state = REQ_STATE_DB_WAIT; return (HTTP_STATE_CONTINUE); }