source: trunk/client/src/smbwrp.h@ 960

Last change on this file since 960 was 960, checked in by Silvan Scherrer, 9 years ago

samba client: add the possibility to have logfiles per share

  • Property svn:eol-style set to native
File size: 7.6 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
133struct DirectoryCache;
134
135typedef struct _Resource
136{
137 int rootlevel;
138 smbwrp_server srv;
139 int easupport;
140 int krb5support;
141 int cachetimeout;
142 int cachedepth;
143 int loglevel;
144 char logfile[_MAX_PATH +1];
145 FILE *logfileFH;
146 char smb_logfile[_MAX_PATH +1];
147 int ifL;
148 int firstLogLine;
149 int smb_initialised;
150 struct DirectoryCache *pdc;
151} Resource;
152
153typedef struct _Connection
154{
155 Resource *pRes;
156 cli_state* cli;
157 smbwrp_file file;
158} Connection;
159
160
161typedef struct filelist_state
162{
163 unsigned long pipe;
164 char * data;
165 int datalen;
166 int bufferlen;
167 void ( * _System add_dir_entry)(void * st);
168 char mask[ _MAX_PATH];
169 char dir[ _MAX_PATH];
170 char dir_mask[ _MAX_PATH];
171 smbwrp_fileinfo finfo;
172 Connection* pConn;
173 void *plist;
174 unsigned long ulAttribute;
175 const char *fullpath;
176} filelist_state;
177
178#pragma pack()
179
180int _System smbwrp_getclisize(void);
181int _System smbwrp_init(Resource *pRes);
182int _System smbwrp_connect(Resource * pRes, cli_state **);
183void _System smbwrp_disconnect(Resource * pRes, cli_state *);
184int _System smbwrp_open(Resource *pRes, cli_state * cli, smbwrp_file * file);
185int _System smbwrp_read(Resource *pRes, cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
186int _System smbwrp_write(Resource *pRes, cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
187int _System smbwrp_lseek(Resource *pRes, cli_state * cli, smbwrp_file * file, int whence, long long offset);
188int _System smbwrp_close(Resource *pRes, cli_state * cli, smbwrp_file * file);
189int _System smbwrp_setattr(Resource *pRes, cli_state * cli, smbwrp_fileinfo *finfo);
190int _System smbwrp_getattr(Resource *pRes, smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo);
191int _System smbwrp_fgetattr(Resource *pRes, cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo);
192int _System smbwrp_filelist(Resource *pRes, smbwrp_server *srv, cli_state * cli, filelist_state * state);
193int _System smbwrp_rename(Resource *pRes, cli_state * cli, char *oldname, char *newname);
194int _System smbwrp_chdir(Resource *pRes, smbwrp_server *srv, cli_state * cli, char *fname);
195int _System smbwrp_mkdir(Resource *pRes, cli_state * cli, char *fname);
196int _System smbwrp_rmdir(Resource *pRes, cli_state * cli, char *fname);
197int _System smbwrp_unlink(Resource *pRes, cli_state * cli, const char *fname);
198int _System smbwrp_setfilesize(Resource *pRes, cli_state * cli, smbwrp_file * file, long long newsize);
199int _System smbwrp_setea(Resource *pRes, cli_state * cli, char *fname, char * name, unsigned char * value, int size);
200int _System smbwrp_fsetea(Resource *pRes, cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size);
201int _System smbwrp_listea(Resource *pRes, cli_state * cli, char *fname, void * buffer, unsigned long size);
202int _System smbwrp_flistea(Resource *pRes, cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size);
203int _System smbwrp_dskattr(Resource *pRes, cli_state * cli, FSALLOCATE *pfsa);
204
205/* Directory cache helpers. */
206int dircache_create(Resource *pRes);
207void dircache_delete(Resource *pRes);
208
209typedef void FNADDDIRENTRY(const char*, smbwrp_fileinfo *, const char *, void *);
210typedef FNADDDIRENTRY *PFNADDDIRENTRY;
211
212/* Note: dircache_list_files or dircache_write_begin construct the directory path
213 * using information in the filelist_state structure.
214 */
215int dircache_list_files(PFNADDDIRENTRY fn,
216 filelist_state *state,
217 int *ptotal_received);
218
219void *dircache_write_begin(filelist_state *state,
220 int cFiles);
221void dircache_write_entry(Resource *pRes, void *dircachectx, const smbwrp_fileinfo *finfo);
222void dircache_write_end(Resource *pRes, void *dircachectx);
223
224void dircache_invalidate(const char *path,
225 Resource *pRes,
226 int fParent);
227
228int dircache_find_path(Resource *pRes,
229 const char *path,
230 smbwrp_fileinfo *finfo,
231 unsigned long *pulAge);
232
233/* Prototype the debug log helper. */
234void debuglocal(Resource *pRes, int level, const char * fmt, ...);
235
236void smbwrp_initthread(void);
237
238#endif /* _SMBWRP_H */
Note: See TracBrowser for help on using the repository browser.