Fix problems in libsmbclient with pring job struct plus add implementation
[gd/samba/.git] / source / include / libsmbclient.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 2.0
4    SMB client library API definitions
5    Copyright (C) Andrew Tridgell 1998
6    Copyright (C) Richard Sharpe 2000
7    Copyright (C) John Terpsra 2000
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #ifndef _SMBCLIENT_H
25 #define _SMBCLIENT_H
26
27 /* Make sure we have the following includes for now ... */
28
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <fcntl.h>
32
33 #define SMBC_MAX_NAME 1023
34
35 struct smbc_dirent {
36
37   uint smbc_type;  /* Type of entity, see below */
38   uint dirlen;     /* Convenience               */
39   uint namelen;
40   uint commentlen;
41   char *comment;   /* Points to the comment futher down */
42   char name[1];
43
44 };
45
46 #ifndef _CLIENT_H
47 typedef unsigned short uint16;
48 struct print_job_info {
49   uint16 id;
50   uint16 priority;
51   size_t size;
52   char user[128];
53   char name[128];
54   time_t t;
55 };
56 #endif
57
58 /*
59  * Entity types
60  */
61 #define SMBC_WORKGROUP     1
62 #define SMBC_SERVER        2
63 #define SMBC_FILE_SHARE    3
64 #define SMBC_PRINTER_SHARE 4
65 #define SMBC_COMMS_SHARE   5
66 #define SMBC_IPC_SHARE     6
67 #define SMBC_DIR           7
68 #define SMBC_FILE          8
69 #define SMBC_LINK          9
70
71 #define SMBC_FILE_MODE (S_IFREG | 0444)
72 #define SMBC_DIR_MODE  (S_IFDIR | 0555)
73
74 typedef void (*smbc_get_auth_data_fn)(char *server, char *share,
75                                       char *workgroup, int wgmaxlen, 
76                                       char *username, int unmaxlen,
77                                       char *password, int pwmaxlen);
78
79 /*
80  * Init the smbc package
81  */
82 int smbc_init(smbc_get_auth_data_fn fn, const char *workgroup, int debug);
83
84 /*
85  * Open a file on an SMB server, this has the same form as normal open
86  * but the fname is a URL of the form smb://server/share/path
87  */
88
89 int smbc_open(const char *fname, int flags, mode_t mode);
90
91 /*
92  * Create a file on an SMB server, similar to smbc_open
93  */
94
95 int smbc_creat(const char *fname, mode_t mode);
96
97 /*
98  * Read from a file, what about pread?
99  */
100
101 ssize_t smbc_read(int fd, void *buf, size_t count);
102
103 /* 
104  * Write to a file, what about pwrite?
105  */
106
107 ssize_t smbc_write(int fd, void *buf, size_t count);
108
109 /*
110  * Close a file by fd
111  */
112
113 int smbc_close(int fd);
114
115 /*
116  * Unlink a file on server, share, dir, file ...
117  */
118
119 int smbc_unlink(const char *fname);
120
121 /*
122  * rename oname to nname ... probably need to be on the same
123  * server initially. Later can copy between servers ...
124  */
125
126 int smbc_rename(const char *oname, const char *nname);
127
128 /*
129  * Seek to a specific location in a file on an SMB server 
130  */
131
132 off_t smbc_lseek(int fd, off_t offset, int whence);
133
134 /*
135  * Stat a file to get info via file name
136  */
137
138 int smbc_stat(const char *fname, struct stat *st);
139
140 /*
141  * Stat a file to get info via an fd
142  */
143
144 int smbc_fstat(int fd, struct stat *st);
145
146 /* 
147  * Chown a file 
148  */
149
150 int smbc_chown(const char *fname, uid_t owner, gid_t group);
151
152 /*
153  * Chmod a file
154  */
155
156 int smbc_chmod(const char *fname, mode_t newmode);
157
158 /*
159  * Open a directory on a URL (server and share and dir)
160  */
161
162 int smbc_opendir(const char *fname);
163
164 /*
165  * Close a directory
166  */
167
168 int smbc_closedir(int fd);
169
170 /* 
171  * Get a directory entry
172  */
173
174 int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count);
175
176 /*
177  * Read a dirent in the old way
178  */
179
180 struct smbc_dirent *smbc_readdir(unsigned int fd);
181
182 /* 
183  * Create a directory on a server, share, dir in fname URL
184  */
185
186 int smbc_mkdir(const char *fname, mode_t mode);
187
188 /*
189  * Remove a directory on a server
190  */
191
192 int smbc_rmdir(const char *fname);
193
194 /*
195  * Get the current directory offset
196  */
197
198 off_t smbc_telldir(int fd);
199
200 /* 
201  * lseek on directories, rewind by smbc_lseekdir(fd, 0, SEEK_SET)
202  */
203
204 int smbc_lseekdir(int fd, off_t offset, int whence);
205
206 /* 
207  * Print a file given the name in fname. It would be a URL ...
208  */
209
210 int smbc_print_file(const char *fname, const char *printq);
211
212 /* 
213  * Open a print file that can be written to by other calls. This simply
214  * does an smbc_open call after checking if there is a file name on the
215  * URI. If not, a temporary name is added ...
216  */
217
218 int smbc_open_print_job(const char *fname);
219
220 /*
221  * List the print jobs on a print share, for the moment, pass a callback 
222  */
223
224 int smbc_list_print_jobs(const char *fname, void (*fn)(struct print_job_info *));
225
226 /* 
227  * Delete a print job 
228  */
229
230 int smbc_unlink_print_job(const char *fname, int id);
231
232 #endif