Home | History | Annotate | Line # | Download | only in ipc
      1 /*	$NetBSD: ipc_cmd.c,v 1.2 2013/11/22 15:52:05 christos Exp $	*/
      2 #include "config.h"
      3 
      4 #include <sys/types.h>
      5 #include <sys/queue.h>
      6 
      7 #include <bitstring.h>
      8 #include <limits.h>
      9 #include <stdio.h>
     10 
     11 #include "../common/common.h"
     12 
     13 #include "ip.h"
     14 
     15 static int ipc_unmarshall_a __P((IPVIWIN *, IP_BUF*, IPFunc));
     16 static int ipc_unmarshall_12 __P((IPVIWIN *, IP_BUF*, IPFunc));
     17 static int ipc_unmarshall __P((IPVIWIN *, IP_BUF*, IPFunc));
     18 static int ipc_unmarshall_ab1 __P((IPVIWIN *, IP_BUF*, IPFunc));
     19 #if 0
     20 static int ipc_unmarshall_1a __P((IPVIWIN *, IP_BUF*, IPFunc));
     21 #endif
     22 static int ipc_unmarshall_1 __P((IPVIWIN *, IP_BUF*, IPFunc));
     23 static int ipc_unmarshall_123 __P((IPVIWIN *, IP_BUF*, IPFunc));
     24 
     25 #define OFFSET(t,m) ((size_t)&((t *)0)->m)
     26 
     27 IPFUNLIST const ipfuns[] = {
     28 /* SI_ADDSTR */
     29     {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, addstr)},
     30 /* SI_ATTRIBUTE */
     31     {"12",  ipc_unmarshall_12,	OFFSET(IPSIOPS, attribute)},
     32 /* SI_BELL */
     33     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, bell)},
     34 /* SI_BUSY_OFF */
     35     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, busy_off)},
     36 /* SI_BUSY_ON */
     37     {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, busy_on)},
     38 /* SI_CLRTOEOL */
     39     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, clrtoeol)},
     40 /* SI_DELETELN */
     41     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, deleteln)},
     42 /* SI_DISCARD */
     43     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, discard)},
     44 /* SI_EDITOPT */
     45     {"ab1", ipc_unmarshall_ab1,	OFFSET(IPSIOPS, editopt)},
     46 /* SI_INSERTLN */
     47     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, insertln)},
     48 /* SI_MOVE */
     49     {"12",  ipc_unmarshall_12,	OFFSET(IPSIOPS, move)},
     50 /* SI_QUIT */
     51     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, quit)},
     52 /* SI_REDRAW */
     53     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, redraw)},
     54 /* SI_REFRESH */
     55     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, refresh)},
     56 /* SI_RENAME */
     57     {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, rename)},
     58 /* SI_REPLY */
     59     {"1a",  NULL,		0},
     60 /* SI_REWRITE */
     61     {"1",   ipc_unmarshall_1,	OFFSET(IPSIOPS, rewrite)},
     62 /* SI_SCROLLBAR */
     63     {"123", ipc_unmarshall_123,	OFFSET(IPSIOPS, scrollbar)},
     64 /* SI_SELECT */
     65     {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, select)},
     66 /* SI_SPLIT */
     67     {"",    ipc_unmarshall,	OFFSET(IPSIOPS, split)},
     68 /* SI_WADDSTR */
     69     {"a",   ipc_unmarshall_a,	OFFSET(IPSIOPS, waddstr)},
     70 /* SI_EVENT_SUP */
     71 };
     72 
     73 static int
     74 ipc_unmarshall_a(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
     75 {
     76     return ((IPFunc_a)func)(ipvi, ipb->str1, ipb->len1);
     77 }
     78 
     79 static int
     80 ipc_unmarshall_12(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
     81 {
     82     return ((IPFunc_12)func)(ipvi, ipb->val1, ipb->val2);
     83 }
     84 
     85 static int
     86 ipc_unmarshall(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
     87 {
     88     return func(ipvi);
     89 }
     90 
     91 static int
     92 ipc_unmarshall_ab1(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
     93 {
     94     return ((IPFunc_ab1)func)(ipvi, ipb->str1, ipb->len1, ipb->str2, ipb->len2, ipb->val1);
     95 }
     96 
     97 #if 0
     98 static int
     99 ipc_unmarshall_1a(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
    100 {
    101     return ((IPFunc_1a)func)(ipvi, ipb->val1, ipb->str1, ipb->len1);
    102 }
    103 #endif
    104 
    105 static int
    106 ipc_unmarshall_1(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
    107 {
    108     return ((IPFunc_1)func)(ipvi, ipb->val1);
    109 }
    110 
    111 static int
    112 ipc_unmarshall_123(IPVIWIN *ipvi, IP_BUF *ipb, IPFunc func)
    113 {
    114     return ((IPFunc_123)func)(ipvi, ipb->val1, ipb->val2, ipb->val3);
    115 }
    116