static int process_message(SoupMessage *msg) { struct request *req; char *data; GTimer *timer; gulong microsecs; timer = g_timer_new(); g_timer_start(timer); req = request_new(msg->request_body->data); if (!req) return 1; data = request_response(req); if (!data) return 1; request_destroy(req); soup_message_set_response(msg, "application/json", SOUP_MEMORY_TAKE, data, strlen(data)); soup_message_set_status(msg, SOUP_STATUS_OK); g_timer_stop(timer); g_print("Time elapsed: %f\n", g_timer_elapsed(timer, µsecs)); g_timer_destroy(timer); return 0; }
int client_method(int id, void *in, void **out) { int lenreq, lenres, err, skip; lenreq = write_request_header(bufreq, BUF_REQ_SIZE, id); lenreq += (Operations[id].constructinfunc)(bufreq+lenreq, BUF_REQ_SIZE-lenreq, in); lenreq += write_request_footer(bufreq+lenreq, BUF_REQ_SIZE-lenreq); err = request_response(id, bufreq, lenreq, bufres, &lenres); *out = NULL; if (!err) { skip = skip_response_header(bufres, lenres); if (skip >= 0) { *out = (Operations[id].parseoutfunc)(bufres+skip, lenres-skip); } else { err = skip; } } return err; }