File: fdlist.h

package info (click to toggle)
twin 0.4.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,804 kB
  • ctags: 23,904
  • sloc: ansic: 61,860; cpp: 1,023; makefile: 777; sh: 552; lex: 302; yacc: 231
file content (58 lines) | stat: -rw-r--r-- 2,101 bytes parent folder | download | duplicates (2)
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
/*
 *  fdlist.h  --  include for File Descriptor book-keeping
 *
 *  Copyright (C) 2001 by Massimiliano Ghilardi
 *
 */

#ifndef _TWIN_FDLIST_H
#define _TWIN_FDLIST_H

typedef void (*handler_io_s)(int, uldat);
typedef void (*handler_io_d)(int, obj);

typedef struct fdlist fdlist;	/* for compressed sockets, two fdlist's are used: */
struct fdlist {			/* the uncompressed one has                       */
    int Fd;                     /* Fd == GZFD and pairSlot == the compressed one; */
    uldat pairSlot;		/* the compressed has                             */
    obj HandlerData;		/* Fd == real fd and pairSlot == the uncompressed;*/
    union {
	handler_io_s S;
	handler_io_d D;
    } HandlerIO;
    msgport MsgPort;		/* other sockets just have                        */
    byte *WQueue;		/* Fd == real fd and pairSlot == NOSLOT;          */
    byte *RQueue;
    uldat WQlen, WQmax;
    uldat RQstart, RQlen, RQmax;
    void (*PrivateAfterFlush)(uldat Slot); /* private enable/disable compression routine.
					    * it gets called after RemoteFlush() and it must
					    * remove itself if needed (e.g. call-once routines)
					    */
    byte (*PrivateFlush)(uldat Slot); /* private flush ((un)compression) routine */
    void *PrivateData;		/* used by (un)compression routines to hold private data */
    /*
     * PrivateFlush and PrivateData are used both on low-level, compressed slot and on
     * uncompressed slot: in the compressed slot they are used to compress outgoing data,
     * while in the uncompressed one they are used to uncompress incoming data.
     */
    byte AlienMagic[9 /*TWS_highest*/];/* sizes and endianity used by slot
					* instead of native sizes and endianity */
    byte extern_couldntwrite;
};

enum Alien_magics {
	/* these are possible values of AlienXendian(slot) */
	MagicUnknown = 0, MagicNative = 1,
	MagicAlien = 2, MagicAlienXendian = 3
};

#define AlienMagic(slot)	(FdList[slot].AlienMagic)

#define AlienXendian(slot)	AlienMagic(slot)[TWS_void /*0*/]
#define AlienSizeof(type, slot) AlienMagic(slot)[TWS_##type]



#endif /* _TWIN_FDLIST_H */