Sync usage with man page.
[netbsd-mini2440.git] / dist / nvi / ipc / ipc_cmd.c
blob9bc89f334dcd660dd5ac89790e990ee45722e539
1 /* $NetBSD$ */
3 #include "config.h"
5 #include <sys/types.h>
6 #include <sys/queue.h>
8 #include <bitstring.h>
9 #include <limits.h>
10 #include <stdio.h>
12 #include "../common/common.h"
14 #include "ip.h"
16 static int ipc_unmarshall_a __P((IPVIWIN *, IP_BUF*, IPFunc));
17 static int ipc_unmarshall_12 __P((IPVIWIN *, IP_BUF*, IPFunc));
18 static int ipc_unmarshall __P((IPVIWIN *, IP_BUF*, IPFunc));
19 static int ipc_unmarshall_ab1 __P((IPVIWIN *, IP_BUF*, IPFunc));
20 static int ipc_unmarshall_1a __P((IPVIWIN *, IP_BUF*, IPFunc));
21 static int ipc_unmarshall_1 __P((IPVIWIN *, IP_BUF*, IPFunc));
22 static int ipc_unmarshall_123 __P((IPVIWIN *, IP_BUF*, IPFunc));
24 #define OFFSET(t,m) ((size_t)&((t *)0)->m)
26 IPFUNLIST const ipfuns[] = {
27 /* SI_ADDSTR */
28 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, addstr)},
29 /* SI_ATTRIBUTE */
30 {"12", ipc_unmarshall_12, OFFSET(IPSIOPS, attribute)},
31 /* SI_BELL */
32 {"", ipc_unmarshall, OFFSET(IPSIOPS, bell)},
33 /* SI_BUSY_OFF */
34 {"", ipc_unmarshall, OFFSET(IPSIOPS, busy_off)},
35 /* SI_BUSY_ON */
36 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, busy_on)},
37 /* SI_CLRTOEOL */
38 {"", ipc_unmarshall, OFFSET(IPSIOPS, clrtoeol)},
39 /* SI_DELETELN */
40 {"", ipc_unmarshall, OFFSET(IPSIOPS, deleteln)},
41 /* SI_DISCARD */
42 {"", ipc_unmarshall, OFFSET(IPSIOPS, discard)},
43 /* SI_EDITOPT */
44 {"ab1", ipc_unmarshall_ab1, OFFSET(IPSIOPS, editopt)},
45 /* SI_INSERTLN */
46 {"", ipc_unmarshall, OFFSET(IPSIOPS, insertln)},
47 /* SI_MOVE */
48 {"12", ipc_unmarshall_12, OFFSET(IPSIOPS, move)},
49 /* SI_QUIT */
50 {"", ipc_unmarshall, OFFSET(IPSIOPS, quit)},
51 /* SI_REDRAW */
52 {"", ipc_unmarshall, OFFSET(IPSIOPS, redraw)},
53 /* SI_REFRESH */
54 {"", ipc_unmarshall, OFFSET(IPSIOPS, refresh)},
55 /* SI_RENAME */
56 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, rename)},
57 /* SI_REPLY */
58 {"1a", NULL, 0},
59 /* SI_REWRITE */
60 {"1", ipc_unmarshall_1, OFFSET(IPSIOPS, rewrite)},
61 /* SI_SCROLLBAR */
62 {"123", ipc_unmarshall_123, OFFSET(IPSIOPS, scrollbar)},
63 /* SI_SELECT */
64 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, select)},
65 /* SI_SPLIT */
66 {"", ipc_unmarshall, OFFSET(IPSIOPS, split)},
67 /* SI_WADDSTR */
68 {"a", ipc_unmarshall_a, OFFSET(IPSIOPS, waddstr)},
69 /* SI_EVENT_SUP */
72 static int
73 ipc_unmarshall_a(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
75 return ((IPFunc_a)func)(ipvi, ipb->str1, ipb->len1);
78 static int
79 ipc_unmarshall_12(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
81 return ((IPFunc_12)func)(ipvi, ipb->val1, ipb->val2);
84 static int
85 ipc_unmarshall(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
87 return func(ipvi);
90 static int
91 ipc_unmarshall_ab1(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
93 return ((IPFunc_ab1)func)(ipvi, ipb->str1, ipb->len1, ipb->str2, ipb->len2, ipb->val1);
96 static int
97 ipc_unmarshall_1a(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
99 return ((IPFunc_1a)func)(ipvi, ipb->val1, ipb->str1, ipb->len1);
102 static int
103 ipc_unmarshall_1(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
105 return ((IPFunc_1)func)(ipvi, ipb->val1);
108 static int
109 ipc_unmarshall_123(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
111 return ((IPFunc_123)func)(ipvi, ipb->val1, ipb->val2, ipb->val3);