r599: Bug #1178. Make the libsmbclient routines callable by C++ programs. Also
[Samba/gebeck_regimport.git] / source3 / include / libsmbclient.h
blobaaa19cb191b09a25834caa19be49f258d7b1dae3
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
31 * documentation tool:
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
41 * Callback functions
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>
67 #include <sys/stat.h>
68 #include <fcntl.h>
69 #include <utime.h>
71 #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */
73 #define SMBC_WORKGROUP 1
74 #define SMBC_SERVER 2
75 #define SMBC_FILE_SHARE 3
76 #define SMBC_PRINTER_SHARE 4
77 #define SMBC_COMMS_SHARE 5
78 #define SMBC_IPC_SHARE 6
79 #define SMBC_DIR 7
80 #define SMBC_FILE 8
81 #define SMBC_LINK 9
83 /**@ingroup structure
84 * Structure that represents a directory entry.
87 struct smbc_dirent
89 /** Type of entity.
90 SMBC_WORKGROUP=1,
91 SMBC_SERVER=2,
92 SMBC_FILE_SHARE=3,
93 SMBC_PRINTER_SHARE=4,
94 SMBC_COMMS_SHARE=5,
95 SMBC_IPC_SHARE=6,
96 SMBC_DIR=7,
97 SMBC_FILE=8,
98 SMBC_LINK=9,*/
99 unsigned int smbc_type;
101 /** Length of this smbc_dirent in bytes
103 unsigned int dirlen;
104 /** The length of the comment string in bytes (includes null
105 * terminator)
107 unsigned int commentlen;
108 /** Points to the null terminated comment string
110 char *comment;
111 /** The length of the name string in bytes (includes null
112 * terminator)
114 unsigned int namelen;
115 /** Points to the null terminated name string
117 char name[1];
121 * Flags for smbc_setxattr()
122 * Specify a bitwise OR of these, or 0 to add or replace as necessary
124 #define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */
125 #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */
128 #ifndef ENOATTR
129 # define ENOATTR ENOENT /* No such attribute */
130 #endif
135 /**@ingroup structure
136 * Structure that represents a print job.
139 #ifndef _CLIENT_H
140 struct print_job_info
142 /** numeric ID of the print job
144 unsigned short id;
146 /** represents print job priority (lower numbers mean higher priority)
148 unsigned short priority;
150 /** Size of the print job
152 size_t size;
154 /** Name of the user that owns the print job
156 char user[128];
158 /** Name of the print job. This will have no name if an anonymous print
159 * file was opened. Ie smb://server/printer
161 char name[128];
163 /** Time the print job was spooled
165 time_t t;
167 #endif /* _CLIENT_H */
170 /**@ingroup structure
171 * Server handle
173 typedef struct _SMBCSRV SMBCSRV;
175 /**@ingroup structure
176 * File or directory handle
178 typedef struct _SMBCFILE SMBCFILE;
180 /**@ingroup structure
181 * File or directory handle
183 typedef struct _SMBCCTX SMBCCTX;
189 /**@ingroup callback
190 * Authentication callback function type.
192 * Type for the the authentication function called by the library to
193 * obtain authentication credentals
195 * @param srv Server being authenticated to
197 * @param shr Share being authenticated to
199 * @param wg Pointer to buffer containing a "hint" for the
200 * workgroup to be authenticated. Should be filled in
201 * with the correct workgroup if the hint is wrong.
203 * @param wglen The size of the workgroup buffer in bytes
205 * @param un Pointer to buffer containing a "hint" for the
206 * user name to be use for authentication. Should be
207 * filled in with the correct workgroup if the hint is
208 * wrong.
210 * @param unlen The size of the username buffer in bytes
212 * @param pw Pointer to buffer containing to which password
213 * copied
215 * @param pwlen The size of the password buffer in bytes
218 typedef void (*smbc_get_auth_data_fn)(const char *srv,
219 const char *shr,
220 char *wg, int wglen,
221 char *un, int unlen,
222 char *pw, int pwlen);
225 /**@ingroup callback
226 * Print job info callback function type.
228 * @param i pointer to print job information structure
231 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
234 /**@ingroup callback
235 * Check if a server is still good
237 * @param c pointer to smb context
239 * @param srv pointer to server to check
241 * @return 0 when connection is good. 1 on error.
244 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
246 /**@ingroup callback
247 * Remove a server if unused
249 * @param c pointer to smb context
251 * @param srv pointer to server to remove
253 * @return 0 on success. 1 on failure.
256 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
259 /**@ingroup callback
260 * Add a server to the cache system
262 * @param c pointer to smb context
264 * @param srv pointer to server to add
266 * @param server server name
268 * @param share share name
270 * @param workgroup workgroup used to connect
272 * @param username username used to connect
274 * @return 0 on success. 1 on failure.
277 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
278 const char * server, const char * share,
279 const char * workgroup, const char * username);
281 /**@ingroup callback
282 * Look up a server in the cache system
284 * @param c pointer to smb context
286 * @param server server name to match
288 * @param share share name to match
290 * @param workgroup workgroup to match
292 * @param username username to match
294 * @return pointer to SMBCSRV on success. NULL on failure.
297 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server,
298 const char * share, const char * workgroup,
299 const char * username);
301 /**@ingroup callback
302 * Check if a server is still good
304 * @param c pointer to smb context
306 * @param srv pointer to server to remove
308 * @return 0 when found and removed. 1 on failure.
311 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
314 /**@ingroup callback
315 * Try to remove all servers from the cache system and disconnect
317 * @param c pointer to smb context
319 * @return 0 when found and removed. 1 on failure.
322 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
327 /**@ingroup structure
328 * Structure that contains a client context information
329 * This structure is know as SMBCCTX
331 struct _SMBCCTX {
332 /** debug level
334 int debug;
336 /** netbios name used for making connections
338 char * netbios_name;
340 /** workgroup name used for making connections
342 char * workgroup;
344 /** username used for making connections
346 char * user;
348 /** timeout used for waiting on connections / response data (in milliseconds)
350 int timeout;
352 /** callable functions for files:
353 * For usage and return values see the smbc_* functions
355 SMBCFILE * (*open) (SMBCCTX *c, const char *fname, int flags, mode_t mode);
356 SMBCFILE * (*creat) (SMBCCTX *c, const char *path, mode_t mode);
357 ssize_t (*read) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
358 ssize_t (*write) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
359 int (*unlink) (SMBCCTX *c, const char *fname);
360 int (*rename) (SMBCCTX *ocontext, const char *oname,
361 SMBCCTX *ncontext, const char *nname);
362 off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence);
363 int (*stat) (SMBCCTX *c, const char *fname, struct stat *st);
364 int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st);
365 int (*close) (SMBCCTX *c, SMBCFILE *file);
367 /** callable functions for dirs
369 SMBCFILE * (*opendir) (SMBCCTX *c, const char *fname);
370 int (*closedir)(SMBCCTX *c, SMBCFILE *dir);
371 struct smbc_dirent * (*readdir)(SMBCCTX *c, SMBCFILE *dir);
372 int (*getdents)(SMBCCTX *c, SMBCFILE *dir,
373 struct smbc_dirent *dirp, int count);
374 int (*mkdir) (SMBCCTX *c, const char *fname, mode_t mode);
375 int (*rmdir) (SMBCCTX *c, const char *fname);
376 off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir);
377 int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset);
378 int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st);
379 int (*chmod)(SMBCCTX *c, const char *fname, mode_t mode);
380 int (*utimes)(SMBCCTX *c,
381 const char *fname, struct timeval *tbuf);
382 int (*setxattr)(SMBCCTX *context,
383 const char *fname,
384 const char *name,
385 const void *value,
386 size_t size,
387 int flags);
388 int (*getxattr)(SMBCCTX *context,
389 const char *fname,
390 const char *name,
391 const void *value,
392 size_t size);
393 int (*removexattr)(SMBCCTX *context,
394 const char *fname,
395 const char *name);
396 int (*listxattr)(SMBCCTX *context,
397 const char *fname,
398 char *list,
399 size_t size);
401 /** callable functions for printing
403 int (*print_file)(SMBCCTX *c_file, const char *fname,
404 SMBCCTX *c_print, const char *printq);
405 SMBCFILE * (*open_print_job)(SMBCCTX *c, const char *fname);
406 int (*list_print_jobs)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn);
407 int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id);
410 /** Callbacks
411 * These callbacks _always_ have to be initialized because they will not be checked
412 * at dereference for increased speed.
414 struct _smbc_callbacks {
415 /** authentication function callback: called upon auth requests
417 smbc_get_auth_data_fn auth_fn;
419 /** check if a server is still good
421 smbc_check_server_fn check_server_fn;
423 /** remove a server if unused
425 smbc_remove_unused_server_fn remove_unused_server_fn;
427 /** Cache subsystem
428 * For an example cache system see samba/source/libsmb/libsmb_cache.c
429 * Cache subsystem functions follow.
432 /** server cache addition
434 smbc_add_cached_srv_fn add_cached_srv_fn;
436 /** server cache lookup
438 smbc_get_cached_srv_fn get_cached_srv_fn;
440 /** server cache removal
442 smbc_remove_cached_srv_fn remove_cached_srv_fn;
444 /** server cache purging, try to remove all cached servers (disconnect)
446 smbc_purge_cached_fn purge_cached_fn;
447 } callbacks;
450 /** Space to store private data of the server cache.
452 struct smbc_server_cache * server_cache;
454 /** INTERNAL DATA
455 * do _NOT_ touch this from your program !
457 struct smbc_internal_data * internal;
462 /**@ingroup misc
463 * Create a new SBMCCTX (a context).
465 * Must be called before the context is passed to smbc_context_init()
467 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
468 * - ENOMEM Out of memory
470 * @see smbc_free_context(), smbc_init_context()
472 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
474 #ifdef __cplusplus
475 extern "C" {
476 #endif
477 SMBCCTX * smbc_new_context(void);
478 #ifdef __cplusplus
480 #endif
482 /**@ingroup misc
483 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
485 * The context will be deleted if possible.
487 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
489 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
492 * @return Returns 0 on succes. Returns 1 on failure with errno set:
493 * - EBUSY Server connections are still used, Files are open or cache
494 * could not be purged
495 * - EBADF context == NULL
497 * @see smbc_new_context()
499 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
500 * just before exit()'ing. When shutdown_ctx is 0, this function can be
501 * use in periodical cleanup functions for example.
503 #ifdef __cplusplus
504 extern "C" {
505 #endif
506 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
507 #ifdef __cplusplus
509 #endif
511 /**@ingroup misc
512 * Initialize a SBMCCTX (a context).
514 * Must be called before using any SMBCCTX API function
516 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
518 * @return A pointer to the given SMBCCTX on success, NULL on error with errno set:
519 * - EBADF NULL context given
520 * - ENOMEM Out of memory
521 * - ENOENT The smb.conf file would not load
523 * @see smbc_new_context()
525 * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe,
526 * but it might leak memory on smbc_context_init() failure. Avoid this.
527 * You'll have to call smbc_free_context() yourself on failure.
529 #ifdef __cplusplus
530 extern "C" {
531 #endif
532 SMBCCTX * smbc_init_context(SMBCCTX * context);
533 #ifdef __cplusplus
535 #endif
537 /**@ingroup misc
538 * Initialize the samba client library.
540 * Must be called before using any of the smbclient API function
542 * @param fn The function that will be called to obtaion
543 * authentication credentials.
545 * @param debug Allows caller to set the debug level. Can be
546 * changed in smb.conf file. Allows caller to set
547 * debugging if no smb.conf.
549 * @return 0 on success, < 0 on error with errno set:
550 * - ENOMEM Out of memory
551 * - ENOENT The smb.conf file would not load
555 #ifdef __cplusplus
556 extern "C" {
557 #endif
558 int smbc_init(smbc_get_auth_data_fn fn, int debug);
559 #ifdef __cplusplus
561 #endif
563 /**@ingroup misc
564 * Set or retrieve the compatibility library's context pointer
566 * @param context New context to use, or NULL. If a new context is provided,
567 * it must have allocated with smbc_new_context() and
568 * initialized with smbc_init_context(), followed, optionally,
569 * by some manual changes to some of the non-internal fields.
571 * @return The old context.
573 * @see smbc_new_context(), smbc_init_context(), smbc_init()
575 * @note This function may be called prior to smbc_init() to force
576 * use of the next context without any internal calls to
577 * smbc_new_context() or smbc_init_context(). It may also
578 * be called after smbc_init() has already called those two
579 * functions, to replace the existing context with a new one.
580 * Care should be taken, in this latter case, to ensure that
581 * the server cache and any data allocated by the
582 * authentication functions have been freed, if necessary.
585 #ifdef __cplusplus
586 extern "C" {
587 #endif
588 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
589 #ifdef __cplusplus
591 #endif
593 /**@ingroup file
594 * Open a file on an SMB server.
596 * @param furl The smb url of the file to be opened.
598 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
599 * request opening the file read-only,write-only
600 * or read/write. flags may also be bitwise-or'd with
601 * one or more of the following:
602 * O_CREAT - If the file does not exist it will be
603 * created.
604 * O_EXCL - When used with O_CREAT, if the file
605 * already exists it is an error and the open will
606 * fail.
607 * O_TRUNC - If the file already exists it will be
608 * truncated.
609 * O_APPEND The file is opened in append mode
611 * @param mode mode specifies the permissions to use if a new
612 * file is created. It is modified by the
613 * process's umask in the usual way: the permissions
614 * of the created file are (mode & ~umask)
616 * Not currently use, but there for future use.
617 * We will map this to SYSTEM, HIDDEN, etc bits
618 * that reverses the mapping that smbc_fstat does.
620 * @return Valid file handle, < 0 on error with errno set:
621 * - ENOMEM Out of memory
622 * - EINVAL if an invalid parameter passed, like no
623 * file, or smbc_init not called.
624 * - EEXIST pathname already exists and O_CREAT and
625 * O_EXCL were used.
626 * - EISDIR pathname refers to a directory and
627 * the access requested involved writing.
628 * - EACCES The requested access to the file is not
629 * allowed
630 * - ENODEV The requested share does not exist
631 * - ENOTDIR A file on the path is not a directory
632 * - ENOENT A directory component in pathname does
633 * not exist.
635 * @see smbc_creat()
637 * @note This call uses an underlying routine that may create
638 * a new connection to the server specified in the URL.
639 * If the credentials supplied in the URL, or via the
640 * auth_fn in the smbc_init call, fail, this call will
641 * try again with an empty username and password. This
642 * often gets mapped to the guest account on some machines.
644 #ifdef __cplusplus
645 extern "C" {
646 #endif
647 int smbc_open(const char *furl, int flags, mode_t mode);
648 #ifdef __cplusplus
650 #endif
652 /**@ingroup file
653 * Create a file on an SMB server.
655 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
657 * @param furl The smb url of the file to be created
659 * @param mode mode specifies the permissions to use if a new
660 * file is created. It is modified by the
661 * process's umask in the usual way: the permissions
662 * of the created file are (mode & ~umask)
664 * NOTE, the above is not true. We are dealing with
665 * an SMB server, which has no concept of a umask!
667 * @return Valid file handle, < 0 on error with errno set:
668 * - ENOMEM Out of memory
669 * - EINVAL if an invalid parameter passed, like no
670 * file, or smbc_init not called.
671 * - EEXIST pathname already exists and O_CREAT and
672 * O_EXCL were used.
673 * - EISDIR pathname refers to a directory and
674 * the access requested involved writing.
675 * - EACCES The requested access to the file is not
676 * allowed
677 * - ENOENT A directory component in pathname does
678 * not exist.
679 * - ENODEV The requested share does not exist.
680 * @see smbc_open()
683 #ifdef __cplusplus
684 extern "C" {
685 #endif
686 int smbc_creat(const char *furl, mode_t mode);
687 #ifdef __cplusplus
689 #endif
691 /**@ingroup file
692 * Read from a file using an opened file handle.
694 * @param fd Open file handle from smbc_open() or smbc_creat()
696 * @param buf Pointer to buffer to recieve read data
698 * @param bufsize Size of buf in bytes
700 * @return Number of bytes read, < 0 on error with errno set:
701 * - EISDIR fd refers to a directory
702 * - EBADF fd is not a valid file descriptor or
703 * is not open for reading.
704 * - EINVAL fd is attached to an object which is
705 * unsuitable for reading, or no buffer passed or
706 * smbc_init not called.
708 * @see smbc_open(), smbc_write()
711 #ifdef __cplusplus
712 extern "C" {
713 #endif
714 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
715 #ifdef __cplusplus
717 #endif
719 /**@ingroup file
720 * Write to a file using an opened file handle.
722 * @param fd Open file handle from smbc_open() or smbc_creat()
724 * @param buf Pointer to buffer to recieve read data
726 * @param bufsize Size of buf in bytes
728 * @return Number of bytes written, < 0 on error with errno set:
729 * - EISDIR fd refers to a directory.
730 * - EBADF fd is not a valid file descriptor or
731 * is not open for reading.
732 * - EINVAL fd is attached to an object which is
733 * unsuitable for reading, or no buffer passed or
734 * smbc_init not called.
736 * @see smbc_open(), smbc_read()
739 #ifdef __cplusplus
740 extern "C" {
741 #endif
742 ssize_t smbc_write(int fd, void *buf, size_t bufsize);
743 #ifdef __cplusplus
745 #endif
747 /**@ingroup file
748 * Seek to a specific location in a file.
750 * @param fd Open file handle from smbc_open() or smbc_creat()
752 * @param offset Offset in bytes from whence
754 * @param whence A location in the file:
755 * - SEEK_SET The offset is set to offset bytes from
756 * the beginning of the file
757 * - SEEK_CUR The offset is set to current location
758 * plus offset bytes.
759 * - SEEK_END The offset is set to the size of the
760 * file plus offset bytes.
762 * @return Upon successful completion, lseek returns the
763 * resulting offset location as measured in bytes
764 * from the beginning of the file. Otherwise, a value
765 * of (off_t)-1 is returned and errno is set to
766 * indicate the error:
767 * - EBADF Fildes is not an open file descriptor.
768 * - EINVAL Whence is not a proper value or smbc_init
769 * not called.
771 * @todo Are all the whence values really supported?
773 * @todo Are errno values complete and correct?
775 #ifdef __cplusplus
776 extern "C" {
777 #endif
778 off_t smbc_lseek(int fd, off_t offset, int whence);
779 #ifdef __cplusplus
781 #endif
783 /**@ingroup file
784 * Close an open file handle.
786 * @param fd The file handle to close
788 * @return 0 on success, < 0 on error with errno set:
789 * - EBADF fd isn't a valid open file descriptor
790 * - EINVAL smbc_init() failed or has not been called
792 * @see smbc_open(), smbc_creat()
794 #ifdef __cplusplus
795 extern "C" {
796 #endif
797 int smbc_close(int fd);
798 #ifdef __cplusplus
800 #endif
802 /**@ingroup directory
803 * Unlink (delete) a file or directory.
805 * @param furl The smb url of the file to delete
807 * @return 0 on success, < 0 on error with errno set:
808 * - EACCES or EPERM Write access to the directory
809 * containing pathname is not allowed or one
810 * of the directories in pathname did not allow
811 * search (execute) permission
812 * - ENOENT A directory component in pathname does
813 * not exist
814 * - EINVAL NULL was passed in the file param or
815 * smbc_init not called.
816 * - EACCES You do not have access to the file
817 * - ENOMEM Insufficient kernel memory was available
819 * @see smbc_rmdir()s
821 * @todo Are errno values complete and correct?
823 #ifdef __cplusplus
824 extern "C" {
825 #endif
826 int smbc_unlink(const char *furl);
827 #ifdef __cplusplus
829 #endif
831 /**@ingroup directory
832 * Rename or move a file or directory.
834 * @param ourl The original smb url (source url) of file or
835 * directory to be moved
837 * @param nurl The new smb url (destination url) of the file
838 * or directory after the move. Currently nurl must
839 * be on the same share as ourl.
841 * @return 0 on success, < 0 on error with errno set:
842 * - EISDIR nurl is an existing directory, but ourl is
843 * not a directory.
844 * - EEXIST nurl is a non-empty directory,
845 * i.e., contains entries other than "." and ".."
846 * - EINVAL The new url contained a path prefix
847 * of the old, or, more generally, an attempt was
848 * made to make a directory a subdirectory of itself
849 * or smbc_init not called.
850 * - ENOTDIR A component used as a directory in ourl
851 * or nurl path is not, in fact, a directory. Or,
852 * ourl is a directory, and newpath exists but is not
853 * a directory.
854 * - EACCES or EPERM Write access to the directory
855 * containing ourl or nurl is not allowed for the
856 * process's effective uid, or one of the
857 * directories in ourl or nurl did not allow search
858 * (execute) permission, or ourl was a directory
859 * and did not allow write permission.
860 * - ENOENT A directory component in ourl or nurl
861 * does not exist.
862 * - EXDEV Rename across shares not supported.
863 * - ENOMEM Insufficient kernel memory was available.
864 * - EEXIST The target file, nurl, already exists.
867 * @todo Are we going to support copying when urls are not on the same
868 * share? I say no... NOTE. I agree for the moment.
871 #ifdef __cplusplus
872 extern "C" {
873 #endif
874 int smbc_rename(const char *ourl, const char *nurl);
875 #ifdef __cplusplus
877 #endif
879 /**@ingroup directory
880 * Open a directory used to obtain directory entries.
882 * @param durl The smb url of the directory to open
884 * @return Valid directory handle. < 0 on error with errno set:
885 * - EACCES Permission denied.
886 * - EINVAL A NULL file/URL was passed, or the URL would
887 * not parse, or was of incorrect form or smbc_init not
888 * called.
889 * - ENOENT durl does not exist, or name is an
890 * - ENOMEM Insufficient memory to complete the
891 * operation.
892 * - ENOTDIR name is not a directory.
893 * - EPERM the workgroup could not be found.
894 * - ENODEV the workgroup or server could not be found.
896 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
899 #ifdef __cplusplus
900 extern "C" {
901 #endif
902 int smbc_opendir(const char *durl);
903 #ifdef __cplusplus
905 #endif
907 /**@ingroup directory
908 * Close a directory handle opened by smbc_opendir().
910 * @param dh Directory handle to close
912 * @return 0 on success, < 0 on error with errno set:
913 * - EBADF dh is an invalid directory handle
915 * @see smbc_opendir()
917 #ifdef __cplusplus
918 extern "C" {
919 #endif
920 int smbc_closedir(int dh);
921 #ifdef __cplusplus
923 #endif
925 /**@ingroup directory
926 * Get multiple directory entries.
928 * smbc_getdents() reads as many dirent structures from the an open
929 * directory handle into a specified memory area as will fit.
931 * @param dh Valid directory as returned by smbc_opendir()
933 * @param dirp pointer to buffer that will receive the directory
934 * entries.
936 * @param count The size of the dirp buffer in bytes
938 * @returns If any dirents returned, return will indicate the
939 * total size. If there were no more dirents available,
940 * 0 is returned. < 0 indicates an error.
941 * - EBADF Invalid directory handle
942 * - EINVAL Result buffer is too small or smbc_init
943 * not called.
944 * - ENOENT No such directory.
945 * @see , smbc_dirent, smbc_readdir(), smbc_open()
947 * @todo Are errno values complete and correct?
949 * @todo Add example code so people know how to parse buffers.
951 #ifdef __cplusplus
952 extern "C" {
953 #endif
954 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
955 #ifdef __cplusplus
957 #endif
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 #ifdef __cplusplus
972 extern "C" {
973 #endif
974 struct smbc_dirent* smbc_readdir(unsigned int dh);
975 #ifdef __cplusplus
977 #endif
979 /**@ingroup directory
980 * Get the current directory offset.
982 * smbc_telldir() may be used in conjunction with smbc_readdir() and
983 * smbc_lseekdir().
985 * @param dh Valid directory as returned by smbc_opendir()
987 * @return The current location in the directory stream or -1
988 * if an error occur. The current location is not
989 * an offset. Becuase of the implementation, it is a
990 * handle that allows the library to find the entry
991 * later.
992 * - EBADF dh is not a valid directory handle
993 * - EINVAL smbc_init() failed or has not been called
994 * - ENOTDIR if dh is not a directory
996 * @see smbc_readdir()
999 #ifdef __cplusplus
1000 extern "C" {
1001 #endif
1002 off_t smbc_telldir(int dh);
1003 #ifdef __cplusplus
1005 #endif
1007 /**@ingroup directory
1008 * lseek on directories.
1010 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
1011 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
1013 * @param fd Valid directory as returned by smbc_opendir()
1015 * @param offset The offset (as returned by smbc_telldir). Can be
1016 * NULL, in which case we will rewind
1018 * @return 0 on success, -1 on failure
1019 * - EBADF dh is not a valid directory handle
1020 * - ENOTDIR if dh is not a directory
1021 * - EINVAL offset did not refer to a valid dirent or
1022 * smbc_init not called.
1024 * @see smbc_telldir()
1027 * @todo In what does the reture and errno values mean?
1029 #ifdef __cplusplus
1030 extern "C" {
1031 #endif
1032 int smbc_lseekdir(int fd, off_t offset);
1033 #ifdef __cplusplus
1035 #endif
1037 /**@ingroup directory
1038 * Create a directory.
1040 * @param durl The url of the directory to create
1042 * @param mode Specifies the permissions to use. It is modified
1043 * by the process's umask in the usual way: the
1044 * permissions of the created file are (mode & ~umask).
1046 * @return 0 on success, < 0 on error with errno set:
1047 * - EEXIST directory url already exists
1048 * - EACCES The parent directory does not allow write
1049 * permission to the process, or one of the directories
1050 * - ENOENT A directory component in pathname does not
1051 * exist.
1052 * - EINVAL NULL durl passed or smbc_init not called.
1053 * - ENOMEM Insufficient memory was available.
1055 * @see smbc_rmdir()
1058 #ifdef __cplusplus
1059 extern "C" {
1060 #endif
1061 int smbc_mkdir(const char *durl, mode_t mode);
1062 #ifdef __cplusplus
1064 #endif
1066 /**@ingroup directory
1067 * Remove a directory.
1069 * @param durl The smb url of the directory to remove
1071 * @return 0 on success, < 0 on error with errno set:
1072 * - EACCES or EPERM Write access to the directory
1073 * containing pathname was not allowed.
1074 * - EINVAL durl is NULL or smbc_init not called.
1075 * - ENOENT A directory component in pathname does not
1076 * exist.
1077 * - ENOTEMPTY directory contains entries.
1078 * - ENOMEM Insufficient kernel memory was available.
1080 * @see smbc_mkdir(), smbc_unlink()
1082 * @todo Are errno values complete and correct?
1084 #ifdef __cplusplus
1085 extern "C" {
1086 #endif
1087 int smbc_rmdir(const char *durl);
1088 #ifdef __cplusplus
1090 #endif
1092 /**@ingroup attribute
1093 * Get information about a file or directory.
1095 * @param url The smb url to get information for
1097 * @param st pointer to a buffer that will be filled with
1098 * standard Unix struct stat information.
1100 * @return 0 on success, < 0 on error with errno set:
1101 * - ENOENT A component of the path file_name does not
1102 * exist.
1103 * - EINVAL a NULL url was passed or smbc_init not called.
1104 * - EACCES Permission denied.
1105 * - ENOMEM Out of memory
1106 * - ENOTDIR The target dir, url, is not a directory.
1108 * @see Unix stat()
1111 #ifdef __cplusplus
1112 extern "C" {
1113 #endif
1114 int smbc_stat(const char *url, struct stat *st);
1115 #ifdef __cplusplus
1117 #endif
1119 /**@ingroup attribute
1120 * Get file information via an file descriptor.
1122 * @param fd Open file handle from smbc_open() or smbc_creat()
1124 * @param st pointer to a buffer that will be filled with
1125 * standard Unix struct stat information.
1127 * @return EBADF filedes is bad.
1128 * - EACCES Permission denied.
1129 * - EBADF fd is not a valid file descriptor
1130 * - EINVAL Problems occurred in the underlying routines
1131 * or smbc_init not called.
1132 * - ENOMEM Out of memory
1134 * @see smbc_stat(), Unix stat()
1137 #ifdef __cplusplus
1138 extern "C" {
1139 #endif
1140 int smbc_fstat(int fd, struct stat *st);
1141 #ifdef __cplusplus
1143 #endif
1145 /**@ingroup attribue
1146 * Change the ownership of a file or directory.
1148 * @param url The smb url of the file or directory to change
1149 * ownership of.
1151 * @param owner I have no idea?
1153 * @param group I have not idea?
1155 * @return 0 on success, < 0 on error with errno set:
1156 * - EPERM The effective UID does not match the owner
1157 * of the file, and is not zero; or the owner or group
1158 * were specified incorrectly.
1159 * - ENOENT The file does not exist.
1160 * - ENOMEM Insufficient was available.
1161 * - ENOENT file or directory does not exist
1163 * @todo Are we actually going to be able to implement this function
1165 * @todo How do we abstract owner and group uid and gid?
1168 #ifdef __cplusplus
1169 extern "C" {
1170 #endif
1171 int smbc_chown(const char *url, uid_t owner, gid_t group);
1172 #ifdef __cplusplus
1174 #endif
1176 /**@ingroup attribute
1177 * Change the permissions of a file.
1179 * @param url The smb url of the file or directory to change
1180 * permissions of
1182 * @param mode The permissions to set:
1183 * - Put good explaination of permissions here!
1185 * @return 0 on success, < 0 on error with errno set:
1186 * - EPERM The effective UID does not match the owner
1187 * of the file, and is not zero
1188 * - ENOENT The file does not exist.
1189 * - ENOMEM Insufficient was available.
1190 * - ENOENT file or directory does not exist
1192 * @todo Actually implement this fuction?
1194 * @todo Are errno values complete and correct?
1196 #ifdef __cplusplus
1197 extern "C" {
1198 #endif
1199 int smbc_chmod(const char *url, mode_t mode);
1200 #ifdef __cplusplus
1202 #endif
1204 /**@ingroup attribute
1205 * Change the last modification time on a file
1207 * @param url The smb url of the file or directory to change
1208 * the modification time of
1210 * @param tbuf A timeval structure which contains the desired
1211 * modification time. NOTE: Only the tv_sec field is
1212 * used. The tv_usec (microseconds) portion is ignored.
1214 * @return 0 on success, < 0 on error with errno set:
1215 * - EINVAL The client library is not properly initialized
1216 * - EPERM Permission was denied.
1219 #ifdef __cplusplus
1220 extern "C" {
1221 #endif
1222 int smbc_utimes(const char *url, struct timeval *tbuf);
1223 #ifdef __cplusplus
1225 #endif
1227 #ifdef HAVE_UTIME_H
1228 /**@ingroup attribute
1229 * Change the last modification time on a file
1231 * @param url The smb url of the file or directory to change
1232 * the modification time of
1234 * @param utbuf A utimebuf structure which contains the desired
1235 * modification time. NOTE: Although the structure contains
1236 * an access time as well, the access time value is ignored.
1238 * @return 0 on success, < 0 on error with errno set:
1239 * - EINVAL The client library is not properly initialized
1240 * - ENOMEM No memory was available for internal needs
1241 * - EPERM Permission was denied.
1244 #ifdef __cplusplus
1245 extern "C" {
1246 #endif
1247 int smbc_utime(const char *fname, struct utimbuf *utbuf);
1248 #ifdef __cplusplus
1250 #endif
1251 #endif
1253 /**@ingroup attribute
1254 * Set extended attributes for a file. This is used for modifying a file's
1255 * security descriptor (i.e. owner, group, and access control list)
1257 * @param url The smb url of the file or directory to set extended
1258 * attributes for.
1260 * @param name The name of an attribute to be changed. Names are of
1261 * one of the following forms:
1263 * system.nt_sec_desc.<attribute name>
1264 * system.nt_sec_desc.*
1265 * system.nt_sec_desc.*+
1267 * where <attribute name> is one of:
1269 * revision
1270 * owner
1271 * owner+
1272 * group
1273 * group+
1274 * acl:<name or sid>
1275 * acl+:<name or sid>
1277 * In the forms "system.nt_sec_desc.*" and
1278 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1279 * literal, i.e. the string is provided exactly as shown, and
1280 * the value parameter should contain a complete security
1281 * descriptor with name:value pairs separated by tabs,
1282 * commas, or newlines (not spaces!).
1284 * The plus sign ('+') indicates that SIDs should be mapped
1285 * to names. Without the plus sign, SIDs are not mapped;
1286 * rather they are simply converted to a string format.
1288 * @param value The value to be assigned to the specified attribute name.
1289 * This buffer should contain only the attribute value if the
1290 * name was of the "system.nt_sec_desc.<attribute_name>"
1291 * form. If the name was of the "system.nt_sec_desc.*" form
1292 * then a complete security descriptor, with name:value pairs
1293 * separated by tabs, commas, or newlines (not spaces!),
1294 * should be provided in this value buffer. A complete
1295 * security descriptor will contain one or more entries
1296 * selected from the following:
1298 * REVISION:<revision number>
1299 * OWNER:<sid or name>
1300 * GROUP:<sid or name>
1301 * ACL:<sid or name>:<type>/<flags>/<mask>
1303 * The revision of the ACL specifies the internal Windows NT
1304 * ACL revision for the security descriptor. If not specified
1305 * it defaults to 1. Using values other than 1 may cause
1306 * strange behaviour.
1308 * The owner and group specify the owner and group sids for
1309 * the object. If the attribute name (either '*+' with a
1310 * complete security descriptor, or individual 'owner+' or
1311 * 'group+' attribute names) ended with a plus sign, the
1312 * specified name is resolved to a SID value, using the
1313 * server on which the file or directory resides. Otherwise,
1314 * the value should be provided in SID-printable format as
1315 * S-1-x-y-z, and is used directly. The <sid or name>
1316 * associated with the ACL: attribute should be provided
1317 * similarly.
1319 * @param size The number of the bytes of data in the value buffer
1321 * @param flags A bit-wise OR of zero or more of the following:
1322 * SMBC_XATTR_FLAG_CREATE -
1323 * fail if the named attribute already exists
1324 * SMBC_XATTR_FLAG_REPLACE -
1325 * fail if the attribute does not already exist
1327 * If neither flag is specified, the specified attributes
1328 * will be added or replace existing attributes of the same
1329 * name, as necessary.
1331 * @return 0 on success, < 0 on error with errno set:
1332 * - EINVAL The client library is not properly initialized
1333 * or one of the parameters is not of a correct
1334 * form
1335 * - ENOMEM No memory was available for internal needs
1336 * - EEXIST If the attribute already exists and the flag
1337 * SMBC_XATTR_FLAG_CREAT was specified
1338 * - ENOATTR If the attribute does not exist and the flag
1339 * SMBC_XATTR_FLAG_REPLACE was specified
1340 * - EPERM Permission was denied.
1341 * - ENOTSUP The referenced file system does not support
1342 * extended attributes
1344 * @note Attribute names are compared in a case-insensitive
1345 * fashion. All of the following are equivalent, although
1346 * the all-lower-case name is the preferred format:
1347 * system.nt_sec_desc.owner
1348 * SYSTEM.NT_SEC_DESC.OWNER
1349 * sYsTeM.nt_sEc_desc.owNER
1352 #ifdef __cplusplus
1353 extern "C" {
1354 #endif
1355 int smbc_setxattr(const char *url,
1356 const char *name,
1357 const void *value,
1358 size_t size,
1359 int flags);
1360 #ifdef __cplusplus
1362 #endif
1364 /**@ingroup attribute
1365 * Set extended attributes for a file. This is used for modifying a file's
1366 * security descriptor (i.e. owner, group, and access control list). The
1367 * POSIX function which this maps to would act on a symbolic link rather than
1368 * acting on what the symbolic link points to, but with no symbolic links in
1369 * SMB file systems, this function is functionally identical to
1370 * smbc_setxattr().
1372 * @param url The smb url of the file or directory to set extended
1373 * attributes for.
1375 * @param name The name of an attribute to be changed. Names are of
1376 * one of the following forms:
1378 * system.nt_sec_desc.<attribute name>
1379 * system.nt_sec_desc.*
1380 * system.nt_sec_desc.*+
1382 * where <attribute name> is one of:
1384 * revision
1385 * owner
1386 * owner+
1387 * group
1388 * group+
1389 * acl:<name or sid>
1390 * acl+:<name or sid>
1392 * In the forms "system.nt_sec_desc.*" and
1393 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1394 * literal, i.e. the string is provided exactly as shown, and
1395 * the value parameter should contain a complete security
1396 * descriptor with name:value pairs separated by tabs,
1397 * commas, or newlines (not spaces!).
1399 * The plus sign ('+') indicates that SIDs should be mapped
1400 * to names. Without the plus sign, SIDs are not mapped;
1401 * rather they are simply converted to a string format.
1403 * @param value The value to be assigned to the specified attribute name.
1404 * This buffer should contain only the attribute value if the
1405 * name was of the "system.nt_sec_desc.<attribute_name>"
1406 * form. If the name was of the "system.nt_sec_desc.*" form
1407 * then a complete security descriptor, with name:value pairs
1408 * separated by tabs, commas, or newlines (not spaces!),
1409 * should be provided in this value buffer. A complete
1410 * security descriptor will contain one or more entries
1411 * selected from the following:
1413 * REVISION:<revision number>
1414 * OWNER:<sid or name>
1415 * GROUP:<sid or name>
1416 * ACL:<sid or name>:<type>/<flags>/<mask>
1418 * The revision of the ACL specifies the internal Windows NT
1419 * ACL revision for the security descriptor. If not specified
1420 * it defaults to 1. Using values other than 1 may cause
1421 * strange behaviour.
1423 * The owner and group specify the owner and group sids for
1424 * the object. If the attribute name (either '*+' with a
1425 * complete security descriptor, or individual 'owner+' or
1426 * 'group+' attribute names) ended with a plus sign, the
1427 * specified name is resolved to a SID value, using the
1428 * server on which the file or directory resides. Otherwise,
1429 * the value should be provided in SID-printable format as
1430 * S-1-x-y-z, and is used directly. The <sid or name>
1431 * associated with the ACL: attribute should be provided
1432 * similarly.
1434 * @param size The number of the bytes of data in the value buffer
1436 * @param flags A bit-wise OR of zero or more of the following:
1437 * SMBC_XATTR_FLAG_CREATE -
1438 * fail if the named attribute already exists
1439 * SMBC_XATTR_FLAG_REPLACE -
1440 * fail if the attribute does not already exist
1442 * If neither flag is specified, the specified attributes
1443 * will be added or replace existing attributes of the same
1444 * name, as necessary.
1446 * @return 0 on success, < 0 on error with errno set:
1447 * - EINVAL The client library is not properly initialized
1448 * or one of the parameters is not of a correct
1449 * form
1450 * - ENOMEM No memory was available for internal needs
1451 * - EEXIST If the attribute already exists and the flag
1452 * SMBC_XATTR_FLAG_CREAT was specified
1453 * - ENOATTR If the attribute does not exist and the flag
1454 * SMBC_XATTR_FLAG_REPLACE was specified
1455 * - EPERM Permission was denied.
1456 * - ENOTSUP The referenced file system does not support
1457 * extended attributes
1459 * @note Attribute names are compared in a case-insensitive
1460 * fashion. All of the following are equivalent, although
1461 * the all-lower-case name is the preferred format:
1462 * system.nt_sec_desc.owner
1463 * SYSTEM.NT_SEC_DESC.OWNER
1464 * sYsTeM.nt_sEc_desc.owNER
1467 #ifdef __cplusplus
1468 extern "C" {
1469 #endif
1470 int smbc_lsetxattr(const char *url,
1471 const char *name,
1472 const void *value,
1473 size_t size,
1474 int flags);
1475 #ifdef __cplusplus
1477 #endif
1479 /**@ingroup attribute
1480 * Set extended attributes for a file. This is used for modifying a file's
1481 * security descriptor (i.e. owner, group, and access control list)
1483 * @param fd A file descriptor associated with an open file (as
1484 * previously returned by smbc_open(), to get extended
1485 * attributes for.
1487 * @param name The name of an attribute to be changed. Names are of
1488 * one of the following forms:
1490 * system.nt_sec_desc.<attribute name>
1491 * system.nt_sec_desc.*
1492 * system.nt_sec_desc.*+
1494 * where <attribute name> is one of:
1496 * revision
1497 * owner
1498 * owner+
1499 * group
1500 * group+
1501 * acl:<name or sid>
1502 * acl+:<name or sid>
1504 * In the forms "system.nt_sec_desc.*" and
1505 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1506 * literal, i.e. the string is provided exactly as shown, and
1507 * the value parameter should contain a complete security
1508 * descriptor with name:value pairs separated by tabs,
1509 * commas, or newlines (not spaces!).
1511 * The plus sign ('+') indicates that SIDs should be mapped
1512 * to names. Without the plus sign, SIDs are not mapped;
1513 * rather they are simply converted to a string format.
1515 * @param value The value to be assigned to the specified attribute name.
1516 * This buffer should contain only the attribute value if the
1517 * name was of the "system.nt_sec_desc.<attribute_name>"
1518 * form. If the name was of the "system.nt_sec_desc.*" form
1519 * then a complete security descriptor, with name:value pairs
1520 * separated by tabs, commas, or newlines (not spaces!),
1521 * should be provided in this value buffer. A complete
1522 * security descriptor will contain one or more entries
1523 * selected from the following:
1525 * REVISION:<revision number>
1526 * OWNER:<sid or name>
1527 * GROUP:<sid or name>
1528 * ACL:<sid or name>:<type>/<flags>/<mask>
1530 * The revision of the ACL specifies the internal Windows NT
1531 * ACL revision for the security descriptor. If not specified
1532 * it defaults to 1. Using values other than 1 may cause
1533 * strange behaviour.
1535 * The owner and group specify the owner and group sids for
1536 * the object. If the attribute name (either '*+' with a
1537 * complete security descriptor, or individual 'owner+' or
1538 * 'group+' attribute names) ended with a plus sign, the
1539 * specified name is resolved to a SID value, using the
1540 * server on which the file or directory resides. Otherwise,
1541 * the value should be provided in SID-printable format as
1542 * S-1-x-y-z, and is used directly. The <sid or name>
1543 * associated with the ACL: attribute should be provided
1544 * similarly.
1546 * @param size The number of the bytes of data in the value buffer
1548 * @param flags A bit-wise OR of zero or more of the following:
1549 * SMBC_XATTR_FLAG_CREATE -
1550 * fail if the named attribute already exists
1551 * SMBC_XATTR_FLAG_REPLACE -
1552 * fail if the attribute does not already exist
1554 * If neither flag is specified, the specified attributes
1555 * will be added or replace existing attributes of the same
1556 * name, as necessary.
1558 * @return 0 on success, < 0 on error with errno set:
1559 * - EINVAL The client library is not properly initialized
1560 * or one of the parameters is not of a correct
1561 * form
1562 * - ENOMEM No memory was available for internal needs
1563 * - EEXIST If the attribute already exists and the flag
1564 * SMBC_XATTR_FLAG_CREAT was specified
1565 * - ENOATTR If the attribute does not exist and the flag
1566 * SMBC_XATTR_FLAG_REPLACE was specified
1567 * - EPERM Permission was denied.
1568 * - ENOTSUP The referenced file system does not support
1569 * extended attributes
1571 * @note Attribute names are compared in a case-insensitive
1572 * fashion. All of the following are equivalent, although
1573 * the all-lower-case name is the preferred format:
1574 * system.nt_sec_desc.owner
1575 * SYSTEM.NT_SEC_DESC.OWNER
1576 * sYsTeM.nt_sEc_desc.owNER
1579 #ifdef __cplusplus
1580 extern "C" {
1581 #endif
1582 int smbc_fsetxattr(int fd,
1583 const char *name,
1584 const void *value,
1585 size_t size,
1586 int flags);
1587 #ifdef __cplusplus
1589 #endif
1591 /**@ingroup attribute
1592 * Get extended attributes for a file.
1594 * @param url The smb url of the file or directory to get extended
1595 * attributes for.
1597 * @param name The name of an attribute to be retrieved. Names are of
1598 * one of the following forms:
1600 * system.nt_sec_desc.<attribute name>
1601 * system.nt_sec_desc.*
1602 * system.nt_sec_desc.*+
1604 * where <attribute name> is one of:
1606 * revision
1607 * owner
1608 * owner+
1609 * group
1610 * group+
1611 * acl:<name or sid>
1612 * acl+:<name or sid>
1614 * In the forms "system.nt_sec_desc.*" and
1615 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1616 * literal, i.e. the string is provided exactly as shown, and
1617 * the value parameter will return a complete security
1618 * descriptor with name:value pairs separated by tabs,
1619 * commas, or newlines (not spaces!).
1621 * The plus sign ('+') indicates that SIDs should be mapped
1622 * to names. Without the plus sign, SIDs are not mapped;
1623 * rather they are simply converted to a string format.
1625 * @param value A pointer to a buffer in which the value of the specified
1626 * attribute will be placed (unless size is zero).
1628 * @param size The size of the buffer pointed to by value. This parameter
1629 * may also be zero, in which case the size of the buffer
1630 * required to hold the attribute value will be returned,
1631 * but nothing will be placed into the value buffer.
1633 * @return 0 on success, < 0 on error with errno set:
1634 * - EINVAL The client library is not properly initialized
1635 * or one of the parameters is not of a correct
1636 * form
1637 * - ENOMEM No memory was available for internal needs
1638 * - EEXIST If the attribute already exists and the flag
1639 * SMBC_XATTR_FLAG_CREAT was specified
1640 * - ENOATTR If the attribute does not exist and the flag
1641 * SMBC_XATTR_FLAG_REPLACE was specified
1642 * - EPERM Permission was denied.
1643 * - ENOTSUP The referenced file system does not support
1644 * extended attributes
1647 #ifdef __cplusplus
1648 extern "C" {
1649 #endif
1650 int smbc_getxattr(const char *url,
1651 const char *name,
1652 const void *value,
1653 size_t size);
1654 #ifdef __cplusplus
1656 #endif
1658 /**@ingroup attribute
1659 * Get extended attributes for a file. The POSIX function which this maps to
1660 * would act on a symbolic link rather than acting on what the symbolic link
1661 * points to, but with no symbolic links in SMB file systems, this function
1662 * is functionally identical to smbc_getxattr().
1664 * @param url The smb url of the file or directory to get extended
1665 * attributes for.
1667 * @param name The name of an attribute to be retrieved. Names are of
1668 * one of the following forms:
1670 * system.nt_sec_desc.<attribute name>
1671 * system.nt_sec_desc.*
1672 * system.nt_sec_desc.*+
1674 * where <attribute name> is one of:
1676 * revision
1677 * owner
1678 * owner+
1679 * group
1680 * group+
1681 * acl:<name or sid>
1682 * acl+:<name or sid>
1684 * In the forms "system.nt_sec_desc.*" and
1685 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1686 * literal, i.e. the string is provided exactly as shown, and
1687 * the value parameter will return a complete security
1688 * descriptor with name:value pairs separated by tabs,
1689 * commas, or newlines (not spaces!).
1691 * The plus sign ('+') indicates that SIDs should be mapped
1692 * to names. Without the plus sign, SIDs are not mapped;
1693 * rather they are simply converted to a string format.
1695 * @param value A pointer to a buffer in which the value of the specified
1696 * attribute will be placed (unless size is zero).
1698 * @param size The size of the buffer pointed to by value. This parameter
1699 * may also be zero, in which case the size of the buffer
1700 * required to hold the attribute value will be returned,
1701 * but nothing will be placed into the value buffer.
1703 * @return 0 on success, < 0 on error with errno set:
1704 * - EINVAL The client library is not properly initialized
1705 * or one of the parameters is not of a correct
1706 * form
1707 * - ENOMEM No memory was available for internal needs
1708 * - EEXIST If the attribute already exists and the flag
1709 * SMBC_XATTR_FLAG_CREAT was specified
1710 * - ENOATTR If the attribute does not exist and the flag
1711 * SMBC_XATTR_FLAG_REPLACE was specified
1712 * - EPERM Permission was denied.
1713 * - ENOTSUP The referenced file system does not support
1714 * extended attributes
1717 #ifdef __cplusplus
1718 extern "C" {
1719 #endif
1720 int smbc_lgetxattr(const char *url,
1721 const char *name,
1722 const void *value,
1723 size_t size);
1724 #ifdef __cplusplus
1726 #endif
1728 /**@ingroup attribute
1729 * Get extended attributes for a file.
1731 * @param fd A file descriptor associated with an open file (as
1732 * previously returned by smbc_open(), to get extended
1733 * attributes for.
1735 * @param name The name of an attribute to be retrieved. Names are of
1736 * one of the following forms:
1738 * system.nt_sec_desc.<attribute name>
1739 * system.nt_sec_desc.*
1740 * system.nt_sec_desc.*+
1742 * where <attribute name> is one of:
1744 * revision
1745 * owner
1746 * owner+
1747 * group
1748 * group+
1749 * acl:<name or sid>
1750 * acl+:<name or sid>
1752 * In the forms "system.nt_sec_desc.*" and
1753 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1754 * literal, i.e. the string is provided exactly as shown, and
1755 * the value parameter will return a complete security
1756 * descriptor with name:value pairs separated by tabs,
1757 * commas, or newlines (not spaces!).
1759 * The plus sign ('+') indicates that SIDs should be mapped
1760 * to names. Without the plus sign, SIDs are not mapped;
1761 * rather they are simply converted to a string format.
1763 * @param value A pointer to a buffer in which the value of the specified
1764 * attribute will be placed (unless size is zero).
1766 * @param size The size of the buffer pointed to by value. This parameter
1767 * may also be zero, in which case the size of the buffer
1768 * required to hold the attribute value will be returned,
1769 * but nothing will be placed into the value buffer.
1771 * @return 0 on success, < 0 on error with errno set:
1772 * - EINVAL The client library is not properly initialized
1773 * or one of the parameters is not of a correct
1774 * form
1775 * - ENOMEM No memory was available for internal needs
1776 * - EEXIST If the attribute already exists and the flag
1777 * SMBC_XATTR_FLAG_CREAT was specified
1778 * - ENOATTR If the attribute does not exist and the flag
1779 * SMBC_XATTR_FLAG_REPLACE was specified
1780 * - EPERM Permission was denied.
1781 * - ENOTSUP The referenced file system does not support
1782 * extended attributes
1785 #ifdef __cplusplus
1786 extern "C" {
1787 #endif
1788 int smbc_fgetxattr(int fd,
1789 const char *name,
1790 const void *value,
1791 size_t size);
1792 #ifdef __cplusplus
1794 #endif
1796 /**@ingroup attribute
1797 * Remove extended attributes for a file. This is used for modifying a file's
1798 * security descriptor (i.e. owner, group, and access control list)
1800 * @param url The smb url of the file or directory to remove the extended
1801 * attributes for.
1803 * @param name The name of an attribute to be removed. Names are of
1804 * one of the following forms:
1806 * system.nt_sec_desc.<attribute name>
1807 * system.nt_sec_desc.*
1808 * system.nt_sec_desc.*+
1810 * where <attribute name> is one of:
1812 * revision
1813 * owner
1814 * owner+
1815 * group
1816 * group+
1817 * acl:<name or sid>
1818 * acl+:<name or sid>
1820 * In the forms "system.nt_sec_desc.*" and
1821 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1822 * literal, i.e. the string is provided exactly as shown, and
1823 * the value parameter will return a complete security
1824 * descriptor with name:value pairs separated by tabs,
1825 * commas, or newlines (not spaces!).
1827 * The plus sign ('+') indicates that SIDs should be mapped
1828 * to names. Without the plus sign, SIDs are not mapped;
1829 * rather they are simply converted to a string format.
1831 * @return 0 on success, < 0 on error with errno set:
1832 * - EINVAL The client library is not properly initialized
1833 * - ENOMEM No memory was available for internal needs
1834 * - EPERM Permission was denied.
1835 * - ENOTSUP The referenced file system does not support
1836 * extended attributes
1839 #ifdef __cplusplus
1840 extern "C" {
1841 #endif
1842 int smbc_removexattr(const char *url,
1843 const char *name);
1844 #ifdef __cplusplus
1846 #endif
1848 /**@ingroup attribute
1849 * Remove extended attributes for a file. This is used for modifying a file's
1850 * security descriptor (i.e. owner, group, and access control list) The POSIX
1851 * function which this maps to would act on a symbolic link rather than acting
1852 * on what the symbolic link points to, but with no symbolic links in SMB file
1853 * systems, this function is functionally identical to smbc_removexattr().
1855 * @param url The smb url of the file or directory to remove the extended
1856 * attributes for.
1858 * @param name The name of an attribute to be removed. Names are of
1859 * one of the following forms:
1861 * system.nt_sec_desc.<attribute name>
1862 * system.nt_sec_desc.*
1863 * system.nt_sec_desc.*+
1865 * where <attribute name> is one of:
1867 * revision
1868 * owner
1869 * owner+
1870 * group
1871 * group+
1872 * acl:<name or sid>
1873 * acl+:<name or sid>
1875 * In the forms "system.nt_sec_desc.*" and
1876 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1877 * literal, i.e. the string is provided exactly as shown, and
1878 * the value parameter will return a complete security
1879 * descriptor with name:value pairs separated by tabs,
1880 * commas, or newlines (not spaces!).
1882 * The plus sign ('+') indicates that SIDs should be mapped
1883 * to names. Without the plus sign, SIDs are not mapped;
1884 * rather they are simply converted to a string format.
1886 * @return 0 on success, < 0 on error with errno set:
1887 * - EINVAL The client library is not properly initialized
1888 * - ENOMEM No memory was available for internal needs
1889 * - EPERM Permission was denied.
1890 * - ENOTSUP The referenced file system does not support
1891 * extended attributes
1894 #ifdef __cplusplus
1895 extern "C" {
1896 #endif
1897 int smbc_lremovexattr(const char *url,
1898 const char *name);
1899 #ifdef __cplusplus
1901 #endif
1903 /**@ingroup attribute
1904 * Remove extended attributes for a file. This is used for modifying a file's
1905 * security descriptor (i.e. owner, group, and access control list)
1907 * @param fd A file descriptor associated with an open file (as
1908 * previously returned by smbc_open(), to get extended
1909 * attributes for.
1911 * @param name The name of an attribute to be removed. Names are of
1912 * one of the following forms:
1914 * system.nt_sec_desc.<attribute name>
1915 * system.nt_sec_desc.*
1916 * system.nt_sec_desc.*+
1918 * where <attribute name> is one of:
1920 * revision
1921 * owner
1922 * owner+
1923 * group
1924 * group+
1925 * acl:<name or sid>
1926 * acl+:<name or sid>
1928 * In the forms "system.nt_sec_desc.*" and
1929 * "system.nt_sec_desc.*+", the asterisk and plus signs are
1930 * literal, i.e. the string is provided exactly as shown, and
1931 * the value parameter will return a complete security
1932 * descriptor with name:value pairs separated by tabs,
1933 * commas, or newlines (not spaces!).
1935 * The plus sign ('+') indicates that SIDs should be mapped
1936 * to names. Without the plus sign, SIDs are not mapped;
1937 * rather they are simply converted to a string format.
1939 * @return 0 on success, < 0 on error with errno set:
1940 * - EINVAL The client library is not properly initialized
1941 * - ENOMEM No memory was available for internal needs
1942 * - EPERM Permission was denied.
1943 * - ENOTSUP The referenced file system does not support
1944 * extended attributes
1947 #ifdef __cplusplus
1948 extern "C" {
1949 #endif
1950 int smbc_fremovexattr(int fd,
1951 const char *name);
1952 #ifdef __cplusplus
1954 #endif
1956 /**@ingroup attribute
1957 * List the supported extended attribute names associated with a file
1959 * @param url The smb url of the file or directory to list the extended
1960 * attributes for.
1962 * @param list A pointer to a buffer in which the list of attributes for
1963 * the specified file or directory will be placed (unless
1964 * size is zero).
1966 * @param size The size of the buffer pointed to by list. This parameter
1967 * may also be zero, in which case the size of the buffer
1968 * required to hold all of the attribute names will be
1969 * returned, but nothing will be placed into the list buffer.
1971 * @return 0 on success, < 0 on error with errno set:
1972 * - EINVAL The client library is not properly initialized
1973 * - ENOMEM No memory was available for internal needs
1974 * - EPERM Permission was denied.
1975 * - ENOTSUP The referenced file system does not support
1976 * extended attributes
1978 * @note This function always returns all attribute names supported
1979 * by NT file systems, regardless of wether the referenced
1980 * file system supports extended attributes (e.g. a Windows
1981 * 2000 machine supports extended attributes if NTFS is used,
1982 * but not if FAT is used, and Windows 98 doesn't support
1983 * extended attributes at all. Whether this is a feature or
1984 * a bug is yet to be decided.
1986 #ifdef __cplusplus
1987 extern "C" {
1988 #endif
1989 int smbc_listxattr(const char *url,
1990 char *list,
1991 size_t size);
1992 #ifdef __cplusplus
1994 #endif
1996 /**@ingroup attribute
1997 * List the supported extended attribute names associated with a file The
1998 * POSIX function which this maps to would act on a symbolic link rather than
1999 * acting on what the symbolic link points to, but with no symbolic links in
2000 * SMB file systems, this function is functionally identical to
2001 * smbc_listxattr().
2003 * @param url The smb url of the file or directory to list the extended
2004 * attributes for.
2006 * @param list A pointer to a buffer in which the list of attributes for
2007 * the specified file or directory will be placed (unless
2008 * size is zero).
2010 * @param size The size of the buffer pointed to by list. This parameter
2011 * may also be zero, in which case the size of the buffer
2012 * required to hold all of the attribute names will be
2013 * returned, but nothing will be placed into the list buffer.
2015 * @return 0 on success, < 0 on error with errno set:
2016 * - EINVAL The client library is not properly initialized
2017 * - ENOMEM No memory was available for internal needs
2018 * - EPERM Permission was denied.
2019 * - ENOTSUP The referenced file system does not support
2020 * extended attributes
2022 * @note This function always returns all attribute names supported
2023 * by NT file systems, regardless of wether the referenced
2024 * file system supports extended attributes (e.g. a Windows
2025 * 2000 machine supports extended attributes if NTFS is used,
2026 * but not if FAT is used, and Windows 98 doesn't support
2027 * extended attributes at all. Whether this is a feature or
2028 * a bug is yet to be decided.
2030 #ifdef __cplusplus
2031 extern "C" {
2032 #endif
2033 int smbc_llistxattr(const char *url,
2034 char *list,
2035 size_t size);
2036 #ifdef __cplusplus
2038 #endif
2040 /**@ingroup attribute
2041 * List the supported extended attribute names associated with a file
2043 * @param fd A file descriptor associated with an open file (as
2044 * previously returned by smbc_open(), to get extended
2045 * attributes for.
2047 * @param list A pointer to a buffer in which the list of attributes for
2048 * the specified file or directory will be placed (unless
2049 * size is zero).
2051 * @param size The size of the buffer pointed to by list. This parameter
2052 * may also be zero, in which case the size of the buffer
2053 * required to hold all of the attribute names will be
2054 * returned, but nothing will be placed into the list buffer.
2056 * @return 0 on success, < 0 on error with errno set:
2057 * - EINVAL The client library is not properly initialized
2058 * - ENOMEM No memory was available for internal needs
2059 * - EPERM Permission was denied.
2060 * - ENOTSUP The referenced file system does not support
2061 * extended attributes
2063 * @note This function always returns all attribute names supported
2064 * by NT file systems, regardless of wether the referenced
2065 * file system supports extended attributes (e.g. a Windows
2066 * 2000 machine supports extended attributes if NTFS is used,
2067 * but not if FAT is used, and Windows 98 doesn't support
2068 * extended attributes at all. Whether this is a feature or
2069 * a bug is yet to be decided.
2071 #ifdef __cplusplus
2072 extern "C" {
2073 #endif
2074 int smbc_flistxattr(int fd,
2075 char *list,
2076 size_t size);
2077 #ifdef __cplusplus
2079 #endif
2081 /**@ingroup print
2082 * Print a file given the name in fname. It would be a URL ...
2084 * @param fname The URL of a file on a remote SMB server that the
2085 * caller wants printed
2087 * @param printq The URL of the print share to print the file to.
2089 * @return 0 on success, < 0 on error with errno set:
2091 * - EINVAL fname or printq was NULL or smbc_init not
2092 * not called.
2093 * and errors returned by smbc_open
2096 #ifdef __cplusplus
2097 extern "C" {
2098 #endif
2099 int smbc_print_file(const char *fname, const char *printq);
2100 #ifdef __cplusplus
2102 #endif
2104 /**@ingroup print
2105 * Open a print file that can be written to by other calls. This simply
2106 * does an smbc_open call after checking if there is a file name on the
2107 * URI. If not, a temporary name is added ...
2109 * @param fname The URL of the print share to print to?
2111 * @returns A file handle for the print file if successful.
2112 * Returns -1 if an error ocurred and errno has the values
2113 * - EINVAL fname was NULL or smbc_init not called.
2114 * - all errors returned by smbc_open
2117 #ifdef __cplusplus
2118 extern "C" {
2119 #endif
2120 int smbc_open_print_job(const char *fname);
2121 #ifdef __cplusplus
2123 #endif
2125 /**@ingroup print
2126 * List the print jobs on a print share, for the moment, pass a callback
2128 * @param purl The url of the print share to list the jobs of
2130 * @param fn Callback function the receives printjob info
2132 * @return 0 on success, < 0 on error with errno set:
2133 * - EINVAL fname was NULL or smbc_init not called
2134 * - EACCES ???
2136 #ifdef __cplusplus
2137 extern "C" {
2138 #endif
2139 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
2140 #ifdef __cplusplus
2142 #endif
2144 /**@ingroup print
2145 * Delete a print job
2147 * @param purl Url of the print share
2149 * @param id The id of the job to delete
2151 * @return 0 on success, < 0 on error with errno set:
2152 * - EINVAL fname was NULL or smbc_init not called
2154 * @todo what errno values are possible here?
2156 #ifdef __cplusplus
2157 extern "C" {
2158 #endif
2159 int smbc_unlink_print_job(const char *purl, int id);
2160 #ifdef __cplusplus
2162 #endif
2164 /**@ingroup callback
2165 * Remove a server from the cached server list it's unused.
2167 * @param context pointer to smb context
2169 * @param srv pointer to server to remove
2171 * @return On success, 0 is returned. 1 is returned if the server could not
2172 * be removed. Also useable outside libsmbclient.
2174 #ifdef __cplusplus
2175 extern "C" {
2176 #endif
2177 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
2178 #ifdef __cplusplus
2180 #endif
2182 #endif /* SMBCLIENT_H_INCLUDED */