parent
e61b2b515a
commit
078e74e14c
8 changed files with 225 additions and 9 deletions
@ -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 */ |
||||
|
@ -0,0 +1,32 @@ |
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 |
||||
*/ |
||||
#ifdef E_TYPEDEFS |
||||
|
||||
typedef struct _E_Ipc_Int E_Ipc_Int; |
||||
typedef struct _E_Ipc_Double E_Ipc_Double; |
||||
|
||||
#else |
||||
#ifndef E_IPC_CODEC_H |
||||
#define E_IPC_CODEC_H |
||||
|
||||
struct _E_Ipc_Int |
||||
{ |
||||
int val; |
||||
}; |
||||
|
||||
struct _E_Ipc_Double |
||||
{ |
||||
double val; |
||||
}; |
||||
|
||||
EAPI int e_ipc_codec_init(void); |
||||
EAPI void e_ipc_codec_shutdown(void); |
||||
|
||||
EAPI int e_ipc_codec_int_dec(char *data, int bytes, int *dest); |
||||
EAPI void *e_ipc_codec_int_enc(int val, int *size_ret); |
||||
EAPI int e_ipc_codec_double_dec(char *data, int bytes, double *dest); |
||||
EAPI void *e_ipc_codec_double_enc(double val, int *size_ret); |
||||
|
||||
#endif |
||||
#endif |
Loading…
Reference in new issue