jpayne@69: /* jpayne@69: * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. jpayne@69: * jpayne@69: * Licensed under the OpenSSL license (the "License"). You may not use jpayne@69: * this file except in compliance with the License. You can obtain a copy jpayne@69: * in the file LICENSE in the source distribution or at jpayne@69: * https://www.openssl.org/source/license.html jpayne@69: */ jpayne@69: jpayne@69: #ifndef HEADER_CONF_H jpayne@69: # define HEADER_CONF_H jpayne@69: jpayne@69: # include jpayne@69: # include jpayne@69: # include jpayne@69: # include jpayne@69: # include jpayne@69: # include jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: typedef struct { jpayne@69: char *section; jpayne@69: char *name; jpayne@69: char *value; jpayne@69: } CONF_VALUE; jpayne@69: jpayne@69: DEFINE_STACK_OF(CONF_VALUE) jpayne@69: DEFINE_LHASH_OF(CONF_VALUE); jpayne@69: jpayne@69: struct conf_st; jpayne@69: struct conf_method_st; jpayne@69: typedef struct conf_method_st CONF_METHOD; jpayne@69: jpayne@69: struct conf_method_st { jpayne@69: const char *name; jpayne@69: CONF *(*create) (CONF_METHOD *meth); jpayne@69: int (*init) (CONF *conf); jpayne@69: int (*destroy) (CONF *conf); jpayne@69: int (*destroy_data) (CONF *conf); jpayne@69: int (*load_bio) (CONF *conf, BIO *bp, long *eline); jpayne@69: int (*dump) (const CONF *conf, BIO *bp); jpayne@69: int (*is_number) (const CONF *conf, char c); jpayne@69: int (*to_int) (const CONF *conf, char c); jpayne@69: int (*load) (CONF *conf, const char *name, long *eline); jpayne@69: }; jpayne@69: jpayne@69: /* Module definitions */ jpayne@69: jpayne@69: typedef struct conf_imodule_st CONF_IMODULE; jpayne@69: typedef struct conf_module_st CONF_MODULE; jpayne@69: jpayne@69: DEFINE_STACK_OF(CONF_MODULE) jpayne@69: DEFINE_STACK_OF(CONF_IMODULE) jpayne@69: jpayne@69: /* DSO module function typedefs */ jpayne@69: typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); jpayne@69: typedef void conf_finish_func (CONF_IMODULE *md); jpayne@69: jpayne@69: # define CONF_MFLAGS_IGNORE_ERRORS 0x1 jpayne@69: # define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 jpayne@69: # define CONF_MFLAGS_SILENT 0x4 jpayne@69: # define CONF_MFLAGS_NO_DSO 0x8 jpayne@69: # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 jpayne@69: # define CONF_MFLAGS_DEFAULT_SECTION 0x20 jpayne@69: jpayne@69: int CONF_set_default_method(CONF_METHOD *meth); jpayne@69: void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); jpayne@69: LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, jpayne@69: long *eline); jpayne@69: # ifndef OPENSSL_NO_STDIO jpayne@69: LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, jpayne@69: long *eline); jpayne@69: # endif jpayne@69: LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, jpayne@69: long *eline); jpayne@69: STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, jpayne@69: const char *section); jpayne@69: char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, jpayne@69: const char *name); jpayne@69: long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, jpayne@69: const char *name); jpayne@69: void CONF_free(LHASH_OF(CONF_VALUE) *conf); jpayne@69: #ifndef OPENSSL_NO_STDIO jpayne@69: int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); jpayne@69: #endif jpayne@69: int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); jpayne@69: jpayne@69: DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) jpayne@69: jpayne@69: #if OPENSSL_API_COMPAT < 0x10100000L jpayne@69: # define OPENSSL_no_config() \ jpayne@69: OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * New conf code. The semantics are different from the functions above. If jpayne@69: * that wasn't the case, the above functions would have been replaced jpayne@69: */ jpayne@69: jpayne@69: struct conf_st { jpayne@69: CONF_METHOD *meth; jpayne@69: void *meth_data; jpayne@69: LHASH_OF(CONF_VALUE) *data; jpayne@69: }; jpayne@69: jpayne@69: CONF *NCONF_new(CONF_METHOD *meth); jpayne@69: CONF_METHOD *NCONF_default(void); jpayne@69: CONF_METHOD *NCONF_WIN32(void); jpayne@69: void NCONF_free(CONF *conf); jpayne@69: void NCONF_free_data(CONF *conf); jpayne@69: jpayne@69: int NCONF_load(CONF *conf, const char *file, long *eline); jpayne@69: # ifndef OPENSSL_NO_STDIO jpayne@69: int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); jpayne@69: # endif jpayne@69: int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); jpayne@69: STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, jpayne@69: const char *section); jpayne@69: char *NCONF_get_string(const CONF *conf, const char *group, const char *name); jpayne@69: int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, jpayne@69: long *result); jpayne@69: #ifndef OPENSSL_NO_STDIO jpayne@69: int NCONF_dump_fp(const CONF *conf, FILE *out); jpayne@69: #endif jpayne@69: int NCONF_dump_bio(const CONF *conf, BIO *out); jpayne@69: jpayne@69: #define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) jpayne@69: jpayne@69: /* Module functions */ jpayne@69: jpayne@69: int CONF_modules_load(const CONF *cnf, const char *appname, jpayne@69: unsigned long flags); jpayne@69: int CONF_modules_load_file(const char *filename, const char *appname, jpayne@69: unsigned long flags); jpayne@69: void CONF_modules_unload(int all); jpayne@69: void CONF_modules_finish(void); jpayne@69: #if OPENSSL_API_COMPAT < 0x10100000L jpayne@69: # define CONF_modules_free() while(0) continue jpayne@69: #endif jpayne@69: int CONF_module_add(const char *name, conf_init_func *ifunc, jpayne@69: conf_finish_func *ffunc); jpayne@69: jpayne@69: const char *CONF_imodule_get_name(const CONF_IMODULE *md); jpayne@69: const char *CONF_imodule_get_value(const CONF_IMODULE *md); jpayne@69: void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); jpayne@69: void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); jpayne@69: CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); jpayne@69: unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); jpayne@69: void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); jpayne@69: void *CONF_module_get_usr_data(CONF_MODULE *pmod); jpayne@69: void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); jpayne@69: jpayne@69: char *CONF_get1_default_config_file(void); jpayne@69: jpayne@69: int CONF_parse_list(const char *list, int sep, int nospc, jpayne@69: int (*list_cb) (const char *elem, int len, void *usr), jpayne@69: void *arg); jpayne@69: jpayne@69: void OPENSSL_load_builtin_modules(void); jpayne@69: jpayne@69: jpayne@69: # ifdef __cplusplus jpayne@69: } jpayne@69: # endif jpayne@69: #endif