summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-03-16 21:59:20 +0000
committerJeremy Allison <jra@samba.org>2004-03-16 21:59:20 +0000
commit3e326c48c9bffa8f47f35d0444efec3e5927856e (patch)
tree4a9b7db2369fd69cffcddaf3ad6eebf18944f146 /source3/lib
parent2f8a18c093938f7aa31541f9b56da9be23fb861b (diff)
downloadsamba-3e326c48c9bffa8f47f35d0444efec3e5927856e.tar.gz
samba-3e326c48c9bffa8f47f35d0444efec3e5927856e.tar.bz2
samba-3e326c48c9bffa8f47f35d0444efec3e5927856e.zip
Add function next_mb_char_size() that returns a size_t of the number of
bytes in the mb character at a pointer. Will be useful in fixing check_path_syntax() to not use a "blacklist". Also re-added my (C) to reply.c. I mean, really - I've been adding code to the file for over 10 years and I recognise many of the fuctions as mine ! :-). Jeremy. (This used to be commit 5a804dbe0f3ddbd6f3fbdd6b2c5510e143607541)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/charcnv.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index b06d869bcc..9ec6e73970 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -1313,3 +1313,27 @@ size_t align_string(const void *base_ptr, const char *p, int flags)
}
return 0;
}
+
+/****************************************************************
+ Calculate the size (in bytes) of the next multibyte character in
+ our internal character set. Note that p must be pointing to a
+ valid mb char, not within one.
+****************************************************************/
+
+size_t next_mb_char_size(const char *s)
+{
+ size_t i;
+
+ if (!(*s & 0x80))
+ return 1; /* ascii. */
+
+ for ( i = 1; i <=4; i++ ) {
+ smb_ucs2_t uc;
+ if (convert_string(CH_UNIX, CH_UCS2, s, i, &uc, 2, False) == 2) {
+ return i;
+ }
+ }
+ /* We're hosed - we don't know how big this is... */
+ DEBUG(10,("next_mb_char_size: unknown size at string %s\n", s));
+ return 1;
+}