8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / gss_mechs / mech_krb5 / profile / prof_int.h
blob95c84b9659943b2e13ced65fe608ce47b6b07dd2
1 /*
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
3 */
5 /*
6 * prof-int.h
7 */
9 /* Solaris Kerberos */
10 #ifndef __PROF_INT_H
11 #define __PROF_INT_H
13 #include <time.h>
14 #include <stdio.h>
16 #if defined(__MACH__) && defined(__APPLE__)
17 #include <TargetConditionals.h>
18 #define PROFILE_SUPPORTS_FOREIGN_NEWLINES
19 #endif
21 #include "k5-thread.h"
22 #include "k5-platform.h"
23 #include "com_err.h"
24 #include "profile.h"
26 typedef long prf_magic_t;
29 * This is the structure which stores the profile information for a
30 * particular configuration file.
32 * Locking strategy:
33 * - filespec, fslen are fixed after creation
34 * - refcount and next should only be tweaked with the global lock held
35 * - other fields can be tweaked after grabbing the in-struct lock
37 struct _prf_data_t {
38 prf_magic_t magic;
39 k5_mutex_t lock;
40 struct profile_node *root;
41 time_t last_stat;
42 time_t timestamp; /* time tree was last updated from file */
43 unsigned long frac_ts; /* fractional part of timestamp, if any */
44 int flags; /* r/w, dirty */
45 int upd_serial; /* incremented when data changes */
46 char *comment;
48 size_t fslen;
50 /* Some separation between fields controlled by different
51 mutexes. Theoretically, both could be accessed at the same
52 time from different threads on different CPUs with separate
53 caches. Don't let the threads clobber each other's
54 changes. One mutex controlling the whole thing would be
55 better, but sufficient separation might suffice.
57 This is icky. I just hope it's adequate.
59 For next major release, fix this. */
60 union { double d; void *p; UINT64_TYPE ll; k5_mutex_t m; } pad;
62 int refcount; /* prf_file_t references */
63 struct _prf_data_t *next;
64 /* Was: "profile_filespec_t filespec". Now: flexible char
65 array ... except, we need to work in C89, so an array
66 length must be specified. */
67 const char filespec[sizeof("/etc/krb5.conf")];
70 typedef struct _prf_data_t *prf_data_t;
71 prf_data_t profile_make_prf_data(const char *);
73 struct _prf_file_t {
74 prf_magic_t magic;
75 struct _prf_data_t *data;
76 struct _prf_file_t *next;
79 typedef struct _prf_file_t *prf_file_t;
82 * The profile flags
84 #define PROFILE_FILE_RW 0x0001
85 #define PROFILE_FILE_DIRTY 0x0002
86 #define PROFILE_FILE_SHARED 0x0004
89 * This structure defines the high-level, user visible profile_t
90 * object, which is used as a handle by users who need to query some
91 * configuration file(s)
93 struct _profile_t {
94 prf_magic_t magic;
95 prf_file_t first_file;
98 typedef struct _profile_options {
99 char *name;
100 int *value;
101 int found;
102 } profile_options_boolean;
104 typedef struct _profile_times {
105 char *name;
106 char **value;
107 int found;
108 } profile_option_strings;
111 * Solaris Kerberos: Added here to provide to other non-prof_get functions.
112 * The profile_string_list structure is used for internal booking
113 * purposes to build up the list, which is returned in *ret_list by
114 * the end_list() function.
116 struct profile_string_list {
117 char **list;
118 int num;
119 int max;
123 * Used by the profile iterator in prof_get.c
125 #define PROFILE_ITER_LIST_SECTION 0x0001
126 #define PROFILE_ITER_SECTIONS_ONLY 0x0002
127 #define PROFILE_ITER_RELATIONS_ONLY 0x0004
129 #define PROFILE_ITER_FINAL_SEEN 0x0100
132 * Check if a filespec is last in a list (NULL on UNIX, invalid FSSpec on MacOS
135 #define PROFILE_LAST_FILESPEC(x) (((x) == NULL) || ((x)[0] == '\0'))
137 /* profile_parse.c */
139 errcode_t profile_parse_file
140 (FILE *f, struct profile_node **root);
142 errcode_t profile_write_tree_file
143 (struct profile_node *root, FILE *dstfile);
145 errcode_t profile_write_tree_to_buffer
146 (struct profile_node *root, char **buf);
149 /* prof_tree.c */
151 void profile_free_node
152 (struct profile_node *relation);
154 errcode_t profile_create_node
155 (const char *name, const char *value,
156 struct profile_node **ret_node);
158 errcode_t profile_verify_node
159 (struct profile_node *node);
161 errcode_t profile_add_node
162 (struct profile_node *section,
163 const char *name, const char *value,
164 struct profile_node **ret_node);
166 errcode_t profile_make_node_final
167 (struct profile_node *node);
169 int profile_is_node_final
170 (struct profile_node *node);
172 const char *profile_get_node_name
173 (struct profile_node *node);
175 const char *profile_get_node_value
176 (struct profile_node *node);
178 errcode_t profile_find_node
179 (struct profile_node *section,
180 const char *name, const char *value,
181 int section_flag, void **state,
182 struct profile_node **node);
184 errcode_t profile_find_node_relation
185 (struct profile_node *section,
186 const char *name, void **state,
187 char **ret_name, char **value);
189 errcode_t profile_find_node_subsection
190 (struct profile_node *section,
191 const char *name, void **state,
192 char **ret_name, struct profile_node **subsection);
194 errcode_t profile_get_node_parent
195 (struct profile_node *section,
196 struct profile_node **parent);
198 errcode_t profile_delete_node_relation
199 (struct profile_node *section, const char *name);
201 errcode_t profile_find_node_name
202 (struct profile_node *section, void **state,
203 char **ret_name);
205 errcode_t profile_node_iterator_create
206 (profile_t profile, const char *const *names,
207 int flags, void **ret_iter);
209 void profile_node_iterator_free
210 (void **iter_p);
212 errcode_t profile_node_iterator
213 (void **iter_p, struct profile_node **ret_node,
214 char **ret_name, char **ret_value);
216 errcode_t profile_remove_node
217 (struct profile_node *node);
219 errcode_t profile_set_relation_value
220 (struct profile_node *node, const char *new_value);
222 errcode_t profile_rename_node
223 (struct profile_node *node, const char *new_name);
225 /* prof_file.c */
227 errcode_t KRB5_CALLCONV profile_copy (profile_t, profile_t *);
229 errcode_t profile_open_file
230 (const_profile_filespec_t file, prf_file_t *ret_prof);
232 #define profile_update_file(P) profile_update_file_data((P)->data)
233 errcode_t profile_update_file_data
234 (prf_data_t profile);
236 #define profile_flush_file(P) (((P) && (P)->magic == PROF_MAGIC_FILE) ? profile_flush_file_data((P)->data) : PROF_MAGIC_FILE)
237 errcode_t profile_flush_file_data
238 (prf_data_t data);
240 #define profile_flush_file_to_file(P,F) (((P) && (P)->magic == PROF_MAGIC_FILE) ? profile_flush_file_data_to_file((P)->data, (F)) : PROF_MAGIC_FILE)
241 errcode_t profile_flush_file_data_to_file
242 (prf_data_t data, const char *outfile);
244 errcode_t profile_flush_file_data_to_buffer
245 (prf_data_t data, char **bufp);
247 void profile_free_file
248 (prf_file_t profile);
250 errcode_t profile_close_file
251 (prf_file_t profile);
253 void profile_dereference_data (prf_data_t);
254 void profile_dereference_data_locked (prf_data_t);
256 int profile_lock_global (void);
257 int profile_unlock_global (void);
259 /* prof_init.c -- included from profile.h */
260 errcode_t profile_ser_size
261 (const char *, profile_t, size_t *);
263 errcode_t profile_ser_externalize
264 (const char *, profile_t, unsigned char **, size_t *);
266 errcode_t profile_ser_internalize
267 (const char *, profile_t *, unsigned char **, size_t *);
269 /* prof_get.c */
271 errcode_t profile_get_value
272 (profile_t profile, const char **names,
273 const char **ret_value);
276 * Solaris Kerberos: Need basic routines for other functions besides prof_get.
278 errcode_t init_list(struct profile_string_list *list);
279 void end_list(struct profile_string_list *list, char ***ret_list);
280 errcode_t add_to_list(struct profile_string_list *list, const char *str);
282 /* Others included from profile.h */
284 /* prof_set.c -- included from profile.h */
286 /* Solaris Kerberos */
287 #endif /* __PROF_INT_H */