1 | /* |
---|
2 | * This file contains miscellaneous pieces of code which regfio.c |
---|
3 | * depends upon, from the Samba Subversion tree. See: |
---|
4 | * http://websvn.samba.org/cgi-bin/viewcvs.cgi/trunk/source/ |
---|
5 | * |
---|
6 | * Copyright (C) 2005,2009 Timothy D. Morgan |
---|
7 | * Copyright (C) 1992-2005 Samba development team |
---|
8 | * (see individual files under Subversion for details.) |
---|
9 | * |
---|
10 | * This program is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License as published by |
---|
12 | * the Free Software Foundation; version 3 of the License. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | * $Id: smb_deps.h 132 2009-01-11 21:44:33Z tim $ |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef _SMB_DEPS_H |
---|
27 | #define _SMB_DEPS_H |
---|
28 | |
---|
29 | #include <stdlib.h> |
---|
30 | #include <stdbool.h> |
---|
31 | #include <stdio.h> |
---|
32 | #include <string.h> |
---|
33 | #include <errno.h> |
---|
34 | #include <fcntl.h> |
---|
35 | #include <sys/stat.h> |
---|
36 | #include <sys/types.h> |
---|
37 | #include <unistd.h> |
---|
38 | |
---|
39 | #include "byteorder.h" |
---|
40 | |
---|
41 | #define DEBUG(lvl,body) 0 |
---|
42 | |
---|
43 | void* zalloc(size_t size); |
---|
44 | void* zcalloc(size_t size, unsigned int count); |
---|
45 | |
---|
46 | /* From includes.h */ |
---|
47 | |
---|
48 | #define uint8 unsigned char |
---|
49 | #define int16 short |
---|
50 | #define uint16 unsigned short |
---|
51 | #define int32 int |
---|
52 | #define uint32 unsigned int |
---|
53 | |
---|
54 | #define SMB_STRUCT_STAT struct stat |
---|
55 | #define QSORT_CAST (int (*)(const void *, const void *)) |
---|
56 | |
---|
57 | #define MIN(a,b) ((a)<(b)?(a):(b)) |
---|
58 | #define MAX(a,b) ((a)>(b)?(a):(b)) |
---|
59 | |
---|
60 | extern int DEBUGLEVEL; |
---|
61 | |
---|
62 | #define DLIST_ADD(list, p) \ |
---|
63 | { \ |
---|
64 | if (!(list)) { \ |
---|
65 | (list) = (p); \ |
---|
66 | (p)->next = (p)->prev = NULL; \ |
---|
67 | } else { \ |
---|
68 | (list)->prev = (p); \ |
---|
69 | (p)->next = (list); \ |
---|
70 | (p)->prev = NULL; \ |
---|
71 | (list) = (p); \ |
---|
72 | }\ |
---|
73 | } |
---|
74 | |
---|
75 | /* End of stuff from includes.h */ |
---|
76 | |
---|
77 | /* From smb.h */ |
---|
78 | |
---|
79 | typedef struct nttime_info |
---|
80 | { |
---|
81 | uint32 low; |
---|
82 | uint32 high; |
---|
83 | } NTTIME; |
---|
84 | |
---|
85 | /* End of stuff from smb.h */ |
---|
86 | |
---|
87 | /* From smb_macros.h */ |
---|
88 | |
---|
89 | #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) |
---|
90 | #define SMB_MALLOC_P(type) (type *)malloc_(sizeof(type)) |
---|
91 | #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) |
---|
92 | #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) |
---|
93 | #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) |
---|
94 | |
---|
95 | /* End of stuff from smb_macros.h */ |
---|
96 | |
---|
97 | /* From ntdomain.h */ |
---|
98 | |
---|
99 | struct uuid { |
---|
100 | uint32 time_low; |
---|
101 | uint16 time_mid; |
---|
102 | uint16 time_hi_and_version; |
---|
103 | uint8 clock_seq[2]; |
---|
104 | uint8 node[6]; |
---|
105 | }; |
---|
106 | |
---|
107 | typedef struct _prs_struct { |
---|
108 | bool io; /* parsing in or out of data stream */ |
---|
109 | /* |
---|
110 | * If the (incoming) data is big-endian. On output we are |
---|
111 | * always little-endian. |
---|
112 | */ |
---|
113 | bool bigendian_data; |
---|
114 | uint8 align; /* data alignment */ |
---|
115 | bool is_dynamic; /* Do we own this memory or not ? */ |
---|
116 | uint32 data_offset; /* Current working offset into data. */ |
---|
117 | uint32 buffer_size; /* Current allocated size of the buffer. */ |
---|
118 | uint32 grow_size; /* size requested via prs_grow() calls */ |
---|
119 | char *data_p; /* The buffer itself. */ |
---|
120 | void *mem_ctx; /* When unmarshalling, use this.... */ |
---|
121 | } prs_struct; |
---|
122 | |
---|
123 | #define MARSHALL 0 |
---|
124 | #define UNMARSHALL 1 |
---|
125 | |
---|
126 | #define RPC_LITTLE_ENDIAN 0 |
---|
127 | #define RPC_PARSE_ALIGN 4 |
---|
128 | |
---|
129 | /* End of stuff from ntdomain.h */ |
---|
130 | |
---|
131 | |
---|
132 | /* From lib/time.c */ |
---|
133 | |
---|
134 | #define CHAR_BIT 8 |
---|
135 | #define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \ |
---|
136 | : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)) |
---|
137 | #define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) |
---|
138 | #define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60)) |
---|
139 | |
---|
140 | void unix_to_nt_time(NTTIME* nt, time_t t); |
---|
141 | time_t nt_time_to_unix(const NTTIME* nt); |
---|
142 | |
---|
143 | /* End of stuff from lib/time.c */ |
---|
144 | |
---|
145 | /* From rpc_dce.h */ |
---|
146 | |
---|
147 | #define MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */ |
---|
148 | |
---|
149 | /* End of stuff from rpc_dce.h */ |
---|
150 | |
---|
151 | /* From parse_prs.h */ |
---|
152 | |
---|
153 | bool prs_grow(prs_struct *ps, uint32 extra_space); |
---|
154 | bool prs_align(prs_struct *ps); |
---|
155 | bool prs_init(prs_struct *ps, uint32 size, void *ctx, bool io); |
---|
156 | char *prs_mem_get(prs_struct *ps, uint32 extra_size); |
---|
157 | bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32); |
---|
158 | bool prs_uint32s(const char *name, prs_struct *ps, |
---|
159 | int depth, uint32 *data32s, int len); |
---|
160 | bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16); |
---|
161 | bool prs_uint16_pre(const char *name, prs_struct *ps, int depth, |
---|
162 | uint16 *data16, uint32 *offset); |
---|
163 | bool prs_uint16_post(const char *name, prs_struct *ps, int depth, |
---|
164 | uint16 *data16, uint32 ptr_uint16, uint32 start_offset); |
---|
165 | bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8); |
---|
166 | bool prs_uint8s(const char *name, prs_struct *ps, int depth, |
---|
167 | uint8* data8s, int len); |
---|
168 | bool prs_set_offset(prs_struct *ps, uint32 offset); |
---|
169 | |
---|
170 | /* End of stuff from parse_prs.h */ |
---|
171 | |
---|
172 | |
---|
173 | /* From pstring.h */ |
---|
174 | |
---|
175 | #define FSTRING_LEN 256 |
---|
176 | typedef char fstring[FSTRING_LEN]; |
---|
177 | |
---|
178 | /* End of stuff from pstring.h */ |
---|
179 | |
---|
180 | /* From rpc_parse/parse_misc.c */ |
---|
181 | |
---|
182 | bool smb_io_uuid(const char *desc, struct uuid *uuid, |
---|
183 | prs_struct *ps, int depth); |
---|
184 | bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth); |
---|
185 | |
---|
186 | /* End of stuff from rpc_parse/parse_misc.c */ |
---|
187 | |
---|
188 | #endif /* _SMB_DEPS_H */ |
---|