assume char* is in CODESET encoding
[nvi.git] / ipc / ipc_cmd.c
blob069506fade7645d82aa2de73a77798d57497029c
1 #include "config.h"
3 #include <sys/types.h>
4 #include <sys/queue.h>
6 #include <bitstring.h>
7 #include <limits.h>
8 #include <stdio.h>
10 #include "../common/common.h"
12 #include "ip.h"
14 static int ipc_unmarshall_a __P((IPVIWIN *, IP_BUF*, IPFunc));
15 static int ipc_unmarshall_12 __P((IPVIWIN *, IP_BUF*, IPFunc));
16 static int ipc_unmarshall __P((IPVIWIN *, IP_BUF*, IPFunc));
17 static int ipc_unmarshall_ab1 __P((IPVIWIN *, IP_BUF*, IPFunc));
18 static int ipc_unmarshall_1a __P((IPVIWIN *, IP_BUF*, IPFunc));
19 static int ipc_unmarshall_1 __P((IPVIWIN *, IP_BUF*, IPFunc));
20 static int ipc_unmarshall_123 __P((IPVIWIN *, IP_BUF*, IPFunc));
22 #define OFFSET(t,m) ((size_t)&((t *)0)->m)
24 IPFUNLIST const ipfuns[] = {
25 /* SI_ADDSTR */
26 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, addstr)},
27 /* SI_ATTRIBUTE */
28 {"12", ipc_unmarshall_12, OFFSET(IPSIOPS, attribute)},
29 /* SI_BELL */
30 {"", ipc_unmarshall, OFFSET(IPSIOPS, bell)},
31 /* SI_BUSY_OFF */
32 {"", ipc_unmarshall, OFFSET(IPSIOPS, busy_off)},
33 /* SI_BUSY_ON */
34 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, busy_on)},
35 /* SI_CLRTOEOL */
36 {"", ipc_unmarshall, OFFSET(IPSIOPS, clrtoeol)},
37 /* SI_DELETELN */
38 {"", ipc_unmarshall, OFFSET(IPSIOPS, deleteln)},
39 /* SI_DISCARD */
40 {"", ipc_unmarshall, OFFSET(IPSIOPS, discard)},
41 /* SI_EDITOPT */
42 {"ab1", ipc_unmarshall_ab1, OFFSET(IPSIOPS, editopt)},
43 /* SI_INSERTLN */
44 {"", ipc_unmarshall, OFFSET(IPSIOPS, insertln)},
45 /* SI_MOVE */
46 {"12", ipc_unmarshall_12, OFFSET(IPSIOPS, move)},
47 /* SI_QUIT */
48 {"", ipc_unmarshall, OFFSET(IPSIOPS, quit)},
49 /* SI_REDRAW */
50 {"", ipc_unmarshall, OFFSET(IPSIOPS, redraw)},
51 /* SI_REFRESH */
52 {"", ipc_unmarshall, OFFSET(IPSIOPS, refresh)},
53 /* SI_RENAME */
54 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, rename)},
55 /* SI_REPLY */
56 {"1a", NULL, 0},
57 /* SI_REWRITE */
58 {"1", ipc_unmarshall_1, OFFSET(IPSIOPS, rewrite)},
59 /* SI_SCROLLBAR */
60 {"123", ipc_unmarshall_123, OFFSET(IPSIOPS, scrollbar)},
61 /* SI_SELECT */
62 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, select)},
63 /* SI_SPLIT */
64 {"", ipc_unmarshall, OFFSET(IPSIOPS, split)},
65 /* SI_WADDSTR */
66 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, waddstr)},
67 /* SI_EVENT_SUP */
70 static int
71 ipc_unmarshall_a(ipvi, ipb, func)
72 IPVIWIN *ipvi;
73 IP_BUF *ipb;
74 IPFunc func;
76 return ((IPFunc_a)func)(ipvi, ipb->str1, ipb->len1);
79 static int
80 ipc_unmarshall_12(ipvi, ipb, func)
81 IPVIWIN *ipvi;
82 IP_BUF *ipb;
83 IPFunc func;
85 return ((IPFunc_12)func)(ipvi, ipb->val1, ipb->val2);
88 static int
89 ipc_unmarshall(ipvi, ipb, func)
90 IPVIWIN *ipvi;
91 IP_BUF *ipb;
92 IPFunc func;
94 return func(ipvi);
97 static int
98 ipc_unmarshall_ab1(ipvi, ipb, func)
99 IPVIWIN *ipvi;
100 IP_BUF *ipb;
101 IPFunc func;
103 return ((IPFunc_ab1)func)(ipvi, ipb->str1, ipb->len1, ipb->str2, ipb->len2, ipb->val1);
106 static int
107 ipc_unmarshall_1a(ipvi, ipb, func)
108 IPVIWIN *ipvi;
109 IP_BUF *ipb;
110 IPFunc func;
112 return ((IPFunc_1a)func)(ipvi, ipb->val1, ipb->str1, ipb->len1);
115 static int
116 ipc_unmarshall_1(ipvi, ipb, func)
117 IPVIWIN *ipvi;
118 IP_BUF *ipb;
119 IPFunc func;
121 return ((IPFunc_1)func)(ipvi, ipb->val1);
124 static int
125 ipc_unmarshall_123(ipvi, ipb, func)
126 IPVIWIN *ipvi;
127 IP_BUF *ipb;
128 IPFunc func;
130 return ((IPFunc_123)func)(ipvi, ipb->val1, ipb->val2, ipb->val3);