Imported Upstream version 1.10.2
[platform/upstream/krb5.git] / src / include / gssrpc / types.hin
1 /* @(#)types.h  2.3 88/08/15 4.0 RPCSRC */
2 /*
3  * Copyright (c) 2010, Oracle America, Inc.
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *
18  *     * Neither the name of the “Oracle America, Inc.” nor the names of
19  *       its contributors may be used to endorse or promote products
20  *       derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 /*      @(#)types.h 1.18 87/07/24 SMI      */
35
36 /*
37  * Rpc additions to <sys/types.h>
38  */
39 #ifndef GSSRPC_TYPES_H
40 #define GSSRPC_TYPES_H
41
42 #include <sys/types.h>
43
44 @GSSRPC__SYS_SELECT_H@
45 @GSSRPC__SYS_TIME_H@
46 @GSSRPC__UNISTD_H@
47
48 /*
49  * Try to get MAXHOSTNAMELEN from somewhere.
50  */
51 @GSSRPC__SYS_PARAM_H@
52 @GSSRPC__NETDB_H@
53
54 /* Get htonl(), ntohl(), etc. */
55 #include <netinet/in.h>
56
57 #include <stdlib.h>
58
59 /*
60  * Pull in typedefs for fixed-width integers somehow, if they weren't
61  * in sys/types.h.
62  */
63 @GSSRPC__STDINT_H@
64 @GSSRPC__INTTYPES_H@
65 /* Define if there is no uint32_t in system headers. */
66 @GSSRPC__FAKE_UINT32@
67
68 #include <limits.h>
69
70 #ifndef GSSRPC__BEGIN_DECLS
71 #ifdef __cplusplus
72 #define GSSRPC__BEGIN_DECLS     extern "C" {
73 #define GSSRPC__END_DECLS       }
74 #else
75 #define GSSRPC__BEGIN_DECLS
76 #define GSSRPC__END_DECLS
77 #endif
78 #endif
79
80 GSSRPC__BEGIN_DECLS
81
82 #if defined(CHAR_BIT) && CHAR_BIT != 8
83 #error "Bytes must be exactly 8 bits."
84 #endif
85
86 /*
87  * If no uint32_t in system headers, fake it by looking for a 32-bit
88  * two's-complement type.  Yes, this stomps on POSIX namespace, but if
89  * we get here, we're on a system that's far from being
90  * POSIX-compliant anyway.
91  */
92 #if GSSRPC__FAKE_UINT32
93 #if (UINT_MAX == 0xffffffffUL) && (INT_MAX == 0x7fffffffL) \
94         && (INT_MIN == -INT_MAX-1)
95 typedef int             int32_t;
96 typedef unsigned int    uint32_t;
97 #else
98 #if (ULONG_MAX == 0xffffffffUL) && (LONG_MAX == 0x7fffffffL) \
99         && (LONG_MIN == -LONG_MAX-1)
100 typedef long            int32_t;
101 typedef unsigned long   uint32_t;
102 #else
103 #if (USHRT_MAX == 0xffffffffUL) && (SHRT_MAX == 0x7fffffffL) \
104         && (SHRT_MIN == -SHRT_MAX-1)
105 typedef short           int32_t;
106 typedef unsigned short  uint32_t;
107 #else
108 #error "Can't fake up uint32_t."
109 #endif
110 #endif
111 #endif
112 #endif /* GSSRPC__FAKE_UINT32 */
113
114 #if (LONG_MIN != -LONG_MAX-1) || (INT_MIN != -INT_MAX-1) \
115         || (SHRT_MIN != -SHRT_MAX-1)
116 #error "Integer types must be two's-complement."
117 #endif
118
119 /* Define if we need to fake up some BSD type aliases. */
120 #ifndef GSSRPC__BSD_TYPEALIASES /* Allow application to override. */
121 @GSSRPC__BSD_TYPEALIASES@
122 #endif
123 #if GSSRPC__BSD_TYPEALIASES
124 typedef unsigned char   u_char;
125 typedef unsigned short  u_short;
126 typedef unsigned int    u_int;
127 typedef unsigned long   u_long;
128 #endif
129
130 typedef uint32_t        rpcprog_t;
131 typedef uint32_t        rpcvers_t;
132 typedef uint32_t        rpcprot_t;
133 typedef uint32_t        rpcproc_t;
134 typedef uint32_t        rpcport_t;
135 typedef int32_t         rpc_inline_t;
136
137 /* This is for rpc/netdb.h */
138 @rpcent_define@
139
140 #define bool_t  int
141 #define enum_t  int
142 #ifndef FALSE
143 #       define  FALSE   (0)
144 #endif
145 #ifndef TRUE
146 #       define  TRUE    (1)
147 #endif
148 /* XXX namespace */
149 #define __dontcare__    -1
150 #ifndef NULL
151 #       define NULL 0
152 #endif
153
154 /*
155  * The below should probably be internal-only, but seem to be
156  * traditionally exported in RPC implementations.
157  */
158 #define mem_alloc(bsize)        malloc(bsize)
159 #define mem_free(ptr, bsize)    free(ptr)
160
161 #if 0
162 #include <netdb.h> /* XXX This should not have to be here.
163                     * I got sick of seeing the warnings for MAXHOSTNAMELEN
164                     * and the two values were different. -- shanzer
165                     */
166 #endif
167
168 #ifndef INADDR_LOOPBACK
169 #define       INADDR_LOOPBACK         (uint32_t)0x7F000001
170 #endif
171 #ifndef MAXHOSTNAMELEN
172 #define        MAXHOSTNAMELEN  64
173 #endif
174
175 GSSRPC__END_DECLS
176
177 #include <gssrpc/rename.h>
178
179 #endif /* !defined(GSSRPC_TYPES_H) */