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
8 Copyright (C) Derrell Lipman 2003
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 =====================================================================*/
26 #ifndef SMBCLIENT_H_INCLUDED
27 #define SMBCLIENT_H_INCLUDED
29 /*-------------------------------------------------------------------*/
30 /* The following are special comments to instruct DOXYGEN (automated
33 /** \defgroup libsmbclient
35 /** \defgroup structure Data Structures Type and Constants
36 * \ingroup libsmbclient
37 * Data structures, types, and constants
39 /** \defgroup callback Callback function types
40 * \ingroup libsmbclient
43 /** \defgroup file File Functions
44 * \ingroup libsmbclient
45 * Functions used to access individual file contents
47 /** \defgroup directory Directory Functions
48 * \ingroup libsmbclient
49 * Functions used to access directory entries
51 /** \defgroup attribute Attributes Functions
52 * \ingroup libsmbclient
53 * Functions used to view or change file and directory attributes
55 /** \defgroup print Print Functions
56 * \ingroup libsmbclient
57 * Functions used to access printing functionality
59 /** \defgroup misc Miscellaneous Functions
60 * \ingroup libsmbclient
61 * Functions that don't fit in to other categories
63 /*-------------------------------------------------------------------*/
65 /* Make sure we have the following includes for now ... */
66 #include <sys/types.h>
71 #define SMBC_CTX_VERSION 1
73 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
75 #define SMBC_WORKGROUP 1
77 #define SMBC_FILE_SHARE 3
78 #define SMBC_PRINTER_SHARE 4
79 #define SMBC_COMMS_SHARE 5
80 #define SMBC_IPC_SHARE 6
86 * Structure that represents a directory entry.
101 unsigned int smbc_type;
103 /** Length of this smbc_dirent in bytes
106 /** The length of the comment string in bytes (includes null
109 unsigned int commentlen;
110 /** Points to the null terminated comment string
113 /** The length of the name string in bytes (includes null
116 unsigned int namelen;
117 /** Points to the null terminated name string
123 * Flags for smbc_setxattr()
124 * Specify a bitwise OR of these, or 0 to add or replace as necessary
126 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
127 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
131 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
132 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
133 * "system.*") is specified.
135 #define SMBC_DOS_MODE_READONLY 0x01
136 #define SMBC_DOS_MODE_HIDDEN 0x02
137 #define SMBC_DOS_MODE_SYSTEM 0x04
138 #define SMBC_DOS_MODE_VOLUME_ID 0x08
139 #define SMBC_DOS_MODE_DIRECTORY 0x10
140 #define SMBC_DOS_MODE_ARCHIVE 0x20
144 # define ENOATTR ENOENT /* No such attribute */
150 /**@ingroup structure
151 * Structure that represents a print job.
155 struct print_job_info
157 /** numeric ID of the print job
161 /** represents print job priority (lower numbers mean higher priority)
163 unsigned short priority;
165 /** Size of the print job
169 /** Name of the user that owns the print job
173 /** Name of the print job. This will have no name if an anonymous print
174 * file was opened. Ie smb://server/printer
178 /** Time the print job was spooled
182 #endif /* _CLIENT_H */
185 /**@ingroup structure
188 typedef struct _SMBCSRV SMBCSRV;
190 /**@ingroup structure
191 * File or directory handle
193 typedef struct _SMBCFILE SMBCFILE;
195 /**@ingroup structure
196 * File or directory handle
198 typedef struct _SMBCCTX SMBCCTX;
205 * Authentication callback function type.
207 * Type for the the authentication function called by the library to
208 * obtain authentication credentals
210 * @param srv Server being authenticated to
212 * @param shr Share being authenticated to
214 * @param wg Pointer to buffer containing a "hint" for the
215 * workgroup to be authenticated. Should be filled in
216 * with the correct workgroup if the hint is wrong.
218 * @param wglen The size of the workgroup buffer in bytes
220 * @param un Pointer to buffer containing a "hint" for the
221 * user name to be use for authentication. Should be
222 * filled in with the correct workgroup if the hint is
225 * @param unlen The size of the username buffer in bytes
227 * @param pw Pointer to buffer containing to which password
230 * @param pwlen The size of the password buffer in bytes
233 typedef void (*smbc_get_auth_data_fn)(const char *srv,
237 char *pw, int pwlen);
241 * Print job info callback function type.
243 * @param i pointer to print job information structure
246 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
250 * Check if a server is still good
252 * @param c pointer to smb context
254 * @param srv pointer to server to check
256 * @return 0 when connection is good. 1 on error.
259 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
262 * Remove a server if unused
264 * @param c pointer to smb context
266 * @param srv pointer to server to remove
268 * @return 0 on success. 1 on failure.
271 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
275 * Add a server to the cache system
277 * @param c pointer to smb context
279 * @param srv pointer to server to add
281 * @param server server name
283 * @param share share name
285 * @param workgroup workgroup used to connect
287 * @param username username used to connect
289 * @return 0 on success. 1 on failure.
292 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
293 const char * server, const char * share,
294 const char * workgroup, const char * username);
297 * Look up a server in the cache system
299 * @param c pointer to smb context
301 * @param server server name to match
303 * @param share share name to match
305 * @param workgroup workgroup to match
307 * @param username username to match
309 * @return pointer to SMBCSRV on success. NULL on failure.
312 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
313 const char * share, const char * workgroup,
314 const char * username);
317 * Check if a server is still good
319 * @param c pointer to smb context
321 * @param srv pointer to server to remove
323 * @return 0 when found and removed. 1 on failure.
326 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
330 * Try to remove all servers from the cache system and disconnect
332 * @param c pointer to smb context
334 * @return 0 when found and removed. 1 on failure.
337 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
342 /**@ingroup structure
343 * Structure that contains a client context information
344 * This structure is know as SMBCCTX
351 /** netbios name used for making connections
355 /** workgroup name used for making connections
359 /** username used for making connections
363 /** timeout used for waiting on connections / response data (in milliseconds)
367 /** callable functions for files:
368 * For usage and return values see the smbc_* functions
370 SMBCFILE * (*open) (SMBCCTX *c, const char *fname, int flags, mode_t mode);
371 SMBCFILE * (*creat) (SMBCCTX *c, const char *path, mode_t mode);
372 ssize_t (*read) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
373 ssize_t (*write) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
374 int (*unlink) (SMBCCTX *c, const char *fname);
375 int (*rename) (SMBCCTX *ocontext, const char *oname,
376 SMBCCTX *ncontext, const char *nname);
377 off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence);
378 int (*stat) (SMBCCTX *c, const char *fname, struct stat *st);
379 int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st);
380 int (*close) (SMBCCTX *c, SMBCFILE *file);
382 /** callable functions for dirs
384 SMBCFILE * (*opendir) (SMBCCTX *c, const char *fname);
385 int (*closedir)(SMBCCTX *c, SMBCFILE *dir);
386 struct smbc_dirent * (*readdir)(SMBCCTX *c, SMBCFILE *dir);
387 int (*getdents)(SMBCCTX *c, SMBCFILE *dir,
388 struct smbc_dirent *dirp, int count);
389 int (*mkdir) (SMBCCTX *c, const char *fname, mode_t mode);
390 int (*rmdir) (SMBCCTX *c, const char *fname);
391 off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir);
392 int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset);
393 int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st);
394 int (*chmod)(SMBCCTX *c, const char *fname, mode_t mode);
395 int (*utimes)(SMBCCTX *c,
396 const char *fname, struct timeval *tbuf);
397 int (*setxattr)(SMBCCTX *context,
403 int (*getxattr)(SMBCCTX *context,
408 int (*removexattr)(SMBCCTX *context,
411 int (*listxattr)(SMBCCTX *context,
416 /** callable functions for printing
418 int (*print_file)(SMBCCTX *c_file, const char *fname,
419 SMBCCTX *c_print, const char *printq);
420 SMBCFILE * (*open_print_job)(SMBCCTX *c, const char *fname);
421 int (*list_print_jobs)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn);
422 int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id);
426 * These callbacks _always_ have to be initialized because they will not be checked
427 * at dereference for increased speed.
429 struct _smbc_callbacks {
430 /** authentication function callback: called upon auth requests
432 smbc_get_auth_data_fn auth_fn;
434 /** check if a server is still good
436 smbc_check_server_fn check_server_fn;
438 /** remove a server if unused
440 smbc_remove_unused_server_fn remove_unused_server_fn;
443 * For an example cache system see samba/source/libsmb/libsmb_cache.c
444 * Cache subsystem functions follow.
447 /** server cache addition
449 smbc_add_cached_srv_fn add_cached_srv_fn;
451 /** server cache lookup
453 smbc_get_cached_srv_fn get_cached_srv_fn;
455 /** server cache removal
457 smbc_remove_cached_srv_fn remove_cached_srv_fn;
459 /** server cache purging, try to remove all cached servers (disconnect)
461 smbc_purge_cached_fn purge_cached_fn;
465 /** Space to store private data of the server cache.
467 struct smbc_server_cache * server_cache;
470 * do _NOT_ touch this from your program !
472 struct smbc_internal_data * internal;
477 /* Flags for SMBCCTX->flags */
478 #define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
479 #define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
480 #define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */
481 #define SMBCCTX_FLAG_CTXVER (1 << 3 ) /* internal flag used to define _SMBCCTX version */
484 * Create a new SBMCCTX (a context).
486 * Must be called before the context is passed to smbc_context_init()
488 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
489 * - ENOMEM Out of memory
491 * @see smbc_free_context(), smbc_init_context()
493 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
498 SMBCCTX * smbc_new_context(void);
504 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
506 * The context will be deleted if possible.
508 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
510 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
513 * @return Returns 0 on succes. Returns 1 on failure with errno set:
514 * - EBUSY Server connections are still used, Files are open or cache
515 * could not be purged
516 * - EBADF context == NULL
518 * @see smbc_new_context()
520 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
521 * just before exit()'ing. When shutdown_ctx is 0, this function can be
522 * use in periodical cleanup functions for example.
527 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
533 * Initialize a SBMCCTX (a context).
535 * Must be called before using any SMBCCTX API function
537 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
539 * @return A pointer to the given SMBCCTX on success, NULL on error with errno set:
540 * - EBADF NULL context given
541 * - ENOMEM Out of memory
542 * - ENOENT The smb.conf file would not load
544 * @see smbc_new_context()
546 * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe,
547 * but it might leak memory on smbc_context_init() failure. Avoid this.
548 * You'll have to call smbc_free_context() yourself on failure.
553 SMBCCTX * smbc_init_context(SMBCCTX * context);
559 * Initialize the samba client library.
561 * Must be called before using any of the smbclient API function
563 * @param fn The function that will be called to obtaion
564 * authentication credentials.
566 * @param debug Allows caller to set the debug level. Can be
567 * changed in smb.conf file. Allows caller to set
568 * debugging if no smb.conf.
570 * @return 0 on success, < 0 on error with errno set:
571 * - ENOMEM Out of memory
572 * - ENOENT The smb.conf file would not load
579 int smbc_init(smbc_get_auth_data_fn fn, int debug);
585 * Set or retrieve the compatibility library's context pointer
587 * @param context New context to use, or NULL. If a new context is provided,
588 * it must have allocated with smbc_new_context() and
589 * initialized with smbc_init_context(), followed, optionally,
590 * by some manual changes to some of the non-internal fields.
592 * @return The old context.
594 * @see smbc_new_context(), smbc_init_context(), smbc_init()
596 * @note This function may be called prior to smbc_init() to force
597 * use of the next context without any internal calls to
598 * smbc_new_context() or smbc_init_context(). It may also
599 * be called after smbc_init() has already called those two
600 * functions, to replace the existing context with a new one.
601 * Care should be taken, in this latter case, to ensure that
602 * the server cache and any data allocated by the
603 * authentication functions have been freed, if necessary.
609 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
615 * Open a file on an SMB server.
617 * @param furl The smb url of the file to be opened.
619 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
620 * request opening the file read-only,write-only
621 * or read/write. flags may also be bitwise-or'd with
622 * one or more of the following:
623 * O_CREAT - If the file does not exist it will be
625 * O_EXCL - When used with O_CREAT, if the file
626 * already exists it is an error and the open will
628 * O_TRUNC - If the file already exists it will be
630 * O_APPEND The file is opened in append mode
632 * @param mode mode specifies the permissions to use if a new
633 * file is created. It is modified by the
634 * process's umask in the usual way: the permissions
635 * of the created file are (mode & ~umask)
637 * Not currently use, but there for future use.
638 * We will map this to SYSTEM, HIDDEN, etc bits
639 * that reverses the mapping that smbc_fstat does.
641 * @return Valid file handle, < 0 on error with errno set:
642 * - ENOMEM Out of memory
643 * - EINVAL if an invalid parameter passed, like no
644 * file, or smbc_init not called.
645 * - EEXIST pathname already exists and O_CREAT and
647 * - EISDIR pathname refers to a directory and
648 * the access requested involved writing.
649 * - EACCES The requested access to the file is not
651 * - ENODEV The requested share does not exist
652 * - ENOTDIR A file on the path is not a directory
653 * - ENOENT A directory component in pathname does
658 * @note This call uses an underlying routine that may create
659 * a new connection to the server specified in the URL.
660 * If the credentials supplied in the URL, or via the
661 * auth_fn in the smbc_init call, fail, this call will
662 * try again with an empty username and password. This
663 * often gets mapped to the guest account on some machines.
668 int smbc_open(const char *furl, int flags, mode_t mode);
674 * Create a file on an SMB server.
676 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
678 * @param furl The smb url of the file to be created
680 * @param mode mode specifies the permissions to use if a new
681 * file is created. It is modified by the
682 * process's umask in the usual way: the permissions
683 * of the created file are (mode & ~umask)
685 * NOTE, the above is not true. We are dealing with
686 * an SMB server, which has no concept of a umask!
688 * @return Valid file handle, < 0 on error with errno set:
689 * - ENOMEM Out of memory
690 * - EINVAL if an invalid parameter passed, like no
691 * file, or smbc_init not called.
692 * - EEXIST pathname already exists and O_CREAT and
694 * - EISDIR pathname refers to a directory and
695 * the access requested involved writing.
696 * - EACCES The requested access to the file is not
698 * - ENOENT A directory component in pathname does
700 * - ENODEV The requested share does not exist.
707 int smbc_creat(const char *furl, mode_t mode);
713 * Read from a file using an opened file handle.
715 * @param fd Open file handle from smbc_open() or smbc_creat()
717 * @param buf Pointer to buffer to recieve read data
719 * @param bufsize Size of buf in bytes
721 * @return Number of bytes read, < 0 on error with errno set:
722 * - EISDIR fd refers to a directory
723 * - EBADF fd is not a valid file descriptor or
724 * is not open for reading.
725 * - EINVAL fd is attached to an object which is
726 * unsuitable for reading, or no buffer passed or
727 * smbc_init not called.
729 * @see smbc_open(), smbc_write()
735 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
741 * Write to a file using an opened file handle.
743 * @param fd Open file handle from smbc_open() or smbc_creat()
745 * @param buf Pointer to buffer to recieve read data
747 * @param bufsize Size of buf in bytes
749 * @return Number of bytes written, < 0 on error with errno set:
750 * - EISDIR fd refers to a directory.
751 * - EBADF fd is not a valid file descriptor or
752 * is not open for reading.
753 * - EINVAL fd is attached to an object which is
754 * unsuitable for reading, or no buffer passed or
755 * smbc_init not called.
757 * @see smbc_open(), smbc_read()
763 ssize_t smbc_write(int fd, void *buf, size_t bufsize);
769 * Seek to a specific location in a file.
771 * @param fd Open file handle from smbc_open() or smbc_creat()
773 * @param offset Offset in bytes from whence
775 * @param whence A location in the file:
776 * - SEEK_SET The offset is set to offset bytes from
777 * the beginning of the file
778 * - SEEK_CUR The offset is set to current location
780 * - SEEK_END The offset is set to the size of the
781 * file plus offset bytes.
783 * @return Upon successful completion, lseek returns the
784 * resulting offset location as measured in bytes
785 * from the beginning of the file. Otherwise, a value
786 * of (off_t)-1 is returned and errno is set to
787 * indicate the error:
788 * - EBADF Fildes is not an open file descriptor.
789 * - EINVAL Whence is not a proper value or smbc_init
792 * @todo Are all the whence values really supported?
794 * @todo Are errno values complete and correct?
799 off_t smbc_lseek(int fd, off_t offset, int whence);
805 * Close an open file handle.
807 * @param fd The file handle to close
809 * @return 0 on success, < 0 on error with errno set:
810 * - EBADF fd isn't a valid open file descriptor
811 * - EINVAL smbc_init() failed or has not been called
813 * @see smbc_open(), smbc_creat()
818 int smbc_close(int fd);
823 /**@ingroup directory
824 * Unlink (delete) a file or directory.
826 * @param furl The smb url of the file to delete
828 * @return 0 on success, < 0 on error with errno set:
829 * - EACCES or EPERM Write access to the directory
830 * containing pathname is not allowed or one
831 * of the directories in pathname did not allow
832 * search (execute) permission
833 * - ENOENT A directory component in pathname does
835 * - EINVAL NULL was passed in the file param or
836 * smbc_init not called.
837 * - EACCES You do not have access to the file
838 * - ENOMEM Insufficient kernel memory was available
842 * @todo Are errno values complete and correct?
847 int smbc_unlink(const char *furl);
852 /**@ingroup directory
853 * Rename or move a file or directory.
855 * @param ourl The original smb url (source url) of file or
856 * directory to be moved
858 * @param nurl The new smb url (destination url) of the file
859 * or directory after the move. Currently nurl must
860 * be on the same share as ourl.
862 * @return 0 on success, < 0 on error with errno set:
863 * - EISDIR nurl is an existing directory, but ourl is
865 * - EEXIST nurl is a non-empty directory,
866 * i.e., contains entries other than "." and ".."
867 * - EINVAL The new url contained a path prefix
868 * of the old, or, more generally, an attempt was
869 * made to make a directory a subdirectory of itself
870 * or smbc_init not called.
871 * - ENOTDIR A component used as a directory in ourl
872 * or nurl path is not, in fact, a directory. Or,
873 * ourl is a directory, and newpath exists but is not
875 * - EACCES or EPERM Write access to the directory
876 * containing ourl or nurl is not allowed for the
877 * process's effective uid, or one of the
878 * directories in ourl or nurl did not allow search
879 * (execute) permission, or ourl was a directory
880 * and did not allow write permission.
881 * - ENOENT A directory component in ourl or nurl
883 * - EXDEV Rename across shares not supported.
884 * - ENOMEM Insufficient kernel memory was available.
885 * - EEXIST The target file, nurl, already exists.
888 * @todo Are we going to support copying when urls are not on the same
889 * share? I say no... NOTE. I agree for the moment.
895 int smbc_rename(const char *ourl, const char *nurl);
900 /**@ingroup directory
901 * Open a directory used to obtain directory entries.
903 * @param durl The smb url of the directory to open
905 * @return Valid directory handle. < 0 on error with errno set:
906 * - EACCES Permission denied.
907 * - EINVAL A NULL file/URL was passed, or the URL would
908 * not parse, or was of incorrect form or smbc_init not
910 * - ENOENT durl does not exist, or name is an
911 * - ENOMEM Insufficient memory to complete the
913 * - ENOTDIR name is not a directory.
914 * - EPERM the workgroup could not be found.
915 * - ENODEV the workgroup or server could not be found.
917 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
923 int smbc_opendir(const char *durl);
928 /**@ingroup directory
929 * Close a directory handle opened by smbc_opendir().
931 * @param dh Directory handle to close
933 * @return 0 on success, < 0 on error with errno set:
934 * - EBADF dh is an invalid directory handle
936 * @see smbc_opendir()
941 int smbc_closedir(int dh);
946 /**@ingroup directory
947 * Get multiple directory entries.
949 * smbc_getdents() reads as many dirent structures from the an open
950 * directory handle into a specified memory area as will fit.
952 * @param dh Valid directory as returned by smbc_opendir()
954 * @param dirp pointer to buffer that will receive the directory
957 * @param count The size of the dirp buffer in bytes
959 * @returns If any dirents returned, return will indicate the
960 * total size. If there were no more dirents available,
961 * 0 is returned. < 0 indicates an error.
962 * - EBADF Invalid directory handle
963 * - EINVAL Result buffer is too small or smbc_init
965 * - ENOENT No such directory.
966 * @see , smbc_dirent, smbc_readdir(), smbc_open()
968 * @todo Are errno values complete and correct?
970 * @todo Add example code so people know how to parse buffers.
975 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
980 /**@ingroup directory
981 * Get a single directory entry.
983 * @param dh Valid directory as returned by smbc_opendir()
985 * @return A pointer to a smbc_dirent structure, or NULL if an
986 * error occurs or end-of-directory is reached:
987 * - EBADF Invalid directory handle
988 * - EINVAL smbc_init() failed or has not been called
990 * @see smbc_dirent, smbc_getdents(), smbc_open()
995 struct smbc_dirent* smbc_readdir(unsigned int dh);
1000 /**@ingroup directory
1001 * Get the current directory offset.
1003 * smbc_telldir() may be used in conjunction with smbc_readdir() and
1006 * @param dh Valid directory as returned by smbc_opendir()
1008 * @return The current location in the directory stream or -1
1009 * if an error occur. The current location is not
1010 * an offset. Becuase of the implementation, it is a
1011 * handle that allows the library to find the entry
1013 * - EBADF dh is not a valid directory handle
1014 * - EINVAL smbc_init() failed or has not been called
1015 * - ENOTDIR if dh is not a directory
1017 * @see smbc_readdir()
1023 off_t smbc_telldir(int dh);
1028 /**@ingroup directory
1029 * lseek on directories.
1031 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1032 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1034 * @param fd Valid directory as returned by smbc_opendir()
1036 * @param offset The offset (as returned by smbc_telldir). Can be
1037 * NULL, in which case we will rewind
1039 * @return 0 on success, -1 on failure
1040 * - EBADF dh is not a valid directory handle
1041 * - ENOTDIR if dh is not a directory
1042 * - EINVAL offset did not refer to a valid dirent or
1043 * smbc_init not called.
1045 * @see smbc_telldir()
1048 * @todo In what does the reture and errno values mean?
1053 int smbc_lseekdir(int fd, off_t offset);
1058 /**@ingroup directory
1059 * Create a directory.
1061 * @param durl The url of the directory to create
1063 * @param mode Specifies the permissions to use. It is modified
1064 * by the process's umask in the usual way: the
1065 * permissions of the created file are (mode & ~umask).
1067 * @return 0 on success, < 0 on error with errno set:
1068 * - EEXIST directory url already exists
1069 * - EACCES The parent directory does not allow write
1070 * permission to the process, or one of the directories
1071 * - ENOENT A directory component in pathname does not
1073 * - EINVAL NULL durl passed or smbc_init not called.
1074 * - ENOMEM Insufficient memory was available.
1082 int smbc_mkdir(const char *durl, mode_t mode);
1087 /**@ingroup directory
1088 * Remove a directory.
1090 * @param durl The smb url of the directory to remove
1092 * @return 0 on success, < 0 on error with errno set:
1093 * - EACCES or EPERM Write access to the directory
1094 * containing pathname was not allowed.
1095 * - EINVAL durl is NULL or smbc_init not called.
1096 * - ENOENT A directory component in pathname does not
1098 * - ENOTEMPTY directory contains entries.
1099 * - ENOMEM Insufficient kernel memory was available.
1101 * @see smbc_mkdir(), smbc_unlink()
1103 * @todo Are errno values complete and correct?
1108 int smbc_rmdir(const char *durl);
1113 /**@ingroup attribute
1114 * Get information about a file or directory.
1116 * @param url The smb url to get information for
1118 * @param st pointer to a buffer that will be filled with
1119 * standard Unix struct stat information.
1121 * @return 0 on success, < 0 on error with errno set:
1122 * - ENOENT A component of the path file_name does not
1124 * - EINVAL a NULL url was passed or smbc_init not called.
1125 * - EACCES Permission denied.
1126 * - ENOMEM Out of memory
1127 * - ENOTDIR The target dir, url, is not a directory.
1135 int smbc_stat(const char *url, struct stat *st);
1140 /**@ingroup attribute
1141 * Get file information via an file descriptor.
1143 * @param fd Open file handle from smbc_open() or smbc_creat()
1145 * @param st pointer to a buffer that will be filled with
1146 * standard Unix struct stat information.
1148 * @return EBADF filedes is bad.
1149 * - EACCES Permission denied.
1150 * - EBADF fd is not a valid file descriptor
1151 * - EINVAL Problems occurred in the underlying routines
1152 * or smbc_init not called.
1153 * - ENOMEM Out of memory
1155 * @see smbc_stat(), Unix stat()
1161 int smbc_fstat(int fd, struct stat *st);
1166 /**@ingroup attribue
1167 * Change the ownership of a file or directory.
1169 * @param url The smb url of the file or directory to change
1172 * @param owner I have no idea?
1174 * @param group I have not idea?
1176 * @return 0 on success, < 0 on error with errno set:
1177 * - EPERM The effective UID does not match the owner
1178 * of the file, and is not zero; or the owner or group
1179 * were specified incorrectly.
1180 * - ENOENT The file does not exist.
1181 * - ENOMEM Insufficient was available.
1182 * - ENOENT file or directory does not exist
1184 * @todo Are we actually going to be able to implement this function
1186 * @todo How do we abstract owner and group uid and gid?
1192 int smbc_chown(const char *url, uid_t owner, gid_t group);
1197 /**@ingroup attribute
1198 * Change the permissions of a file.
1200 * @param url The smb url of the file or directory to change
1203 * @param mode The permissions to set:
1204 * - Put good explaination of permissions here!
1206 * @return 0 on success, < 0 on error with errno set:
1207 * - EPERM The effective UID does not match the owner
1208 * of the file, and is not zero
1209 * - ENOENT The file does not exist.
1210 * - ENOMEM Insufficient was available.
1211 * - ENOENT file or directory does not exist
1213 * @todo Actually implement this fuction?
1215 * @todo Are errno values complete and correct?
1220 int smbc_chmod(const char *url, mode_t mode);
1225 /**@ingroup attribute
1226 * Change the last modification time on a file
1228 * @param url The smb url of the file or directory to change
1229 * the modification time of
1231 * @param tbuf A timeval structure which contains the desired
1232 * modification time. NOTE: Only the tv_sec field is
1233 * used. The tv_usec (microseconds) portion is ignored.
1235 * @return 0 on success, < 0 on error with errno set:
1236 * - EINVAL The client library is not properly initialized
1237 * - EPERM Permission was denied.
1243 int smbc_utimes(const char *url, struct timeval *tbuf);
1249 /**@ingroup attribute
1250 * Change the last modification time on a file
1252 * @param url The smb url of the file or directory to change
1253 * the modification time of
1255 * @param utbuf A utimebuf structure which contains the desired
1256 * modification time. NOTE: Although the structure contains
1257 * an access time as well, the access time value is ignored.
1259 * @return 0 on success, < 0 on error with errno set:
1260 * - EINVAL The client library is not properly initialized
1261 * - ENOMEM No memory was available for internal needs
1262 * - EPERM Permission was denied.
1268 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1274 /**@ingroup attribute
1275 * Set extended attributes for a file. This is used for modifying a file's
1276 * security descriptor (i.e. owner, group, and access control list)
1278 * @param url The smb url of the file or directory to set extended
1281 * @param name The name of an attribute to be changed. Names are of
1282 * one of the following forms:
1284 * system.nt_sec_desc.<attribute name>
1285 * system.nt_sec_desc.*
1286 * system.nt_sec_desc.*+
1288 * where <attribute name> is one of:
1296 * acl+:<name or sid>
1298 * In the forms "system.nt_sec_desc.*" and
1299 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1300 * literal, i.e. the string is provided exactly as shown, and
1301 * the value parameter should contain a complete security
1302 * descriptor with name:value pairs separated by tabs,
1303 * commas, or newlines (not spaces!).
1305 * The plus sign ('+') indicates that SIDs should be mapped
1306 * to names. Without the plus sign, SIDs are not mapped;
1307 * rather they are simply converted to a string format.
1309 * @param value The value to be assigned to the specified attribute name.
1310 * This buffer should contain only the attribute value if the
1311 * name was of the "system.nt_sec_desc.<attribute_name>"
1312 * form. If the name was of the "system.nt_sec_desc.*" form
1313 * then a complete security descriptor, with name:value pairs
1314 * separated by tabs, commas, or newlines (not spaces!),
1315 * should be provided in this value buffer. A complete
1316 * security descriptor will contain one or more entries
1317 * selected from the following:
1319 * REVISION:<revision number>
1320 * OWNER:<sid or name>
1321 * GROUP:<sid or name>
1322 * ACL:<sid or name>:<type>/<flags>/<mask>
1324 * The revision of the ACL specifies the internal Windows NT
1325 * ACL revision for the security descriptor. If not specified
1326 * it defaults to 1. Using values other than 1 may cause
1327 * strange behaviour.
1329 * The owner and group specify the owner and group sids for
1330 * the object. If the attribute name (either '*+' with a
1331 * complete security descriptor, or individual 'owner+' or
1332 * 'group+' attribute names) ended with a plus sign, the
1333 * specified name is resolved to a SID value, using the
1334 * server on which the file or directory resides. Otherwise,
1335 * the value should be provided in SID-printable format as
1336 * S-1-x-y-z, and is used directly. The <sid or name>
1337 * associated with the ACL: attribute should be provided
1340 * @param size The number of the bytes of data in the value buffer
1342 * @param flags A bit-wise OR of zero or more of the following:
1343 * SMBC_XATTR_FLAG_CREATE -
1344 * fail if the named attribute already exists
1345 * SMBC_XATTR_FLAG_REPLACE -
1346 * fail if the attribute does not already exist
1348 * If neither flag is specified, the specified attributes
1349 * will be added or replace existing attributes of the same
1350 * name, as necessary.
1352 * @return 0 on success, < 0 on error with errno set:
1353 * - EINVAL The client library is not properly initialized
1354 * or one of the parameters is not of a correct
1356 * - ENOMEM No memory was available for internal needs
1357 * - EEXIST If the attribute already exists and the flag
1358 * SMBC_XATTR_FLAG_CREAT was specified
1359 * - ENOATTR If the attribute does not exist and the flag
1360 * SMBC_XATTR_FLAG_REPLACE was specified
1361 * - EPERM Permission was denied.
1362 * - ENOTSUP The referenced file system does not support
1363 * extended attributes
1365 * @note Attribute names are compared in a case-insensitive
1366 * fashion. All of the following are equivalent, although
1367 * the all-lower-case name is the preferred format:
1368 * system.nt_sec_desc.owner
1369 * SYSTEM.NT_SEC_DESC.OWNER
1370 * sYsTeM.nt_sEc_desc.owNER
1376 int smbc_setxattr(const char *url,
1385 /**@ingroup attribute
1386 * Set extended attributes for a file. This is used for modifying a file's
1387 * security descriptor (i.e. owner, group, and access control list). The
1388 * POSIX function which this maps to would act on a symbolic link rather than
1389 * acting on what the symbolic link points to, but with no symbolic links in
1390 * SMB file systems, this function is functionally identical to
1393 * @param url The smb url of the file or directory to set extended
1396 * @param name The name of an attribute to be changed. Names are of
1397 * one of the following forms:
1399 * system.nt_sec_desc.<attribute name>
1400 * system.nt_sec_desc.*
1401 * system.nt_sec_desc.*+
1403 * where <attribute name> is one of:
1411 * acl+:<name or sid>
1413 * In the forms "system.nt_sec_desc.*" and
1414 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1415 * literal, i.e. the string is provided exactly as shown, and
1416 * the value parameter should contain a complete security
1417 * descriptor with name:value pairs separated by tabs,
1418 * commas, or newlines (not spaces!).
1420 * The plus sign ('+') indicates that SIDs should be mapped
1421 * to names. Without the plus sign, SIDs are not mapped;
1422 * rather they are simply converted to a string format.
1424 * @param value The value to be assigned to the specified attribute name.
1425 * This buffer should contain only the attribute value if the
1426 * name was of the "system.nt_sec_desc.<attribute_name>"
1427 * form. If the name was of the "system.nt_sec_desc.*" form
1428 * then a complete security descriptor, with name:value pairs
1429 * separated by tabs, commas, or newlines (not spaces!),
1430 * should be provided in this value buffer. A complete
1431 * security descriptor will contain one or more entries
1432 * selected from the following:
1434 * REVISION:<revision number>
1435 * OWNER:<sid or name>
1436 * GROUP:<sid or name>
1437 * ACL:<sid or name>:<type>/<flags>/<mask>
1439 * The revision of the ACL specifies the internal Windows NT
1440 * ACL revision for the security descriptor. If not specified
1441 * it defaults to 1. Using values other than 1 may cause
1442 * strange behaviour.
1444 * The owner and group specify the owner and group sids for
1445 * the object. If the attribute name (either '*+' with a
1446 * complete security descriptor, or individual 'owner+' or
1447 * 'group+' attribute names) ended with a plus sign, the
1448 * specified name is resolved to a SID value, using the
1449 * server on which the file or directory resides. Otherwise,
1450 * the value should be provided in SID-printable format as
1451 * S-1-x-y-z, and is used directly. The <sid or name>
1452 * associated with the ACL: attribute should be provided
1455 * @param size The number of the bytes of data in the value buffer
1457 * @param flags A bit-wise OR of zero or more of the following:
1458 * SMBC_XATTR_FLAG_CREATE -
1459 * fail if the named attribute already exists
1460 * SMBC_XATTR_FLAG_REPLACE -
1461 * fail if the attribute does not already exist
1463 * If neither flag is specified, the specified attributes
1464 * will be added or replace existing attributes of the same
1465 * name, as necessary.
1467 * @return 0 on success, < 0 on error with errno set:
1468 * - EINVAL The client library is not properly initialized
1469 * or one of the parameters is not of a correct
1471 * - ENOMEM No memory was available for internal needs
1472 * - EEXIST If the attribute already exists and the flag
1473 * SMBC_XATTR_FLAG_CREAT was specified
1474 * - ENOATTR If the attribute does not exist and the flag
1475 * SMBC_XATTR_FLAG_REPLACE was specified
1476 * - EPERM Permission was denied.
1477 * - ENOTSUP The referenced file system does not support
1478 * extended attributes
1480 * @note Attribute names are compared in a case-insensitive
1481 * fashion. All of the following are equivalent, although
1482 * the all-lower-case name is the preferred format:
1483 * system.nt_sec_desc.owner
1484 * SYSTEM.NT_SEC_DESC.OWNER
1485 * sYsTeM.nt_sEc_desc.owNER
1491 int smbc_lsetxattr(const char *url,
1500 /**@ingroup attribute
1501 * Set extended attributes for a file. This is used for modifying a file's
1502 * security descriptor (i.e. owner, group, and access control list)
1504 * @param fd A file descriptor associated with an open file (as
1505 * previously returned by smbc_open(), to get extended
1508 * @param name The name of an attribute to be changed. Names are of
1509 * one of the following forms:
1511 * system.nt_sec_desc.<attribute name>
1512 * system.nt_sec_desc.*
1513 * system.nt_sec_desc.*+
1515 * where <attribute name> is one of:
1523 * acl+:<name or sid>
1525 * In the forms "system.nt_sec_desc.*" and
1526 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1527 * literal, i.e. the string is provided exactly as shown, and
1528 * the value parameter should contain a complete security
1529 * descriptor with name:value pairs separated by tabs,
1530 * commas, or newlines (not spaces!).
1532 * The plus sign ('+') indicates that SIDs should be mapped
1533 * to names. Without the plus sign, SIDs are not mapped;
1534 * rather they are simply converted to a string format.
1536 * @param value The value to be assigned to the specified attribute name.
1537 * This buffer should contain only the attribute value if the
1538 * name was of the "system.nt_sec_desc.<attribute_name>"
1539 * form. If the name was of the "system.nt_sec_desc.*" form
1540 * then a complete security descriptor, with name:value pairs
1541 * separated by tabs, commas, or newlines (not spaces!),
1542 * should be provided in this value buffer. A complete
1543 * security descriptor will contain one or more entries
1544 * selected from the following:
1546 * REVISION:<revision number>
1547 * OWNER:<sid or name>
1548 * GROUP:<sid or name>
1549 * ACL:<sid or name>:<type>/<flags>/<mask>
1551 * The revision of the ACL specifies the internal Windows NT
1552 * ACL revision for the security descriptor. If not specified
1553 * it defaults to 1. Using values other than 1 may cause
1554 * strange behaviour.
1556 * The owner and group specify the owner and group sids for
1557 * the object. If the attribute name (either '*+' with a
1558 * complete security descriptor, or individual 'owner+' or
1559 * 'group+' attribute names) ended with a plus sign, the
1560 * specified name is resolved to a SID value, using the
1561 * server on which the file or directory resides. Otherwise,
1562 * the value should be provided in SID-printable format as
1563 * S-1-x-y-z, and is used directly. The <sid or name>
1564 * associated with the ACL: attribute should be provided
1567 * @param size The number of the bytes of data in the value buffer
1569 * @param flags A bit-wise OR of zero or more of the following:
1570 * SMBC_XATTR_FLAG_CREATE -
1571 * fail if the named attribute already exists
1572 * SMBC_XATTR_FLAG_REPLACE -
1573 * fail if the attribute does not already exist
1575 * If neither flag is specified, the specified attributes
1576 * will be added or replace existing attributes of the same
1577 * name, as necessary.
1579 * @return 0 on success, < 0 on error with errno set:
1580 * - EINVAL The client library is not properly initialized
1581 * or one of the parameters is not of a correct
1583 * - ENOMEM No memory was available for internal needs
1584 * - EEXIST If the attribute already exists and the flag
1585 * SMBC_XATTR_FLAG_CREAT was specified
1586 * - ENOATTR If the attribute does not exist and the flag
1587 * SMBC_XATTR_FLAG_REPLACE was specified
1588 * - EPERM Permission was denied.
1589 * - ENOTSUP The referenced file system does not support
1590 * extended attributes
1592 * @note Attribute names are compared in a case-insensitive
1593 * fashion. All of the following are equivalent, although
1594 * the all-lower-case name is the preferred format:
1595 * system.nt_sec_desc.owner
1596 * SYSTEM.NT_SEC_DESC.OWNER
1597 * sYsTeM.nt_sEc_desc.owNER
1603 int smbc_fsetxattr(int fd,
1612 /**@ingroup attribute
1613 * Get extended attributes for a file.
1615 * @param url The smb url of the file or directory to get extended
1618 * @param name The name of an attribute to be retrieved. Names are of
1619 * one of the following forms:
1621 * system.nt_sec_desc.<attribute name>
1622 * system.nt_sec_desc.*
1623 * system.nt_sec_desc.*+
1625 * where <attribute name> is one of:
1633 * acl+:<name or sid>
1635 * In the forms "system.nt_sec_desc.*" and
1636 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1637 * literal, i.e. the string is provided exactly as shown, and
1638 * the value parameter will return a complete security
1639 * descriptor with name:value pairs separated by tabs,
1640 * commas, or newlines (not spaces!).
1642 * The plus sign ('+') indicates that SIDs should be mapped
1643 * to names. Without the plus sign, SIDs are not mapped;
1644 * rather they are simply converted to a string format.
1646 * @param value A pointer to a buffer in which the value of the specified
1647 * attribute will be placed (unless size is zero).
1649 * @param size The size of the buffer pointed to by value. This parameter
1650 * may also be zero, in which case the size of the buffer
1651 * required to hold the attribute value will be returned,
1652 * but nothing will be placed into the value buffer.
1654 * @return 0 on success, < 0 on error with errno set:
1655 * - EINVAL The client library is not properly initialized
1656 * or one of the parameters is not of a correct
1658 * - ENOMEM No memory was available for internal needs
1659 * - EEXIST If the attribute already exists and the flag
1660 * SMBC_XATTR_FLAG_CREAT was specified
1661 * - ENOATTR If the attribute does not exist and the flag
1662 * SMBC_XATTR_FLAG_REPLACE was specified
1663 * - EPERM Permission was denied.
1664 * - ENOTSUP The referenced file system does not support
1665 * extended attributes
1671 int smbc_getxattr(const char *url,
1679 /**@ingroup attribute
1680 * Get extended attributes for a file. The POSIX function which this maps to
1681 * would act on a symbolic link rather than acting on what the symbolic link
1682 * points to, but with no symbolic links in SMB file systems, this function
1683 * is functionally identical to smbc_getxattr().
1685 * @param url The smb url of the file or directory to get extended
1688 * @param name The name of an attribute to be retrieved. Names are of
1689 * one of the following forms:
1691 * system.nt_sec_desc.<attribute name>
1692 * system.nt_sec_desc.*
1693 * system.nt_sec_desc.*+
1695 * where <attribute name> is one of:
1703 * acl+:<name or sid>
1705 * In the forms "system.nt_sec_desc.*" and
1706 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1707 * literal, i.e. the string is provided exactly as shown, and
1708 * the value parameter will return a complete security
1709 * descriptor with name:value pairs separated by tabs,
1710 * commas, or newlines (not spaces!).
1712 * The plus sign ('+') indicates that SIDs should be mapped
1713 * to names. Without the plus sign, SIDs are not mapped;
1714 * rather they are simply converted to a string format.
1716 * @param value A pointer to a buffer in which the value of the specified
1717 * attribute will be placed (unless size is zero).
1719 * @param size The size of the buffer pointed to by value. This parameter
1720 * may also be zero, in which case the size of the buffer
1721 * required to hold the attribute value will be returned,
1722 * but nothing will be placed into the value buffer.
1724 * @return 0 on success, < 0 on error with errno set:
1725 * - EINVAL The client library is not properly initialized
1726 * or one of the parameters is not of a correct
1728 * - ENOMEM No memory was available for internal needs
1729 * - EEXIST If the attribute already exists and the flag
1730 * SMBC_XATTR_FLAG_CREAT was specified
1731 * - ENOATTR If the attribute does not exist and the flag
1732 * SMBC_XATTR_FLAG_REPLACE was specified
1733 * - EPERM Permission was denied.
1734 * - ENOTSUP The referenced file system does not support
1735 * extended attributes
1741 int smbc_lgetxattr(const char *url,
1749 /**@ingroup attribute
1750 * Get extended attributes for a file.
1752 * @param fd A file descriptor associated with an open file (as
1753 * previously returned by smbc_open(), to get extended
1756 * @param name The name of an attribute to be retrieved. Names are of
1757 * one of the following forms:
1759 * system.nt_sec_desc.<attribute name>
1760 * system.nt_sec_desc.*
1761 * system.nt_sec_desc.*+
1763 * where <attribute name> is one of:
1771 * acl+:<name or sid>
1773 * In the forms "system.nt_sec_desc.*" and
1774 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1775 * literal, i.e. the string is provided exactly as shown, and
1776 * the value parameter will return a complete security
1777 * descriptor with name:value pairs separated by tabs,
1778 * commas, or newlines (not spaces!).
1780 * The plus sign ('+') indicates that SIDs should be mapped
1781 * to names. Without the plus sign, SIDs are not mapped;
1782 * rather they are simply converted to a string format.
1784 * @param value A pointer to a buffer in which the value of the specified
1785 * attribute will be placed (unless size is zero).
1787 * @param size The size of the buffer pointed to by value. This parameter
1788 * may also be zero, in which case the size of the buffer
1789 * required to hold the attribute value will be returned,
1790 * but nothing will be placed into the value buffer.
1792 * @return 0 on success, < 0 on error with errno set:
1793 * - EINVAL The client library is not properly initialized
1794 * or one of the parameters is not of a correct
1796 * - ENOMEM No memory was available for internal needs
1797 * - EEXIST If the attribute already exists and the flag
1798 * SMBC_XATTR_FLAG_CREAT was specified
1799 * - ENOATTR If the attribute does not exist and the flag
1800 * SMBC_XATTR_FLAG_REPLACE was specified
1801 * - EPERM Permission was denied.
1802 * - ENOTSUP The referenced file system does not support
1803 * extended attributes
1809 int smbc_fgetxattr(int fd,
1817 /**@ingroup attribute
1818 * Remove extended attributes for a file. This is used for modifying a file's
1819 * security descriptor (i.e. owner, group, and access control list)
1821 * @param url The smb url of the file or directory to remove the extended
1824 * @param name The name of an attribute to be removed. Names are of
1825 * one of the following forms:
1827 * system.nt_sec_desc.<attribute name>
1828 * system.nt_sec_desc.*
1829 * system.nt_sec_desc.*+
1831 * where <attribute name> is one of:
1839 * acl+:<name or sid>
1841 * In the forms "system.nt_sec_desc.*" and
1842 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1843 * literal, i.e. the string is provided exactly as shown, and
1844 * the value parameter will return a complete security
1845 * descriptor with name:value pairs separated by tabs,
1846 * commas, or newlines (not spaces!).
1848 * The plus sign ('+') indicates that SIDs should be mapped
1849 * to names. Without the plus sign, SIDs are not mapped;
1850 * rather they are simply converted to a string format.
1852 * @return 0 on success, < 0 on error with errno set:
1853 * - EINVAL The client library is not properly initialized
1854 * - ENOMEM No memory was available for internal needs
1855 * - EPERM Permission was denied.
1856 * - ENOTSUP The referenced file system does not support
1857 * extended attributes
1863 int smbc_removexattr(const char *url,
1869 /**@ingroup attribute
1870 * Remove extended attributes for a file. This is used for modifying a file's
1871 * security descriptor (i.e. owner, group, and access control list) The POSIX
1872 * function which this maps to would act on a symbolic link rather than acting
1873 * on what the symbolic link points to, but with no symbolic links in SMB file
1874 * systems, this function is functionally identical to smbc_removexattr().
1876 * @param url The smb url of the file or directory to remove the extended
1879 * @param name The name of an attribute to be removed. Names are of
1880 * one of the following forms:
1882 * system.nt_sec_desc.<attribute name>
1883 * system.nt_sec_desc.*
1884 * system.nt_sec_desc.*+
1886 * where <attribute name> is one of:
1894 * acl+:<name or sid>
1896 * In the forms "system.nt_sec_desc.*" and
1897 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1898 * literal, i.e. the string is provided exactly as shown, and
1899 * the value parameter will return a complete security
1900 * descriptor with name:value pairs separated by tabs,
1901 * commas, or newlines (not spaces!).
1903 * The plus sign ('+') indicates that SIDs should be mapped
1904 * to names. Without the plus sign, SIDs are not mapped;
1905 * rather they are simply converted to a string format.
1907 * @return 0 on success, < 0 on error with errno set:
1908 * - EINVAL The client library is not properly initialized
1909 * - ENOMEM No memory was available for internal needs
1910 * - EPERM Permission was denied.
1911 * - ENOTSUP The referenced file system does not support
1912 * extended attributes
1918 int smbc_lremovexattr(const char *url,
1924 /**@ingroup attribute
1925 * Remove extended attributes for a file. This is used for modifying a file's
1926 * security descriptor (i.e. owner, group, and access control list)
1928 * @param fd A file descriptor associated with an open file (as
1929 * previously returned by smbc_open(), to get extended
1932 * @param name The name of an attribute to be removed. Names are of
1933 * one of the following forms:
1935 * system.nt_sec_desc.<attribute name>
1936 * system.nt_sec_desc.*
1937 * system.nt_sec_desc.*+
1939 * where <attribute name> is one of:
1947 * acl+:<name or sid>
1949 * In the forms "system.nt_sec_desc.*" and
1950 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1951 * literal, i.e. the string is provided exactly as shown, and
1952 * the value parameter will return a complete security
1953 * descriptor with name:value pairs separated by tabs,
1954 * commas, or newlines (not spaces!).
1956 * The plus sign ('+') indicates that SIDs should be mapped
1957 * to names. Without the plus sign, SIDs are not mapped;
1958 * rather they are simply converted to a string format.
1960 * @return 0 on success, < 0 on error with errno set:
1961 * - EINVAL The client library is not properly initialized
1962 * - ENOMEM No memory was available for internal needs
1963 * - EPERM Permission was denied.
1964 * - ENOTSUP The referenced file system does not support
1965 * extended attributes
1971 int smbc_fremovexattr(int fd,
1977 /**@ingroup attribute
1978 * List the supported extended attribute names associated with a file
1980 * @param url The smb url of the file or directory to list the extended
1983 * @param list A pointer to a buffer in which the list of attributes for
1984 * the specified file or directory will be placed (unless
1987 * @param size The size of the buffer pointed to by list. This parameter
1988 * may also be zero, in which case the size of the buffer
1989 * required to hold all of the attribute names will be
1990 * returned, but nothing will be placed into the list buffer.
1992 * @return 0 on success, < 0 on error with errno set:
1993 * - EINVAL The client library is not properly initialized
1994 * - ENOMEM No memory was available for internal needs
1995 * - EPERM Permission was denied.
1996 * - ENOTSUP The referenced file system does not support
1997 * extended attributes
1999 * @note This function always returns all attribute names supported
2000 * by NT file systems, regardless of wether the referenced
2001 * file system supports extended attributes (e.g. a Windows
2002 * 2000 machine supports extended attributes if NTFS is used,
2003 * but not if FAT is used, and Windows 98 doesn't support
2004 * extended attributes at all. Whether this is a feature or
2005 * a bug is yet to be decided.
2010 int smbc_listxattr(const char *url,
2017 /**@ingroup attribute
2018 * List the supported extended attribute names associated with a file The
2019 * POSIX function which this maps to would act on a symbolic link rather than
2020 * acting on what the symbolic link points to, but with no symbolic links in
2021 * SMB file systems, this function is functionally identical to
2024 * @param url The smb url of the file or directory to list the extended
2027 * @param list A pointer to a buffer in which the list of attributes for
2028 * the specified file or directory will be placed (unless
2031 * @param size The size of the buffer pointed to by list. This parameter
2032 * may also be zero, in which case the size of the buffer
2033 * required to hold all of the attribute names will be
2034 * returned, but nothing will be placed into the list buffer.
2036 * @return 0 on success, < 0 on error with errno set:
2037 * - EINVAL The client library is not properly initialized
2038 * - ENOMEM No memory was available for internal needs
2039 * - EPERM Permission was denied.
2040 * - ENOTSUP The referenced file system does not support
2041 * extended attributes
2043 * @note This function always returns all attribute names supported
2044 * by NT file systems, regardless of wether the referenced
2045 * file system supports extended attributes (e.g. a Windows
2046 * 2000 machine supports extended attributes if NTFS is used,
2047 * but not if FAT is used, and Windows 98 doesn't support
2048 * extended attributes at all. Whether this is a feature or
2049 * a bug is yet to be decided.
2054 int smbc_llistxattr(const char *url,
2061 /**@ingroup attribute
2062 * List the supported extended attribute names associated with a file
2064 * @param fd A file descriptor associated with an open file (as
2065 * previously returned by smbc_open(), to get extended
2068 * @param list A pointer to a buffer in which the list of attributes for
2069 * the specified file or directory will be placed (unless
2072 * @param size The size of the buffer pointed to by list. This parameter
2073 * may also be zero, in which case the size of the buffer
2074 * required to hold all of the attribute names will be
2075 * returned, but nothing will be placed into the list buffer.
2077 * @return 0 on success, < 0 on error with errno set:
2078 * - EINVAL The client library is not properly initialized
2079 * - ENOMEM No memory was available for internal needs
2080 * - EPERM Permission was denied.
2081 * - ENOTSUP The referenced file system does not support
2082 * extended attributes
2084 * @note This function always returns all attribute names supported
2085 * by NT file systems, regardless of wether the referenced
2086 * file system supports extended attributes (e.g. a Windows
2087 * 2000 machine supports extended attributes if NTFS is used,
2088 * but not if FAT is used, and Windows 98 doesn't support
2089 * extended attributes at all. Whether this is a feature or
2090 * a bug is yet to be decided.
2095 int smbc_flistxattr(int fd,
2103 * Print a file given the name in fname. It would be a URL ...
2105 * @param fname The URL of a file on a remote SMB server that the
2106 * caller wants printed
2108 * @param printq The URL of the print share to print the file to.
2110 * @return 0 on success, < 0 on error with errno set:
2112 * - EINVAL fname or printq was NULL or smbc_init not
2114 * and errors returned by smbc_open
2120 int smbc_print_file(const char *fname, const char *printq);
2126 * Open a print file that can be written to by other calls. This simply
2127 * does an smbc_open call after checking if there is a file name on the
2128 * URI. If not, a temporary name is added ...
2130 * @param fname The URL of the print share to print to?
2132 * @returns A file handle for the print file if successful.
2133 * Returns -1 if an error ocurred and errno has the values
2134 * - EINVAL fname was NULL or smbc_init not called.
2135 * - all errors returned by smbc_open
2141 int smbc_open_print_job(const char *fname);
2147 * List the print jobs on a print share, for the moment, pass a callback
2149 * @param purl The url of the print share to list the jobs of
2151 * @param fn Callback function the receives printjob info
2153 * @return 0 on success, < 0 on error with errno set:
2154 * - EINVAL fname was NULL or smbc_init not called
2160 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2166 * Delete a print job
2168 * @param purl Url of the print share
2170 * @param id The id of the job to delete
2172 * @return 0 on success, < 0 on error with errno set:
2173 * - EINVAL fname was NULL or smbc_init not called
2175 * @todo what errno values are possible here?
2180 int smbc_unlink_print_job(const char *purl, int id);
2185 /**@ingroup callback
2186 * Remove a server from the cached server list it's unused.
2188 * @param context pointer to smb context
2190 * @param srv pointer to server to remove
2192 * @return On success, 0 is returned. 1 is returned if the server could not
2193 * be removed. Also useable outside libsmbclient.
2198 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2203 /**@ingroup directory
2204 * Convert strings of %xx to their single character equivalent.
2206 * @param dest A pointer to a buffer in which the resulting decoded
2207 * string should be placed. This may be a pointer to the
2208 * same buffer as src_segment.
2210 * @param src A pointer to the buffer containing the URL to be decoded.
2211 * Any %xx sequences herein are converted to their single
2212 * character equivalent. Each 'x' must be a valid hexadecimal
2213 * digit, or that % sequence is left undecoded.
2215 * @param max_dest_len
2216 * The size of the buffer pointed to by dest_segment.
2218 * @return The number of % sequences which could not be converted
2219 * due to lack of two following hexadecimal digits.
2225 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
2232 * Convert any characters not specifically allowed in a URL into their %xx
2235 * @param dest A pointer to a buffer in which the resulting encoded
2236 * string should be placed. Unlike smbc_urldecode(), this
2237 * must be a buffer unique from src.
2239 * @param src A pointer to the buffer containing the string to be encoded.
2240 * Any character not specifically allowed in a URL is converted
2241 * into its hexadecimal value and encoded as %xx.
2243 * @param max_dest_len
2244 * The size of the buffer pointed to by dest_segment.
2246 * @returns The remaining buffer length.
2252 smbc_urlencode(char * dest, char * src, int max_dest_len);
2258 /**@ingroup directory
2259 * Return the version of the linked Samba code, and thus the version of the
2260 * libsmbclient code.
2262 * @return The version string.
2274 #endif /* SMBCLIENT_H_INCLUDED */