diff options
Diffstat (limited to 'src/lib/libcrypto/conf/conf_lib.c')
| -rw-r--r-- | src/lib/libcrypto/conf/conf_lib.c | 126 |
1 files changed, 1 insertions, 125 deletions
diff --git a/src/lib/libcrypto/conf/conf_lib.c b/src/lib/libcrypto/conf/conf_lib.c index 4440cfe6fd..7d426d56b2 100644 --- a/src/lib/libcrypto/conf/conf_lib.c +++ b/src/lib/libcrypto/conf/conf_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: conf_lib.c,v 1.23 2024/08/31 09:41:53 tb Exp $ */ | 1 | /* $OpenBSD: conf_lib.c,v 1.24 2024/08/31 09:50:52 tb Exp $ */ |
| 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -77,130 +77,6 @@ CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash) | |||
| 77 | conf->data = hash; | 77 | conf->data = hash; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | /* The following section contains the "CONF classic" functions, | ||
| 81 | rewritten in terms of the new CONF interface. */ | ||
| 82 | |||
| 83 | int | ||
| 84 | CONF_set_default_method(CONF_METHOD *meth) | ||
| 85 | { | ||
| 86 | default_CONF_method = meth; | ||
| 87 | return 1; | ||
| 88 | } | ||
| 89 | |||
| 90 | LHASH_OF(CONF_VALUE) * | ||
| 91 | CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, long *eline) | ||
| 92 | { | ||
| 93 | LHASH_OF(CONF_VALUE) *ltmp; | ||
| 94 | BIO *in = NULL; | ||
| 95 | |||
| 96 | in = BIO_new_file(file, "rb"); | ||
| 97 | if (in == NULL) { | ||
| 98 | CONFerror(ERR_R_SYS_LIB); | ||
| 99 | return NULL; | ||
| 100 | } | ||
| 101 | |||
| 102 | ltmp = CONF_load_bio(conf, in, eline); | ||
| 103 | BIO_free(in); | ||
| 104 | |||
| 105 | return ltmp; | ||
| 106 | } | ||
| 107 | LCRYPTO_ALIAS(CONF_load); | ||
| 108 | |||
| 109 | LHASH_OF(CONF_VALUE) * | ||
| 110 | CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, long *eline) | ||
| 111 | { | ||
| 112 | BIO *btmp; | ||
| 113 | LHASH_OF(CONF_VALUE) *ltmp; | ||
| 114 | |||
| 115 | if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { | ||
| 116 | CONFerror(ERR_R_BUF_LIB); | ||
| 117 | return NULL; | ||
| 118 | } | ||
| 119 | ltmp = CONF_load_bio(conf, btmp, eline); | ||
| 120 | BIO_free(btmp); | ||
| 121 | return ltmp; | ||
| 122 | } | ||
| 123 | |||
| 124 | LHASH_OF(CONF_VALUE) * | ||
| 125 | CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, long *eline) | ||
| 126 | { | ||
| 127 | CONF ctmp; | ||
| 128 | int ret; | ||
| 129 | |||
| 130 | CONF_set_nconf(&ctmp, conf); | ||
| 131 | |||
| 132 | ret = NCONF_load_bio(&ctmp, bp, eline); | ||
| 133 | if (ret) | ||
| 134 | return ctmp.data; | ||
| 135 | return NULL; | ||
| 136 | } | ||
| 137 | |||
| 138 | STACK_OF(CONF_VALUE) * | ||
| 139 | CONF_get_section(LHASH_OF(CONF_VALUE) *conf, const char *section) | ||
| 140 | { | ||
| 141 | if (conf == NULL) { | ||
| 142 | return NULL; | ||
| 143 | } else { | ||
| 144 | CONF ctmp; | ||
| 145 | CONF_set_nconf(&ctmp, conf); | ||
| 146 | return NCONF_get_section(&ctmp, section); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | LCRYPTO_ALIAS(CONF_get_section); | ||
| 150 | |||
| 151 | char * | ||
| 152 | CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, | ||
| 153 | const char *name) | ||
| 154 | { | ||
| 155 | if (conf == NULL) { | ||
| 156 | return NCONF_get_string(NULL, group, name); | ||
| 157 | } else { | ||
| 158 | CONF ctmp; | ||
| 159 | CONF_set_nconf(&ctmp, conf); | ||
| 160 | return NCONF_get_string(&ctmp, group, name); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | LCRYPTO_ALIAS(CONF_get_string); | ||
| 164 | |||
| 165 | long | ||
| 166 | CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, | ||
| 167 | const char *name) | ||
| 168 | { | ||
| 169 | int status; | ||
| 170 | long result = 0; | ||
| 171 | |||
| 172 | if (conf == NULL) { | ||
| 173 | status = NCONF_get_number_e(NULL, group, name, &result); | ||
| 174 | } else { | ||
| 175 | CONF ctmp; | ||
| 176 | CONF_set_nconf(&ctmp, conf); | ||
| 177 | status = NCONF_get_number_e(&ctmp, group, name, &result); | ||
| 178 | } | ||
| 179 | |||
| 180 | if (status == 0) { | ||
| 181 | /* This function does not believe in errors... */ | ||
| 182 | ERR_clear_error(); | ||
| 183 | } | ||
| 184 | return result; | ||
| 185 | } | ||
| 186 | LCRYPTO_ALIAS(CONF_get_number); | ||
| 187 | |||
| 188 | void | ||
| 189 | CONF_free(LHASH_OF(CONF_VALUE) *conf) | ||
| 190 | { | ||
| 191 | CONF ctmp; | ||
| 192 | |||
| 193 | CONF_set_nconf(&ctmp, conf); | ||
| 194 | ctmp.meth->destroy_data(&ctmp); | ||
| 195 | } | ||
| 196 | LCRYPTO_ALIAS(CONF_free); | ||
| 197 | |||
| 198 | /* The following section contains the "New CONF" functions. They are | ||
| 199 | completely centralised around a new CONF structure that may contain | ||
| 200 | basically anything, but at least a method pointer and a table of data. | ||
| 201 | These functions are also written in terms of the bridge functions used | ||
| 202 | by the "CONF classic" functions, for consistency. */ | ||
| 203 | |||
| 204 | CONF * | 80 | CONF * |
| 205 | NCONF_new(const CONF_METHOD *meth) | 81 | NCONF_new(const CONF_METHOD *meth) |
| 206 | { | 82 | { |
