OLD | NEW |
1 /* conf_mod.c */ | 1 /* conf_mod.c */ |
2 /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL |
3 * project 2001. | 3 * project 2001. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 * callback function giving the start and length of each member | 575 * callback function giving the start and length of each member |
576 * optionally stripping leading and trailing whitespace. This can | 576 * optionally stripping leading and trailing whitespace. This can |
577 * be used to parse comma separated lists for example. | 577 * be used to parse comma separated lists for example. |
578 */ | 578 */ |
579 | 579 |
580 int CONF_parse_list(const char *list_, int sep, int nospc, | 580 int CONF_parse_list(const char *list_, int sep, int nospc, |
581 int (*list_cb)(const char *elem, int len, void *usr), void *arg) | 581 int (*list_cb)(const char *elem, int len, void *usr), void *arg) |
582 { | 582 { |
583 int ret; | 583 int ret; |
584 const char *lstart, *tmpend, *p; | 584 const char *lstart, *tmpend, *p; |
| 585 |
| 586 if(list_ == NULL) |
| 587 { |
| 588 CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL); |
| 589 return 0; |
| 590 } |
| 591 |
585 lstart = list_; | 592 lstart = list_; |
586 | |
587 for(;;) | 593 for(;;) |
588 { | 594 { |
589 if (nospc) | 595 if (nospc) |
590 { | 596 { |
591 while(*lstart && isspace((unsigned char)*lstart)) | 597 while(*lstart && isspace((unsigned char)*lstart)) |
592 lstart++; | 598 lstart++; |
593 } | 599 } |
594 p = strchr(lstart, sep); | 600 p = strchr(lstart, sep); |
595 if (p == lstart || !*lstart) | 601 if (p == lstart || !*lstart) |
596 ret = list_cb(NULL, 0, arg); | 602 ret = list_cb(NULL, 0, arg); |
(...skipping 11 matching lines...) Expand all Loading... |
608 ret = list_cb(lstart, tmpend - lstart + 1, arg); | 614 ret = list_cb(lstart, tmpend - lstart + 1, arg); |
609 } | 615 } |
610 if (ret <= 0) | 616 if (ret <= 0) |
611 return ret; | 617 return ret; |
612 if (p == NULL) | 618 if (p == NULL) |
613 return 1; | 619 return 1; |
614 lstart = p + 1; | 620 lstart = p + 1; |
615 } | 621 } |
616 } | 622 } |
617 | 623 |
OLD | NEW |