summaryrefslogtreecommitdiff
path: root/source3/lib/util_str.c
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2005-07-06 21:02:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:18 -0500
commite0ffbfc5587ed296d5a9e8f5ed30b6e8b2cd6fcf (patch)
treec7650ee5c7cc4fe3925273a6f337bd7b4c0b568b /source3/lib/util_str.c
parentc379e33da6a9692cf6540a933e1b8a682645b6b1 (diff)
downloadsamba-e0ffbfc5587ed296d5a9e8f5ed30b6e8b2cd6fcf.tar.gz
samba-e0ffbfc5587ed296d5a9e8f5ed30b6e8b2cd6fcf.tar.bz2
samba-e0ffbfc5587ed296d5a9e8f5ed30b6e8b2cd6fcf.zip
r8189: commit vampire ldif patch, mostly from Don Watson (dwatson@us.ibm.com). Yes,
that's my copyright...that's just how we have to do things at big blue. Adds subcommand to vampire to allow data to be put into an ldif file instead of actually writing to the passdb. See "net rpc help vampire" for usage info. This should be added to docs as well. (This used to be commit cb5634a305256a70daa2fcbd85d9a5459b4aeaa3)
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r--source3/lib/util_str.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index f600d1704e..42229f105a 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -2194,3 +2194,30 @@ void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
*len = -1;
*string = NULL;
}
+
+/*
+ Returns the substring from src between the first occurrence of
+ the char "front" and the first occurence of the char "back".
+ Mallocs the return string which must be freed. Not for use
+ with wide character strings.
+*/
+char *sstring_sub(const char *src, char front, char back)
+{
+ char *temp1, *temp2, *temp3;
+ ptrdiff_t len;
+
+ temp1 = strchr(src, front);
+ if (temp1 == NULL) return NULL;
+ temp2 = strchr(src, back);
+ if (temp2 == NULL) return NULL;
+ len = temp2 - temp1;
+ if (len <= 0) return NULL;
+ temp3 = (char*)SMB_MALLOC(len);
+ if (temp3 == NULL) {
+ DEBUG(1,("Malloc failure in sstring_sub\n"));
+ return NULL;
+ }
+ memcpy(temp3, temp1+1, len-1);
+ temp3[len-1] = '\0';
+ return temp3;
+}