conf_def.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. /* crypto/conf/conf.c */
  2. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young (eay@cryptsoft.com).
  7. * The implementation was written so as to conform with Netscapes SSL.
  8. *
  9. * This library is free for commercial and non-commercial use as long as
  10. * the following conditions are aheared to. The following conditions
  11. * apply to all code found in this distribution, be it the RC4, RSA,
  12. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  13. * included with this distribution is covered by the same copyright terms
  14. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  15. *
  16. * Copyright remains Eric Young's, and as such any Copyright notices in
  17. * the code are not to be removed.
  18. * If this package is used in a product, Eric Young should be given attribution
  19. * as the author of the parts of the library used.
  20. * This can be in the form of a textual message at program startup or
  21. * in documentation (online or textual) provided with the package.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. All advertising materials mentioning features or use of this software
  32. * must display the following acknowledgement:
  33. * "This product includes cryptographic software written by
  34. * Eric Young (eay@cryptsoft.com)"
  35. * The word 'cryptographic' can be left out if the rouines from the library
  36. * being used are not cryptographic related :-).
  37. * 4. If you include any Windows specific code (or a derivative thereof) from
  38. * the apps directory (application code) you must include an acknowledgement:
  39. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  42. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  44. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  45. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  47. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  49. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  50. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  51. * SUCH DAMAGE.
  52. *
  53. * The licence and distribution terms for any publically available version or
  54. * derivative of this code cannot be changed. i.e. this code cannot simply be
  55. * copied and put under another distribution licence
  56. * [including the GNU Public Licence.]
  57. */
  58. /* Part of the code in here was originally in conf.c, which is now removed */
  59. #include <stdio.h>
  60. #include <string.h>
  61. #include "cryptlib.h"
  62. #include <openssl/stack.h>
  63. #include <openssl/lhash.h>
  64. #include <openssl/conf.h>
  65. #include <openssl/conf_api.h>
  66. #include "conf_def.h"
  67. #include <openssl/buffer.h>
  68. #include <openssl/err.h>
  69. static char *eat_ws(CONF *conf, char *p);
  70. static char *eat_alpha_numeric(CONF *conf, char *p);
  71. static void clear_comments(CONF *conf, char *p);
  72. static int str_copy(CONF *conf, char *section, char **to, char *from);
  73. static char *scan_quote(CONF *conf, char *p);
  74. static char *scan_dquote(CONF *conf, char *p);
  75. #define scan_esc(conf,p) (((IS_EOF((conf),(p)[1]))?((p)+1):((p)+2)))
  76. static CONF *def_create(CONF_METHOD *meth);
  77. static int def_init_default(CONF *conf);
  78. static int def_init_WIN32(CONF *conf);
  79. static int def_destroy(CONF *conf);
  80. static int def_destroy_data(CONF *conf);
  81. static int def_load(CONF *conf, const char *name, long *eline);
  82. static int def_load_bio(CONF *conf, BIO *bp, long *eline);
  83. static int def_dump(const CONF *conf, BIO *bp);
  84. static int def_is_number(const CONF *conf, char c);
  85. static int def_to_int(const CONF *conf, char c);
  86. const char CONF_def_version[] = "CONF_def" OPENSSL_VERSION_PTEXT;
  87. static CONF_METHOD default_method = {
  88. "OpenSSL default",
  89. def_create,
  90. def_init_default,
  91. def_destroy,
  92. def_destroy_data,
  93. def_load_bio,
  94. def_dump,
  95. def_is_number,
  96. def_to_int,
  97. def_load
  98. };
  99. static CONF_METHOD WIN32_method = {
  100. "WIN32",
  101. def_create,
  102. def_init_WIN32,
  103. def_destroy,
  104. def_destroy_data,
  105. def_load_bio,
  106. def_dump,
  107. def_is_number,
  108. def_to_int,
  109. def_load
  110. };
  111. CONF_METHOD *NCONF_default()
  112. {
  113. return &default_method;
  114. }
  115. CONF_METHOD *NCONF_WIN32()
  116. {
  117. return &WIN32_method;
  118. }
  119. static CONF *def_create(CONF_METHOD *meth)
  120. {
  121. CONF *ret;
  122. ret = OPENSSL_malloc(sizeof(CONF) + sizeof(unsigned short *));
  123. if (ret)
  124. if (meth->init(ret) == 0) {
  125. OPENSSL_free(ret);
  126. ret = NULL;
  127. }
  128. return ret;
  129. }
  130. static int def_init_default(CONF *conf)
  131. {
  132. if (conf == NULL)
  133. return 0;
  134. conf->meth = &default_method;
  135. conf->meth_data = CONF_type_default;
  136. conf->data = NULL;
  137. return 1;
  138. }
  139. static int def_init_WIN32(CONF *conf)
  140. {
  141. if (conf == NULL)
  142. return 0;
  143. conf->meth = &WIN32_method;
  144. conf->meth_data = (void *)CONF_type_win32;
  145. conf->data = NULL;
  146. return 1;
  147. }
  148. static int def_destroy(CONF *conf)
  149. {
  150. if (def_destroy_data(conf)) {
  151. OPENSSL_free(conf);
  152. return 1;
  153. }
  154. return 0;
  155. }
  156. static int def_destroy_data(CONF *conf)
  157. {
  158. if (conf == NULL)
  159. return 0;
  160. _CONF_free_data(conf);
  161. return 1;
  162. }
  163. static int def_load(CONF *conf, const char *name, long *line)
  164. {
  165. int ret;
  166. BIO *in = NULL;
  167. #ifdef OPENSSL_SYS_VMS
  168. in = BIO_new_file(name, "r");
  169. #else
  170. in = BIO_new_file(name, "rb");
  171. #endif
  172. if (in == NULL) {
  173. if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
  174. CONFerr(CONF_F_DEF_LOAD, CONF_R_NO_SUCH_FILE);
  175. else
  176. CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB);
  177. return 0;
  178. }
  179. ret = def_load_bio(conf, in, line);
  180. BIO_free(in);
  181. return ret;
  182. }
  183. static int def_load_bio(CONF *conf, BIO *in, long *line)
  184. {
  185. /* The macro BUFSIZE conflicts with a system macro in VxWorks */
  186. #define CONFBUFSIZE 512
  187. int bufnum = 0, i, ii;
  188. BUF_MEM *buff = NULL;
  189. char *s, *p, *end;
  190. int again;
  191. long eline = 0;
  192. char btmp[DECIMAL_SIZE(eline) + 1];
  193. CONF_VALUE *v = NULL, *tv;
  194. CONF_VALUE *sv = NULL;
  195. char *section = NULL, *buf;
  196. char *start, *psection, *pname;
  197. void *h = (void *)(conf->data);
  198. if ((buff = BUF_MEM_new()) == NULL) {
  199. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);
  200. goto err;
  201. }
  202. section = BUF_strdup("default");
  203. if (section == NULL) {
  204. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  205. goto err;
  206. }
  207. if (_CONF_new_data(conf) == 0) {
  208. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  209. goto err;
  210. }
  211. sv = _CONF_new_section(conf, section);
  212. if (sv == NULL) {
  213. CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  214. goto err;
  215. }
  216. bufnum = 0;
  217. again = 0;
  218. for (;;) {
  219. if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {
  220. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);
  221. goto err;
  222. }
  223. p = &(buff->data[bufnum]);
  224. *p = '\0';
  225. BIO_gets(in, p, CONFBUFSIZE - 1);
  226. p[CONFBUFSIZE - 1] = '\0';
  227. ii = i = strlen(p);
  228. if (i == 0 && !again)
  229. break;
  230. again = 0;
  231. while (i > 0) {
  232. if ((p[i - 1] != '\r') && (p[i - 1] != '\n'))
  233. break;
  234. else
  235. i--;
  236. }
  237. /*
  238. * we removed some trailing stuff so there is a new line on the end.
  239. */
  240. if (ii && i == ii)
  241. again = 1; /* long line */
  242. else {
  243. p[i] = '\0';
  244. eline++; /* another input line */
  245. }
  246. /* we now have a line with trailing \r\n removed */
  247. /* i is the number of bytes */
  248. bufnum += i;
  249. v = NULL;
  250. /* check for line continuation */
  251. if (bufnum >= 1) {
  252. /*
  253. * If we have bytes and the last char '\\' and second last char
  254. * is not '\\'
  255. */
  256. p = &(buff->data[bufnum - 1]);
  257. if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) {
  258. bufnum--;
  259. again = 1;
  260. }
  261. }
  262. if (again)
  263. continue;
  264. bufnum = 0;
  265. buf = buff->data;
  266. clear_comments(conf, buf);
  267. s = eat_ws(conf, buf);
  268. if (IS_EOF(conf, *s))
  269. continue; /* blank line */
  270. if (*s == '[') {
  271. char *ss;
  272. s++;
  273. start = eat_ws(conf, s);
  274. ss = start;
  275. again:
  276. end = eat_alpha_numeric(conf, ss);
  277. p = eat_ws(conf, end);
  278. if (*p != ']') {
  279. if (*p != '\0' && ss != p) {
  280. ss = p;
  281. goto again;
  282. }
  283. CONFerr(CONF_F_DEF_LOAD_BIO,
  284. CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
  285. goto err;
  286. }
  287. *end = '\0';
  288. if (!str_copy(conf, NULL, &section, start))
  289. goto err;
  290. if ((sv = _CONF_get_section(conf, section)) == NULL)
  291. sv = _CONF_new_section(conf, section);
  292. if (sv == NULL) {
  293. CONFerr(CONF_F_DEF_LOAD_BIO,
  294. CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  295. goto err;
  296. }
  297. continue;
  298. } else {
  299. pname = s;
  300. psection = NULL;
  301. end = eat_alpha_numeric(conf, s);
  302. if ((end[0] == ':') && (end[1] == ':')) {
  303. *end = '\0';
  304. end += 2;
  305. psection = pname;
  306. pname = end;
  307. end = eat_alpha_numeric(conf, end);
  308. }
  309. p = eat_ws(conf, end);
  310. if (*p != '=') {
  311. CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_EQUAL_SIGN);
  312. goto err;
  313. }
  314. *end = '\0';
  315. p++;
  316. start = eat_ws(conf, p);
  317. while (!IS_EOF(conf, *p))
  318. p++;
  319. p--;
  320. while ((p != start) && (IS_WS(conf, *p)))
  321. p--;
  322. p++;
  323. *p = '\0';
  324. if (!(v = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) {
  325. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  326. goto err;
  327. }
  328. if (psection == NULL)
  329. psection = section;
  330. v->name = (char *)OPENSSL_malloc(strlen(pname) + 1);
  331. v->value = NULL;
  332. if (v->name == NULL) {
  333. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  334. goto err;
  335. }
  336. BUF_strlcpy(v->name, pname, strlen(pname) + 1);
  337. if (!str_copy(conf, psection, &(v->value), start))
  338. goto err;
  339. if (strcmp(psection, section) != 0) {
  340. if ((tv = _CONF_get_section(conf, psection))
  341. == NULL)
  342. tv = _CONF_new_section(conf, psection);
  343. if (tv == NULL) {
  344. CONFerr(CONF_F_DEF_LOAD_BIO,
  345. CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  346. goto err;
  347. }
  348. } else
  349. tv = sv;
  350. #if 1
  351. if (_CONF_add_string(conf, tv, v) == 0) {
  352. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  353. goto err;
  354. }
  355. #else
  356. v->section = tv->section;
  357. if (!sk_CONF_VALUE_push(ts, v)) {
  358. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  359. goto err;
  360. }
  361. vv = (CONF_VALUE *)lh_insert(conf->data, v);
  362. if (vv != NULL) {
  363. sk_CONF_VALUE_delete_ptr(ts, vv);
  364. OPENSSL_free(vv->name);
  365. OPENSSL_free(vv->value);
  366. OPENSSL_free(vv);
  367. }
  368. #endif
  369. v = NULL;
  370. }
  371. }
  372. if (buff != NULL)
  373. BUF_MEM_free(buff);
  374. if (section != NULL)
  375. OPENSSL_free(section);
  376. return (1);
  377. err:
  378. if (buff != NULL)
  379. BUF_MEM_free(buff);
  380. if (section != NULL)
  381. OPENSSL_free(section);
  382. if (line != NULL)
  383. *line = eline;
  384. BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
  385. ERR_add_error_data(2, "line ", btmp);
  386. if ((h != conf->data) && (conf->data != NULL)) {
  387. CONF_free(conf->data);
  388. conf->data = NULL;
  389. }
  390. if (v != NULL) {
  391. if (v->name != NULL)
  392. OPENSSL_free(v->name);
  393. if (v->value != NULL)
  394. OPENSSL_free(v->value);
  395. if (v != NULL)
  396. OPENSSL_free(v);
  397. }
  398. return (0);
  399. }
  400. static void clear_comments(CONF *conf, char *p)
  401. {
  402. for (;;) {
  403. if (IS_FCOMMENT(conf, *p)) {
  404. *p = '\0';
  405. return;
  406. }
  407. if (!IS_WS(conf, *p)) {
  408. break;
  409. }
  410. p++;
  411. }
  412. for (;;) {
  413. if (IS_COMMENT(conf, *p)) {
  414. *p = '\0';
  415. return;
  416. }
  417. if (IS_DQUOTE(conf, *p)) {
  418. p = scan_dquote(conf, p);
  419. continue;
  420. }
  421. if (IS_QUOTE(conf, *p)) {
  422. p = scan_quote(conf, p);
  423. continue;
  424. }
  425. if (IS_ESC(conf, *p)) {
  426. p = scan_esc(conf, p);
  427. continue;
  428. }
  429. if (IS_EOF(conf, *p))
  430. return;
  431. else
  432. p++;
  433. }
  434. }
  435. static int str_copy(CONF *conf, char *section, char **pto, char *from)
  436. {
  437. int q, r, rr = 0, to = 0, len = 0;
  438. char *s, *e, *rp, *p, *rrp, *np, *cp, v;
  439. BUF_MEM *buf;
  440. if ((buf = BUF_MEM_new()) == NULL)
  441. return (0);
  442. len = strlen(from) + 1;
  443. if (!BUF_MEM_grow(buf, len))
  444. goto err;
  445. for (;;) {
  446. if (IS_QUOTE(conf, *from)) {
  447. q = *from;
  448. from++;
  449. while (!IS_EOF(conf, *from) && (*from != q)) {
  450. if (IS_ESC(conf, *from)) {
  451. from++;
  452. if (IS_EOF(conf, *from))
  453. break;
  454. }
  455. buf->data[to++] = *(from++);
  456. }
  457. if (*from == q)
  458. from++;
  459. } else if (IS_DQUOTE(conf, *from)) {
  460. q = *from;
  461. from++;
  462. while (!IS_EOF(conf, *from)) {
  463. if (*from == q) {
  464. if (*(from + 1) == q) {
  465. from++;
  466. } else {
  467. break;
  468. }
  469. }
  470. buf->data[to++] = *(from++);
  471. }
  472. if (*from == q)
  473. from++;
  474. } else if (IS_ESC(conf, *from)) {
  475. from++;
  476. v = *(from++);
  477. if (IS_EOF(conf, v))
  478. break;
  479. else if (v == 'r')
  480. v = '\r';
  481. else if (v == 'n')
  482. v = '\n';
  483. else if (v == 'b')
  484. v = '\b';
  485. else if (v == 't')
  486. v = '\t';
  487. buf->data[to++] = v;
  488. } else if (IS_EOF(conf, *from))
  489. break;
  490. else if (*from == '$') {
  491. /* try to expand it */
  492. rrp = NULL;
  493. s = &(from[1]);
  494. if (*s == '{')
  495. q = '}';
  496. else if (*s == '(')
  497. q = ')';
  498. else
  499. q = 0;
  500. if (q)
  501. s++;
  502. cp = section;
  503. e = np = s;
  504. while (IS_ALPHA_NUMERIC(conf, *e))
  505. e++;
  506. if ((e[0] == ':') && (e[1] == ':')) {
  507. cp = np;
  508. rrp = e;
  509. rr = *e;
  510. *rrp = '\0';
  511. e += 2;
  512. np = e;
  513. while (IS_ALPHA_NUMERIC(conf, *e))
  514. e++;
  515. }
  516. r = *e;
  517. *e = '\0';
  518. rp = e;
  519. if (q) {
  520. if (r != q) {
  521. CONFerr(CONF_F_STR_COPY, CONF_R_NO_CLOSE_BRACE);
  522. goto err;
  523. }
  524. e++;
  525. }
  526. /*-
  527. * So at this point we have
  528. * np which is the start of the name string which is
  529. * '\0' terminated.
  530. * cp which is the start of the section string which is
  531. * '\0' terminated.
  532. * e is the 'next point after'.
  533. * r and rr are the chars replaced by the '\0'
  534. * rp and rrp is where 'r' and 'rr' came from.
  535. */
  536. p = _CONF_get_string(conf, cp, np);
  537. if (rrp != NULL)
  538. *rrp = rr;
  539. *rp = r;
  540. if (p == NULL) {
  541. CONFerr(CONF_F_STR_COPY, CONF_R_VARIABLE_HAS_NO_VALUE);
  542. goto err;
  543. }
  544. if (!BUF_MEM_grow_clean(buf,
  545. (strlen(p) + buf->length - (e - from)))) {
  546. CONFerr(CONF_F_STR_COPY, ERR_R_MALLOC_FAILURE);
  547. goto err;
  548. }
  549. while (*p)
  550. buf->data[to++] = *(p++);
  551. /*
  552. * Since we change the pointer 'from', we also have to change the
  553. * perceived length of the string it points at. /RL
  554. */
  555. len -= e - from;
  556. from = e;
  557. /*
  558. * In case there were no braces or parenthesis around the
  559. * variable reference, we have to put back the character that was
  560. * replaced with a '\0'. /RL
  561. */
  562. *rp = r;
  563. } else
  564. buf->data[to++] = *(from++);
  565. }
  566. buf->data[to] = '\0';
  567. if (*pto != NULL)
  568. OPENSSL_free(*pto);
  569. *pto = buf->data;
  570. OPENSSL_free(buf);
  571. return (1);
  572. err:
  573. if (buf != NULL)
  574. BUF_MEM_free(buf);
  575. return (0);
  576. }
  577. static char *eat_ws(CONF *conf, char *p)
  578. {
  579. while (IS_WS(conf, *p) && (!IS_EOF(conf, *p)))
  580. p++;
  581. return (p);
  582. }
  583. static char *eat_alpha_numeric(CONF *conf, char *p)
  584. {
  585. for (;;) {
  586. if (IS_ESC(conf, *p)) {
  587. p = scan_esc(conf, p);
  588. continue;
  589. }
  590. if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p))
  591. return (p);
  592. p++;
  593. }
  594. }
  595. static char *scan_quote(CONF *conf, char *p)
  596. {
  597. int q = *p;
  598. p++;
  599. while (!(IS_EOF(conf, *p)) && (*p != q)) {
  600. if (IS_ESC(conf, *p)) {
  601. p++;
  602. if (IS_EOF(conf, *p))
  603. return (p);
  604. }
  605. p++;
  606. }
  607. if (*p == q)
  608. p++;
  609. return (p);
  610. }
  611. static char *scan_dquote(CONF *conf, char *p)
  612. {
  613. int q = *p;
  614. p++;
  615. while (!(IS_EOF(conf, *p))) {
  616. if (*p == q) {
  617. if (*(p + 1) == q) {
  618. p++;
  619. } else {
  620. break;
  621. }
  622. }
  623. p++;
  624. }
  625. if (*p == q)
  626. p++;
  627. return (p);
  628. }
  629. static void dump_value_doall_arg(CONF_VALUE *a, BIO *out)
  630. {
  631. if (a->name)
  632. BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
  633. else
  634. BIO_printf(out, "[[%s]]\n", a->section);
  635. }
  636. static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO)
  637. static int def_dump(const CONF *conf, BIO *out)
  638. {
  639. lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value),
  640. BIO, out);
  641. return 1;
  642. }
  643. static int def_is_number(const CONF *conf, char c)
  644. {
  645. return IS_NUMBER(conf, c);
  646. }
  647. static int def_to_int(const CONF *conf, char c)
  648. {
  649. return c - '0';
  650. }