summaryrefslogtreecommitdiff
path: root/instr-client.c
diff options
context:
space:
mode:
authorroot <root@fedora-arm.domain.avtechpulse.com>1999-12-31 19:49:19 -0500
committerroot <root@fedora-arm.domain.avtechpulse.com>1999-12-31 19:49:19 -0500
commit3702b14f594c86af91e063e8b1403e7bfd982bfe (patch)
treecaec2c51f56121cd201141003cfb851f9108303b /instr-client.c
parentdcbb634ee0093999b5316a579728969e8bdb1852 (diff)
initial parser re-implementation
Diffstat (limited to 'instr-client.c')
-rw-r--r--instr-client.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/instr-client.c b/instr-client.c
index ed5c64f..fc15a20 100644
--- a/instr-client.c
+++ b/instr-client.c
@@ -1,11 +1,12 @@
#include <stdio.h>
#include <gio/gio.h>
#include <string.h>
-#include "response.h"
-#include "version.h"
#include <stdlib.h>
#include <strings.h>
+#include "response.h"
+#include "version.h"
+
static int port = 3333;
#define BUFSIZE 1024
@@ -68,8 +69,18 @@ stdinAvailable (GIOChannel *source, GIOCondition condition, gpointer data)
//write the message
gssize written=0;
GPollableOutputStream* out = (GPollableOutputStream*)data;
- written = g_pollable_output_stream_write_nonblocking(out, tmp, size, NULL, NULL);
- if (written <=0 || written == G_IO_ERROR_WOULD_BLOCK) {
+ if (g_pollable_output_stream_is_writable(out) == FALSE) {
+ g_print("stream is not writable\n");
+ }
+
+ GError* error = NULL;
+
+ written = g_pollable_output_stream_write_nonblocking(out, tmp, size, NULL, &error);
+ if(error != NULL && error->message)
+ g_print("Got error: %s\n", error->message);
+
+ if (written != size || written <= 0) {
+ g_print("Could not write. blocking. Written: %d\n", written);
return FALSE;
}
@@ -84,11 +95,16 @@ static gboolean cbServerInput(gpointer data, gpointer additional)
memset(buffer,0,BUFSIZE);
GPollableInputStream* inStream = (GPollableInputStream*)data;
+ GError *error = NULL;
+
+ size=g_pollable_input_stream_read_nonblocking(inStream, buffer, BUFSIZE, NULL, &error);
+ if(size <=0) {
+ terminate("Connection to server lost", -1);
+ }
- size=g_pollable_input_stream_read_nonblocking(inStream, buffer, BUFSIZE, NULL, NULL);
- if(size <=0) terminate("Connection to server lost", -1);
-
- g_print("\n%s", buffer);
+ if(buffer[0] != ' ') {
+ g_print("%s", buffer);
+ }
g_print("> ");
return TRUE;
}
@@ -103,8 +119,7 @@ int main(int argc, char** argv)
GError* error = NULL;
GIOChannel* stdinChannel = NULL;
client = g_socket_client_new();
- GSource *source = NULL;
-
+
/* connect to the host */
connection = g_socket_client_connect_to_host (client,
(gchar*)"localhost",
@@ -117,11 +132,9 @@ int main(int argc, char** argv)
g_object_unref(client);
return -1;
}
-
g_printf("Welcome to InstrumentShell v%s\n\n",FW_VERSION);
g_print("> ");
-
//register Pollable sources
out = g_io_stream_get_output_stream (G_IO_STREAM (connection));
in = g_io_stream_get_input_stream (G_IO_STREAM (connection));
@@ -142,4 +155,4 @@ int main(int argc, char** argv)
g_source_attach(inSource, NULL);
g_main_loop_run (g_main_loop_new (NULL, FALSE));
return 0;
-}
+} \ No newline at end of file