chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / keydis.c
1 /*
2  * keydis.c:
3  *
4  * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
5  * All rights reserved.
6  *
7  */
8
9 static char rcsid[] = "$Id$";
10
11 /*
12  * $Log$
13  * Revision 1.1  2008/02/14 02:46:44  james
14  * *** empty log message ***
15  *
16  * Revision 1.1  2008/02/14 01:55:57  james
17  * *** empty log message ***
18  *
19  */
20
21
22 #include "project.h"
23
24 typedef struct
25 {
26   KEYDIS_SIGNATURE;
27   Context *c;
28 } KeyDis_VT102;
29
30 typedef struct
31 {
32   KEYDIS_SIGNATURE;
33   Socket *s;
34 } KeyDis_IPC;
35
36
37 static void
38 keydis_close (KeyDis * t)
39 {
40   free (t);
41 }
42
43
44 static int
45 keydis_ipc_key (KeyDis * _t, int key)
46 {
47   KeyDis_IPC *t = (KeyDis_IPC *) _t;
48
49   return ipc_msg_send_key (t->s, key);
50 }
51
52 static int
53 keydis_vt102_key (KeyDis * _t, int key)
54 {
55   KeyDis_VT102 *t = (KeyDis_VT102 *) _t;
56
57   vt102_send (t->c, key);
58   return 0;
59 }
60
61
62 KeyDis *
63 keydis_vt102_new (Context * c)
64 {
65   KeyDis_VT102 *t = malloc (sizeof (KeyDis_VT102));
66   t->key = keydis_vt102_key;
67   t->close = keydis_close;
68   t->c = c;
69   return (KeyDis *) t;
70 }
71
72
73 KeyDis *
74 keydis_ipc_new (Socket * s)
75 {
76   KeyDis_IPC *t = malloc (sizeof (KeyDis_IPC));
77   t->key = keydis_ipc_key;
78   t->close = keydis_close;
79   t->s = s;
80   return (KeyDis *) t;
81 }