1 1.1 christos /* 2 1.1 christos * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos #include <stdio.h> 11 1.1 christos #include <string.h> 12 1.1 christos #include <openssl/bio.h> 13 1.1 christos #include <openssl/conf.h> 14 1.1 christos #include <openssl/safestack.h> 15 1.1 christos #include <openssl/err.h> 16 1.1 christos 17 1.1 christos static void dump_section(const char *name, const CONF *cnf) 18 1.1 christos { 19 1.1 christos STACK_OF(CONF_VALUE) *sect = NCONF_get_section(cnf, name); 20 1.1 christos int i; 21 1.1 christos 22 1.1 christos printf("[ %s ]\n", name); 23 1.1 christos for (i = 0; i < sk_CONF_VALUE_num(sect); i++) { 24 1.1 christos CONF_VALUE *cv = sk_CONF_VALUE_value(sect, i); 25 1.1 christos 26 1.1 christos printf("%s = %s\n", cv->name, cv->value); 27 1.1 christos } 28 1.1 christos } 29 1.1 christos 30 1.1 christos int main(int argc, char **argv) 31 1.1 christos { 32 1.1 christos long eline; 33 1.1 christos CONF *conf = NCONF_new(NCONF_default()); 34 1.1 christos int ret = 1; 35 1.1 christos STACK_OF(OPENSSL_CSTRING) *section_names = NULL; 36 1.1 christos 37 1.1 christos if (conf != NULL && NCONF_load(conf, argv[1], &eline)) { 38 1.1 christos int i; 39 1.1 christos 40 1.1 christos section_names = NCONF_get_section_names(conf); 41 1.1 christos for (i = 0; i < sk_OPENSSL_CSTRING_num(section_names); i++) { 42 1.1 christos dump_section(sk_OPENSSL_CSTRING_value(section_names, i), conf); 43 1.1 christos } 44 1.1 christos sk_OPENSSL_CSTRING_free(section_names); 45 1.1 christos ret = 0; 46 1.1 christos } else { 47 1.1 christos ERR_print_errors_fp(stderr); 48 1.1 christos } 49 1.1 christos NCONF_free(conf); 50 1.1 christos return ret; 51 1.1 christos } 52