summaryrefslogtreecommitdiffstats
path: root/crypto/conf
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2002-01-22 01:40:18 +0000
committerDr. Stephen Henson <steve@openssl.org>2002-01-22 01:40:18 +0000
commitdf5eaa8a5297d42d1b44cfcf1210e7b016d3f7c1 (patch)
treec33133c2de7ca506de2789946bbdcd58b783ad89 /crypto/conf
parent6ce46d69f5d940b07e8f4f191121546c3f33ada6 (diff)
default_algorithms option in ENGINE config.
Diffstat (limited to 'crypto/conf')
-rw-r--r--crypto/conf/conf.h3
-rw-r--r--crypto/conf/conf_mod.c46
2 files changed, 49 insertions, 0 deletions
diff --git a/crypto/conf/conf.h b/crypto/conf/conf.h
index 26452d4c81..882d75c74e 100644
--- a/crypto/conf/conf.h
+++ b/crypto/conf/conf.h
@@ -190,6 +190,9 @@ void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);
char *CONF_get1_default_config_file(void);
+int CONF_parse_list(char *list, int sep, int nospc,
+ int (*list_cb)(char *elem, int len, void *usr), void *arg);
+
/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
* made after this point may be overwritten when the script is next run.
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index 234eb7a06e..100d72ed03 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -57,6 +57,7 @@
*/
#include <stdio.h>
+#include <ctype.h>
#include <openssl/crypto.h>
#include "cryptlib.h"
#include <openssl/conf.h>
@@ -549,3 +550,48 @@ char *CONF_get1_default_config_file(void)
return file;
}
+
+/* This function takes a list separated by 'sep' and calls the
+ * callback function giving the start and length of each member
+ * optionally stripping leading and trailing whitespace. This can
+ * be used to parse comma separated lists for example.
+ */
+
+int CONF_parse_list(char *list, int sep, int nospc,
+ int (*list_cb)(char *elem, int len, void *usr), void *arg)
+ {
+ int ret;
+ char *lstart, *tmpend, *p;
+ lstart = list;
+
+ for(;;)
+ {
+ if (nospc)
+ {
+ while(*lstart && isspace((unsigned char)*lstart))
+ lstart++;
+ }
+ p = strchr(lstart, sep);
+ if (p == lstart || !*lstart)
+ ret = list_cb(NULL, 0, arg);
+ else
+ {
+ if (p)
+ tmpend = p - 1;
+ else
+ tmpend = lstart + strlen(lstart) - 1;
+ if (nospc)
+ {
+ while(isspace((unsigned char)*tmpend))
+ tmpend--;
+ }
+ ret = list_cb(lstart, tmpend - lstart + 1, arg);
+ }
+ if (ret <= 0)
+ return ret;
+ if (p == NULL)
+ return 1;
+ lstart = p + 1;
+ }
+ }
+