Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / cmd / krb5_locl.h
blobaedbd63060bb045b9316bae3b41b45f888f827e4
2 /* This header file transforms the Heimdal config_parse.c profile
3 * parser into an AFS profile parser, hiding the krb5-ness of the parser
4 * behind the scenes.
5 */
7 #include <afsconfig.h>
8 #include <afs/stds.h>
10 #include <roken.h>
12 #include <assert.h>
13 #include <ctype.h>
15 #include "cmd.h"
17 #define PACKAGE "openafs"
19 #ifndef TRUE
20 # define TRUE 1
21 #endif
22 #ifndef FALSE
23 # define FALSE 0
24 #endif
26 #define KRB5_BUFSIZ 1024
28 #define KRB5_LIB_FUNCTION static AFS_UNUSED
29 #define KRB5_LIB_CALL
31 #define KRB5_DEPRECATED_FUNCTION(x)
33 #define N_(X,Y) X
35 typedef struct cmd_config_binding krb5_config_binding;
36 typedef struct cmd_config_binding krb5_config_section;
38 #define krb5_config_list cmd_config_list
39 #define krb5_config_string cmd_config_string
40 #define _krb5_config_get_entry _cmd_config_get_entry
42 struct krb5_context_data {
43 krb5_config_section *cf;
46 typedef struct krb5_context_data * krb5_context;
47 typedef int krb5_error_code;
48 typedef int krb5_boolean;
49 typedef time_t krb5_deltat;
51 static void krb5_set_error_message(krb5_context context, krb5_error_code ret,
52 const char *fmt, ...) {
53 return;
56 static krb5_error_code
57 krb5_enomem(krb5_context context)
59 return ENOMEM;
62 #ifdef EXPAND_PATH_HEADER
64 #include <shlobj.h>
66 static int _krb5_expand_path_tokens(krb5_context, const char *, char**);
68 int
69 _cmd_ExpandPathTokens(krb5_context context, const char *in, char **out) {
70 return _krb5_expand_path_tokens(context, in, out);
73 HINSTANCE _krb5_hInstance = NULL;
75 /* This bodge avoids the need for everything linking against cmd to also
76 * link against the shell library on Windows */
77 #undef SHGetFolderPath
78 #define SHGetFolderPath internal_getpath
80 HRESULT internal_getpath(void *a, int b, void *c, DWORD d, LPTSTR out) {
81 return E_INVALIDARG;
84 #else
86 #define KRB5_CONFIG_BADFORMAT CMD_BADFORMAT
88 #define _krb5_expand_path_tokens _cmd_ExpandPathTokens
90 extern int _cmd_ExpandPathTokens(krb5_context, const char *, char **);
92 static const void *_krb5_config_vget(krb5_context,
93 const krb5_config_section *, int,
94 va_list);
95 static const void *_krb5_config_vget_next(krb5_context,
96 const krb5_config_section *,
97 const krb5_config_binding **,
98 int, va_list);
99 static const char *krb5_config_vget_string(krb5_context,
100 const krb5_config_section *,
101 va_list);
102 static const char *krb5_config_vget_string_default(krb5_context,
103 const krb5_config_section *,
104 const char *,
105 va_list);
106 static const krb5_config_binding * krb5_config_vget_list
107 (krb5_context, const krb5_config_section *, va_list);
108 static krb5_error_code krb5_config_parse_file_multi
109 (krb5_context, const char *, krb5_config_section **);
110 static krb5_error_code krb5_config_parse_file
111 (krb5_context, const char *, krb5_config_section **);
112 static krb5_error_code krb5_config_file_free
113 (krb5_context, krb5_config_section *);
114 static krb5_boolean krb5_config_vget_bool_default
115 (krb5_context, const krb5_config_section *, int, va_list);
116 static int krb5_config_vget_int_default
117 (krb5_context, const krb5_config_section *, int, va_list);
119 static krb5_error_code
120 krb5_string_to_deltat(const char *str, krb5_deltat *t) {
121 return 1;
124 KRB5_LIB_FUNCTION void krb5_clear_error_message(krb5_context context) {
125 return;
129 static int _krb5_homedir_access(krb5_context context) {
130 return 0;
133 static krb5_error_code
134 krb5_abortx(krb5_context context, const char *fmt, ...)
136 va_list ap;
137 va_start(ap, fmt);
139 vfprintf(stderr, fmt, ap);
140 va_end(ap);
142 abort();
145 /* Wrappers */
149 cmd_RawConfigParseFileMulti(const char *fname, cmd_config_section **res) {
150 return krb5_config_parse_file_multi(NULL, fname, res);
154 cmd_RawConfigParseFile(const char *fname, cmd_config_section **res) {
155 return krb5_config_parse_file(NULL, fname, res);
159 cmd_RawConfigFileFree(cmd_config_section *s) {
160 return krb5_config_file_free(NULL, s);
163 const char*
164 cmd_RawConfigGetString(const cmd_config_section *c,
165 const char *defval, ...)
167 const char *ret;
168 va_list args;
170 assert(c != NULL);
172 va_start(args, defval);
173 ret = krb5_config_vget_string_default (NULL, c, defval, args);
174 va_end(args);
175 return ret;
179 cmd_RawConfigGetBool(const cmd_config_section *c, int defval, ...)
181 va_list ap;
182 krb5_boolean ret;
184 assert(c != NULL);
186 va_start(ap, defval);
187 ret = krb5_config_vget_bool_default (NULL, c, defval, ap);
188 va_end(ap);
189 return ret;
193 cmd_RawConfigGetInt(const cmd_config_section *c, int defval, ...)
195 va_list ap;
196 int ret;
198 assert(c != NULL);
200 va_start(ap, defval);
201 ret = krb5_config_vget_int_default (NULL, c, defval, ap);
202 va_end(ap);
203 return ret;
206 const cmd_config_binding *
207 cmd_RawConfigGetList(const cmd_config_section *c, ...)
209 va_list ap;
210 const cmd_config_binding *ret;
212 assert(c != NULL);
214 va_start(ap, c);
215 ret = krb5_config_vget_list (NULL, c, ap);
216 va_end(ap);
218 return ret;
220 #endif