r3424: don't run mkproto.pl on pidl generated code, instead rely on pidl generating the
[samba.git] / source4 / include / rewrite.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB parameters and setup, plus a whole lot more.
4    
5    Copyright (C) Andrew Tridgell              1992-2000
6    Copyright (C) John H Terpstra              1996-2002
7    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
8    Copyright (C) Paul Ashton                  1998-2000
9    Copyright (C) Simo Sorce                   2001-2002
10    Copyright (C) Martin Pool                  2002
11    
12    This program is free software; you can redistribute it and/or modify
13    it under the terms of the GNU General Public License as published by
14    the Free Software Foundation; either version 2 of the License, or
15    (at your option) any later version.
16    
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21    
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27 #ifndef _REWRITE_H
28 #define _REWRITE_H
29
30 #define False (0)
31 #define True (1)
32 #define Auto (2)
33
34 #ifndef _BOOL
35 typedef int BOOL;
36 #define _BOOL       /* So we don't typedef BOOL again in vfs.h */
37 #endif
38
39 /* string manipulation flags - see clistr.c and srvstr.c */
40 #define STR_TERMINATE 1
41 #define STR_UPPER 2
42 #define STR_ASCII 4
43 #define STR_UNICODE 8
44 #define STR_NOALIGN 16
45 #define STR_NO_RANGE_CHECK 32
46 #define STR_LEN8BIT 64
47 #define STR_TERMINATE_ASCII 128 /* only terminate if ascii */
48 #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */
49
50 /* Debugging stuff */
51 #include "debug.h"
52 #include "doserr.h"
53
54 /* for compatibility */
55 #define SID_NAME_USE samr_SidType
56
57 /* used to hold an arbitrary blob of data */
58 typedef struct data_blob {
59         uint8_t *data;
60         size_t length;
61 } DATA_BLOB;
62
63 /* Globally Unique ID */
64 #define GUID_SIZE 16
65
66 /* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30 */
67 typedef uint64_t NTTIME;
68
69 /* 8 byte aligned 'hyper' type from MS IDL */
70 typedef uint64_t HYPER_T;
71
72
73 #include "enums.h"
74 #include "events.h"
75
76 /* used for network interfaces */
77 struct interface
78 {
79         struct interface *next, *prev;
80         struct in_addr ip;
81         struct in_addr bcast;
82         struct in_addr nmask;
83 };
84
85 /* the following are used by loadparm for option lists */
86 typedef enum
87 {
88   P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
89   P_STRING,P_USTRING,P_ENUM,P_SEP
90 } parm_type;
91
92 typedef enum
93 {
94   P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
95 } parm_class;
96
97 struct enum_list {
98         int value;
99         const char *name;
100 };
101
102 struct parm_struct
103 {
104         const char *label;
105         parm_type type;
106         parm_class class;
107         void *ptr;
108         BOOL (*special)(const char *, char **);
109         const struct enum_list *enum_list;
110         uint_t flags;
111         union {
112                 BOOL bvalue;
113                 int ivalue;
114                 char *svalue;
115                 char cvalue;
116                 char **lvalue;
117         } def;
118 };
119
120 struct bitmap {
121         uint32_t *b;
122         uint_t n;
123 };
124
125 #define FLAG_BASIC      0x0001 /* fundamental options */
126 #define FLAG_SHARE      0x0002 /* file sharing options */
127 #define FLAG_PRINT      0x0004 /* printing options */
128 #define FLAG_GLOBAL     0x0008 /* local options that should be globally settable in SWAT */
129 #define FLAG_WIZARD     0x0010 /* Parameters that the wizard will operate on */
130 #define FLAG_ADVANCED   0x0020 /* Parameters that the wizard will operate on */
131 #define FLAG_DEVELOPER  0x0040 /* Parameters that the wizard will operate on */
132 #define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
133 #define FLAG_HIDE       0x2000 /* options that should be hidden in SWAT */
134 #define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
135 #define FLAG_CMDLINE    0x8000 /* this option was set from the command line */
136
137 #ifndef LOCKING_VERSION
138 #define LOCKING_VERSION 4
139 #endif /* LOCKING_VERSION */
140
141 #ifndef SIGNAL_CAST
142 #define SIGNAL_CAST (RETSIGTYPE (*)(int))
143 #endif
144
145 #ifndef SELECT_CAST
146 #define SELECT_CAST
147 #endif
148
149 /*
150  * Loopback command offsets.
151  */
152
153 #define OPBRK_CMD_LEN_OFFSET 0
154 #define OPBRK_CMD_PORT_OFFSET 4
155 #define OPBRK_CMD_HEADER_LEN 6
156
157 #define OPBRK_MESSAGE_CMD_OFFSET 0
158
159 /* Message types */
160 #define OPLOCK_BREAK_CMD 0x1
161 #define KERNEL_OPLOCK_BREAK_CMD 0x2
162 #define LEVEL_II_OPLOCK_BREAK_CMD 0x3
163 #define ASYNC_LEVEL_II_OPLOCK_BREAK_CMD 0x4
164
165 /*
166  * Capabilities abstracted for different systems.
167  */
168
169 #define KERNEL_OPLOCK_CAPABILITY 0x1
170
171 /*
172  * Oplock break command code sent via the kernel interface (if it exists).
173  *
174  * Form of this is :
175  *
176  *  0     2       2+devsize 2+devsize+inodesize
177  *  +----+--------+--------+----------+
178  *  | cmd| dev    |  inode |  fileid  |
179  *  +----+--------+--------+----------+
180  */
181 #define KERNEL_OPLOCK_BREAK_DEV_OFFSET 2
182 #define KERNEL_OPLOCK_BREAK_INODE_OFFSET (KERNEL_OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
183 #define KERNEL_OPLOCK_BREAK_FILEID_OFFSET (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
184 #define KERNEL_OPLOCK_BREAK_MSG_LEN (KERNEL_OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
185
186
187 #define CMD_REPLY 0x8000
188
189 #include "smb_macros.h"
190
191 /* A netbios name structure. */
192 struct nmb_name {
193         char         name[17];
194         char         scope[64];
195         uint_t name_type;
196 };
197
198
199 /* A netbios node status array element. */
200 struct node_status {
201         char name[16];
202         uint8_t type;
203         uint8_t flags;
204 };
205
206 #include "rpc_secdes.h"
207
208 #include "client.h"
209
210 /*
211    Do you want session setups at user level security with a invalid
212    password to be rejected or allowed in as guest? WinNT rejects them
213    but it can be a pain as it means "net view" needs to use a password
214
215    You have 3 choices in the setting of map_to_guest:
216
217    "NEVER_MAP_TO_GUEST" means session setups with an invalid password
218    are rejected. This is the default.
219
220    "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
221    are rejected, unless the username does not exist, in which case it
222    is treated as a guest login
223
224    "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
225    are treated as a guest login
226
227    Note that map_to_guest only has an effect in user or server
228    level security.
229 */
230
231 #define NEVER_MAP_TO_GUEST 0
232 #define MAP_TO_GUEST_ON_BAD_USER 1
233 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
234
235 #define SAFE_NETBIOS_CHARS ". -_"
236
237 /* generic iconv conversion structure */
238 typedef struct {
239         size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
240                          char **outbuf, size_t *outbytesleft);
241         size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
242                        char **outbuf, size_t *outbytesleft);
243         size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
244                        char **outbuf, size_t *outbytesleft);
245         void *cd_direct, *cd_pull, *cd_push;
246 } *smb_iconv_t;
247
248 #include "lib/cmdline/popt_common.h"
249
250 #endif /* _REWRITE_H */