1 /* 2 * unistr.h - Exports for Unicode string handling. Originated from the Linux-NTFS 3 * project. 4 * 5 * Copyright (c) 2000-2004 Anton Altaparmakov 6 * 7 * This program/include file is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as published 9 * by the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program/include file is distributed in the hope that it will be 13 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program (in the main directory of the NTFS-3G 19 * distribution in the file COPYING); if not, write to the Free Software 20 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 23 #ifndef _NTFS_UNISTR_H 24 #define _NTFS_UNISTR_H 25 26 #include "types.h" 27 #include "layout.h" 28 29 extern BOOL ntfs_names_are_equal(const ntfschar *s1, size_t s1_len, 30 const ntfschar *s2, size_t s2_len, const IGNORE_CASE_BOOL ic, 31 const ntfschar *upcase, const u32 upcase_size); 32 33 extern int ntfs_names_full_collate(const ntfschar *name1, const u32 name1_len, 34 const ntfschar *name2, const u32 name2_len, 35 const IGNORE_CASE_BOOL ic, 36 const ntfschar *upcase, const u32 upcase_len); 37 38 extern int ntfs_ucsncmp(const ntfschar *s1, const ntfschar *s2, size_t n); 39 40 extern int ntfs_ucsncasecmp(const ntfschar *s1, const ntfschar *s2, size_t n, 41 const ntfschar *upcase, const u32 upcase_size); 42 43 extern u32 ntfs_ucsnlen(const ntfschar *s, u32 maxlen); 44 45 extern ntfschar *ntfs_ucsndup(const ntfschar *s, u32 maxlen); 46 47 extern void ntfs_name_upcase(ntfschar *name, u32 name_len, 48 const ntfschar *upcase, const u32 upcase_len); 49 50 extern void ntfs_name_locase(ntfschar *name, u32 name_len, 51 const ntfschar *locase, const u32 locase_len); 52 53 extern void ntfs_file_value_upcase(FILE_NAME_ATTR *file_name_attr, 54 const ntfschar *upcase, const u32 upcase_len); 55 56 extern int ntfs_ucstombs(const ntfschar *ins, const int ins_len, char **outs, 57 int outs_len); 58 extern int ntfs_mbstoucs(const char *ins, ntfschar **outs); 59 60 extern char *ntfs_uppercase_mbs(const char *low, 61 const ntfschar *upcase, u32 upcase_len); 62 63 extern void ntfs_upcase_table_build(ntfschar *uc, u32 uc_len); 64 extern u32 ntfs_upcase_build_default(ntfschar **upcase); 65 extern ntfschar *ntfs_locase_table_build(const ntfschar *uc, u32 uc_cnt); 66 67 extern ntfschar *ntfs_str2ucs(const char *s, int *len); 68 69 extern void ntfs_ucsfree(ntfschar *ucs); 70 71 extern BOOL ntfs_forbidden_chars(const ntfschar *name, int len, BOOL strict); 72 extern BOOL ntfs_forbidden_names(ntfs_volume *vol, 73 const ntfschar *name, int len, BOOL strict); 74 extern BOOL ntfs_collapsible_chars(ntfs_volume *vol, 75 const ntfschar *shortname, int shortlen, 76 const ntfschar *longname, int longlen); 77 78 extern int ntfs_set_char_encoding(const char *locale); 79 80 #if defined(__APPLE__) || defined(__DARWIN__) 81 /** 82 * Mac OS X only. 83 * 84 * Sets file name Unicode normalization form conversion on or off. 85 * normalize=0 : Off 86 * normalize=1 : On 87 * If set to on, all filenames returned by ntfs-3g will be converted to the NFD 88 * normalization form, while all filenames recieved by ntfs-3g will be converted to the NFC 89 * normalization form. Since Windows and most other OS:es use the NFC form while Mac OS X 90 * mostly uses NFD, this conversion increases compatibility between Mac applications and 91 * NTFS-3G. 92 * 93 * @param normalize decides whether or not the string functions will do automatic filename 94 * normalization when converting to and from UTF-8. 0 means normalization is disabled, 95 * 1 means it is enabled. 96 * @return -1 if the argument was invalid or an error occurred, 0 if all went well. 97 */ 98 extern int ntfs_macosx_normalize_filenames(int normalize); 99 100 /** 101 * Mac OS X only. 102 * 103 * Normalizes the input string "utf8_string" to one of the normalization forms NFD or NFC. 104 * The parameter "composed" decides whether output should be in composed, NFC, form 105 * (composed == 1) or decomposed, NFD, form (composed == 0). 106 * Input is assumed to be properly UTF-8 encoded and null-terminated. Output will be a newly 107 * ntfs_calloc'ed string encoded in UTF-8. It is the callers responsibility to free(...) the 108 * allocated string when it's no longer needed. 109 * 110 * @param utf8_string the input string, which may be in any normalization form. 111 * @param target a pointer where the resulting string will be stored. 112 * @param composed decides which composition form to normalize the input string to. 0 means 113 * composed form (NFC), 1 means decomposed form (NFD). 114 * @return -1 if the normalization failed for some reason, otherwise the length of the 115 * normalized string stored in target. 116 */ 117 extern int ntfs_macosx_normalize_utf8(const char *utf8_string, char **target, int composed); 118 #endif /* defined(__APPLE__) || defined(__DARWIN__) */ 119 120 #endif /* defined _NTFS_UNISTR_H */ 121 122