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

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

samba client: adjust copyright

  • 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-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 char logfile[_MAX_PATH + 1];
140 char loglevel;
141 int easupport;
142 int krb5support;
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.