Windows global stuff:
[krb5.git] / src / lib / gssapi / generic / gssapiP_generic.h
1 /*
2  * Copyright 1993 by OpenVision Technologies, Inc.
3  * 
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without fee,
6  * provided that the above copyright notice appears in all copies and
7  * that both that copyright notice and this permission notice appear in
8  * supporting documentation, and that the name of OpenVision not be used
9  * in advertising or publicity pertaining to distribution of the software
10  * without specific, written prior permission. OpenVision makes no
11  * representations about the suitability of this software for any
12  * purpose.  It is provided "as is" without express or implied warranty.
13  * 
14  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20  * PERFORMANCE OF THIS SOFTWARE.
21  */
22
23 #ifndef _GSSAPIP_GENERIC_H_
24 #define _GSSAPIP_GENERIC_H_
25
26 #include "gssapi.h"
27
28 #include "gssapi_err_generic.h"
29 #include <errno.h>
30 #include <sys/types.h>
31
32 /** helper macros **/
33
34 #define g_OID_equal(o1,o2) \
35    (((o1)->length == (o2)->length) && \
36     (memcmp((o1)->elements,(o2)->elements,(int) (o1)->length) == 0))
37
38 /* this code knows that an int on the wire is 32 bits.  The type of
39    num should be at least this big, or the extra shifts may do weird
40    things */
41
42 #define TWRITE_INT(ptr, num, bigend) \
43    (ptr)[0] = (char) ((bigend)?((num)>>24):((num)&0xff)); \
44    (ptr)[1] = (char) ((bigend)?(((num)>>16)&0xff):(((num)>>8)&0xff)); \
45    (ptr)[2] = (char) ((bigend)?(((num)>>8)&0xff):(((num)>>16)&0xff)); \
46    (ptr)[3] = (char) ((bigend)?((num)&0xff):((num)>>24)); \
47    (ptr) += 4;
48
49 #define TREAD_INT(ptr, num, bigend) \
50    (num) = (((ptr)[0]<<((bigend)?24: 0)) | \
51             ((ptr)[1]<<((bigend)?16: 8)) | \
52             ((ptr)[2]<<((bigend)? 8:16)) | \
53             ((ptr)[3]<<((bigend)? 0:24))); \
54    (ptr) += 4;
55
56 #define TWRITE_STR(ptr, str, len) \
57    memcpy((ptr), (char *) (str), (len)); \
58    (ptr) += (len);
59
60 #define TREAD_STR(ptr, str, len) \
61    (str) = (ptr); \
62    (ptr) += (len);
63
64 #define TWRITE_BUF(ptr, buf, bigend) \
65    TWRITE_INT((ptr), (buf).length, (bigend)); \
66    TWRITE_STR((ptr), (buf).value, (buf).length);
67
68 /** malloc wrappers; these may actually do something later */
69
70 #define xmalloc(n) malloc(n)
71 #define xrealloc(p,n) realloc(p,n)
72 #ifdef xfree
73 #undef xfree
74 #endif
75 #define xfree(p) free(p)
76
77 /** helper functions **/
78
79 int g_save_name PROTOTYPE((void **vdb, gss_name_t *name));
80 int g_save_cred_id PROTOTYPE((void **vdb, gss_cred_id_t *cred));
81 int g_save_ctx_id PROTOTYPE((void **vdb, gss_ctx_id_t *ctx));
82
83 int g_validate_name PROTOTYPE((void **vdb, gss_name_t *name));
84 int g_validate_cred_id PROTOTYPE((void **vdb, gss_cred_id_t *cred));
85 int g_validate_ctx_id PROTOTYPE((void **vdb, gss_ctx_id_t *ctx));
86
87 int g_delete_name PROTOTYPE((void **vdb, gss_name_t *name));
88 int g_delete_cred_id PROTOTYPE((void **vdb, gss_cred_id_t *cred));
89 int g_delete_ctx_id PROTOTYPE((void **vdb, gss_ctx_id_t *ctx));
90
91 int g_make_string_buffer PROTOTYPE((const char *str, gss_buffer_t buffer));
92
93 int g_copy_OID_set PROTOTYPE((const gss_OID_set_desc * const in, gss_OID_set *out));
94
95 int g_token_size PROTOTYPE((const_gss_OID mech, unsigned int body_size));
96
97 void g_make_token_header PROTOTYPE((const_gss_OID mech, int body_size,
98                           unsigned char **buf, int tok_type));
99
100 int g_verify_token_header PROTOTYPE((const_gss_OID mech, int *body_size,
101                           unsigned char **buf, int tok_type, int toksize));
102
103 OM_uint32 g_display_major_status PROTOTYPE((OM_uint32 *minor_status,
104                                  OM_uint32 status_value,
105                                  int *message_context,
106                                  gss_buffer_t status_string));
107
108 OM_uint32 g_display_com_err_status PROTOTYPE((OM_uint32 *minor_status,
109                                    OM_uint32 status_value,
110                                    gss_buffer_t status_string));
111
112 char * g_canonicalize_host PROTOTYPE((char *hostname));
113
114 char * g_strdup PROTOTYPE((char *str));
115
116 /** declarations of internal name mechanism functions **/
117
118 OM_uint32 generic_gss_release_buffer
119 PROTOTYPE( (OM_uint32*,       /* minor_status */
120             gss_buffer_t      /* buffer */
121            ));
122
123 OM_uint32 generic_gss_release_oid_set
124 PROTOTYPE( (OM_uint32*,       /* minor_status */
125             gss_OID_set*      /* set */
126            ));
127
128 #endif /* _GSSAPIP_GENERIC_H_ */