.gitignore: Update
[AROS.git] / test / uae / types.h
blob15129796e43083a0b42741304ffb65d3502f9948
1 #ifndef EXEC_TYPES_H
2 #define EXEC_TYPES_H
4 #include <netinet/in.h>
6 typedef char BYTE;
7 typedef unsigned char UBYTE;
9 class WORD
11 /* This is the data. It's defined in protected mode so the child classes
12 can directly access it. Note that the value is encoded in *big endian*. */
13 protected:
14 short data;
16 /* Now the initializations and the conversions. They are defined in public
17 mode because everyone must be able to access them. */
18 public:
19 /* Convert the data to int in host-endianess */
20 inline operator int ()
22 return (int) ntohs (data);
25 /* Same for short */
26 inline operator short ()
28 return ntohs (data);
31 /* Create a variable of type WORD from a short */
32 inline WORD (short v)
34 data = htons (v);
37 /* Same but from an int */
38 inline WORD (int v)
40 //printf ("WORD(int): v=%d\n", v);
41 data = htons (((short)v));
42 //printf ("WORD(int): data=%d\n", data);
45 /* How to copy a variable of type WORD */
46 inline WORD (const WORD& v)
48 data = v.data;
51 /* How to create an uninitilized WORD variable */
52 inline WORD ()
54 return;
58 /* This is pretty much the same but different types */
59 class APTR
61 protected:
62 long data;
64 public:
65 inline operator int ()
67 return (int) ntohl (data);
70 inline operator void * ()
72 return (void *) ntohl (data);
75 inline APTR (int v)
77 data = htonl (v);
80 inline APTR (void * v)
82 data = htonl (((long)v));
85 inline APTR (const APTR& v)
87 data = v.data;
90 inline APTR ()
92 return;
95 #ifdef DEBUG
96 /* Debugging */
97 inline void print ()
99 printf ("%08lx", data);
101 #endif
104 /* This is an example how to inhert the functionality for other
105 pointers. */
106 class STRPTR : APTR
108 public:
109 inline operator char * ()
111 return (char *) ntohl (data);
114 inline operator const char * ()
116 return (const char *) ntohl (data);
119 inline STRPTR ()
121 return;
124 inline STRPTR (char * v)
126 data = htonl ((long)v);
130 #endif /* EXEC_TYPES_H */