]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Move utf16_len[_n]() to lib/util/charset/
authorVolker Lendecke <vl@samba.org>
Tue, 5 Jan 2021 09:27:12 +0000 (10:27 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 12 Jan 2021 00:10:30 +0000 (00:10 +0000)
util_unistr.c references it, avoid broken dependencies

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/charset/charset.h
lib/util/charset/util_unistr.c
lib/util/samba_util.h
lib/util/util_str.c

index 3aa8a812cccb276ff0bcec63258bfdd346175653..c62832cccd635fdc77e8128b1b9d0b9ad9feb5f2 100644 (file)
@@ -95,6 +95,19 @@ struct smb_iconv_handle;
 
 size_t ucs2_align(const void *base_ptr, const void *p, int flags);
 
+/**
+return the number of bytes occupied by a buffer in CH_UTF16 format
+the result includes the null termination
+**/
+size_t utf16_len(const void *buf);
+
+/**
+return the number of bytes occupied by a buffer in CH_UTF16 format
+the result includes the null termination
+limited by 'n' bytes
+**/
+size_t utf16_len_n(const void *src, size_t n);
+
 char *strchr_m(const char *s, char c);
 /**
  * Calculate the number of units (8 or 16-bit, depending on the
index ed394f58aef82dcee3d5b8cfeda0fff5b8c8ddf1..585cb787d092104dd59ab04d3291d0ac05a1df37 100644 (file)
@@ -188,6 +188,36 @@ size_t ucs2_align(const void *base_ptr, const void *p, int flags)
        return PTR_DIFF(p, base_ptr) & 1;
 }
 
+/**
+return the number of bytes occupied by a buffer in CH_UTF16 format
+the result includes the null termination
+**/
+size_t utf16_len(const void *buf)
+{
+       size_t len;
+
+       for (len = 0; SVAL(buf,len); len += 2) ;
+
+       return len + 2;
+}
+
+/**
+return the number of bytes occupied by a buffer in CH_UTF16 format
+the result includes the null termination
+limited by 'n' bytes
+**/
+size_t utf16_len_n(const void *src, size_t n)
+{
+       size_t len;
+
+       for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ;
+
+       if (len+2 <= n) {
+               len += 2;
+       }
+
+       return len;
+}
 
 /**
  * Copy a string from a char* unix src to a dos codepage string destination.
index a8be028e5638cccceadca67d663726ae2db3954e..f0bfa809d7bd7730313b392b81def81110c5ad33 100644 (file)
@@ -312,19 +312,6 @@ _PUBLIC_ bool conv_str_size_error(const char * str, uint64_t * val);
  */
 _PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val);
 
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-**/
-_PUBLIC_ size_t utf16_len(const void *buf);
-
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-limited by 'n' bytes
-**/
-_PUBLIC_ size_t utf16_len_n(const void *src, size_t n);
-
 /**
  * @brief Constant time compare to memory regions.
  *
index c7773e0c927490ee196e369fa84a34f4f07c709a..da1989f80f298f718f8fd7e58a91a2ef49bdca54 100644 (file)
@@ -305,37 +305,6 @@ _PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean)
        return false;
 }
 
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-**/
-_PUBLIC_ size_t utf16_len(const void *buf)
-{
-       size_t len;
-
-       for (len = 0; SVAL(buf,len); len += 2) ;
-
-       return len + 2;
-}
-
-/**
-return the number of bytes occupied by a buffer in CH_UTF16 format
-the result includes the null termination
-limited by 'n' bytes
-**/
-_PUBLIC_ size_t utf16_len_n(const void *src, size_t n)
-{
-       size_t len;
-
-       for (len = 0; (len+2 < n) && SVAL(src, len); len += 2) ;
-
-       if (len+2 <= n) {
-               len += 2;
-       }
-
-       return len;
-}
-
 _PUBLIC_ int memcmp_const_time(const void *s1, const void *s2, size_t n)
 {
        const uint8_t *p1 = s1, *p2 = s2;