File: ipc_cmd.c

package info (click to toggle)
nvi 1.81.6-15
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 11,852 kB
  • sloc: ansic: 43,645; sh: 11,207; makefile: 604; perl: 262; tcl: 234; awk: 19
file content (110 lines) | stat: -rw-r--r-- 3,147 bytes parent folder | download | duplicates (10)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "config.h"

#include <sys/types.h>
#include <sys/queue.h>

#include <bitstring.h>
#include <limits.h>
#include <stdio.h>

#include "../common/common.h"

#include "ip.h"

static int ipc_unmarshall_a __P((IPVIWIN *, IP_BUF*, IPFunc));
static int ipc_unmarshall_12 __P((IPVIWIN *, IP_BUF*, IPFunc));
static int ipc_unmarshall __P((IPVIWIN *, IP_BUF*, IPFunc));
static int ipc_unmarshall_ab1 __P((IPVIWIN *, IP_BUF*, IPFunc));
static int ipc_unmarshall_1a __P((IPVIWIN *, IP_BUF*, IPFunc));
static int ipc_unmarshall_1 __P((IPVIWIN *, IP_BUF*, IPFunc));
static int ipc_unmarshall_123 __P((IPVIWIN *, IP_BUF*, IPFunc));

#define OFFSET(t,m) ((size_t)&((t *)0)->m)

IPFUNLIST const ipfuns[] = {
/* SI_ADDSTR */
    {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, addstr)},
/* SI_ATTRIBUTE */
    {"12",  ipc_unmarshall_12,	OFFSET(IPSIOPS, attribute)},
/* SI_BELL */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, bell)},
/* SI_BUSY_OFF */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, busy_off)},
/* SI_BUSY_ON */
    {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, busy_on)},
/* SI_CLRTOEOL */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, clrtoeol)},
/* SI_DELETELN */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, deleteln)},
/* SI_DISCARD */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, discard)},
/* SI_EDITOPT */
    {"ab1", ipc_unmarshall_ab1,	OFFSET(IPSIOPS, editopt)},
/* SI_INSERTLN */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, insertln)},
/* SI_MOVE */
    {"12",  ipc_unmarshall_12,	OFFSET(IPSIOPS, move)},
/* SI_QUIT */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, quit)},
/* SI_REDRAW */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, redraw)},
/* SI_REFRESH */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, refresh)},
/* SI_RENAME */
    {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, rename)},
/* SI_REPLY */
    {"1a",  NULL,		0},
/* SI_REWRITE */
    {"1",   ipc_unmarshall_1,	OFFSET(IPSIOPS, rewrite)},
/* SI_SCROLLBAR */
    {"123", ipc_unmarshall_123,	OFFSET(IPSIOPS, scrollbar)},
/* SI_SELECT */
    {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, select)},
/* SI_SPLIT */
    {"",    ipc_unmarshall,	OFFSET(IPSIOPS, split)},
/* SI_WADDSTR */
    {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, waddstr)},
/* SI_EVENT_SUP */
};

static int
ipc_unmarshall_a(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return ((IPFunc_a)func)(ipvi, ipb->str1, ipb->len1);
}

static int
ipc_unmarshall_12(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return ((IPFunc_12)func)(ipvi, ipb->val1, ipb->val2);
}

static int
ipc_unmarshall(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return func(ipvi);
}

static int
ipc_unmarshall_ab1(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return ((IPFunc_ab1)func)(ipvi, ipb->str1, ipb->len1, ipb->str2, ipb->len2, ipb->val1);
}

static int
ipc_unmarshall_1a(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return ((IPFunc_1a)func)(ipvi, ipb->val1, ipb->str1, ipb->len1);
}

static int
ipc_unmarshall_1(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return ((IPFunc_1)func)(ipvi, ipb->val1);
}

static int
ipc_unmarshall_123(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
{
    return ((IPFunc_123)func)(ipvi, ipb->val1, ipb->val2, ipb->val3);
}