The latest changes to libsmbclient ...
[tprouty/samba.git] / source3 / 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 namelen;
39   uint commentlen;
40   char *comment;   /* Points to the comment futher down */
41   char name[1];
42
43 };
44
45 #define SMBC_WORKGROUP     1
46 #define SMBC_SERVER        2
47 #define SMBC_FILE_SHARE    3
48 #define SMBC_PRINTER_SHARE 4
49 #define SMBC_COMMS_SHARE   5
50 #define SMBC_IPC_SHARE     6
51 #define SMBC_DIR           7
52 #define SMBC_FILE          8
53 #define SMBC_LINK          9
54
55 #define SMBC_FILE_MODE (S_IFREG | 0444)
56 #define SMBC_DIR_MODE  (S_IFDIR | 0555)
57
58 typedef void (*smbc_get_auth_data_fn)(char *server, char *share,
59                                       char **workgroup, char **username,
60                                       char **password);
61
62 /*
63  * Init the smbc package
64  */
65 int smbc_init(smbc_get_auth_data_fn fn, const char *workgroup, int debug);
66
67 /*
68  * Open a file on an SMB server, this has the same form as normal open
69  * but the fname is a URL of the form smb://server/share/path
70  */
71
72 int smbc_open(const char *fname, int flags, mode_t mode);
73
74 /*
75  * Create a file on an SMB server, similar to smbc_open
76  */
77
78 int smbc_creat(const char *fname, mode_t mode);
79
80 /*
81  * Read from a file, what about pread?
82  */
83
84 ssize_t smbc_read(int fd, void *buf, size_t count);
85
86 /* 
87  * Write to a file, what about pwrite?
88  */
89
90 ssize_t smbc_write(int fd, void *buf, size_t count);
91
92 /*
93  * Close a file by fd
94  */
95
96 int smbc_close(int fd);
97
98 /*
99  * Unlink a file on server, share, dir, file ...
100  */
101
102 int smbc_unlink(const char *fname);
103
104 /*
105  * rename oname to nname ... probably need to be on the same
106  * server initially. Later can copy between servers ...
107  */
108
109 int smbc_rename(const char *oname, const char *nname);
110
111 /*
112  * Seek to a specific location in a file on an SMB server 
113  */
114
115 off_t smbc_lseek(int fd, off_t offset, int whence);
116
117 /*
118  * Stat a file to get info via file name
119  */
120
121 int smbc_stat(const char *fname, struct stat *st);
122
123 /*
124  * Stat a file to get info via an fd
125  */
126
127 int smbc_fstat(int fd, struct stat *st);
128
129 /* 
130  * Chown a file 
131  */
132
133 int smbc_chown(const *fname, uid_t owner, gid_t group);
134
135 /*
136  * Chmod a file
137  */
138
139 int smbc_chmod(const char *fname, mode_t newmode);
140
141 /*
142  * Open a directory on a URL (server and share and dir)
143  */
144
145 int smbc_opendir(const char *fname);
146
147 /*
148  * Close a directory
149  */
150
151 int smbc_closedir(int fd);
152
153 /* 
154  * Get a directory entry
155  */
156
157 int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count);
158
159 /* 
160  * Create a directory on a server, share, dir in fname URL
161  */
162
163 int smbc_mkdir(const char *fname, mode_t mode);
164
165 /* 
166  * lseek on directories, rewind by smbc_lseekdir(fd, 0, SEEK_SET)
167  */
168
169 int smbc_lseekdir(int fd, off_t offset, int whence);
170
171 /* 
172  * Must also provide print functions ... soon
173  */
174
175 #endif