diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/conf/conf_def.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libcrypto/conf/conf_def.c')
-rw-r--r-- | src/lib/libcrypto/conf/conf_def.c | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c index 773df32c68..31f2766246 100644 --- a/src/lib/libcrypto/conf/conf_def.c +++ b/src/lib/libcrypto/conf/conf_def.c | |||
@@ -81,10 +81,11 @@ static int def_init_default(CONF *conf); | |||
81 | static int def_init_WIN32(CONF *conf); | 81 | static int def_init_WIN32(CONF *conf); |
82 | static int def_destroy(CONF *conf); | 82 | static int def_destroy(CONF *conf); |
83 | static int def_destroy_data(CONF *conf); | 83 | static int def_destroy_data(CONF *conf); |
84 | static int def_load(CONF *conf, BIO *bp, long *eline); | 84 | static int def_load(CONF *conf, const char *name, long *eline); |
85 | static int def_dump(CONF *conf, BIO *bp); | 85 | static int def_load_bio(CONF *conf, BIO *bp, long *eline); |
86 | static int def_is_number(CONF *conf, char c); | 86 | static int def_dump(const CONF *conf, BIO *bp); |
87 | static int def_to_int(CONF *conf, char c); | 87 | static int def_is_number(const CONF *conf, char c); |
88 | static int def_to_int(const CONF *conf, char c); | ||
88 | 89 | ||
89 | const char *CONF_def_version="CONF_def" OPENSSL_VERSION_PTEXT; | 90 | const char *CONF_def_version="CONF_def" OPENSSL_VERSION_PTEXT; |
90 | 91 | ||
@@ -94,10 +95,11 @@ static CONF_METHOD default_method = { | |||
94 | def_init_default, | 95 | def_init_default, |
95 | def_destroy, | 96 | def_destroy, |
96 | def_destroy_data, | 97 | def_destroy_data, |
97 | def_load, | 98 | def_load_bio, |
98 | def_dump, | 99 | def_dump, |
99 | def_is_number, | 100 | def_is_number, |
100 | def_to_int | 101 | def_to_int, |
102 | def_load | ||
101 | }; | 103 | }; |
102 | 104 | ||
103 | static CONF_METHOD WIN32_method = { | 105 | static CONF_METHOD WIN32_method = { |
@@ -106,10 +108,11 @@ static CONF_METHOD WIN32_method = { | |||
106 | def_init_WIN32, | 108 | def_init_WIN32, |
107 | def_destroy, | 109 | def_destroy, |
108 | def_destroy_data, | 110 | def_destroy_data, |
109 | def_load, | 111 | def_load_bio, |
110 | def_dump, | 112 | def_dump, |
111 | def_is_number, | 113 | def_is_number, |
112 | def_to_int | 114 | def_to_int, |
115 | def_load | ||
113 | }; | 116 | }; |
114 | 117 | ||
115 | CONF_METHOD *NCONF_default() | 118 | CONF_METHOD *NCONF_default() |
@@ -177,7 +180,32 @@ static int def_destroy_data(CONF *conf) | |||
177 | return 1; | 180 | return 1; |
178 | } | 181 | } |
179 | 182 | ||
180 | static int def_load(CONF *conf, BIO *in, long *line) | 183 | static int def_load(CONF *conf, const char *name, long *line) |
184 | { | ||
185 | int ret; | ||
186 | BIO *in=NULL; | ||
187 | |||
188 | #ifdef OPENSSL_SYS_VMS | ||
189 | in=BIO_new_file(name, "r"); | ||
190 | #else | ||
191 | in=BIO_new_file(name, "rb"); | ||
192 | #endif | ||
193 | if (in == NULL) | ||
194 | { | ||
195 | if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE) | ||
196 | CONFerr(CONF_F_CONF_LOAD,CONF_R_NO_SUCH_FILE); | ||
197 | else | ||
198 | CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB); | ||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | ret = def_load_bio(conf, in, line); | ||
203 | BIO_free(in); | ||
204 | |||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | static int def_load_bio(CONF *conf, BIO *in, long *line) | ||
181 | { | 209 | { |
182 | #define BUFSIZE 512 | 210 | #define BUFSIZE 512 |
183 | char btmp[16]; | 211 | char btmp[16]; |
@@ -418,7 +446,11 @@ err: | |||
418 | if (line != NULL) *line=eline; | 446 | if (line != NULL) *line=eline; |
419 | sprintf(btmp,"%ld",eline); | 447 | sprintf(btmp,"%ld",eline); |
420 | ERR_add_error_data(2,"line ",btmp); | 448 | ERR_add_error_data(2,"line ",btmp); |
421 | if ((h != conf->data) && (conf->data != NULL)) CONF_free(conf->data); | 449 | if ((h != conf->data) && (conf->data != NULL)) |
450 | { | ||
451 | CONF_free(conf->data); | ||
452 | conf->data=NULL; | ||
453 | } | ||
422 | if (v != NULL) | 454 | if (v != NULL) |
423 | { | 455 | { |
424 | if (v->name != NULL) OPENSSL_free(v->name); | 456 | if (v->name != NULL) OPENSSL_free(v->name); |
@@ -685,18 +717,20 @@ static void dump_value(CONF_VALUE *a, BIO *out) | |||
685 | BIO_printf(out, "[[%s]]\n", a->section); | 717 | BIO_printf(out, "[[%s]]\n", a->section); |
686 | } | 718 | } |
687 | 719 | ||
688 | static int def_dump(CONF *conf, BIO *out) | 720 | static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE *, BIO *) |
721 | |||
722 | static int def_dump(const CONF *conf, BIO *out) | ||
689 | { | 723 | { |
690 | lh_doall_arg(conf->data, (void (*)())dump_value, out); | 724 | lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value), out); |
691 | return 1; | 725 | return 1; |
692 | } | 726 | } |
693 | 727 | ||
694 | static int def_is_number(CONF *conf, char c) | 728 | static int def_is_number(const CONF *conf, char c) |
695 | { | 729 | { |
696 | return IS_NUMBER(conf,c); | 730 | return IS_NUMBER(conf,c); |
697 | } | 731 | } |
698 | 732 | ||
699 | static int def_to_int(CONF *conf, char c) | 733 | static int def_to_int(const CONF *conf, char c) |
700 | { | 734 | { |
701 | return c - '0'; | 735 | return c - '0'; |
702 | } | 736 | } |