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

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

samba client: remove tabs in source and beautify it completely

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