mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
s3-lib Move sstring_sub() to it's only user and make static
This should not be used more generally, as it is specifically not for multibyte strings, and uses malloc rather than talloc. Andrew Bartlett
This commit is contained in:
parent
8d639feed9
commit
a5a2373979
@ -897,7 +897,6 @@ void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
|
||||
int asprintf_strupper_m(char **strp, const char *fmt, ...);
|
||||
char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...);
|
||||
char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...);
|
||||
char *sstring_sub(const char *src, char front, char back);
|
||||
bool validate_net_name( const char *name,
|
||||
const char *invalid_chars,
|
||||
int max_len);
|
||||
|
@ -1143,33 +1143,6 @@ char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Check a string for any occurrences of a specified list of invalid
|
||||
characters.
|
||||
|
@ -68,6 +68,33 @@ struct samsync_ldif_context {
|
||||
int num_alloced;
|
||||
};
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
static 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;
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
****************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user