From 92d5506d7fe5036999cca50d6b9b9cce3f29daff Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Mon, 13 Aug 2012 17:53:08 -0400 Subject: simplify output callback by calculating string size automatically --- response.c | 8 ++++---- signalobject.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/response.c b/response.c index a597ea8..10cc941 100644 --- a/response.c +++ b/response.c @@ -15,7 +15,7 @@ extern GAsyncQueue* stdinQueue; //our queue SignalObject* signalObject; //the signal object which registered the signal id //write output to client -static gssize writeOutput(GPollableOutputStream* stream, gchar* data, gssize size); +static gssize writeOutput(GPollableOutputStream* stream, gchar* data); //callback for client output, this is where the queue messages are sent to the client gboolean cbClientOutput(gpointer data, gpointer additional) @@ -89,9 +89,9 @@ gboolean cbClientInput(gpointer data, gpointer additional) } //write output to client -static gssize writeOutput(GPollableOutputStream* stream, gchar* data, gssize size) +static gssize writeOutput(GPollableOutputStream* stream, gchar* data) { - return g_pollable_output_stream_write_nonblocking(stream, data, size, NULL, NULL); + return g_pollable_output_stream_write_nonblocking(stream, data, strlen(data), NULL, NULL); } //initialize the signals @@ -138,7 +138,7 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) strcat(out, "\n"); } - written = data->cb(stream, out, strlen(out)); + written = data->cb(stream, out); if (written == -1) { g_print("Could not send message to client\n"); } diff --git a/signalobject.h b/signalobject.h index dedb9b8..6abf273 100644 --- a/signalobject.h +++ b/signalobject.h @@ -22,7 +22,7 @@ typedef struct _SignalObjectClass SignalObjectClass; struct _SignalObject { GObject parentInstance; gpointer instance; - gssize (*cb)(GPollableOutputStream* stream, gchar* data, gssize size); + gssize (*cb)(GPollableOutputStream* stream, gchar* data); GPollableInputStream* inStream; GPollableOutputStream* outStream; gchar* data; @@ -32,7 +32,7 @@ struct _SignalObject { struct _SignalObjectClass { GObjectClass parent_class; gpointer instance; - gssize (*cb)(GPollableOutputStream* stream, gchar* data, gssize size); + gssize (*cb)(GPollableOutputStream* stream, gchar* data); GPollableInputStream* inStream; GPollableOutputStream* outStream; gchar* data; -- cgit