1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * xfermem.h
|
---|
11 | *
|
---|
12 | * Oliver Fromme <oliver.fromme@heim3.tu-clausthal.de>
|
---|
13 | * Sat Mar 29 04:41:34 MET 1997
|
---|
14 | *
|
---|
15 | * This is a stand-alone module which implements a unidirectional,
|
---|
16 | * fast pipe using mmap(). Its primary use is to transfer large
|
---|
17 | * amounts of data from a parent process to its child process,
|
---|
18 | * with a buffer in between which decouples blocking conditions
|
---|
19 | * on both sides. Control information is transferred between the
|
---|
20 | * processes through a socketpair. See xftest.c for an example on
|
---|
21 | * how to use this module.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef TRUE
|
---|
25 | #define FALSE 0
|
---|
26 | #define TRUE 1
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | typedef unsigned char byte;
|
---|
30 |
|
---|
31 | typedef struct {
|
---|
32 | int freeindex; /* [W] next free index */
|
---|
33 | int readindex; /* [R] next index to read */
|
---|
34 | int fd[2];
|
---|
35 | int wakeme[2];
|
---|
36 | byte *data;
|
---|
37 | byte *metadata;
|
---|
38 | int size;
|
---|
39 | int metasize;
|
---|
40 | } txfermem;
|
---|
41 | /*
|
---|
42 | * [W] -- May be written to by the writing process only!
|
---|
43 | * [R] -- May be written to by the reading process only!
|
---|
44 | * All other entries are initialized once.
|
---|
45 | */
|
---|
46 |
|
---|
47 | void xfermem_init (txfermem **xf, int bufsize, int msize);
|
---|
48 | void xfermem_init_writer (txfermem *xf);
|
---|
49 | void xfermem_init_reader (txfermem *xf);
|
---|
50 |
|
---|
51 | int xfermem_write (txfermem *xf, byte *data, int count);
|
---|
52 | int xfermem_read (txfermem *xf, byte *data, int count);
|
---|
53 |
|
---|
54 | int xfermem_get_freespace (txfermem *xf);
|
---|
55 | int xfermem_get_usedspace (txfermem *xf);
|
---|
56 | #define XF_CMD_WAKEUP 0x02
|
---|
57 | #define XF_CMD_TERMINATE 0x03
|
---|
58 | #define XF_WRITER 0
|
---|
59 | #define XF_READER 1
|
---|
60 | int xfermem_getcmd (int fd, int block);
|
---|
61 | int xfermem_putcmd (int fd, byte cmd);
|
---|
62 | int xfermem_block (int fd, txfermem *xf);
|
---|
63 |
|
---|
64 | void xfermem_done (txfermem *xf);
|
---|
65 | #define xfermem_done_writer xfermem_init_reader
|
---|
66 | #define xfermem_done_reader xfermem_init_writer
|
---|
67 |
|
---|
68 | /* EOF */
|
---|