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
33 /*-------------------------------------------------------------------*/
34 /* The following are special comments to instruct DOXYGEN (automated
37 /** \defgroup libsmbclient
39 /** \defgroup structure Data Structures Type and Constants
40 * \ingroup libsmbclient
41 * Data structures, types, and constants
43 /** \defgroup callback Callback function types
44 * \ingroup libsmbclient
47 /** \defgroup file File Functions
48 * \ingroup libsmbclient
49 * Functions used to access individual file contents
51 /** \defgroup directory Directory Functions
52 * \ingroup libsmbclient
53 * Functions used to access directory entries
55 /** \defgroup attribute Attributes Functions
56 * \ingroup libsmbclient
57 * Functions used to view or change file and directory attributes
59 /** \defgroup print Print Functions
60 * \ingroup libsmbclient
61 * Functions used to access printing functionality
63 /** \defgroup misc Miscellaneous Functions
64 * \ingroup libsmbclient
65 * Functions that don't fit in to other categories
67 /*-------------------------------------------------------------------*/
69 /* Make sure we have the following includes for now ... */
70 #include <sys/types.h>
75 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
77 #define SMBC_WORKGROUP 1
79 #define SMBC_FILE_SHARE 3
80 #define SMBC_PRINTER_SHARE 4
81 #define SMBC_COMMS_SHARE 5
82 #define SMBC_IPC_SHARE 6
88 * Structure that represents a directory entry.
103 unsigned int smbc_type
;
105 /** Length of this smbc_dirent in bytes
108 /** The length of the comment string in bytes (includes null
111 unsigned int commentlen
;
112 /** Points to the null terminated comment string
115 /** The length of the name string in bytes (includes null
118 unsigned int namelen
;
119 /** Points to the null terminated name string
125 * Flags for smbc_setxattr()
126 * Specify a bitwise OR of these, or 0 to add or replace as necessary
128 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
129 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
133 * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
134 * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
135 * "system.*") is specified.
137 #define SMBC_DOS_MODE_READONLY 0x01
138 #define SMBC_DOS_MODE_HIDDEN 0x02
139 #define SMBC_DOS_MODE_SYSTEM 0x04
140 #define SMBC_DOS_MODE_VOLUME_ID 0x08
141 #define SMBC_DOS_MODE_DIRECTORY 0x10
142 #define SMBC_DOS_MODE_ARCHIVE 0x20
146 # define ENOATTR ENOENT /* No such attribute */
152 /**@ingroup structure
153 * Structure that represents a print job.
157 struct print_job_info
159 /** numeric ID of the print job
163 /** represents print job priority (lower numbers mean higher priority)
165 unsigned short priority
;
167 /** Size of the print job
171 /** Name of the user that owns the print job
175 /** Name of the print job. This will have no name if an anonymous print
176 * file was opened. Ie smb://server/printer
180 /** Time the print job was spooled
184 #endif /* _CLIENT_H */
187 /**@ingroup structure
190 typedef struct _SMBCSRV SMBCSRV
;
192 /**@ingroup structure
193 * File or directory handle
195 typedef struct _SMBCFILE SMBCFILE
;
197 /**@ingroup structure
198 * File or directory handle
200 typedef struct _SMBCCTX SMBCCTX
;
207 * Authentication callback function type.
209 * Type for the the authentication function called by the library to
210 * obtain authentication credentals
212 * @param srv Server being authenticated to
214 * @param shr Share being authenticated to
216 * @param wg Pointer to buffer containing a "hint" for the
217 * workgroup to be authenticated. Should be filled in
218 * with the correct workgroup if the hint is wrong.
220 * @param wglen The size of the workgroup buffer in bytes
222 * @param un Pointer to buffer containing a "hint" for the
223 * user name to be use for authentication. Should be
224 * filled in with the correct workgroup if the hint is
227 * @param unlen The size of the username buffer in bytes
229 * @param pw Pointer to buffer containing to which password
232 * @param pwlen The size of the password buffer in bytes
235 typedef void (*smbc_get_auth_data_fn
)(const char *srv
,
239 char *pw
, int pwlen
);
243 * Print job info callback function type.
245 * @param i pointer to print job information structure
248 typedef void (*smbc_list_print_job_fn
)(struct print_job_info
*i
);
252 * Check if a server is still good
254 * @param c pointer to smb context
256 * @param srv pointer to server to check
258 * @return 0 when connection is good. 1 on error.
261 typedef int (*smbc_check_server_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
264 * Remove a server if unused
266 * @param c pointer to smb context
268 * @param srv pointer to server to remove
270 * @return 0 on success. 1 on failure.
273 typedef int (*smbc_remove_unused_server_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
277 * Add a server to the cache system
279 * @param c pointer to smb context
281 * @param srv pointer to server to add
283 * @param server server name
285 * @param share share name
287 * @param workgroup workgroup used to connect
289 * @param username username used to connect
291 * @return 0 on success. 1 on failure.
294 typedef int (*smbc_add_cached_srv_fn
) (SMBCCTX
* c
, SMBCSRV
*srv
,
295 const char * server
, const char * share
,
296 const char * workgroup
, const char * username
);
299 * Look up a server in the cache system
301 * @param c pointer to smb context
303 * @param server server name to match
305 * @param share share name to match
307 * @param workgroup workgroup to match
309 * @param username username to match
311 * @return pointer to SMBCSRV on success. NULL on failure.
314 typedef SMBCSRV
* (*smbc_get_cached_srv_fn
) (SMBCCTX
* c
, const char * server
,
315 const char * share
, const char * workgroup
,
316 const char * username
);
319 * Check if a server is still good
321 * @param c pointer to smb context
323 * @param srv pointer to server to remove
325 * @return 0 when found and removed. 1 on failure.
328 typedef int (*smbc_remove_cached_srv_fn
)(SMBCCTX
* c
, SMBCSRV
*srv
);
332 * Try to remove all servers from the cache system and disconnect
334 * @param c pointer to smb context
336 * @return 0 when found and removed. 1 on failure.
339 typedef int (*smbc_purge_cached_fn
) (SMBCCTX
* c
);
344 /**@ingroup structure
345 * Structure that contains a client context information
346 * This structure is know as SMBCCTX
353 /** netbios name used for making connections
357 /** workgroup name used for making connections
361 /** username used for making connections
365 /** timeout used for waiting on connections / response data (in milliseconds)
369 /** callable functions for files:
370 * For usage and return values see the smbc_* functions
372 SMBCFILE
* (*open
) (SMBCCTX
*c
, const char *fname
, int flags
, mode_t mode
);
373 SMBCFILE
* (*creat
) (SMBCCTX
*c
, const char *path
, mode_t mode
);
374 ssize_t (*read
) (SMBCCTX
*c
, SMBCFILE
*file
, void *buf
, size_t count
);
375 ssize_t (*write
) (SMBCCTX
*c
, SMBCFILE
*file
, void *buf
, size_t count
);
376 int (*unlink
) (SMBCCTX
*c
, const char *fname
);
377 int (*rename
) (SMBCCTX
*ocontext
, const char *oname
,
378 SMBCCTX
*ncontext
, const char *nname
);
379 off_t (*lseek
) (SMBCCTX
*c
, SMBCFILE
* file
, off_t offset
, int whence
);
380 int (*stat
) (SMBCCTX
*c
, const char *fname
, struct stat
*st
);
381 int (*fstat
) (SMBCCTX
*c
, SMBCFILE
*file
, struct stat
*st
);
382 int (*close_fn
) (SMBCCTX
*c
, SMBCFILE
*file
);
384 /** callable functions for dirs
386 SMBCFILE
* (*opendir
) (SMBCCTX
*c
, const char *fname
);
387 int (*closedir
)(SMBCCTX
*c
, SMBCFILE
*dir
);
388 struct smbc_dirent
* (*readdir
)(SMBCCTX
*c
, SMBCFILE
*dir
);
389 int (*getdents
)(SMBCCTX
*c
, SMBCFILE
*dir
,
390 struct smbc_dirent
*dirp
, int count
);
391 int (*mkdir
) (SMBCCTX
*c
, const char *fname
, mode_t mode
);
392 int (*rmdir
) (SMBCCTX
*c
, const char *fname
);
393 off_t (*telldir
) (SMBCCTX
*c
, SMBCFILE
*dir
);
394 int (*lseekdir
)(SMBCCTX
*c
, SMBCFILE
*dir
, off_t offset
);
395 int (*fstatdir
)(SMBCCTX
*c
, SMBCFILE
*dir
, struct stat
*st
);
396 int (*chmod
)(SMBCCTX
*c
, const char *fname
, mode_t mode
);
397 int (*utimes
)(SMBCCTX
*c
,
398 const char *fname
, struct timeval
*tbuf
);
399 int (*setxattr
)(SMBCCTX
*context
,
405 int (*getxattr
)(SMBCCTX
*context
,
410 int (*removexattr
)(SMBCCTX
*context
,
413 int (*listxattr
)(SMBCCTX
*context
,
418 /** callable functions for printing
420 int (*print_file
)(SMBCCTX
*c_file
, const char *fname
,
421 SMBCCTX
*c_print
, const char *printq
);
422 SMBCFILE
* (*open_print_job
)(SMBCCTX
*c
, const char *fname
);
423 int (*list_print_jobs
)(SMBCCTX
*c
, const char *fname
, smbc_list_print_job_fn fn
);
424 int (*unlink_print_job
)(SMBCCTX
*c
, const char *fname
, int id
);
428 * These callbacks _always_ have to be initialized because they will not be checked
429 * at dereference for increased speed.
431 struct _smbc_callbacks
{
432 /** authentication function callback: called upon auth requests
434 smbc_get_auth_data_fn auth_fn
;
436 /** check if a server is still good
438 smbc_check_server_fn check_server_fn
;
440 /** remove a server if unused
442 smbc_remove_unused_server_fn remove_unused_server_fn
;
445 * For an example cache system see samba/source/libsmb/libsmb_cache.c
446 * Cache subsystem functions follow.
449 /** server cache addition
451 smbc_add_cached_srv_fn add_cached_srv_fn
;
453 /** server cache lookup
455 smbc_get_cached_srv_fn get_cached_srv_fn
;
457 /** server cache removal
459 smbc_remove_cached_srv_fn remove_cached_srv_fn
;
461 /** server cache purging, try to remove all cached servers (disconnect)
463 smbc_purge_cached_fn purge_cached_fn
;
467 /** Space to store private data of the server cache.
469 struct smbc_server_cache
* server_cache
;
473 /** user options selections that apply to this session
475 struct _smbc_options
{
478 * From how many local master browsers should the list of
479 * workgroups be retrieved? It can take up to 12 minutes or
480 * longer after a server becomes a local master browser, for
481 * it to have the entire browse list (the list of
482 * workgroups/domains) from an entire network. Since a client
483 * never knows which local master browser will be found first,
484 * the one which is found first and used to retrieve a browse
485 * list may have an incomplete or empty browse list. By
486 * requesting the browse list from multiple local master
487 * browsers, a more complete list can be generated. For small
488 * networks (few workgroups), it is recommended that this
489 * value be set to 0, causing the browse lists from all found
490 * local master browsers to be retrieved and merged. For
491 * networks with many workgroups, a suitable value for this
492 * variable is probably somewhere around 3. (Default: 3).
494 int browse_max_lmb_count
;
497 * There is a difference in the desired return strings from
498 * smbc_readdir() depending upon whether the filenames are to
499 * be displayed to the user, or whether they are to be
500 * appended to the path name passed to smbc_opendir() to call
501 * a further smbc_ function (e.g. open the file with
502 * smbc_open()). In the former case, the filename should be
503 * in "human readable" form. In the latter case, the smbc_
504 * functions expect a URL which must be url-encoded. Those
505 * functions decode the URL. If, for example, smbc_readdir()
506 * returned a file name of "abc%20def.txt", passing a path
507 * with this file name attached to smbc_open() would cause
508 * smbc_open to attempt to open the file "abc def.txt" since
509 * the %20 is decoded into a space.
511 * Set this option to True if the names returned by
512 * smbc_readdir() should be url-encoded such that they can be
513 * passed back to another smbc_ call. Set it to False if the
514 * names returned by smbc_readdir() are to be presented to the
517 * For backwards compatibility, this option defaults to False.
519 int urlencode_readdir_entries
;
522 * Some Windows versions appear to have a limit to the number
523 * of concurrent SESSIONs and/or TREE CONNECTions. In
524 * one-shot programs (i.e. the program runs and then quickly
525 * ends, thereby shutting down all connections), it is
526 * probably reasonable to establish a new connection for each
527 * share. In long-running applications, the limitation can be
528 * avoided by using only a single connection to each server,
529 * and issuing a new TREE CONNECT when the share is accessed.
531 int one_share_per_server
;
535 * do _NOT_ touch this from your program !
537 struct smbc_internal_data
* internal
;
540 /* Flags for SMBCCTX->flags */
541 #define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
542 #define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
543 #define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */
546 * Create a new SBMCCTX (a context).
548 * Must be called before the context is passed to smbc_context_init()
550 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
551 * - ENOMEM Out of memory
553 * @see smbc_free_context(), smbc_init_context()
555 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
557 SMBCCTX
* smbc_new_context(void);
560 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
562 * The context will be deleted if possible.
564 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
566 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
569 * @return Returns 0 on succes. Returns 1 on failure with errno set:
570 * - EBUSY Server connections are still used, Files are open or cache
571 * could not be purged
572 * - EBADF context == NULL
574 * @see smbc_new_context()
576 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
577 * just before exit()'ing. When shutdown_ctx is 0, this function can be
578 * use in periodical cleanup functions for example.
580 int smbc_free_context(SMBCCTX
* context
, int shutdown_ctx
);
584 * Initialize a SBMCCTX (a context).
586 * Must be called before using any SMBCCTX API function
588 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
590 * @return A pointer to the given SMBCCTX on success, NULL on error with errno set:
591 * - EBADF NULL context given
592 * - ENOMEM Out of memory
593 * - ENOENT The smb.conf file would not load
595 * @see smbc_new_context()
597 * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe,
598 * but it might leak memory on smbc_context_init() failure. Avoid this.
599 * You'll have to call smbc_free_context() yourself on failure.
602 SMBCCTX
* smbc_init_context(SMBCCTX
* context
);
605 * Initialize the samba client library.
607 * Must be called before using any of the smbclient API function
609 * @param fn The function that will be called to obtaion
610 * authentication credentials.
612 * @param debug Allows caller to set the debug level. Can be
613 * changed in smb.conf file. Allows caller to set
614 * debugging if no smb.conf.
616 * @return 0 on success, < 0 on error with errno set:
617 * - ENOMEM Out of memory
618 * - ENOENT The smb.conf file would not load
622 int smbc_init(smbc_get_auth_data_fn fn
, int debug
);
625 * Set or retrieve the compatibility library's context pointer
627 * @param context New context to use, or NULL. If a new context is provided,
628 * it must have allocated with smbc_new_context() and
629 * initialized with smbc_init_context(), followed, optionally,
630 * by some manual changes to some of the non-internal fields.
632 * @return The old context.
634 * @see smbc_new_context(), smbc_init_context(), smbc_init()
636 * @note This function may be called prior to smbc_init() to force
637 * use of the next context without any internal calls to
638 * smbc_new_context() or smbc_init_context(). It may also
639 * be called after smbc_init() has already called those two
640 * functions, to replace the existing context with a new one.
641 * Care should be taken, in this latter case, to ensure that
642 * the server cache and any data allocated by the
643 * authentication functions have been freed, if necessary.
646 SMBCCTX
* smbc_set_context(SMBCCTX
* new_context
);
649 * Open a file on an SMB server.
651 * @param furl The smb url of the file to be opened.
653 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
654 * request opening the file read-only,write-only
655 * or read/write. flags may also be bitwise-or'd with
656 * one or more of the following:
657 * O_CREAT - If the file does not exist it will be
659 * O_EXCL - When used with O_CREAT, if the file
660 * already exists it is an error and the open will
662 * O_TRUNC - If the file already exists it will be
664 * O_APPEND The file is opened in append mode
666 * @param mode mode specifies the permissions to use if a new
667 * file is created. It is modified by the
668 * process's umask in the usual way: the permissions
669 * of the created file are (mode & ~umask)
671 * Not currently use, but there for future use.
672 * We will map this to SYSTEM, HIDDEN, etc bits
673 * that reverses the mapping that smbc_fstat does.
675 * @return Valid file handle, < 0 on error with errno set:
676 * - ENOMEM Out of memory
677 * - EINVAL if an invalid parameter passed, like no
678 * file, or smbc_init not called.
679 * - EEXIST pathname already exists and O_CREAT and
681 * - EISDIR pathname refers to a directory and
682 * the access requested involved writing.
683 * - EACCES The requested access to the file is not
685 * - ENODEV The requested share does not exist
686 * - ENOTDIR A file on the path is not a directory
687 * - ENOENT A directory component in pathname does
692 * @note This call uses an underlying routine that may create
693 * a new connection to the server specified in the URL.
694 * If the credentials supplied in the URL, or via the
695 * auth_fn in the smbc_init call, fail, this call will
696 * try again with an empty username and password. This
697 * often gets mapped to the guest account on some machines.
700 int smbc_open(const char *furl
, int flags
, mode_t mode
);
703 * Create a file on an SMB server.
705 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
707 * @param furl The smb url of the file to be created
709 * @param mode mode specifies the permissions to use if a new
710 * file is created. It is modified by the
711 * process's umask in the usual way: the permissions
712 * of the created file are (mode & ~umask)
714 * NOTE, the above is not true. We are dealing with
715 * an SMB server, which has no concept of a umask!
717 * @return Valid file handle, < 0 on error with errno set:
718 * - ENOMEM Out of memory
719 * - EINVAL if an invalid parameter passed, like no
720 * file, or smbc_init not called.
721 * - EEXIST pathname already exists and O_CREAT and
723 * - EISDIR pathname refers to a directory and
724 * the access requested involved writing.
725 * - EACCES The requested access to the file is not
727 * - ENOENT A directory component in pathname does
729 * - ENODEV The requested share does not exist.
734 int smbc_creat(const char *furl
, mode_t mode
);
737 * Read from a file using an opened file handle.
739 * @param fd Open file handle from smbc_open() or smbc_creat()
741 * @param buf Pointer to buffer to recieve read data
743 * @param bufsize Size of buf in bytes
745 * @return Number of bytes read, < 0 on error with errno set:
746 * - EISDIR fd refers to a directory
747 * - EBADF fd is not a valid file descriptor or
748 * is not open for reading.
749 * - EINVAL fd is attached to an object which is
750 * unsuitable for reading, or no buffer passed or
751 * smbc_init not called.
753 * @see smbc_open(), smbc_write()
756 ssize_t
smbc_read(int fd
, void *buf
, size_t bufsize
);
760 * Write to a file using an opened file handle.
762 * @param fd Open file handle from smbc_open() or smbc_creat()
764 * @param buf Pointer to buffer to recieve read data
766 * @param bufsize Size of buf in bytes
768 * @return Number of bytes written, < 0 on error with errno set:
769 * - EISDIR fd refers to a directory.
770 * - EBADF fd is not a valid file descriptor or
771 * is not open for reading.
772 * - EINVAL fd is attached to an object which is
773 * unsuitable for reading, or no buffer passed or
774 * smbc_init not called.
776 * @see smbc_open(), smbc_read()
779 ssize_t
smbc_write(int fd
, void *buf
, size_t bufsize
);
783 * Seek to a specific location in a file.
785 * @param fd Open file handle from smbc_open() or smbc_creat()
787 * @param offset Offset in bytes from whence
789 * @param whence A location in the file:
790 * - SEEK_SET The offset is set to offset bytes from
791 * the beginning of the file
792 * - SEEK_CUR The offset is set to current location
794 * - SEEK_END The offset is set to the size of the
795 * file plus offset bytes.
797 * @return Upon successful completion, lseek returns the
798 * resulting offset location as measured in bytes
799 * from the beginning of the file. Otherwise, a value
800 * of (off_t)-1 is returned and errno is set to
801 * indicate the error:
802 * - EBADF Fildes is not an open file descriptor.
803 * - EINVAL Whence is not a proper value or smbc_init
806 * @todo Are all the whence values really supported?
808 * @todo Are errno values complete and correct?
810 off_t
smbc_lseek(int fd
, off_t offset
, int whence
);
814 * Close an open file handle.
816 * @param fd The file handle to close
818 * @return 0 on success, < 0 on error with errno set:
819 * - EBADF fd isn't a valid open file descriptor
820 * - EINVAL smbc_init() failed or has not been called
822 * @see smbc_open(), smbc_creat()
824 int smbc_close(int fd
);
827 /**@ingroup directory
828 * Unlink (delete) a file or directory.
830 * @param furl The smb url of the file to delete
832 * @return 0 on success, < 0 on error with errno set:
833 * - EACCES or EPERM Write access to the directory
834 * containing pathname is not allowed or one
835 * of the directories in pathname did not allow
836 * search (execute) permission
837 * - ENOENT A directory component in pathname does
839 * - EINVAL NULL was passed in the file param or
840 * smbc_init not called.
841 * - EACCES You do not have access to the file
842 * - ENOMEM Insufficient kernel memory was available
846 * @todo Are errno values complete and correct?
848 int smbc_unlink(const char *furl
);
851 /**@ingroup directory
852 * Rename or move a file or directory.
854 * @param ourl The original smb url (source url) of file or
855 * directory to be moved
857 * @param nurl The new smb url (destination url) of the file
858 * or directory after the move. Currently nurl must
859 * be on the same share as ourl.
861 * @return 0 on success, < 0 on error with errno set:
862 * - EISDIR nurl is an existing directory, but ourl is
864 * - EEXIST nurl is a non-empty directory,
865 * i.e., contains entries other than "." and ".."
866 * - EINVAL The new url contained a path prefix
867 * of the old, or, more generally, an attempt was
868 * made to make a directory a subdirectory of itself
869 * or smbc_init not called.
870 * - ENOTDIR A component used as a directory in ourl
871 * or nurl path is not, in fact, a directory. Or,
872 * ourl is a directory, and newpath exists but is not
874 * - EACCES or EPERM Write access to the directory
875 * containing ourl or nurl is not allowed for the
876 * process's effective uid, or one of the
877 * directories in ourl or nurl did not allow search
878 * (execute) permission, or ourl was a directory
879 * and did not allow write permission.
880 * - ENOENT A directory component in ourl or nurl
882 * - EXDEV Rename across shares not supported.
883 * - ENOMEM Insufficient kernel memory was available.
884 * - EEXIST The target file, nurl, already exists.
887 * @todo Are we going to support copying when urls are not on the same
888 * share? I say no... NOTE. I agree for the moment.
891 int smbc_rename(const char *ourl
, const char *nurl
);
894 /**@ingroup directory
895 * Open a directory used to obtain directory entries.
897 * @param durl The smb url of the directory to open
899 * @return Valid directory handle. < 0 on error with errno set:
900 * - EACCES Permission denied.
901 * - EINVAL A NULL file/URL was passed, or the URL would
902 * not parse, or was of incorrect form or smbc_init not
904 * - ENOENT durl does not exist, or name is an
905 * - ENOMEM Insufficient memory to complete the
907 * - ENOTDIR name is not a directory.
908 * - EPERM the workgroup could not be found.
909 * - ENODEV the workgroup or server could not be found.
911 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
914 int smbc_opendir(const char *durl
);
917 /**@ingroup directory
918 * Close a directory handle opened by smbc_opendir().
920 * @param dh Directory handle to close
922 * @return 0 on success, < 0 on error with errno set:
923 * - EBADF dh is an invalid directory handle
925 * @see smbc_opendir()
927 int smbc_closedir(int dh
);
930 /**@ingroup directory
931 * Get multiple directory entries.
933 * smbc_getdents() reads as many dirent structures from the an open
934 * directory handle into a specified memory area as will fit.
936 * @param dh Valid directory as returned by smbc_opendir()
938 * @param dirp pointer to buffer that will receive the directory
941 * @param count The size of the dirp buffer in bytes
943 * @returns If any dirents returned, return will indicate the
944 * total size. If there were no more dirents available,
945 * 0 is returned. < 0 indicates an error.
946 * - EBADF Invalid directory handle
947 * - EINVAL Result buffer is too small or smbc_init
949 * - ENOENT No such directory.
950 * @see , smbc_dirent, smbc_readdir(), smbc_open()
952 * @todo Are errno values complete and correct?
954 * @todo Add example code so people know how to parse buffers.
956 int smbc_getdents(unsigned int dh
, struct smbc_dirent
*dirp
, int count
);
959 /**@ingroup directory
960 * Get a single directory entry.
962 * @param dh Valid directory as returned by smbc_opendir()
964 * @return A pointer to a smbc_dirent structure, or NULL if an
965 * error occurs or end-of-directory is reached:
966 * - EBADF Invalid directory handle
967 * - EINVAL smbc_init() failed or has not been called
969 * @see smbc_dirent, smbc_getdents(), smbc_open()
971 struct smbc_dirent
* smbc_readdir(unsigned int dh
);
974 /**@ingroup directory
975 * Get the current directory offset.
977 * smbc_telldir() may be used in conjunction with smbc_readdir() and
980 * @param dh Valid directory as returned by smbc_opendir()
982 * @return The current location in the directory stream or -1
983 * if an error occur. The current location is not
984 * an offset. Becuase of the implementation, it is a
985 * handle that allows the library to find the entry
987 * - EBADF dh is not a valid directory handle
988 * - EINVAL smbc_init() failed or has not been called
989 * - ENOTDIR if dh is not a directory
991 * @see smbc_readdir()
994 off_t
smbc_telldir(int dh
);
997 /**@ingroup directory
998 * lseek on directories.
1000 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1001 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1003 * @param fd Valid directory as returned by smbc_opendir()
1005 * @param offset The offset (as returned by smbc_telldir). Can be
1006 * NULL, in which case we will rewind
1008 * @return 0 on success, -1 on failure
1009 * - EBADF dh is not a valid directory handle
1010 * - ENOTDIR if dh is not a directory
1011 * - EINVAL offset did not refer to a valid dirent or
1012 * smbc_init not called.
1014 * @see smbc_telldir()
1017 * @todo In what does the reture and errno values mean?
1019 int smbc_lseekdir(int fd
, off_t offset
);
1021 /**@ingroup directory
1022 * Create a directory.
1024 * @param durl The url of the directory to create
1026 * @param mode Specifies the permissions to use. It is modified
1027 * by the process's umask in the usual way: the
1028 * permissions of the created file are (mode & ~umask).
1030 * @return 0 on success, < 0 on error with errno set:
1031 * - EEXIST directory url already exists
1032 * - EACCES The parent directory does not allow write
1033 * permission to the process, or one of the directories
1034 * - ENOENT A directory component in pathname does not
1036 * - EINVAL NULL durl passed or smbc_init not called.
1037 * - ENOMEM Insufficient memory was available.
1042 int smbc_mkdir(const char *durl
, mode_t mode
);
1045 /**@ingroup directory
1046 * Remove a directory.
1048 * @param durl The smb url of the directory to remove
1050 * @return 0 on success, < 0 on error with errno set:
1051 * - EACCES or EPERM Write access to the directory
1052 * containing pathname was not allowed.
1053 * - EINVAL durl is NULL or smbc_init not called.
1054 * - ENOENT A directory component in pathname does not
1056 * - ENOTEMPTY directory contains entries.
1057 * - ENOMEM Insufficient kernel memory was available.
1059 * @see smbc_mkdir(), smbc_unlink()
1061 * @todo Are errno values complete and correct?
1063 int smbc_rmdir(const char *durl
);
1066 /**@ingroup attribute
1067 * Get information about a file or directory.
1069 * @param url The smb url to get information for
1071 * @param st pointer to a buffer that will be filled with
1072 * standard Unix struct stat information.
1074 * @return 0 on success, < 0 on error with errno set:
1075 * - ENOENT A component of the path file_name does not
1077 * - EINVAL a NULL url was passed or smbc_init not called.
1078 * - EACCES Permission denied.
1079 * - ENOMEM Out of memory
1080 * - ENOTDIR The target dir, url, is not a directory.
1085 int smbc_stat(const char *url
, struct stat
*st
);
1088 /**@ingroup attribute
1089 * Get file information via an file descriptor.
1091 * @param fd Open file handle from smbc_open() or smbc_creat()
1093 * @param st pointer to a buffer that will be filled with
1094 * standard Unix struct stat information.
1096 * @return EBADF filedes is bad.
1097 * - EACCES Permission denied.
1098 * - EBADF fd is not a valid file descriptor
1099 * - EINVAL Problems occurred in the underlying routines
1100 * or smbc_init not called.
1101 * - ENOMEM Out of memory
1103 * @see smbc_stat(), Unix stat()
1106 int smbc_fstat(int fd
, struct stat
*st
);
1109 /**@ingroup attribue
1110 * Change the ownership of a file or directory.
1112 * @param url The smb url of the file or directory to change
1115 * @param owner I have no idea?
1117 * @param group I have not idea?
1119 * @return 0 on success, < 0 on error with errno set:
1120 * - EPERM The effective UID does not match the owner
1121 * of the file, and is not zero; or the owner or group
1122 * were specified incorrectly.
1123 * - ENOENT The file does not exist.
1124 * - ENOMEM Insufficient was available.
1125 * - ENOENT file or directory does not exist
1127 * @todo Are we actually going to be able to implement this function
1129 * @todo How do we abstract owner and group uid and gid?
1132 int smbc_chown(const char *url
, uid_t owner
, gid_t group
);
1135 /**@ingroup attribute
1136 * Change the permissions of a file.
1138 * @param url The smb url of the file or directory to change
1141 * @param mode The permissions to set:
1142 * - Put good explaination of permissions here!
1144 * @return 0 on success, < 0 on error with errno set:
1145 * - EPERM The effective UID does not match the owner
1146 * of the file, and is not zero
1147 * - ENOENT The file does not exist.
1148 * - ENOMEM Insufficient was available.
1149 * - ENOENT file or directory does not exist
1151 * @todo Actually implement this fuction?
1153 * @todo Are errno values complete and correct?
1155 int smbc_chmod(const char *url
, mode_t mode
);
1157 /**@ingroup attribute
1158 * Change the last modification time on a file
1160 * @param url The smb url of the file or directory to change
1161 * the modification time of
1163 * @param tbuf A timeval structure which contains the desired
1164 * modification time. NOTE: Only the tv_sec field is
1165 * used. The tv_usec (microseconds) portion is ignored.
1167 * @return 0 on success, < 0 on error with errno set:
1168 * - EINVAL The client library is not properly initialized
1169 * - EPERM Permission was denied.
1172 int smbc_utimes(const char *url
, struct timeval
*tbuf
);
1175 /**@ingroup attribute
1176 * Change the last modification time on a file
1178 * @param url The smb url of the file or directory to change
1179 * the modification time of
1181 * @param utbuf A utimebuf structure which contains the desired
1182 * modification time. NOTE: Although the structure contains
1183 * an access time as well, the access time value is ignored.
1185 * @return 0 on success, < 0 on error with errno set:
1186 * - EINVAL The client library is not properly initialized
1187 * - ENOMEM No memory was available for internal needs
1188 * - EPERM Permission was denied.
1191 int smbc_utime(const char *fname
, struct utimbuf
*utbuf
);
1194 /**@ingroup attribute
1195 * Set extended attributes for a file. This is used for modifying a file's
1196 * security descriptor (i.e. owner, group, and access control list)
1198 * @param url The smb url of the file or directory to set extended
1201 * @param name The name of an attribute to be changed. Names are of
1202 * one of the following forms:
1204 * system.nt_sec_desc.<attribute name>
1205 * system.nt_sec_desc.*
1206 * system.nt_sec_desc.*+
1208 * where <attribute name> is one of:
1216 * acl+:<name or sid>
1218 * In the forms "system.nt_sec_desc.*" and
1219 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1220 * literal, i.e. the string is provided exactly as shown, and
1221 * the value parameter should contain a complete security
1222 * descriptor with name:value pairs separated by tabs,
1223 * commas, or newlines (not spaces!).
1225 * The plus sign ('+') indicates that SIDs should be mapped
1226 * to names. Without the plus sign, SIDs are not mapped;
1227 * rather they are simply converted to a string format.
1229 * @param value The value to be assigned to the specified attribute name.
1230 * This buffer should contain only the attribute value if the
1231 * name was of the "system.nt_sec_desc.<attribute_name>"
1232 * form. If the name was of the "system.nt_sec_desc.*" form
1233 * then a complete security descriptor, with name:value pairs
1234 * separated by tabs, commas, or newlines (not spaces!),
1235 * should be provided in this value buffer. A complete
1236 * security descriptor will contain one or more entries
1237 * selected from the following:
1239 * REVISION:<revision number>
1240 * OWNER:<sid or name>
1241 * GROUP:<sid or name>
1242 * ACL:<sid or name>:<type>/<flags>/<mask>
1244 * The revision of the ACL specifies the internal Windows NT
1245 * ACL revision for the security descriptor. If not specified
1246 * it defaults to 1. Using values other than 1 may cause
1247 * strange behaviour.
1249 * The owner and group specify the owner and group sids for
1250 * the object. If the attribute name (either '*+' with a
1251 * complete security descriptor, or individual 'owner+' or
1252 * 'group+' attribute names) ended with a plus sign, the
1253 * specified name is resolved to a SID value, using the
1254 * server on which the file or directory resides. Otherwise,
1255 * the value should be provided in SID-printable format as
1256 * S-1-x-y-z, and is used directly. The <sid or name>
1257 * associated with the ACL: attribute should be provided
1260 * @param size The number of the bytes of data in the value buffer
1262 * @param flags A bit-wise OR of zero or more of the following:
1263 * SMBC_XATTR_FLAG_CREATE -
1264 * fail if the named attribute already exists
1265 * SMBC_XATTR_FLAG_REPLACE -
1266 * fail if the attribute does not already exist
1268 * If neither flag is specified, the specified attributes
1269 * will be added or replace existing attributes of the same
1270 * name, as necessary.
1272 * @return 0 on success, < 0 on error with errno set:
1273 * - EINVAL The client library is not properly initialized
1274 * or one of the parameters is not of a correct
1276 * - ENOMEM No memory was available for internal needs
1277 * - EEXIST If the attribute already exists and the flag
1278 * SMBC_XATTR_FLAG_CREAT was specified
1279 * - ENOATTR If the attribute does not exist and the flag
1280 * SMBC_XATTR_FLAG_REPLACE was specified
1281 * - EPERM Permission was denied.
1282 * - ENOTSUP The referenced file system does not support
1283 * extended attributes
1285 * @note Attribute names are compared in a case-insensitive
1286 * fashion. All of the following are equivalent, although
1287 * the all-lower-case name is the preferred format:
1288 * system.nt_sec_desc.owner
1289 * SYSTEM.NT_SEC_DESC.OWNER
1290 * sYsTeM.nt_sEc_desc.owNER
1293 int smbc_setxattr(const char *url
,
1300 /**@ingroup attribute
1301 * Set extended attributes for a file. This is used for modifying a file's
1302 * security descriptor (i.e. owner, group, and access control list). The
1303 * POSIX function which this maps to would act on a symbolic link rather than
1304 * acting on what the symbolic link points to, but with no symbolic links in
1305 * SMB file systems, this function is functionally identical to
1308 * @param url The smb url of the file or directory to set extended
1311 * @param name The name of an attribute to be changed. Names are of
1312 * one of the following forms:
1314 * system.nt_sec_desc.<attribute name>
1315 * system.nt_sec_desc.*
1316 * system.nt_sec_desc.*+
1318 * where <attribute name> is one of:
1326 * acl+:<name or sid>
1328 * In the forms "system.nt_sec_desc.*" and
1329 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1330 * literal, i.e. the string is provided exactly as shown, and
1331 * the value parameter should contain a complete security
1332 * descriptor with name:value pairs separated by tabs,
1333 * commas, or newlines (not spaces!).
1335 * The plus sign ('+') indicates that SIDs should be mapped
1336 * to names. Without the plus sign, SIDs are not mapped;
1337 * rather they are simply converted to a string format.
1339 * @param value The value to be assigned to the specified attribute name.
1340 * This buffer should contain only the attribute value if the
1341 * name was of the "system.nt_sec_desc.<attribute_name>"
1342 * form. If the name was of the "system.nt_sec_desc.*" form
1343 * then a complete security descriptor, with name:value pairs
1344 * separated by tabs, commas, or newlines (not spaces!),
1345 * should be provided in this value buffer. A complete
1346 * security descriptor will contain one or more entries
1347 * selected from the following:
1349 * REVISION:<revision number>
1350 * OWNER:<sid or name>
1351 * GROUP:<sid or name>
1352 * ACL:<sid or name>:<type>/<flags>/<mask>
1354 * The revision of the ACL specifies the internal Windows NT
1355 * ACL revision for the security descriptor. If not specified
1356 * it defaults to 1. Using values other than 1 may cause
1357 * strange behaviour.
1359 * The owner and group specify the owner and group sids for
1360 * the object. If the attribute name (either '*+' with a
1361 * complete security descriptor, or individual 'owner+' or
1362 * 'group+' attribute names) ended with a plus sign, the
1363 * specified name is resolved to a SID value, using the
1364 * server on which the file or directory resides. Otherwise,
1365 * the value should be provided in SID-printable format as
1366 * S-1-x-y-z, and is used directly. The <sid or name>
1367 * associated with the ACL: attribute should be provided
1370 * @param size The number of the bytes of data in the value buffer
1372 * @param flags A bit-wise OR of zero or more of the following:
1373 * SMBC_XATTR_FLAG_CREATE -
1374 * fail if the named attribute already exists
1375 * SMBC_XATTR_FLAG_REPLACE -
1376 * fail if the attribute does not already exist
1378 * If neither flag is specified, the specified attributes
1379 * will be added or replace existing attributes of the same
1380 * name, as necessary.
1382 * @return 0 on success, < 0 on error with errno set:
1383 * - EINVAL The client library is not properly initialized
1384 * or one of the parameters is not of a correct
1386 * - ENOMEM No memory was available for internal needs
1387 * - EEXIST If the attribute already exists and the flag
1388 * SMBC_XATTR_FLAG_CREAT was specified
1389 * - ENOATTR If the attribute does not exist and the flag
1390 * SMBC_XATTR_FLAG_REPLACE was specified
1391 * - EPERM Permission was denied.
1392 * - ENOTSUP The referenced file system does not support
1393 * extended attributes
1395 * @note Attribute names are compared in a case-insensitive
1396 * fashion. All of the following are equivalent, although
1397 * the all-lower-case name is the preferred format:
1398 * system.nt_sec_desc.owner
1399 * SYSTEM.NT_SEC_DESC.OWNER
1400 * sYsTeM.nt_sEc_desc.owNER
1403 int smbc_lsetxattr(const char *url
,
1410 /**@ingroup attribute
1411 * Set extended attributes for a file. This is used for modifying a file's
1412 * security descriptor (i.e. owner, group, and access control list)
1414 * @param fd A file descriptor associated with an open file (as
1415 * previously returned by smbc_open(), to get extended
1418 * @param name The name of an attribute to be changed. Names are of
1419 * one of the following forms:
1421 * system.nt_sec_desc.<attribute name>
1422 * system.nt_sec_desc.*
1423 * system.nt_sec_desc.*+
1425 * where <attribute name> is one of:
1433 * acl+:<name or sid>
1435 * In the forms "system.nt_sec_desc.*" and
1436 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1437 * literal, i.e. the string is provided exactly as shown, and
1438 * the value parameter should contain a complete security
1439 * descriptor with name:value pairs separated by tabs,
1440 * commas, or newlines (not spaces!).
1442 * The plus sign ('+') indicates that SIDs should be mapped
1443 * to names. Without the plus sign, SIDs are not mapped;
1444 * rather they are simply converted to a string format.
1446 * @param value The value to be assigned to the specified attribute name.
1447 * This buffer should contain only the attribute value if the
1448 * name was of the "system.nt_sec_desc.<attribute_name>"
1449 * form. If the name was of the "system.nt_sec_desc.*" form
1450 * then a complete security descriptor, with name:value pairs
1451 * separated by tabs, commas, or newlines (not spaces!),
1452 * should be provided in this value buffer. A complete
1453 * security descriptor will contain one or more entries
1454 * selected from the following:
1456 * REVISION:<revision number>
1457 * OWNER:<sid or name>
1458 * GROUP:<sid or name>
1459 * ACL:<sid or name>:<type>/<flags>/<mask>
1461 * The revision of the ACL specifies the internal Windows NT
1462 * ACL revision for the security descriptor. If not specified
1463 * it defaults to 1. Using values other than 1 may cause
1464 * strange behaviour.
1466 * The owner and group specify the owner and group sids for
1467 * the object. If the attribute name (either '*+' with a
1468 * complete security descriptor, or individual 'owner+' or
1469 * 'group+' attribute names) ended with a plus sign, the
1470 * specified name is resolved to a SID value, using the
1471 * server on which the file or directory resides. Otherwise,
1472 * the value should be provided in SID-printable format as
1473 * S-1-x-y-z, and is used directly. The <sid or name>
1474 * associated with the ACL: attribute should be provided
1477 * @param size The number of the bytes of data in the value buffer
1479 * @param flags A bit-wise OR of zero or more of the following:
1480 * SMBC_XATTR_FLAG_CREATE -
1481 * fail if the named attribute already exists
1482 * SMBC_XATTR_FLAG_REPLACE -
1483 * fail if the attribute does not already exist
1485 * If neither flag is specified, the specified attributes
1486 * will be added or replace existing attributes of the same
1487 * name, as necessary.
1489 * @return 0 on success, < 0 on error with errno set:
1490 * - EINVAL The client library is not properly initialized
1491 * or one of the parameters is not of a correct
1493 * - ENOMEM No memory was available for internal needs
1494 * - EEXIST If the attribute already exists and the flag
1495 * SMBC_XATTR_FLAG_CREAT was specified
1496 * - ENOATTR If the attribute does not exist and the flag
1497 * SMBC_XATTR_FLAG_REPLACE was specified
1498 * - EPERM Permission was denied.
1499 * - ENOTSUP The referenced file system does not support
1500 * extended attributes
1502 * @note Attribute names are compared in a case-insensitive
1503 * fashion. All of the following are equivalent, although
1504 * the all-lower-case name is the preferred format:
1505 * system.nt_sec_desc.owner
1506 * SYSTEM.NT_SEC_DESC.OWNER
1507 * sYsTeM.nt_sEc_desc.owNER
1510 int smbc_fsetxattr(int fd
,
1517 /**@ingroup attribute
1518 * Get extended attributes for a file.
1520 * @param url The smb url of the file or directory to get extended
1523 * @param name The name of an attribute to be retrieved. Names are of
1524 * one of the following forms:
1526 * system.nt_sec_desc.<attribute name>
1527 * system.nt_sec_desc.*
1528 * system.nt_sec_desc.*+
1530 * where <attribute name> is one of:
1538 * acl+:<name or sid>
1540 * In the forms "system.nt_sec_desc.*" and
1541 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1542 * literal, i.e. the string is provided exactly as shown, and
1543 * the value parameter will return a complete security
1544 * descriptor with name:value pairs separated by tabs,
1545 * commas, or newlines (not spaces!).
1547 * The plus sign ('+') indicates that SIDs should be mapped
1548 * to names. Without the plus sign, SIDs are not mapped;
1549 * rather they are simply converted to a string format.
1551 * @param value A pointer to a buffer in which the value of the specified
1552 * attribute will be placed (unless size is zero).
1554 * @param size The size of the buffer pointed to by value. This parameter
1555 * may also be zero, in which case the size of the buffer
1556 * required to hold the attribute value will be returned,
1557 * but nothing will be placed into the value buffer.
1559 * @return 0 on success, < 0 on error with errno set:
1560 * - EINVAL The client library is not properly initialized
1561 * or one of the parameters is not of a correct
1563 * - ENOMEM No memory was available for internal needs
1564 * - EEXIST If the attribute already exists and the flag
1565 * SMBC_XATTR_FLAG_CREAT was specified
1566 * - ENOATTR If the attribute does not exist and the flag
1567 * SMBC_XATTR_FLAG_REPLACE was specified
1568 * - EPERM Permission was denied.
1569 * - ENOTSUP The referenced file system does not support
1570 * extended attributes
1573 int smbc_getxattr(const char *url
,
1579 /**@ingroup attribute
1580 * Get extended attributes for a file. The POSIX function which this maps to
1581 * would act on a symbolic link rather than acting on what the symbolic link
1582 * points to, but with no symbolic links in SMB file systems, this function
1583 * is functionally identical to smbc_getxattr().
1585 * @param url The smb url of the file or directory to get extended
1588 * @param name The name of an attribute to be retrieved. Names are of
1589 * one of the following forms:
1591 * system.nt_sec_desc.<attribute name>
1592 * system.nt_sec_desc.*
1593 * system.nt_sec_desc.*+
1595 * where <attribute name> is one of:
1603 * acl+:<name or sid>
1605 * In the forms "system.nt_sec_desc.*" and
1606 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1607 * literal, i.e. the string is provided exactly as shown, and
1608 * the value parameter will return a complete security
1609 * descriptor with name:value pairs separated by tabs,
1610 * commas, or newlines (not spaces!).
1612 * The plus sign ('+') indicates that SIDs should be mapped
1613 * to names. Without the plus sign, SIDs are not mapped;
1614 * rather they are simply converted to a string format.
1616 * @param value A pointer to a buffer in which the value of the specified
1617 * attribute will be placed (unless size is zero).
1619 * @param size The size of the buffer pointed to by value. This parameter
1620 * may also be zero, in which case the size of the buffer
1621 * required to hold the attribute value will be returned,
1622 * but nothing will be placed into the value buffer.
1624 * @return 0 on success, < 0 on error with errno set:
1625 * - EINVAL The client library is not properly initialized
1626 * or one of the parameters is not of a correct
1628 * - ENOMEM No memory was available for internal needs
1629 * - EEXIST If the attribute already exists and the flag
1630 * SMBC_XATTR_FLAG_CREAT was specified
1631 * - ENOATTR If the attribute does not exist and the flag
1632 * SMBC_XATTR_FLAG_REPLACE was specified
1633 * - EPERM Permission was denied.
1634 * - ENOTSUP The referenced file system does not support
1635 * extended attributes
1638 int smbc_lgetxattr(const char *url
,
1644 /**@ingroup attribute
1645 * Get extended attributes for a file.
1647 * @param fd A file descriptor associated with an open file (as
1648 * previously returned by smbc_open(), to get extended
1651 * @param name The name of an attribute to be retrieved. Names are of
1652 * one of the following forms:
1654 * system.nt_sec_desc.<attribute name>
1655 * system.nt_sec_desc.*
1656 * system.nt_sec_desc.*+
1658 * where <attribute name> is one of:
1666 * acl+:<name or sid>
1668 * In the forms "system.nt_sec_desc.*" and
1669 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1670 * literal, i.e. the string is provided exactly as shown, and
1671 * the value parameter will return a complete security
1672 * descriptor with name:value pairs separated by tabs,
1673 * commas, or newlines (not spaces!).
1675 * The plus sign ('+') indicates that SIDs should be mapped
1676 * to names. Without the plus sign, SIDs are not mapped;
1677 * rather they are simply converted to a string format.
1679 * @param value A pointer to a buffer in which the value of the specified
1680 * attribute will be placed (unless size is zero).
1682 * @param size The size of the buffer pointed to by value. This parameter
1683 * may also be zero, in which case the size of the buffer
1684 * required to hold the attribute value will be returned,
1685 * but nothing will be placed into the value buffer.
1687 * @return 0 on success, < 0 on error with errno set:
1688 * - EINVAL The client library is not properly initialized
1689 * or one of the parameters is not of a correct
1691 * - ENOMEM No memory was available for internal needs
1692 * - EEXIST If the attribute already exists and the flag
1693 * SMBC_XATTR_FLAG_CREAT was specified
1694 * - ENOATTR If the attribute does not exist and the flag
1695 * SMBC_XATTR_FLAG_REPLACE was specified
1696 * - EPERM Permission was denied.
1697 * - ENOTSUP The referenced file system does not support
1698 * extended attributes
1701 int smbc_fgetxattr(int fd
,
1707 /**@ingroup attribute
1708 * Remove extended attributes for a file. This is used for modifying a file's
1709 * security descriptor (i.e. owner, group, and access control list)
1711 * @param url The smb url of the file or directory to remove the extended
1714 * @param name The name of an attribute to be removed. Names are of
1715 * one of the following forms:
1717 * system.nt_sec_desc.<attribute name>
1718 * system.nt_sec_desc.*
1719 * system.nt_sec_desc.*+
1721 * where <attribute name> is one of:
1729 * acl+:<name or sid>
1731 * In the forms "system.nt_sec_desc.*" and
1732 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1733 * literal, i.e. the string is provided exactly as shown, and
1734 * the value parameter will return a complete security
1735 * descriptor with name:value pairs separated by tabs,
1736 * commas, or newlines (not spaces!).
1738 * The plus sign ('+') indicates that SIDs should be mapped
1739 * to names. Without the plus sign, SIDs are not mapped;
1740 * rather they are simply converted to a string format.
1742 * @return 0 on success, < 0 on error with errno set:
1743 * - EINVAL The client library is not properly initialized
1744 * - ENOMEM No memory was available for internal needs
1745 * - EPERM Permission was denied.
1746 * - ENOTSUP The referenced file system does not support
1747 * extended attributes
1750 int smbc_removexattr(const char *url
,
1754 /**@ingroup attribute
1755 * Remove extended attributes for a file. This is used for modifying a file's
1756 * security descriptor (i.e. owner, group, and access control list) The POSIX
1757 * function which this maps to would act on a symbolic link rather than acting
1758 * on what the symbolic link points to, but with no symbolic links in SMB file
1759 * systems, this function is functionally identical to smbc_removexattr().
1761 * @param url The smb url of the file or directory to remove the extended
1764 * @param name The name of an attribute to be removed. Names are of
1765 * one of the following forms:
1767 * system.nt_sec_desc.<attribute name>
1768 * system.nt_sec_desc.*
1769 * system.nt_sec_desc.*+
1771 * where <attribute name> is one of:
1779 * acl+:<name or sid>
1781 * In the forms "system.nt_sec_desc.*" and
1782 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1783 * literal, i.e. the string is provided exactly as shown, and
1784 * the value parameter will return a complete security
1785 * descriptor with name:value pairs separated by tabs,
1786 * commas, or newlines (not spaces!).
1788 * The plus sign ('+') indicates that SIDs should be mapped
1789 * to names. Without the plus sign, SIDs are not mapped;
1790 * rather they are simply converted to a string format.
1792 * @return 0 on success, < 0 on error with errno set:
1793 * - EINVAL The client library is not properly initialized
1794 * - ENOMEM No memory was available for internal needs
1795 * - EPERM Permission was denied.
1796 * - ENOTSUP The referenced file system does not support
1797 * extended attributes
1800 int smbc_lremovexattr(const char *url
,
1804 /**@ingroup attribute
1805 * Remove extended attributes for a file. This is used for modifying a file's
1806 * security descriptor (i.e. owner, group, and access control list)
1808 * @param fd A file descriptor associated with an open file (as
1809 * previously returned by smbc_open(), to get extended
1812 * @param name The name of an attribute to be removed. Names are of
1813 * one of the following forms:
1815 * system.nt_sec_desc.<attribute name>
1816 * system.nt_sec_desc.*
1817 * system.nt_sec_desc.*+
1819 * where <attribute name> is one of:
1827 * acl+:<name or sid>
1829 * In the forms "system.nt_sec_desc.*" and
1830 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1831 * literal, i.e. the string is provided exactly as shown, and
1832 * the value parameter will return a complete security
1833 * descriptor with name:value pairs separated by tabs,
1834 * commas, or newlines (not spaces!).
1836 * The plus sign ('+') indicates that SIDs should be mapped
1837 * to names. Without the plus sign, SIDs are not mapped;
1838 * rather they are simply converted to a string format.
1840 * @return 0 on success, < 0 on error with errno set:
1841 * - EINVAL The client library is not properly initialized
1842 * - ENOMEM No memory was available for internal needs
1843 * - EPERM Permission was denied.
1844 * - ENOTSUP The referenced file system does not support
1845 * extended attributes
1848 int smbc_fremovexattr(int fd
,
1852 /**@ingroup attribute
1853 * List the supported extended attribute names associated with a file
1855 * @param url The smb url of the file or directory to list the extended
1858 * @param list A pointer to a buffer in which the list of attributes for
1859 * the specified file or directory will be placed (unless
1862 * @param size The size of the buffer pointed to by list. This parameter
1863 * may also be zero, in which case the size of the buffer
1864 * required to hold all of the attribute names will be
1865 * returned, but nothing will be placed into the list buffer.
1867 * @return 0 on success, < 0 on error with errno set:
1868 * - EINVAL The client library is not properly initialized
1869 * - ENOMEM No memory was available for internal needs
1870 * - EPERM Permission was denied.
1871 * - ENOTSUP The referenced file system does not support
1872 * extended attributes
1874 * @note This function always returns all attribute names supported
1875 * by NT file systems, regardless of wether the referenced
1876 * file system supports extended attributes (e.g. a Windows
1877 * 2000 machine supports extended attributes if NTFS is used,
1878 * but not if FAT is used, and Windows 98 doesn't support
1879 * extended attributes at all. Whether this is a feature or
1880 * a bug is yet to be decided.
1882 int smbc_listxattr(const char *url
,
1886 /**@ingroup attribute
1887 * List the supported extended attribute names associated with a file The
1888 * POSIX function which this maps to would act on a symbolic link rather than
1889 * acting on what the symbolic link points to, but with no symbolic links in
1890 * SMB file systems, this function is functionally identical to
1893 * @param url The smb url of the file or directory to list the extended
1896 * @param list A pointer to a buffer in which the list of attributes for
1897 * the specified file or directory will be placed (unless
1900 * @param size The size of the buffer pointed to by list. This parameter
1901 * may also be zero, in which case the size of the buffer
1902 * required to hold all of the attribute names will be
1903 * returned, but nothing will be placed into the list buffer.
1905 * @return 0 on success, < 0 on error with errno set:
1906 * - EINVAL The client library is not properly initialized
1907 * - ENOMEM No memory was available for internal needs
1908 * - EPERM Permission was denied.
1909 * - ENOTSUP The referenced file system does not support
1910 * extended attributes
1912 * @note This function always returns all attribute names supported
1913 * by NT file systems, regardless of wether the referenced
1914 * file system supports extended attributes (e.g. a Windows
1915 * 2000 machine supports extended attributes if NTFS is used,
1916 * but not if FAT is used, and Windows 98 doesn't support
1917 * extended attributes at all. Whether this is a feature or
1918 * a bug is yet to be decided.
1920 int smbc_llistxattr(const char *url
,
1924 /**@ingroup attribute
1925 * List the supported extended attribute names associated with a file
1927 * @param fd A file descriptor associated with an open file (as
1928 * previously returned by smbc_open(), to get extended
1931 * @param list A pointer to a buffer in which the list of attributes for
1932 * the specified file or directory will be placed (unless
1935 * @param size The size of the buffer pointed to by list. This parameter
1936 * may also be zero, in which case the size of the buffer
1937 * required to hold all of the attribute names will be
1938 * returned, but nothing will be placed into the list buffer.
1940 * @return 0 on success, < 0 on error with errno set:
1941 * - EINVAL The client library is not properly initialized
1942 * - ENOMEM No memory was available for internal needs
1943 * - EPERM Permission was denied.
1944 * - ENOTSUP The referenced file system does not support
1945 * extended attributes
1947 * @note This function always returns all attribute names supported
1948 * by NT file systems, regardless of wether the referenced
1949 * file system supports extended attributes (e.g. a Windows
1950 * 2000 machine supports extended attributes if NTFS is used,
1951 * but not if FAT is used, and Windows 98 doesn't support
1952 * extended attributes at all. Whether this is a feature or
1953 * a bug is yet to be decided.
1955 int smbc_flistxattr(int fd
,
1960 * Print a file given the name in fname. It would be a URL ...
1962 * @param fname The URL of a file on a remote SMB server that the
1963 * caller wants printed
1965 * @param printq The URL of the print share to print the file to.
1967 * @return 0 on success, < 0 on error with errno set:
1969 * - EINVAL fname or printq was NULL or smbc_init not
1971 * and errors returned by smbc_open
1974 int smbc_print_file(const char *fname
, const char *printq
);
1977 * Open a print file that can be written to by other calls. This simply
1978 * does an smbc_open call after checking if there is a file name on the
1979 * URI. If not, a temporary name is added ...
1981 * @param fname The URL of the print share to print to?
1983 * @returns A file handle for the print file if successful.
1984 * Returns -1 if an error ocurred and errno has the values
1985 * - EINVAL fname was NULL or smbc_init not called.
1986 * - all errors returned by smbc_open
1989 int smbc_open_print_job(const char *fname
);
1992 * List the print jobs on a print share, for the moment, pass a callback
1994 * @param purl The url of the print share to list the jobs of
1996 * @param fn Callback function the receives printjob info
1998 * @return 0 on success, < 0 on error with errno set:
1999 * - EINVAL fname was NULL or smbc_init not called
2002 int smbc_list_print_jobs(const char *purl
, smbc_list_print_job_fn fn
);
2005 * Delete a print job
2007 * @param purl Url of the print share
2009 * @param id The id of the job to delete
2011 * @return 0 on success, < 0 on error with errno set:
2012 * - EINVAL fname was NULL or smbc_init not called
2014 * @todo what errno values are possible here?
2016 int smbc_unlink_print_job(const char *purl
, int id
);
2018 /**@ingroup callback
2019 * Remove a server from the cached server list it's unused.
2021 * @param context pointer to smb context
2023 * @param srv pointer to server to remove
2025 * @return On success, 0 is returned. 1 is returned if the server could not
2026 * be removed. Also useable outside libsmbclient.
2028 int smbc_remove_unused_server(SMBCCTX
* context
, SMBCSRV
* srv
);
2034 /**@ingroup directory
2035 * Convert strings of %xx to their single character equivalent.
2037 * @param dest A pointer to a buffer in which the resulting decoded
2038 * string should be placed. This may be a pointer to the
2039 * same buffer as src_segment.
2041 * @param src A pointer to the buffer containing the URL to be decoded.
2042 * Any %xx sequences herein are converted to their single
2043 * character equivalent. Each 'x' must be a valid hexadecimal
2044 * digit, or that % sequence is left undecoded.
2046 * @param max_dest_len
2047 * The size of the buffer pointed to by dest_segment.
2049 * @return The number of % sequences which could not be converted
2050 * due to lack of two following hexadecimal digits.
2056 smbc_urldecode(char *dest
, char * src
, size_t max_dest_len
);
2063 * Convert any characters not specifically allowed in a URL into their %xx
2066 * @param dest A pointer to a buffer in which the resulting encoded
2067 * string should be placed. Unlike smbc_urldecode(), this
2068 * must be a buffer unique from src.
2070 * @param src A pointer to the buffer containing the string to be encoded.
2071 * Any character not specifically allowed in a URL is converted
2072 * into its hexadecimal value and encoded as %xx.
2074 * @param max_dest_len
2075 * The size of the buffer pointed to by dest_segment.
2077 * @returns The remaining buffer length.
2083 smbc_urlencode(char * dest
, char * src
, int max_dest_len
);
2089 /**@ingroup directory
2090 * Return the version of the linked Samba code, and thus the version of the
2091 * libsmbclient code.
2093 * @return The version string.
2105 #endif /* SMBCLIENT_H_INCLUDED */