source: trunk/client/src/smbwrp.h

Last change on this file was 976, checked in by Yuri Dario, 9 years ago

Store samba data in dynamic allocated memory for new caching code. Added
deallocator code. ticket#274.

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