conf_def.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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 = (char *)OPENSSL_malloc(10);
  203. if (section == NULL) {
  204. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  205. goto err;
  206. }
  207. BUF_strlcpy(section, "default", 10);
  208. if (_CONF_new_data(conf) == 0) {
  209. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  210. goto err;
  211. }
  212. sv = _CONF_new_section(conf, section);
  213. if (sv == NULL) {
  214. CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  215. goto err;
  216. }
  217. bufnum = 0;
  218. again = 0;
  219. for (;;) {
  220. if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {
  221. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);
  222. goto err;
  223. }
  224. p = &(buff->data[bufnum]);
  225. *p = '\0';
  226. BIO_gets(in, p, CONFBUFSIZE - 1);
  227. p[CONFBUFSIZE - 1] = '\0';
  228. ii = i = strlen(p);
  229. if (i == 0 && !again)
  230. break;
  231. again = 0;
  232. while (i > 0) {
  233. if ((p[i - 1] != '\r') && (p[i - 1] != '\n'))
  234. break;
  235. else
  236. i--;
  237. }
  238. /*
  239. * we removed some trailing stuff so there is a new line on the end.
  240. */
  241. if (ii && i == ii)
  242. again = 1; /* long line */
  243. else {
  244. p[i] = '\0';
  245. eline++; /* another input line */
  246. }
  247. /* we now have a line with trailing \r\n removed */
  248. /* i is the number of bytes */
  249. bufnum += i;
  250. v = NULL;
  251. /* check for line continuation */
  252. if (bufnum >= 1) {
  253. /*
  254. * If we have bytes and the last char '\\' and second last char
  255. * is not '\\'
  256. */
  257. p = &(buff->data[bufnum - 1]);
  258. if (IS_ESC(conf, p[0]) && ((bufnum <= 1) || !IS_ESC(conf, p[-1]))) {
  259. bufnum--;
  260. again = 1;
  261. }
  262. }
  263. if (again)
  264. continue;
  265. bufnum = 0;
  266. buf = buff->data;
  267. clear_comments(conf, buf);
  268. s = eat_ws(conf, buf);
  269. if (IS_EOF(conf, *s))
  270. continue; /* blank line */
  271. if (*s == '[') {
  272. char *ss;
  273. s++;
  274. start = eat_ws(conf, s);
  275. ss = start;
  276. again:
  277. end = eat_alpha_numeric(conf, ss);
  278. p = eat_ws(conf, end);
  279. if (*p != ']') {
  280. if (*p != '\0' && ss != p) {
  281. ss = p;
  282. goto again;
  283. }
  284. CONFerr(CONF_F_DEF_LOAD_BIO,
  285. CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
  286. goto err;
  287. }
  288. *end = '\0';
  289. if (!str_copy(conf, NULL, &section, start))
  290. goto err;
  291. if ((sv = _CONF_get_section(conf, section)) == NULL)
  292. sv = _CONF_new_section(conf, section);
  293. if (sv == NULL) {
  294. CONFerr(CONF_F_DEF_LOAD_BIO,
  295. CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  296. goto err;
  297. }
  298. continue;
  299. } else {
  300. pname = s;
  301. psection = NULL;
  302. end = eat_alpha_numeric(conf, s);
  303. if ((end[0] == ':') && (end[1] == ':')) {
  304. *end = '\0';
  305. end += 2;
  306. psection = pname;
  307. pname = end;
  308. end = eat_alpha_numeric(conf, end);
  309. }
  310. p = eat_ws(conf, end);
  311. if (*p != '=') {
  312. CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_EQUAL_SIGN);
  313. goto err;
  314. }
  315. *end = '\0';
  316. p++;
  317. start = eat_ws(conf, p);
  318. while (!IS_EOF(conf, *p))
  319. p++;
  320. p--;
  321. while ((p != start) && (IS_WS(conf, *p)))
  322. p--;
  323. p++;
  324. *p = '\0';
  325. if (!(v = (CONF_VALUE *)OPENSSL_malloc(sizeof(CONF_VALUE)))) {
  326. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  327. goto err;
  328. }
  329. if (psection == NULL)
  330. psection = section;
  331. v->name = (char *)OPENSSL_malloc(strlen(pname) + 1);
  332. v->value = NULL;
  333. if (v->name == NULL) {
  334. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  335. goto err;
  336. }
  337. BUF_strlcpy(v->name, pname, strlen(pname) + 1);
  338. if (!str_copy(conf, psection, &(v->value), start))
  339. goto err;
  340. if (strcmp(psection, section) != 0) {
  341. if ((tv = _CONF_get_section(conf, psection))
  342. == NULL)
  343. tv = _CONF_new_section(conf, psection);
  344. if (tv == NULL) {
  345. CONFerr(CONF_F_DEF_LOAD_BIO,
  346. CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
  347. goto err;
  348. }
  349. } else
  350. tv = sv;
  351. #if 1
  352. if (_CONF_add_string(conf, tv, v) == 0) {
  353. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  354. goto err;
  355. }
  356. #else
  357. v->section = tv->section;
  358. if (!sk_CONF_VALUE_push(ts, v)) {
  359. CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
  360. goto err;
  361. }
  362. vv = (CONF_VALUE *)lh_insert(conf->data, v);
  363. if (vv != NULL) {
  364. sk_CONF_VALUE_delete_ptr(ts, vv);
  365. OPENSSL_free(vv->name);
  366. OPENSSL_free(vv->value);
  367. OPENSSL_free(vv);
  368. }
  369. #endif
  370. v = NULL;
  371. }
  372. }
  373. if (buff != NULL)
  374. BUF_MEM_free(buff);
  375. if (section != NULL)
  376. OPENSSL_free(section);
  377. return (1);
  378. err:
  379. if (buff != NULL)
  380. BUF_MEM_free(buff);
  381. if (section != NULL)
  382. OPENSSL_free(section);
  383. if (line != NULL)
  384. *line = eline;
  385. BIO_snprintf(btmp, sizeof btmp, "%ld", eline);
  386. ERR_add_error_data(2, "line ", btmp);
  387. if ((h != conf->data) && (conf->data != NULL)) {
  388. CONF_free(conf->data);
  389. conf->data = NULL;
  390. }
  391. if (v != NULL) {
  392. if (v->name != NULL)
  393. OPENSSL_free(v->name);
  394. if (v->value != NULL)
  395. OPENSSL_free(v->value);
  396. if (v != NULL)
  397. OPENSSL_free(v);
  398. }
  399. return (0);
  400. }
  401. static void clear_comments(CONF *conf, char *p)
  402. {
  403. for (;;) {
  404. if (IS_FCOMMENT(conf, *p)) {
  405. *p = '\0';
  406. return;
  407. }
  408. if (!IS_WS(conf, *p)) {
  409. break;
  410. }
  411. p++;
  412. }
  413. for (;;) {
  414. if (IS_COMMENT(conf, *p)) {
  415. *p = '\0';
  416. return;
  417. }
  418. if (IS_DQUOTE(conf, *p)) {
  419. p = scan_dquote(conf, p);
  420. continue;
  421. }
  422. if (IS_QUOTE(conf, *p)) {
  423. p = scan_quote(conf, p);
  424. continue;
  425. }
  426. if (IS_ESC(conf, *p)) {
  427. p = scan_esc(conf, p);
  428. continue;
  429. }
  430. if (IS_EOF(conf, *p))
  431. return;
  432. else
  433. p++;
  434. }
  435. }
  436. static int str_copy(CONF *conf, char *section, char **pto, char *from)
  437. {
  438. int q, r, rr = 0, to = 0, len = 0;
  439. char *s, *e, *rp, *p, *rrp, *np, *cp, v;
  440. BUF_MEM *buf;
  441. if ((buf = BUF_MEM_new()) == NULL)
  442. return (0);
  443. len = strlen(from) + 1;
  444. if (!BUF_MEM_grow(buf, len))
  445. goto err;
  446. for (;;) {
  447. if (IS_QUOTE(conf, *from)) {
  448. q = *from;
  449. from++;
  450. while (!IS_EOF(conf, *from) && (*from != q)) {
  451. if (IS_ESC(conf, *from)) {
  452. from++;
  453. if (IS_EOF(conf, *from))
  454. break;
  455. }
  456. buf->data[to++] = *(from++);
  457. }
  458. if (*from == q)
  459. from++;
  460. } else if (IS_DQUOTE(conf, *from)) {
  461. q = *from;
  462. from++;
  463. while (!IS_EOF(conf, *from)) {
  464. if (*from == q) {
  465. if (*(from + 1) == q) {
  466. from++;
  467. } else {
  468. break;
  469. }
  470. }
  471. buf->data[to++] = *(from++);
  472. }
  473. if (*from == q)
  474. from++;
  475. } else if (IS_ESC(conf, *from)) {
  476. from++;
  477. v = *(from++);
  478. if (IS_EOF(conf, v))
  479. break;
  480. else if (v == 'r')
  481. v = '\r';
  482. else if (v == 'n')
  483. v = '\n';
  484. else if (v == 'b')
  485. v = '\b';
  486. else if (v == 't')
  487. v = '\t';
  488. buf->data[to++] = v;
  489. } else if (IS_EOF(conf, *from))
  490. break;
  491. else if (*from == '$') {
  492. /* try to expand it */
  493. rrp = NULL;
  494. s = &(from[1]);
  495. if (*s == '{')
  496. q = '}';
  497. else if (*s == '(')
  498. q = ')';
  499. else
  500. q = 0;
  501. if (q)
  502. s++;
  503. cp = section;
  504. e = np = s;
  505. while (IS_ALPHA_NUMERIC(conf, *e))
  506. e++;
  507. if ((e[0] == ':') && (e[1] == ':')) {
  508. cp = np;
  509. rrp = e;
  510. rr = *e;
  511. *rrp = '\0';
  512. e += 2;
  513. np = e;
  514. while (IS_ALPHA_NUMERIC(conf, *e))
  515. e++;
  516. }
  517. r = *e;
  518. *e = '\0';
  519. rp = e;
  520. if (q) {
  521. if (r != q) {
  522. CONFerr(CONF_F_STR_COPY, CONF_R_NO_CLOSE_BRACE);
  523. goto err;
  524. }
  525. e++;
  526. }
  527. /*-
  528. * So at this point we have
  529. * np which is the start of the name string which is
  530. * '\0' terminated.
  531. * cp which is the start of the section string which is
  532. * '\0' terminated.
  533. * e is the 'next point after'.
  534. * r and rr are the chars replaced by the '\0'
  535. * rp and rrp is where 'r' and 'rr' came from.
  536. */
  537. p = _CONF_get_string(conf, cp, np);
  538. if (rrp != NULL)
  539. *rrp = rr;
  540. *rp = r;
  541. if (p == NULL) {
  542. CONFerr(CONF_F_STR_COPY, CONF_R_VARIABLE_HAS_NO_VALUE);
  543. goto err;
  544. }
  545. BUF_MEM_grow_clean(buf, (strlen(p) + buf->length - (e - from)));
  546. while (*p)
  547. buf->data[to++] = *(p++);
  548. /*
  549. * Since we change the pointer 'from', we also have to change the
  550. * perceived length of the string it points at. /RL
  551. */
  552. len -= e - from;
  553. from = e;
  554. /*
  555. * In case there were no braces or parenthesis around the
  556. * variable reference, we have to put back the character that was
  557. * replaced with a '\0'. /RL
  558. */
  559. *rp = r;
  560. } else
  561. buf->data[to++] = *(from++);
  562. }
  563. buf->data[to] = '\0';
  564. if (*pto != NULL)
  565. OPENSSL_free(*pto);
  566. *pto = buf->data;
  567. OPENSSL_free(buf);
  568. return (1);
  569. err:
  570. if (buf != NULL)
  571. BUF_MEM_free(buf);
  572. return (0);
  573. }
  574. static char *eat_ws(CONF *conf, char *p)
  575. {
  576. while (IS_WS(conf, *p) && (!IS_EOF(conf, *p)))
  577. p++;
  578. return (p);
  579. }
  580. static char *eat_alpha_numeric(CONF *conf, char *p)
  581. {
  582. for (;;) {
  583. if (IS_ESC(conf, *p)) {
  584. p = scan_esc(conf, p);
  585. continue;
  586. }
  587. if (!IS_ALPHA_NUMERIC_PUNCT(conf, *p))
  588. return (p);
  589. p++;
  590. }
  591. }
  592. static char *scan_quote(CONF *conf, char *p)
  593. {
  594. int q = *p;
  595. p++;
  596. while (!(IS_EOF(conf, *p)) && (*p != q)) {
  597. if (IS_ESC(conf, *p)) {
  598. p++;
  599. if (IS_EOF(conf, *p))
  600. return (p);
  601. }
  602. p++;
  603. }
  604. if (*p == q)
  605. p++;
  606. return (p);
  607. }
  608. static char *scan_dquote(CONF *conf, char *p)
  609. {
  610. int q = *p;
  611. p++;
  612. while (!(IS_EOF(conf, *p))) {
  613. if (*p == q) {
  614. if (*(p + 1) == q) {
  615. p++;
  616. } else {
  617. break;
  618. }
  619. }
  620. p++;
  621. }
  622. if (*p == q)
  623. p++;
  624. return (p);
  625. }
  626. static void dump_value_doall_arg(CONF_VALUE *a, BIO *out)
  627. {
  628. if (a->name)
  629. BIO_printf(out, "[%s] %s=%s\n", a->section, a->name, a->value);
  630. else
  631. BIO_printf(out, "[[%s]]\n", a->section);
  632. }
  633. static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, BIO)
  634. static int def_dump(const CONF *conf, BIO *out)
  635. {
  636. lh_CONF_VALUE_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_value),
  637. BIO, out);
  638. return 1;
  639. }
  640. static int def_is_number(const CONF *conf, char c)
  641. {
  642. return IS_NUMBER(conf, c);
  643. }
  644. static int def_to_int(const CONF *conf, char c)
  645. {
  646. return c - '0';
  647. }