From 3f06a3d031f45bc45033f9088ebca9d0a5e9d45a Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 30 Oct 2010 14:58:32 +0200 Subject: [PATCH] Add basic update for GWeb request API --- gweb/gweb.c | 15 ++++++++++----- gweb/gweb.h | 5 ++++- tools/web-test.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gweb/gweb.c b/gweb/gweb.c index 39f8ecf..3a61353 100644 --- a/gweb/gweb.c +++ b/gweb/gweb.c @@ -35,6 +35,9 @@ #include "gresolv.h" #include "gweb.h" +struct _GWebResult { +}; + struct web_session { GWeb *web; @@ -49,6 +52,8 @@ struct web_session { guint resolv_action; char *request; + GWebResult *result; + GWebResultFunc result_func; gpointer result_data; }; @@ -201,7 +206,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) { session->transport_watch = 0; if (session->result_func != NULL) - session->result_func(400, session->result_data); + session->result_func(400, NULL, session->result_data); return FALSE; } @@ -213,7 +218,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (len == 0) { session->transport_watch = 0; if (session->result_func != NULL) - session->result_func(200, session->result_data); + session->result_func(200, NULL, session->result_data); return FALSE; } printf("%s", buf); @@ -339,7 +344,7 @@ static void resolv_result(GResolvResultStatus status, if (results == NULL || results[0] == NULL) { if (session->result_func != NULL) - session->result_func(404, session->result_data); + session->result_func(404, NULL, session->result_data); return; } @@ -347,7 +352,7 @@ static void resolv_result(GResolvResultStatus status, if (inet_aton(results[0], NULL) == 0) { if (session->result_func != NULL) - session->result_func(400, session->result_data); + session->result_func(400, NULL, session->result_data); return; } @@ -355,7 +360,7 @@ static void resolv_result(GResolvResultStatus status, if (connect_session_transport(session) < 0) { if (session->result_func != NULL) - session->result_func(409, session->result_data); + session->result_func(409, NULL, session->result_data); return; } diff --git a/gweb/gweb.h b/gweb/gweb.h index 1ab2a9f..e32a896 100644 --- a/gweb/gweb.h +++ b/gweb/gweb.h @@ -31,14 +31,17 @@ extern "C" { #endif struct _GWeb; +struct _GWebResult; typedef struct _GWeb GWeb; +typedef struct _GWebResult GWebResult; typedef enum { G_WEB_METHOD_GET, } GWebMethod; -typedef void (*GWebResultFunc)(uint16_t status, gpointer user_data); +typedef void (*GWebResultFunc)(guint16 status, GWebResult *result, + gpointer user_data); typedef void (*GWebDebugFunc)(const char *str, gpointer user_data); diff --git a/tools/web-test.c b/tools/web-test.c index 253948f..0d0e363 100644 --- a/tools/web-test.c +++ b/tools/web-test.c @@ -44,7 +44,7 @@ static void sig_term(int sig) g_main_loop_quit(main_loop); } -static void web_result(uint16_t status, gpointer user_data) +static void web_result(guint16 status, GWebResult *result, gpointer user_data) { gdouble elapsed; -- 2.7.4