1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos NCONF_new_ex, NCONF_new, NCONF_free, NCONF_default, NCONF_load, 6 1.1 christos NCONF_get0_libctx, NCONF_get_section, NCONF_get_section_names 7 1.1 christos - functionality to Load and parse configuration files manually 8 1.1 christos 9 1.1 christos =head1 SYNOPSIS 10 1.1 christos 11 1.1 christos #include <openssl/conf.h> 12 1.1 christos 13 1.1 christos typedef struct { 14 1.1 christos char *section; 15 1.1 christos char *name; 16 1.1 christos char *value; 17 1.1 christos } CONF_VALUE; 18 1.1 christos 19 1.1 christos CONF *NCONF_new_ex(OSSL_LIB_CTX *libctx, CONF_METHOD *meth); 20 1.1 christos CONF *NCONF_new(CONF_METHOD *meth); 21 1.1 christos void NCONF_free(CONF *conf); 22 1.1 christos CONF_METHOD *NCONF_default(void); 23 1.1 christos int NCONF_load(CONF *conf, const char *file, long *eline); 24 1.1 christos OSSL_LIB_CTX *NCONF_get0_libctx(const CONF *conf); 25 1.1 christos 26 1.1 christos STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *name); 27 1.1 christos STACK_OF(OPENSSL_CSTRING) *NCONF_get_section_names(const CONF *conf); 28 1.1 christos 29 1.1 christos =head1 DESCRIPTION 30 1.1 christos 31 1.1 christos NCONF_new_ex() creates a new CONF object in heap memory and assigns to 32 1.1 christos it a context I<libctx> that can be used during loading. If the method table 33 1.1 christos I<meth> is set to NULL then the default value of NCONF_default() is used. 34 1.1 christos 35 1.1 christos NCONF_new() is similar to NCONF_new_ex() but sets the I<libctx> to NULL. 36 1.1 christos 37 1.1 christos NCONF_free() frees the data associated with I<conf> and then frees the I<conf> 38 1.1.1.2 christos object. If the argument is NULL, nothing is done. 39 1.1 christos 40 1.1 christos NCONF_load() parses the file named I<filename> and adds the values found to 41 1.1 christos I<conf>. If an error occurs I<file> and I<eline> list the file and line that 42 1.1 christos the load failed on if they are not NULL. 43 1.1 christos 44 1.1 christos NCONF_default() gets the default method table for processing a configuration file. 45 1.1 christos 46 1.1 christos NCONF_get0_libctx() gets the library context associated with the I<conf> 47 1.1 christos parameter. 48 1.1 christos 49 1.1 christos NCONF_get_section_names() gets the names of the sections associated with 50 1.1 christos the I<conf> as B<STACK_OF(OPENSSL_CSTRING)> strings. The individual strings 51 1.1 christos are associated with the I<conf> and will be invalid after I<conf> is 52 1.1 christos freed. The returned stack must be freed with sk_OPENSSL_CSTRING_free(). 53 1.1 christos 54 1.1 christos NCONF_get_section() gets the config values associated with the I<conf> from 55 1.1 christos the config section I<name> as B<STACK_OF(CONF_VALUE)> structures. The returned 56 1.1 christos stack is associated with the I<conf> and will be invalid after I<conf> 57 1.1 christos is freed. It must not be freed by the caller. 58 1.1 christos 59 1.1 christos =head1 RETURN VALUES 60 1.1 christos 61 1.1 christos NCONF_load() returns 1 on success or 0 on error. 62 1.1 christos 63 1.1 christos NCONF_new_ex() and NCONF_new() return a newly created I<CONF> object 64 1.1 christos or NULL if an error occurs. 65 1.1 christos 66 1.1 christos =head1 SEE ALSO 67 1.1 christos 68 1.1 christos L<CONF_modules_load_file(3)>, 69 1.1 christos 70 1.1 christos =head1 HISTORY 71 1.1 christos 72 1.1 christos NCONF_new_ex(), NCONF_get0_libctx(), and NCONF_get_section_names() were added 73 1.1 christos in OpenSSL 3.0. 74 1.1 christos 75 1.1 christos =head1 COPYRIGHT 76 1.1 christos 77 1.1.1.2 christos Copyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved. 78 1.1 christos 79 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 80 1.1 christos this file except in compliance with the License. You can obtain a copy 81 1.1 christos in the file LICENSE in the source distribution or at 82 1.1 christos L<https://www.openssl.org/source/license.html>. 83 1.1 christos 84 1.1 christos =cut 85