add another registry rpc (opnum 0x14). Have no idea what it's real name
[Samba.git] / source / include / libsmbclient.h
blobf26956399693f5e3df329ae0a3dc61b298cd0859
1 /*=====================================================================
2 Unix SMB/Netbios implementation.
3 SMB client library API definitions
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000
6 Copyright (C) John Terpsra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 =====================================================================*/
25 #ifndef SMBCLIENT_H_INCLUDED
26 #define SMBCLIENT_H_INCLUDED
28 /*-------------------------------------------------------------------*/
29 /* The following are special comments to instruct DOXYGEN (automated
30 * documentation tool:
32 /** \defgroup libsmbclient
34 /** \defgroup structure Data Structures Type and Constants
35 * \ingroup libsmbclient
36 * Data structures, types, and constants
38 /** \defgroup file File Functions
39 * \ingroup libsmbclient
40 * Functions used to access individual file contents
42 /** \defgroup directory Directory Functions
43 * \ingroup libsmbclient
44 * Functions used to access directory entries
46 /** \defgroup attribute Attributes Functions
47 * \ingroup libsmbclient
48 * Functions used to view or change file and directory attributes
50 /** \defgroup print Print Functions
51 * \ingroup libsmbclient
52 * Functions used to access printing functionality
54 /** \defgroup attribute Miscellaneous Functions
55 * \ingroup libsmbclient
56 * Functions that don't fit in to other categories
58 /*-------------------------------------------------------------------*/
60 /* Make sure we have the following includes for now ... */
61 #include <sys/types.h>
62 #include <sys/stat.h>
63 #include <fcntl.h>
65 #define SMBC_MAX_NAME 1023
66 #define SMBC_WORKGROUP 1
67 #define SMBC_SERVER 2
68 #define SMBC_FILE_SHARE 3
69 #define SMBC_PRINTER_SHARE 4
70 #define SMBC_COMMS_SHARE 5
71 #define SMBC_IPC_SHARE 6
72 #define SMBC_DIR 7
73 #define SMBC_FILE 8
74 #define SMBC_LINK 9
76 #define SMBC_FILE_MODE (S_IFREG | 0444)
77 #define SMBC_DIR_MODE (S_IFDIR | 0555)
79 #define SMBC_MAX_FD 10000
82 /**@ingroup structure
83 * Structure that represents a directory entry.
86 struct smbc_dirent
88 /** Type of entity.
89 SMBC_WORKGROUP=1,
90 SMBC_SERVER=2,
91 SMBC_FILE_SHARE=3,
92 SMBC_PRINTER_SHARE=4,
93 SMBC_COMMS_SHARE=5,
94 SMBC_IPC_SHARE=6,
95 SMBC_DIR=7,
96 SMBC_FILE=8,
97 SMBC_LINK=9,*/
98 unsigned int smbc_type;
100 /** Length of this smbc_dirent in bytes
102 unsigned int dirlen;
103 /** The length of the comment string in bytes (includes null
104 * terminator)
106 unsigned int commentlen;
107 /** Points to the null terminated comment string
109 char *comment;
110 /** The length of the name string in bytes (includes null
111 * terminator)
113 unsigned int namelen;
114 /** Points to the null terminated name string
116 char name[1];
119 #ifndef _CLIENT_H
121 /**@ingroup structure
122 * Structure that represents a print job.
125 struct print_job_info
127 /** numeric ID of the print job
129 unsigned short id;
131 /** represents print job priority (lower numbers mean higher priority)
133 unsigned short priority;
135 /** Size of the print job
137 size_t size;
139 /** Name of the user that owns the print job
141 char user[128];
143 /** Name of the print job. This will have no name if an anonymous print
144 * file was opened. Ie smb://server/printer
146 char name[128];
148 /** Time the print job was spooled
150 time_t t;
152 #endif /* ifndef _CLIENT_H */
154 /**@ingroup structure
155 * Authentication callback function type.
157 * Type for the the authentication function called by the library to
158 * obtain authentication credentals
160 * @param srv Server being authenticated to
162 * @param shr Share being authenticated to
164 * @param wg Pointer to buffer containing a "hint" for the
165 * workgroup to be authenticated. Should be filled in
166 * with the correct workgroup if the hint is wrong.
168 * @param wglen The size of the workgroup buffer in bytes
170 * @param un Pointer to buffer containing a "hint" for the
171 * user name to be use for authentication. Should be
172 * filled in with the correct workgroup if the hint is
173 * wrong.
175 * @param unlen The size of the username buffer in bytes
177 * @param pw Pointer to buffer containing to which password
178 * copied
180 * @param pwlen The size of the password buffer in bytes
183 typedef void (*smbc_get_auth_data_fn)(const char *srv,
184 const char *shr,
185 char *wg, int wglen,
186 char *un, int unlen,
187 char *pw, int pwlen);
190 /**@ingroup structure
191 * Print job info callback function type.
193 * @param i pointer to print job information structure
196 typedef void (*smbc_get_print_job_info)(struct print_job_info *i);
198 typedef struct _SMBCSRV {
199 struct cli_state cli;
200 dev_t dev;
201 BOOL no_pathinfo2;
202 int server_fd;
204 struct _SMBCSRV *next, *prev;
206 } SMBCSRV;
209 * Keep directory entries in a list
211 struct smbc_dir_list {
212 struct smbc_dir_list *next;
213 struct smbc_dirent *dirent;
217 * Structure for open file management
219 typedef struct _SMBCFILE {
220 int cli_fd;
221 char *fname;
222 off_t offset;
223 SMBCSRV *srv;
224 BOOL file;
225 struct smbc_dir_list *dir_list, *dir_end, *dir_next;
226 int dir_type, dir_error;
228 struct _SMBCFILE *next, *prev;
229 } SMBCFILE;
231 /**@ingroup structure
232 * Structure that contains a client context information
234 typedef struct _SMBCCTX {
235 /** debug level
237 int debug;
239 /** netbios name used for making connections
241 char * netbios_name;
243 /** workgroup name used for making connections
245 char * workgroup;
247 /** username used for making connections
249 char * user;
251 /** timeout used for waiting on connections / response data (in milliseconds)
253 int timeout;
255 /** callable functions for files:
256 * For usage and return values see the smbc_* functions
258 SMBCFILE * (*open) (struct _SMBCCTX *c, const char *fname, int flags, mode_t mode);
259 SMBCFILE * (*creat) (struct _SMBCCTX *c, const char *path, mode_t mode);
260 ssize_t (*read) (struct _SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
261 ssize_t (*write) (struct _SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
262 int (*unlink) (struct _SMBCCTX *c, const char *fname);
263 int (*rename) (struct _SMBCCTX *ocontext, const char *oname,
264 struct _SMBCCTX *ncontext, const char *nname);
265 off_t (*lseek) (struct _SMBCCTX *c, SMBCFILE * file, off_t offset, int whence);
266 int (*stat) (struct _SMBCCTX *c, const char *fname, struct stat *st);
267 int (*fstat) (struct _SMBCCTX *c, SMBCFILE *file, struct stat *st);
268 int (*close) (struct _SMBCCTX *c, SMBCFILE *file);
270 /** callable functions for dirs
272 SMBCFILE * (*opendir) (struct _SMBCCTX *c, const char *fname);
273 int (*closedir)(struct _SMBCCTX *c, SMBCFILE *dir);
274 struct smbc_dirent * (*readdir)(struct _SMBCCTX *c, SMBCFILE *dir);
275 int (*getdents)(struct _SMBCCTX *c, SMBCFILE *dir,
276 struct smbc_dirent *dirp, int count);
277 int (*mkdir) (struct _SMBCCTX *c, const char *fname, mode_t mode);
278 int (*rmdir) (struct _SMBCCTX *c, const char *fname);
279 off_t (*telldir) (struct _SMBCCTX *c, SMBCFILE *dir);
280 int (*lseekdir)(struct _SMBCCTX *c, SMBCFILE *dir, off_t offset);
281 int (*fstatdir)(struct _SMBCCTX *c, SMBCFILE *dir, struct stat *st);
283 /** callable functions for printing
285 int (*print_file)(struct _SMBCCTX *c_file, const char *fname,
286 struct _SMBCCTX *c_print, const char *printq);
287 SMBCFILE * (*open_print_job)(struct _SMBCCTX *c, const char *fname);
288 int (*list_print_jobs)(struct _SMBCCTX *c, const char *fname, void (*fn)(struct print_job_info *));
289 int (*unlink_print_job)(struct _SMBCCTX *c, const char *fname, int id);
292 /** Callbacks
293 * These callbacks _always_ have to be intialized because they will not be checked
294 * at dereference for increased speed.
296 struct _smbc_callbacks {
297 /** authentication function callback: called upon auth requests
299 smbc_get_auth_data_fn auth_fn;
301 /** check if a server is still good
303 int (*check_server_fn)(struct _SMBCCTX * c, SMBCSRV *srv);
305 /** remove a server if unused
307 int (*remove_unused_server_fn)(struct _SMBCCTX * c, SMBCSRV *srv);
309 /** Cache subsystem
310 * For an example cache system see samba/source/libsmb/libsmb_cache.c
311 * Cache subsystem functions follow.
314 /** server cache addition
316 int (*add_cached_srv_fn) (struct _SMBCCTX * c, SMBCSRV *srv,
317 char * server, char * share,
318 char * workgroup, char * username);
319 /** server cache lookup
321 SMBCSRV * (*get_cached_srv_fn) (struct _SMBCCTX * c, char * server,
322 char * share, char * workgroup, char * username);
323 /** server cache removal
325 int (*remove_cached_srv_fn)(struct _SMBCCTX * c, SMBCSRV *srv);
327 /** server cache purging, try to remove all cached servers (disconnect)
329 int (*purge_cached_fn) (struct _SMBCCTX * c);
331 } callbacks;
334 /** Space to store private data of the server cache.
336 void * server_cache;
338 /** INTERNAL functions
339 * do _NOT_ touch these from your program !
342 /** INTERNAL: is this handle initialized ?
344 int _initialized;
346 /** INTERNAL: dirent pointer location
348 char _dirent[512];
350 /** INTERNAL: server connection list
352 SMBCSRV * _servers;
354 /** INTERNAL: open file/dir list
356 SMBCFILE * _files;
358 } SMBCCTX;
361 /**@ingroup misc
362 * Create a new SBMCCTX (a context).
364 * Must be called before the context is passed to smbc_context_init()
366 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
367 * - ENOMEM Out of memory
369 * @see smbc_free_context(), smbc_init_context()
371 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
373 SMBCCTX * smbc_new_context(void);
375 /**@ingroup misc
376 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
378 * The context will be deleted if possible.
380 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
382 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
385 * @return Returns 0 on succes. Returns 1 on failure with errno set:
386 * - EBUSY Server connections are still used, Files are open or cache
387 * could not be purged
388 * - EBADF context == NULL
390 * @see smbc_new_context()
392 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
393 * just before exit()'ing. When shutdown_ctx is 0, this function can be
394 * use in periodical cleanup functions for example.
396 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
399 /**@ingroup misc
400 * Initialize a SBMCCTX (a context).
402 * Must be called before using any SMBCCTX API function
404 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
406 * @return A pointer to the given SMBCCTX on success, NULL on error with errno set:
407 * - EBADF NULL context given
408 * - ENOMEM Out of memory
409 * - ENOENT The smb.conf file would not load
411 * @see smbc_new_context()
413 * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe,
414 * but it might leak memory on smbc_context_init() failure. Avoid this.
415 * You'll have to call smbc_free_context() yourself on failure.
418 SMBCCTX * smbc_init_context(SMBCCTX * context);
420 /**@ingroup misc
421 * Initialize the samba client library.
423 * Must be called before using any of the smbclient API function
425 * @param fn The function that will be called to obtaion
426 * authentication credentials.
428 * @param debug Allows caller to set the debug level. Can be
429 * changed in smb.conf file. Allows caller to set
430 * debugging if no smb.conf.
432 * @return 0 on success, < 0 on error with errno set:
433 * - ENOMEM Out of memory
434 * - ENOENT The smb.conf file would not load
438 int smbc_init(smbc_get_auth_data_fn fn, int debug);
440 /**@ingroup file
441 * Open a file on an SMB server.
443 * @param furl The smb url of the file to be opened.
445 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
446 * request opening the file read-only,write-only
447 * or read/write. flags may also be bitwise-or'd with
448 * one or more of the following:
449 * O_CREAT - If the file does not exist it will be
450 * created.
451 * O_EXCL - When used with O_CREAT, if the file
452 * already exists it is an error and the open will
453 * fail.
454 * O_TRUNC - If the file already exists it will be
455 * truncated.
456 * O_APPEND The file is opened in append mode
458 * @param mode mode specifies the permissions to use if a new
459 * file is created. It is modified by the
460 * process's umask in the usual way: the permissions
461 * of the created file are (mode & ~umask)
463 * Not currently use, but there for future use.
464 * We will map this to SYSTEM, HIDDEN, etc bits
465 * that reverses the mapping that smbc_fstat does.
467 * @return Valid file handle, < 0 on error with errno set:
468 * - ENOMEM Out of memory
469 * - EINVAL if an invalid parameter passed, like no
470 * file, or smbc_init not called.
471 * - EEXIST pathname already exists and O_CREAT and
472 * O_EXCL were used.
473 * - EISDIR pathname refers to a directory and
474 * the access requested involved writing.
475 * - EACCES The requested access to the file is not
476 * allowed
477 * - ENODEV The requested share does not exist
478 * - ENOTDIR A file on the path is not a directory
479 * - ENOENT A directory component in pathname does
480 * not exist.
482 * @see smbc_creat()
484 * @note This call uses an underlying routine that may create
485 * a new connection to the server specified in the URL.
486 * If the credentials supplied in the URL, or via the
487 * auth_fn in the smbc_init call, fail, this call will
488 * try again with an empty username and password. This
489 * often gets mapped to the guest account on some machines.
492 int smbc_open(const char *furl, int flags, mode_t mode);
494 /**@ingroup file
495 * Create a file on an SMB server.
497 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
499 * @param furl The smb url of the file to be created
501 * @param mode mode specifies the permissions to use if a new
502 * file is created. It is modified by the
503 * process's umask in the usual way: the permissions
504 * of the created file are (mode & ~umask)
506 * NOTE, the above is not true. We are dealing with
507 * an SMB server, which has no concept of a umask!
509 * @return Valid file handle, < 0 on error with errno set:
510 * - ENOMEM Out of memory
511 * - EINVAL if an invalid parameter passed, like no
512 * file, or smbc_init not called.
513 * - EEXIST pathname already exists and O_CREAT and
514 * O_EXCL were used.
515 * - EISDIR pathname refers to a directory and
516 * the access requested involved writing.
517 * - EACCES The requested access to the file is not
518 * allowed
519 * - ENOENT A directory component in pathname does
520 * not exist.
521 * - ENODEV The requested share does not exist.
522 * @see smbc_open()
526 int smbc_creat(const char *furl, mode_t mode);
528 /**@ingroup file
529 * Read from a file using an opened file handle.
531 * @param fd Open file handle from smbc_open() or smbc_creat()
533 * @param buf Pointer to buffer to recieve read data
535 * @param bufsize Size of buf in bytes
537 * @return Number of bytes read, < 0 on error with errno set:
538 * - EISDIR fd refers to a directory
539 * - EBADF fd is not a valid file descriptor or
540 * is not open for reading.
541 * - EINVAL fd is attached to an object which is
542 * unsuitable for reading, or no buffer passed or
543 * smbc_init not called.
545 * @see smbc_open(), smbc_write()
548 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
551 /**@ingroup file
552 * Write to a file using an opened file handle.
554 * @param fd Open file handle from smbc_open() or smbc_creat()
556 * @param buf Pointer to buffer to recieve read data
558 * @param bufsize Size of buf in bytes
560 * @return Number of bytes written, < 0 on error with errno set:
561 * - EISDIR fd refers to a directory.
562 * - EBADF fd is not a valid file descriptor or
563 * is not open for reading.
564 * - EINVAL fd is attached to an object which is
565 * unsuitable for reading, or no buffer passed or
566 * smbc_init not called.
568 * @see smbc_open(), smbc_read()
571 ssize_t smbc_write(int fd, void *buf, size_t bufsize);
574 /**@ingroup file
575 * Seek to a specific location in a file.
577 * @param fd Open file handle from smbc_open() or smbc_creat()
579 * @param offset Offset in bytes from whence
581 * @param whence A location in the file:
582 * - SEEK_SET The offset is set to offset bytes from
583 * the beginning of the file
584 * - SEEK_CUR The offset is set to current location
585 * plus offset bytes.
586 * - SEEK_END The offset is set to the size of the
587 * file plus offset bytes.
589 * @return Upon successful completion, lseek returns the
590 * resulting offset location as measured in bytes
591 * from the beginning of the file. Otherwise, a value
592 * of (off_t)-1 is returned and errno is set to
593 * indicate the error:
594 * - EBADF Fildes is not an open file descriptor.
595 * - EINVAL Whence is not a proper value or smbc_init
596 * not called.
598 * @todo Are all the whence values really supported?
600 * @todo Are errno values complete and correct?
602 off_t smbc_lseek(int fd, off_t offset, int whence);
605 /**@ingroup file
606 * Close an open file handle.
608 * @param fd The file handle to close
610 * @return 0 on success, < 0 on error with errno set:
611 * - EBADF fd isn't a valid open file descriptor
612 * - EINVAL smbc_init() failed or has not been called
614 * @see smbc_open(), smbc_creat()
616 int smbc_close(int fd);
619 /**@ingroup directory
620 * Unlink (delete) a file or directory.
622 * @param furl The smb url of the file to delete
624 * @return 0 on success, < 0 on error with errno set:
625 * - EACCES or EPERM Write access to the directory
626 * containing pathname is not allowed or one
627 * of the directories in pathname did not allow
628 * search (execute) permission
629 * - ENOENT A directory component in pathname does
630 * not exist
631 * - EINVAL NULL was passed in the file param or
632 * smbc_init not called.
633 * - EACCES You do not have access to the file
634 * - ENOMEM Insufficient kernel memory was available
636 * @see smbc_rmdir()s
638 * @todo Are errno values complete and correct?
640 int smbc_unlink(const char *furl);
643 /**@ingroup directory
644 * Rename or move a file or directory.
646 * @param ourl The original smb url (source url) of file or
647 * directory to be moved
649 * @param nurl The new smb url (destination url) of the file
650 * or directory after the move. Currently nurl must
651 * be on the same share as ourl.
653 * @return 0 on success, < 0 on error with errno set:
654 * - EISDIR nurl is an existing directory, but ourl is
655 * not a directory.
656 * - EEXIST nurl is a non-empty directory,
657 * i.e., contains entries other than "." and ".."
658 * - EINVAL The new url contained a path prefix
659 * of the old, or, more generally, an attempt was
660 * made to make a directory a subdirectory of itself
661 * or smbc_init not called.
662 * - ENOTDIR A component used as a directory in ourl
663 * or nurl path is not, in fact, a directory. Or,
664 * ourl is a directory, and newpath exists but is not
665 * a directory.
666 * - EACCES or EPERM Write access to the directory
667 * containing ourl or nurl is not allowed for the
668 * process's effective uid, or one of the
669 * directories in ourl or nurl did not allow search
670 * (execute) permission, or ourl was a directory
671 * and did not allow write permission.
672 * - ENOENT A directory component in ourl or nurl
673 * does not exist.
674 * - EXDEV Rename across shares not supported.
675 * - ENOMEM Insufficient kernel memory was available.
676 * - EEXIST The target file, nurl, already exists.
679 * @todo Are we going to support copying when urls are not on the same
680 * share? I say no... NOTE. I agree for the moment.
683 int smbc_rename(const char *ourl, const char *nurl);
686 /**@ingroup directory
687 * Open a directory used to obtain directory entries.
689 * @param durl The smb url of the directory to open
691 * @return Valid directory handle. < 0 on error with errno set:
692 * - EACCES Permission denied.
693 * - EINVAL A NULL file/URL was passed, or the URL would
694 * not parse, or was of incorrect form or smbc_init not
695 * called.
696 * - ENOENT durl does not exist, or name is an
697 * - ENOMEM Insufficient memory to complete the
698 * operation.
699 * - ENOTDIR name is not a directory.
700 * - EPERM the workgroup could not be found.
701 * - ENODEV the workgroup or server could not be found.
703 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
706 int smbc_opendir(const char *durl);
709 /**@ingroup directory
710 * Close a directory handle opened by smbc_opendir().
712 * @param dh Directory handle to close
714 * @return 0 on success, < 0 on error with errno set:
715 * - EBADF dh is an invalid directory handle
717 * @see smbc_opendir()
719 int smbc_closedir(int dh);
722 /**@ingroup directory
723 * Get multiple directory entries.
725 * smbc_getdents() reads as many dirent structures from the an open
726 * directory handle into a specified memory area as will fit.
728 * @param dh Valid directory as returned by smbc_opendir()
730 * @param dirp pointer to buffer that will receive the directory
731 * entries.
733 * @param count The size of the dirp buffer in bytes
735 * @returns If any dirents returned, return will indicate the
736 * total size. If there were no more dirents available,
737 * 0 is returned. < 0 indicates an error.
738 * - EBADF Invalid directory handle
739 * - EINVAL Result buffer is too small or smbc_init
740 * not called.
741 * - ENOENT No such directory.
742 * @see , smbc_dirent, smbc_readdir(), smbc_open()
744 * @todo Are errno values complete and correct?
746 * @todo Add example code so people know how to parse buffers.
748 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
751 /**@ingroup directory
752 * Get a single directory entry.
754 * @param dh Valid directory as returned by smbc_opendir()
756 * @return A pointer to a smbc_dirent structure, or NULL if an
757 * error occurs or end-of-directory is reached:
758 * - EBADF Invalid directory handle
759 * - EINVAL smbc_init() failed or has not been called
761 * @see smbc_dirent, smbc_getdents(), smbc_open()
763 struct smbc_dirent* smbc_readdir(unsigned int dh);
766 /**@ingroup directory
767 * Get the current directory offset.
769 * smbc_telldir() may be used in conjunction with smbc_readdir() and
770 * smbc_lseekdir().
772 * @param dh Valid directory as returned by smbc_opendir()
774 * @return The current location in the directory stream or -1
775 * if an error occur. The current location is not
776 * an offset. Becuase of the implementation, it is a
777 * handle that allows the library to find the entry
778 * later.
779 * - EBADF dh is not a valid directory handle
780 * - EINVAL smbc_init() failed or has not been called
781 * - ENOTDIR if dh is not a directory
783 * @see smbc_readdir()
786 off_t smbc_telldir(int dh);
789 /**@ingroup directory
790 * lseek on directories.
792 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
793 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
795 * @param fd Valid directory as returned by smbc_opendir()
797 * @param offset The offset (as returned by smbc_telldir). Can be
798 * NULL, in which case we will rewind
800 * @return 0 on success, -1 on failure
801 * - EBADF dh is not a valid directory handle
802 * - ENOTDIR if dh is not a directory
803 * - EINVAL offset did not refer to a valid dirent or
804 * smbc_init not called.
806 * @see smbc_telldir()
809 * @todo In what does the reture and errno values mean?
811 int smbc_lseekdir(int fd, off_t offset);
813 /**@ingroup directory
814 * Create a directory.
816 * @param durl The url of the directory to create
818 * @param mode Specifies the permissions to use. It is modified
819 * by the process's umask in the usual way: the
820 * permissions of the created file are (mode & ~umask).
822 * @return 0 on success, < 0 on error with errno set:
823 * - EEXIST directory url already exists
824 * - EACCES The parent directory does not allow write
825 * permission to the process, or one of the directories
826 * - ENOENT A directory component in pathname does not
827 * exist.
828 * - EINVAL NULL durl passed or smbc_init not called.
829 * - ENOMEM Insufficient memory was available.
831 * @see smbc_rmdir()
834 int smbc_mkdir(const char *durl, mode_t mode);
837 /**@ingroup directory
838 * Remove a directory.
840 * @param durl The smb url of the directory to remove
842 * @return 0 on success, < 0 on error with errno set:
843 * - EACCES or EPERM Write access to the directory
844 * containing pathname was not allowed.
845 * - EINVAL durl is NULL or smbc_init not called.
846 * - ENOENT A directory component in pathname does not
847 * exist.
848 * - ENOTEMPTY directory contains entries.
849 * - ENOMEM Insufficient kernel memory was available.
851 * @see smbc_mkdir(), smbc_unlink()
853 * @todo Are errno values complete and correct?
855 int smbc_rmdir(const char *durl);
858 /**@ingroup attribute
859 * Get information about a file or directory.
861 * @param url The smb url to get information for
863 * @param st pointer to a buffer that will be filled with
864 * standard Unix struct stat information.
866 * @return 0 on success, < 0 on error with errno set:
867 * - ENOENT A component of the path file_name does not
868 * exist.
869 * - EINVAL a NULL url was passed or smbc_init not called.
870 * - EACCES Permission denied.
871 * - ENOMEM Out of memory
872 * - ENOTDIR The target dir, url, is not a directory.
874 * @see Unix stat()
877 int smbc_stat(const char *url, struct stat *st);
880 /**@ingroup attribute
881 * Get file information via an file descriptor.
883 * @param fd Open file handle from smbc_open() or smbc_creat()
885 * @param st pointer to a buffer that will be filled with
886 * standard Unix struct stat information.
888 * @return EBADF filedes is bad.
889 * - EACCES Permission denied.
890 * - EBADF fd is not a valid file descriptor
891 * - EINVAL Problems occurred in the underlying routines
892 * or smbc_init not called.
893 * - ENOMEM Out of memory
895 * @see smbc_stat(), Unix stat()
898 int smbc_fstat(int fd, struct stat *st);
901 /**@ingroup attribue
902 * Change the ownership of a file or directory.
904 * @param url The smb url of the file or directory to change
905 * ownership of.
907 * @param owner I have no idea?
909 * @param group I have not idea?
911 * @return 0 on success, < 0 on error with errno set:
912 * - EPERM The effective UID does not match the owner
913 * of the file, and is not zero; or the owner or group
914 * were specified incorrectly.
915 * - ENOENT The file does not exist.
916 * - ENOMEM Insufficient was available.
917 * - ENOENT file or directory does not exist
919 * @todo Are we actually going to be able to implement this function
921 * @todo How do we abstract owner and group uid and gid?
924 int smbc_chown(const char *url, uid_t owner, gid_t group);
927 /**@ingroup attribute
928 * Change the permissions of a file.
930 * @param url The smb url of the file or directory to change
931 * permissions of
933 * @param mode The permissions to set:
934 * - Put good explaination of permissions here!
936 * @return 0 on success, < 0 on error with errno set:
937 * - EPERM The effective UID does not match the owner
938 * of the file, and is not zero
939 * - ENOENT The file does not exist.
940 * - ENOMEM Insufficient was available.
941 * - ENOENT file or directory does not exist
943 * @todo Actually implement this fuction?
945 * @todo Are errno values complete and correct?
947 int smbc_chmod(const char *url, mode_t mode);
950 /**@ingroup print
951 * Print a file given the name in fname. It would be a URL ...
953 * @param fname The URL of a file on a remote SMB server that the
954 * caller wants printed
956 * @param printq The URL of the print share to print the file to.
958 * @return 0 on success, < 0 on error with errno set:
960 * - EINVAL fname or printq was NULL or smbc_init not
961 * not called.
962 * and errors returned by smbc_open
965 int smbc_print_file(const char *fname, const char *printq);
967 /**@ingroup print
968 * Open a print file that can be written to by other calls. This simply
969 * does an smbc_open call after checking if there is a file name on the
970 * URI. If not, a temporary name is added ...
972 * @param fname The URL of the print share to print to?
974 * @returns A file handle for the print file if successful.
975 * Returns -1 if an error ocurred and errno has the values
976 * - EINVAL fname was NULL or smbc_init not called.
977 * - all errors returned by smbc_open
980 int smbc_open_print_job(const char *fname);
982 /**@ingroup print
983 * List the print jobs on a print share, for the moment, pass a callback
985 * @param purl The url of the print share to list the jobs of
987 * @param fn Callback function the receives printjob info
989 * @return 0 on success, < 0 on error with errno set:
990 * - EINVAL fname was NULL or smbc_init not called
991 * - EACCES ???
993 int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn);
995 /**@ingroup print
996 * Delete a print job
998 * @param purl Url of the print share
1000 * @param id The id of the job to delete
1002 * @return 0 on success, < 0 on error with errno set:
1003 * - EINVAL fname was NULL or smbc_init not called
1005 * @todo what errno values are possible here?
1007 int smbc_unlink_print_job(const char *purl, int id);
1010 #endif /* SMBCLIENT_H_INCLUDED */