diff options
Diffstat (limited to 'src/keydis.c')
-rw-r--r-- | src/keydis.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/keydis.c b/src/keydis.c new file mode 100644 index 0000000..e921f79 --- /dev/null +++ b/src/keydis.c @@ -0,0 +1,81 @@ +/* + * keydis.c: + * + * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>, + * All rights reserved. + * + */ + +static char rcsid[] = "$Id$"; + +/* + * $Log$ + * Revision 1.1 2008/02/14 02:46:44 james + * *** empty log message *** + * + * Revision 1.1 2008/02/14 01:55:57 james + * *** empty log message *** + * + */ + + +#include "project.h" + +typedef struct +{ + KEYDIS_SIGNATURE; + Context *c; +} KeyDis_VT102; + +typedef struct +{ + KEYDIS_SIGNATURE; + Socket *s; +} KeyDis_IPC; + + +static void +keydis_close (KeyDis * t) +{ + free (t); +} + + +static int +keydis_ipc_key (KeyDis * _t, int key) +{ + KeyDis_IPC *t = (KeyDis_IPC *) _t; + + return ipc_msg_send_key (t->s, key); +} + +static int +keydis_vt102_key (KeyDis * _t, int key) +{ + KeyDis_VT102 *t = (KeyDis_VT102 *) _t; + + vt102_send (t->c, key); + return 0; +} + + +KeyDis * +keydis_vt102_new (Context * c) +{ + KeyDis_VT102 *t = malloc (sizeof (KeyDis_VT102)); + t->key = keydis_vt102_key; + t->close = keydis_close; + t->c = c; + return (KeyDis *) t; +} + + +KeyDis * +keydis_ipc_new (Socket * s) +{ + KeyDis_IPC *t = malloc (sizeof (KeyDis_IPC)); + t->key = keydis_ipc_key; + t->close = keydis_close; + t->s = s; + return (KeyDis *) t; +} |