From fbe19a11f887c959d03bfb7c93e7dbda8e73f54b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 15 Jul 2009 21:17:17 +0000 Subject: [PATCH] * Fixed several build issues. * Removed the broken character conversion functions of the Haiku "port". Instead map the 4 unused wchar/locale support functions to panic(). Eventually we might want to provide minimalistic wchar support in the kernel instead, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31596 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/ntfs/libntfs/Jamfile | 7 +- .../kernel/file_systems/ntfs/libntfs/config.h | 2 + .../kernel/file_systems/ntfs/libntfs/unistr.c | 221 +----------------- .../kernel/file_systems/ntfs/libntfs/unistr.h | 2 + 4 files changed, 18 insertions(+), 214 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile b/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile index 7fe9d771b0..2e0cd3360d 100644 --- a/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile +++ b/src/add-ons/kernel/file_systems/ntfs/libntfs/Jamfile @@ -1,8 +1,10 @@ SubDir HAIKU_TOP src add-ons kernel file_systems ntfs libntfs ; -SubDirCcFlags -Wall -Wno-multichar -DHAVE_CONFIG_H=1 ; +SubDirCcFlags -Wall -Wno-multichar ; -StaticLibrary libntfs.a : +DEFINES += HAVE_CONFIG_H=1 ; + +KernelStaticLibrary libntfs.a : attrib.c attrlist.c bitmap.c @@ -27,4 +29,3 @@ StaticLibrary libntfs.a : unistr.c volume.c ; - diff --git a/src/add-ons/kernel/file_systems/ntfs/libntfs/config.h b/src/add-ons/kernel/file_systems/ntfs/libntfs/config.h index ecd07c1f65..6e58ab7283 100644 --- a/src/add-ons/kernel/file_systems/ntfs/libntfs/config.h +++ b/src/add-ons/kernel/file_systems/ntfs/libntfs/config.h @@ -12,6 +12,8 @@ /* Define to 1 if you have the header file. */ #define HAVE_CTYPE_H 1 +#define HAVE_DAEMON 1 + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H diff --git a/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c b/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c index 2b919eb11f..de151f077d 100644 --- a/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c +++ b/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.c @@ -55,6 +55,15 @@ #define NOREVBOM 0 /* JPA rejecting U+FFFE and U+FFFF, open to debate */ +// no wchar support in the Haiku kernel +#if defined(__HAIKU__) && defined(_KERNEL_MODE) +# include +# define mbstowcs(a, b, c) (panic("mbstowcs"), 0) +# define wctomb(a, b) (panic("wctomb"), 0) +# define mbtowc(a, b, c) (panic("mbtowc"), 0) +# define setlocale(a, b) (panic("setlocale"), 0) +#endif + /* * IMPORTANT * ========= @@ -62,9 +71,8 @@ * All these routines assume that the Unicode characters are in little endian * encoding inside the strings!!! */ -#ifndef __HAIKU__ static int use_utf8 = 1; /* use UTF-8 encoding for file names */ -#endif + /* * This is used by the name collation functions to quickly determine what * characters are (in)valid. @@ -383,7 +391,6 @@ int ntfs_file_values_compare(const FILE_NAME_ATTR *file_name_attr1, err_val, ic, upcase, upcase_len); } -#ifndef __HAIKU__ /* NTFS uses Unicode (UTF-16LE [NTFS-3G uses UCS-2LE, which is enough for now]) for path names, but the Unicode code points need to be @@ -700,208 +707,6 @@ static int ntfs_utf8_to_utf16(const char *ins, ntfschar **outs) fail: return ret; } -#endif - -#ifdef __HAIKU__ -/* Encode a single wide character into a sequence of utf8 bytes. - * Returns the number of bytes consumed, or 0 on error. - */ -static int -ntfs_utf16_to_utf8(ntfschar c, unsigned char* buf) -{ - if(c==0) - return 0; /* No support for embedded 0 runes */ - if(c<0x80) { - if(buf)buf[0]=(unsigned char)c; - return 1; - } - if(c<0x800) { - if(buf) { - buf[0] = 0xc0 | (c>>6); - buf[1] = 0x80 | (c & 0x3f); - } - return 2; - } - if(c<0x10000) { - if(buf) { - buf[0] = 0xe0 | (c>>12); - buf[1] = 0x80 | ((c>>6) & 0x3f); - buf[2] = 0x80 | (c & 0x3f); - } - return 3; - } - /* We don't support characters above 0xFFFF in NTFS */ - return 0; -} - - -/* Decodes a sequence of utf8 bytes into a single wide character. - * The character is returned in host byte order. - * Returns the number of bytes consumed, or 0 on error. - */ -static int -ntfs_utf16_from_utf8(const unsigned char* str, ntfschar* c) -{ - int l=0,i; - - if(*str<0x80) { - *c = *str; - return 1; - } - if(*str<0xc0) /* lead byte must not be 10xxxxxx */ - return 0; /* is c0 a possible lead byte? */ - if(*str<0xe0) { /* 110xxxxx */ - *c = *str & 0x1f; - l=2; - } else if(*str<0xf0) { /* 1110xxxx */ - *c = *str & 0xf; - l=3; - } else if(*str<0xf8) { /* 11110xxx */ - *c = *str & 7; - l=4; - } else /* We don't support characters above 0xFFFF in NTFS */ - return 0; - - - for(i=1;i= 0), not counting the terminating NULL byte. If the output - * string buffer was allocated, *@outs is set to it. - * - * On error, -1 is returned, and errno is set to the error code. The following - * error codes can be expected: - * EINVAL Invalid arguments (e.g. @ins or @outs is NULL). - * EILSEQ The input string cannot be represented as a multibyte - * sequence according to the current locale. - * ENAMETOOLONG Destination buffer is too small for input string. - * ENOMEM Not enough memory to allocate destination buffer. - */ -int ntfs_ucstombs(const ntfschar *ins, const int ins_len, char **outs, int outs_len) -{ - int out_len = outs_len; - if(ntfs_dupuni2utf8(ins,ins_len,outs,&out_len)==0) - return out_len; - else - return EINVAL; -} - -/** - * ntfs_mbstoucs - convert a multibyte string to a little endian Unicode string - * @ins: input multibyte string buffer - * @outs: on return contains the (allocated) output Unicode string - * @outs_len: length of output buffer in Unicode characters - * - * Convert the input multibyte string @ins, from the current locale into the - * corresponding little endian, 2-byte Unicode string. - * - * If *@outs is NULL, the function allocates the string and the caller is - * responsible for calling free(*@outs); when finished with it. - * - * On success the function returns the number of Unicode characters written to - * the output string *@outs (>= 0), not counting the terminating Unicode NULL - * character. If the output string buffer was allocated, *@outs is set to it. - * - * On error, -1 is returned, and errno is set to the error code. The following - * error codes can be expected: - * EINVAL Invalid arguments (e.g. @ins or @outs is NULL). - * EILSEQ The input string cannot be represented as a Unicode - * string according to the current locale. - * ENAMETOOLONG Destination buffer is too small for input string. - * ENOMEM Not enough memory to allocate destination buffer. - */ -int ntfs_mbstoucs(const char *ins, ntfschar **outs) -{ - int in_len = strlen(ins); - int out_len = 0; - if(ntfs_duputf82uni((unsigned char*)ins,in_len,outs,&out_len)==0) - return out_len; - else - return EILSEQ; -} - -#else /** * ntfs_ucstombs - convert a little endian Unicode string to a multibyte string @@ -1152,8 +957,6 @@ err_out: return -1; } -#endif //__HAIKU__ - /** * ntfs_upcase_table_build - build the default upcase table for NTFS * @uc: destination buffer where to store the built table @@ -1275,8 +1078,6 @@ void ntfs_ucsfree(ntfschar *ucs) * Define the character encoding to be used. * Use UTF-8 unless specified otherwise. */ -#ifndef __HAIKU__ - int ntfs_set_char_encoding(const char *locale) { use_utf8 = 0; @@ -1292,5 +1093,3 @@ int ntfs_set_char_encoding(const char *locale) } return 0; /* always successful */ } -#endif - diff --git a/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h b/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h index 6de4bacc52..189384cdf3 100644 --- a/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h +++ b/src/add-ons/kernel/file_systems/ntfs/libntfs/unistr.h @@ -65,5 +65,7 @@ extern ntfschar *ntfs_str2ucs(const char *s, int *len); extern void ntfs_ucsfree(ntfschar *ucs); +extern int ntfs_set_char_encoding(const char *locale); + #endif /* defined _NTFS_UNISTR_H */