File: xio-nop.c

package info (click to toggle)
socat 2.0.0~beta9-1
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 3,740 kB
  • sloc: ansic: 30,875; sh: 11,630; makefile: 149
file content (64 lines) | stat: -rw-r--r-- 2,034 bytes parent folder | download
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
/* source: xio-nop.c */
/* Copyright Gerhard Rieger 2006-2007 */
/* Published under the GNU General Public License V.2, see file COPYING */

/* this file contains the source for a degenerated address that just transfers
   data */

#include "xiosysincludes.h"
#include "xioopen.h"

#include "xio-nop.h"


#if WITH_NOP

static int xioopen_nop(int argc, const char *argv[], struct opt *opts,
				  int xioflags, xiofile_t *xxfd,
				  unsigned groups, int dummy1, int dummy2,
				  int dummy3);

static const struct xioaddr_inter_desc xiointer_nop0ro = { XIOADDR_PROT, "nop", 0, XIOBIT_RDONLY, 0/*groups*/, XIOSHUT_CLOSE, XIOCLOSE_NONE, xioopen_nop, 0, 0, 0, XIOBIT_WRONLY HELP("") };
static const struct xioaddr_inter_desc xiointer_nop0wo = { XIOADDR_PROT, "nop", 0, XIOBIT_WRONLY, 0/*groups*/, XIOSHUT_CLOSE, XIOCLOSE_NONE, xioopen_nop, 0, 0, 0, XIOBIT_RDONLY HELP("") };
static const struct xioaddr_inter_desc xiointer_nop0rw = { XIOADDR_PROT, "nop", 0, XIOBIT_RDWR,   0/*groups*/, XIOSHUT_CLOSE, XIOCLOSE_NONE, xioopen_nop, 0, 0, 0, XIOBIT_RDWR   HELP("") };

const union xioaddr_desc *xioaddrs_nop[] = {
   (union xioaddr_desc *)&xiointer_nop0ro,
   (union xioaddr_desc *)&xiointer_nop0wo,
   (union xioaddr_desc *)&xiointer_nop0rw,
   NULL };

static int xioopen_nop(int argc, const char *argv[], struct opt *opts,
				  int xioflags, xiofile_t *xxfd,
				  unsigned groups, int dummy, int dummy2,
				  int dummy3) {
   struct single *xfd = &xxfd->stream;
   int result;

   if (argc != 1) {
      Error("address NOP takes no arguments");
      return STAT_NORETRY;
   }

   if (xfd->rfd < 0 && xfd->wfd < 0) { /*!!!*/
      Error("NOP cannot be endpoint");
      return STAT_NORETRY;
   }

   applyopts(-1, opts, PH_INIT);
   if (applyopts_single(xfd, opts, PH_INIT) < 0)  return -1;

   Notice("opening NOP");

   xfd->dtype = XIODATA_STREAM;
   /*xfd->fdtype = FDTYPE_DOUBLE;*/

   applyopts(xfd->rfd, opts, PH_ALL);

   if ((result = _xio_openlate(xfd, opts)) < 0)
      return result;

   return 0;
}
#endif /* WITH_NOP */