blob: e921f794ac163eced28d3e1ea1a1052e1395e521 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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;
}
|