substdio.h
author tomas@localhost
Thu, 01 Nov 2007 14:46:11 +0100
changeset 0 c045670f36e9
permissions -rw-r--r--
Imported queue-fix-1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     1
#ifndef SUBSTDIO_H
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     2
#define SUBSTDIO_H
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     3
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     4
typedef struct substdio {
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     5
  char *x;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     6
  int p;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     7
  int n;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     8
  int fd;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     9
  int (*op)();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    10
} substdio;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    11
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    12
#define SUBSTDIO_FDBUF(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    13
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    14
extern void substdio_fdbuf();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    15
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    16
extern int substdio_flush();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    17
extern int substdio_put();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    18
extern int substdio_bput();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    19
extern int substdio_putflush();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    20
extern int substdio_puts();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    21
extern int substdio_bputs();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    22
extern int substdio_putsflush();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    23
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    24
extern int substdio_get();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    25
extern int substdio_bget();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    26
extern int substdio_feed();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    27
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    28
extern char *substdio_peek();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    29
extern void substdio_seek();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    30
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    31
#define substdio_fileno(s) ((s)->fd)
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    32
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    33
#define SUBSTDIO_INSIZE 8192
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    34
#define SUBSTDIO_OUTSIZE 8192
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    35
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    36
#define substdio_PEEK(s) ( (s)->x + (s)->n )
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    37
#define substdio_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    38
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    39
#define substdio_BPUTC(s,c) \
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    40
  ( ((s)->n != (s)->p) \
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    41
    ? ( (s)->x[(s)->p++] = (c), 0 ) \
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    42
    : substdio_bput((s),&(c),1) \
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    43
  )
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    44
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    45
extern int substdio_copy();
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    46
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    47
#endif