diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-13 18:03:43 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-13 18:03:43 -0400 |
commit | 17f1a001386bf5072009556757c05b2c952c92e1 (patch) | |
tree | d5146857393dc2a20b41c60600059dc75e54b4bc /response.c | |
parent | 92d5506d7fe5036999cca50d6b9b9cce3f29daff (diff) |
always append CR+LF to outgoing message
Diffstat (limited to 'response.c')
-rw-r--r-- | response.c | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -91,7 +91,26 @@ gboolean cbClientInput(gpointer data, gpointer additional) //write output to client static gssize writeOutput(GPollableOutputStream* stream, gchar* data) { - return g_pollable_output_stream_write_nonblocking(stream, data, strlen(data), NULL, NULL); + gssize written_bytes = 0; + + gchar *terminated; + if(data==NULL) { + terminated = g_strdup("\r\n"); + } else { + terminated = g_strdup_printf ("%s\r\n", data); + } + +// if(!strlen(out)) { +// strcpy(out, " "); +// } +// +// if(out[strlen(out)-1] != '\n' && out[strlen(out)-1] != '\r') { +// strcat(out, "\n"); +// } + + written_bytes = g_pollable_output_stream_write_nonblocking(stream, terminated, strlen(data), NULL, NULL); + g_free (terminated); + return written_bytes; } //initialize the signals @@ -128,15 +147,6 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data) // FIXME - Parser_main may generate multiple responses Parser_main(str, &out, 1); - if(out==NULL) out=g_strdup(" "); - - if(!strlen(out)) { - strcpy(out, " "); - } - - if(out[strlen(out)-1] != '\n' && out[strlen(out)-1] != '\r') { - strcat(out, "\n"); - } written = data->cb(stream, out); if (written == -1) { |