summaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-01-26 17:14:49 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-01-26 17:14:49 +0000
commit74edf282e97f18ba5f79574f3e196211cf927a16 (patch)
tree70ec250bbf85c3ddb4d04790d065cd67faafa6dd /src/misc.c
parent033ce652559ac342a94bdf9edbabe77ed1e81369 (diff)
Bug: 425 - export buildStringList for modules to use.
git-svn-id: svn://svn.anope.org/anope/trunk@960 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@687 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c
index 478fe98bb..7ac0a809e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1158,4 +1158,31 @@ void ntoa(struct in_addr addr, char *ipaddr, int len)
bytes[3]);
}
+/**
+ * Build a string list from a given source string.
+ * This is usually used for parsing out values from the config file, but could
+ * be used for other things.
+ * NOTE: this function uses strtok(), be aware it will break any buffer you think you have in there ;)
+ **/
+char **buildStringList(char *src, int *number)
+{
+ char *s;
+ int i = 0;
+ char **list = NULL;
+
+ if (src) {
+ s = strtok(src, " ");
+ do {
+ if (s) {
+ i++;
+ list = realloc(list, sizeof(char *) * i);
+ list[i - 1] = sstrdup(s);
+ }
+ } while ((s = strtok(NULL, " ")));
+ }
+ *number = i; /* always zero it, even if we have no setters */
+ return list;
+}
+
+
/* EOF */