From 8630f69b165553b1c343f065bfd314ef43f78c84 Mon Sep 17 00:00:00 2001 From: Markus Grueneis Date: Wed, 24 Nov 2010 22:39:16 +0000 Subject: added example gcsd startup script, and example dispatch-table for simple binary protocol git-svn-id: https://svn.spreadspace.org/gcsd/trunk@62 ac14a137-c7f1-4531-abe0-07747231d213 --- examples/dynamic_dispatch_table.lua | 16 ++++++++++++++++ examples/start_gcsd.sh | 7 +++++++ 2 files changed, 23 insertions(+) create mode 100644 examples/dynamic_dispatch_table.lua create mode 100644 examples/start_gcsd.sh diff --git a/examples/dynamic_dispatch_table.lua b/examples/dynamic_dispatch_table.lua new file mode 100644 index 0000000..c515621 --- /dev/null +++ b/examples/dynamic_dispatch_table.lua @@ -0,0 +1,16 @@ +local get_length_table = { + [".."] = function(match) + local bytes = string.byte(match, 1, 2) + local length = bytes[1] * 256^2 + bytes[2] -- TODO byte order? + local get_binary_data_table = { + [string.rep(".", length)] = function(match) + command_queue:enqueue(match) + dispatch_table:register_handler_table(get_length_table) + end + } + + dispatch_table:register_handler_table(get_binary_data_table) + end +} + +return get_length_table diff --git a/examples/start_gcsd.sh b/examples/start_gcsd.sh new file mode 100644 index 0000000..9f315c7 --- /dev/null +++ b/examples/start_gcsd.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# -U debug-mode (starts debug module) +# -o start stdio as output module +# -i start dummy as input module +# -l use specified file as dispatch-table configuration +gcsd -U -o stdio:name=stdio -i dummy:name=dumm -l tmp.lua -- cgit v1.2.3