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
|
---|
66 | typedef struct cli_state cli_state;
|
---|
67 | #else
|
---|
68 | typedef unsigned long cli_state;
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | #define CAP_NOPATHINFO2 0x01000000
|
---|
72 |
|
---|
73 | typedef 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 |
|
---|
85 | typedef 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 | char fullname[261];
|
---|
94 | char fname[261];
|
---|
95 | } smbwrp_file;
|
---|
96 |
|
---|
97 | typedef struct smbwrp_fileinfo
|
---|
98 | {
|
---|
99 | unsigned long long size;
|
---|
100 | unsigned long attr;
|
---|
101 | unsigned long ctime;
|
---|
102 | unsigned long mtime;
|
---|
103 | unsigned long atime;
|
---|
104 | int easize;
|
---|
105 | char fname[261];
|
---|
106 | } smbwrp_fileinfo;
|
---|
107 |
|
---|
108 | typedef struct smbwrp_fileseek
|
---|
109 | {
|
---|
110 | int whence;
|
---|
111 | long offset;
|
---|
112 | unsigned long result;
|
---|
113 | } smbwrp_fileseek;
|
---|
114 |
|
---|
115 |
|
---|
116 | #ifndef INCL_DOS
|
---|
117 | typedef struct _FSALLOCATE /* fsalloc */
|
---|
118 | {
|
---|
119 | unsigned long idFileSystem;
|
---|
120 | unsigned long cSectorUnit;
|
---|
121 | unsigned long cUnit;
|
---|
122 | unsigned long cUnitAvail;
|
---|
123 | unsigned short cbSector;
|
---|
124 | } FSALLOCATE;
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | typedef struct _Resource
|
---|
128 | {
|
---|
129 | int rootlevel;
|
---|
130 | smbwrp_server srv;
|
---|
131 | char logfile[_MAX_PATH + 1];
|
---|
132 | char loglevel;
|
---|
133 | int easupport;
|
---|
134 | int krb5support;
|
---|
135 | } Resource;
|
---|
136 |
|
---|
137 | typedef struct _Connection
|
---|
138 | {
|
---|
139 | Resource *pRes;
|
---|
140 | cli_state* cli;
|
---|
141 | smbwrp_file file;
|
---|
142 | } Connection;
|
---|
143 |
|
---|
144 |
|
---|
145 | typedef struct filelist_state
|
---|
146 | {
|
---|
147 | unsigned long pipe;
|
---|
148 | char * data;
|
---|
149 | int datalen;
|
---|
150 | int bufferlen;
|
---|
151 | void ( * _System add_dir_entry)(void * st);
|
---|
152 | char mask[ _MAX_PATH];
|
---|
153 | char dir[ _MAX_PATH];
|
---|
154 | char dir_mask[ _MAX_PATH];
|
---|
155 | smbwrp_fileinfo finfo;
|
---|
156 | Connection* pConn;
|
---|
157 | void *plist;
|
---|
158 | unsigned long ulAttribute;
|
---|
159 | } filelist_state;
|
---|
160 |
|
---|
161 | #pragma pack()
|
---|
162 |
|
---|
163 | int _System smbwrp_getclisize(void);
|
---|
164 | int _System smbwrp_init(void);
|
---|
165 | int _System smbwrp_connect(Resource * pRes, cli_state **);
|
---|
166 | void _System smbwrp_disconnect(Resource * pRes, cli_state *);
|
---|
167 | int _System smbwrp_open(cli_state * cli, smbwrp_file * file);
|
---|
168 | int _System smbwrp_read(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
|
---|
169 | int _System smbwrp_write(cli_state * cli, smbwrp_file * file, void *buf, unsigned long count, unsigned long * result);
|
---|
170 | int _System smbwrp_lseek(cli_state * cli, smbwrp_file * file, int whence, long long offset);
|
---|
171 | int _System smbwrp_close(cli_state * cli, smbwrp_file * file);
|
---|
172 | int _System smbwrp_setattr(cli_state * cli, smbwrp_fileinfo *finfo);
|
---|
173 | int _System smbwrp_getattr(smbwrp_server *srv, cli_state * cli, smbwrp_fileinfo *finfo);
|
---|
174 | int _System smbwrp_fgetattr(cli_state * cli, smbwrp_file *file, smbwrp_fileinfo *finfo);
|
---|
175 | int _System smbwrp_filelist(smbwrp_server *srv, cli_state * cli, filelist_state * state);
|
---|
176 | int _System smbwrp_rename(cli_state * cli, char *oldname, char *newname);
|
---|
177 | int _System smbwrp_chdir(smbwrp_server *srv, cli_state * cli, char *fname);
|
---|
178 | int _System smbwrp_mkdir(cli_state * cli, char *fname);
|
---|
179 | int _System smbwrp_rmdir(cli_state * cli, char *fname);
|
---|
180 | int _System smbwrp_unlink(cli_state * cli, const char *fname);
|
---|
181 | int _System smbwrp_setfilesize(cli_state * cli, smbwrp_file * file, long long newsize);
|
---|
182 | int _System smbwrp_setea(cli_state * cli, char *fname, char * name, unsigned char * value, int size);
|
---|
183 | int _System smbwrp_fsetea(cli_state * cli, smbwrp_file *file, char * name, unsigned char * value, int size);
|
---|
184 | int _System smbwrp_listea(cli_state * cli, char *fname, void * buffer, unsigned long size);
|
---|
185 | int _System smbwrp_flistea(cli_state * cli, smbwrp_file *file, void * buffer, unsigned long size);
|
---|
186 | int _System smbwrp_dskattr(cli_state * cli, FSALLOCATE *pfsa);
|
---|
187 |
|
---|
188 | #endif /* _SMBWRP_H */
|
---|