--- /dev/null
+# Copyright (C) 2008 Equinox Software, Inc.
+# Kevin Beswick <kevinbeswick00@gmail.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+
+LDADD = $(DEF_LDLIBS)
+AM_CFLAGS = $(DEF_CFLAGS) -DEXEC_DEFAULT -L@top_builddir@/src/libopensrf
+AM_LDFLAGS = $(DEF_LDFLAGS)
+
+DISTCLEANFILES = Makefile.in Makefile
+
+bin_PROGRAMS = osrf-websocket-stdio
+osrf_websocket_stdio_SOURCES = osrf-websocket-stdio.c
--- /dev/null
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <opensrf/utils.h>
+#include <opensrf/socket_bundle.h>
+#include <opensrf/transport_client.h>
+#include <opensrf/osrf_message.h>
+#include <opensrf/osrf_app_session.h>
+#include <opensrf/utils.h>
+#include <opensrf/log.h>
+
+static void child_init();
+static void read_from_stdin();
+static void read_from_osrf();
+static growing_buffer* stdin_buf = NULL;
+static transport_client* osrf_handle = NULL;
+char* osrf_config = "/openils/conf/opensrf_core.xml"; // TODO
+
+int main() {
+ // Reusable stdin reading buffer.
+ stdin_buf = buffer_init(512);
+
+ child_init(); // exits on error
+
+ // Disable output buffering.
+ setbuf(stdout, NULL);
+
+ fd_set fds;
+ int stdin_no = fileno(stdin);
+ int osrf_no = osrf_handle->session->sock_id;
+ int maxfd = osrf_no > stdin_no ? osrf_no : stdin_no;
+
+ while (1) {
+
+ FD_ZERO(&fds);
+ FD_SET(osrf_no, &fds);
+ FD_SET(stdin_no, &fds);
+
+ select(maxfd + 1, &fds, NULL, NULL, NULL);
+
+ if (FD_ISSET(stdin_no, &fds)) {
+ read_from_stdin();
+ }
+
+ if (FD_ISSET(osrf_no, &fds)) {
+ read_from_osrf();
+ }
+ }
+
+ buffer_free(stdin_buf);
+ return 0;
+}
+
+
+// Connect to opensrf
+static void child_init() {
+
+ if (!osrf_system_bootstrap_client(osrf_config, "gateway") ) {
+ fprintf(stderr, "Cannot boostrap OSRF\n");
+ exit(1);
+ }
+
+ osrf_handle = osrfSystemGetTransportClient();
+ osrfAppSessionSetIngress("osrf-websocket-stdio");
+}
+
+// Relay messages from STDIN to OpenSRF
+// Reads one message then exits
+static void read_from_stdin() {
+ char c;
+
+ while ( (c = getchar()) ) {
+
+ if (c == '\n') { // end of current message
+
+ if (stdin_buf->n_used > 0) {
+ printf("Echoing: %s\n", stdin_buf->buf);
+ buffer_reset(stdin_buf);
+ }
+
+ return;
+
+ } else {
+
+ buffer_add_char(stdin_buf, c);
+ }
+ }
+}
+
+
+// Relay messages from OpenSRF to STDIN
+// Relays all available messages
+static void read_from_osrf() {
+
+}
+
+
+