diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-04-14 15:48:00 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-04-14 09:21:59 +0200 |
commit | e1078b87ded65bd7af8401597ae017b90bdf3ce0 (patch) | |
tree | 3d06711f5ae0514b40b9398b6c84db9fcd6ecbe4 /source3 | |
parent | bbeba18b1ce2cae4a7fcdf040c168f89ce118861 (diff) | |
download | samba-e1078b87ded65bd7af8401597ae017b90bdf3ce0.tar.gz samba-e1078b87ded65bd7af8401597ae017b90bdf3ce0.tar.bz2 samba-e1078b87ded65bd7af8401597ae017b90bdf3ce0.zip |
lib/util Move alpha_strcpy() from s3 into common code
Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Thu Apr 14 09:21:59 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 4 | ||||
-rw-r--r-- | source3/lib/util_str.c | 50 |
2 files changed, 0 insertions, 54 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 4362ddb9b8..2b6e168248 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -968,10 +968,6 @@ char *safe_strcpy_fn(char *dest, char *safe_strcat_fn(char *dest, const char *src, size_t maxlength); -char *alpha_strcpy(char *dest, - const char *src, - const char *other_safe_chars, - size_t maxlength); char *StrnCpy(char *dest,const char *src,size_t n); bool in_list(const char *s, const char *list, bool casesensitive); void string_free(char **s); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 13b415070d..88a3d703f4 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -399,56 +399,6 @@ char *safe_strcat_fn(char *dest, } /** - Paranoid strcpy into a buffer of given length (includes terminating - zero. Strips out all but 'a-Z0-9' and the character in other_safe_chars - and replaces with '_'. Deliberately does *NOT* check for multibyte - characters. Treats src as an array of bytes, not as a multibyte - string. Any byte >0x7f is automatically converted to '_'. - other_safe_chars must also contain an ascii string (bytes<0x7f). -**/ - -char *alpha_strcpy(char *dest, - const char *src, - const char *other_safe_chars, - size_t maxlength) -{ - size_t len, i; - - if (!dest) { - smb_panic("ERROR: NULL dest in alpha_strcpy"); - } - - if (!src) { - *dest = 0; - return dest; - } - - len = strlen(src); - if (len >= maxlength) - len = maxlength - 1; - - if (!other_safe_chars) - other_safe_chars = ""; - - for(i = 0; i < len; i++) { - int val = (src[i] & 0xff); - if (val > 0x7f) { - dest[i] = '_'; - continue; - } - if (isupper(val) || islower(val) || - isdigit(val) || strchr(other_safe_chars, val)) - dest[i] = src[i]; - else - dest[i] = '_'; - } - - dest[i] = '\0'; - - return dest; -} - -/** Like strncpy but always null terminates. Make sure there is room! The variable n should always be one less than the available size. **/ |