profile.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /*
  2. * profile.h
  3. */
  4. #ifndef _KRB5_PROFILE_H
  5. #define _KRB5_PROFILE_H
  6. #if defined(_WIN32)
  7. #include <win-mac.h>
  8. #endif
  9. #if defined(__MACH__) && defined(__APPLE__)
  10. # include <TargetConditionals.h>
  11. # if TARGET_RT_MAC_CFM
  12. # error "Use KfM 4.0 SDK headers for CFM compilation."
  13. # endif
  14. #endif
  15. #ifndef KRB5_CALLCONV
  16. #define KRB5_CALLCONV
  17. #define KRB5_CALLCONV_C
  18. #endif
  19. typedef struct _profile_t *profile_t;
  20. /* Used by profile_init_flags(). */
  21. #define PROFILE_INIT_ALLOW_MODULE 0x0001 /* Allow module declaration */
  22. /*
  23. * Used by the profile iterator in prof_get.c
  24. */
  25. #define PROFILE_ITER_LIST_SECTION 0x0001
  26. #define PROFILE_ITER_SECTIONS_ONLY 0x0002
  27. #define PROFILE_ITER_RELATIONS_ONLY 0x0004
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif /* __cplusplus */
  31. typedef char* profile_filespec_t; /* path as C string */
  32. typedef char* profile_filespec_list_t; /* list of : separated paths, C string */
  33. typedef const char * const_profile_filespec_t; /* path as C string */
  34. typedef const char * const_profile_filespec_list_t; /* list of : separated paths, C string */
  35. long KRB5_CALLCONV profile_init
  36. (const_profile_filespec_t *files, profile_t *ret_profile);
  37. long KRB5_CALLCONV profile_init_flags
  38. (const_profile_filespec_t *files, int flags, profile_t *ret_profile);
  39. long KRB5_CALLCONV profile_init_path
  40. (const_profile_filespec_list_t filelist, profile_t *ret_profile);
  41. long KRB5_CALLCONV profile_flush
  42. (profile_t profile);
  43. long KRB5_CALLCONV profile_flush_to_file
  44. (profile_t profile, const_profile_filespec_t outfile);
  45. long KRB5_CALLCONV profile_flush_to_buffer
  46. (profile_t profile, char **bufp);
  47. void KRB5_CALLCONV profile_free_buffer
  48. (profile_t profile, char *buf);
  49. long KRB5_CALLCONV profile_is_writable
  50. (profile_t profile, int *writable);
  51. long KRB5_CALLCONV profile_is_modified
  52. (profile_t profile, int *modified);
  53. void KRB5_CALLCONV profile_abandon
  54. (profile_t profile);
  55. void KRB5_CALLCONV profile_release
  56. (profile_t profile);
  57. long KRB5_CALLCONV profile_get_values
  58. (profile_t profile, const char *const *names, char ***ret_values);
  59. void KRB5_CALLCONV profile_free_list
  60. (char **list);
  61. long KRB5_CALLCONV profile_get_string
  62. (profile_t profile, const char *name, const char *subname,
  63. const char *subsubname, const char *def_val,
  64. char **ret_string);
  65. long KRB5_CALLCONV profile_get_integer
  66. (profile_t profile, const char *name, const char *subname,
  67. const char *subsubname, int def_val,
  68. int *ret_default);
  69. long KRB5_CALLCONV profile_get_boolean
  70. (profile_t profile, const char *name, const char *subname,
  71. const char *subsubname, int def_val,
  72. int *ret_default);
  73. long KRB5_CALLCONV profile_get_relation_names
  74. (profile_t profile, const char **names, char ***ret_names);
  75. long KRB5_CALLCONV profile_get_subsection_names
  76. (profile_t profile, const char **names, char ***ret_names);
  77. long KRB5_CALLCONV profile_iterator_create
  78. (profile_t profile, const char *const *names,
  79. int flags, void **ret_iter);
  80. void KRB5_CALLCONV profile_iterator_free
  81. (void **iter_p);
  82. long KRB5_CALLCONV profile_iterator
  83. (void **iter_p, char **ret_name, char **ret_value);
  84. void KRB5_CALLCONV profile_release_string (char *str);
  85. long KRB5_CALLCONV profile_update_relation
  86. (profile_t profile, const char **names,
  87. const char *old_value, const char *new_value);
  88. long KRB5_CALLCONV profile_clear_relation
  89. (profile_t profile, const char **names);
  90. long KRB5_CALLCONV profile_rename_section
  91. (profile_t profile, const char **names,
  92. const char *new_name);
  93. long KRB5_CALLCONV profile_add_relation
  94. (profile_t profile, const char **names,
  95. const char *new_value);
  96. /*
  97. * profile_init_vtable allows a caller to create a profile-compatible object
  98. * with a different back end.
  99. */
  100. /*
  101. * Mandatory: Look up all of the relations for names, placing the resulting
  102. * values in *ret_values. If no relations exist, return PROF_NO_RELATION, or
  103. * PROF_NO_SECTION to indicate that one of the intermediate names does not
  104. * exist as a section. The list will be freed with free_values.
  105. */
  106. typedef long
  107. (*profile_get_values_fn)(void *cbdata, const char *const *names,
  108. char ***ret_values);
  109. /* Mandatory: Free a list of strings returned by get_values. */
  110. typedef void
  111. (*profile_free_values_fn)(void *cbdata, char **values);
  112. /* Optional: Release any data associated with the profile. */
  113. typedef void
  114. (*profile_cleanup_fn)(void *cbdata);
  115. /*
  116. * Optional (mandatory if cleanup is defined): Generate a new cbdata pointer
  117. * for a copy of the profile. If not implemented, the new profile will receive
  118. * the same cbdata pointer as the old one.
  119. */
  120. typedef long
  121. (*profile_copy_fn)(void *cbdata, void **ret_cbdata);
  122. /*
  123. * Optional: Create an iterator handle.
  124. *
  125. * If flags contains PROFILE_ITER_LIST_SECTION, iterate over all of the
  126. * relations and sections within names. Otherwise, iterate over the relation
  127. * values for names, or produce a single section result if names is a section.
  128. *
  129. * If flags contains PROFILE_ITER_SECTIONS_ONLY, produce only sections.
  130. *
  131. * If flags contains PROFILE_ITER_RELATIONS_ONLY, produce only relations.
  132. */
  133. typedef long
  134. (*profile_iterator_create_fn)(void *cbdata, const char *const *names,
  135. int flags, void **ret_iter);
  136. /*
  137. * Optional (mandatory if iterator_create is defined): Produce the next
  138. * relation or section in an iteration. If producing a section result, set
  139. * *ret_value to NULL. The returned strings will be freed with free_string.
  140. */
  141. typedef long
  142. (*profile_iterator_fn)(void *cbdata, void *iter, char **ret_name,
  143. char **ret_value);
  144. /*
  145. * Optional (mandatory if iterator_create is defined): Free the memory for an
  146. * iterator.
  147. */
  148. typedef void
  149. (*profile_iterator_free_fn)(void *cbdata, void *iter);
  150. /* Optional (mandatory if iterator is defined): Free a string value. */
  151. typedef void
  152. (*profile_free_string_fn)(void *cbdata, char *string);
  153. /*
  154. * Optional: Determine if a profile is writable. If not implemented, the
  155. * profile is never writable.
  156. */
  157. typedef long
  158. (*profile_writable_fn)(void *cbdata, int *writable);
  159. /*
  160. * Optional: Determine if a profile is modified in memory relative to the
  161. * persistent store. If not implemented, the profile is assumed to never be
  162. * modified.
  163. */
  164. typedef long
  165. (*profile_modified_fn)(void *cbdata, int *modified);
  166. /*
  167. * Optional: Change the value of a relation, or remove it if new_value is NULL.
  168. * If old_value is set and the relation does not have that value, return
  169. * PROF_NO_RELATION.
  170. */
  171. typedef long
  172. (*profile_update_relation_fn)(void *cbdata, const char **names,
  173. const char *old_value, const char *new_value);
  174. /*
  175. * Optional: Rename a section to new_name, or remove the section if new_name is
  176. * NULL.
  177. */
  178. typedef long
  179. (*profile_rename_section_fn)(void *cbdata, const char **names,
  180. const char *new_name);
  181. /*
  182. * Optional: Add a new relation, or a new section if new_value is NULL. Add
  183. * any intermediate sections as necessary.
  184. */
  185. typedef long
  186. (*profile_add_relation_fn)(void *cbdata, const char **names,
  187. const char *new_value);
  188. /*
  189. * Optional: Flush any pending memory updates to the persistent store. If
  190. * implemented, this function will be called by profile_release as well as
  191. * profile_flush, so make sure it's not inefficient to flush an unmodified
  192. * profile.
  193. */
  194. typedef long
  195. (*profile_flush_fn)(void *cbdata);
  196. struct profile_vtable {
  197. int minor_ver; /* Set to structure minor version (currently 1)
  198. * if calling profile_init_vtable. */
  199. /* Methods needed for a basic read-only non-iterable profile (cleanup is
  200. * optional). */
  201. profile_get_values_fn get_values;
  202. profile_free_values_fn free_values;
  203. profile_cleanup_fn cleanup;
  204. profile_copy_fn copy;
  205. /* Methods for iterable profiles. */
  206. profile_iterator_create_fn iterator_create;
  207. profile_iterator_fn iterator;
  208. profile_iterator_free_fn iterator_free;
  209. profile_free_string_fn free_string;
  210. /* Methods for writable profiles. */
  211. profile_writable_fn writable;
  212. profile_modified_fn modified;
  213. profile_update_relation_fn update_relation;
  214. profile_rename_section_fn rename_section;
  215. profile_add_relation_fn add_relation;
  216. profile_flush_fn flush;
  217. /* End of minor version 1. */
  218. };
  219. /*
  220. * Create a profile object whose operations will be performed using the
  221. * function pointers in vtable. cbdata will be supplied to each vtable
  222. * function as the first argument.
  223. */
  224. long KRB5_CALLCONV profile_init_vtable
  225. (struct profile_vtable *vtable, void *cbdata, profile_t *ret_profile);
  226. /*
  227. * Dynamically loadable profile modules should define a function named
  228. * "profile_module_init" matching the following signature. The function should
  229. * initialize the methods of the provided vtable structure, stopping at the
  230. * field corresponding to vtable->minor_ver. Do not change the value of
  231. * vtable->minor_ver. Unimplemented methods can be left uninitialized. The
  232. * function should supply a callback data pointer in *cb_ret; this pointer can
  233. * be cleaned up via the vtable cleanup method.
  234. */
  235. typedef long
  236. (*profile_module_init_fn)(const char *residual, struct profile_vtable *vtable,
  237. void **cb_ret);
  238. #ifdef __cplusplus
  239. }
  240. #endif /* __cplusplus */
  241. #endif /* _KRB5_PROFILE_H */
  242. /*
  243. * et-h-prof_err.h:
  244. * This file is automatically generated; please do not edit it.
  245. */
  246. #include <com_err.h>
  247. #define PROF_VERSION (-1429577728L)
  248. #define PROF_MAGIC_NODE (-1429577727L)
  249. #define PROF_NO_SECTION (-1429577726L)
  250. #define PROF_NO_RELATION (-1429577725L)
  251. #define PROF_ADD_NOT_SECTION (-1429577724L)
  252. #define PROF_SECTION_WITH_VALUE (-1429577723L)
  253. #define PROF_BAD_LINK_LIST (-1429577722L)
  254. #define PROF_BAD_GROUP_LVL (-1429577721L)
  255. #define PROF_BAD_PARENT_PTR (-1429577720L)
  256. #define PROF_MAGIC_ITERATOR (-1429577719L)
  257. #define PROF_SET_SECTION_VALUE (-1429577718L)
  258. #define PROF_EINVAL (-1429577717L)
  259. #define PROF_READ_ONLY (-1429577716L)
  260. #define PROF_SECTION_NOTOP (-1429577715L)
  261. #define PROF_SECTION_SYNTAX (-1429577714L)
  262. #define PROF_RELATION_SYNTAX (-1429577713L)
  263. #define PROF_EXTRA_CBRACE (-1429577712L)
  264. #define PROF_MISSING_OBRACE (-1429577711L)
  265. #define PROF_MAGIC_PROFILE (-1429577710L)
  266. #define PROF_MAGIC_SECTION (-1429577709L)
  267. #define PROF_TOPSECTION_ITER_NOSUPP (-1429577708L)
  268. #define PROF_INVALID_SECTION (-1429577707L)
  269. #define PROF_END_OF_SECTIONS (-1429577706L)
  270. #define PROF_BAD_NAMESET (-1429577705L)
  271. #define PROF_NO_PROFILE (-1429577704L)
  272. #define PROF_MAGIC_FILE (-1429577703L)
  273. #define PROF_FAIL_OPEN (-1429577702L)
  274. #define PROF_EXISTS (-1429577701L)
  275. #define PROF_BAD_BOOLEAN (-1429577700L)
  276. #define PROF_BAD_INTEGER (-1429577699L)
  277. #define PROF_MAGIC_FILE_DATA (-1429577698L)
  278. #define PROF_FAIL_INCLUDE_FILE (-1429577697L)
  279. #define PROF_FAIL_INCLUDE_DIR (-1429577696L)
  280. #define PROF_UNSUPPORTED (-1429577695L)
  281. #define PROF_MAGIC_NODE_ITERATOR (-1429577694L)
  282. #define PROF_MODULE (-1429577693L)
  283. #define PROF_MODULE_SYNTAX (-1429577692L)
  284. #define PROF_MODULE_INVALID (-1429577691L)
  285. #define ERROR_TABLE_BASE_prof (-1429577728L)
  286. extern const struct error_table et_prof_error_table;
  287. #if !defined(_WIN32)
  288. /* for compatibility with older versions... */
  289. extern void initialize_prof_error_table (void) /*@modifies internalState@*/;
  290. #else
  291. #define initialize_prof_error_table()
  292. #endif
  293. #if !defined(_WIN32)
  294. #define init_prof_err_tbl initialize_prof_error_table
  295. #define prof_err_base ERROR_TABLE_BASE_prof
  296. #endif