FANDOM


Below is the full text to nhxdr.h from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[SLASH'EM 0.0.7E7F2/nhxdr.h#line123]], for example.

The latest source code for vanilla NetHack is at Source code.


The NetHack General Public License applies to screenshots, source code and other content from NetHack.
1.    /* $Id: nhxdr.h,v 1.7 2003/10/25 18:06:00 j_ali Exp $ */
2.    /* Copyright (c) Slash'EM Development Team 2001-2003 */
3.    /* NetHack may be freely redistributed.  See license for details. */
4.    
5.    #ifndef NHXDR_H
6.    #define NHXDR_H
7.    
8.    #ifndef FALSE
9.    #define FALSE 0
10.   #endif
11.   
12.   #ifndef TRUE
13.   #define TRUE 1
14.   #endif
15.   
16.   #ifndef MIN
17.   #define MIN(a, b)	((a) <= (b) ? (a) : (b))
18.   #endif
19.   
20.   #ifndef MAX
21.   #define MAX(a, b)	((a) >= (b) ? (a) : (b))
22.   #endif
23.   
24.   #ifndef NDECL
25.   /*
26.    * Assume an ANSI X3.159 compatible compiler
27.    */
28.   #define NDECL(f)		(f)(void)
29.   #define FDECL(f, p)		(f)p
30.   #define VDECL(f, p)		(f)p
31.   #define CHAR_P			int
32.   #define SHORT_P			int
33.   #define BOOLEAN_P		int
34.   #endif
35.   
36.   #define NHEXT_XDR_RNDUP(x)	(((x) - 1 | 3) + 1)
37.   
38.   typedef enum { nhext_xdr_false = 0, nhext_xdr_true = 1 } nhext_xdr_bool_t;
39.   
40.   enum nhext_xdr_op {
41.       NHEXT_XDR_ENCODE, NHEXT_XDR_DECODE, NHEXT_XDR_FREE, NHEXT_XDR_COUNT
42.   };
43.   
44.   typedef struct nhext_xdr {
45.       void *x_data;
46.       enum nhext_xdr_op x_op;
47.       nhext_xdr_bool_t (*x_write)(struct nhext_xdr *xdrs, const void *addr,
48.         int size);
49.       nhext_xdr_bool_t (*x_read)(struct nhext_xdr *xdrs, void *addr, int size);
50.       void (*x_destroy)(struct nhext_xdr *xdrs);
51.       unsigned int x_pos, x_size;
52.   } NhExtXdr;
53.   
54.   typedef struct NhExtIO_ NhExtIO;
55.   typedef int (*nhext_io_func)(void *handle, void *buf, unsigned int len);
56.   typedef struct NhExtNB_ NhExtNB;
57.   
58.   #define E extern
59.   
60.   E unsigned int FDECL(nhext_xdr_getpos, (NhExtXdr *));
61.   E nhext_xdr_bool_t FDECL(nhext_xdr_setpos, (NhExtXdr *, unsigned int));
62.   E void FDECL(nhext_xdr_free, (nhext_xdr_bool_t (*)(), char *));
63.   E void FDECL(nhext_xdrmem_create, (NhExtXdr *, char *, unsigned int,
64.   			enum nhext_xdr_op));
65.   E void FDECL(nhext_xdrio_create, (NhExtXdr *, NhExtIO *, enum nhext_xdr_op));
66.   
67.   #define nhext_xdr_destroy(xdrs)	(*(xdrs)->x_destroy)(xdrs)
68.   
69.   E nhext_xdr_bool_t FDECL(nhext_xdr_long, (NhExtXdr *, long *));
70.   E nhext_xdr_bool_t FDECL(nhext_xdr_u_long, (NhExtXdr *, unsigned long *));
71.   E nhext_xdr_bool_t FDECL(nhext_xdr_short, (NhExtXdr *, short *));
72.   E nhext_xdr_bool_t FDECL(nhext_xdr_u_short, (NhExtXdr *, unsigned short *));
73.   E nhext_xdr_bool_t FDECL(nhext_xdr_int, (NhExtXdr *, int *));
74.   E nhext_xdr_bool_t FDECL(nhext_xdr_u_int, (NhExtXdr *, unsigned int *));
75.   E nhext_xdr_bool_t FDECL(nhext_xdr_char, (NhExtXdr *, char *));
76.   E nhext_xdr_bool_t FDECL(nhext_xdr_u_char, (NhExtXdr *, unsigned char *));
77.   E nhext_xdr_bool_t FDECL(nhext_xdr_enum, (NhExtXdr *, int *));
78.   E nhext_xdr_bool_t FDECL(nhext_xdr_bool, (NhExtXdr *, nhext_xdr_bool_t *));
79.   E nhext_xdr_bool_t FDECL(nhext_xdr_string, (NhExtXdr *, char **, unsigned int));
80.   E nhext_xdr_bool_t FDECL(nhext_xdr_bytes, (NhExtXdr *, char **, unsigned int *,
81.     unsigned int));
82.   E nhext_xdr_bool_t FDECL(nhext_xdr_wrapstring, (NhExtXdr *, char **));
83.   E nhext_xdr_bool_t FDECL(nhext_xdr_vector, (NhExtXdr *, char *, unsigned int,
84.     unsigned int, nhext_xdr_bool_t (*)()));
85.   E nhext_xdr_bool_t FDECL(nhext_xdr_array, (NhExtXdr *, char **, unsigned int *,
86.     unsigned int, unsigned int, nhext_xdr_bool_t (*)()));
87.   
88.   #define NHEXT_IO_RDONLY		1
89.   #define NHEXT_IO_WRONLY		2
90.   #define NHEXT_IO_NBLOCK		4
91.   #define NHEXT_IO_NOAUTOFILL	8
92.   #define NHEXT_IO_LINEBUF	16	/* Only honoured by text based calls */
93.   #define NHEXT_IO_SIMPLEBUFFER	32
94.   #define NHEXT_IO_PENDING	64
95.   
96.   #if __GNUC__ >= 3 || __GNUC__ == 2 && __GNUC_MINOR__ >= 5
97.   #define NHEXT__PRINTF(p_fmt, p_arg0) \
98.   	__attribute__((format(printf, p_fmt, p_arg0)))
99.   #else
100.  #define NHEXT__PRINTF(p_fmt, p_arg0)
101.  #endif
102.  
103.  E NhExtIO *FDECL(nhext_io_open, (nhext_io_func, void *, unsigned int));
104.  E int FDECL(nhext_io_close, (NhExtIO *));
105.  E unsigned int FDECL(nhext_io_getmode, (NhExtIO *));
106.  E void FDECL(nhext_io_setmode, (NhExtIO *, unsigned int));
107.  E void FDECL(nhext_io_setautofill_limit, (NhExtIO *, unsigned int));
108.  E void FDECL(nhext_io_setnbfunc, (NhExtIO *, nhext_io_func));
109.  E int FDECL(nhext_io_filbuf, (NhExtIO *, int));
110.  E int FDECL(nhext_io_getc, (NhExtIO *));
111.  E int FDECL(nhext_io_read, (NhExtIO *, char *, int));
112.  E char *FDECL(nhext_io_getpacket, (NhExtIO *, int *));
113.  E int FDECL(nhext_io_willblock, (NhExtIO *));
114.  E int FDECL(nhext_io_flush, (NhExtIO *));
115.  E int FDECL(nhext_io_fputc, (int, NhExtIO *));
116.  E int FDECL(nhext_io_write, (NhExtIO *, char *, int));
117.  E int FDECL(nhext_io_writet, (NhExtIO *, char *, int));
118.  #ifdef _STDARG_H
119.  E int FDECL(nhext_io_vprintf, (NhExtIO *, char *, va_list));
120.  #endif
121.  E int FDECL(nhext_io_printf, (NhExtIO *, char *, ...)) NHEXT__PRINTF(2, 3);
122.  
123.  E NhExtNB *FDECL(nhext_nb_open, (nhext_io_func, void *));
124.  E int FDECL(nhext_nb_close, (NhExtNB *));
125.  E int FDECL(nhext_nb_read, (NhExtNB *, char *, int, int));
126.  
127.  #endif /* NHXDR_H */

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.