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
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>
65 #define SMBC_MAX_NAME 1023
66 #define SMBC_WORKGROUP 1
68 #define SMBC_FILE_SHARE 3
69 #define SMBC_PRINTER_SHARE 4
70 #define SMBC_COMMS_SHARE 5
71 #define SMBC_IPC_SHARE 6
76 #define SMBC_FILE_MODE (S_IFREG | 0444)
77 #define SMBC_DIR_MODE (S_IFDIR | 0555)
79 #define SMBC_MAX_FD 10000
83 * Structure that represents a directory entry.
100 /** Length of this smbc_dirent in bytes
103 /** The length of the comment string in bytes (includes null
107 /** Points to the null terminated comment string
110 /** The length of the name string in bytes (includes null
114 /** Points to the null terminated name string
121 typedef unsigned short uint16
;
123 /**@ingroup structure
124 * Structure that represents a print job.
127 struct print_job_info
129 /** numeric ID of the print job
133 /** represents print job priority (lower numbers mean higher priority)
137 /** Size of the print job
141 /** Name of the user that owns the print job
145 /** Name of the print job. This will have no name if an anonymous print
146 * file was opened. Ie smb://server/printer
150 /** Time the print job was spooled
157 /**@ingroup structure
158 * Authentication callback function type.
160 * Type for the the authentication function called by the library to
161 * obtain authentication credentals
163 * @param srv Server being authenticated to
165 * @param shr Share being authenticated to
167 * @param wg Pointer to buffer containing a "hint" for the
168 * workgroup to be authenticated. Should be filled in
169 * with the correct workgroup if the hint is wrong.
171 * @param wglen The size of the workgroup buffer in bytes
173 * @param un Pointer to buffer containing a "hint" for the
174 * user name to be use for authentication. Should be
175 * filled in with the correct workgroup if the hint is
178 * @param unlen The size of the username buffer in bytes
180 * @param pw Pointer to buffer containing to which password
183 * @param pwlen The size of the password buffer in bytes
186 typedef void (*smbc_get_auth_data_fn
)(const char *srv
,
190 char *pw
, int pwlen
);
193 /**@ingroup structure
194 * Print job info callback function type.
196 * @param i pointer to print job information structure
199 typedef void (*smbc_get_print_job_info
)(struct print_job_info
*i
);
203 #ifndef _SMBC_INTERNAL
204 /**@ingroup structure
205 * Type for connected server management
210 /**@ingroup structure
211 * Type for open file/directory management
214 typedef int SMBCFILE
;
218 * These definitions are only available to the libsmbclient internals
219 * They all have to define _SMBC_INTERNAL to get these
221 typedef struct _SMBCSRV
{
222 struct cli_state cli
;
227 struct _SMBCSRV
*next
, *prev
;
232 * Keep directory entries in a list
234 struct smbc_dir_list
{
235 struct smbc_dir_list
*next
;
236 struct smbc_dirent
*dirent
;
241 * Structure for open file management
243 typedef struct _SMBCFILE
{
249 struct smbc_dir_list
*dir_list
, *dir_end
, *dir_next
;
250 int dir_type
, dir_error
;
252 struct _SMBCFILE
*next
, *prev
;
254 #endif /* ifndef _SMBC_INTERNAL */
256 /**@ingroup structure
257 * Structure that contains a client context information
259 typedef struct _SMBCCTX
{
264 /** netbios name used for making connections
268 /** workgroup name used for making connections
272 /** username used for making connections
276 /** timeout used for waiting on connections / response data (in milliseconds)
280 /** callable functions for files:
281 * For usage and return values see the smbc_* functions
283 SMBCFILE
* (*open
) (struct _SMBCCTX
*c
, const char *fname
, int flags
, mode_t mode
);
284 SMBCFILE
* (*creat
) (struct _SMBCCTX
*c
, const char *path
, mode_t mode
);
285 ssize_t (*read
) (struct _SMBCCTX
*c
, SMBCFILE
*file
, void *buf
, size_t count
);
286 ssize_t (*write
) (struct _SMBCCTX
*c
, SMBCFILE
*file
, void *buf
, size_t count
);
287 int (*unlink
) (struct _SMBCCTX
*c
, const char *fname
);
288 int (*rename
) (struct _SMBCCTX
*ocontext
, const char *oname
,
289 struct _SMBCCTX
*ncontext
, const char *nname
);
290 off_t (*lseek
) (struct _SMBCCTX
*c
, SMBCFILE
* file
, off_t offset
, int whence
);
291 int (*stat
) (struct _SMBCCTX
*c
, const char *fname
, struct stat
*st
);
292 int (*fstat
) (struct _SMBCCTX
*c
, SMBCFILE
*file
, struct stat
*st
);
293 int (*close
) (struct _SMBCCTX
*c
, SMBCFILE
*file
);
295 /** callable functions for dirs
297 SMBCFILE
* (*opendir
) (struct _SMBCCTX
*c
, const char *fname
);
298 int (*closedir
)(struct _SMBCCTX
*c
, SMBCFILE
*dir
);
299 struct smbc_dirent
* (*readdir
)(struct _SMBCCTX
*c
, SMBCFILE
*dir
);
300 int (*getdents
)(struct _SMBCCTX
*c
, SMBCFILE
*dir
,
301 struct smbc_dirent
*dirp
, int count
);
302 int (*mkdir
) (struct _SMBCCTX
*c
, const char *fname
, mode_t mode
);
303 int (*rmdir
) (struct _SMBCCTX
*c
, const char *fname
);
304 off_t (*telldir
) (struct _SMBCCTX
*c
, SMBCFILE
*dir
);
305 int (*lseekdir
)(struct _SMBCCTX
*c
, SMBCFILE
*dir
, off_t offset
);
306 int (*fstatdir
)(struct _SMBCCTX
*c
, SMBCFILE
*dir
, struct stat
*st
);
308 /** callable functions for printing
310 int (*print_file
)(struct _SMBCCTX
*c_file
, const char *fname
,
311 struct _SMBCCTX
*c_print
, const char *printq
);
312 SMBCFILE
* (*open_print_job
)(struct _SMBCCTX
*c
, const char *fname
);
313 int (*list_print_jobs
)(struct _SMBCCTX
*c
, const char *fname
, void (*fn
)(struct print_job_info
*));
314 int (*unlink_print_job
)(struct _SMBCCTX
*c
, const char *fname
, int id
);
318 * These callbacks _always_ have to be intialized because they will not be checked
319 * at dereference for increased speed.
321 struct _smbc_callbacks
{
322 /** authentication function callback: called upon auth requests
324 smbc_get_auth_data_fn auth_fn
;
326 /** check if a server is still good
328 int (*check_server_fn
)(struct _SMBCCTX
* c
, SMBCSRV
*srv
);
330 /** remove a server if unused
332 int (*remove_unused_server_fn
)(struct _SMBCCTX
* c
, SMBCSRV
*srv
);
335 * For an example cache system see samba/source/libsmb/libsmb_cache.c
336 * Cache subsystem functions follow.
339 /** server cache addition
341 int (*add_cached_srv_fn
) (struct _SMBCCTX
* c
, SMBCSRV
*srv
,
342 char * server
, char * share
,
343 char * workgroup
, char * username
);
344 /** server cache lookup
346 SMBCSRV
* (*get_cached_srv_fn
) (struct _SMBCCTX
* c
, char * server
,
347 char * share
, char * workgroup
, char * username
);
348 /** server cache removal
350 int (*remove_cached_srv_fn
)(struct _SMBCCTX
* c
, SMBCSRV
*srv
);
352 /** server cache purging, try to remove all cached servers (disconnect)
354 int (*purge_cached_fn
) (struct _SMBCCTX
* c
);
359 /** Space to store private data of the server cache.
363 /** INTERNAL functions
364 * do _NOT_ touch these from your program !
367 /** INTERNAL: is this handle initialized ?
371 /** INTERNAL: dirent pointer location
375 /** INTERNAL: server connection list
379 /** INTERNAL: open file/dir list
387 * Create a new SBMCCTX (a context).
389 * Must be called before the context is passed to smbc_context_init()
391 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
392 * - ENOMEM Out of memory
394 * @see smbc_free_context(), smbc_init_context()
396 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
398 SMBCCTX
* smbc_new_context(void);
402 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
404 * The context will be deleted if possible.
406 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
408 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
411 * @return Returns 0 on succes. Returns 1 on failure with errno set:
412 * - EBUSY Server connections are still used, Files are open or cache
413 * could not be purged
414 * - EBADF context == NULL
416 * @see smbc_new_context()
418 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
419 * just before exit()'ing. When shutdown_ctx is 0, this function can be
420 * use in periodical cleanup functions for example.
422 int smbc_free_context(SMBCCTX
* context
, int shutdown_ctx
);
426 * Initialize a SBMCCTX (a context).
428 * Must be called before using any SMBCCTX API function
430 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
432 * @return A pointer to the given SMBCCTX on success, NULL on error with errno set:
433 * - EBADF NULL context given
434 * - ENOMEM Out of memory
435 * - ENOENT The smb.conf file would not load
437 * @see smbc_new_context()
439 * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe,
440 * but it might leak memory on smbc_context_init() failure. Avoid this.
441 * You'll have to call smbc_free_context() yourself on failure.
443 SMBCCTX
* smbc_init_context(SMBCCTX
* context
);
447 * Initialize the samba client library.
449 * Must be called before using any of the smbclient API function
451 * @param fn The function that will be called to obtaion
452 * authentication credentials.
454 * @param debug Allows caller to set the debug level. Can be
455 * changed in smb.conf file. Allows caller to set
456 * debugging if no smb.conf.
458 * @return 0 on success, < 0 on error with errno set:
459 * - ENOMEM Out of memory
460 * - ENOENT The smb.conf file would not load
463 int smbc_init(smbc_get_auth_data_fn fn
, int debug
);
467 * Open a file on an SMB server.
469 * @param furl The smb url of the file to be opened.
471 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
472 * request opening the file read-only,write-only
473 * or read/write. flags may also be bitwise-or'd with
474 * one or more of the following:
475 * O_CREAT - If the file does not exist it will be
477 * O_EXCL - When used with O_CREAT, if the file
478 * already exists it is an error and the open will
480 * O_TRUNC - If the file already exists it will be
482 * O_APPEND The file is opened in append mode
484 * @param mode mode specifies the permissions to use if a new
485 * file is created. It is modified by the
486 * process's umask in the usual way: the permissions
487 * of the created file are (mode & ~umask)
489 * Not currently use, but there for future use.
490 * We will map this to SYSTEM, HIDDEN, etc bits
491 * that reverses the mapping that smbc_fstat does.
493 * @return Valid file handle, < 0 on error with errno set:
494 * - ENOMEM Out of memory
495 * - EINVAL if an invalid parameter passed, like no
496 * file, or smbc_init not called.
497 * - EEXIST pathname already exists and O_CREAT and
499 * - EISDIR pathname refers to a directory and
500 * the access requested involved writing.
501 * - EACCES The requested access to the file is not
503 * - ENODEV The requested share does not exist
504 * - ENOTDIR A file on the path is not a directory
505 * - ENOENT A directory component in pathname does
510 * @note This call uses an underlying routine that may create
511 * a new connection to the server specified in the URL.
512 * If the credentials supplied in the URL, or via the
513 * auth_fn in the smbc_init call, fail, this call will
514 * try again with an empty username and password. This
515 * often gets mapped to the guest account on some machines.
517 int smbc_open(const char *furl
, int flags
, mode_t mode
);
521 * Create a file on an SMB server.
523 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
525 * @param furl The smb url of the file to be created
527 * @param mode mode specifies the permissions to use if a new
528 * file is created. It is modified by the
529 * process's umask in the usual way: the permissions
530 * of the created file are (mode & ~umask)
532 * NOTE, the above is not true. We are dealing with
533 * an SMB server, which has no concept of a umask!
535 * @return Valid file handle, < 0 on error with errno set:
536 * - ENOMEM Out of memory
537 * - EINVAL if an invalid parameter passed, like no
538 * file, or smbc_init not called.
539 * - EEXIST pathname already exists and O_CREAT and
541 * - EISDIR pathname refers to a directory and
542 * the access requested involved writing.
543 * - EACCES The requested access to the file is not
545 * - ENOENT A directory component in pathname does
547 * - ENODEV The requested share does not exist.
551 int smbc_creat(const char *furl
, mode_t mode
);
555 * Read from a file using an opened file handle.
557 * @param fd Open file handle from smbc_open() or smbc_creat()
559 * @param buf Pointer to buffer to recieve read data
561 * @param bufsize Size of buf in bytes
563 * @return Number of bytes read, < 0 on error with errno set:
564 * - EISDIR fd refers to a directory
565 * - EBADF fd is not a valid file descriptor or
566 * is not open for reading.
567 * - EINVAL fd is attached to an object which is
568 * unsuitable for reading, or no buffer passed or
569 * smbc_init not called.
571 * @see smbc_open(), smbc_write()
574 ssize_t
smbc_read(int fd
, void *buf
, size_t bufsize
);
578 * Write to a file using an opened file handle.
580 * @param fd Open file handle from smbc_open() or smbc_creat()
582 * @param buf Pointer to buffer to recieve read data
584 * @param bufsize Size of buf in bytes
586 * @return Number of bytes written, < 0 on error with errno set:
587 * - EISDIR fd refers to a directory.
588 * - EBADF fd is not a valid file descriptor or
589 * is not open for reading.
590 * - EINVAL fd is attached to an object which is
591 * unsuitable for reading, or no buffer passed or
592 * smbc_init not called.
594 * @see smbc_open(), smbc_read()
597 ssize_t
smbc_write(int fd
, void *buf
, size_t bufsize
);
601 * Seek to a specific location in a file.
603 * @param fd Open file handle from smbc_open() or smbc_creat()
605 * @param offset Offset in bytes from whence
607 * @param whence A location in the file:
608 * - SEEK_SET The offset is set to offset bytes from
609 * the beginning of the file
610 * - SEEK_CUR The offset is set to current location
612 * - SEEK_END The offset is set to the size of the
613 * file plus offset bytes.
615 * @return Upon successful completion, lseek returns the
616 * resulting offset location as measured in bytes
617 * from the beginning of the file. Otherwise, a value
618 * of (off_t)-1 is returned and errno is set to
619 * indicate the error:
620 * - EBADF Fildes is not an open file descriptor.
621 * - EINVAL Whence is not a proper value or smbc_init
624 * @todo Are all the whence values really supported?
626 * @todo Are errno values complete and correct?
628 off_t
smbc_lseek(int fd
, off_t offset
, int whence
);
632 * Close an open file handle.
634 * @param fd The file handle to close
636 * @return 0 on success, < 0 on error with errno set:
637 * - EBADF fd isn't a valid open file descriptor
638 * - EINVAL smbc_init() failed or has not been called
640 * @see smbc_open(), smbc_creat()
642 int smbc_close(int fd
);
645 /**@ingroup directory
646 * Unlink (delete) a file or directory.
648 * @param furl The smb url of the file to delete
650 * @return 0 on success, < 0 on error with errno set:
651 * - EACCES or EPERM Write access to the directory
652 * containing pathname is not allowed or one
653 * of the directories in pathname did not allow
654 * search (execute) permission
655 * - ENOENT A directory component in pathname does
657 * - EINVAL NULL was passed in the file param or
658 * smbc_init not called.
659 * - EACCES You do not have access to the file
660 * - ENOMEM Insufficient kernel memory was available
664 * @todo Are errno values complete and correct?
666 int smbc_unlink(const char *furl
);
669 /**@ingroup directory
670 * Rename or move a file or directory.
672 * @param ourl The original smb url (source url) of file or
673 * directory to be moved
675 * @param nurl The new smb url (destination url) of the file
676 * or directory after the move. Currently nurl must
677 * be on the same share as ourl.
679 * @return 0 on success, < 0 on error with errno set:
680 * - EISDIR nurl is an existing directory, but ourl is
682 * - EEXIST nurl is a non-empty directory,
683 * i.e., contains entries other than "." and ".."
684 * - EINVAL The new url contained a path prefix
685 * of the old, or, more generally, an attempt was
686 * made to make a directory a subdirectory of itself
687 * or smbc_init not called.
688 * - ENOTDIR A component used as a directory in ourl
689 * or nurl path is not, in fact, a directory. Or,
690 * ourl is a directory, and newpath exists but is not
692 * - EACCES or EPERM Write access to the directory
693 * containing ourl or nurl is not allowed for the
694 * process's effective uid, or one of the
695 * directories in ourl or nurl did not allow search
696 * (execute) permission, or ourl was a directory
697 * and did not allow write permission.
698 * - ENOENT A directory component in ourl or nurl
700 * - EXDEV Rename across shares not supported.
701 * - ENOMEM Insufficient kernel memory was available.
702 * - EEXIST The target file, nurl, already exists.
705 * @todo Are we going to support copying when urls are not on the same
706 * share? I say no... NOTE. I agree for the moment.
709 int smbc_rename(const char *ourl
, const char *nurl
);
712 /**@ingroup directory
713 * Open a directory used to obtain directory entries.
715 * @param durl The smb url of the directory to open
717 * @return Valid directory handle. < 0 on error with errno set:
718 * - EACCES Permission denied.
719 * - EINVAL A NULL file/URL was passed, or the URL would
720 * not parse, or was of incorrect form or smbc_init not
722 * - ENOENT durl does not exist, or name is an
723 * - ENOMEM Insufficient memory to complete the
725 * - ENOTDIR name is not a directory.
726 * - EPERM the workgroup could not be found.
727 * - ENODEV the workgroup or server could not be found.
729 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
732 int smbc_opendir(const char *durl
);
735 /**@ingroup directory
736 * Close a directory handle opened by smbc_opendir().
738 * @param dh Directory handle to close
740 * @return 0 on success, < 0 on error with errno set:
741 * - EBADF dh is an invalid directory handle
743 * @see smbc_opendir()
745 int smbc_closedir(int dh
);
748 /**@ingroup directory
749 * Get multiple directory entries.
751 * smbc_getdents() reads as many dirent structures from the an open
752 * directory handle into a specified memory area as will fit.
754 * @param dh Valid directory as returned by smbc_opendir()
756 * @param dirp pointer to buffer that will receive the directory
759 * @param count The size of the dirp buffer in bytes
761 * @returns If any dirents returned, return will indicate the
762 * total size. If there were no more dirents available,
763 * 0 is returned. < 0 indicates an error.
764 * - EBADF Invalid directory handle
765 * - EINVAL Result buffer is too small or smbc_init
767 * - ENOENT No such directory.
768 * @see , smbc_dirent, smbc_readdir(), smbc_open()
770 * @todo Are errno values complete and correct?
772 * @todo Add example code so people know how to parse buffers.
774 int smbc_getdents(unsigned int dh
, struct smbc_dirent
*dirp
, int count
);
777 /**@ingroup directory
778 * Get a single directory entry.
780 * @param dh Valid directory as returned by smbc_opendir()
782 * @return A pointer to a smbc_dirent structure, or NULL if an
783 * error occurs or end-of-directory is reached:
784 * - EBADF Invalid directory handle
785 * - EINVAL smbc_init() failed or has not been called
787 * @see smbc_dirent, smbc_getdents(), smbc_open()
789 struct smbc_dirent
* smbc_readdir(unsigned int dh
);
792 /**@ingroup directory
793 * Get the current directory offset.
795 * smbc_telldir() may be used in conjunction with smbc_readdir() and
798 * @param dh Valid directory as returned by smbc_opendir()
800 * @return The current location in the directory stream or -1
801 * if an error occur. The current location is not
802 * an offset. Becuase of the implementation, it is a
803 * handle that allows the library to find the entry
805 * - EBADF dh is not a valid directory handle
806 * - EINVAL smbc_init() failed or has not been called
807 * - ENOTDIR if dh is not a directory
809 * @see smbc_readdir()
812 off_t
smbc_telldir(int dh
);
815 /**@ingroup directory
816 * lseek on directories.
818 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
819 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
821 * @param fd Valid directory as returned by smbc_opendir()
823 * @param offset The offset (as returned by smbc_telldir). Can be
824 * NULL, in which case we will rewind
826 * @return 0 on success, -1 on failure
827 * - EBADF dh is not a valid directory handle
828 * - ENOTDIR if dh is not a directory
829 * - EINVAL offset did not refer to a valid dirent or
830 * smbc_init not called.
832 * @see smbc_telldir()
835 * @todo In what does the reture and errno values mean?
837 int smbc_lseekdir(int fd
, off_t offset
);
839 /**@ingroup directory
840 * Create a directory.
842 * @param durl The url of the directory to create
844 * @param mode Specifies the permissions to use. It is modified
845 * by the process's umask in the usual way: the
846 * permissions of the created file are (mode & ~umask).
848 * @return 0 on success, < 0 on error with errno set:
849 * - EEXIST directory url already exists
850 * - EACCES The parent directory does not allow write
851 * permission to the process, or one of the directories
852 * - ENOENT A directory component in pathname does not
854 * - EINVAL NULL durl passed or smbc_init not called.
855 * - ENOMEM Insufficient memory was available.
860 int smbc_mkdir(const char *durl
, mode_t mode
);
863 /**@ingroup directory
864 * Remove a directory.
866 * @param durl The smb url of the directory to remove
868 * @return 0 on success, < 0 on error with errno set:
869 * - EACCES or EPERM Write access to the directory
870 * containing pathname was not allowed.
871 * - EINVAL durl is NULL or smbc_init not called.
872 * - ENOENT A directory component in pathname does not
874 * - ENOTEMPTY directory contains entries.
875 * - ENOMEM Insufficient kernel memory was available.
877 * @see smbc_mkdir(), smbc_unlink()
879 * @todo Are errno values complete and correct?
881 int smbc_rmdir(const char *durl
);
884 /**@ingroup attribute
885 * Get information about a file or directory.
887 * @param url The smb url to get information for
889 * @param st pointer to a buffer that will be filled with
890 * standard Unix struct stat information.
892 * @return 0 on success, < 0 on error with errno set:
893 * - ENOENT A component of the path file_name does not
895 * - EINVAL a NULL url was passed or smbc_init not called.
896 * - EACCES Permission denied.
897 * - ENOMEM Out of memory
898 * - ENOTDIR The target dir, url, is not a directory.
903 int smbc_stat(const char *url
, struct stat
*st
);
906 /**@ingroup attribute
907 * Get file information via an file descriptor.
909 * @param fd Open file handle from smbc_open() or smbc_creat()
911 * @param st pointer to a buffer that will be filled with
912 * standard Unix struct stat information.
914 * @return EBADF filedes is bad.
915 * - EACCES Permission denied.
916 * - EBADF fd is not a valid file descriptor
917 * - EINVAL Problems occurred in the underlying routines
918 * or smbc_init not called.
919 * - ENOMEM Out of memory
921 * @see smbc_stat(), Unix stat()
924 int smbc_fstat(int fd
, struct stat
*st
);
928 * Change the ownership of a file or directory.
930 * @param url The smb url of the file or directory to change
933 * @param owner I have no idea?
935 * @param group I have not idea?
937 * @return 0 on success, < 0 on error with errno set:
938 * - EPERM The effective UID does not match the owner
939 * of the file, and is not zero; or the owner or group
940 * were specified incorrectly.
941 * - ENOENT The file does not exist.
942 * - ENOMEM Insufficient was available.
943 * - ENOENT file or directory does not exist
945 * @todo Are we actually going to be able to implement this function
947 * @todo How do we abstract owner and group uid and gid?
950 int smbc_chown(const char *url
, uid_t owner
, gid_t group
);
953 /**@ingroup attribute
954 * Change the permissions of a file.
956 * @param url The smb url of the file or directory to change
959 * @param mode The permissions to set:
960 * - Put good explaination of permissions here!
962 * @return 0 on success, < 0 on error with errno set:
963 * - EPERM The effective UID does not match the owner
964 * of the file, and is not zero
965 * - ENOENT The file does not exist.
966 * - ENOMEM Insufficient was available.
967 * - ENOENT file or directory does not exist
969 * @todo Actually implement this fuction?
971 * @todo Are errno values complete and correct?
973 int smbc_chmod(const char *url
, mode_t mode
);
977 * Print a file given the name in fname. It would be a URL ...
979 * @param fname The URL of a file on a remote SMB server that the
980 * caller wants printed
982 * @param printq The URL of the print share to print the file to.
984 * @return 0 on success, < 0 on error with errno set:
986 * - EINVAL fname or printq was NULL or smbc_init not
988 * and errors returned by smbc_open
991 int smbc_print_file(const char *fname
, const char *printq
);
994 * Open a print file that can be written to by other calls. This simply
995 * does an smbc_open call after checking if there is a file name on the
996 * URI. If not, a temporary name is added ...
998 * @param fname The URL of the print share to print to?
1000 * @returns A file handle for the print file if successful.
1001 * Returns -1 if an error ocurred and errno has the values
1002 * - EINVAL fname was NULL or smbc_init not called.
1003 * - all errors returned by smbc_open
1006 int smbc_open_print_job(const char *fname
);
1009 * List the print jobs on a print share, for the moment, pass a callback
1011 * @param purl The url of the print share to list the jobs of
1013 * @param fn Callback function the receives printjob info
1015 * @return 0 on success, < 0 on error with errno set:
1016 * - EINVAL fname was NULL or smbc_init not called
1019 int smbc_list_print_jobs(const char *purl
, smbc_get_print_job_info fn
);
1022 * Delete a print job
1024 * @param purl Url of the print share
1026 * @param id The id of the job to delete
1028 * @return 0 on success, < 0 on error with errno set:
1029 * - EINVAL fname was NULL or smbc_init not called
1031 * @todo what errno values are possible here?
1033 int smbc_unlink_print_job(const char *purl
, int id
);
1036 #endif /* SMBCLIENT_H_INCLUDED */