lib/util Move alpha_strcpy() from s3 into common code
authorAndrew Bartlett <abartlet@samba.org>
Thu, 14 Apr 2011 05:48:00 +0000 (15:48 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 14 Apr 2011 07:21:59 +0000 (09:21 +0200)
Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Thu Apr 14 09:21:59 CEST 2011 on sn-devel-104

lib/util/charset/util_unistr.c
lib/util/util_str_common.c
source3/include/proto.h
source3/lib/util_str.c

index ddb15f88f9351e97b7f21a2dbe6d0e8e791829d8..a1be501c7ced21b3328b22ad0334d55c3f04f5c5 100644 (file)
@@ -38,52 +38,6 @@ _PUBLIC_ void string_replace_m(char *s, char oldc, char newc)
        }
 }
 
        }
 }
 
-/**
- 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. Don't change it !
-**/
-
-_PUBLIC_ char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength)
-{
-       size_t len, i;
-
-       if (maxlength == 0) {
-               /* can't fit any bytes at all! */
-               return NULL;
-       }
-
-       if (!dest) {
-               DEBUG(0,("ERROR: NULL dest in alpha_strcpy\n"));
-               return NULL;
-       }
-
-       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 (isupper(val) || islower(val) || isdigit(val) || strchr_m(other_safe_chars, val))
-                       dest[i] = src[i];
-               else
-                       dest[i] = '_';
-       }
-
-       dest[i] = '\0';
-
-       return dest;
-}
-
 /**
  Convert a string to lower case, allocated with talloc
 **/
 /**
  Convert a string to lower case, allocated with talloc
 **/
index e6671be8ad45650f015e2db897258349ac52b6fb..fe78d65020bfb6d9879db2a994e1fbf49279f74e 100644 (file)
@@ -102,3 +102,54 @@ void string_replace( char *s, char oldc, char newc )
                p += c_size;
        }
 }
                p += c_size;
        }
 }
+
+
+/**
+ 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;
+}
index 4362ddb9b82ad9b2bba3adb2077090b2269a393f..2b6e168248f3ffa75201c925897ebe4f08b8f537 100644 (file)
@@ -968,10 +968,6 @@ char *safe_strcpy_fn(char *dest,
 char *safe_strcat_fn(char *dest,
                const char *src,
                size_t maxlength);
 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);
 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);
index 13b415070d9df26a00996cbc4c63ff91b9fa298f..88a3d703f4d81316779b9e8dd9c548ae48ac1dfd 100644 (file)
@@ -398,56 +398,6 @@ char *safe_strcat_fn(char *dest,
        return dest;
 }
 
        return 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.
 /**
  Like strncpy but always null terminates. Make sure there is room!
  The variable n should always be one less than the available size.