conf.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef HEADER_CONF_H
  10. # define HEADER_CONF_H
  11. # include <openssl/bio.h>
  12. # include <openssl/lhash.h>
  13. # include <openssl/safestack.h>
  14. # include <openssl/e_os2.h>
  15. # include <openssl/ossl_typ.h>
  16. # include <openssl/conferr.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef struct {
  21. char *section;
  22. char *name;
  23. char *value;
  24. } CONF_VALUE;
  25. DEFINE_STACK_OF(CONF_VALUE)
  26. DEFINE_LHASH_OF(CONF_VALUE);
  27. struct conf_st;
  28. struct conf_method_st;
  29. typedef struct conf_method_st CONF_METHOD;
  30. struct conf_method_st {
  31. const char *name;
  32. CONF *(*create) (CONF_METHOD *meth);
  33. int (*init) (CONF *conf);
  34. int (*destroy) (CONF *conf);
  35. int (*destroy_data) (CONF *conf);
  36. int (*load_bio) (CONF *conf, BIO *bp, long *eline);
  37. int (*dump) (const CONF *conf, BIO *bp);
  38. int (*is_number) (const CONF *conf, char c);
  39. int (*to_int) (const CONF *conf, char c);
  40. int (*load) (CONF *conf, const char *name, long *eline);
  41. };
  42. /* Module definitions */
  43. typedef struct conf_imodule_st CONF_IMODULE;
  44. typedef struct conf_module_st CONF_MODULE;
  45. DEFINE_STACK_OF(CONF_MODULE)
  46. DEFINE_STACK_OF(CONF_IMODULE)
  47. /* DSO module function typedefs */
  48. typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);
  49. typedef void conf_finish_func (CONF_IMODULE *md);
  50. # define CONF_MFLAGS_IGNORE_ERRORS 0x1
  51. # define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2
  52. # define CONF_MFLAGS_SILENT 0x4
  53. # define CONF_MFLAGS_NO_DSO 0x8
  54. # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
  55. # define CONF_MFLAGS_DEFAULT_SECTION 0x20
  56. int CONF_set_default_method(CONF_METHOD *meth);
  57. void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);
  58. LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
  59. long *eline);
  60. # ifndef OPENSSL_NO_STDIO
  61. LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
  62. long *eline);
  63. # endif
  64. LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,
  65. long *eline);
  66. STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,
  67. const char *section);
  68. char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,
  69. const char *name);
  70. long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,
  71. const char *name);
  72. void CONF_free(LHASH_OF(CONF_VALUE) *conf);
  73. #ifndef OPENSSL_NO_STDIO
  74. int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);
  75. #endif
  76. int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
  77. DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))
  78. #if OPENSSL_API_COMPAT < 0x10100000L
  79. # define OPENSSL_no_config() \
  80. OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)
  81. #endif
  82. /*
  83. * New conf code. The semantics are different from the functions above. If
  84. * that wasn't the case, the above functions would have been replaced
  85. */
  86. struct conf_st {
  87. CONF_METHOD *meth;
  88. void *meth_data;
  89. LHASH_OF(CONF_VALUE) *data;
  90. };
  91. CONF *NCONF_new(CONF_METHOD *meth);
  92. CONF_METHOD *NCONF_default(void);
  93. CONF_METHOD *NCONF_WIN32(void);
  94. void NCONF_free(CONF *conf);
  95. void NCONF_free_data(CONF *conf);
  96. int NCONF_load(CONF *conf, const char *file, long *eline);
  97. # ifndef OPENSSL_NO_STDIO
  98. int NCONF_load_fp(CONF *conf, FILE *fp, long *eline);
  99. # endif
  100. int NCONF_load_bio(CONF *conf, BIO *bp, long *eline);
  101. STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,
  102. const char *section);
  103. char *NCONF_get_string(const CONF *conf, const char *group, const char *name);
  104. int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
  105. long *result);
  106. #ifndef OPENSSL_NO_STDIO
  107. int NCONF_dump_fp(const CONF *conf, FILE *out);
  108. #endif
  109. int NCONF_dump_bio(const CONF *conf, BIO *out);
  110. #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)
  111. /* Module functions */
  112. int CONF_modules_load(const CONF *cnf, const char *appname,
  113. unsigned long flags);
  114. int CONF_modules_load_file(const char *filename, const char *appname,
  115. unsigned long flags);
  116. void CONF_modules_unload(int all);
  117. void CONF_modules_finish(void);
  118. #if OPENSSL_API_COMPAT < 0x10100000L
  119. # define CONF_modules_free() while(0) continue
  120. #endif
  121. int CONF_module_add(const char *name, conf_init_func *ifunc,
  122. conf_finish_func *ffunc);
  123. const char *CONF_imodule_get_name(const CONF_IMODULE *md);
  124. const char *CONF_imodule_get_value(const CONF_IMODULE *md);
  125. void *CONF_imodule_get_usr_data(const CONF_IMODULE *md);
  126. void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);
  127. CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);
  128. unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);
  129. void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);
  130. void *CONF_module_get_usr_data(CONF_MODULE *pmod);
  131. void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
  132. char *CONF_get1_default_config_file(void);
  133. int CONF_parse_list(const char *list, int sep, int nospc,
  134. int (*list_cb) (const char *elem, int len, void *usr),
  135. void *arg);
  136. void OPENSSL_load_builtin_modules(void);
  137. # ifdef __cplusplus
  138. }
  139. # endif
  140. #endif