1/*
2 * Copyright (c) 2008 - 2009 Apple Inc. All rights reserved.
3
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef _SMB_CONVERTER_H_
26#define _SMB_CONVERTER_H_
27
28/*
29 * Don't use the SFM conversion tables, really defined so we know that we
30 * specifically do not want to use the SFM conversions.
31 */
32#define NO_SFM_CONVERSIONS			0x0000
33/*
34 * Used when calling the smb_convert_path_to_network and smb_convert_network_to_path
35 * routines. Since UTF_SFM_CONVERSIONS is only defined in the kernel. The kernel
36 * has it defined as "Use SFM mappings for illegal NTFS chars"
37 */
38#define SMB_UTF_SFM_CONVERSIONS		0x0020
39/*
40 * Used when calling the smb_convert_path_to_network and smb_convert_network_to_path
41 * routines. Make sure the returned path is a full path, add a starting delimiter
42 * if one does exist. The calling process must make sure the buffer is large
43 * enough to hold the output plus the terminator size.
44 */
45#define SMB_FULLPATH_CONVERSIONS	0x0100
46
47#ifdef KERNEL
48#include <sys/utfconv.h>
49
50
51int smb_convert_to_network(const char **inbuf, size_t *inbytesleft, char **outbuf,
52						   size_t *outbytesleft, int flags, int usingUnicode);
53int smb_convert_from_network(const char **inbuf, size_t *inbytesleft, char **outbuf,
54							 size_t *outbytesleft, int flags, int usingUnicode);
55size_t smb_strtouni(uint16_t *dst, const char *src, size_t inlen, int flags);
56size_t smb_unitostr(char *dst, const uint16_t *src, size_t inlen, size_t maxlen, int flags);
57size_t smb_utf16_strnsize(const uint16_t *s, size_t n_bytes);
58int smb_convert_path_to_network(char *path, size_t max_path_len, char *network,
59								size_t *ntwrk_len, char ntwrk_delimiter, int inflags,
60								int usingUnicode);
61int smb_convert_network_to_path(char *network, size_t max_ntwrk_len, char *path,
62							size_t *path_len, char ntwrk_delimiter, int flags,
63							int usingUnicode);
64#endif // KERNEL
65
66#endif // _SMB_CONVERTER_H_
67