aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/e_ipc_codec.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-05-12 14:46:28 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-05-12 14:46:28 +0000
commit078e74e14cc155d26c160fd6671661a5b9c85c5d (patch)
treebe8a6b4bfc157785c43a08128029b744e49e0e05 /src/bin/e_ipc_codec.c
parentCompiler warnings. (diff)
downloadenlightenment-078e74e14cc155d26c160fd6671661a5b9c85c5d.tar.gz
move some to codecs. this needs cleaning tho... (ipc)
SVN revision: 14732
Diffstat (limited to 'src/bin/e_ipc_codec.c')
-rw-r--r--src/bin/e_ipc_codec.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/bin/e_ipc_codec.c b/src/bin/e_ipc_codec.c
new file mode 100644
index 000000000..4c88d515a
--- /dev/null
+++ b/src/bin/e_ipc_codec.c
@@ -0,0 +1,76 @@
+#include "e.h"
+
+/* local subsystem functions */
+
+/* encode functions, Should these be global? */
+
+/* local subsystem globals */
+static Eet_Data_Descriptor *_e_ipc_int_edd = NULL;
+static Eet_Data_Descriptor *_e_ipc_double_edd = NULL;
+
+/* externally accessible functions */
+int
+e_ipc_codec_init(void)
+{
+ _e_ipc_int_edd = E_CONFIG_DD_NEW("int", E_Ipc_Int);
+ E_CONFIG_VAL(_e_ipc_int_edd, E_Ipc_Int, val, INT);
+
+ _e_ipc_double_edd = E_CONFIG_DD_NEW("double", E_Ipc_Double);
+ E_CONFIG_VAL(_e_ipc_double_edd, E_Ipc_Double, val, DOUBLE);
+
+ return 1;
+}
+
+void
+e_ipc_codec_shutdown(void)
+{
+ E_CONFIG_DD_FREE(_e_ipc_int_edd);
+ E_CONFIG_DD_FREE(_e_ipc_double_edd);
+}
+
+int
+e_ipc_codec_int_dec(char *data, int bytes, int *dest)
+{
+ E_Ipc_Int *dat;
+
+ if (!data) return 0;
+ dat = eet_data_descriptor_decode(_e_ipc_int_edd, data, bytes);
+ if (!dat) return 0;
+ if (dest) *dest = dat->val;
+ free(dat);
+ return 1;
+}
+
+void *
+e_ipc_codec_int_enc(int val, int *size_ret)
+{
+ E_Ipc_Int dat;
+
+ dat.val = val;
+ return eet_data_descriptor_encode(_e_ipc_int_edd, &dat, size_ret);
+}
+
+int
+e_ipc_codec_double_dec(char *data, int bytes, double *dest)
+{
+ E_Ipc_Double *dat;
+
+ if (!data) return 0;
+ dat = eet_data_descriptor_decode(_e_ipc_double_edd, data, bytes);
+ if (!dat) return 0;
+ if (dest) *dest = dat->val;
+ free(dat);
+ return 1;
+}
+
+void *
+e_ipc_codec_double_enc(double val, int *size_ret)
+{
+ E_Ipc_Double dat;
+
+ dat.val = val;
+ return eet_data_descriptor_encode(_e_ipc_double_edd, &dat, size_ret);
+}
+
+/* local subsystem globals */
+