source: branches/client-3.0/src/smbwrp.h@ 931

Last change on this file since 931 was 931, checked in by Paul Smedley, 9 years ago

Add support to enable NTLMv1 authentication

  • Property svn:eol-style set to native
File size: 6.8 KB
Line 
1/*
2 Netdrive Samba client plugin
3 samba library wrappers
4 Copyright (C) netlabs.org 2003-2008
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _SMBWRP_H
22#define _SMBWRP_H
23
24#if !defined (O_RDONLY)
25#define O_ACCMODE 0x03 /* mask */
26#define O_RDONLY 0x00
27#define O_WRONLY 0x01
28#define O_RDWR 0x02
29#define O_NONBLOCK 0x04
30#define O_APPEND 0x08
31#define O_TEXT 0x10
32
33#define O_BINARY 0x0100
34#define O_CREAT 0x0200
35#define O_TRUNC 0x0400
36#define O_EXCL 0x0800
37#define O_SYNC 0x2000
38#define O_NOCTTY 0x4000
39#define O_SIZE 0x8000
40#endif
41
42#if !defined (DENY_NONE)
43/* deny modes */
44#define DENY_DOS 0
45#define DENY_ALL 1
46#define DENY_WRITE 2
47#define DENY_READ 3
48#define DENY_NONE 4
49#define DENY_FCB 7
50#endif
51
52
53/* these define the attribute byte as seen by DOS */
54#ifndef aRONLY
55#define aRONLY (1L<<0) /* 0x01 */
56#define aHIDDEN (1L<<1) /* 0x02 */
57#define aSYSTEM (1L<<2) /* 0x04 */
58#define aVOLID (1L<<3) /* 0x08 */
59#define aDIR (1L<<4) /* 0x10 */
60#define aARCH (1L<<5) /* 0x20 */
61#endif
62
63#pragma pack(1)
64
65#ifdef CLI_BUFFER_SIZE
66typedef struct cli_state cli_state;
67#else
68typedef unsigned long cli_state;
69#endif
70
71#define CAP_NOPATHINFO2 0x01000000
72
73typedef struct smbwrp_server
74{
75 char server_name[256];
76 char share_name[256];
77 char workgroup[256];
78 char username[256];
79 char password[256];
80 char master[256];
81 int ifmastergroup;
82 int no_pathinfo2;
83} smbwrp_server;
84
85typedef struct smbwrp_file
86{
87 int fd;
88 unsigned long long offset;
89 int openmode;
90 int openattr;
91 int denymode;
92 unsigned long mtime;
93 unsigned long ctime;
94 int updatetime;
95 // 0 = time is not updated upon file close
96 // 1 = modified time is updated to current time
97 // 2 = create and modified time are updated according local file
98 char fullname[261];
99 char fname[261];
100} smbwrp_file;
101
102typedef struct smbwrp_fileinfo
103{
104 unsigned long long size;
105 unsigned long attr;
106 unsigned long ctime;
107 unsigned long mtime;
108 unsigned long atime;
109 int easize;
110 char fname[261];
111} smbwrp_fileinfo;
112
113typedef struct smbwrp_fileseek
114{
115 int whence;
116 long offset;
117 unsigned long result;
118} smbwrp_fileseek;
119
120
121#ifndef INCL_DOS
122typedef struct _FSALLOCATE /* fsalloc */
123{
124 unsigned long idFileSystem;
125 unsigned long cSectorUnit;
126 unsigned long cUnit;
127 unsigned long cUnitAvail;
128 unsigned short cbSector;
129} FSALLOCATE;
130#endif
131
132struct DirectoryCache;
133
134typedef struct _Resource
135{
136 int rootlevel;
137 smbwrp_server srv;
138 char logfile[_MAX_PATH + 1];
139 char loglevel;
140 int easupport;
141 int krb5support;
142 int ntlmv1support;
143 int cachetimeout;
144 int cachedepth;
145 struct DirectoryCache *pdc;
146} Resource;
147
148typedef struct _Connection
149{
150 Resource *pRes;
151 cli_state* cli;
152 smbwrp_file file;
153} Connection;
154
155
156typedef struct filelist_state
157{
158 unsigned long pipe;
159 char * data;
160 int datalen;
161 int bufferlen;
162 void ( * _System add_dir_entry)(void * st);
163 char mask[ _MAX_PATH];
164 char dir[ _MAX_PATH];
165 char dir_mask[ _MAX_PATH];
166 smbwrp_fileinfo finfo;
167 Connection* pConn;
168 void *plist;
169 unsigned long ulAttribute;
170 const char *fullpath;
171} filelist_state;
172
173#pragma pack()
174
175int _System smbwrp_getclisize(void);
176int _System smbwrp_init(void);
177int _System smbwrp_connect(Resource * pRes, cli_state **);
178void _System smbwrp_disconnect(Resource * pRes, cli_state *);
179int _System smbwrp_open(cli_state * cli, smbwrp_file * file);
180int _System smbwrp_read(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
181int _System smbwrp_write(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
182int _System smbwrp_lseek(cli_state * cli, smbwrp_file * file, int whence, long long offset);
183int _System smbwrp_close(cli_state * cli, smbwrp_file * file);
184int _System smbwrp_setattr(cli_state * cli, smbwrp_fileinfo *finfo);
185int _System smbwrp_getattr(smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo);
186int _System smbwrp_fgetattr(cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo);
187int _System smbwrp_filelist(smbwrp_server *srv, cli_state * cli, filelist_state * state);
188int _System smbwrp_rename(cli_state * cli, char *oldname, char *newname);
189int _System smbwrp_chdir(smbwrp_server *srv, cli_state * cli, char *fname);
190int _System smbwrp_mkdir(cli_state * cli, char *fname);
191int _System smbwrp_rmdir(cli_state * cli, char *fname);
192int _System smbwrp_unlink(cli_state * cli, const char *fname);
193int _System smbwrp_setfilesize(cli_state * cli, smbwrp_file * file, long long newsize);
194int _System smbwrp_setea(cli_state * cli, char *fname, char * name, unsigned char * value, int size);
195int _System smbwrp_fsetea(cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size);
196int _System smbwrp_listea(cli_state * cli, char *fname, void * buffer, unsigned long size);
197int _System smbwrp_flistea(cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size);
198int _System smbwrp_dskattr(cli_state * cli, FSALLOCATE *pfsa);
199
200/* Directory cache helpers. */
201int dircache_create(struct DirectoryCache **ppdc, unsigned long ulExpirationTime, int cMaxEntries);
202void dircache_delete(struct DirectoryCache *pdc);
203
204typedef void FNADDDIRENTRY(const char*, smbwrp_fileinfo *, const char *, void *);
205typedef FNADDDIRENTRY *PFNADDDIRENTRY;
206
207/* Note: dircache_list_files or dircache_write_begin construct the directory path
208 * using information in the filelist_state structure.
209 */
210int dircache_list_files(PFNADDDIRENTRY fn,
211 filelist_state *state,
212 int *ptotal_received);
213
214void *dircache_write_begin(filelist_state *state,
215 int cFiles);
216void dircache_write_entry(void *dircachectx, const smbwrp_fileinfo *finfo);
217void dircache_write_end(void *dircachectx);
218
219void dircache_invalidate(const char *path,
220 struct DirectoryCache *pdc,
221 int fParent);
222
223int dircache_find_path(struct DirectoryCache *pdc,
224 const char *path,
225 smbwrp_fileinfo *finfo,
226 unsigned long *pulAge);
227
228/* Prototype the debug log helper. */
229void debuglocal(int level, const char * fmt, ...);
230
231void smbwrp_initthread(void);
232
233#endif /* _SMBWRP_H */
Note: See TracBrowser for help on using the repository browser.