Now that I am running config.developer, I decided to get rif of some warnings:
[Samba/gbeck.git] / source3 / include / libsmbclient.h
blob0c905edcbcc6053419e01e1f88a56f9ccbc4bcf7
1 /*=====================================================================
2 Unix SMB/Netbios implementation.
3 SMB client library API definitions
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000
6 Copyright (C) John Terpsra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 =====================================================================*/
25 #ifndef SMBCLIENT_H_INCLUDED
26 #define SMBCLIENT_H_INCLUDED
28 /*-------------------------------------------------------------------*/
29 /* The following are special comments to instruct DOXYGEN (automated
30 * documentation tool:
32 /** \defgroup libsmbclient
34 /** \defgroup structure Data Structures Type and Constants
35 * \ingroup libsmbclient
36 * Data structures, types, and constants
38 /** \defgroup callback Callback function types
39 * \ingroup libsmbclient
40 * Callback functions
42 /** \defgroup file File Functions
43 * \ingroup libsmbclient
44 * Functions used to access individual file contents
46 /** \defgroup directory Directory Functions
47 * \ingroup libsmbclient
48 * Functions used to access directory entries
50 /** \defgroup attribute Attributes Functions
51 * \ingroup libsmbclient
52 * Functions used to view or change file and directory attributes
54 /** \defgroup print Print Functions
55 * \ingroup libsmbclient
56 * Functions used to access printing functionality
58 /** \defgroup misc Miscellaneous Functions
59 * \ingroup libsmbclient
60 * Functions that don't fit in to other categories
62 /*-------------------------------------------------------------------*/
64 /* Make sure we have the following includes for now ... */
65 #include <sys/types.h>
66 #include <sys/stat.h>
67 #include <fcntl.h>
69 #define SMBC_WORKGROUP 1
70 #define SMBC_SERVER 2
71 #define SMBC_FILE_SHARE 3
72 #define SMBC_PRINTER_SHARE 4
73 #define SMBC_COMMS_SHARE 5
74 #define SMBC_IPC_SHARE 6
75 #define SMBC_DIR 7
76 #define SMBC_FILE 8
77 #define SMBC_LINK 9
79 /**@ingroup structure
80 * Structure that represents a directory entry.
83 struct smbc_dirent
85 /** Type of entity.
86 SMBC_WORKGROUP=1,
87 SMBC_SERVER=2,
88 SMBC_FILE_SHARE=3,
89 SMBC_PRINTER_SHARE=4,
90 SMBC_COMMS_SHARE=5,
91 SMBC_IPC_SHARE=6,
92 SMBC_DIR=7,
93 SMBC_FILE=8,
94 SMBC_LINK=9,*/
95 unsigned int smbc_type;
97 /** Length of this smbc_dirent in bytes
99 unsigned int dirlen;
100 /** The length of the comment string in bytes (includes null
101 * terminator)
103 unsigned int commentlen;
104 /** Points to the null terminated comment string
106 char *comment;
107 /** The length of the name string in bytes (includes null
108 * terminator)
110 unsigned int namelen;
111 /** Points to the null terminated name string
113 char name[1];
117 /**@ingroup structure
118 * Structure that represents a print job.
121 #ifndef _CLIENT_H
122 struct print_job_info
124 /** numeric ID of the print job
126 unsigned short id;
128 /** represents print job priority (lower numbers mean higher priority)
130 unsigned short priority;
132 /** Size of the print job
134 size_t size;
136 /** Name of the user that owns the print job
138 char user[128];
140 /** Name of the print job. This will have no name if an anonymous print
141 * file was opened. Ie smb://server/printer
143 char name[128];
145 /** Time the print job was spooled
147 time_t t;
149 #endif /* _CLIENT_H */
152 /**@ingroup structure
153 * Server handle
155 typedef struct _SMBCSRV SMBCSRV;
157 /**@ingroup structure
158 * File or directory handle
160 typedef struct _SMBCFILE SMBCFILE;
162 /**@ingroup structure
163 * File or directory handle
165 typedef struct _SMBCCTX SMBCCTX;
171 /**@ingroup callback
172 * Authentication callback function type.
174 * Type for the the authentication function called by the library to
175 * obtain authentication credentals
177 * @param srv Server being authenticated to
179 * @param shr Share being authenticated to
181 * @param wg Pointer to buffer containing a "hint" for the
182 * workgroup to be authenticated. Should be filled in
183 * with the correct workgroup if the hint is wrong.
185 * @param wglen The size of the workgroup buffer in bytes
187 * @param un Pointer to buffer containing a "hint" for the
188 * user name to be use for authentication. Should be
189 * filled in with the correct workgroup if the hint is
190 * wrong.
192 * @param unlen The size of the username buffer in bytes
194 * @param pw Pointer to buffer containing to which password
195 * copied
197 * @param pwlen The size of the password buffer in bytes
200 typedef void (*smbc_get_auth_data_fn)(const char *srv,
201 const char *shr,
202 char *wg, int wglen,
203 char *un, int unlen,
204 char *pw, int pwlen);
207 /**@ingroup callback
208 * Print job info callback function type.
210 * @param i pointer to print job information structure
213 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
216 /**@ingroup callback
217 * Check if a server is still good
219 * @param c pointer to smb context
221 * @param srv pointer to server to check
223 * @return 0 when connection is good. 1 on error.
226 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
228 /**@ingroup callback
229 * Remove a server if unused
231 * @param c pointer to smb context
233 * @param srv pointer to server to remove
235 * @return 0 on success. 1 on failure.
238 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
241 /**@ingroup callback
242 * Add a server to the cache system
244 * @param c pointer to smb context
246 * @param srv pointer to server to add
248 * @param server server name
250 * @param share share name
252 * @param workgroup workgroup used to connect
254 * @param username username used to connect
256 * @return 0 on success. 1 on failure.
259 typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv,
260 char * server, char * share,
261 char * workgroup, char * username);
264 /**@ingroup callback
265 * Look up a server in the cache system
267 * @param c pointer to smb context
269 * @param server server name to match
271 * @param share share name to match
273 * @param workgroup workgroup to match
275 * @param username username to match
277 * @return pointer to SMBCSRV on success. NULL on failure.
280 typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, char * server,
281 char * share, char * workgroup, char * username);
284 /**@ingroup callback
285 * Check if a server is still good
287 * @param c pointer to smb context
289 * @param srv pointer to server to remove
291 * @return 0 when found and removed. 1 on failure.
294 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
297 /**@ingroup callback
298 * Try to remove all servers from the cache system and disconnect
300 * @param c pointer to smb context
302 * @return 0 when found and removed. 1 on failure.
305 typedef int (*smbc_purge_cached_fn) (SMBCCTX * c);
310 /**@ingroup structure
311 * Structure that contains a client context information
312 * This structure is know as SMBCCTX
314 struct _SMBCCTX {
315 /** debug level
317 int debug;
319 /** netbios name used for making connections
321 char * netbios_name;
323 /** workgroup name used for making connections
325 char * workgroup;
327 /** username used for making connections
329 char * user;
331 /** timeout used for waiting on connections / response data (in milliseconds)
333 int timeout;
335 /** callable functions for files:
336 * For usage and return values see the smbc_* functions
338 SMBCFILE * (*open) (SMBCCTX *c, const char *fname, int flags, mode_t mode);
339 SMBCFILE * (*creat) (SMBCCTX *c, const char *path, mode_t mode);
340 ssize_t (*read) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
341 ssize_t (*write) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count);
342 int (*unlink) (SMBCCTX *c, const char *fname);
343 int (*rename) (SMBCCTX *ocontext, const char *oname,
344 SMBCCTX *ncontext, const char *nname);
345 off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence);
346 int (*stat) (SMBCCTX *c, const char *fname, struct stat *st);
347 int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st);
348 int (*close) (SMBCCTX *c, SMBCFILE *file);
350 /** callable functions for dirs
352 SMBCFILE * (*opendir) (SMBCCTX *c, const char *fname);
353 int (*closedir)(SMBCCTX *c, SMBCFILE *dir);
354 struct smbc_dirent * (*readdir)(SMBCCTX *c, SMBCFILE *dir);
355 int (*getdents)(SMBCCTX *c, SMBCFILE *dir,
356 struct smbc_dirent *dirp, int count);
357 int (*mkdir) (SMBCCTX *c, const char *fname, mode_t mode);
358 int (*rmdir) (SMBCCTX *c, const char *fname);
359 off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir);
360 int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset);
361 int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st);
363 /** callable functions for printing
365 int (*print_file)(SMBCCTX *c_file, const char *fname,
366 SMBCCTX *c_print, const char *printq);
367 SMBCFILE * (*open_print_job)(SMBCCTX *c, const char *fname);
368 int (*list_print_jobs)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn);
369 int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id);
372 /** Callbacks
373 * These callbacks _always_ have to be initialized because they will not be checked
374 * at dereference for increased speed.
376 struct _smbc_callbacks {
377 /** authentication function callback: called upon auth requests
379 smbc_get_auth_data_fn auth_fn;
381 /** check if a server is still good
383 smbc_check_server_fn check_server_fn;
385 /** remove a server if unused
387 smbc_remove_unused_server_fn remove_unused_server_fn;
389 /** Cache subsystem
390 * For an example cache system see samba/source/libsmb/libsmb_cache.c
391 * Cache subsystem functions follow.
394 /** server cache addition
396 smbc_add_cached_srv_fn add_cached_srv_fn;
398 /** server cache lookup
400 smbc_get_cached_srv_fn get_cached_srv_fn;
402 /** server cache removal
404 smbc_remove_cached_srv_fn remove_cached_srv_fn;
406 /** server cache purging, try to remove all cached servers (disconnect)
408 smbc_purge_cached_fn purge_cached_fn;
409 } callbacks;
412 /** Space to store private data of the server cache.
414 struct smbc_server_cache * server_cache;
416 /** INTERNAL DATA
417 * do _NOT_ touch this from your program !
419 struct smbc_internal_data * internal;
424 /**@ingroup misc
425 * Create a new SBMCCTX (a context).
427 * Must be called before the context is passed to smbc_context_init()
429 * @return The given SMBCCTX pointer on success, NULL on error with errno set:
430 * - ENOMEM Out of memory
432 * @see smbc_free_context(), smbc_init_context()
434 * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer !
436 SMBCCTX * smbc_new_context(void);
438 /**@ingroup misc
439 * Delete a SBMCCTX (a context) acquired from smbc_new_context().
441 * The context will be deleted if possible.
443 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
445 * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy.
448 * @return Returns 0 on succes. Returns 1 on failure with errno set:
449 * - EBUSY Server connections are still used, Files are open or cache
450 * could not be purged
451 * - EBADF context == NULL
453 * @see smbc_new_context()
455 * @note It is advised to clean up all the contexts with shutdown_ctx set to 1
456 * just before exit()'ing. When shutdown_ctx is 0, this function can be
457 * use in periodical cleanup functions for example.
459 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
462 /**@ingroup misc
463 * Initialize a SBMCCTX (a context).
465 * Must be called before using any SMBCCTX API function
467 * @param context A pointer to a SMBCCTX obtained from smbc_new_context()
469 * @return A pointer to the given SMBCCTX on success, NULL on error with errno set:
470 * - EBADF NULL context given
471 * - ENOMEM Out of memory
472 * - ENOENT The smb.conf file would not load
474 * @see smbc_new_context()
476 * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe,
477 * but it might leak memory on smbc_context_init() failure. Avoid this.
478 * You'll have to call smbc_free_context() yourself on failure.
481 SMBCCTX * smbc_init_context(SMBCCTX * context);
483 /**@ingroup misc
484 * Initialize the samba client library.
486 * Must be called before using any of the smbclient API function
488 * @param fn The function that will be called to obtaion
489 * authentication credentials.
491 * @param debug Allows caller to set the debug level. Can be
492 * changed in smb.conf file. Allows caller to set
493 * debugging if no smb.conf.
495 * @return 0 on success, < 0 on error with errno set:
496 * - ENOMEM Out of memory
497 * - ENOENT The smb.conf file would not load
501 int smbc_init(smbc_get_auth_data_fn fn, int debug);
503 /**@ingroup file
504 * Open a file on an SMB server.
506 * @param furl The smb url of the file to be opened.
508 * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which
509 * request opening the file read-only,write-only
510 * or read/write. flags may also be bitwise-or'd with
511 * one or more of the following:
512 * O_CREAT - If the file does not exist it will be
513 * created.
514 * O_EXCL - When used with O_CREAT, if the file
515 * already exists it is an error and the open will
516 * fail.
517 * O_TRUNC - If the file already exists it will be
518 * truncated.
519 * O_APPEND The file is opened in append mode
521 * @param mode mode specifies the permissions to use if a new
522 * file is created. It is modified by the
523 * process's umask in the usual way: the permissions
524 * of the created file are (mode & ~umask)
526 * Not currently use, but there for future use.
527 * We will map this to SYSTEM, HIDDEN, etc bits
528 * that reverses the mapping that smbc_fstat does.
530 * @return Valid file handle, < 0 on error with errno set:
531 * - ENOMEM Out of memory
532 * - EINVAL if an invalid parameter passed, like no
533 * file, or smbc_init not called.
534 * - EEXIST pathname already exists and O_CREAT and
535 * O_EXCL were used.
536 * - EISDIR pathname refers to a directory and
537 * the access requested involved writing.
538 * - EACCES The requested access to the file is not
539 * allowed
540 * - ENODEV The requested share does not exist
541 * - ENOTDIR A file on the path is not a directory
542 * - ENOENT A directory component in pathname does
543 * not exist.
545 * @see smbc_creat()
547 * @note This call uses an underlying routine that may create
548 * a new connection to the server specified in the URL.
549 * If the credentials supplied in the URL, or via the
550 * auth_fn in the smbc_init call, fail, this call will
551 * try again with an empty username and password. This
552 * often gets mapped to the guest account on some machines.
555 int smbc_open(const char *furl, int flags, mode_t mode);
557 /**@ingroup file
558 * Create a file on an SMB server.
560 * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC
562 * @param furl The smb url of the file to be created
564 * @param mode mode specifies the permissions to use if a new
565 * file is created. It is modified by the
566 * process's umask in the usual way: the permissions
567 * of the created file are (mode & ~umask)
569 * NOTE, the above is not true. We are dealing with
570 * an SMB server, which has no concept of a umask!
572 * @return Valid file handle, < 0 on error with errno set:
573 * - ENOMEM Out of memory
574 * - EINVAL if an invalid parameter passed, like no
575 * file, or smbc_init not called.
576 * - EEXIST pathname already exists and O_CREAT and
577 * O_EXCL were used.
578 * - EISDIR pathname refers to a directory and
579 * the access requested involved writing.
580 * - EACCES The requested access to the file is not
581 * allowed
582 * - ENOENT A directory component in pathname does
583 * not exist.
584 * - ENODEV The requested share does not exist.
585 * @see smbc_open()
589 int smbc_creat(const char *furl, mode_t mode);
591 /**@ingroup file
592 * Read from a file using an opened file handle.
594 * @param fd Open file handle from smbc_open() or smbc_creat()
596 * @param buf Pointer to buffer to recieve read data
598 * @param bufsize Size of buf in bytes
600 * @return Number of bytes read, < 0 on error with errno set:
601 * - EISDIR fd refers to a directory
602 * - EBADF fd is not a valid file descriptor or
603 * is not open for reading.
604 * - EINVAL fd is attached to an object which is
605 * unsuitable for reading, or no buffer passed or
606 * smbc_init not called.
608 * @see smbc_open(), smbc_write()
611 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
614 /**@ingroup file
615 * Write to a file using an opened file handle.
617 * @param fd Open file handle from smbc_open() or smbc_creat()
619 * @param buf Pointer to buffer to recieve read data
621 * @param bufsize Size of buf in bytes
623 * @return Number of bytes written, < 0 on error with errno set:
624 * - EISDIR fd refers to a directory.
625 * - EBADF fd is not a valid file descriptor or
626 * is not open for reading.
627 * - EINVAL fd is attached to an object which is
628 * unsuitable for reading, or no buffer passed or
629 * smbc_init not called.
631 * @see smbc_open(), smbc_read()
634 ssize_t smbc_write(int fd, void *buf, size_t bufsize);
637 /**@ingroup file
638 * Seek to a specific location in a file.
640 * @param fd Open file handle from smbc_open() or smbc_creat()
642 * @param offset Offset in bytes from whence
644 * @param whence A location in the file:
645 * - SEEK_SET The offset is set to offset bytes from
646 * the beginning of the file
647 * - SEEK_CUR The offset is set to current location
648 * plus offset bytes.
649 * - SEEK_END The offset is set to the size of the
650 * file plus offset bytes.
652 * @return Upon successful completion, lseek returns the
653 * resulting offset location as measured in bytes
654 * from the beginning of the file. Otherwise, a value
655 * of (off_t)-1 is returned and errno is set to
656 * indicate the error:
657 * - EBADF Fildes is not an open file descriptor.
658 * - EINVAL Whence is not a proper value or smbc_init
659 * not called.
661 * @todo Are all the whence values really supported?
663 * @todo Are errno values complete and correct?
665 off_t smbc_lseek(int fd, off_t offset, int whence);
668 /**@ingroup file
669 * Close an open file handle.
671 * @param fd The file handle to close
673 * @return 0 on success, < 0 on error with errno set:
674 * - EBADF fd isn't a valid open file descriptor
675 * - EINVAL smbc_init() failed or has not been called
677 * @see smbc_open(), smbc_creat()
679 int smbc_close(int fd);
682 /**@ingroup directory
683 * Unlink (delete) a file or directory.
685 * @param furl The smb url of the file to delete
687 * @return 0 on success, < 0 on error with errno set:
688 * - EACCES or EPERM Write access to the directory
689 * containing pathname is not allowed or one
690 * of the directories in pathname did not allow
691 * search (execute) permission
692 * - ENOENT A directory component in pathname does
693 * not exist
694 * - EINVAL NULL was passed in the file param or
695 * smbc_init not called.
696 * - EACCES You do not have access to the file
697 * - ENOMEM Insufficient kernel memory was available
699 * @see smbc_rmdir()s
701 * @todo Are errno values complete and correct?
703 int smbc_unlink(const char *furl);
706 /**@ingroup directory
707 * Rename or move a file or directory.
709 * @param ourl The original smb url (source url) of file or
710 * directory to be moved
712 * @param nurl The new smb url (destination url) of the file
713 * or directory after the move. Currently nurl must
714 * be on the same share as ourl.
716 * @return 0 on success, < 0 on error with errno set:
717 * - EISDIR nurl is an existing directory, but ourl is
718 * not a directory.
719 * - EEXIST nurl is a non-empty directory,
720 * i.e., contains entries other than "." and ".."
721 * - EINVAL The new url contained a path prefix
722 * of the old, or, more generally, an attempt was
723 * made to make a directory a subdirectory of itself
724 * or smbc_init not called.
725 * - ENOTDIR A component used as a directory in ourl
726 * or nurl path is not, in fact, a directory. Or,
727 * ourl is a directory, and newpath exists but is not
728 * a directory.
729 * - EACCES or EPERM Write access to the directory
730 * containing ourl or nurl is not allowed for the
731 * process's effective uid, or one of the
732 * directories in ourl or nurl did not allow search
733 * (execute) permission, or ourl was a directory
734 * and did not allow write permission.
735 * - ENOENT A directory component in ourl or nurl
736 * does not exist.
737 * - EXDEV Rename across shares not supported.
738 * - ENOMEM Insufficient kernel memory was available.
739 * - EEXIST The target file, nurl, already exists.
742 * @todo Are we going to support copying when urls are not on the same
743 * share? I say no... NOTE. I agree for the moment.
746 int smbc_rename(const char *ourl, const char *nurl);
749 /**@ingroup directory
750 * Open a directory used to obtain directory entries.
752 * @param durl The smb url of the directory to open
754 * @return Valid directory handle. < 0 on error with errno set:
755 * - EACCES Permission denied.
756 * - EINVAL A NULL file/URL was passed, or the URL would
757 * not parse, or was of incorrect form or smbc_init not
758 * called.
759 * - ENOENT durl does not exist, or name is an
760 * - ENOMEM Insufficient memory to complete the
761 * operation.
762 * - ENOTDIR name is not a directory.
763 * - EPERM the workgroup could not be found.
764 * - ENODEV the workgroup or server could not be found.
766 * @see smbc_getdents(), smbc_readdir(), smbc_closedir()
769 int smbc_opendir(const char *durl);
772 /**@ingroup directory
773 * Close a directory handle opened by smbc_opendir().
775 * @param dh Directory handle to close
777 * @return 0 on success, < 0 on error with errno set:
778 * - EBADF dh is an invalid directory handle
780 * @see smbc_opendir()
782 int smbc_closedir(int dh);
785 /**@ingroup directory
786 * Get multiple directory entries.
788 * smbc_getdents() reads as many dirent structures from the an open
789 * directory handle into a specified memory area as will fit.
791 * @param dh Valid directory as returned by smbc_opendir()
793 * @param dirp pointer to buffer that will receive the directory
794 * entries.
796 * @param count The size of the dirp buffer in bytes
798 * @returns If any dirents returned, return will indicate the
799 * total size. If there were no more dirents available,
800 * 0 is returned. < 0 indicates an error.
801 * - EBADF Invalid directory handle
802 * - EINVAL Result buffer is too small or smbc_init
803 * not called.
804 * - ENOENT No such directory.
805 * @see , smbc_dirent, smbc_readdir(), smbc_open()
807 * @todo Are errno values complete and correct?
809 * @todo Add example code so people know how to parse buffers.
811 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
814 /**@ingroup directory
815 * Get a single directory entry.
817 * @param dh Valid directory as returned by smbc_opendir()
819 * @return A pointer to a smbc_dirent structure, or NULL if an
820 * error occurs or end-of-directory is reached:
821 * - EBADF Invalid directory handle
822 * - EINVAL smbc_init() failed or has not been called
824 * @see smbc_dirent, smbc_getdents(), smbc_open()
826 struct smbc_dirent* smbc_readdir(unsigned int dh);
829 /**@ingroup directory
830 * Get the current directory offset.
832 * smbc_telldir() may be used in conjunction with smbc_readdir() and
833 * smbc_lseekdir().
835 * @param dh Valid directory as returned by smbc_opendir()
837 * @return The current location in the directory stream or -1
838 * if an error occur. The current location is not
839 * an offset. Becuase of the implementation, it is a
840 * handle that allows the library to find the entry
841 * later.
842 * - EBADF dh is not a valid directory handle
843 * - EINVAL smbc_init() failed or has not been called
844 * - ENOTDIR if dh is not a directory
846 * @see smbc_readdir()
849 off_t smbc_telldir(int dh);
852 /**@ingroup directory
853 * lseek on directories.
855 * smbc_lseekdir() may be used in conjunction with smbc_readdir() and
856 * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL))
858 * @param fd Valid directory as returned by smbc_opendir()
860 * @param offset The offset (as returned by smbc_telldir). Can be
861 * NULL, in which case we will rewind
863 * @return 0 on success, -1 on failure
864 * - EBADF dh is not a valid directory handle
865 * - ENOTDIR if dh is not a directory
866 * - EINVAL offset did not refer to a valid dirent or
867 * smbc_init not called.
869 * @see smbc_telldir()
872 * @todo In what does the reture and errno values mean?
874 int smbc_lseekdir(int fd, off_t offset);
876 /**@ingroup directory
877 * Create a directory.
879 * @param durl The url of the directory to create
881 * @param mode Specifies the permissions to use. It is modified
882 * by the process's umask in the usual way: the
883 * permissions of the created file are (mode & ~umask).
885 * @return 0 on success, < 0 on error with errno set:
886 * - EEXIST directory url already exists
887 * - EACCES The parent directory does not allow write
888 * permission to the process, or one of the directories
889 * - ENOENT A directory component in pathname does not
890 * exist.
891 * - EINVAL NULL durl passed or smbc_init not called.
892 * - ENOMEM Insufficient memory was available.
894 * @see smbc_rmdir()
897 int smbc_mkdir(const char *durl, mode_t mode);
900 /**@ingroup directory
901 * Remove a directory.
903 * @param durl The smb url of the directory to remove
905 * @return 0 on success, < 0 on error with errno set:
906 * - EACCES or EPERM Write access to the directory
907 * containing pathname was not allowed.
908 * - EINVAL durl is NULL or smbc_init not called.
909 * - ENOENT A directory component in pathname does not
910 * exist.
911 * - ENOTEMPTY directory contains entries.
912 * - ENOMEM Insufficient kernel memory was available.
914 * @see smbc_mkdir(), smbc_unlink()
916 * @todo Are errno values complete and correct?
918 int smbc_rmdir(const char *durl);
921 /**@ingroup attribute
922 * Get information about a file or directory.
924 * @param url The smb url to get information for
926 * @param st pointer to a buffer that will be filled with
927 * standard Unix struct stat information.
929 * @return 0 on success, < 0 on error with errno set:
930 * - ENOENT A component of the path file_name does not
931 * exist.
932 * - EINVAL a NULL url was passed or smbc_init not called.
933 * - EACCES Permission denied.
934 * - ENOMEM Out of memory
935 * - ENOTDIR The target dir, url, is not a directory.
937 * @see Unix stat()
940 int smbc_stat(const char *url, struct stat *st);
943 /**@ingroup attribute
944 * Get file information via an file descriptor.
946 * @param fd Open file handle from smbc_open() or smbc_creat()
948 * @param st pointer to a buffer that will be filled with
949 * standard Unix struct stat information.
951 * @return EBADF filedes is bad.
952 * - EACCES Permission denied.
953 * - EBADF fd is not a valid file descriptor
954 * - EINVAL Problems occurred in the underlying routines
955 * or smbc_init not called.
956 * - ENOMEM Out of memory
958 * @see smbc_stat(), Unix stat()
961 int smbc_fstat(int fd, struct stat *st);
964 /**@ingroup attribue
965 * Change the ownership of a file or directory.
967 * @param url The smb url of the file or directory to change
968 * ownership of.
970 * @param owner I have no idea?
972 * @param group I have not idea?
974 * @return 0 on success, < 0 on error with errno set:
975 * - EPERM The effective UID does not match the owner
976 * of the file, and is not zero; or the owner or group
977 * were specified incorrectly.
978 * - ENOENT The file does not exist.
979 * - ENOMEM Insufficient was available.
980 * - ENOENT file or directory does not exist
982 * @todo Are we actually going to be able to implement this function
984 * @todo How do we abstract owner and group uid and gid?
987 int smbc_chown(const char *url, uid_t owner, gid_t group);
990 /**@ingroup attribute
991 * Change the permissions of a file.
993 * @param url The smb url of the file or directory to change
994 * permissions of
996 * @param mode The permissions to set:
997 * - Put good explaination of permissions here!
999 * @return 0 on success, < 0 on error with errno set:
1000 * - EPERM The effective UID does not match the owner
1001 * of the file, and is not zero
1002 * - ENOENT The file does not exist.
1003 * - ENOMEM Insufficient was available.
1004 * - ENOENT file or directory does not exist
1006 * @todo Actually implement this fuction?
1008 * @todo Are errno values complete and correct?
1010 int smbc_chmod(const char *url, mode_t mode);
1013 /**@ingroup print
1014 * Print a file given the name in fname. It would be a URL ...
1016 * @param fname The URL of a file on a remote SMB server that the
1017 * caller wants printed
1019 * @param printq The URL of the print share to print the file to.
1021 * @return 0 on success, < 0 on error with errno set:
1023 * - EINVAL fname or printq was NULL or smbc_init not
1024 * not called.
1025 * and errors returned by smbc_open
1028 int smbc_print_file(const char *fname, const char *printq);
1030 /**@ingroup print
1031 * Open a print file that can be written to by other calls. This simply
1032 * does an smbc_open call after checking if there is a file name on the
1033 * URI. If not, a temporary name is added ...
1035 * @param fname The URL of the print share to print to?
1037 * @returns A file handle for the print file if successful.
1038 * Returns -1 if an error ocurred and errno has the values
1039 * - EINVAL fname was NULL or smbc_init not called.
1040 * - all errors returned by smbc_open
1043 int smbc_open_print_job(const char *fname);
1045 /**@ingroup print
1046 * List the print jobs on a print share, for the moment, pass a callback
1048 * @param purl The url of the print share to list the jobs of
1050 * @param fn Callback function the receives printjob info
1052 * @return 0 on success, < 0 on error with errno set:
1053 * - EINVAL fname was NULL or smbc_init not called
1054 * - EACCES ???
1056 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
1058 /**@ingroup print
1059 * Delete a print job
1061 * @param purl Url of the print share
1063 * @param id The id of the job to delete
1065 * @return 0 on success, < 0 on error with errno set:
1066 * - EINVAL fname was NULL or smbc_init not called
1068 * @todo what errno values are possible here?
1070 int smbc_unlink_print_job(const char *purl, int id);
1073 #endif /* SMBCLIENT_H_INCLUDED */