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_api.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_api.c')
-rw-r--r-- | src/lib/libcrypto/conf/conf_api.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c index d05a778ff6..0032baa711 100644 --- a/src/lib/libcrypto/conf/conf_api.c +++ b/src/lib/libcrypto/conf/conf_api.c | |||
@@ -67,26 +67,34 @@ | |||
67 | #include <string.h> | 67 | #include <string.h> |
68 | #include <openssl/conf.h> | 68 | #include <openssl/conf.h> |
69 | #include <openssl/conf_api.h> | 69 | #include <openssl/conf_api.h> |
70 | #include "e_os.h" | ||
70 | 71 | ||
71 | static void value_free_hash(CONF_VALUE *a, LHASH *conf); | 72 | static void value_free_hash(CONF_VALUE *a, LHASH *conf); |
72 | static void value_free_stack(CONF_VALUE *a,LHASH *conf); | 73 | static void value_free_stack(CONF_VALUE *a,LHASH *conf); |
73 | static unsigned long hash(CONF_VALUE *v); | 74 | static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_hash, CONF_VALUE *, LHASH *) |
74 | static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); | 75 | static IMPLEMENT_LHASH_DOALL_ARG_FN(value_free_stack, CONF_VALUE *, LHASH *) |
76 | /* We don't use function pointer casting or wrapper functions - but cast each | ||
77 | * callback parameter inside the callback functions. */ | ||
78 | /* static unsigned long hash(CONF_VALUE *v); */ | ||
79 | static unsigned long hash(const void *v_void); | ||
80 | /* static int cmp_conf(CONF_VALUE *a,CONF_VALUE *b); */ | ||
81 | static int cmp_conf(const void *a_void,const void *b_void); | ||
75 | 82 | ||
76 | /* Up until OpenSSL 0.9.5a, this was get_section */ | 83 | /* Up until OpenSSL 0.9.5a, this was get_section */ |
77 | CONF_VALUE *_CONF_get_section(CONF *conf, char *section) | 84 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section) |
78 | { | 85 | { |
79 | CONF_VALUE *v,vv; | 86 | CONF_VALUE *v,vv; |
80 | 87 | ||
81 | if ((conf == NULL) || (section == NULL)) return(NULL); | 88 | if ((conf == NULL) || (section == NULL)) return(NULL); |
82 | vv.name=NULL; | 89 | vv.name=NULL; |
83 | vv.section=section; | 90 | vv.section=(char *)section; |
84 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); | 91 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); |
85 | return(v); | 92 | return(v); |
86 | } | 93 | } |
87 | 94 | ||
88 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ | 95 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ |
89 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(CONF *conf, char *section) | 96 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, |
97 | const char *section) | ||
90 | { | 98 | { |
91 | CONF_VALUE *v; | 99 | CONF_VALUE *v; |
92 | 100 | ||
@@ -121,7 +129,7 @@ int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value) | |||
121 | return 1; | 129 | return 1; |
122 | } | 130 | } |
123 | 131 | ||
124 | char *_CONF_get_string(CONF *conf, char *section, char *name) | 132 | char *_CONF_get_string(const CONF *conf, const char *section, const char *name) |
125 | { | 133 | { |
126 | CONF_VALUE *v,vv; | 134 | CONF_VALUE *v,vv; |
127 | char *p; | 135 | char *p; |
@@ -131,8 +139,8 @@ char *_CONF_get_string(CONF *conf, char *section, char *name) | |||
131 | { | 139 | { |
132 | if (section != NULL) | 140 | if (section != NULL) |
133 | { | 141 | { |
134 | vv.name=name; | 142 | vv.name=(char *)name; |
135 | vv.section=section; | 143 | vv.section=(char *)section; |
136 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); | 144 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); |
137 | if (v != NULL) return(v->value); | 145 | if (v != NULL) return(v->value); |
138 | if (strcmp(section,"ENV") == 0) | 146 | if (strcmp(section,"ENV") == 0) |
@@ -142,7 +150,7 @@ char *_CONF_get_string(CONF *conf, char *section, char *name) | |||
142 | } | 150 | } |
143 | } | 151 | } |
144 | vv.section="default"; | 152 | vv.section="default"; |
145 | vv.name=name; | 153 | vv.name=(char *)name; |
146 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); | 154 | v=(CONF_VALUE *)lh_retrieve(conf->data,&vv); |
147 | if (v != NULL) | 155 | if (v != NULL) |
148 | return(v->value); | 156 | return(v->value); |
@@ -153,6 +161,9 @@ char *_CONF_get_string(CONF *conf, char *section, char *name) | |||
153 | return(Getenv(name)); | 161 | return(Getenv(name)); |
154 | } | 162 | } |
155 | 163 | ||
164 | #if 0 /* There's no way to provide error checking with this function, so | ||
165 | force implementors of the higher levels to get a string and read | ||
166 | the number themselves. */ | ||
156 | long _CONF_get_number(CONF *conf, char *section, char *name) | 167 | long _CONF_get_number(CONF *conf, char *section, char *name) |
157 | { | 168 | { |
158 | char *str; | 169 | char *str; |
@@ -169,6 +180,7 @@ long _CONF_get_number(CONF *conf, char *section, char *name) | |||
169 | str++; | 180 | str++; |
170 | } | 181 | } |
171 | } | 182 | } |
183 | #endif | ||
172 | 184 | ||
173 | int _CONF_new_data(CONF *conf) | 185 | int _CONF_new_data(CONF *conf) |
174 | { | 186 | { |
@@ -177,7 +189,7 @@ int _CONF_new_data(CONF *conf) | |||
177 | return 0; | 189 | return 0; |
178 | } | 190 | } |
179 | if (conf->data == NULL) | 191 | if (conf->data == NULL) |
180 | if ((conf->data = lh_new(hash,cmp_conf)) == NULL) | 192 | if ((conf->data = lh_new(hash, cmp_conf)) == NULL) |
181 | { | 193 | { |
182 | return 0; | 194 | return 0; |
183 | } | 195 | } |
@@ -190,12 +202,14 @@ void _CONF_free_data(CONF *conf) | |||
190 | 202 | ||
191 | conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' | 203 | conf->data->down_load=0; /* evil thing to make sure the 'OPENSSL_free()' |
192 | * works as expected */ | 204 | * works as expected */ |
193 | lh_doall_arg(conf->data,(void (*)())value_free_hash,conf->data); | 205 | lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_hash), |
206 | conf->data); | ||
194 | 207 | ||
195 | /* We now have only 'section' entries in the hash table. | 208 | /* We now have only 'section' entries in the hash table. |
196 | * Due to problems with */ | 209 | * Due to problems with */ |
197 | 210 | ||
198 | lh_doall_arg(conf->data,(void (*)())value_free_stack,conf->data); | 211 | lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(value_free_stack), |
212 | conf->data); | ||
199 | lh_free(conf->data); | 213 | lh_free(conf->data); |
200 | } | 214 | } |
201 | 215 | ||
@@ -228,14 +242,19 @@ static void value_free_stack(CONF_VALUE *a, LHASH *conf) | |||
228 | OPENSSL_free(a); | 242 | OPENSSL_free(a); |
229 | } | 243 | } |
230 | 244 | ||
231 | static unsigned long hash(CONF_VALUE *v) | 245 | /* static unsigned long hash(CONF_VALUE *v) */ |
246 | static unsigned long hash(const void *v_void) | ||
232 | { | 247 | { |
248 | CONF_VALUE *v = (CONF_VALUE *)v_void; | ||
233 | return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); | 249 | return((lh_strhash(v->section)<<2)^lh_strhash(v->name)); |
234 | } | 250 | } |
235 | 251 | ||
236 | static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) | 252 | /* static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) */ |
253 | static int cmp_conf(const void *a_void,const void *b_void) | ||
237 | { | 254 | { |
238 | int i; | 255 | int i; |
256 | CONF_VALUE *a = (CONF_VALUE *)a_void; | ||
257 | CONF_VALUE *b = (CONF_VALUE *)b_void; | ||
239 | 258 | ||
240 | if (a->section != b->section) | 259 | if (a->section != b->section) |
241 | { | 260 | { |
@@ -255,7 +274,7 @@ static int cmp_conf(CONF_VALUE *a, CONF_VALUE *b) | |||
255 | } | 274 | } |
256 | 275 | ||
257 | /* Up until OpenSSL 0.9.5a, this was new_section */ | 276 | /* Up until OpenSSL 0.9.5a, this was new_section */ |
258 | CONF_VALUE *_CONF_new_section(CONF *conf, char *section) | 277 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section) |
259 | { | 278 | { |
260 | STACK *sk=NULL; | 279 | STACK *sk=NULL; |
261 | int ok=0,i; | 280 | int ok=0,i; |