conf_def.c 16 KB

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