Windows global stuff:
[krb5.git] / src / include / krb5 / base-defs.h
1 /*
2  * include/krb5/base-defs.h
3  *
4  * Copyright 1989,1990 by the Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  * 
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  M.I.T. makes no representations about the suitability of
20  * this software for any purpose.  It is provided "as is" without express
21  * or implied warranty.
22  * 
23  *
24  * Basic definitions for Kerberos V5 library
25  */
26
27 #ifndef KRB5_BASE_DEFS__
28 #define KRB5_BASE_DEFS__
29
30 #include "wordsize.h"
31
32 #ifndef FALSE
33 #define FALSE   0
34 #endif
35 #ifndef TRUE
36 #define TRUE    1
37 #endif
38
39 typedef unsigned int krb5_boolean;
40 typedef unsigned int krb5_msgtype;      
41 typedef unsigned int krb5_kvno; 
42
43 typedef unsigned int krb5_addrtype;
44 typedef unsigned int krb5_keytype;
45 typedef unsigned int krb5_enctype;
46 typedef unsigned int krb5_cksumtype;
47 typedef unsigned int krb5_authdatatype;
48
49 typedef krb5_int32      krb5_preauthtype; /* This may change, later on */
50 typedef krb5_int32      krb5_flags;
51 typedef krb5_int32      krb5_timestamp;
52 typedef krb5_int32      krb5_error_code;
53 typedef krb5_int32      krb5_deltat;
54
55 typedef krb5_error_code krb5_magic;
56
57 typedef struct _krb5_data {
58     krb5_magic magic;
59     int length;
60     char FAR *data;
61 } krb5_data;
62
63 /* make const & volatile available without effect */
64
65 #if !defined(__STDC__) && !defined(HAS_ANSI_CONST) && !defined(_WINDOWS)
66 #define const
67 #endif
68 #if !defined(__STDC__) && !defined(HAS_ANSI_VOLATILE) && !defined(_WINDOWS)
69 #define volatile
70 #endif
71
72 #if defined(__STDC__) || defined(HAS_VOID_TYPE) || defined(_WINDOWS)
73 typedef void FAR * krb5_pointer;
74 typedef void const FAR * krb5_const_pointer;
75 #else
76 typedef char FAR * krb5_pointer;
77 typedef char const FAR * krb5_const_pointer;
78 #endif
79
80 #if defined(__STDC__) || defined(KRB5_PROVIDE_PROTOTYPES) || defined(_WINDOWS)
81 #define PROTOTYPE(x) x
82 #if defined(__STDC__) || defined(HAVE_STDARG_H) || defined(_WINDOWS)
83 #define STDARG_P(x) x
84 #else
85 #define STDARG_P(x) ()
86 #endif /* defined(__STDC__) || defined(HAVE_STDARG_H) */
87 #else
88 #define PROTOTYPE(x) ()
89 #define STDARG_P(x) ()
90 #endif /* STDC or PROTOTYPES */
91
92 #ifdef NO_NESTED_PROTOTYPES
93 #define NPROTOTYPE(x) ()
94 #else
95 #define NPROTOTYPE(x) PROTOTYPE(x)
96 #endif
97
98 typedef struct krb5_principal_data {
99     krb5_magic magic;
100     krb5_data realm;
101     krb5_data FAR *data;                /* An array of strings */
102     krb5_int32 length;
103     krb5_int32 type;
104 } krb5_principal_data;
105
106 typedef krb5_principal_data FAR * krb5_principal;
107
108 /*
109  * Per V5 spec on definition of principal types
110  */
111
112 /* Name type not known */
113 #define KRB5_NT_UNKNOWN         0
114 /* Just the name of the principal as in DCE, or for users */
115 #define KRB5_NT_PRINCIPAL       1
116 /* Service and other unique instance (krbtgt) */
117 #define KRB5_NT_SRV_INST        2
118 /* Service with host name as instance (telnet, rcommands) */
119 #define KRB5_NT_SRV_HST         3
120 /* Service with host as remaining components */
121 #define KRB5_NT_SRV_XHST        4
122 /* Unique ID */
123 #define KRB5_NT_UID             5
124
125 /* constant version thereof: */
126 typedef const krb5_principal_data FAR *krb5_const_principal;
127
128 #define krb5_princ_realm(context, princ) (&(princ)->realm)
129 #define krb5_princ_set_realm(context, princ,value) ((princ)->realm = *(value))
130 #define krb5_princ_set_realm_length(context, princ,value) (princ)->realm.length = (value)
131 #define krb5_princ_set_realm_data(context, princ,value) (princ)->realm.data = (value)
132 #define krb5_princ_size(context, princ) (princ)->length
133 #define krb5_princ_type(context, princ) (princ)->type
134 #define krb5_princ_name(context, princ) (princ)->data
135 #define krb5_princ_component(context, princ,i) ((princ)->data + i)
136
137 #endif /* KRB5_BASE_DEFS__ */