s3:passdb: add sid_check_object_is_for_passdb()
[kai/samba.git] / source3 / registry / reg_parse_internal.h
1 /*
2  * Unix SMB/CIFS implementation.
3  *
4  * Registry helper routines
5  *
6  * Copyright (C) Gregor Beck 2010
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 /**
23  * @brief  Some stuff used by reg_parse and reg_format.
24  * It might be usefull elsewehre but need some review of the interfaces.
25  * @file   reg_parse_internal.h
26  * @author Gregor Beck <gb@sernet.de>
27  * @date   Sep 2010
28  */
29 #ifndef __REG_PARSE_INTERNAL_H
30 #define __REG_PARSE_INTERNAL_H
31
32 #include "includes.h"
33 #include "system/iconv.h"
34
35 struct cbuf;
36
37 #define USE_NATIVE_ICONV
38 #if defined USE_NATIVE_ICONV && defined HAVE_NATIVE_ICONV
39 #  define smb_iconv_t     iconv_t
40 #  define smb_iconv(CD, IPTR, ILEN, OPTR, OLEN) \
41         iconv(CD, (char**)(IPTR), ILEN, OPTR, OLEN)
42 #  define smb_iconv_open  iconv_open
43 #  define smb_iconv_close iconv_close
44 #endif
45
46 size_t iconvert_talloc(const void* ctx,
47                        smb_iconv_t cd,
48                        const char* src, size_t srclen,
49                        char** pdst);
50
51 struct hive_info {
52         uint32_t handle;
53         const char* short_name;
54         size_t short_name_len;
55         const char* long_name;
56         size_t long_name_len;
57 };
58
59 extern const struct hive_info HIVE_INFO_HKLM;
60 extern const struct hive_info HIVE_INFO_HKCU;
61 extern const struct hive_info HIVE_INFO_HKCR;
62 extern const struct hive_info HIVE_INFO_HKU;
63 extern const struct hive_info HIVE_INFO_HKCC;
64 extern const struct hive_info HIVE_INFO_HKDD;
65 extern const struct hive_info HIVE_INFO_HKPD;
66 extern const struct hive_info HIVE_INFO_HKPT;
67 extern const struct hive_info HIVE_INFO_HKPN;
68
69 extern const struct hive_info* HIVE_INFO[];
70
71 const struct hive_info* hive_info(const char* name);
72 bool srprs_hive(const char** ptr, const struct hive_info** result);
73
74
75
76 const char* get_charset(const char* c);
77
78 bool set_iconv(smb_iconv_t* t, const char* to, const char* from);
79
80 /**
81  * Parse option string
82  * @param[in,out] ptr parse position
83  * @param[in] mem_ctx talloc context
84  * @param[out] name ptr 2 value
85  * @param[out] value ptr 2 value
86  * @return true on success
87  */
88 bool srprs_option(const char** ptr, const void* mem_ctx, char** name, char** value);
89
90 /**
91  * Write Byte Order Mark for \p charset to file.
92  * If \c charset==NULL write BOM for \p ctype.
93  *
94  * @param[in] file file to write to
95  * @param[in] charset
96  * @param[in] ctype
97  *
98  * @return number of bytes written, -1 on error
99  * @todo write to cbuf
100  */
101 int write_bom(FILE* file, const char* charset, charset_t ctype);
102
103 /**
104  * Parse Byte Order Mark.
105  *
106  * @param[in,out] ptr parse position
107  * @param[out] name name of characterset
108  * @param[out] ctype charset_t
109  *
110  * @return true if found
111  * @ingroup parse bom
112  */
113 bool srprs_bom(const char** ptr, const char** name, charset_t* ctype);
114
115 enum fmt_case {
116         FMT_CASE_PRESERVE=0,
117         FMT_CASE_UPPER,
118         FMT_CASE_LOWER,
119         FMT_CASE_TITLE
120 };
121 int cbuf_puts_case(struct cbuf* s, const char* str, size_t len, enum fmt_case fmt);
122
123 #endif /* __REG_PARSE_INTERNAL_H */