From b87c484051e8fcb4fc920d7355eb92ff68a41350 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Tue, 26 Dec 2000 05:57:10 +0000 Subject: First pass at the libsmbclient code ... This code handles the basic stuff and compiles and links under Linux, but I do not know about any other operating systems. Now onto directory listing routines, including those that list workgroups, servers, etc. Nothing is built automatically yet, you have to make client/testsmbc to build the library and test program. Also, no make install targets are defined for libsmbclient.so as yet, either. Would be good if people test on operating systems other than Linux. (This used to be commit 51c0436a50e9f9274cee9de043bbefc93aff8011) --- source3/include/libsmbclient.h | 154 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 source3/include/libsmbclient.h (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h new file mode 100644 index 0000000000..a56ff2d7eb --- /dev/null +++ b/source3/include/libsmbclient.h @@ -0,0 +1,154 @@ +/* + Unix SMB/Netbios implementation. + Version 2.0 + SMB client library API definitions + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000 + Copyright (C) John Terpsra 2000 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _SMBCLIENT_H +#define _SMBCLIENT_H + +/* Make sure we have the following includes for now ... */ + +#include +#include +#include +#include + +#define SMBC_FILE_MODE (S_IFREG | 0444) +#define SMBC_DIR_MODE (S_IFDIR | 0555) + +typedef void (*smbc_get_auth_data_fn)(char *server, char *share, + char **workgroup, char **username, + char **password); + +/* + * Init the smbc package + */ +int smbc_init(smbc_get_auth_data_fn fn, const char *workgroup, int debug); + +/* + * Open a file on an SMB server, this has the same form as normal open + * but the fname is a URL of the form smb://server/share/path + */ + +int smbc_open(const char *fname, int flags, mode_t mode); + +/* + * Create a file on an SMB server, similar to smbc_open + */ + +int smbc_creat(const char *fname, mode_t mode); + +/* + * Read from a file, what about pread? + */ + +ssize_t smbc_read(int fd, void *buf, size_t count); + +/* + * Write to a file, what about pwrite? + */ + +ssize_t smbc_write(int fd, void *buf, size_t count); + +/* + * Close a file by fd + */ + +int smbc_close(int fd); + +/* + * Unlink a file on server, share, dir, file ... + */ + +int smbc_unlink(const char *fname); + +/* + * rename oname to nname ... probably need to be on the same + * server initially. Later can copy between servers ... + */ + +int smbc_rename(const char *oname, const char *nname); + +/* + * Seek to a specific location in a file on an SMB server + */ + +off_t smbc_lseek(int fd, off_t offset, int whence); + +/* + * Stat a file to get info via file name + */ + +int smbc_stat(const char *fname, struct stat *st); + +/* + * Stat a file to get info via an fd + */ + +int smbc_fstat(int fd, struct stat *st); + +/* + * Chown a file + */ + +int smbc_chown(const *fname, uid_t owner, gid_t group); + +/* + * Chmod a file + */ + +int smbc_chmod(const char *fname, mode_t newmode); + +/* + * Open a directory on a URL (server and share and dir) + */ + +int smbc_opendir(const char *fname); + +/* + * Close a directory + */ + +int smbc_closedir(int fd); + +/* + * Get a directory entry + */ + +int smbc_getdents(unsigned int fd, struct dirent *dirp, int count); + +/* + * Create a directory on a server, share, dir in fname URL + */ + +int smbc_mkdir(const char *fname, mode_t mode); + +/* + * lseek on directories, rewind by smbc_lseekdir(fd, 0, SEEK_SET) + */ + +int smbc_lseekdir(int fd, off_t offset, int whence); + +/* + * Must also provide print functions ... soon + */ + +#endif -- cgit From b6e811b90bf8cc6ca440ffedd210e5b16df555b2 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 5 Jan 2001 13:43:19 +0000 Subject: The latest changes to libsmbclient ... It can now do a directory listing for workgroups, servers, and shares, and, with a bit more effort, it will be able to list directories and files. I also does not request a username and password for the IPC$ share, but it should if the first attempt to connect fails. (This used to be commit 38ff91c5059a32c7ad2fd6074697c7c7f68a878c) --- source3/include/libsmbclient.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index a56ff2d7eb..173a56270b 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -29,7 +29,28 @@ #include #include #include -#include + +#define SMBC_MAX_NAME 1023 + +struct smbc_dirent { + + uint smbc_type; /* Type of entity, see below */ + uint namelen; + uint commentlen; + char *comment; /* Points to the comment futher down */ + char name[1]; + +}; + +#define SMBC_WORKGROUP 1 +#define SMBC_SERVER 2 +#define SMBC_FILE_SHARE 3 +#define SMBC_PRINTER_SHARE 4 +#define SMBC_COMMS_SHARE 5 +#define SMBC_IPC_SHARE 6 +#define SMBC_DIR 7 +#define SMBC_FILE 8 +#define SMBC_LINK 9 #define SMBC_FILE_MODE (S_IFREG | 0444) #define SMBC_DIR_MODE (S_IFDIR | 0555) @@ -133,7 +154,7 @@ int smbc_closedir(int fd); * Get a directory entry */ -int smbc_getdents(unsigned int fd, struct dirent *dirp, int count); +int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count); /* * Create a directory on a server, share, dir in fname URL -- cgit From c29e85cf89409a7ecbf8316af5d796f812d6be34 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 5 Jan 2001 22:32:53 +0000 Subject: Fix a small type in libsmbclient.h ... (This used to be commit 807e2e1faa23a36cd1abc07ac8a26d157099aba1) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 173a56270b..691307badf 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -130,7 +130,7 @@ int smbc_fstat(int fd, struct stat *st); * Chown a file */ -int smbc_chown(const *fname, uid_t owner, gid_t group); +int smbc_chown(const char *fname, uid_t owner, gid_t group); /* * Chmod a file -- cgit From c6d5280a546752a7eb93deba90dd49ee9cf327d5 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sun, 7 Jan 2001 07:10:50 +0000 Subject: More fixes and implementation bits and pieces for libsmbclient (This used to be commit 991f6907ac200d53b95a206d65844a0c0830caae) --- source3/include/libsmbclient.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 691307badf..6f608bdc5b 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -35,6 +35,7 @@ struct smbc_dirent { uint smbc_type; /* Type of entity, see below */ + uint dirlen; /* Convenience */ uint namelen; uint commentlen; char *comment; /* Points to the comment futher down */ @@ -42,6 +43,9 @@ struct smbc_dirent { }; +/* + * Entity types + */ #define SMBC_WORKGROUP 1 #define SMBC_SERVER 2 #define SMBC_FILE_SHARE 3 -- cgit From fb4013444677629af4b663a61da3b575bba49195 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 12 Jan 2001 05:10:45 +0000 Subject: Many bug fixes to the libsmbclient.c code plus - an implementation of smbc_readdir - extensions to tree.c to show files in a second window - changes to auth_fn to provide buffers for username, password, etc from caller rather than callee (This used to be commit 7f559c1a7307b91218d5984f48f65e7dc0ab66b9) --- source3/include/libsmbclient.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 6f608bdc5b..34e9405ff5 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -60,8 +60,9 @@ struct smbc_dirent { #define SMBC_DIR_MODE (S_IFDIR | 0555) typedef void (*smbc_get_auth_data_fn)(char *server, char *share, - char **workgroup, char **username, - char **password); + char *workgroup, int wgmaxlen, + char *username, int unmaxlen, + char *password, int pwmaxlen); /* * Init the smbc package @@ -160,6 +161,12 @@ int smbc_closedir(int fd); int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count); +/* + * Read a dirent in the old way + */ + +struct smbc_dirent *smbc_readdir(unsigned int fd); + /* * Create a directory on a server, share, dir in fname URL */ -- cgit From 338fd23290cb0770b59cb77ef4733bb8da6d3164 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 12 Jan 2001 12:48:55 +0000 Subject: Some more bug fixes plus implementations of smbc_mkdir and smbc_rmdir, both tested ... More later. (This used to be commit 66bb40153a9ff38692356cadfad89cf91439032e) --- source3/include/libsmbclient.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 34e9405ff5..5889502ae2 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -173,6 +173,18 @@ struct smbc_dirent *smbc_readdir(unsigned int fd); int smbc_mkdir(const char *fname, mode_t mode); +/* + * Remove a directory on a server + */ + +int smbc_rmdir(const char *fname); + +/* + * Get the current directory offset + */ + +off_t smbc_telldir(int fd); + /* * lseek on directories, rewind by smbc_lseekdir(fd, 0, SEEK_SET) */ -- cgit From 2fd7e6e6a0d1b22d841d49c4fc0868c0be471475 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sun, 4 Feb 2001 19:48:26 +0000 Subject: Fix some further small bugs in libsmbclient to make it pass the Caldera test suite and start to add the printing routines. (This used to be commit 838cfad404ef648ee7909f449264afa4db60fa3b) --- source3/include/libsmbclient.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 5889502ae2..a02c0e5317 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -192,7 +192,29 @@ off_t smbc_telldir(int fd); int smbc_lseekdir(int fd, off_t offset, int whence); /* - * Must also provide print functions ... soon + * Print a file given the name in fname. It would be a URL ... */ +int smbc_print_file(const char *fname); + +/* + * Open a print file that can be written to by other calls. This simply + * does an smbc_open call after checking if there is a file name on the + * URI. If not, a temporary name is added ... + */ + +int smbc_open_print_job(const char *fname); + +/* + * List the print jobs on a print share, for the moment, pass a callback + */ + +int smbc_list_print_jobs(const char *fname, void (*fn)(struct print_job_info *)); + +/* + * Delete a print job + */ + +int smbc_unlink_print_job(int id); + #endif -- cgit From ca03ad79cfaad48fb20426dfb98a30740fe80a0d Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 5 Feb 2001 13:02:20 +0000 Subject: Implement two printing related functions and start the remaining two. (This used to be commit c19559a286c3ec6dedefbd2423aa5738edd9ba41) --- source3/include/libsmbclient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index a02c0e5317..5469966cf8 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -195,7 +195,7 @@ int smbc_lseekdir(int fd, off_t offset, int whence); * Print a file given the name in fname. It would be a URL ... */ -int smbc_print_file(const char *fname); +int smbc_print_file(const char *fname, const char *printq); /* * Open a print file that can be written to by other calls. This simply @@ -215,6 +215,6 @@ int smbc_list_print_jobs(const char *fname, void (*fn)(struct print_job_info *)) * Delete a print job */ -int smbc_unlink_print_job(int id); +int smbc_unlink_print_job(const char *fname, int id); #endif -- cgit From 5455f2896f65a650a32f18dfb4bc4ae81a79848e Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Tue, 6 Feb 2001 19:25:12 +0000 Subject: Fix problems in libsmbclient with pring job struct plus add implementation of last two print routines ... (This used to be commit 7c50af3b71eeedfef8ed0d5771c2dc578fa95741) --- source3/include/libsmbclient.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 5469966cf8..fe383e845a 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -43,6 +43,18 @@ struct smbc_dirent { }; +#ifndef _CLIENT_H +typedef unsigned short uint16; +struct print_job_info { + uint16 id; + uint16 priority; + size_t size; + char user[128]; + char name[128]; + time_t t; +}; +#endif + /* * Entity types */ -- cgit From 167a7d76d96a2e4884b85ac3eb775050b34346de Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 12 Feb 2001 12:17:54 +0000 Subject: Added commented/documented version of libsmbclient.h and fixed up a small problem in libsmbclient.c where we no longer pass the workgroup. (This used to be commit 3c6611434601a45ba448f0313397104c7cea616c) --- source3/include/libsmbclient.h | 852 +++++++++++++++++++++++++++++++++-------- 1 file changed, 692 insertions(+), 160 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index fe383e845a..5440c690b8 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1,4 +1,4 @@ -/* +/*===================================================================== Unix SMB/Netbios implementation. Version 2.0 SMB client library API definitions @@ -19,214 +19,746 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ +=====================================================================*/ -#ifndef _SMBCLIENT_H -#define _SMBCLIENT_H +#ifndef SMBCLIENT_H_INCLUDED +#define SMBCLIENT_H_INCLUDED -/* Make sure we have the following includes for now ... */ +/*-------------------------------------------------------------------*/ +/* The following are special comments to instruct DOXYGEN (automated + * documentation tool: +*/ +/** \defgroup structure Data Structures Type and Constants +* Data structures, types, and constants +*/ +/** \defgroup file File Functions +* Functions used to access individual file contents +*/ +/** \defgroup directory Directory Functions +* Functions used to access directory entries +*/ +/** \defgroup attribute Attributes Functions +* Functions used to view or change file and directory attributes +*/ +/** \defgroup print Print Functions +* Functions used to access printing functionality +*/ +/** \defgroup attribute Miscellaneous Functions +* Functions that don't fit in to other categories +*/ +/*-------------------------------------------------------------------*/ +/* Make sure we have the following includes for now ... */ #include #include #include -#define SMBC_MAX_NAME 1023 - -struct smbc_dirent { - - uint smbc_type; /* Type of entity, see below */ - uint dirlen; /* Convenience */ - uint namelen; - uint commentlen; - char *comment; /* Points to the comment futher down */ - char name[1]; - -}; - -#ifndef _CLIENT_H -typedef unsigned short uint16; -struct print_job_info { - uint16 id; - uint16 priority; - size_t size; - char user[128]; - char name[128]; - time_t t; -}; -#endif - -/* - * Entity types - */ -#define SMBC_WORKGROUP 1 -#define SMBC_SERVER 2 -#define SMBC_FILE_SHARE 3 -#define SMBC_PRINTER_SHARE 4 -#define SMBC_COMMS_SHARE 5 -#define SMBC_IPC_SHARE 6 -#define SMBC_DIR 7 -#define SMBC_FILE 8 -#define SMBC_LINK 9 +#define SMBC_MAX_NAME 1023 +#define SMBC_WORKGROUP 1 +#define SMBC_SERVER 2 +#define SMBC_FILE_SHARE 3 +#define SMBC_PRINTER_SHARE 4 +#define SMBC_COMMS_SHARE 5 +#define SMBC_IPC_SHARE 6 +#define SMBC_DIR 7 +#define SMBC_FILE 8 +#define SMBC_LINK 9 #define SMBC_FILE_MODE (S_IFREG | 0444) #define SMBC_DIR_MODE (S_IFDIR | 0555) -typedef void (*smbc_get_auth_data_fn)(char *server, char *share, - char *workgroup, int wgmaxlen, - char *username, int unmaxlen, - char *password, int pwmaxlen); - -/* - * Init the smbc package - */ -int smbc_init(smbc_get_auth_data_fn fn, const char *workgroup, int debug); - -/* - * Open a file on an SMB server, this has the same form as normal open - * but the fname is a URL of the form smb://server/share/path - */ - -int smbc_open(const char *fname, int flags, mode_t mode); - -/* - * Create a file on an SMB server, similar to smbc_open - */ - -int smbc_creat(const char *fname, mode_t mode); - -/* - * Read from a file, what about pread? - */ - -ssize_t smbc_read(int fd, void *buf, size_t count); - -/* - * Write to a file, what about pwrite? - */ - -ssize_t smbc_write(int fd, void *buf, size_t count); +/**@ingroup structure + * Structure that represents a directory entry. + * +*/ +struct smbc_dirent +{ + /** Type of entity. + SMBC_WORKGROUP=1, + SMBC_SERVER=2, + SMBC_FILE_SHARE=3, + SMBC_PRINTER_SHARE=4, + SMBC_COMMS_SHARE=5, + SMBC_IPC_SHARE=6, + SMBC_DIR=7, + SMBC_FILE=8, + SMBC_LINK=9,*/ + uint smbc_type; + + /** Length of this smbc_dirent in bytes + */ + uint dirlen; + /** The length of the comment string in bytes (includes null + * terminator) + */ + uint commentlen; + /** Points to the null terminated comment string + */ + char *comment; + /** The length of the name string in bytes (includes null + * terminator) + */ + uint namelen; + /** Points to the null terminated name string + */ + char name[1]; +}; -/* - * Close a file by fd - */ -int smbc_close(int fd); +#ifndef _CLIENT_H +typedef unsigned short uint16; -/* - * Unlink a file on server, share, dir, file ... +/**@ingroup structure + * Structure that represents a print job. + * + * @todo Make sure the discriptions of structure members are correct. */ +struct print_job_info +{ + /** numeric ID of the print job + */ + uint16 id; + + /** represents print job priority (lower numbers mean higher priority?) + */ + uint16 priority; + + /** Size of the print job + */ + size_t size; + + /** Name of the user that owns the print job + */ + char user[128]; + + /** Name of the print job + */ + char name[128]; + + /** Time the print job was spooled? + */ + time_t t; +}; +#endif -int smbc_unlink(const char *fname); -/* - * rename oname to nname ... probably need to be on the same - * server initially. Later can copy between servers ... +/**@ingroup structure + * Authentication callback function type. + * + * Type for the the authentication function called by the library to + * obtain authentication credentals + * + * @param srv Server being authenticated to + * + * @param shr Share being authenticated to + * + * @param wg Pointer to buffer containing a "hint" for the + * workgroup to be authenticated. Should be filled + * with the correct workgroup if the hint is wrong. + * + * @param wglen The size of the workgroup buffer in bytes + * + * @param un Pointer to buffer containing a "hint" for the + * user name to be use for authentication. Should be + * filled with the correct workgroup if the hint is + * wrong. + * + * @param unlen The size of the username buffer in bytes + * + * @param pw Pointer to buffer containing to which password + * copied + * + * @param pwlen The size of the password buffer in bytes + * */ - -int smbc_rename(const char *oname, const char *nname); - -/* - * Seek to a specific location in a file on an SMB server +typedef void (*smbc_get_auth_data_fn)(const char *srv, + const char *shr, + char *wg, int wglen, + char *un, int unlen, + char *pw, int pwlen); + + +/**@ingroup structure + * Print job info callback function type. + * + * @param i pointer to print job information structure + * + */ +typedef void (*smbc_get_print_job_info)(struct print_job_info *i); + + +/**@ingroup misc + * Initialize the samba client library. + * + * Must be called before using any of the smbclient API function + * + * @param fn The function that will be called to obtaion + * authentication credentials. + * + * @param debug Allows caller to set the debug level. Can be + * changed in smb.conf file. + * + * @return 0 on success, < 0 on error with errno set: + * - ENOMEM Out of memory + * + * @todo Why do we need to pass in debug information? */ - +int smbc_init(smbc_get_auth_data_fn fn, int debug); + + +/**@ingroup file + * Open a file on an SMB server. + * + * @param furl The smb url of the file to be opened. + * + * @param flags Is one of O_RDONLY, O_WRONLY or O_RDWR which + * request opening the file read-only,write-only + * or read/write. flags may also be bitwise-or'd with + * one or more of the following: + * O_CREAT - If the file does not exist it will be + * created. + * O_EXCL - When used with O_CREAT, if the file + * already exists it is an error and the open will + * fail. + * O_TRUNC - If the file already exists it will be + * truncated. + * O_APPEND The file is opened in append mode + * + * @param mode mode specifies the permissions to use if a new + * file is created. It is modified by the + * process's umask in the usual way: the permissions + * of the created file are (mode & ~umask) + * + * Not currently use, but there for future use + * when we figure this out. + * + * @return Valid file handle, < 0 on error with errno set: + * - ENOMEM Out of memory + * - EEXIST pathname already exists and O_CREAT and + * O_EXCL were used. + * - EISDIR pathname refers to a directory and + * the access requested involved writing. + * - EACCES The requested access to the file is not + * allowed + * - ENOENT A directory component in pathname does + * not exist. + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_creat() + * + * @todo Mode needs to be better explained if there is any differences + * from standard open(). + * + * @todo Are errno values complete and correct? They look OK. + * +*/ +int smbc_open(const char *furl, int flags, mode_t mode); + + +/**@ingroup file + * Create a file on an SMB server. + * + * Same as calling smbc_open() with flags = O_CREAT|O_WRONLY|O_TRUNC + * + * @param furl The smb url of the file to be created + * + * @param mode mode specifies the permissions to use if a new + * file is created. It is modified by the + * process's umask in the usual way: the permissions + * of the created file are (mode & ~umask) + * + * @return Valid file handle, < 0 on error with errno set: + * - ENOMEM Out of memory + * - EEXIST pathname already exists and O_CREAT and + * O_EXCL were used. + * - EISDIR pathname refers to a directory and + * the access requested involved writing. + * - EACCES The requested access to the file is not + * allowed + * - ENOENT A directory component in pathname does + * not exist. + * - EUCLEAN smbc_init() failed or has not been called + * @see smbc_open() + * + * @todo Are errno values complete and correct? +*/ +int smbc_creat(const char *furl, mode_t mode); + + +/**@ingroup file + * Read from a file using an opened file handle. + * + * @param fd Open file handle from smbc_open() or smbc_creat() + * + * @param buf Pointer to buffer to recieve read data + * + * @param bufsize Size of buf in bytes + * + * @return Number of bytes read, < 0 on error with errno set: + * - EISDIR fd refers to a directory + * - EBADF fd is not a valid file descriptor or + * is not open for reading. + * - EINVAL fd is attached to an object which is + * unsuitable for reading. + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_open(), smbc_write() + * + * @todo Are errno values complete and correct? +*/ +ssize_t smbc_read(int fd, void *buf, size_t bufsize); + + +/**@ingroup file + * Write to a file using an opened file handle. + * + * @param fd Open file handle from smbc_open() or smbc_creat() + * + * @param buf Pointer to buffer to recieve read data + * + * @param bufsize Size of buf in bytes + * + * @return Number of bytes written, < 0 on error with errno set: + * - EISDIR fd refers to a directory. + * - EBADF fd is not a valid file descriptor or + * is not open for reading. + * - EINVAL fd is attached to an object which is + * unsuitable for reading. + * - EUCLEAN smbc_init() failed or has not been called + * @see smbc_open(), smbc_read() + * + * @todo Are errno values complete and correct? +*/ +ssize_t smbc_write(int fd, void *buf, size_t bufsize); + + +/**@ingroup file + * Seek to a specific location in a file. + * + * @param fd Open file handle from smbc_open() or smbc_creat() + * + * @param offset Offset in bytes from whence + * + * @param whence A location in the file: + * - SEEK_SET The offset is set to offset bytes from + * the beginning of the file + * - SEEK_CUR The offset is set to current location + * plus offset bytes. + * - SEEK_END The offset is set to the size of the + * file plus offset bytes. + * + * @return Upon successful completion, lseek returns the + * resulting offset location as measured in bytes + * from the beginning of the file. Otherwise, a value + * of (off_t)-1 is returned and errno is set to + * indicate the error: + * - EBADF Fildes is not an open file descriptor. + * - EINVAL Whence is not a proper value. + * - EUCLEAN smbc_init() failed or has not been called + * + * @todo Are all the whence values really supported? + * + * @todo Are errno values complete and correct? +*/ off_t smbc_lseek(int fd, off_t offset, int whence); -/* - * Stat a file to get info via file name - */ - -int smbc_stat(const char *fname, struct stat *st); - -/* - * Stat a file to get info via an fd - */ - -int smbc_fstat(int fd, struct stat *st); - -/* - * Chown a file - */ - -int smbc_chown(const char *fname, uid_t owner, gid_t group); -/* - * Chmod a file - */ - -int smbc_chmod(const char *fname, mode_t newmode); - -/* - * Open a directory on a URL (server and share and dir) - */ +/**@ingroup file + * Close an open file handle. + * + * @param fd The file handle to close + * + * @return 0 on success, < 0 on error with errno set: + * - EBADF fd isn't a valid open file descriptor + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_open(), smbc_creat() +*/ +int smbc_close(int fd); -int smbc_opendir(const char *fname); -/* - * Close a directory +/**@ingroup directory + * Unlink (delete) a file or directory. + * + * @param furl The smb url of the file to delete + * + * @return 0 on success, < 0 on error with errno set: + * - EACCES or EPERM Write access to the directory + * containing pathname is not allowed or one + * of the directories in pathname did not allow + * search (execute) permission + * - ENOENT A directory component in pathname does + * not exist + * - ENOMEM Insufficient kernel memory was availabl + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_rmdir()s + * + * @todo Are errno values complete and correct? +*/ +int smbc_unlink(const char *furl); + + +/**@ingroup directory + * Rename or move a file or directory. + * + * @param ourl The original smb url (source url) of file or + * directory to be moved + * + * @param nurl The new smb url (destination url) of the file + * or directory after the move. Currently nurl must + * be on the same share as ourl. + * + * @return 0 on success, < 0 on error with errno set: + * - EISDIR nurl is an existing directory, but ourl is + * not a directory. + * - EEXIST nurl is a non-empty directory, + * i.e., contains entries other than "." and ".." + * - EINVAL The new url contained a path prefix + * of the old, or, more generally, an attempt was + * made to make a directory a subdirectory of itself. + * - ENOTDIR A component used as a directory in ourl + * or nurl path is not, in fact, a directory. Or, + * ourl is a directory, and newpath exists but is not + * a directory. + * - EACCES or EPERM Write access to the directory + * containing ourl or nurl is not allowed for the + * process's effective uid, or one of the + * directories in ourl or nurl did not allow search + * (execute) permission, or ourl was a directory + * and did not allow write permission. + * - ENOENT A directory component in ourl or nurl + * does not exist. + * - ENOMEM Insufficient kernel memory was available. + * - EUCLEAN smbc_init() failed or has not been called + * + * @todo Are errno values complete and correct? + * + * @todo Are we going to support copying when urls are not on the same + * share? I say no... + * +*/ +int smbc_rename(const char *ourl, const char *nurl); + + +/**@ingroup directory + * Open a directory used to obtain directory entries. + * + * @param durl The smb url of the directory to open + * + * @return Valid directory handle. < 0 on error with errno set: + * - EACCES Permission denied. + * - ENOENT durl does not exist, or name is an + * - ENOMEM Insufficient memory to complete the + * operation. + * - ENOTDIR name is not a directory. + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_getdents(), smbc_readdir(), smbc_closedir() + * + * @todo Are errno values complete and correct? +*/ +int smbc_opendir(const char *durl); + + +/**@ingroup directory + * Close a directory handle opened by smbc_opendir(). + * + * @param dh Directory handle to close + * + * @return 0 on success, < 0 on error with errno set: + * - EBADF dh is an invalid directory handle + * + * @see smbc_opendir() +*/ +int smbc_closedir(int dh); + + +/**@ingroup directory + * Get multiple directory entries. + * + * smbc_getdents() reads several dirent structures from the an open + * directory handle into a specified memory area. + * + * @param dh Valid directory as returned by smbc_opendir() + * + * @param dirp pointer to buffer that will receive the directory + * entries. + * + * @param count The size of the dirp buffer in bytes + * + * @returns - EBADF Invalid directory handle + * - EINVAL Result buffer is too small + * - ENOENT No such directory. + * - EUCLEAN smbc_init() failed or has not been called + * @see , smbc_dirent, smbc_readdir(), smbc_open() + * + * @todo Are errno values complete and correct? + * + * @todo Add example code so people know how to parse buffers. */ - -int smbc_closedir(int fd); - -/* - * Get a directory entry +int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); + + +/**@ingroup directory + * Get a single directory entry. + * + * @param dh Valid directory as returned by smbc_opendir() + * + * @return A pointer to a smbc_dirent structure, or NULL if an + * error occurs or end-of-directory is reached: + * - EBADF Invalid directory handle + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_dirent, smbc_getdents(), smbc_open() +*/ +struct smbc_dirent* smbc_readdir(unsigned int dh); + + +/**@ingroup directory + * Get the current directory offset. + * + * smbc_telldir() may be used in conjunction with smbc_readdir() and + * smbc_lseekdir(). + * + * @param dh Valid directory as returned by smbc_opendir() + * + * @return The current location in the directory stream or -1 + * if an error occur. + * - EBADF dh is not a valid directory handle + * + * @see smbc_readdir() + * + * @todo What in the is the offset related to bytes or directory entry + * number? +*/ +off_t smbc_telldir(int dh); + + +/**@ingroup directory + * lseek on directories. + * + * smbc_lseekdir() may be used in conjunction with smbc_readdir() and + * smbc_telldir(). (rewind by smbc_lseekdir(fd, 0, SEEK_SET)) + * + * @param dh Valid directory as returned by smbc_opendir() + * + * @param offset The offset (as returned by smbc_telldir) from + * whence + * + * @param whence A location in the directory stream: + * - SEEK_SET this is the only one that makes sense... + * - SEEK_CUR ??? + * - SEEK_END ??? + * + * @return I have no idea? + * + * @see smbc_telldir() + * + * @todo What in the is the offset related to? Bytes or directory + * entry number? + * + * @todo In what do SEEK_SET and friends really mean? + * + * @todo In what does the reture and errno values mean? */ - -int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count); - -/* - * Read a dirent in the old way +int smbc_lseekdir(int dh, off_t offset, int whence); + + +/**@ingroup directory + * Create a directory. + * + * @param durl The url of the directory to create + * + * @param mode Specifies the permissions to use. It is modified + * by the process's umask in the usual way: the + * permissions of the created file are (mode & ~umask). + * + * @return 0 on success, < 0 on error with errno set: + * - EEXIST directory url already exists + * - EACCES The parent directory does not allow write + * permission to the process, or one of the directories + * - ENOENT A directory component in pathname does not + * exist. + * - ENOMEM Insufficient memory was available. + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_rmdir() + * + * @todo Are errno values complete and correct? +*/ +int smbc_mkdir(const char *durl, mode_t mode); + + +/**@ingroup directory + * Remove a directory. + * + * @param durl The smb url of the directory to remove + * + * @return 0 on success, < 0 on error with errno set: + * - EACCES or EPERM Write access to the directory + * containing pathname was not allowed. + * - ENOENT A directory component in pathname does not + * exist. + * - ENOTEMPTY directory contains entries. + * - ENOMEM Insufficient kernel memory was available. + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_mkdir(), smbc_unlink() + * + * @todo Are errno values complete and correct? */ - -struct smbc_dirent *smbc_readdir(unsigned int fd); - -/* - * Create a directory on a server, share, dir in fname URL +int smbc_rmdir(const char *durl); + + +/**@ingroup attribute + * Get information about a file or directory. + * + * @param url The smb url to get information for + * + * @param st pointer to a buffer that will be filled with + * standard Unix struct stat information. + * + * @return 0 on success, < 0 on error with errno set: + * - ENOENT A component of the path file_name does not + * exist. + * - EACCES Permission denied. + * - ENOMEM Out of memory + * - EUCLEAN smbc_init() failed or has not been called + * + * @see Unix stat() + * + * @todo Are errno values complete and correct? */ - -int smbc_mkdir(const char *fname, mode_t mode); - -/* - * Remove a directory on a server +int smbc_stat(const char *url, struct stat *st); + + +/**@ingroup attribute + * Get file information via an file descriptor. + * + * @param fd Open file handle from smbc_open() or smbc_creat() + * + * @param st pointer to a buffer that will be filled with + * standard Unix struct stat information. + * + * @return EBADF filedes is bad. + * -EACCES Permission denied. + * -ENOMEM Out of memory + * - EUCLEAN smbc_init() failed or has not been called + * + * @see smbc_stat(), Unix stat() */ +int smbc_fstat(int fd, struct stat *st); -int smbc_rmdir(const char *fname); -/* - * Get the current directory offset +/**@ingroup attribue + * Change the ownership of a file or directory. + * + * @param url The smb url of the file or directory to change + * ownership of. + * + * @param owner I have no idea? + * + * @param group I have not idea? + * + * @return 0 on success, < 0 on error with errno set: + * - EPERM The effective UID does not match the owner + * of the file, and is not zero; or the owner or group + * were specified incorrectly. + * - ENOENT The file does not exist. + * - ENOMEM Insufficient was available. + * - ENOENT file or directory does not exist + * + * @todo Are we actually going to be able to implement this function + * + * @todo How do we abstract owner and group uid and gid? + * */ - -off_t smbc_telldir(int fd); - -/* - * lseek on directories, rewind by smbc_lseekdir(fd, 0, SEEK_SET) +int smbc_chown(const char *url, uid_t owner, gid_t group); + + +/**@ingroup attribute + * Change the permissions of a file. + * + * @param url The smb url of the file or directory to change + * permissions of + * + * @param mode The permissions to set: + * - Put good explaination of permissions here! + * + * @return 0 on success, < 0 on error with errno set: + * - EPERM The effective UID does not match the owner + * of the file, and is not zero + * - ENOENT The file does not exist. + * - ENOMEM Insufficient was available. + * - ENOENT file or directory does not exist + * + * @todo Actually implement this fuction? + * + * @todo Are errno values complete and correct? */ +int smbc_chmod(const char *url, mode_t mode); -int smbc_lseekdir(int fd, off_t offset, int whence); -/* +/**@ingroup print * Print a file given the name in fname. It would be a URL ... - */ - + * + * @param fname I do not know what this is it the url of the file + * to print? + * + * @param printq I do not know what this is, is it the url of the + * printer to print to? + * + * @return 0 on success, < 0 on error with errno set: + * + * @todo I have no idea what this does. What is fname? What is + * printq? + * + * @todo What errno values are possible here + */ int smbc_print_file(const char *fname, const char *printq); -/* +/**@ingroup print * Open a print file that can be written to by other calls. This simply * does an smbc_open call after checking if there is a file name on the * URI. If not, a temporary name is added ... + * + * @param fname Is this the url of a print share? + * + * @returns A file handle right? + * + * @todo What errno values are possible here + * + * @todo What is fname is it the url of a print share? */ - int smbc_open_print_job(const char *fname); -/* +/**@ingroup print * List the print jobs on a print share, for the moment, pass a callback + * + * @param purl The url of the print share to list the jobs of + * + * @param fn Callback function the receives printjob info + * + * @return 0 on success, < 0 on error with errno set: + * + * @todo what errno values are possible here? */ -int smbc_list_print_jobs(const char *fname, void (*fn)(struct print_job_info *)); +int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn); -/* +/**@ingroup print * Delete a print job + * + * @param purl Url of the print share + * + * @param id The id of the job to delete + * + * @return 0 on success, < 0 on error with errno set: + * + * @todo what errno values are possible here? */ +int smbc_unlink_print_job(const char *purl, int id); -int smbc_unlink_print_job(const char *fname, int id); -#endif +#endif /* SMBCLIENT_H_INCLUDED */ -- cgit From 2b22019e426c4bb7a5745a326c302a4e19aa5ff2 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Wed, 7 Mar 2001 04:39:31 +0000 Subject: Fix the definition and implementation of smbc_lseekdir ... (This used to be commit e628d80d1e0f6ec87b61baeaf64019b43bf7dac8) --- source3/include/libsmbclient.h | 150 ++++++++++++++++++++++------------------- 1 file changed, 82 insertions(+), 68 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 5440c690b8..2fe0af35e6 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -111,7 +111,6 @@ typedef unsigned short uint16; /**@ingroup structure * Structure that represents a print job. * - * @todo Make sure the discriptions of structure members are correct. */ struct print_job_info { @@ -119,7 +118,7 @@ struct print_job_info */ uint16 id; - /** represents print job priority (lower numbers mean higher priority?) + /** represents print job priority (lower numbers mean higher priority) */ uint16 priority; @@ -131,11 +130,12 @@ struct print_job_info */ char user[128]; - /** Name of the print job + /** Name of the print job. This will have no name if an anonymous print + * file was opened. Ie smb://server/printer */ char name[128]; - /** Time the print job was spooled? + /** Time the print job was spooled */ time_t t; }; @@ -153,14 +153,14 @@ struct print_job_info * @param shr Share being authenticated to * * @param wg Pointer to buffer containing a "hint" for the - * workgroup to be authenticated. Should be filled + * workgroup to be authenticated. Should be filled in * with the correct workgroup if the hint is wrong. * * @param wglen The size of the workgroup buffer in bytes * * @param un Pointer to buffer containing a "hint" for the * user name to be use for authentication. Should be - * filled with the correct workgroup if the hint is + * filled in with the correct workgroup if the hint is * wrong. * * @param unlen The size of the username buffer in bytes @@ -196,12 +196,13 @@ typedef void (*smbc_get_print_job_info)(struct print_job_info *i); * authentication credentials. * * @param debug Allows caller to set the debug level. Can be - * changed in smb.conf file. + * changed in smb.conf file. Allows caller to set + * debugging if no smb.conf. * * @return 0 on success, < 0 on error with errno set: * - ENOMEM Out of memory + * - ENOENT The smb.conf file would not load * - * @todo Why do we need to pass in debug information? */ int smbc_init(smbc_get_auth_data_fn fn, int debug); @@ -229,11 +230,14 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * process's umask in the usual way: the permissions * of the created file are (mode & ~umask) * - * Not currently use, but there for future use - * when we figure this out. + * Not currently use, but there for future use. + * We will map this to SYSTEM, HIDDEN, etc bits + * that reverses the mapping that smbc_fstat does. * * @return Valid file handle, < 0 on error with errno set: * - ENOMEM Out of memory + * - EINVAL if an invalid parameter passed, like no + * file. * - EEXIST pathname already exists and O_CREAT and * O_EXCL were used. * - EISDIR pathname refers to a directory and @@ -246,11 +250,6 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * * @see smbc_creat() * - * @todo Mode needs to be better explained if there is any differences - * from standard open(). - * - * @todo Are errno values complete and correct? They look OK. - * */ int smbc_open(const char *furl, int flags, mode_t mode); @@ -266,9 +265,14 @@ int smbc_open(const char *furl, int flags, mode_t mode); * file is created. It is modified by the * process's umask in the usual way: the permissions * of the created file are (mode & ~umask) + * + * NOTE, the above is not true. We are dealing with + * an SMB server, which has no concept of a umask! * * @return Valid file handle, < 0 on error with errno set: * - ENOMEM Out of memory + * - EINVAL if an invalid parameter passed, like no + * file. * - EEXIST pathname already exists and O_CREAT and * O_EXCL were used. * - EISDIR pathname refers to a directory and @@ -280,7 +284,6 @@ int smbc_open(const char *furl, int flags, mode_t mode); * - EUCLEAN smbc_init() failed or has not been called * @see smbc_open() * - * @todo Are errno values complete and correct? */ int smbc_creat(const char *furl, mode_t mode); @@ -299,13 +302,12 @@ int smbc_creat(const char *furl, mode_t mode); * - EBADF fd is not a valid file descriptor or * is not open for reading. * - EINVAL fd is attached to an object which is - * unsuitable for reading. + * unsuitable for reading, or no buffer passed. * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_open(), smbc_write() * - * @todo Are errno values complete and correct? -*/ + */ ssize_t smbc_read(int fd, void *buf, size_t bufsize); @@ -323,12 +325,11 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize); * - EBADF fd is not a valid file descriptor or * is not open for reading. * - EINVAL fd is attached to an object which is - * unsuitable for reading. + * unsuitable for reading, or no buffer passed. * - EUCLEAN smbc_init() failed or has not been called * @see smbc_open(), smbc_read() * - * @todo Are errno values complete and correct? -*/ + */ ssize_t smbc_write(int fd, void *buf, size_t bufsize); @@ -389,7 +390,9 @@ int smbc_close(int fd); * search (execute) permission * - ENOENT A directory component in pathname does * not exist - * - ENOMEM Insufficient kernel memory was availabl + * - EINVAL NULL was passed in the file param + * - EACCES You do not have access to the file + * - ENOMEM Insufficient kernel memory was available * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_rmdir()s @@ -429,13 +432,14 @@ int smbc_unlink(const char *furl); * and did not allow write permission. * - ENOENT A directory component in ourl or nurl * does not exist. + * - EXDEV Rename across shares not supported. * - ENOMEM Insufficient kernel memory was available. * - EUCLEAN smbc_init() failed or has not been called * * @todo Are errno values complete and correct? * * @todo Are we going to support copying when urls are not on the same - * share? I say no... + * share? I say no... NOTE. I agree for the moment. * */ int smbc_rename(const char *ourl, const char *nurl); @@ -448,15 +452,18 @@ int smbc_rename(const char *ourl, const char *nurl); * * @return Valid directory handle. < 0 on error with errno set: * - EACCES Permission denied. + * - EINVAL A NULL file/URL was passed, or the URL would + * not parse, or was of incorrect form. * - ENOENT durl does not exist, or name is an * - ENOMEM Insufficient memory to complete the * operation. * - ENOTDIR name is not a directory. + * - EPERM the workgroup could not be found. + * - ENODEV the workgroup or server could not be found. * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_getdents(), smbc_readdir(), smbc_closedir() * - * @todo Are errno values complete and correct? */ int smbc_opendir(const char *durl); @@ -477,8 +484,8 @@ int smbc_closedir(int dh); /**@ingroup directory * Get multiple directory entries. * - * smbc_getdents() reads several dirent structures from the an open - * directory handle into a specified memory area. + * smbc_getdents() reads as many dirent structures from the an open + * directory handle into a specified memory area as will fit. * * @param dh Valid directory as returned by smbc_opendir() * @@ -487,7 +494,10 @@ int smbc_closedir(int dh); * * @param count The size of the dirp buffer in bytes * - * @returns - EBADF Invalid directory handle + * @returns If any dirents returned, return will indicate the + * total size. If there were no more dirents available, + * 0 is returned. < 0 indicates an error. + * - EBADF Invalid directory handle * - EINVAL Result buffer is too small * - ENOENT No such directory. * - EUCLEAN smbc_init() failed or has not been called @@ -524,13 +534,16 @@ struct smbc_dirent* smbc_readdir(unsigned int dh); * @param dh Valid directory as returned by smbc_opendir() * * @return The current location in the directory stream or -1 - * if an error occur. + * if an error occur. The current location is not + * an offset. Becuase of the implementation, it is a + * handle that allows the library to find the entry + * later. * - EBADF dh is not a valid directory handle + * - EUCLEAN smbc_init() failed or has not been called + * - ENOTDIR if dh is not a directory * * @see smbc_readdir() * - * @todo What in the is the offset related to bytes or directory entry - * number? */ off_t smbc_telldir(int dh); @@ -539,31 +552,25 @@ off_t smbc_telldir(int dh); * lseek on directories. * * smbc_lseekdir() may be used in conjunction with smbc_readdir() and - * smbc_telldir(). (rewind by smbc_lseekdir(fd, 0, SEEK_SET)) + * smbc_telldir(). (rewind by smbc_lseekdir(fd, NULL)) * - * @param dh Valid directory as returned by smbc_opendir() + * @param fd Valid directory as returned by smbc_opendir() * - * @param offset The offset (as returned by smbc_telldir) from - * whence - * - * @param whence A location in the directory stream: - * - SEEK_SET this is the only one that makes sense... - * - SEEK_CUR ??? - * - SEEK_END ??? + * @param offset The offset (as returned by smbc_telldir). Can be + * NULL, in which case we will rewind * - * @return I have no idea? + * @return 0 on success, -1 on failure + * - EUCLEAN smbc_init() failed or has not been called + * - EBADF dh is not a valid directory handle + * - ENOTDIR if dh is not a directory + * - EINVAL offset did not refer to a valid dirent * * @see smbc_telldir() * - * @todo What in the is the offset related to? Bytes or directory - * entry number? - * - * @todo In what do SEEK_SET and friends really mean? * * @todo In what does the reture and errno values mean? */ -int smbc_lseekdir(int dh, off_t offset, int whence); - +int smbc_lseekdir(int fd, off_t offset); /**@ingroup directory * Create a directory. @@ -580,12 +587,12 @@ int smbc_lseekdir(int dh, off_t offset, int whence); * permission to the process, or one of the directories * - ENOENT A directory component in pathname does not * exist. + * - EINVAL NULL durl passed. * - ENOMEM Insufficient memory was available. * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_rmdir() * - * @todo Are errno values complete and correct? */ int smbc_mkdir(const char *durl, mode_t mode); @@ -598,6 +605,7 @@ int smbc_mkdir(const char *durl, mode_t mode); * @return 0 on success, < 0 on error with errno set: * - EACCES or EPERM Write access to the directory * containing pathname was not allowed. + * - EINVAL durl is NULL. * - ENOENT A directory component in pathname does not * exist. * - ENOTEMPTY directory contains entries. @@ -622,13 +630,13 @@ int smbc_rmdir(const char *durl); * @return 0 on success, < 0 on error with errno set: * - ENOENT A component of the path file_name does not * exist. + * - EINVAL a NULL url was passed. * - EACCES Permission denied. * - ENOMEM Out of memory * - EUCLEAN smbc_init() failed or has not been called * * @see Unix stat() * - * @todo Are errno values complete and correct? */ int smbc_stat(const char *url, struct stat *st); @@ -642,11 +650,15 @@ int smbc_stat(const char *url, struct stat *st); * standard Unix struct stat information. * * @return EBADF filedes is bad. - * -EACCES Permission denied. - * -ENOMEM Out of memory + * - EACCES Permission denied. + * - EBADF fd is not a valid file descriptor + * - EINVAL ??? What is this for??? It is the wrong return + * - ENOMEM Out of memory * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_stat(), Unix stat() + * + * @todo Fix the EINVAL return ... It is wrong */ int smbc_fstat(int fd, struct stat *st); @@ -703,19 +715,18 @@ int smbc_chmod(const char *url, mode_t mode); /**@ingroup print * Print a file given the name in fname. It would be a URL ... * - * @param fname I do not know what this is it the url of the file - * to print? + * @param fname The URL of a file on a remote SMB server that the + * caller wants printed * - * @param printq I do not know what this is, is it the url of the - * printer to print to? + * @param printq The URL of the print share to print the file to. * - * @return 0 on success, < 0 on error with errno set: + * @return 0 on success, < 0 on error with errno set: * - * @todo I have no idea what this does. What is fname? What is - * printq? + * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL fname or printq was NULL + * and errors returned by smbc_open * - * @todo What errno values are possible here - */ +*/ int smbc_print_file(const char *fname, const char *printq); /**@ingroup print @@ -723,13 +734,14 @@ int smbc_print_file(const char *fname, const char *printq); * does an smbc_open call after checking if there is a file name on the * URI. If not, a temporary name is added ... * - * @param fname Is this the url of a print share? + * @param fname The URL of the print share to print to? * - * @returns A file handle right? - * - * @todo What errno values are possible here + * @returns A file handle for the print file if successful. + * Returns -1 if an error ocurred and errno has the values + * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL fname was NULL + * - all errors returned by smbc_open * - * @todo What is fname is it the url of a print share? */ int smbc_open_print_job(const char *fname); @@ -741,10 +753,10 @@ int smbc_open_print_job(const char *fname); * @param fn Callback function the receives printjob info * * @return 0 on success, < 0 on error with errno set: - * - * @todo what errno values are possible here? + * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL fname was NULL + * - EACCES ??? */ - int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn); /**@ingroup print @@ -755,6 +767,8 @@ int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn); * @param id The id of the job to delete * * @return 0 on success, < 0 on error with errno set: + * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL fname was NULL * * @todo what errno values are possible here? */ -- cgit From 9579f927dc5ce82bdf51ce49419dc039560e5e18 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sat, 10 Mar 2001 01:29:20 +0000 Subject: More documentation in the header in doxygen format (This used to be commit db2e712ad3ccfceb87d36e59d5f2e18a992b3e72) --- source3/include/libsmbclient.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 2fe0af35e6..e1c8cf5c87 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -244,12 +244,20 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * the access requested involved writing. * - EACCES The requested access to the file is not * allowed + * - ENODEV The requested share does not exist + * - ENOTDIR A file on the path is not a directory * - ENOENT A directory component in pathname does * not exist. * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_creat() * + * @note This call uses an underlying routine that may create + * a new connection to the server specified in the URL. + * If the credentials supplied in the URL, or via the + * auth_fn in the smbc_init call, fail, this call will + * try again with an empty username and password. This + * often gets mapped to the guest account on some machines. */ int smbc_open(const char *furl, int flags, mode_t mode); @@ -281,6 +289,7 @@ int smbc_open(const char *furl, int flags, mode_t mode); * allowed * - ENOENT A directory component in pathname does * not exist. + * - ENODEV The requested share does not exist. * - EUCLEAN smbc_init() failed or has not been called * @see smbc_open() * @@ -435,8 +444,8 @@ int smbc_unlink(const char *furl); * - EXDEV Rename across shares not supported. * - ENOMEM Insufficient kernel memory was available. * - EUCLEAN smbc_init() failed or has not been called + * - EEXIST The target file, nurl, already exists. * - * @todo Are errno values complete and correct? * * @todo Are we going to support copying when urls are not on the same * share? I say no... NOTE. I agree for the moment. @@ -633,6 +642,7 @@ int smbc_rmdir(const char *durl); * - EINVAL a NULL url was passed. * - EACCES Permission denied. * - ENOMEM Out of memory + * - ENOTDIR The target dir, url, is not a directory. * - EUCLEAN smbc_init() failed or has not been called * * @see Unix stat() @@ -652,13 +662,12 @@ int smbc_stat(const char *url, struct stat *st); * @return EBADF filedes is bad. * - EACCES Permission denied. * - EBADF fd is not a valid file descriptor - * - EINVAL ??? What is this for??? It is the wrong return + * - EINVAL Problems occurred in the underlying routines. * - ENOMEM Out of memory * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_stat(), Unix stat() * - * @todo Fix the EINVAL return ... It is wrong */ int smbc_fstat(int fd, struct stat *st); -- cgit From 5d72464a56bd2c28b19c169cd4b5febb4cc1091c Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Tue, 15 May 2001 01:47:22 +0000 Subject: Updated the inplace documentation to reflect change from EUCLEAN to EINVAL. (This used to be commit d090ae63aebbbbb4e1d2dbe438005742ed216e31) --- source3/include/libsmbclient.h | 71 +++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 39 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index e1c8cf5c87..54660c4853 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -237,7 +237,7 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * @return Valid file handle, < 0 on error with errno set: * - ENOMEM Out of memory * - EINVAL if an invalid parameter passed, like no - * file. + * file, or smbc_init not called. * - EEXIST pathname already exists and O_CREAT and * O_EXCL were used. * - EISDIR pathname refers to a directory and @@ -248,7 +248,6 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * - ENOTDIR A file on the path is not a directory * - ENOENT A directory component in pathname does * not exist. - * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_creat() * @@ -280,7 +279,7 @@ int smbc_open(const char *furl, int flags, mode_t mode); * @return Valid file handle, < 0 on error with errno set: * - ENOMEM Out of memory * - EINVAL if an invalid parameter passed, like no - * file. + * file, or smbc_init not called. * - EEXIST pathname already exists and O_CREAT and * O_EXCL were used. * - EISDIR pathname refers to a directory and @@ -290,7 +289,6 @@ int smbc_open(const char *furl, int flags, mode_t mode); * - ENOENT A directory component in pathname does * not exist. * - ENODEV The requested share does not exist. - * - EUCLEAN smbc_init() failed or has not been called * @see smbc_open() * */ @@ -311,8 +309,8 @@ int smbc_creat(const char *furl, mode_t mode); * - EBADF fd is not a valid file descriptor or * is not open for reading. * - EINVAL fd is attached to an object which is - * unsuitable for reading, or no buffer passed. - * - EUCLEAN smbc_init() failed or has not been called + * unsuitable for reading, or no buffer passed or + * smbc_init not called. * * @see smbc_open(), smbc_write() * @@ -334,8 +332,9 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize); * - EBADF fd is not a valid file descriptor or * is not open for reading. * - EINVAL fd is attached to an object which is - * unsuitable for reading, or no buffer passed. - * - EUCLEAN smbc_init() failed or has not been called + * unsuitable for reading, or no buffer passed or + * smbc_init not called. + * * @see smbc_open(), smbc_read() * */ @@ -363,8 +362,8 @@ ssize_t smbc_write(int fd, void *buf, size_t bufsize); * of (off_t)-1 is returned and errno is set to * indicate the error: * - EBADF Fildes is not an open file descriptor. - * - EINVAL Whence is not a proper value. - * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL Whence is not a proper value or smbc_init + * not called. * * @todo Are all the whence values really supported? * @@ -380,7 +379,7 @@ off_t smbc_lseek(int fd, off_t offset, int whence); * * @return 0 on success, < 0 on error with errno set: * - EBADF fd isn't a valid open file descriptor - * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL smbc_init() failed or has not been called * * @see smbc_open(), smbc_creat() */ @@ -399,10 +398,10 @@ int smbc_close(int fd); * search (execute) permission * - ENOENT A directory component in pathname does * not exist - * - EINVAL NULL was passed in the file param + * - EINVAL NULL was passed in the file param or + * smbc_init not called. * - EACCES You do not have access to the file * - ENOMEM Insufficient kernel memory was available - * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_rmdir()s * @@ -428,7 +427,8 @@ int smbc_unlink(const char *furl); * i.e., contains entries other than "." and ".." * - EINVAL The new url contained a path prefix * of the old, or, more generally, an attempt was - * made to make a directory a subdirectory of itself. + * made to make a directory a subdirectory of itself + * or smbc_init not called. * - ENOTDIR A component used as a directory in ourl * or nurl path is not, in fact, a directory. Or, * ourl is a directory, and newpath exists but is not @@ -443,7 +443,6 @@ int smbc_unlink(const char *furl); * does not exist. * - EXDEV Rename across shares not supported. * - ENOMEM Insufficient kernel memory was available. - * - EUCLEAN smbc_init() failed or has not been called * - EEXIST The target file, nurl, already exists. * * @@ -462,14 +461,14 @@ int smbc_rename(const char *ourl, const char *nurl); * @return Valid directory handle. < 0 on error with errno set: * - EACCES Permission denied. * - EINVAL A NULL file/URL was passed, or the URL would - * not parse, or was of incorrect form. + * not parse, or was of incorrect form or smbc_init not + * called. * - ENOENT durl does not exist, or name is an * - ENOMEM Insufficient memory to complete the * operation. * - ENOTDIR name is not a directory. * - EPERM the workgroup could not be found. * - ENODEV the workgroup or server could not be found. - * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_getdents(), smbc_readdir(), smbc_closedir() * @@ -507,9 +506,9 @@ int smbc_closedir(int dh); * total size. If there were no more dirents available, * 0 is returned. < 0 indicates an error. * - EBADF Invalid directory handle - * - EINVAL Result buffer is too small + * - EINVAL Result buffer is too small or smbc_init + * not called. * - ENOENT No such directory. - * - EUCLEAN smbc_init() failed or has not been called * @see , smbc_dirent, smbc_readdir(), smbc_open() * * @todo Are errno values complete and correct? @@ -527,7 +526,7 @@ int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); * @return A pointer to a smbc_dirent structure, or NULL if an * error occurs or end-of-directory is reached: * - EBADF Invalid directory handle - * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL smbc_init() failed or has not been called * * @see smbc_dirent, smbc_getdents(), smbc_open() */ @@ -548,7 +547,7 @@ struct smbc_dirent* smbc_readdir(unsigned int dh); * handle that allows the library to find the entry * later. * - EBADF dh is not a valid directory handle - * - EUCLEAN smbc_init() failed or has not been called + * - EINVAL smbc_init() failed or has not been called * - ENOTDIR if dh is not a directory * * @see smbc_readdir() @@ -569,10 +568,10 @@ off_t smbc_telldir(int dh); * NULL, in which case we will rewind * * @return 0 on success, -1 on failure - * - EUCLEAN smbc_init() failed or has not been called * - EBADF dh is not a valid directory handle * - ENOTDIR if dh is not a directory - * - EINVAL offset did not refer to a valid dirent + * - EINVAL offset did not refer to a valid dirent or + * smbc_init not called. * * @see smbc_telldir() * @@ -596,9 +595,8 @@ int smbc_lseekdir(int fd, off_t offset); * permission to the process, or one of the directories * - ENOENT A directory component in pathname does not * exist. - * - EINVAL NULL durl passed. + * - EINVAL NULL durl passed or smbc_init not called. * - ENOMEM Insufficient memory was available. - * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_rmdir() * @@ -614,12 +612,11 @@ int smbc_mkdir(const char *durl, mode_t mode); * @return 0 on success, < 0 on error with errno set: * - EACCES or EPERM Write access to the directory * containing pathname was not allowed. - * - EINVAL durl is NULL. + * - EINVAL durl is NULL or smbc_init not called. * - ENOENT A directory component in pathname does not * exist. * - ENOTEMPTY directory contains entries. * - ENOMEM Insufficient kernel memory was available. - * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_mkdir(), smbc_unlink() * @@ -639,11 +636,10 @@ int smbc_rmdir(const char *durl); * @return 0 on success, < 0 on error with errno set: * - ENOENT A component of the path file_name does not * exist. - * - EINVAL a NULL url was passed. + * - EINVAL a NULL url was passed or smbc_init not called. * - EACCES Permission denied. * - ENOMEM Out of memory * - ENOTDIR The target dir, url, is not a directory. - * - EUCLEAN smbc_init() failed or has not been called * * @see Unix stat() * @@ -662,9 +658,9 @@ int smbc_stat(const char *url, struct stat *st); * @return EBADF filedes is bad. * - EACCES Permission denied. * - EBADF fd is not a valid file descriptor - * - EINVAL Problems occurred in the underlying routines. + * - EINVAL Problems occurred in the underlying routines + * or smbc_init not called. * - ENOMEM Out of memory - * - EUCLEAN smbc_init() failed or has not been called * * @see smbc_stat(), Unix stat() * @@ -731,8 +727,8 @@ int smbc_chmod(const char *url, mode_t mode); * * @return 0 on success, < 0 on error with errno set: * - * - EUCLEAN smbc_init() failed or has not been called - * - EINVAL fname or printq was NULL + * - EINVAL fname or printq was NULL or smbc_init not + * not called. * and errors returned by smbc_open * */ @@ -747,8 +743,7 @@ int smbc_print_file(const char *fname, const char *printq); * * @returns A file handle for the print file if successful. * Returns -1 if an error ocurred and errno has the values - * - EUCLEAN smbc_init() failed or has not been called - * - EINVAL fname was NULL + * - EINVAL fname was NULL or smbc_init not called. * - all errors returned by smbc_open * */ @@ -762,8 +757,7 @@ int smbc_open_print_job(const char *fname); * @param fn Callback function the receives printjob info * * @return 0 on success, < 0 on error with errno set: - * - EUCLEAN smbc_init() failed or has not been called - * - EINVAL fname was NULL + * - EINVAL fname was NULL or smbc_init not called * - EACCES ??? */ int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn); @@ -776,8 +770,7 @@ int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn); * @param id The id of the job to delete * * @return 0 on success, < 0 on error with errno set: - * - EUCLEAN smbc_init() failed or has not been called - * - EINVAL fname was NULL + * - EINVAL fname was NULL or smbc_init not called * * @todo what errno values are possible here? */ -- cgit From 7c74cc5cab1d9db431197192a44b5fc08e0412f1 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Wed, 21 Nov 2001 03:55:59 +0000 Subject: Fix up libsmbclient in head. Apply the patches from Tom Jansen, get rid of fprintfs and change them to DEBUGs, etc ... (This used to be commit 7ac404c85303c9c3fbd48054fc4876bd4bc1567b) --- source3/include/libsmbclient.h | 189 +++++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 93 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 54660c4853..c6e9be3c47 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1,25 +1,25 @@ /*===================================================================== - Unix SMB/Netbios implementation. - Version 2.0 - SMB client library API definitions - Copyright (C) Andrew Tridgell 1998 - Copyright (C) Richard Sharpe 2000 - Copyright (C) John Terpsra 2000 + Unix SMB/Netbios implementation. + Version 2.0 + SMB client library API definitions + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000 + Copyright (C) John Terpsra 2000 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -=====================================================================*/ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + =====================================================================*/ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED @@ -27,25 +27,25 @@ /*-------------------------------------------------------------------*/ /* The following are special comments to instruct DOXYGEN (automated * documentation tool: -*/ + */ /** \defgroup structure Data Structures Type and Constants -* Data structures, types, and constants -*/ + * Data structures, types, and constants + */ /** \defgroup file File Functions -* Functions used to access individual file contents -*/ + * Functions used to access individual file contents + */ /** \defgroup directory Directory Functions -* Functions used to access directory entries -*/ + * Functions used to access directory entries + */ /** \defgroup attribute Attributes Functions -* Functions used to view or change file and directory attributes -*/ + * Functions used to view or change file and directory attributes + */ /** \defgroup print Print Functions -* Functions used to access printing functionality -*/ + * Functions used to access printing functionality + */ /** \defgroup attribute Miscellaneous Functions -* Functions that don't fit in to other categories -*/ + * Functions that don't fit in to other categories + */ /*-------------------------------------------------------------------*/ /* Make sure we have the following includes for now ... */ @@ -67,41 +67,44 @@ #define SMBC_FILE_MODE (S_IFREG | 0444) #define SMBC_DIR_MODE (S_IFDIR | 0555) +#define SMBC_MAX_FD 10000 + + /**@ingroup structure * Structure that represents a directory entry. * -*/ + */ struct smbc_dirent { - /** Type of entity. - SMBC_WORKGROUP=1, - SMBC_SERVER=2, - SMBC_FILE_SHARE=3, - SMBC_PRINTER_SHARE=4, - SMBC_COMMS_SHARE=5, - SMBC_IPC_SHARE=6, - SMBC_DIR=7, - SMBC_FILE=8, - SMBC_LINK=9,*/ - uint smbc_type; - - /** Length of this smbc_dirent in bytes - */ - uint dirlen; - /** The length of the comment string in bytes (includes null - * terminator) - */ - uint commentlen; - /** Points to the null terminated comment string - */ - char *comment; - /** The length of the name string in bytes (includes null - * terminator) - */ - uint namelen; - /** Points to the null terminated name string - */ - char name[1]; + /** Type of entity. + SMBC_WORKGROUP=1, + SMBC_SERVER=2, + SMBC_FILE_SHARE=3, + SMBC_PRINTER_SHARE=4, + SMBC_COMMS_SHARE=5, + SMBC_IPC_SHARE=6, + SMBC_DIR=7, + SMBC_FILE=8, + SMBC_LINK=9,*/ + uint smbc_type; + + /** Length of this smbc_dirent in bytes + */ + uint dirlen; + /** The length of the comment string in bytes (includes null + * terminator) + */ + uint commentlen; + /** Points to the null terminated comment string + */ + char *comment; + /** The length of the name string in bytes (includes null + * terminator) + */ + uint namelen; + /** Points to the null terminated name string + */ + char name[1]; }; @@ -114,30 +117,30 @@ typedef unsigned short uint16; */ struct print_job_info { - /** numeric ID of the print job - */ - uint16 id; + /** numeric ID of the print job + */ + uint16 id; - /** represents print job priority (lower numbers mean higher priority) - */ - uint16 priority; + /** represents print job priority (lower numbers mean higher priority) + */ + uint16 priority; - /** Size of the print job - */ - size_t size; + /** Size of the print job + */ + size_t size; - /** Name of the user that owns the print job - */ - char user[128]; + /** Name of the user that owns the print job + */ + char user[128]; - /** Name of the print job. This will have no name if an anonymous print - * file was opened. Ie smb://server/printer - */ - char name[128]; - - /** Time the print job was spooled - */ - time_t t; + /** Name of the print job. This will have no name if an anonymous print + * file was opened. Ie smb://server/printer + */ + char name[128]; + + /** Time the print job was spooled + */ + time_t t; }; #endif @@ -257,7 +260,7 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * auth_fn in the smbc_init call, fail, this call will * try again with an empty username and password. This * often gets mapped to the guest account on some machines. -*/ + */ int smbc_open(const char *furl, int flags, mode_t mode); @@ -291,7 +294,7 @@ int smbc_open(const char *furl, int flags, mode_t mode); * - ENODEV The requested share does not exist. * @see smbc_open() * -*/ + */ int smbc_creat(const char *furl, mode_t mode); @@ -368,7 +371,7 @@ ssize_t smbc_write(int fd, void *buf, size_t bufsize); * @todo Are all the whence values really supported? * * @todo Are errno values complete and correct? -*/ + */ off_t smbc_lseek(int fd, off_t offset, int whence); @@ -382,7 +385,7 @@ off_t smbc_lseek(int fd, off_t offset, int whence); * - EINVAL smbc_init() failed or has not been called * * @see smbc_open(), smbc_creat() -*/ + */ int smbc_close(int fd); @@ -406,7 +409,7 @@ int smbc_close(int fd); * @see smbc_rmdir()s * * @todo Are errno values complete and correct? -*/ + */ int smbc_unlink(const char *furl); @@ -449,7 +452,7 @@ int smbc_unlink(const char *furl); * @todo Are we going to support copying when urls are not on the same * share? I say no... NOTE. I agree for the moment. * -*/ + */ int smbc_rename(const char *ourl, const char *nurl); @@ -472,7 +475,7 @@ int smbc_rename(const char *ourl, const char *nurl); * * @see smbc_getdents(), smbc_readdir(), smbc_closedir() * -*/ + */ int smbc_opendir(const char *durl); @@ -485,7 +488,7 @@ int smbc_opendir(const char *durl); * - EBADF dh is an invalid directory handle * * @see smbc_opendir() -*/ + */ int smbc_closedir(int dh); @@ -529,7 +532,7 @@ int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); * - EINVAL smbc_init() failed or has not been called * * @see smbc_dirent, smbc_getdents(), smbc_open() -*/ + */ struct smbc_dirent* smbc_readdir(unsigned int dh); @@ -552,7 +555,7 @@ struct smbc_dirent* smbc_readdir(unsigned int dh); * * @see smbc_readdir() * -*/ + */ off_t smbc_telldir(int dh); @@ -600,7 +603,7 @@ int smbc_lseekdir(int fd, off_t offset); * * @see smbc_rmdir() * -*/ + */ int smbc_mkdir(const char *durl, mode_t mode); @@ -731,7 +734,7 @@ int smbc_chmod(const char *url, mode_t mode); * not called. * and errors returned by smbc_open * -*/ + */ int smbc_print_file(const char *fname, const char *printq); /**@ingroup print -- cgit From 8e267ac00700d7ca81126b9ce2178022c1e45c95 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 22 Nov 2001 04:29:10 +0000 Subject: Made a libsmbclient doxygen group and moved all the libsmbclient groups under it. (This used to be commit 43c496598f8e1aedc9c80222e60bb8e7b3027e03) --- source3/include/libsmbclient.h | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index c6e9be3c47..98701b2693 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -27,25 +27,33 @@ /*-------------------------------------------------------------------*/ /* The following are special comments to instruct DOXYGEN (automated * documentation tool: - */ +*/ +/** \defgroup libsmbclient +*/ /** \defgroup structure Data Structures Type and Constants - * Data structures, types, and constants - */ +* \ingroup libsmbclient +* Data structures, types, and constants +*/ /** \defgroup file File Functions - * Functions used to access individual file contents - */ +* \ingroup libsmbclient +* Functions used to access individual file contents +*/ /** \defgroup directory Directory Functions - * Functions used to access directory entries - */ +* \ingroup libsmbclient +* Functions used to access directory entries +*/ /** \defgroup attribute Attributes Functions - * Functions used to view or change file and directory attributes - */ +* \ingroup libsmbclient +* Functions used to view or change file and directory attributes +*/ /** \defgroup print Print Functions - * Functions used to access printing functionality - */ +* \ingroup libsmbclient +* Functions used to access printing functionality +*/ /** \defgroup attribute Miscellaneous Functions - * Functions that don't fit in to other categories - */ +* \ingroup libsmbclient +* Functions that don't fit in to other categories +*/ /*-------------------------------------------------------------------*/ /* Make sure we have the following includes for now ... */ -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/include/libsmbclient.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 98701b2693..e343b876d3 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1,6 +1,5 @@ /*===================================================================== - Unix SMB/Netbios implementation. - Version 2.0 + Unix SMB/CIFS implementation. SMB client library API definitions Copyright (C) Andrew Tridgell 1998 Copyright (C) Richard Sharpe 2000 -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/include/libsmbclient.h | 248 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 234 insertions(+), 14 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index e343b876d3..f269563996 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1,9 +1,11 @@ /*===================================================================== - Unix SMB/CIFS implementation. + Unix SMB/Netbios implementation. SMB client library API definitions Copyright (C) Andrew Tridgell 1998 Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpsra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -93,30 +95,28 @@ struct smbc_dirent SMBC_DIR=7, SMBC_FILE=8, SMBC_LINK=9,*/ - uint smbc_type; + unsigned int smbc_type; /** Length of this smbc_dirent in bytes */ - uint dirlen; + unsigned int dirlen; /** The length of the comment string in bytes (includes null * terminator) */ - uint commentlen; + unsigned int commentlen; /** Points to the null terminated comment string */ char *comment; /** The length of the name string in bytes (includes null * terminator) */ - uint namelen; + unsigned int namelen; /** Points to the null terminated name string */ char name[1]; }; - #ifndef _CLIENT_H -typedef unsigned short uint16; /**@ingroup structure * Structure that represents a print job. @@ -126,11 +126,11 @@ struct print_job_info { /** numeric ID of the print job */ - uint16 id; + unsigned short id; /** represents print job priority (lower numbers mean higher priority) */ - uint16 priority; + unsigned short priority; /** Size of the print job */ @@ -149,8 +149,7 @@ struct print_job_info */ time_t t; }; -#endif - +#endif /* ifndef _CLIENT_H */ /**@ingroup structure * Authentication callback function type. @@ -196,6 +195,227 @@ typedef void (*smbc_get_auth_data_fn)(const char *srv, */ typedef void (*smbc_get_print_job_info)(struct print_job_info *i); +typedef struct _SMBCSRV { + struct cli_state cli; + dev_t dev; + BOOL no_pathinfo2; + int server_fd; + + struct _SMBCSRV *next, *prev; + +} SMBCSRV; + +/* + * Keep directory entries in a list + */ +struct smbc_dir_list { + struct smbc_dir_list *next; + struct smbc_dirent *dirent; +}; + +/* + * Structure for open file management + */ +typedef struct _SMBCFILE { + int cli_fd; + char *fname; + off_t offset; + SMBCSRV *srv; + BOOL file; + struct smbc_dir_list *dir_list, *dir_end, *dir_next; + int dir_type, dir_error; + + struct _SMBCFILE *next, *prev; +} SMBCFILE; + +/**@ingroup structure + * Structure that contains a client context information + */ +typedef struct _SMBCCTX { + /** debug level + */ + int debug; + + /** netbios name used for making connections + */ + char * netbios_name; + + /** workgroup name used for making connections + */ + char * workgroup; + + /** username used for making connections + */ + char * user; + + /** timeout used for waiting on connections / response data (in milliseconds) + */ + int timeout; + + /** callable functions for files: + * For usage and return values see the smbc_* functions + */ + SMBCFILE * (*open) (struct _SMBCCTX *c, const char *fname, int flags, mode_t mode); + SMBCFILE * (*creat) (struct _SMBCCTX *c, const char *path, mode_t mode); + ssize_t (*read) (struct _SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); + ssize_t (*write) (struct _SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); + int (*unlink) (struct _SMBCCTX *c, const char *fname); + int (*rename) (struct _SMBCCTX *ocontext, const char *oname, + struct _SMBCCTX *ncontext, const char *nname); + off_t (*lseek) (struct _SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); + int (*stat) (struct _SMBCCTX *c, const char *fname, struct stat *st); + int (*fstat) (struct _SMBCCTX *c, SMBCFILE *file, struct stat *st); + int (*close) (struct _SMBCCTX *c, SMBCFILE *file); + + /** callable functions for dirs + */ + SMBCFILE * (*opendir) (struct _SMBCCTX *c, const char *fname); + int (*closedir)(struct _SMBCCTX *c, SMBCFILE *dir); + struct smbc_dirent * (*readdir)(struct _SMBCCTX *c, SMBCFILE *dir); + int (*getdents)(struct _SMBCCTX *c, SMBCFILE *dir, + struct smbc_dirent *dirp, int count); + int (*mkdir) (struct _SMBCCTX *c, const char *fname, mode_t mode); + int (*rmdir) (struct _SMBCCTX *c, const char *fname); + off_t (*telldir) (struct _SMBCCTX *c, SMBCFILE *dir); + int (*lseekdir)(struct _SMBCCTX *c, SMBCFILE *dir, off_t offset); + int (*fstatdir)(struct _SMBCCTX *c, SMBCFILE *dir, struct stat *st); + + /** callable functions for printing + */ + int (*print_file)(struct _SMBCCTX *c_file, const char *fname, + struct _SMBCCTX *c_print, const char *printq); + SMBCFILE * (*open_print_job)(struct _SMBCCTX *c, const char *fname); + int (*list_print_jobs)(struct _SMBCCTX *c, const char *fname, void (*fn)(struct print_job_info *)); + int (*unlink_print_job)(struct _SMBCCTX *c, const char *fname, int id); + + + /** Callbacks + * These callbacks _always_ have to be intialized because they will not be checked + * at dereference for increased speed. + */ + struct _smbc_callbacks { + /** authentication function callback: called upon auth requests + */ + smbc_get_auth_data_fn auth_fn; + + /** check if a server is still good + */ + int (*check_server_fn)(struct _SMBCCTX * c, SMBCSRV *srv); + + /** remove a server if unused + */ + int (*remove_unused_server_fn)(struct _SMBCCTX * c, SMBCSRV *srv); + + /** Cache subsystem + * For an example cache system see samba/source/libsmb/libsmb_cache.c + * Cache subsystem functions follow. + */ + + /** server cache addition + */ + int (*add_cached_srv_fn) (struct _SMBCCTX * c, SMBCSRV *srv, + char * server, char * share, + char * workgroup, char * username); + /** server cache lookup + */ + SMBCSRV * (*get_cached_srv_fn) (struct _SMBCCTX * c, char * server, + char * share, char * workgroup, char * username); + /** server cache removal + */ + int (*remove_cached_srv_fn)(struct _SMBCCTX * c, SMBCSRV *srv); + + /** server cache purging, try to remove all cached servers (disconnect) + */ + int (*purge_cached_fn) (struct _SMBCCTX * c); + + } callbacks; + + + /** Space to store private data of the server cache. + */ + void * server_cache; + + /** INTERNAL functions + * do _NOT_ touch these from your program ! + */ + + /** INTERNAL: is this handle initialized ? + */ + int _initialized; + + /** INTERNAL: dirent pointer location + */ + char _dirent[512]; + + /** INTERNAL: server connection list + */ + SMBCSRV * _servers; + + /** INTERNAL: open file/dir list + */ + SMBCFILE * _files; + +} SMBCCTX; + + +/**@ingroup misc + * Create a new SBMCCTX (a context). + * + * Must be called before the context is passed to smbc_context_init() + * + * @return The given SMBCCTX pointer on success, NULL on error with errno set: + * - ENOMEM Out of memory + * + * @see smbc_free_context(), smbc_init_context() + * + * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer ! + */ +SMBCCTX * smbc_new_context(void); + +/**@ingroup misc + * Delete a SBMCCTX (a context) acquired from smbc_new_context(). + * + * The context will be deleted if possible. + * + * @param context A pointer to a SMBCCTX obtained from smbc_new_context() + * + * @param shutdown_ctx If 1, all connections and files will be closed even if they are busy. + * + * + * @return Returns 0 on succes. Returns 1 on failure with errno set: + * - EBUSY Server connections are still used, Files are open or cache + * could not be purged + * - EBADF context == NULL + * + * @see smbc_new_context() + * + * @note It is advised to clean up all the contexts with shutdown_ctx set to 1 + * just before exit()'ing. When shutdown_ctx is 0, this function can be + * use in periodical cleanup functions for example. + */ +int smbc_free_context(SMBCCTX * context, int shutdown_ctx); + + +/**@ingroup misc + * Initialize a SBMCCTX (a context). + * + * Must be called before using any SMBCCTX API function + * + * @param context A pointer to a SMBCCTX obtained from smbc_new_context() + * + * @return A pointer to the given SMBCCTX on success, NULL on error with errno set: + * - EBADF NULL context given + * - ENOMEM Out of memory + * - ENOENT The smb.conf file would not load + * + * @see smbc_new_context() + * + * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe, + * but it might leak memory on smbc_context_init() failure. Avoid this. + * You'll have to call smbc_free_context() yourself on failure. + */ + +SMBCCTX * smbc_init_context(SMBCCTX * context); /**@ingroup misc * Initialize the samba client library. @@ -214,8 +434,8 @@ typedef void (*smbc_get_print_job_info)(struct print_job_info *i); * - ENOENT The smb.conf file would not load * */ -int smbc_init(smbc_get_auth_data_fn fn, int debug); +int smbc_init(smbc_get_auth_data_fn fn, int debug); /**@ingroup file * Open a file on an SMB server. @@ -268,8 +488,8 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * try again with an empty username and password. This * often gets mapped to the guest account on some machines. */ -int smbc_open(const char *furl, int flags, mode_t mode); +int smbc_open(const char *furl, int flags, mode_t mode); /**@ingroup file * Create a file on an SMB server. @@ -302,8 +522,8 @@ int smbc_open(const char *furl, int flags, mode_t mode); * @see smbc_open() * */ -int smbc_creat(const char *furl, mode_t mode); +int smbc_creat(const char *furl, mode_t mode); /**@ingroup file * Read from a file using an opened file handle. -- cgit From a834a73e341059be154426390304a42e4a011f72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 15:19:00 +0000 Subject: sync'ing up for 3.0alpha20 release (This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index f269563996..2b45709a5e 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -333,7 +333,7 @@ typedef struct _SMBCCTX { /** Space to store private data of the server cache. */ - void * server_cache; + struct smbc_server_cache * server_cache; /** INTERNAL functions * do _NOT_ touch these from your program ! -- cgit From 16925589eb1f12ebe6e493774fd4306a827feb73 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 13 Jan 2003 20:04:40 +0000 Subject: Now that I am running config.developer, I decided to get rif of some warnings: 1. reboot in parse_reg and cli_reg was shadowing a definition on FreeBSD 4.3 from system includes. 2. Added a bit of const to places. 3. Made sure internal functions were declared where needed. (This used to be commit fd847aa93690eb72f0437a8d22c03b222eb2a016) --- source3/include/libsmbclient.h | 257 +++++++++++++++++++++++++---------------- 1 file changed, 160 insertions(+), 97 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 2b45709a5e..0c905edcbc 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -35,6 +35,10 @@ * \ingroup libsmbclient * Data structures, types, and constants */ +/** \defgroup callback Callback function types +* \ingroup libsmbclient +* Callback functions +*/ /** \defgroup file File Functions * \ingroup libsmbclient * Functions used to access individual file contents @@ -51,7 +55,7 @@ * \ingroup libsmbclient * Functions used to access printing functionality */ -/** \defgroup attribute Miscellaneous Functions +/** \defgroup misc Miscellaneous Functions * \ingroup libsmbclient * Functions that don't fit in to other categories */ @@ -62,7 +66,6 @@ #include #include -#define SMBC_MAX_NAME 1023 #define SMBC_WORKGROUP 1 #define SMBC_SERVER 2 #define SMBC_FILE_SHARE 3 @@ -73,12 +76,6 @@ #define SMBC_FILE 8 #define SMBC_LINK 9 -#define SMBC_FILE_MODE (S_IFREG | 0444) -#define SMBC_DIR_MODE (S_IFDIR | 0555) - -#define SMBC_MAX_FD 10000 - - /**@ingroup structure * Structure that represents a directory entry. * @@ -116,12 +113,12 @@ struct smbc_dirent char name[1]; }; -#ifndef _CLIENT_H /**@ingroup structure * Structure that represents a print job. * */ +#ifndef _CLIENT_H struct print_job_info { /** numeric ID of the print job @@ -149,9 +146,29 @@ struct print_job_info */ time_t t; }; -#endif /* ifndef _CLIENT_H */ +#endif /* _CLIENT_H */ + + +/**@ingroup structure + * Server handle + */ +typedef struct _SMBCSRV SMBCSRV; /**@ingroup structure + * File or directory handle + */ +typedef struct _SMBCFILE SMBCFILE; + +/**@ingroup structure + * File or directory handle + */ +typedef struct _SMBCCTX SMBCCTX; + + + + + +/**@ingroup callback * Authentication callback function type. * * Type for the the authentication function called by the library to @@ -187,51 +204,114 @@ typedef void (*smbc_get_auth_data_fn)(const char *srv, char *pw, int pwlen); -/**@ingroup structure +/**@ingroup callback * Print job info callback function type. * * @param i pointer to print job information structure * */ -typedef void (*smbc_get_print_job_info)(struct print_job_info *i); +typedef void (*smbc_list_print_job_fn)(struct print_job_info *i); + -typedef struct _SMBCSRV { - struct cli_state cli; - dev_t dev; - BOOL no_pathinfo2; - int server_fd; +/**@ingroup callback + * Check if a server is still good + * + * @param c pointer to smb context + * + * @param srv pointer to server to check + * + * @return 0 when connection is good. 1 on error. + * + */ +typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv); - struct _SMBCSRV *next, *prev; - -} SMBCSRV; +/**@ingroup callback + * Remove a server if unused + * + * @param c pointer to smb context + * + * @param srv pointer to server to remove + * + * @return 0 on success. 1 on failure. + * + */ +typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv); -/* - * Keep directory entries in a list - */ -struct smbc_dir_list { - struct smbc_dir_list *next; - struct smbc_dirent *dirent; -}; -/* - * Structure for open file management +/**@ingroup callback + * Add a server to the cache system + * + * @param c pointer to smb context + * + * @param srv pointer to server to add + * + * @param server server name + * + * @param share share name + * + * @param workgroup workgroup used to connect + * + * @param username username used to connect + * + * @return 0 on success. 1 on failure. + * + */ +typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv, + char * server, char * share, + char * workgroup, char * username); + + +/**@ingroup callback + * Look up a server in the cache system + * + * @param c pointer to smb context + * + * @param server server name to match + * + * @param share share name to match + * + * @param workgroup workgroup to match + * + * @param username username to match + * + * @return pointer to SMBCSRV on success. NULL on failure. + * + */ +typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, char * server, + char * share, char * workgroup, char * username); + + +/**@ingroup callback + * Check if a server is still good + * + * @param c pointer to smb context + * + * @param srv pointer to server to remove + * + * @return 0 when found and removed. 1 on failure. + * + */ +typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); + + +/**@ingroup callback + * Try to remove all servers from the cache system and disconnect + * + * @param c pointer to smb context + * + * @return 0 when found and removed. 1 on failure. + * */ -typedef struct _SMBCFILE { - int cli_fd; - char *fname; - off_t offset; - SMBCSRV *srv; - BOOL file; - struct smbc_dir_list *dir_list, *dir_end, *dir_next; - int dir_type, dir_error; - - struct _SMBCFILE *next, *prev; -} SMBCFILE; +typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); + + + /**@ingroup structure * Structure that contains a client context information + * This structure is know as SMBCCTX */ -typedef struct _SMBCCTX { +struct _SMBCCTX { /** debug level */ int debug; @@ -255,42 +335,42 @@ typedef struct _SMBCCTX { /** callable functions for files: * For usage and return values see the smbc_* functions */ - SMBCFILE * (*open) (struct _SMBCCTX *c, const char *fname, int flags, mode_t mode); - SMBCFILE * (*creat) (struct _SMBCCTX *c, const char *path, mode_t mode); - ssize_t (*read) (struct _SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); - ssize_t (*write) (struct _SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); - int (*unlink) (struct _SMBCCTX *c, const char *fname); - int (*rename) (struct _SMBCCTX *ocontext, const char *oname, - struct _SMBCCTX *ncontext, const char *nname); - off_t (*lseek) (struct _SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); - int (*stat) (struct _SMBCCTX *c, const char *fname, struct stat *st); - int (*fstat) (struct _SMBCCTX *c, SMBCFILE *file, struct stat *st); - int (*close) (struct _SMBCCTX *c, SMBCFILE *file); + SMBCFILE * (*open) (SMBCCTX *c, const char *fname, int flags, mode_t mode); + SMBCFILE * (*creat) (SMBCCTX *c, const char *path, mode_t mode); + ssize_t (*read) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); + ssize_t (*write) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); + int (*unlink) (SMBCCTX *c, const char *fname); + int (*rename) (SMBCCTX *ocontext, const char *oname, + SMBCCTX *ncontext, const char *nname); + off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); + int (*stat) (SMBCCTX *c, const char *fname, struct stat *st); + int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st); + int (*close) (SMBCCTX *c, SMBCFILE *file); /** callable functions for dirs */ - SMBCFILE * (*opendir) (struct _SMBCCTX *c, const char *fname); - int (*closedir)(struct _SMBCCTX *c, SMBCFILE *dir); - struct smbc_dirent * (*readdir)(struct _SMBCCTX *c, SMBCFILE *dir); - int (*getdents)(struct _SMBCCTX *c, SMBCFILE *dir, + SMBCFILE * (*opendir) (SMBCCTX *c, const char *fname); + int (*closedir)(SMBCCTX *c, SMBCFILE *dir); + struct smbc_dirent * (*readdir)(SMBCCTX *c, SMBCFILE *dir); + int (*getdents)(SMBCCTX *c, SMBCFILE *dir, struct smbc_dirent *dirp, int count); - int (*mkdir) (struct _SMBCCTX *c, const char *fname, mode_t mode); - int (*rmdir) (struct _SMBCCTX *c, const char *fname); - off_t (*telldir) (struct _SMBCCTX *c, SMBCFILE *dir); - int (*lseekdir)(struct _SMBCCTX *c, SMBCFILE *dir, off_t offset); - int (*fstatdir)(struct _SMBCCTX *c, SMBCFILE *dir, struct stat *st); + int (*mkdir) (SMBCCTX *c, const char *fname, mode_t mode); + int (*rmdir) (SMBCCTX *c, const char *fname); + off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir); + int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset); + int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st); /** callable functions for printing */ - int (*print_file)(struct _SMBCCTX *c_file, const char *fname, - struct _SMBCCTX *c_print, const char *printq); - SMBCFILE * (*open_print_job)(struct _SMBCCTX *c, const char *fname); - int (*list_print_jobs)(struct _SMBCCTX *c, const char *fname, void (*fn)(struct print_job_info *)); - int (*unlink_print_job)(struct _SMBCCTX *c, const char *fname, int id); + int (*print_file)(SMBCCTX *c_file, const char *fname, + SMBCCTX *c_print, const char *printq); + SMBCFILE * (*open_print_job)(SMBCCTX *c, const char *fname); + int (*list_print_jobs)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn); + int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id); /** Callbacks - * These callbacks _always_ have to be intialized because they will not be checked + * These callbacks _always_ have to be initialized because they will not be checked * at dereference for increased speed. */ struct _smbc_callbacks { @@ -300,11 +380,11 @@ typedef struct _SMBCCTX { /** check if a server is still good */ - int (*check_server_fn)(struct _SMBCCTX * c, SMBCSRV *srv); + smbc_check_server_fn check_server_fn; /** remove a server if unused */ - int (*remove_unused_server_fn)(struct _SMBCCTX * c, SMBCSRV *srv); + smbc_remove_unused_server_fn remove_unused_server_fn; /** Cache subsystem * For an example cache system see samba/source/libsmb/libsmb_cache.c @@ -313,21 +393,19 @@ typedef struct _SMBCCTX { /** server cache addition */ - int (*add_cached_srv_fn) (struct _SMBCCTX * c, SMBCSRV *srv, - char * server, char * share, - char * workgroup, char * username); + smbc_add_cached_srv_fn add_cached_srv_fn; + /** server cache lookup */ - SMBCSRV * (*get_cached_srv_fn) (struct _SMBCCTX * c, char * server, - char * share, char * workgroup, char * username); + smbc_get_cached_srv_fn get_cached_srv_fn; + /** server cache removal */ - int (*remove_cached_srv_fn)(struct _SMBCCTX * c, SMBCSRV *srv); + smbc_remove_cached_srv_fn remove_cached_srv_fn; /** server cache purging, try to remove all cached servers (disconnect) */ - int (*purge_cached_fn) (struct _SMBCCTX * c); - + smbc_purge_cached_fn purge_cached_fn; } callbacks; @@ -335,27 +413,12 @@ typedef struct _SMBCCTX { */ struct smbc_server_cache * server_cache; - /** INTERNAL functions - * do _NOT_ touch these from your program ! - */ - - /** INTERNAL: is this handle initialized ? - */ - int _initialized; - - /** INTERNAL: dirent pointer location + /** INTERNAL DATA + * do _NOT_ touch this from your program ! */ - char _dirent[512]; - - /** INTERNAL: server connection list - */ - SMBCSRV * _servers; + struct smbc_internal_data * internal; - /** INTERNAL: open file/dir list - */ - SMBCFILE * _files; - -} SMBCCTX; +}; /**@ingroup misc @@ -990,7 +1053,7 @@ int smbc_open_print_job(const char *fname); * - EINVAL fname was NULL or smbc_init not called * - EACCES ??? */ -int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn); +int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn); /**@ingroup print * Delete a print job -- cgit From a8c95d79f83b4097ee20d5f3f1005c38ccf00186 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2003 12:13:07 +0000 Subject: Add support for the new modules system to auth/ (merge from HEAD) (This used to be commit c7a1de090db35835be1a1623bfc80c04065c5dd9) --- source3/include/libsmbclient.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 0c905edcbc..f5d653f697 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -257,9 +257,8 @@ typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv); * */ typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv, - char * server, char * share, - char * workgroup, char * username); - + const char * server, const char * share, + const char * workgroup, const char * username); /**@ingroup callback * Look up a server in the cache system @@ -277,9 +276,9 @@ typedef int (*smbc_add_cached_srv_fn) (SMBCCTX * c, SMBCSRV *srv, * @return pointer to SMBCSRV on success. NULL on failure. * */ -typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, char * server, - char * share, char * workgroup, char * username); - +typedef SMBCSRV * (*smbc_get_cached_srv_fn) (SMBCCTX * c, const char * server, + const char * share, const char * workgroup, + const char * username); /**@ingroup callback * Check if a server is still good -- cgit From 2f84a990bcfae7acaee0759359dd8867b24f600c Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 24 Oct 2003 17:01:19 +0000 Subject: Commit Derrell's changes to libsmbclient plus a small change to configure.in to see if SGI and other platforms will build. (This used to be commit cf9311044c372695592db1b95b814b0870b8cf29) --- source3/include/libsmbclient.h | 864 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 864 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index f5d653f697..afcafeed81 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -5,6 +5,7 @@ Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpsra 2000 Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003 This program is free software; you can redistribute it and/or modify @@ -65,6 +66,9 @@ #include #include #include +#include + +#define SMBC_BASE_FD 10000 /* smallest file descriptor returned */ #define SMBC_WORKGROUP 1 #define SMBC_SERVER 2 @@ -113,6 +117,20 @@ struct smbc_dirent char name[1]; }; +/* + * Flags for smbc_setxattr() + * Specify a bitwise OR of these, or 0 to add or replace as necessary + */ +#define SMBC_XATTR_FLAG_CREATE 0x1 /* fail if attr already exists */ +#define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */ + + +#ifndef ENOATTR +# define ENOATTR ENOENT /* No such attribute */ +#endif + + + /**@ingroup structure * Structure that represents a print job. @@ -358,6 +376,27 @@ struct _SMBCCTX { off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir); int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset); int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st); + int (*chmod)(SMBCCTX *c, const char *fname, mode_t mode); + int (*utimes)(SMBCCTX *c, + const char *fname, struct timeval *tbuf); + int (*setxattr)(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size, + int flags); + int (*getxattr)(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size); + int (*removexattr)(SMBCCTX *context, + const char *fname, + const char *name); + int (*listxattr)(SMBCCTX *context, + const char *fname, + char *list, + size_t size); /** callable functions for printing */ @@ -499,6 +538,30 @@ SMBCCTX * smbc_init_context(SMBCCTX * context); int smbc_init(smbc_get_auth_data_fn fn, int debug); +/**@ingroup misc + * Set or retrieve the compatibility library's context pointer + * + * @param context New context to use, or NULL. If a new context is provided, + * it must have allocated with smbc_new_context() and + * initialized with smbc_init_context(), followed, optionally, + * by some manual changes to some of the non-internal fields. + * + * @return The old context. + * + * @see smbc_new_context(), smbc_init_context(), smbc_init() + * + * @note This function may be called prior to smbc_init() to force + * use of the next context without any internal calls to + * smbc_new_context() or smbc_init_context(). It may also + * be called after smbc_init() has already called those two + * functions, to replace the existing context with a new one. + * Care should be taken, in this latter case, to ensure that + * the server cache and any data allocated by the + * authentication functions have been freed, if necessary. + */ + +SMBCCTX * smbc_set_context(SMBCCTX * new_context); + /**@ingroup file * Open a file on an SMB server. * @@ -1008,6 +1071,807 @@ int smbc_chown(const char *url, uid_t owner, gid_t group); */ int smbc_chmod(const char *url, mode_t mode); +/**@ingroup attribute + * Change the last modification time on a file + * + * @param url The smb url of the file or directory to change + * the modification time of + * + * @param tbuf A timeval structure which contains the desired + * modification time. NOTE: Only the tv_sec field is + * used. The tv_usec (microseconds) portion is ignored. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - EPERM Permission was denied. + * + */ +int smbc_utimes(const char *url, struct timeval *tbuf); + +#ifdef HAVE_UTIME_H +/**@ingroup attribute + * Change the last modification time on a file + * + * @param url The smb url of the file or directory to change + * the modification time of + * + * @param utbuf A utimebuf structure which contains the desired + * modification time. NOTE: Although the structure contains + * an access time as well, the access time value is ignored. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * + */ +int smbc_utime(const char *fname, struct utimbuf *utbuf); +#endif + +/**@ingroup attribute + * Set extended attributes for a file. This is used for modifying a file's + * security descriptor (i.e. owner, group, and access control list) + * + * @param url The smb url of the file or directory to set extended + * attributes for. + * + * @param name The name of an attribute to be changed. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter should contain a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @param value The value to be assigned to the specified attribute name. + * This buffer should contain only the attribute value if the + * name was of the "system.nt_sec_desc." + * form. If the name was of the "system.nt_sec_desc.*" form + * then a complete security descriptor, with name:value pairs + * separated by tabs, commas, or newlines (not spaces!), + * should be provided in this value buffer. A complete + * security descriptor will contain one or more entries + * selected from the following: + * + * REVISION: + * OWNER: + * GROUP: + * ACL::// + * + * The revision of the ACL specifies the internal Windows NT + * ACL revision for the security descriptor. If not specified + * it defaults to 1. Using values other than 1 may cause + * strange behaviour. + * + * The owner and group specify the owner and group sids for + * the object. If the attribute name (either '*+' with a + * complete security descriptor, or individual 'owner+' or + * 'group+' attribute names) ended with a plus sign, the + * specified name is resolved to a SID value, using the + * server on which the file or directory resides. Otherwise, + * the value should be provided in SID-printable format as + * S-1-x-y-z, and is used directly. The + * associated with the ACL: attribute should be provided + * similarly. + * + * @param size The number of the bytes of data in the value buffer + * + * @param flags A bit-wise OR of zero or more of the following: + * SMBC_XATTR_FLAG_CREATE - + * fail if the named attribute already exists + * SMBC_XATTR_FLAG_REPLACE - + * fail if the attribute does not already exist + * + * If neither flag is specified, the specified attributes + * will be added or replace existing attributes of the same + * name, as necessary. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * or one of the parameters is not of a correct + * form + * - ENOMEM No memory was available for internal needs + * - EEXIST If the attribute already exists and the flag + * SMBC_XATTR_FLAG_CREAT was specified + * - ENOATTR If the attribute does not exist and the flag + * SMBC_XATTR_FLAG_REPLACE was specified + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + * @note Attribute names are compared in a case-insensitive + * fashion. All of the following are equivalent, although + * the all-lower-case name is the preferred format: + * system.nt_sec_desc.owner + * SYSTEM.NT_SEC_DESC.OWNER + * sYsTeM.nt_sEc_desc.owNER + * + */ +int smbc_setxattr(const char *url, + const char *name, + const void *value, + size_t size, + int flags); + + +/**@ingroup attribute + * Set extended attributes for a file. This is used for modifying a file's + * security descriptor (i.e. owner, group, and access control list). The + * POSIX function which this maps to would act on a symbolic link rather than + * acting on what the symbolic link points to, but with no symbolic links in + * SMB file systems, this function is functionally identical to + * smbc_setxattr(). + * + * @param url The smb url of the file or directory to set extended + * attributes for. + * + * @param name The name of an attribute to be changed. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter should contain a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @param value The value to be assigned to the specified attribute name. + * This buffer should contain only the attribute value if the + * name was of the "system.nt_sec_desc." + * form. If the name was of the "system.nt_sec_desc.*" form + * then a complete security descriptor, with name:value pairs + * separated by tabs, commas, or newlines (not spaces!), + * should be provided in this value buffer. A complete + * security descriptor will contain one or more entries + * selected from the following: + * + * REVISION: + * OWNER: + * GROUP: + * ACL::// + * + * The revision of the ACL specifies the internal Windows NT + * ACL revision for the security descriptor. If not specified + * it defaults to 1. Using values other than 1 may cause + * strange behaviour. + * + * The owner and group specify the owner and group sids for + * the object. If the attribute name (either '*+' with a + * complete security descriptor, or individual 'owner+' or + * 'group+' attribute names) ended with a plus sign, the + * specified name is resolved to a SID value, using the + * server on which the file or directory resides. Otherwise, + * the value should be provided in SID-printable format as + * S-1-x-y-z, and is used directly. The + * associated with the ACL: attribute should be provided + * similarly. + * + * @param size The number of the bytes of data in the value buffer + * + * @param flags A bit-wise OR of zero or more of the following: + * SMBC_XATTR_FLAG_CREATE - + * fail if the named attribute already exists + * SMBC_XATTR_FLAG_REPLACE - + * fail if the attribute does not already exist + * + * If neither flag is specified, the specified attributes + * will be added or replace existing attributes of the same + * name, as necessary. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * or one of the parameters is not of a correct + * form + * - ENOMEM No memory was available for internal needs + * - EEXIST If the attribute already exists and the flag + * SMBC_XATTR_FLAG_CREAT was specified + * - ENOATTR If the attribute does not exist and the flag + * SMBC_XATTR_FLAG_REPLACE was specified + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + * @note Attribute names are compared in a case-insensitive + * fashion. All of the following are equivalent, although + * the all-lower-case name is the preferred format: + * system.nt_sec_desc.owner + * SYSTEM.NT_SEC_DESC.OWNER + * sYsTeM.nt_sEc_desc.owNER + * + */ +int smbc_lsetxattr(const char *url, + const char *name, + const void *value, + size_t size, + int flags); + + +/**@ingroup attribute + * Set extended attributes for a file. This is used for modifying a file's + * security descriptor (i.e. owner, group, and access control list) + * + * @param fd A file descriptor associated with an open file (as + * previously returned by smbc_open(), to get extended + * attributes for. + * + * @param name The name of an attribute to be changed. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter should contain a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @param value The value to be assigned to the specified attribute name. + * This buffer should contain only the attribute value if the + * name was of the "system.nt_sec_desc." + * form. If the name was of the "system.nt_sec_desc.*" form + * then a complete security descriptor, with name:value pairs + * separated by tabs, commas, or newlines (not spaces!), + * should be provided in this value buffer. A complete + * security descriptor will contain one or more entries + * selected from the following: + * + * REVISION: + * OWNER: + * GROUP: + * ACL::// + * + * The revision of the ACL specifies the internal Windows NT + * ACL revision for the security descriptor. If not specified + * it defaults to 1. Using values other than 1 may cause + * strange behaviour. + * + * The owner and group specify the owner and group sids for + * the object. If the attribute name (either '*+' with a + * complete security descriptor, or individual 'owner+' or + * 'group+' attribute names) ended with a plus sign, the + * specified name is resolved to a SID value, using the + * server on which the file or directory resides. Otherwise, + * the value should be provided in SID-printable format as + * S-1-x-y-z, and is used directly. The + * associated with the ACL: attribute should be provided + * similarly. + * + * @param size The number of the bytes of data in the value buffer + * + * @param flags A bit-wise OR of zero or more of the following: + * SMBC_XATTR_FLAG_CREATE - + * fail if the named attribute already exists + * SMBC_XATTR_FLAG_REPLACE - + * fail if the attribute does not already exist + * + * If neither flag is specified, the specified attributes + * will be added or replace existing attributes of the same + * name, as necessary. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * or one of the parameters is not of a correct + * form + * - ENOMEM No memory was available for internal needs + * - EEXIST If the attribute already exists and the flag + * SMBC_XATTR_FLAG_CREAT was specified + * - ENOATTR If the attribute does not exist and the flag + * SMBC_XATTR_FLAG_REPLACE was specified + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + * @note Attribute names are compared in a case-insensitive + * fashion. All of the following are equivalent, although + * the all-lower-case name is the preferred format: + * system.nt_sec_desc.owner + * SYSTEM.NT_SEC_DESC.OWNER + * sYsTeM.nt_sEc_desc.owNER + * + */ +int smbc_fsetxattr(int fd, + const char *name, + const void *value, + size_t size, + int flags); + + +/**@ingroup attribute + * Get extended attributes for a file. + * + * @param url The smb url of the file or directory to get extended + * attributes for. + * + * @param name The name of an attribute to be retrieved. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter will return a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @param value A pointer to a buffer in which the value of the specified + * attribute will be placed (unless size is zero). + * + * @param size The size of the buffer pointed to by value. This parameter + * may also be zero, in which case the size of the buffer + * required to hold the attribute value will be returned, + * but nothing will be placed into the value buffer. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * or one of the parameters is not of a correct + * form + * - ENOMEM No memory was available for internal needs + * - EEXIST If the attribute already exists and the flag + * SMBC_XATTR_FLAG_CREAT was specified + * - ENOATTR If the attribute does not exist and the flag + * SMBC_XATTR_FLAG_REPLACE was specified + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + */ +int smbc_getxattr(const char *url, + const char *name, + const void *value, + size_t size); + + +/**@ingroup attribute + * Get extended attributes for a file. The POSIX function which this maps to + * would act on a symbolic link rather than acting on what the symbolic link + * points to, but with no symbolic links in SMB file systems, this function + * is functionally identical to smbc_getxattr(). + * + * @param url The smb url of the file or directory to get extended + * attributes for. + * + * @param name The name of an attribute to be retrieved. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter will return a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @param value A pointer to a buffer in which the value of the specified + * attribute will be placed (unless size is zero). + * + * @param size The size of the buffer pointed to by value. This parameter + * may also be zero, in which case the size of the buffer + * required to hold the attribute value will be returned, + * but nothing will be placed into the value buffer. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * or one of the parameters is not of a correct + * form + * - ENOMEM No memory was available for internal needs + * - EEXIST If the attribute already exists and the flag + * SMBC_XATTR_FLAG_CREAT was specified + * - ENOATTR If the attribute does not exist and the flag + * SMBC_XATTR_FLAG_REPLACE was specified + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + */ +int smbc_lgetxattr(const char *url, + const char *name, + const void *value, + size_t size); + + +/**@ingroup attribute + * Get extended attributes for a file. + * + * @param fd A file descriptor associated with an open file (as + * previously returned by smbc_open(), to get extended + * attributes for. + * + * @param name The name of an attribute to be retrieved. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter will return a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @param value A pointer to a buffer in which the value of the specified + * attribute will be placed (unless size is zero). + * + * @param size The size of the buffer pointed to by value. This parameter + * may also be zero, in which case the size of the buffer + * required to hold the attribute value will be returned, + * but nothing will be placed into the value buffer. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * or one of the parameters is not of a correct + * form + * - ENOMEM No memory was available for internal needs + * - EEXIST If the attribute already exists and the flag + * SMBC_XATTR_FLAG_CREAT was specified + * - ENOATTR If the attribute does not exist and the flag + * SMBC_XATTR_FLAG_REPLACE was specified + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + */ +int smbc_fgetxattr(int fd, + const char *name, + const void *value, + size_t size); + + +/**@ingroup attribute + * Remove extended attributes for a file. This is used for modifying a file's + * security descriptor (i.e. owner, group, and access control list) + * + * @param url The smb url of the file or directory to remove the extended + * attributes for. + * + * @param name The name of an attribute to be removed. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter will return a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + */ +int smbc_removexattr(const char *url, + const char *name); + + +/**@ingroup attribute + * Remove extended attributes for a file. This is used for modifying a file's + * security descriptor (i.e. owner, group, and access control list) The POSIX + * function which this maps to would act on a symbolic link rather than acting + * on what the symbolic link points to, but with no symbolic links in SMB file + * systems, this function is functionally identical to smbc_removexattr(). + * + * @param url The smb url of the file or directory to remove the extended + * attributes for. + * + * @param name The name of an attribute to be removed. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter will return a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + */ +int smbc_lremovexattr(const char *url, + const char *name); + + +/**@ingroup attribute + * Remove extended attributes for a file. This is used for modifying a file's + * security descriptor (i.e. owner, group, and access control list) + * + * @param fd A file descriptor associated with an open file (as + * previously returned by smbc_open(), to get extended + * attributes for. + * + * @param name The name of an attribute to be removed. Names are of + * one of the following forms: + * + * system.nt_sec_desc. + * system.nt_sec_desc.* + * system.nt_sec_desc.*+ + * + * where is one of: + * + * revision + * owner + * owner+ + * group + * group+ + * acl: + * acl+: + * + * In the forms "system.nt_sec_desc.*" and + * "system.nt_sec_desc.*+", the asterisk and plus signs are + * literal, i.e. the string is provided exactly as shown, and + * the value parameter will return a complete security + * descriptor with name:value pairs separated by tabs, + * commas, or newlines (not spaces!). + * + * The plus sign ('+') indicates that SIDs should be mapped + * to names. Without the plus sign, SIDs are not mapped; + * rather they are simply converted to a string format. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + */ +int smbc_fremovexattr(int fd, + const char *name); + + +/**@ingroup attribute + * List the supported extended attribute names associated with a file + * + * @param url The smb url of the file or directory to list the extended + * attributes for. + * + * @param list A pointer to a buffer in which the list of attributes for + * the specified file or directory will be placed (unless + * size is zero). + * + * @param size The size of the buffer pointed to by list. This parameter + * may also be zero, in which case the size of the buffer + * required to hold all of the attribute names will be + * returned, but nothing will be placed into the list buffer. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + * @note This function always returns all attribute names supported + * by NT file systems, regardless of wether the referenced + * file system supports extended attributes (e.g. a Windows + * 2000 machine supports extended attributes if NTFS is used, + * but not if FAT is used, and Windows 98 doesn't support + * extended attributes at all. Whether this is a feature or + * a bug is yet to be decided. + */ +int smbc_listxattr(const char *url, + char *list, + size_t size); + +/**@ingroup attribute + * List the supported extended attribute names associated with a file The + * POSIX function which this maps to would act on a symbolic link rather than + * acting on what the symbolic link points to, but with no symbolic links in + * SMB file systems, this function is functionally identical to + * smbc_listxattr(). + * + * @param url The smb url of the file or directory to list the extended + * attributes for. + * + * @param list A pointer to a buffer in which the list of attributes for + * the specified file or directory will be placed (unless + * size is zero). + * + * @param size The size of the buffer pointed to by list. This parameter + * may also be zero, in which case the size of the buffer + * required to hold all of the attribute names will be + * returned, but nothing will be placed into the list buffer. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + * @note This function always returns all attribute names supported + * by NT file systems, regardless of wether the referenced + * file system supports extended attributes (e.g. a Windows + * 2000 machine supports extended attributes if NTFS is used, + * but not if FAT is used, and Windows 98 doesn't support + * extended attributes at all. Whether this is a feature or + * a bug is yet to be decided. + */ +int smbc_llistxattr(const char *url, + char *list, + size_t size); + +/**@ingroup attribute + * List the supported extended attribute names associated with a file + * + * @param fd A file descriptor associated with an open file (as + * previously returned by smbc_open(), to get extended + * attributes for. + * + * @param list A pointer to a buffer in which the list of attributes for + * the specified file or directory will be placed (unless + * size is zero). + * + * @param size The size of the buffer pointed to by list. This parameter + * may also be zero, in which case the size of the buffer + * required to hold all of the attribute names will be + * returned, but nothing will be placed into the list buffer. + * + * @return 0 on success, < 0 on error with errno set: + * - EINVAL The client library is not properly initialized + * - ENOMEM No memory was available for internal needs + * - EPERM Permission was denied. + * - ENOTSUP The referenced file system does not support + * extended attributes + * + * @note This function always returns all attribute names supported + * by NT file systems, regardless of wether the referenced + * file system supports extended attributes (e.g. a Windows + * 2000 machine supports extended attributes if NTFS is used, + * but not if FAT is used, and Windows 98 doesn't support + * extended attributes at all. Whether this is a feature or + * a bug is yet to be decided. + */ +int smbc_flistxattr(int fd, + char *list, + size_t size); /**@ingroup print * Print a file given the name in fname. It would be a URL ... -- cgit From 31e6157dfd2457252029f55616cafb0494aa4da0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 2 Nov 2003 14:15:36 +0000 Subject: Add prototype for smbc_remove_unused_server() to fix compiler warning. Bug #706. (This used to be commit eaf69b1ae7883573830244664cb0a81661541d92) --- source3/include/libsmbclient.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index afcafeed81..68c4a053d1 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1932,5 +1932,16 @@ int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn); */ int smbc_unlink_print_job(const char *purl, int id); +/**@ingroup callback + * Remove a server from the cached server list it's unused. + * + * @param context pointer to smb context + * + * @param srv pointer to server to remove + * + * @return On success, 0 is returned. 1 is returned if the server could not + * be removed. Also useable outside libsmbclient. + */ +int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv); #endif /* SMBCLIENT_H_INCLUDED */ -- cgit From c9f1b5b02260758a3e508fe5e4bff70cf32eef31 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sun, 9 May 2004 04:20:40 +0000 Subject: r599: Bug #1178. Make the libsmbclient routines callable by C++ programs. Also clean up the format of the file a bit. (This used to be commit 63c846fa1da7be563a3df8fff001324268887c1d) --- source3/include/libsmbclient.h | 293 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 264 insertions(+), 29 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 68c4a053d1..aaa19cb191 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -471,7 +471,13 @@ struct _SMBCCTX { * * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer ! */ +#ifdef __cplusplus +extern "C" { +#endif SMBCCTX * smbc_new_context(void); +#ifdef __cplusplus +} +#endif /**@ingroup misc * Delete a SBMCCTX (a context) acquired from smbc_new_context(). @@ -494,8 +500,13 @@ SMBCCTX * smbc_new_context(void); * just before exit()'ing. When shutdown_ctx is 0, this function can be * use in periodical cleanup functions for example. */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_free_context(SMBCCTX * context, int shutdown_ctx); - +#ifdef __cplusplus +} +#endif /**@ingroup misc * Initialize a SBMCCTX (a context). @@ -515,8 +526,13 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); * but it might leak memory on smbc_context_init() failure. Avoid this. * You'll have to call smbc_free_context() yourself on failure. */ - +#ifdef __cplusplus +extern "C" { +#endif SMBCCTX * smbc_init_context(SMBCCTX * context); +#ifdef __cplusplus +} +#endif /**@ingroup misc * Initialize the samba client library. @@ -536,7 +552,13 @@ SMBCCTX * smbc_init_context(SMBCCTX * context); * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_init(smbc_get_auth_data_fn fn, int debug); +#ifdef __cplusplus +} +#endif /**@ingroup misc * Set or retrieve the compatibility library's context pointer @@ -560,7 +582,13 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * authentication functions have been freed, if necessary. */ +#ifdef __cplusplus +extern "C" { +#endif SMBCCTX * smbc_set_context(SMBCCTX * new_context); +#ifdef __cplusplus +} +#endif /**@ingroup file * Open a file on an SMB server. @@ -613,8 +641,13 @@ SMBCCTX * smbc_set_context(SMBCCTX * new_context); * try again with an empty username and password. This * often gets mapped to the guest account on some machines. */ - +#ifdef __cplusplus +extern "C" { +#endif int smbc_open(const char *furl, int flags, mode_t mode); +#ifdef __cplusplus +} +#endif /**@ingroup file * Create a file on an SMB server. @@ -647,8 +680,13 @@ int smbc_open(const char *furl, int flags, mode_t mode); * @see smbc_open() * */ - +#ifdef __cplusplus +extern "C" { +#endif int smbc_creat(const char *furl, mode_t mode); +#ifdef __cplusplus +} +#endif /**@ingroup file * Read from a file using an opened file handle. @@ -670,8 +708,13 @@ int smbc_creat(const char *furl, mode_t mode); * @see smbc_open(), smbc_write() * */ +#ifdef __cplusplus +extern "C" { +#endif ssize_t smbc_read(int fd, void *buf, size_t bufsize); - +#ifdef __cplusplus +} +#endif /**@ingroup file * Write to a file using an opened file handle. @@ -693,8 +736,13 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize); * @see smbc_open(), smbc_read() * */ +#ifdef __cplusplus +extern "C" { +#endif ssize_t smbc_write(int fd, void *buf, size_t bufsize); - +#ifdef __cplusplus +} +#endif /**@ingroup file * Seek to a specific location in a file. @@ -724,8 +772,13 @@ ssize_t smbc_write(int fd, void *buf, size_t bufsize); * * @todo Are errno values complete and correct? */ +#ifdef __cplusplus +extern "C" { +#endif off_t smbc_lseek(int fd, off_t offset, int whence); - +#ifdef __cplusplus +} +#endif /**@ingroup file * Close an open file handle. @@ -738,8 +791,13 @@ off_t smbc_lseek(int fd, off_t offset, int whence); * * @see smbc_open(), smbc_creat() */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_close(int fd); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Unlink (delete) a file or directory. @@ -762,8 +820,13 @@ int smbc_close(int fd); * * @todo Are errno values complete and correct? */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_unlink(const char *furl); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Rename or move a file or directory. @@ -805,8 +868,13 @@ int smbc_unlink(const char *furl); * share? I say no... NOTE. I agree for the moment. * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_rename(const char *ourl, const char *nurl); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Open a directory used to obtain directory entries. @@ -828,8 +896,13 @@ int smbc_rename(const char *ourl, const char *nurl); * @see smbc_getdents(), smbc_readdir(), smbc_closedir() * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_opendir(const char *durl); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Close a directory handle opened by smbc_opendir(). @@ -841,8 +914,13 @@ int smbc_opendir(const char *durl); * * @see smbc_opendir() */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_closedir(int dh); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Get multiple directory entries. @@ -870,8 +948,13 @@ int smbc_closedir(int dh); * * @todo Add example code so people know how to parse buffers. */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Get a single directory entry. @@ -885,8 +968,13 @@ int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); * * @see smbc_dirent, smbc_getdents(), smbc_open() */ +#ifdef __cplusplus +extern "C" { +#endif struct smbc_dirent* smbc_readdir(unsigned int dh); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Get the current directory offset. @@ -908,8 +996,13 @@ struct smbc_dirent* smbc_readdir(unsigned int dh); * @see smbc_readdir() * */ +#ifdef __cplusplus +extern "C" { +#endif off_t smbc_telldir(int dh); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * lseek on directories. @@ -933,7 +1026,13 @@ off_t smbc_telldir(int dh); * * @todo In what does the reture and errno values mean? */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_lseekdir(int fd, off_t offset); +#ifdef __cplusplus +} +#endif /**@ingroup directory * Create a directory. @@ -956,8 +1055,13 @@ int smbc_lseekdir(int fd, off_t offset); * @see smbc_rmdir() * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_mkdir(const char *durl, mode_t mode); - +#ifdef __cplusplus +} +#endif /**@ingroup directory * Remove a directory. @@ -977,8 +1081,13 @@ int smbc_mkdir(const char *durl, mode_t mode); * * @todo Are errno values complete and correct? */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_rmdir(const char *durl); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Get information about a file or directory. @@ -999,8 +1108,13 @@ int smbc_rmdir(const char *durl); * @see Unix stat() * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_stat(const char *url, struct stat *st); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Get file information via an file descriptor. @@ -1020,8 +1134,13 @@ int smbc_stat(const char *url, struct stat *st); * @see smbc_stat(), Unix stat() * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_fstat(int fd, struct stat *st); - +#ifdef __cplusplus +} +#endif /**@ingroup attribue * Change the ownership of a file or directory. @@ -1046,8 +1165,13 @@ int smbc_fstat(int fd, struct stat *st); * @todo How do we abstract owner and group uid and gid? * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_chown(const char *url, uid_t owner, gid_t group); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Change the permissions of a file. @@ -1069,7 +1193,13 @@ int smbc_chown(const char *url, uid_t owner, gid_t group); * * @todo Are errno values complete and correct? */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_chmod(const char *url, mode_t mode); +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Change the last modification time on a file @@ -1086,7 +1216,13 @@ int smbc_chmod(const char *url, mode_t mode); * - EPERM Permission was denied. * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_utimes(const char *url, struct timeval *tbuf); +#ifdef __cplusplus +} +#endif #ifdef HAVE_UTIME_H /**@ingroup attribute @@ -1105,7 +1241,13 @@ int smbc_utimes(const char *url, struct timeval *tbuf); * - EPERM Permission was denied. * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_utime(const char *fname, struct utimbuf *utbuf); +#ifdef __cplusplus +} +#endif #endif /**@ingroup attribute @@ -1207,12 +1349,17 @@ int smbc_utime(const char *fname, struct utimbuf *utbuf); * sYsTeM.nt_sEc_desc.owNER * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_setxattr(const char *url, const char *name, const void *value, size_t size, int flags); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Set extended attributes for a file. This is used for modifying a file's @@ -1317,12 +1464,17 @@ int smbc_setxattr(const char *url, * sYsTeM.nt_sEc_desc.owNER * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_lsetxattr(const char *url, const char *name, const void *value, size_t size, int flags); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Set extended attributes for a file. This is used for modifying a file's @@ -1424,12 +1576,17 @@ int smbc_lsetxattr(const char *url, * sYsTeM.nt_sEc_desc.owNER * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Get extended attributes for a file. @@ -1487,11 +1644,16 @@ int smbc_fsetxattr(int fd, * extended attributes * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_getxattr(const char *url, const char *name, const void *value, size_t size); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Get extended attributes for a file. The POSIX function which this maps to @@ -1552,11 +1714,16 @@ int smbc_getxattr(const char *url, * extended attributes * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_lgetxattr(const char *url, const char *name, const void *value, size_t size); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Get extended attributes for a file. @@ -1615,11 +1782,16 @@ int smbc_lgetxattr(const char *url, * extended attributes * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_fgetxattr(int fd, const char *name, const void *value, size_t size); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Remove extended attributes for a file. This is used for modifying a file's @@ -1664,9 +1836,14 @@ int smbc_fgetxattr(int fd, * extended attributes * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_removexattr(const char *url, const char *name); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Remove extended attributes for a file. This is used for modifying a file's @@ -1714,9 +1891,14 @@ int smbc_removexattr(const char *url, * extended attributes * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_lremovexattr(const char *url, const char *name); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * Remove extended attributes for a file. This is used for modifying a file's @@ -1762,9 +1944,14 @@ int smbc_lremovexattr(const char *url, * extended attributes * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_fremovexattr(int fd, const char *name); - +#ifdef __cplusplus +} +#endif /**@ingroup attribute * List the supported extended attribute names associated with a file @@ -1796,9 +1983,15 @@ int smbc_fremovexattr(int fd, * extended attributes at all. Whether this is a feature or * a bug is yet to be decided. */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_listxattr(const char *url, char *list, size_t size); +#ifdef __cplusplus +} +#endif /**@ingroup attribute * List the supported extended attribute names associated with a file The @@ -1834,9 +2027,15 @@ int smbc_listxattr(const char *url, * extended attributes at all. Whether this is a feature or * a bug is yet to be decided. */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_llistxattr(const char *url, char *list, size_t size); +#ifdef __cplusplus +} +#endif /**@ingroup attribute * List the supported extended attribute names associated with a file @@ -1869,9 +2068,15 @@ int smbc_llistxattr(const char *url, * extended attributes at all. Whether this is a feature or * a bug is yet to be decided. */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_flistxattr(int fd, char *list, size_t size); +#ifdef __cplusplus +} +#endif /**@ingroup print * Print a file given the name in fname. It would be a URL ... @@ -1888,7 +2093,13 @@ int smbc_flistxattr(int fd, * and errors returned by smbc_open * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_print_file(const char *fname, const char *printq); +#ifdef __cplusplus +} +#endif /**@ingroup print * Open a print file that can be written to by other calls. This simply @@ -1903,7 +2114,13 @@ int smbc_print_file(const char *fname, const char *printq); * - all errors returned by smbc_open * */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_open_print_job(const char *fname); +#ifdef __cplusplus +} +#endif /**@ingroup print * List the print jobs on a print share, for the moment, pass a callback @@ -1916,7 +2133,13 @@ int smbc_open_print_job(const char *fname); * - EINVAL fname was NULL or smbc_init not called * - EACCES ??? */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn); +#ifdef __cplusplus +} +#endif /**@ingroup print * Delete a print job @@ -1930,7 +2153,13 @@ int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn); * * @todo what errno values are possible here? */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_unlink_print_job(const char *purl, int id); +#ifdef __cplusplus +} +#endif /**@ingroup callback * Remove a server from the cached server list it's unused. @@ -1942,6 +2171,12 @@ int smbc_unlink_print_job(const char *purl, int id); * @return On success, 0 is returned. 1 is returned if the server could not * be removed. Also useable outside libsmbclient. */ +#ifdef __cplusplus +extern "C" { +#endif int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv); +#ifdef __cplusplus +} +#endif #endif /* SMBCLIENT_H_INCLUDED */ -- cgit From c24c328a9e006473f4dba49fdf1842fb28952ec7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 24 Jan 2005 20:21:15 +0000 Subject: r4970: Fix for bug 2092, allowing fallback after kerberos and allow gnome vfs to prevent auto-anonymous logon. Jeremy. (This used to be commit 843e85bcd978d025964c4d45d9a3886c7cf7f63c) --- source3/include/libsmbclient.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index aaa19cb191..efb04285a7 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -455,9 +455,15 @@ struct _SMBCCTX { * do _NOT_ touch this from your program ! */ struct smbc_internal_data * internal; + + int flags; }; +/* Flags for SMBCCTX->flags */ +#define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) +#define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) +#define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */ /**@ingroup misc * Create a new SBMCCTX (a context). -- cgit From 9d65e0778425b1e49e789178999ce98e59395569 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 10 Mar 2005 23:41:19 +0000 Subject: r5735: rest of derrel's patch for BUG 2308; had to move the options structure from the _SMBCCTX to the internals structure to maintain binary compatibility (derrel, we should talk more about this) (This used to be commit a5ea01bf15758bb2be26ba16784dc0975be783bf) --- source3/include/libsmbclient.h | 88 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index efb04285a7..abcf660c9d 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -68,6 +68,8 @@ #include #include +#define SMBC_CTX_VERSION 1 + #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */ #define SMBC_WORKGROUP 1 @@ -125,6 +127,19 @@ struct smbc_dirent #define SMBC_XATTR_FLAG_REPLACE 0x2 /* fail if attr does not exist */ +/* + * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the + * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or + * "system.*") is specified. + */ +#define SMBC_DOS_MODE_READONLY 0x01 +#define SMBC_DOS_MODE_HIDDEN 0x02 +#define SMBC_DOS_MODE_SYSTEM 0x04 +#define SMBC_DOS_MODE_VOLUME_ID 0x08 +#define SMBC_DOS_MODE_DIRECTORY 0x10 +#define SMBC_DOS_MODE_ARCHIVE 0x20 + + #ifndef ENOATTR # define ENOATTR ENOENT /* No such attribute */ #endif @@ -457,13 +472,13 @@ struct _SMBCCTX { struct smbc_internal_data * internal; int flags; - }; /* Flags for SMBCCTX->flags */ #define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) #define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) #define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */ +#define SMBCCTX_FLAG_CTXVER (1 << 3 ) /* internal flag used to define _SMBCCTX version */ /**@ingroup misc * Create a new SBMCCTX (a context). @@ -2185,4 +2200,75 @@ int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv); } #endif +/**@ingroup directory + * Convert strings of %xx to their single character equivalent. + * + * @param dest A pointer to a buffer in which the resulting decoded + * string should be placed. This may be a pointer to the + * same buffer as src_segment. + * + * @param src A pointer to the buffer containing the URL to be decoded. + * Any %xx sequences herein are converted to their single + * character equivalent. Each 'x' must be a valid hexadecimal + * digit, or that % sequence is left undecoded. + * + * @param max_dest_len + * The size of the buffer pointed to by dest_segment. + * + * @return The number of % sequences which could not be converted + * due to lack of two following hexadecimal digits. + */ +#ifdef __cplusplus +extern "C" { +#endif +int +smbc_urldecode(char *dest, char * src, size_t max_dest_len); +#ifdef __cplusplus +} +#endif + + +/* + * Convert any characters not specifically allowed in a URL into their %xx + * equivalent. + * + * @param dest A pointer to a buffer in which the resulting encoded + * string should be placed. Unlike smbc_urldecode(), this + * must be a buffer unique from src. + * + * @param src A pointer to the buffer containing the string to be encoded. + * Any character not specifically allowed in a URL is converted + * into its hexadecimal value and encoded as %xx. + * + * @param max_dest_len + * The size of the buffer pointed to by dest_segment. + * + * @returns The remaining buffer length. + */ +#ifdef __cplusplus +extern "C" { +#endif +int +smbc_urlencode(char * dest, char * src, int max_dest_len); +#ifdef __cplusplus +} +#endif + + +/**@ingroup directory + * Return the version of the linked Samba code, and thus the version of the + * libsmbclient code. + * + * @return The version string. + */ +#ifdef __cplusplus +extern "C" { +#endif +const char * +smbc_version(void); +#ifdef __cplusplus +} +#endif + + #endif /* SMBCLIENT_H_INCLUDED */ -- cgit From 51310680ce751e30fd5b143e87d025e0dc92ff3c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Mar 2005 17:01:30 +0000 Subject: r5752: implement derrell's solution for binary compatibilty in the _SMBCCTX structure; note that we break compat with 3.0.11 but are ok with earlier versions (This used to be commit 6e8d171551bfe480cb1a526469defc33276550f6) --- source3/include/libsmbclient.h | 68 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index abcf660c9d..636083b41d 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -68,8 +68,6 @@ #include #include -#define SMBC_CTX_VERSION 1 - #define SMBC_BASE_FD 10000 /* smallest file descriptor returned */ #define SMBC_WORKGROUP 1 @@ -466,19 +464,79 @@ struct _SMBCCTX { */ struct smbc_server_cache * server_cache; + int flags; + + /** user options selections that apply to this session + */ + struct _smbc_options { + + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ + int browse_max_lmb_count; + + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ + int urlencode_readdir_entries; + + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ + int one_share_per_server; + } options; + /** INTERNAL DATA * do _NOT_ touch this from your program ! */ struct smbc_internal_data * internal; - - int flags; }; /* Flags for SMBCCTX->flags */ #define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) #define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) #define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */ -#define SMBCCTX_FLAG_CTXVER (1 << 3 ) /* internal flag used to define _SMBCCTX version */ /**@ingroup misc * Create a new SBMCCTX (a context). -- cgit From 100b7adcd7c8df76821839376bb363e7fbf02c82 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 20 Mar 2005 21:54:19 +0000 Subject: r5916: Only one C++ guard is necessary, not one around each smbc function. (This used to be commit e446f16a402bd2f2c0c0cda3db1bd0c423321230) --- source3/include/libsmbclient.h | 295 +++++------------------------------------ 1 file changed, 34 insertions(+), 261 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 636083b41d..ea013c113a 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -26,6 +26,10 @@ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif + /*-------------------------------------------------------------------*/ /* The following are special comments to instruct DOXYGEN (automated * documentation tool: @@ -550,13 +554,7 @@ struct _SMBCCTX { * * @note Do not forget to smbc_init_context() the returned SMBCCTX pointer ! */ -#ifdef __cplusplus -extern "C" { -#endif SMBCCTX * smbc_new_context(void); -#ifdef __cplusplus -} -#endif /**@ingroup misc * Delete a SBMCCTX (a context) acquired from smbc_new_context(). @@ -579,13 +577,8 @@ SMBCCTX * smbc_new_context(void); * just before exit()'ing. When shutdown_ctx is 0, this function can be * use in periodical cleanup functions for example. */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_free_context(SMBCCTX * context, int shutdown_ctx); -#ifdef __cplusplus -} -#endif + /**@ingroup misc * Initialize a SBMCCTX (a context). @@ -605,13 +598,8 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); * but it might leak memory on smbc_context_init() failure. Avoid this. * You'll have to call smbc_free_context() yourself on failure. */ -#ifdef __cplusplus -extern "C" { -#endif + SMBCCTX * smbc_init_context(SMBCCTX * context); -#ifdef __cplusplus -} -#endif /**@ingroup misc * Initialize the samba client library. @@ -631,13 +619,7 @@ SMBCCTX * smbc_init_context(SMBCCTX * context); * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_init(smbc_get_auth_data_fn fn, int debug); -#ifdef __cplusplus -} -#endif /**@ingroup misc * Set or retrieve the compatibility library's context pointer @@ -661,13 +643,7 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug); * authentication functions have been freed, if necessary. */ -#ifdef __cplusplus -extern "C" { -#endif SMBCCTX * smbc_set_context(SMBCCTX * new_context); -#ifdef __cplusplus -} -#endif /**@ingroup file * Open a file on an SMB server. @@ -720,13 +696,8 @@ SMBCCTX * smbc_set_context(SMBCCTX * new_context); * try again with an empty username and password. This * often gets mapped to the guest account on some machines. */ -#ifdef __cplusplus -extern "C" { -#endif + int smbc_open(const char *furl, int flags, mode_t mode); -#ifdef __cplusplus -} -#endif /**@ingroup file * Create a file on an SMB server. @@ -759,13 +730,8 @@ int smbc_open(const char *furl, int flags, mode_t mode); * @see smbc_open() * */ -#ifdef __cplusplus -extern "C" { -#endif + int smbc_creat(const char *furl, mode_t mode); -#ifdef __cplusplus -} -#endif /**@ingroup file * Read from a file using an opened file handle. @@ -787,13 +753,8 @@ int smbc_creat(const char *furl, mode_t mode); * @see smbc_open(), smbc_write() * */ -#ifdef __cplusplus -extern "C" { -#endif ssize_t smbc_read(int fd, void *buf, size_t bufsize); -#ifdef __cplusplus -} -#endif + /**@ingroup file * Write to a file using an opened file handle. @@ -815,13 +776,8 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize); * @see smbc_open(), smbc_read() * */ -#ifdef __cplusplus -extern "C" { -#endif ssize_t smbc_write(int fd, void *buf, size_t bufsize); -#ifdef __cplusplus -} -#endif + /**@ingroup file * Seek to a specific location in a file. @@ -851,13 +807,8 @@ ssize_t smbc_write(int fd, void *buf, size_t bufsize); * * @todo Are errno values complete and correct? */ -#ifdef __cplusplus -extern "C" { -#endif off_t smbc_lseek(int fd, off_t offset, int whence); -#ifdef __cplusplus -} -#endif + /**@ingroup file * Close an open file handle. @@ -870,13 +821,8 @@ off_t smbc_lseek(int fd, off_t offset, int whence); * * @see smbc_open(), smbc_creat() */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_close(int fd); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Unlink (delete) a file or directory. @@ -899,13 +845,8 @@ int smbc_close(int fd); * * @todo Are errno values complete and correct? */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_unlink(const char *furl); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Rename or move a file or directory. @@ -947,13 +888,8 @@ int smbc_unlink(const char *furl); * share? I say no... NOTE. I agree for the moment. * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_rename(const char *ourl, const char *nurl); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Open a directory used to obtain directory entries. @@ -975,13 +911,8 @@ int smbc_rename(const char *ourl, const char *nurl); * @see smbc_getdents(), smbc_readdir(), smbc_closedir() * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_opendir(const char *durl); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Close a directory handle opened by smbc_opendir(). @@ -993,13 +924,8 @@ int smbc_opendir(const char *durl); * * @see smbc_opendir() */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_closedir(int dh); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Get multiple directory entries. @@ -1027,13 +953,8 @@ int smbc_closedir(int dh); * * @todo Add example code so people know how to parse buffers. */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Get a single directory entry. @@ -1047,13 +968,8 @@ int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count); * * @see smbc_dirent, smbc_getdents(), smbc_open() */ -#ifdef __cplusplus -extern "C" { -#endif struct smbc_dirent* smbc_readdir(unsigned int dh); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Get the current directory offset. @@ -1075,13 +991,8 @@ struct smbc_dirent* smbc_readdir(unsigned int dh); * @see smbc_readdir() * */ -#ifdef __cplusplus -extern "C" { -#endif off_t smbc_telldir(int dh); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * lseek on directories. @@ -1105,13 +1016,7 @@ off_t smbc_telldir(int dh); * * @todo In what does the reture and errno values mean? */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_lseekdir(int fd, off_t offset); -#ifdef __cplusplus -} -#endif /**@ingroup directory * Create a directory. @@ -1134,13 +1039,8 @@ int smbc_lseekdir(int fd, off_t offset); * @see smbc_rmdir() * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_mkdir(const char *durl, mode_t mode); -#ifdef __cplusplus -} -#endif + /**@ingroup directory * Remove a directory. @@ -1160,13 +1060,8 @@ int smbc_mkdir(const char *durl, mode_t mode); * * @todo Are errno values complete and correct? */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_rmdir(const char *durl); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Get information about a file or directory. @@ -1187,13 +1082,8 @@ int smbc_rmdir(const char *durl); * @see Unix stat() * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_stat(const char *url, struct stat *st); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Get file information via an file descriptor. @@ -1213,13 +1103,8 @@ int smbc_stat(const char *url, struct stat *st); * @see smbc_stat(), Unix stat() * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_fstat(int fd, struct stat *st); -#ifdef __cplusplus -} -#endif + /**@ingroup attribue * Change the ownership of a file or directory. @@ -1244,13 +1129,8 @@ int smbc_fstat(int fd, struct stat *st); * @todo How do we abstract owner and group uid and gid? * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_chown(const char *url, uid_t owner, gid_t group); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Change the permissions of a file. @@ -1272,13 +1152,7 @@ int smbc_chown(const char *url, uid_t owner, gid_t group); * * @todo Are errno values complete and correct? */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_chmod(const char *url, mode_t mode); -#ifdef __cplusplus -} -#endif /**@ingroup attribute * Change the last modification time on a file @@ -1295,13 +1169,7 @@ int smbc_chmod(const char *url, mode_t mode); * - EPERM Permission was denied. * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_utimes(const char *url, struct timeval *tbuf); -#ifdef __cplusplus -} -#endif #ifdef HAVE_UTIME_H /**@ingroup attribute @@ -1320,13 +1188,7 @@ int smbc_utimes(const char *url, struct timeval *tbuf); * - EPERM Permission was denied. * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_utime(const char *fname, struct utimbuf *utbuf); -#ifdef __cplusplus -} -#endif #endif /**@ingroup attribute @@ -1428,17 +1290,12 @@ int smbc_utime(const char *fname, struct utimbuf *utbuf); * sYsTeM.nt_sEc_desc.owNER * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_setxattr(const char *url, const char *name, const void *value, size_t size, int flags); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Set extended attributes for a file. This is used for modifying a file's @@ -1543,17 +1400,12 @@ int smbc_setxattr(const char *url, * sYsTeM.nt_sEc_desc.owNER * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_lsetxattr(const char *url, const char *name, const void *value, size_t size, int flags); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Set extended attributes for a file. This is used for modifying a file's @@ -1655,17 +1507,12 @@ int smbc_lsetxattr(const char *url, * sYsTeM.nt_sEc_desc.owNER * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Get extended attributes for a file. @@ -1723,16 +1570,11 @@ int smbc_fsetxattr(int fd, * extended attributes * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_getxattr(const char *url, const char *name, const void *value, size_t size); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Get extended attributes for a file. The POSIX function which this maps to @@ -1793,16 +1635,11 @@ int smbc_getxattr(const char *url, * extended attributes * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_lgetxattr(const char *url, const char *name, const void *value, size_t size); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Get extended attributes for a file. @@ -1861,16 +1698,11 @@ int smbc_lgetxattr(const char *url, * extended attributes * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_fgetxattr(int fd, const char *name, const void *value, size_t size); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Remove extended attributes for a file. This is used for modifying a file's @@ -1915,14 +1747,9 @@ int smbc_fgetxattr(int fd, * extended attributes * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_removexattr(const char *url, const char *name); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Remove extended attributes for a file. This is used for modifying a file's @@ -1970,14 +1797,9 @@ int smbc_removexattr(const char *url, * extended attributes * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_lremovexattr(const char *url, const char *name); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * Remove extended attributes for a file. This is used for modifying a file's @@ -2023,14 +1845,9 @@ int smbc_lremovexattr(const char *url, * extended attributes * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_fremovexattr(int fd, const char *name); -#ifdef __cplusplus -} -#endif + /**@ingroup attribute * List the supported extended attribute names associated with a file @@ -2062,15 +1879,9 @@ int smbc_fremovexattr(int fd, * extended attributes at all. Whether this is a feature or * a bug is yet to be decided. */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_listxattr(const char *url, char *list, size_t size); -#ifdef __cplusplus -} -#endif /**@ingroup attribute * List the supported extended attribute names associated with a file The @@ -2106,15 +1917,9 @@ int smbc_listxattr(const char *url, * extended attributes at all. Whether this is a feature or * a bug is yet to be decided. */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_llistxattr(const char *url, char *list, size_t size); -#ifdef __cplusplus -} -#endif /**@ingroup attribute * List the supported extended attribute names associated with a file @@ -2147,15 +1952,9 @@ int smbc_llistxattr(const char *url, * extended attributes at all. Whether this is a feature or * a bug is yet to be decided. */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_flistxattr(int fd, char *list, size_t size); -#ifdef __cplusplus -} -#endif /**@ingroup print * Print a file given the name in fname. It would be a URL ... @@ -2172,13 +1971,7 @@ int smbc_flistxattr(int fd, * and errors returned by smbc_open * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_print_file(const char *fname, const char *printq); -#ifdef __cplusplus -} -#endif /**@ingroup print * Open a print file that can be written to by other calls. This simply @@ -2193,13 +1986,7 @@ int smbc_print_file(const char *fname, const char *printq); * - all errors returned by smbc_open * */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_open_print_job(const char *fname); -#ifdef __cplusplus -} -#endif /**@ingroup print * List the print jobs on a print share, for the moment, pass a callback @@ -2212,13 +1999,7 @@ int smbc_open_print_job(const char *fname); * - EINVAL fname was NULL or smbc_init not called * - EACCES ??? */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn); -#ifdef __cplusplus -} -#endif /**@ingroup print * Delete a print job @@ -2232,13 +2013,7 @@ int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn); * * @todo what errno values are possible here? */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_unlink_print_job(const char *purl, int id); -#ifdef __cplusplus -} -#endif /**@ingroup callback * Remove a server from the cached server list it's unused. @@ -2250,10 +2025,8 @@ int smbc_unlink_print_job(const char *purl, int id); * @return On success, 0 is returned. 1 is returned if the server could not * be removed. Also useable outside libsmbclient. */ -#ifdef __cplusplus -extern "C" { -#endif int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv); + #ifdef __cplusplus } #endif -- cgit From 3a8af94424c8d60dd80f6b57806ef0b79465badc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Jul 2005 12:05:07 +0000 Subject: r8093: Next round. Now it compiles with --enable-socket-wrapper. Volker (This used to be commit 25cbcfba30f534f3fb31627ba43421c42ccd5b0f) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index ea013c113a..3269d6f0bf 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -379,7 +379,7 @@ struct _SMBCCTX { off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); int (*stat) (SMBCCTX *c, const char *fname, struct stat *st); int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st); - int (*close) (SMBCCTX *c, SMBCFILE *file); + int (*close_fn) (SMBCCTX *c, SMBCFILE *file); /** callable functions for dirs */ -- cgit From 7dd03e891e3aa06aa000e9bea8e0bad8ede34c8c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 23 Aug 2005 19:53:34 +0000 Subject: r9540: correct comments in struct smbc_dirent (fixes bug 3030) (This used to be commit 1f8aff85a68569480efc543cfe1556752c35311e) --- source3/include/libsmbclient.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 3269d6f0bf..2d7d96c2dd 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -105,15 +105,15 @@ struct smbc_dirent /** Length of this smbc_dirent in bytes */ unsigned int dirlen; - /** The length of the comment string in bytes (includes null - * terminator) + /** The length of the comment string in bytes (does not include + * null terminator) */ unsigned int commentlen; /** Points to the null terminated comment string */ char *comment; - /** The length of the name string in bytes (includes null - * terminator) + /** The length of the name string in bytes (does not include + * null terminator) */ unsigned int namelen; /** Points to the null terminated name string -- cgit From fcceedd67c29bae6941949a16ebef37e95dab601 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Nov 2005 06:19:34 +0000 Subject: r11573: Adding Andrew Bartlett's patch to make machine account logons work if the client gives the MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT or MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT flags. This changes the auth module interface to 2 (from 1). The effect of this is that clients can access resources as a machine account if they set these flags. This is the same as Windows (think of a VPN where the vpn client authenticates itself to a VPN server using machine account credentials - the vpn server checks that the machine password was valid by performing a machine account check with the PDC in the same was as it would a user account check. I may add in a restriction (parameter) to allow this behaviour to be turned off (as it was previously). That may be on by default. Andrew Bartlett please review this change carefully. Jeremy. (This used to be commit d1caef866326346fb191f8129d13d98379f18cd8) --- source3/include/libsmbclient.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 2d7d96c2dd..46896d68e4 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -339,6 +339,11 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); +/* close was renamed to close_fn, because close is often a macro. + * Allow backward compatability where this is not the case */ +#ifndef close +#define close close_fn +#endif /**@ingroup structure -- cgit From 5cc61b382539f76e7e6c0dc499cef2226b1d8767 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 14 Nov 2005 06:42:44 +0000 Subject: r11719: Remove silly #define of close -> close_fn as this borks any code that includes libsmbclient.h that also calls the system close() fn. Doh ! Thanks to John Terpstra for reporting this. Jeremy. (This used to be commit 6e1cb7047aae80523a53d5552a4f704cd6e62997) --- source3/include/libsmbclient.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 46896d68e4..6d3a0cda09 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -339,13 +339,6 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); -/* close was renamed to close_fn, because close is often a macro. - * Allow backward compatability where this is not the case */ -#ifndef close -#define close close_fn -#endif - - /**@ingroup structure * Structure that contains a client context information * This structure is know as SMBCCTX -- cgit From e836508704dd964e22e8bfc0f8e9ec520a2c94f2 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 22 Mar 2006 22:05:19 +0000 Subject: r14664: r13868@cabra: derrell | 2006-03-22 17:04:30 -0500 Implement enhancement request 3505. Two additional features are added here. There is now a method of saving an opaque user data handle in the smbc_ context, and there is now a way to request that the context be passed to the authentication function. See examples/libsmbclient/testbrowse.c for an example of using these features. (This used to be commit 203b4911c16bd7e10198a6f0e63960f2813025ef) --- source3/include/libsmbclient.h | 96 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 10 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 6d3a0cda09..ba92259f70 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -204,7 +204,7 @@ typedef struct _SMBCCTX SMBCCTX; /**@ingroup callback - * Authentication callback function type. + * Authentication callback function type (traditional method) * * Type for the the authentication function called by the library to * obtain authentication credentals @@ -237,6 +237,43 @@ typedef void (*smbc_get_auth_data_fn)(const char *srv, char *wg, int wglen, char *un, int unlen, char *pw, int pwlen); +/**@ingroup callback + * Authentication callback function type (method that includes context) + * + * Type for the the authentication function called by the library to + * obtain authentication credentals + * + * @param c Pointer to the smb context + * + * @param srv Server being authenticated to + * + * @param shr Share being authenticated to + * + * @param wg Pointer to buffer containing a "hint" for the + * workgroup to be authenticated. Should be filled in + * with the correct workgroup if the hint is wrong. + * + * @param wglen The size of the workgroup buffer in bytes + * + * @param un Pointer to buffer containing a "hint" for the + * user name to be use for authentication. Should be + * filled in with the correct workgroup if the hint is + * wrong. + * + * @param unlen The size of the username buffer in bytes + * + * @param pw Pointer to buffer containing to which password + * copied + * + * @param pwlen The size of the password buffer in bytes + * + */ +typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c, + const char *srv, + const char *shr, + char *wg, int wglen, + char *un, int unlen, + char *pw, int pwlen); /**@ingroup callback @@ -422,14 +459,15 @@ struct _SMBCCTX { int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id); - /** Callbacks - * These callbacks _always_ have to be initialized because they will not be checked - * at dereference for increased speed. - */ + /* + ** Callbacks + * These callbacks _always_ have to be initialized because they will + * not be checked at dereference for increased speed. + */ struct _smbc_callbacks { /** authentication function callback: called upon auth requests */ - smbc_get_auth_data_fn auth_fn; + smbc_get_auth_data_fn auth_fn; /** check if a server is still good */ @@ -578,6 +616,41 @@ SMBCCTX * smbc_new_context(void); int smbc_free_context(SMBCCTX * context, int shutdown_ctx); +/**@ingroup misc + * Each time the context structure is changed, we have binary backward + * compatibility issues. Instead of modifying the public portions of the + * context structure to add new options, instead, we put them in the internal + * portion of the context structure and provide a set function for these new + * options. + * + * @param context A pointer to a SMBCCTX obtained from smbc_new_context() + * + * @param option_name + * The name of the option for which the value is to be set + * + * @param option_value + * The new value of the option being set + * + */ +void +smbc_option_set(SMBCCTX *context, + char *option_name, + void *option_value); +/* + * Retrieve the current value of an option + * + * @param context A pointer to a SMBCCTX obtained from smbc_new_context() + * + * @param option_name + * The name of the option for which the value is to be + * retrieved + * + * @return The value of the specified option. + */ +void * +smbc_option_get(SMBCCTX *context, + char *option_name); + /**@ingroup misc * Initialize a SBMCCTX (a context). * @@ -585,16 +658,19 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); * * @param context A pointer to a SMBCCTX obtained from smbc_new_context() * - * @return A pointer to the given SMBCCTX on success, NULL on error with errno set: + * @return A pointer to the given SMBCCTX on success, + * NULL on error with errno set: * - EBADF NULL context given * - ENOMEM Out of memory * - ENOENT The smb.conf file would not load * * @see smbc_new_context() * - * @note my_context = smbc_init_context(smbc_new_context()) is perfectly safe, - * but it might leak memory on smbc_context_init() failure. Avoid this. - * You'll have to call smbc_free_context() yourself on failure. + * @note my_context = smbc_init_context(smbc_new_context()) + * is perfectly safe, but it might leak memory on + * smbc_context_init() failure. Avoid this. + * You'll have to call smbc_free_context() yourself + * on failure. */ SMBCCTX * smbc_init_context(SMBCCTX * context); -- cgit From 9718506d35ca14c5233b613c647609bf2589f38b Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 27 Jun 2006 02:30:58 +0000 Subject: r16550: Fix bug 3866. Thanks for the report! Although I've never met a computer or compiler that produced pointers to functions which are a different size than pointers to data, I suppose they probably exist. Assigning a pointer to a function is technically illegal in C anyway. Change casts of the option_value based on the option_name to use of variable argument lists. For binary compatibility, I've maintained but deprecated the old behavior of debug_stderr (which expected to be passed a NULL or non-NULL pointer) and added a new option debug_to_stderr which properly expects a boolean (int) parameter. Derrell (This used to be commit c1b4c510530ca3118d1eccb9615a8cad732c7373) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index ba92259f70..66a567a0d5 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -635,7 +635,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); void smbc_option_set(SMBCCTX *context, char *option_name, - void *option_value); + ... /* option_value */); /* * Retrieve the current value of an option * -- cgit From 315f4162111d210d0f65123c8c7fe7084a12121c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 3 Sep 2006 02:10:24 +0000 Subject: r18013: Fix for "bug" (enhancement) 3684. Provide a new option to specify the share mode to be used when opening a file. (This used to be commit 9b6fee5f6f60638ed80fdedcce4b3d29b091f7aa) --- source3/include/libsmbclient.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 66a567a0d5..45f2a41b08 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -141,6 +141,20 @@ struct smbc_dirent #define SMBC_DOS_MODE_DIRECTORY 0x10 #define SMBC_DOS_MODE_ARCHIVE 0x20 +/* + * Valid values for the option "open_share_mode", when calling + * smbc_option_set() + */ +typedef enum smbc_share_mode +{ + SMBC_SHAREMODE_DENY_DOS = 0, + SMBC_SHAREMODE_DENY_ALL = 1, + SMBC_SHAREMODE_DENY_WRITE = 2, + SMBC_SHAREMODE_DENY_READ = 3, + SMBC_SHAREMODE_DENY_NONE = 4, + SMBC_SHAREMODE_DENY_FCB = 7 +} smbc_share_mode; + #ifndef ENOATTR # define ENOATTR ENOENT /* No such attribute */ -- cgit From 7bcf281c9ca60e0d2caea33cdc5a18a33e4d6145 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 3 Feb 2007 17:13:58 +0000 Subject: r21132: - Fixes bug 4366. Documentation for smbc_utimes() was incorrect. - Should fix bug 4115 (but needs confirmation from OP). If the kerberos use flag is set in the context, then also pass it to smbc_attr_server for use by cli_full_connection() - Should fix bug 4309 (but needs confirmation from OP). We no longer send a keepalive packet unconditionally. Instead, we assume (yes, possibly incorrectly, but it's the best guess we can make) that if the connection is on port 139, it's netbios and otherwise, it isn't. If netbios is in use, we send a keepalive packet. Otherwise, we check that the connection is alive using getpeername(). (This used to be commit 2f9be59c10ef991a51cc858ab594187b5ca61382) --- source3/include/libsmbclient.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 45f2a41b08..5d674264d8 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1242,14 +1242,16 @@ int smbc_chown(const char *url, uid_t owner, gid_t group); */ int smbc_chmod(const char *url, mode_t mode); -/**@ingroup attribute +/** + * @ingroup attribute * Change the last modification time on a file * * @param url The smb url of the file or directory to change * the modification time of - * - * @param tbuf A timeval structure which contains the desired - * modification time. NOTE: Only the tv_sec field is + * + * @param tbuf An array of two timeval structures which contains, + * respectively, the desired access and modification times. + * NOTE: Only the tv_sec field off each timeval structure is * used. The tv_usec (microseconds) portion is ignored. * * @return 0 on success, < 0 on error with errno set: @@ -1260,15 +1262,15 @@ int smbc_chmod(const char *url, mode_t mode); int smbc_utimes(const char *url, struct timeval *tbuf); #ifdef HAVE_UTIME_H -/**@ingroup attribute +/** + * @ingroup attribute * Change the last modification time on a file * * @param url The smb url of the file or directory to change * the modification time of - * - * @param utbuf A utimebuf structure which contains the desired - * modification time. NOTE: Although the structure contains - * an access time as well, the access time value is ignored. + * + * @param utbuf A pointer to a utimebuf structure which contains the + * desired access and modification times. * * @return 0 on success, < 0 on error with errno set: * - EINVAL The client library is not properly initialized -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 5d674264d8..545792a7e5 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -10,7 +10,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/include/libsmbclient.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 545792a7e5..9175b33d60 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -19,8 +19,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program; if not, see . =====================================================================*/ #ifndef SMBCLIENT_H_INCLUDED -- cgit From 011e89c85868ec8f16e475a560a0e5bd41995920 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 13 Jan 2008 17:10:06 -0500 Subject: Fix smbc_listxattr() and friends (bug #5189) When the capability of using full names for DOS attributes was added, a bug was introduced which caused the wrong number of bytes to be returned. This patch to smbc_listxattr_ctx() fixes the problem. Thanks to Jack Schmidt for this patch. Derrell (This used to be commit 913c335d21c503d32b35bf65da7b2bddf0473875) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 9175b33d60..07242f7956 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1961,7 +1961,7 @@ int smbc_fremovexattr(int fd, * extended attributes * * @note This function always returns all attribute names supported - * by NT file systems, regardless of wether the referenced + * by NT file systems, regardless of whether the referenced * file system supports extended attributes (e.g. a Windows * 2000 machine supports extended attributes if NTFS is used, * but not if FAT is used, and Windows 98 doesn't support -- cgit From fa341d526293f4d986f2f3d838a728ce4223ee88 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 26 Feb 2008 21:44:51 -0500 Subject: add smbc_ftruncate() to emulate POSIX ftruncate() (This used to be commit 6f5051b9c1405ab1dc3e697419ceedb3acac46d8) --- source3/include/libsmbclient.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 07242f7956..64afc09499 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -427,6 +427,8 @@ struct _SMBCCTX { off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); int (*stat) (SMBCCTX *c, const char *fname, struct stat *st); int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st); + /* ftruncate added near _internal for ABI compatibility */ + int (*close_fn) (SMBCCTX *c, SMBCFILE *file); /** callable functions for dirs @@ -520,6 +522,12 @@ struct _SMBCCTX { int flags; /** user options selections that apply to this session + * + * NEW OPTIONS ARE NOT ADDED HERE! + * + * We must maintain ABI backward compatibility. We now use + * smbc_option_set() and smbc_option_get() for all newly added + * options. */ struct _smbc_options { @@ -580,6 +588,9 @@ struct _SMBCCTX { int one_share_per_server; } options; + /* Add additional functions here for ABI backward compatibility */ + int (*ftruncate)(SMBCCTX *c, SMBCFILE *f, off_t size); + /** INTERNAL DATA * do _NOT_ touch this from your program ! */ @@ -1193,6 +1204,26 @@ int smbc_stat(const char *url, struct stat *st); int smbc_fstat(int fd, struct stat *st); +/**@ingroup attribute + * Truncate a file given a file descriptor + * + * @param fd Open file handle from smbc_open() or smbc_creat() + * + * @param size size to truncate the file to + * + * @return EBADF filedes is bad. + * - EACCES Permission denied. + * - EBADF fd is not a valid file descriptor + * - EINVAL Problems occurred in the underlying routines + * or smbc_init not called. + * - ENOMEM Out of memory + * + * @see , Unix ftruncate() + * + */ +int smbc_ftruncate(int fd, off_t size); + + /**@ingroup attribue * Change the ownership of a file or directory. * -- cgit From 257b7b09298f7cb983b2f31b87fc5e46e0f62f0c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 28 Feb 2008 11:23:20 -0500 Subject: Initial revamp of the libsmbclient interface. The libsmbclient interface has suffered from difficulty of improvement and feature enrichment without causing ABI breakage. Although there were a number of issues, the primary ones were: (a) the user of the library would manually manipulate the context structure members, meaning that nothing in the context structure could change other than adding stuff at the end; (b) there were three methods of setting options: setting bits in a flags field within the context structure, setting explicit options variables within an options structure in the context structure, and by calling the smbc_option_set() function; (c) the authentication callback did not traditionally provide enough information to the callee which required adding an option for a callback with a different signature, and now there are requests for even more information at the callback, requiring yet a third signature and option to set it (if we implement that feature). This commit provides a reorganization of the code which fixes (a) and (b). The context structure is now entirely opaque, and there are setter and getter functions for manipulating it. This makes maintaining ABI consistency much, much easier. Additionally, the options setting/getting has been unified into a single mechanism using smbc_option_set() and smbc_option_get(). Yet to be completed is a refactoring of the authentication callback (c). The test programs in examples/libsmbclient have been modified (if necessary; some applications require no changes at all) for the new API and a few have been minimally tested. Derrell (This used to be commit d4b4bae8ded824d06ad5ab0e219f71187ee5c771) --- source3/include/libsmbclient.h | 495 ++++++++++++++++++++++++----------------- 1 file changed, 292 insertions(+), 203 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 64afc09499..a998bcee69 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -386,221 +386,310 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); * @return 0 when found and removed. 1 on failure. * */ -typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); +typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); -/**@ingroup structure - * Structure that contains a client context information - * This structure is know as SMBCCTX +/** Get the debug level */ +int smbc_getDebug(SMBCCTX *c); + +/** Set the debug level */ +void smbc_setDebug(SMBCCTX *c, int debug); + +/** Get the netbios name used for making connections */ +char * smbc_getNetbiosName(SMBCCTX *c); + +/** Set the netbios name used for making connections */ +void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name); + +/** Get the workgroup used for making connections */ +char * smbc_getWorkgroup(SMBCCTX *c); + +/** Set the workgroup used for making connections */ +void smbc_setWorkgroup(SMBCCTX *c, char * workgroup); + +/** Get the username used for making connections */ +char * smbc_getUser(SMBCCTX *c); + +/** Set the username used for making connections */ +void smbc_setUser(SMBCCTX *c, char * user); + +/** + * Get the timeout used for waiting on connections and response data + * (in milliseconds) */ -struct _SMBCCTX { - /** debug level - */ - int debug; - - /** netbios name used for making connections - */ - char * netbios_name; +int smbc_getTimeout(SMBCCTX *c); - /** workgroup name used for making connections - */ - char * workgroup; +/** + * Set the timeout used for waiting on connections and response data + * (in milliseconds) + */ +void smbc_setTimeout(SMBCCTX *c, int timeout); - /** username used for making connections - */ - char * user; +/** Get the function for obtaining authentication data */ +smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); - /** timeout used for waiting on connections / response data (in milliseconds) - */ - int timeout; - - /** callable functions for files: - * For usage and return values see the smbc_* functions - */ - SMBCFILE * (*open) (SMBCCTX *c, const char *fname, int flags, mode_t mode); - SMBCFILE * (*creat) (SMBCCTX *c, const char *path, mode_t mode); - ssize_t (*read) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); - ssize_t (*write) (SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); - int (*unlink) (SMBCCTX *c, const char *fname); - int (*rename) (SMBCCTX *ocontext, const char *oname, - SMBCCTX *ncontext, const char *nname); - off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); - int (*stat) (SMBCCTX *c, const char *fname, struct stat *st); - int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st); - /* ftruncate added near _internal for ABI compatibility */ - - int (*close_fn) (SMBCCTX *c, SMBCFILE *file); - - /** callable functions for dirs - */ - SMBCFILE * (*opendir) (SMBCCTX *c, const char *fname); - int (*closedir)(SMBCCTX *c, SMBCFILE *dir); - struct smbc_dirent * (*readdir)(SMBCCTX *c, SMBCFILE *dir); - int (*getdents)(SMBCCTX *c, SMBCFILE *dir, - struct smbc_dirent *dirp, int count); - int (*mkdir) (SMBCCTX *c, const char *fname, mode_t mode); - int (*rmdir) (SMBCCTX *c, const char *fname); - off_t (*telldir) (SMBCCTX *c, SMBCFILE *dir); - int (*lseekdir)(SMBCCTX *c, SMBCFILE *dir, off_t offset); - int (*fstatdir)(SMBCCTX *c, SMBCFILE *dir, struct stat *st); - int (*chmod)(SMBCCTX *c, const char *fname, mode_t mode); - int (*utimes)(SMBCCTX *c, - const char *fname, struct timeval *tbuf); - int (*setxattr)(SMBCCTX *context, - const char *fname, - const char *name, - const void *value, - size_t size, - int flags); - int (*getxattr)(SMBCCTX *context, - const char *fname, - const char *name, - const void *value, - size_t size); - int (*removexattr)(SMBCCTX *context, - const char *fname, - const char *name); - int (*listxattr)(SMBCCTX *context, +/** Set the function for obtaining authentication data */ +void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); + +/** Get the function for checking if a server is still good */ +smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c); + +/** Set the function for checking if a server is still good */ +void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn f); + +/** Get the function for removing a server if unused */ +smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c); + +/** Set the function for removing a server if unused */ +void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, + smbc_remove_unused_server_fn f); + +/** Get the function for adding a cached server */ +smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c); + +/** Set the function for adding a cached server */ +void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn f); + +/** Get the function for server cache lookup */ +smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c); + +/** Set the function for server cache lookup */ +void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn f); + +/** Get the function for server cache removal */ +smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c); + +/** Set the function for server cache removal */ +void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, + smbc_remove_cached_srv_fn f); + +/** + * Get the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); + +/** + * Set the function for server cache purging. This function tries to + * remove all cached servers (e.g. on disconnect) + */ +void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, + smbc_purge_cached_srv_fn f); + +/** Get the function to store private data of the server cache */ +struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); + +/** Set the function to store private data of the server cache */ +void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache); + + +/** + * Callable functions for files. + */ + +typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c, + const char *fname, + int flags, + mode_t mode); +smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c); +void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn f); + +typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c, + const char *path, + mode_t mode); +smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c); +void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn); + +typedef ssize_t (*smbc_read_fn)(SMBCCTX *c, + SMBCFILE *file, + void *buf, + size_t count); +smbc_read_fn smbc_getFunctionRead(SMBCCTX *c); +void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn f); + +typedef ssize_t (*smbc_write_fn)(SMBCCTX *c, + SMBCFILE *file, + void *buf, + size_t count); +smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c); +void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn f); + +typedef int (*smbc_unlink_fn)(SMBCCTX *c, + const char *fname); +smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c); +void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn f); + +typedef int (*smbc_rename_fn)(SMBCCTX *ocontext, + const char *oname, + SMBCCTX *ncontext, + const char *nname); +smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c); +void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn f); + +typedef off_t (*smbc_lseek_fn)(SMBCCTX *c, + SMBCFILE * file, + off_t offset, + int whence); +smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c); +void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn f); + +typedef int (*smbc_stat_fn)(SMBCCTX *c, + const char *fname, + struct stat *st); +smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c); +void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn f); + +typedef int (*smbc_fstat_fn)(SMBCCTX *c, + SMBCFILE *file, + struct stat *st); +smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c); +void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn f); + +typedef int (*smbc_ftruncate_fn)(SMBCCTX *c, + SMBCFILE *f, + off_t size); +smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c); +void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn f); + +typedef int (*smbc_close_fn)(SMBCCTX *c, + SMBCFILE *file); +smbc_close_fn smbc_getFunctionClose(SMBCCTX *c); +void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); + + +/** + * Callable functions for directories. + */ + +typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c, + const char *fname); +smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c); +void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn f); + +typedef int (*smbc_closedir_fn)(SMBCCTX *c, + SMBCFILE *dir); +smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c); +void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn f); + +typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c, + SMBCFILE *dir); +smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c); +void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn f); + +typedef int (*smbc_getdents_fn)(SMBCCTX *c, + SMBCFILE *dir, + struct smbc_dirent *dirp, + int count); +smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c); +void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn f); + +typedef int (*smbc_mkdir_fn)(SMBCCTX *c, + const char *fname, + mode_t mode); +smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c); +void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn f); + +typedef int (*smbc_rmdir_fn)(SMBCCTX *c, + const char *fname); +smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c); +void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn f); + +typedef off_t (*smbc_telldir_fn)(SMBCCTX *c, + SMBCFILE *dir); +smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c); +void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn f); + +typedef int (*smbc_lseekdir_fn)(SMBCCTX *c, + SMBCFILE *dir, + off_t offset); +smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c); +void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn f); + +typedef int (*smbc_fstatdir_fn)(SMBCCTX *c, + SMBCFILE *dir, + struct stat *st); +smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c); +void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn f); + + +/** + * Callable functions applicable to both files and directories. + */ + +typedef int (*smbc_chmod_fn)(SMBCCTX *c, + const char *fname, + mode_t mode); +smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c); +void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn f); + +typedef int (*smbc_utimes_fn)(SMBCCTX *c, + const char *fname, + struct timeval *tbuf); +smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c); +void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn f); + +typedef int (*smbc_setxattr_fn)(SMBCCTX *context, + const char *fname, + const char *name, + const void *value, + size_t size, + int flags); +smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c); +void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn f); + +typedef int (*smbc_getxattr_fn)(SMBCCTX *context, const char *fname, - char *list, + const char *name, + const void *value, size_t size); +smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c); +void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn f); - /** callable functions for printing - */ - int (*print_file)(SMBCCTX *c_file, const char *fname, - SMBCCTX *c_print, const char *printq); - SMBCFILE * (*open_print_job)(SMBCCTX *c, const char *fname); - int (*list_print_jobs)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn); - int (*unlink_print_job)(SMBCCTX *c, const char *fname, int id); - - - /* - ** Callbacks - * These callbacks _always_ have to be initialized because they will - * not be checked at dereference for increased speed. - */ - struct _smbc_callbacks { - /** authentication function callback: called upon auth requests - */ - smbc_get_auth_data_fn auth_fn; - - /** check if a server is still good - */ - smbc_check_server_fn check_server_fn; - - /** remove a server if unused - */ - smbc_remove_unused_server_fn remove_unused_server_fn; - - /** Cache subsystem - * For an example cache system see samba/source/libsmb/libsmb_cache.c - * Cache subsystem functions follow. - */ - - /** server cache addition - */ - smbc_add_cached_srv_fn add_cached_srv_fn; - - /** server cache lookup - */ - smbc_get_cached_srv_fn get_cached_srv_fn; - - /** server cache removal - */ - smbc_remove_cached_srv_fn remove_cached_srv_fn; - - /** server cache purging, try to remove all cached servers (disconnect) - */ - smbc_purge_cached_fn purge_cached_fn; - } callbacks; +typedef int (*smbc_removexattr_fn)(SMBCCTX *context, + const char *fname, + const char *name); +smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c); +void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn f); +typedef int (*smbc_listxattr_fn)(SMBCCTX *context, + const char *fname, + char *list, + size_t size); +smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c); +void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn f); - /** Space to store private data of the server cache. - */ - struct smbc_server_cache * server_cache; - - int flags; - - /** user options selections that apply to this session - * - * NEW OPTIONS ARE NOT ADDED HERE! - * - * We must maintain ABI backward compatibility. We now use - * smbc_option_set() and smbc_option_get() for all newly added - * options. - */ - struct _smbc_options { - - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ - int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ - int urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ - int one_share_per_server; - } options; - - /* Add additional functions here for ABI backward compatibility */ - int (*ftruncate)(SMBCCTX *c, SMBCFILE *f, off_t size); - - /** INTERNAL DATA - * do _NOT_ touch this from your program ! - */ - struct smbc_internal_data * internal; -}; -/* Flags for SMBCCTX->flags */ -#define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) -#define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) -#define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */ +/** + * Callable functions related to printing + */ + +typedef int (*smbc_print_file_fn)(SMBCCTX *c_file, + const char *fname, + SMBCCTX *c_print, + const char *printq); +smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c); +void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn f); + +typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c, + const char *fname); +smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c); +void smbc_setFunctionOpenPrintJob(SMBCCTX *c, + smbc_open_print_job_fn f); + +typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c, + const char *fname, + smbc_list_print_job_fn fn); +smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c); +void smbc_setFunctionListPrintJobs(SMBCCTX *c, + smbc_list_print_jobs_fn f); + +typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c, + const char *fname, + int id); +smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c); +void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, + smbc_unlink_print_job_fn f); + /**@ingroup misc * Create a new SBMCCTX (a context). -- cgit From 4ba42cbe0f6bbd25848786e1a87c06aca79b98ea Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Fri, 29 Feb 2008 13:34:35 -0500 Subject: Modified revamp of the libsmbclient interface. Given the tacit (if that) approval by some people, and clear disapproval by others for my proposed clean-up and reorganization of libsmbclient, I've come up with a slightly different approach. This commit changes back to the original libsmbclient.h SMBCCTX structure which will maintain ABI compatibility. I retain, here, the setter and getter functions which all new code should use. Older programs already compiled should continue to work fine. Older programs being recompiled will encounter compile-time errors (intentionally!) so that the code can be corrected to use the setter/getter interfaces. Although this doesn't clean up the interface in the way I had wanted, the code reorganization and requirement for new programs to use the setters and getters allows future progress to be made on libsmbclient without further muddying up the interface, while retaining the ABI compatibility that was the big issue causing disapproval. I hope that this compromise is adequate. Derrell (This used to be commit 56429a3d60b2a48963342f6340b3c01469a892c6) --- source3/include/libsmbclient.h | 282 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 281 insertions(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index a998bcee69..4d78bb2568 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -5,7 +5,7 @@ Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpsra 2000 Copyright (C) Tom Jansen (Ninja ISD) 2002 - Copyright (C) Derrell Lipman 2003 + Copyright (C) Derrell Lipman 2003-2008 This program is free software; you can redistribute it and/or modify @@ -213,6 +213,15 @@ typedef struct _SMBCFILE SMBCFILE; typedef struct _SMBCCTX SMBCCTX; +/* + * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + * For these options, use smbc_option_set() and smbc_option_get(). + */ + +/* Flags for SMBCCTX->flags */ +# define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) +# define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) +# define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) @@ -2311,4 +2320,275 @@ smbc_version(void); #endif +/** + * @ingroup structure + * Structure that contains a client context information + * This structure is known as SMBCCTX + * + * DO NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE! The data in the context + * structure should all be considered private to the library. It remains here + * only for backward compatibility. + * + * See the comments herein for use of the setter and getter functions which + * should now be used for manipulating these values. New features, functions, + * etc., are not added here but rather in _internal where they are not + * directly visible to applications. This makes it much easier to maintain + * ABI compatibility. + */ +struct _SMBCCTX { + struct + { + /** + * debug level + * + * Use smbc_getDebug() and smbc_setDebug() + */ + int debug; + + /** + * netbios name used for making connections + * + * Use smbc_getNetbiosName() and smbc_setNetbiosName() + */ + char * netbios_name; + + /** + * workgroup name used for making connections + * + * Use smbc_getWorkgroup() and smbc_setWorkgroup() + */ + char * workgroup; + + /** + * username used for making connections + * + * Use smbc_getUser() and smbc_setUser() + */ + char * user; + + /** + * timeout used for waiting on connections / response data (in + * milliseconds) + * + * Use smbc_getTimeout() and smbc_setTimeout() + */ + int timeout; + } config; + + /** + * callable functions for files: + * For usage and return values see the SMBC_* functions + * + * Use smbc_getFunction*() and smbc_setFunction*(), e.g. + * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. + */ + struct + { + smbc_open_fn open_fn; + smbc_creat_fn creat_fn; + smbc_read_fn read_fn; + smbc_write_fn write_fn; + smbc_unlink_fn unlink_fn; + smbc_rename_fn rename_fn; + smbc_lseek_fn lseek_fn; + smbc_stat_fn stat_fn; + smbc_fstat_fn fstat_fn; +#if 0 /* internal */ + smbc_ftruncate_fn ftruncate_fn; +#endif + smbc_close_fn close_fn; + smbc_opendir_fn opendir_fn; + smbc_closedir_fn closedir_fn; + smbc_readdir_fn readdir_fn; + smbc_getdents_fn getdents_fn; + smbc_mkdir_fn mkdir_fn; + smbc_rmdir_fn rmdir_fn; + smbc_telldir_fn telldir_fn; + smbc_lseekdir_fn lseekdir_fn; + smbc_fstatdir_fn fstatdir_fn; + smbc_chmod_fn chmod_fn; + smbc_utimes_fn utimes_fn; + smbc_setxattr_fn setxattr_fn; + smbc_getxattr_fn getxattr_fn; + smbc_removexattr_fn removexattr_fn; + smbc_listxattr_fn listxattr_fn; + } posix_emu; + + /* Printing-related functions */ + struct + { + smbc_print_file_fn print_file_fn; + smbc_open_print_job_fn open_print_job_fn; + smbc_list_print_jobs_fn list_print_jobs_fn; + smbc_unlink_print_job_fn unlink_print_job_fn; + } printing; + + /* + ** Callbacks + * These callbacks _always_ have to be initialized because they will + * not be checked at dereference for increased speed. + */ + struct + { + /** + * authentication function callback: called upon auth requests + * + * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() + */ + smbc_get_auth_data_fn get_auth_data_fn; + + /** + * check if a server is still good + * + * Use smbc_getFunctionCheckServer(), + * smbc_setFunctionCheckServer() + */ + smbc_check_server_fn check_server_fn; + + /** + * remove a server if unused + * + * Use smbc_getFunctionRemoveUnusedServer(), + * smbc_setFunctionCheckServer() + */ + smbc_remove_unused_server_fn remove_unused_server_fn; + } server; + + struct + { + /** Cache subsystem + * + * For an example cache system see + * samba/source/libsmb/libsmb_cache.c + * + * Cache subsystem * functions follow. + */ + + /** + * server cache addition + * + * Use smbc_getFunctionAddCachedServer(), + * smbc_setFunctionAddCachedServer() + */ + smbc_add_cached_srv_fn add_cached_server_fn; + + /** + * server cache lookup + * + * Use smbc_getFunctionGetCachedServer(), + * smbc_setFunctionGetCachedServer() + */ + smbc_get_cached_srv_fn get_cached_server_fn; + + /** + * server cache removal + * + * Use smbc_getFunctionRemoveCachedServer(), + * smbc_setFunctionRemoveCachedServer() + */ + smbc_remove_cached_srv_fn remove_cached_server_fn; + + /** + * server cache purging, try to remove all cached servers + * (disconnect) + * + * Use smbc_getFunctionPurgeCachedServers(), + * smbc_setFunctionPurgeCachedServers() + */ + smbc_purge_cached_srv_fn purge_cached_servers_fn; + + /** + * Space to store private data of the server cache. + * + * Use smbc_getServerCacheData(), smbc_setServerCacheData() + */ + struct smbc_server_cache * server_cache_data; + } cache; + + /* + * Very old configuration options. + * + * Use smbc_option_set() and smbc_option_get() instead. + */ + struct + { + int bits; + } flags; + + /** user options selections that apply to this session + * + * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + * + * NEW OPTIONS ARE NOT ADDED HERE! + * + * We must maintain ABI backward compatibility. We now use + * smbc_option_set() and smbc_option_get() for all newly added + * options. + */ + struct _smbc_options { + + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ + int browse_max_lmb_count; + + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ + int urlencode_readdir_entries; + + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ + int one_share_per_server; + } options; + + /** INTERNAL DATA + * do _NOT_ touch this from your program ! + */ + struct SMBC_internal_data * internal; +}; + + #endif /* SMBCLIENT_H_INCLUDED */ -- cgit From 223940d9a887c5b98a5c873797302a6a9407ad7f Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:44:21 -0500 Subject: Additional revamped libsmbclient documentation - Ensured that all public functions have documentation in libsmbclient.h - Reformatted for "proper" indentation - Re-added temporarily-disabled alternate authentication function capability Derrell (This used to be commit 64b7150d92849a1e1e2416b9dcc12fae8d6bea99) --- source3/include/libsmbclient.h | 401 ++++++++++++++++++++++++++++++++--------- 1 file changed, 320 insertions(+), 81 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 4d78bb2568..28cad351de 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -155,6 +155,21 @@ typedef enum smbc_share_mode } smbc_share_mode; +/** + * Values for option SMB Encryption Level, as set and retrieved with + * smbc_setOptionSmbEncryptionLevel() and smbc_getOptionSmbEncryptionLevel() + */ +typedef enum smbc_smb_encrypt_level +{ + SMBC_ENCRYPTLEVEL_NONE = 0, + SMBC_ENCRYPTLEVEL_REQUEST = 1, + SMBC_ENCRYPTLEVEL_REQUIRE = 2 +} smbc_smb_encrypt_level; + + +typedef int smbc_bool; + + #ifndef ENOATTR # define ENOATTR ENOENT /* No such attribute */ #endif @@ -214,11 +229,17 @@ typedef struct _SMBCCTX SMBCCTX; /* + * Flags for SMBCCTX->flags + * * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. - * For these options, use smbc_option_set() and smbc_option_get(). + * Instead, use: + * smbc_setOptionUseKerberos() + * smbc_getOptionUseKerberos() + * smbc_setOptionFallbackAfterKerberos() + * smbc_getOptionFallbackAFterKerberos() + * smbc_setOptionNoAutoAnonymousLogin() + * smbc_getOptionNoAutoAnonymousLogin() */ - -/* Flags for SMBCCTX->flags */ # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) @@ -398,48 +419,286 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); + +/***************************************** + * Getters and setters for CONFIGURATION * + *****************************************/ + /** Get the debug level */ -int smbc_getDebug(SMBCCTX *c); +int +smbc_getDebug(SMBCCTX *c); /** Set the debug level */ -void smbc_setDebug(SMBCCTX *c, int debug); +void +smbc_setDebug(SMBCCTX *c, int debug); /** Get the netbios name used for making connections */ -char * smbc_getNetbiosName(SMBCCTX *c); +char * +smbc_getNetbiosName(SMBCCTX *c); /** Set the netbios name used for making connections */ -void smbc_setNetbiosName(SMBCCTX *c, char * netbios_name); +void +smbc_setNetbiosName(SMBCCTX *c, char * netbios_name); /** Get the workgroup used for making connections */ -char * smbc_getWorkgroup(SMBCCTX *c); +char * +smbc_getWorkgroup(SMBCCTX *c); /** Set the workgroup used for making connections */ void smbc_setWorkgroup(SMBCCTX *c, char * workgroup); /** Get the username used for making connections */ -char * smbc_getUser(SMBCCTX *c); +char * +smbc_getUser(SMBCCTX *c); /** Set the username used for making connections */ -void smbc_setUser(SMBCCTX *c, char * user); +void +smbc_setUser(SMBCCTX *c, char * user); /** * Get the timeout used for waiting on connections and response data * (in milliseconds) */ -int smbc_getTimeout(SMBCCTX *c); +int +smbc_getTimeout(SMBCCTX *c); /** * Set the timeout used for waiting on connections and response data * (in milliseconds) */ -void smbc_setTimeout(SMBCCTX *c, int timeout); +void +smbc_setTimeout(SMBCCTX *c, int timeout); + + + +/*********************************** + * Getters and setters for OPTIONS * + ***********************************/ + +/** Get whether to log to standard error instead of standard output */ +smbc_bool +smbc_getOptionDebugToStderr(SMBCCTX *c); + +/** Set whether to log to standard error instead of standard output */ +void +smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b); + +/** + * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +smbc_bool +smbc_getOptionFullTimeNames(SMBCCTX *c); + +/** + * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather + * than the old-style names such as M_TIME. This allows also setting/getting + * CREATE_TIME which was previously unimplemented. (Note that the old C_TIME + * was supposed to be CHANGE_TIME but was confused and sometimes referred to + * CREATE_TIME.) + */ +void +smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b); + +/** + * Get the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +smbc_share_mode +smbc_getOptionOpenShareMode(SMBCCTX *c); + +/** + * Set the share mode to use for files opened with SMBC_open_ctx(). The + * default is SMBC_SHAREMODE_DENY_NONE. + */ +void +smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode); + +/** Retrieve a previously saved user data handle */ +void * +smbc_getOptionUserData(SMBCCTX *c); + +/** Save a user data handle */ +void +smbc_setOptionUserData(SMBCCTX *c, void *user_data); + +/** Get the encoded value for encryption level. */ +smbc_smb_encrypt_level +smbc_getOptionSmbEncryptionLevel(SMBCCTX *c); + +/** Set the encoded value for encryption level. */ +void +smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level); + +/** + * Get from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +int +smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c); + +/** + * Set from how many local master browsers should the list of workgroups be + * retrieved. It can take up to 12 minutes or longer after a server becomes a + * local master browser, for it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client never knows + * which local master browser will be found first, the one which is found + * first and used to retrieve a browse list may have an incomplete or empty + * browse list. By requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small networks (few + * workgroups), it is recommended that this value be set to 0, causing the + * browse lists from all found local master browsers to be retrieved and + * merged. For networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ +void +smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count); + +/** + * Get whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +smbc_bool +smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c); + +/** + * Set whether to url-encode readdir entries. + * + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ +void +smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b); + +/** + * Get whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +smbc_bool +smbc_getOptionOneSharePerServer(SMBCCTX *c); + +/** + * Set whether to use the same connection for all shares on a server. + * + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ +void +smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b); + +/** Get whether to enable use of kerberos */ +smbc_bool +smbc_getOptionUseKerberos(SMBCCTX *c); + +/** Set whether to enable use of kerberos */ +void +smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b); + +/** Get whether to fallback after kerberos */ +smbc_bool +smbc_getOptionFallbackAfterKerberos(SMBCCTX *c); + +/** Set whether to fallback after kerberos */ +void +smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b); + +/** Get whether to automatically select anonymous login */ +smbc_bool +smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c); + +/** Set whether to automatically select anonymous login */ +void +smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b); /** Get the function for obtaining authentication data */ smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); + + + +/************************************* + * Getters and setters for FUNCTIONS * + *************************************/ + /** Set the function for obtaining authentication data */ void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); +/** Get the new-style authentication function which includes the context. */ +smbc_get_auth_data_with_context_fn +smbc_getFunctionAuthDataWithContext(SMBCCTX *c); + +/** Set the new-style authentication function which includes the context. */ +void +smbc_setFunctionAuthDataWithContext(SMBCCTX *c, + smbc_get_auth_data_with_context_fn fn); + /** Get the function for checking if a server is still good */ smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c); @@ -492,9 +751,12 @@ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache); -/** - * Callable functions for files. - */ + +/***************************************************************** + * Callable functions for files. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c, const char *fname, @@ -566,9 +828,12 @@ smbc_close_fn smbc_getFunctionClose(SMBCCTX *c); void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); -/** - * Callable functions for directories. - */ + +/***************************************************************** + * Callable functions for directories. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c, const char *fname); @@ -621,9 +886,12 @@ smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c); void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn f); -/** - * Callable functions applicable to both files and directories. - */ + +/***************************************************************** + * Callable functions applicable to both files and directories. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef int (*smbc_chmod_fn)(SMBCCTX *c, const char *fname, @@ -668,9 +936,12 @@ smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c); void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn f); -/** - * Callable functions related to printing - */ + +/***************************************************************** + * Callable functions for printing. * + * Each callable has a function signature typedef, a declaration * + * for the getter, and a declaration for the setter. * + *****************************************************************/ typedef int (*smbc_print_file_fn)(SMBCCTX *c_file, const char *fname, @@ -2341,6 +2612,7 @@ struct _SMBCCTX { /** * debug level * + * Manually setting/retrieving this value is deprecated. * Use smbc_getDebug() and smbc_setDebug() */ int debug; @@ -2348,6 +2620,7 @@ struct _SMBCCTX { /** * netbios name used for making connections * + * Manually setting/retrieving this value is deprecated. * Use smbc_getNetbiosName() and smbc_setNetbiosName() */ char * netbios_name; @@ -2355,6 +2628,7 @@ struct _SMBCCTX { /** * workgroup name used for making connections * + * Manually setting/retrieving this value is deprecated. * Use smbc_getWorkgroup() and smbc_setWorkgroup() */ char * workgroup; @@ -2362,6 +2636,7 @@ struct _SMBCCTX { /** * username used for making connections * + * Manually setting/retrieving this value is deprecated. * Use smbc_getUser() and smbc_setUser() */ char * user; @@ -2370,6 +2645,7 @@ struct _SMBCCTX { * timeout used for waiting on connections / response data (in * milliseconds) * + * Manually setting/retrieving this value is deprecated. * Use smbc_getTimeout() and smbc_setTimeout() */ int timeout; @@ -2379,6 +2655,8 @@ struct _SMBCCTX { * callable functions for files: * For usage and return values see the SMBC_* functions * + * Manually setting/retrieving these values is deprecated. + * * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ @@ -2433,6 +2711,7 @@ struct _SMBCCTX { /** * authentication function callback: called upon auth requests * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ smbc_get_auth_data_fn get_auth_data_fn; @@ -2440,6 +2719,7 @@ struct _SMBCCTX { /** * check if a server is still good * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ @@ -2448,6 +2728,7 @@ struct _SMBCCTX { /** * remove a server if unused * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ @@ -2467,6 +2748,7 @@ struct _SMBCCTX { /** * server cache addition * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ @@ -2475,6 +2757,7 @@ struct _SMBCCTX { /** * server cache lookup * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ @@ -2483,6 +2766,7 @@ struct _SMBCCTX { /** * server cache removal * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ @@ -2492,6 +2776,7 @@ struct _SMBCCTX { * server cache purging, try to remove all cached servers * (disconnect) * + * Manually setting/retrieving this value is deprecated. * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ @@ -2500,6 +2785,7 @@ struct _SMBCCTX { /** * Space to store private data of the server cache. * + * Manually setting/retrieving this value is deprecated. * Use smbc_getServerCacheData(), smbc_setServerCacheData() */ struct smbc_server_cache * server_cache_data; @@ -2508,7 +2794,14 @@ struct _SMBCCTX { /* * Very old configuration options. * - * Use smbc_option_set() and smbc_option_get() instead. + * Manually setting/retrieving this value is deprecated. + * Use one of the following functions instead: + * smbc_setOptionUseKerberos() + * smbc_getOptionUseKerberos() + * smbc_setOptionFallbackAfterKerberos() + * smbc_getOptionFallbackAfterKerberos() + * smbc_setOptionNoAutoAnonymousLogin() + * smbc_getOptionNoAutoAnonymousLogin() */ struct { @@ -2521,66 +2814,12 @@ struct _SMBCCTX { * * NEW OPTIONS ARE NOT ADDED HERE! * - * We must maintain ABI backward compatibility. We now use - * smbc_option_set() and smbc_option_get() for all newly added - * options. + * To set and retrieve options, use the smbc_setOption*() and + * smbc_getOption*() functions. */ struct _smbc_options { - - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ int urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ int one_share_per_server; } options; -- cgit From 0bd3df33eddf305f5d812ab1788232c925576c5e Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:55:21 -0500 Subject: Mark smbc_option_{get,set} as deprecated (This used to be commit a8b4b773d4647f28e7b92c5968469721d34eb550) --- source3/include/libsmbclient.h | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 28cad351de..058ac64210 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -142,7 +142,7 @@ struct smbc_dirent /* * Valid values for the option "open_share_mode", when calling - * smbc_option_set() + * smbc_setOptionOpenShareMode() */ typedef enum smbc_share_mode { @@ -1010,35 +1010,15 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); /**@ingroup misc - * Each time the context structure is changed, we have binary backward - * compatibility issues. Instead of modifying the public portions of the - * context structure to add new options, instead, we put them in the internal - * portion of the context structure and provide a set function for these new - * options. - * - * @param context A pointer to a SMBCCTX obtained from smbc_new_context() - * - * @param option_name - * The name of the option for which the value is to be set - * - * @param option_value - * The new value of the option being set * + * @DEPRECATED. Use smbc_setOption*() functions instead. */ void smbc_option_set(SMBCCTX *context, char *option_name, ... /* option_value */); /* - * Retrieve the current value of an option - * - * @param context A pointer to a SMBCCTX obtained from smbc_new_context() - * - * @param option_name - * The name of the option for which the value is to be - * retrieved - * - * @return The value of the specified option. + * @DEPRECATED. Use smbc_getOption*() functions instead. */ void * smbc_option_get(SMBCCTX *context, -- cgit From b3c16a241d27b4220fd25dcf4d30974a787f6ce7 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:56:54 -0500 Subject: Comment was in wrong place (This used to be commit dec70fa3c0424c148016cc667a3c159e16d8a944) --- source3/include/libsmbclient.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 058ac64210..95ee64d0fe 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -677,16 +677,15 @@ smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c); void smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b); -/** Get the function for obtaining authentication data */ -smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); - - /************************************* * Getters and setters for FUNCTIONS * *************************************/ +/** Get the function for obtaining authentication data */ +smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); + /** Set the function for obtaining authentication data */ void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); -- cgit From 4a3410b766a1121804ec2d901bf788354aa197e6 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 21:19:15 -0500 Subject: change variable name from f to fn for function pointers (This used to be commit 1fd65359f6cd07539cfe43146ac367a48708a678) --- source3/include/libsmbclient.h | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 95ee64d0fe..78f5931221 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -687,7 +687,7 @@ smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b); smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c); /** Set the function for obtaining authentication data */ -void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn f); +void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn); /** Get the new-style authentication function which includes the context. */ smbc_get_auth_data_with_context_fn @@ -696,39 +696,39 @@ smbc_getFunctionAuthDataWithContext(SMBCCTX *c); /** Set the new-style authentication function which includes the context. */ void smbc_setFunctionAuthDataWithContext(SMBCCTX *c, - smbc_get_auth_data_with_context_fn fn); + smbc_get_auth_data_with_context_fn fn); /** Get the function for checking if a server is still good */ smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c); /** Set the function for checking if a server is still good */ -void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn f); +void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn); /** Get the function for removing a server if unused */ smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c); /** Set the function for removing a server if unused */ void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c, - smbc_remove_unused_server_fn f); + smbc_remove_unused_server_fn fn); /** Get the function for adding a cached server */ smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c); /** Set the function for adding a cached server */ -void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn f); +void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn); /** Get the function for server cache lookup */ smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c); /** Set the function for server cache lookup */ -void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn f); +void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn); /** Get the function for server cache removal */ smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c); /** Set the function for server cache removal */ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, - smbc_remove_cached_srv_fn f); + smbc_remove_cached_srv_fn fn); /** * Get the function for server cache purging. This function tries to @@ -741,7 +741,7 @@ smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); * remove all cached servers (e.g. on disconnect) */ void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, - smbc_purge_cached_srv_fn f); + smbc_purge_cached_srv_fn fn); /** Get the function to store private data of the server cache */ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); @@ -762,7 +762,7 @@ typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c, int flags, mode_t mode); smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c); -void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn f); +void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn); typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c, const char *path, @@ -775,56 +775,56 @@ typedef ssize_t (*smbc_read_fn)(SMBCCTX *c, void *buf, size_t count); smbc_read_fn smbc_getFunctionRead(SMBCCTX *c); -void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn f); +void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn); typedef ssize_t (*smbc_write_fn)(SMBCCTX *c, SMBCFILE *file, void *buf, size_t count); smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c); -void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn f); +void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn); typedef int (*smbc_unlink_fn)(SMBCCTX *c, const char *fname); smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c); -void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn f); +void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn); typedef int (*smbc_rename_fn)(SMBCCTX *ocontext, const char *oname, SMBCCTX *ncontext, const char *nname); smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c); -void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn f); +void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn); typedef off_t (*smbc_lseek_fn)(SMBCCTX *c, SMBCFILE * file, off_t offset, int whence); smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c); -void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn f); +void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn); typedef int (*smbc_stat_fn)(SMBCCTX *c, const char *fname, struct stat *st); smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c); -void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn f); +void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn); typedef int (*smbc_fstat_fn)(SMBCCTX *c, SMBCFILE *file, struct stat *st); smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c); -void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn f); +void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn); typedef int (*smbc_ftruncate_fn)(SMBCCTX *c, SMBCFILE *f, off_t size); smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c); -void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn f); +void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn); typedef int (*smbc_close_fn)(SMBCCTX *c, SMBCFILE *file); smbc_close_fn smbc_getFunctionClose(SMBCCTX *c); -void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); +void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn); @@ -837,52 +837,52 @@ void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn f); typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c, const char *fname); smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c); -void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn f); +void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn); typedef int (*smbc_closedir_fn)(SMBCCTX *c, SMBCFILE *dir); smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c); -void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn f); +void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn); typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c, SMBCFILE *dir); smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c); -void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn f); +void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn); typedef int (*smbc_getdents_fn)(SMBCCTX *c, SMBCFILE *dir, struct smbc_dirent *dirp, int count); smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c); -void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn f); +void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn); typedef int (*smbc_mkdir_fn)(SMBCCTX *c, const char *fname, mode_t mode); smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c); -void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn f); +void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn); typedef int (*smbc_rmdir_fn)(SMBCCTX *c, const char *fname); smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c); -void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn f); +void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn); typedef off_t (*smbc_telldir_fn)(SMBCCTX *c, SMBCFILE *dir); smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c); -void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn f); +void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn); typedef int (*smbc_lseekdir_fn)(SMBCCTX *c, SMBCFILE *dir, off_t offset); smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c); -void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn f); +void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn); typedef int (*smbc_fstatdir_fn)(SMBCCTX *c, SMBCFILE *dir, struct stat *st); smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c); -void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn f); +void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn); @@ -896,13 +896,13 @@ typedef int (*smbc_chmod_fn)(SMBCCTX *c, const char *fname, mode_t mode); smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c); -void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn f); +void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn); typedef int (*smbc_utimes_fn)(SMBCCTX *c, const char *fname, struct timeval *tbuf); smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c); -void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn f); +void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn); typedef int (*smbc_setxattr_fn)(SMBCCTX *context, const char *fname, @@ -911,7 +911,7 @@ typedef int (*smbc_setxattr_fn)(SMBCCTX *context, size_t size, int flags); smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c); -void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn f); +void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn); typedef int (*smbc_getxattr_fn)(SMBCCTX *context, const char *fname, @@ -919,20 +919,20 @@ typedef int (*smbc_getxattr_fn)(SMBCCTX *context, const void *value, size_t size); smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c); -void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn f); +void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn); typedef int (*smbc_removexattr_fn)(SMBCCTX *context, const char *fname, const char *name); smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c); -void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn f); +void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn); typedef int (*smbc_listxattr_fn)(SMBCCTX *context, const char *fname, char *list, size_t size); smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c); -void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn f); +void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn); @@ -947,27 +947,27 @@ typedef int (*smbc_print_file_fn)(SMBCCTX *c_file, SMBCCTX *c_print, const char *printq); smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c); -void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn f); +void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn); typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c, const char *fname); smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c); void smbc_setFunctionOpenPrintJob(SMBCCTX *c, - smbc_open_print_job_fn f); + smbc_open_print_job_fn fn); typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c, const char *fname, smbc_list_print_job_fn fn); smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c); void smbc_setFunctionListPrintJobs(SMBCCTX *c, - smbc_list_print_jobs_fn f); + smbc_list_print_jobs_fn fn); typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c, const char *fname, int id); smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c); void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c, - smbc_unlink_print_job_fn f); + smbc_unlink_print_job_fn fn); /**@ingroup misc -- cgit From bf950ea7586c558205a7315419d015263f53e4e4 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 2 Mar 2008 16:13:25 -0500 Subject: fixed missing white space (This used to be commit 71e86f13b0ace3841c6712084728c79db74ff803) --- source3/include/libsmbclient.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 78f5931221..bfed71de1c 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1016,6 +1016,7 @@ void smbc_option_set(SMBCCTX *context, char *option_name, ... /* option_value */); + /* * @DEPRECATED. Use smbc_getOption*() functions instead. */ -- cgit From 1363ee9d65965704f716965c6cbcfc0693ca2401 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 3 Mar 2008 18:13:33 -0500 Subject: Continued revamping of libsmbclient. - James suggested using gcc's "deprecated" attribute to mark the context structure fields to generate warnings. This creates a scenario with the best of all worlds. I'm able to move to an organization that more easily allows future enhancements, while avoiding any mandatory changes by applications. Thanks, James! - Updated WHATSNEW.txt so that it accurately reflects the current state of affairs. Derrell (This used to be commit a67f96fbe9683b46c2149f7cb439d13f7f0e6ecd) --- source3/include/libsmbclient.h | 247 ++++++++++++++++++++--------------------- 1 file changed, 121 insertions(+), 126 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index bfed71de1c..a60c05fa7f 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -25,6 +25,13 @@ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED +#undef _DEPRECATED_ +#if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__) +# define _DEPRECATED_ __attribute__ ((deprecated)) +#else +# define _DEPRECATED_ +#endif + #ifdef __cplusplus extern "C" { #endif @@ -416,7 +423,7 @@ typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv); * @return 0 when found and removed. 1 on failure. * */ -typedef int (*smbc_purge_cached_srv_fn) (SMBCCTX * c); +typedef int (*smbc_purge_cached_fn) (SMBCCTX * c); @@ -734,14 +741,14 @@ void smbc_setFunctionRemoveCachedServer(SMBCCTX *c, * Get the function for server cache purging. This function tries to * remove all cached servers (e.g. on disconnect) */ -smbc_purge_cached_srv_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); +smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c); /** * Set the function for server cache purging. This function tries to * remove all cached servers (e.g. on disconnect) */ void smbc_setFunctionPurgeCachedServers(SMBCCTX *c, - smbc_purge_cached_srv_fn fn); + smbc_purge_cached_fn fn); /** Get the function to store private data of the server cache */ struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c); @@ -1010,7 +1017,7 @@ int smbc_free_context(SMBCCTX * context, int shutdown_ctx); /**@ingroup misc * - * @DEPRECATED. Use smbc_setOption*() functions instead. + * @deprecated. Use smbc_setOption*() functions instead. */ void smbc_option_set(SMBCCTX *context, @@ -1018,7 +1025,7 @@ smbc_option_set(SMBCCTX *context, ... /* option_value */); /* - * @DEPRECATED. Use smbc_getOption*() functions instead. + * @deprecated. Use smbc_getOption*() functions instead. */ void * smbc_option_get(SMBCCTX *context, @@ -2570,7 +2577,6 @@ smbc_version(void); } #endif - /** * @ingroup structure * Structure that contains a client context information @@ -2586,137 +2592,129 @@ smbc_version(void); * directly visible to applications. This makes it much easier to maintain * ABI compatibility. */ -struct _SMBCCTX { - struct - { - /** - * debug level - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getDebug() and smbc_setDebug() - */ - int debug; +struct _SMBCCTX +{ + /** + * debug level + * + * DEPRECATED: + * Use smbc_getDebug() and smbc_setDebug() + */ + int debug _DEPRECATED_; - /** - * netbios name used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getNetbiosName() and smbc_setNetbiosName() - */ - char * netbios_name; + /** + * netbios name used for making connections + * + * DEPRECATED: + * Use smbc_getNetbiosName() and smbc_setNetbiosName() + */ + char * netbios_name _DEPRECATED_; - /** - * workgroup name used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getWorkgroup() and smbc_setWorkgroup() - */ - char * workgroup; + /** + * workgroup name used for making connections + * + * DEPRECATED: + * Use smbc_getWorkgroup() and smbc_setWorkgroup() + */ + char * workgroup _DEPRECATED_; - /** - * username used for making connections - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getUser() and smbc_setUser() - */ - char * user; - - /** - * timeout used for waiting on connections / response data (in - * milliseconds) - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getTimeout() and smbc_setTimeout() - */ - int timeout; - } config; + /** + * username used for making connections + * + * DEPRECATED: + * Use smbc_getUser() and smbc_setUser() + */ + char * user _DEPRECATED_; + + /** + * timeout used for waiting on connections / response data (in + * milliseconds) + * + * DEPRECATED: + * Use smbc_getTimeout() and smbc_setTimeout() + */ + int timeout _DEPRECATED_; /** * callable functions for files: * For usage and return values see the SMBC_* functions * - * Manually setting/retrieving these values is deprecated. + * DEPRECATED: * * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ - struct - { - smbc_open_fn open_fn; - smbc_creat_fn creat_fn; - smbc_read_fn read_fn; - smbc_write_fn write_fn; - smbc_unlink_fn unlink_fn; - smbc_rename_fn rename_fn; - smbc_lseek_fn lseek_fn; - smbc_stat_fn stat_fn; - smbc_fstat_fn fstat_fn; + smbc_open_fn open _DEPRECATED_; + smbc_creat_fn creat _DEPRECATED_; + smbc_read_fn read _DEPRECATED_; + smbc_write_fn write _DEPRECATED_; + smbc_unlink_fn unlink _DEPRECATED_; + smbc_rename_fn rename _DEPRECATED_; + smbc_lseek_fn lseek _DEPRECATED_; + smbc_stat_fn stat _DEPRECATED_; + smbc_fstat_fn fstat _DEPRECATED_; #if 0 /* internal */ - smbc_ftruncate_fn ftruncate_fn; + smbc_ftruncate_fn ftruncate_fn; #endif - smbc_close_fn close_fn; - smbc_opendir_fn opendir_fn; - smbc_closedir_fn closedir_fn; - smbc_readdir_fn readdir_fn; - smbc_getdents_fn getdents_fn; - smbc_mkdir_fn mkdir_fn; - smbc_rmdir_fn rmdir_fn; - smbc_telldir_fn telldir_fn; - smbc_lseekdir_fn lseekdir_fn; - smbc_fstatdir_fn fstatdir_fn; - smbc_chmod_fn chmod_fn; - smbc_utimes_fn utimes_fn; - smbc_setxattr_fn setxattr_fn; - smbc_getxattr_fn getxattr_fn; - smbc_removexattr_fn removexattr_fn; - smbc_listxattr_fn listxattr_fn; - } posix_emu; + smbc_close_fn close_fn _DEPRECATED_; + smbc_opendir_fn opendir _DEPRECATED_; + smbc_closedir_fn closedir _DEPRECATED_; + smbc_readdir_fn readdir _DEPRECATED_; + smbc_getdents_fn getdents _DEPRECATED_; + smbc_mkdir_fn mkdir _DEPRECATED_; + smbc_rmdir_fn rmdir _DEPRECATED_; + smbc_telldir_fn telldir _DEPRECATED_; + smbc_lseekdir_fn lseekdir _DEPRECATED_; + smbc_fstatdir_fn fstatdir _DEPRECATED_; + smbc_chmod_fn chmod _DEPRECATED_; + smbc_utimes_fn utimes _DEPRECATED_; + smbc_setxattr_fn setxattr _DEPRECATED_; + smbc_getxattr_fn getxattr _DEPRECATED_; + smbc_removexattr_fn removexattr _DEPRECATED_; + smbc_listxattr_fn listxattr _DEPRECATED_; /* Printing-related functions */ - struct - { - smbc_print_file_fn print_file_fn; - smbc_open_print_job_fn open_print_job_fn; - smbc_list_print_jobs_fn list_print_jobs_fn; - smbc_unlink_print_job_fn unlink_print_job_fn; - } printing; + smbc_print_file_fn print_file _DEPRECATED_; + smbc_open_print_job_fn open_print_job _DEPRECATED_; + smbc_list_print_jobs_fn list_print_jobs _DEPRECATED_; + smbc_unlink_print_job_fn unlink_print_job _DEPRECATED_; /* ** Callbacks - * These callbacks _always_ have to be initialized because they will - * not be checked at dereference for increased speed. + * + * DEPRECATED: + * + * See the comment above each field, for the getter and setter + * functions that should now be used. */ - struct + struct _smbc_callbacks { /** * authentication function callback: called upon auth requests * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ - smbc_get_auth_data_fn get_auth_data_fn; + smbc_get_auth_data_fn auth_fn _DEPRECATED_; /** * check if a server is still good * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ - smbc_check_server_fn check_server_fn; + smbc_check_server_fn check_server_fn _DEPRECATED_; /** * remove a server if unused * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ - smbc_remove_unused_server_fn remove_unused_server_fn; - } server; + smbc_remove_unused_server_fn remove_unused_server_fn _DEPRECATED_; - struct - { /** Cache subsystem * * For an example cache system see @@ -2728,53 +2726,53 @@ struct _SMBCCTX { /** * server cache addition * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ - smbc_add_cached_srv_fn add_cached_server_fn; + smbc_add_cached_srv_fn add_cached_srv_fn _DEPRECATED_; /** * server cache lookup * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ - smbc_get_cached_srv_fn get_cached_server_fn; + smbc_get_cached_srv_fn get_cached_srv_fn _DEPRECATED_; /** * server cache removal * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ - smbc_remove_cached_srv_fn remove_cached_server_fn; + smbc_remove_cached_srv_fn remove_cached_srv_fn _DEPRECATED_; /** * server cache purging, try to remove all cached servers * (disconnect) * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ - smbc_purge_cached_srv_fn purge_cached_servers_fn; + smbc_purge_cached_fn purge_cached_fn _DEPRECATED_; + } callbacks; - /** - * Space to store private data of the server cache. - * - * Manually setting/retrieving this value is deprecated. - * Use smbc_getServerCacheData(), smbc_setServerCacheData() - */ - struct smbc_server_cache * server_cache_data; - } cache; + /** + * Space where the private data of the server cache used to be + * + * DEPRECATED: + * Use smbc_getServerCacheData(), smbc_setServerCacheData() + */ + void * reserved; /* space where server_cache_data used to be */ /* * Very old configuration options. * - * Manually setting/retrieving this value is deprecated. + * DEPRECATED: * Use one of the following functions instead: * smbc_setOptionUseKerberos() * smbc_getOptionUseKerberos() @@ -2783,24 +2781,21 @@ struct _SMBCCTX { * smbc_setOptionNoAutoAnonymousLogin() * smbc_getOptionNoAutoAnonymousLogin() */ - struct - { - int bits; - } flags; + int flags _DEPRECATED_; - /** user options selections that apply to this session - * - * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE. + /** + * user options selections that apply to this session * - * NEW OPTIONS ARE NOT ADDED HERE! + * NEW OPTIONS ARE NOT ADDED HERE! * - * To set and retrieve options, use the smbc_setOption*() and - * smbc_getOption*() functions. + * DEPRECATED: + * To set and retrieve options, use the smbc_setOption*() and + * smbc_getOption*() functions. */ struct _smbc_options { - int browse_max_lmb_count; - int urlencode_readdir_entries; - int one_share_per_server; + int browse_max_lmb_count _DEPRECATED_; + int urlencode_readdir_entries _DEPRECATED_; + int one_share_per_server _DEPRECATED_; } options; /** INTERNAL DATA -- cgit From ee45d0d6630624b735a7ea07639ffa0d774a337c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 3 Mar 2008 18:25:49 -0500 Subject: Missed a few 'deprecated' markers (This used to be commit 76ba37ac46b4a77fe228ca90635fa19140541ccd) --- source3/include/libsmbclient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index a60c05fa7f..e1a4b74567 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -2767,7 +2767,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getServerCacheData(), smbc_setServerCacheData() */ - void * reserved; /* space where server_cache_data used to be */ + void * reserved _DEPRECATED_; /* * Very old configuration options. @@ -2796,7 +2796,7 @@ struct _SMBCCTX int browse_max_lmb_count _DEPRECATED_; int urlencode_readdir_entries _DEPRECATED_; int one_share_per_server _DEPRECATED_; - } options; + } options _DEPRECATED_; /** INTERNAL DATA * do _NOT_ touch this from your program ! -- cgit From 8a228000289b331bbe78d0a9c9b44a2ad4a298f8 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 3 Mar 2008 22:56:32 -0500 Subject: use constant name less likely to cause conflict (This used to be commit fd18b01016d1dc4b08983975353e62084fdc323c) --- source3/include/libsmbclient.h | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index e1a4b74567..2e38944d65 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -25,11 +25,11 @@ #ifndef SMBCLIENT_H_INCLUDED #define SMBCLIENT_H_INCLUDED -#undef _DEPRECATED_ +#undef DEPRECATED_SMBC_INTERFACE #if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__) -# define _DEPRECATED_ __attribute__ ((deprecated)) +# define DEPRECATED_SMBC_INTERFACE __attribute__ ((deprecated)) #else -# define _DEPRECATED_ +# define DEPRECATED_SMBC_INTERFACE #endif #ifdef __cplusplus @@ -2600,7 +2600,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getDebug() and smbc_setDebug() */ - int debug _DEPRECATED_; + int debug DEPRECATED_SMBC_INTERFACE; /** * netbios name used for making connections @@ -2608,7 +2608,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getNetbiosName() and smbc_setNetbiosName() */ - char * netbios_name _DEPRECATED_; + char * netbios_name DEPRECATED_SMBC_INTERFACE; /** * workgroup name used for making connections @@ -2616,7 +2616,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getWorkgroup() and smbc_setWorkgroup() */ - char * workgroup _DEPRECATED_; + char * workgroup DEPRECATED_SMBC_INTERFACE; /** * username used for making connections @@ -2624,7 +2624,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getUser() and smbc_setUser() */ - char * user _DEPRECATED_; + char * user DEPRECATED_SMBC_INTERFACE; /** * timeout used for waiting on connections / response data (in @@ -2633,7 +2633,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getTimeout() and smbc_setTimeout() */ - int timeout _DEPRECATED_; + int timeout DEPRECATED_SMBC_INTERFACE; /** * callable functions for files: @@ -2644,40 +2644,40 @@ struct _SMBCCTX * Use smbc_getFunction*() and smbc_setFunction*(), e.g. * smbc_getFunctionOpen(), smbc_setFunctionUnlink(), etc. */ - smbc_open_fn open _DEPRECATED_; - smbc_creat_fn creat _DEPRECATED_; - smbc_read_fn read _DEPRECATED_; - smbc_write_fn write _DEPRECATED_; - smbc_unlink_fn unlink _DEPRECATED_; - smbc_rename_fn rename _DEPRECATED_; - smbc_lseek_fn lseek _DEPRECATED_; - smbc_stat_fn stat _DEPRECATED_; - smbc_fstat_fn fstat _DEPRECATED_; + smbc_open_fn open DEPRECATED_SMBC_INTERFACE; + smbc_creat_fn creat DEPRECATED_SMBC_INTERFACE; + smbc_read_fn read DEPRECATED_SMBC_INTERFACE; + smbc_write_fn write DEPRECATED_SMBC_INTERFACE; + smbc_unlink_fn unlink DEPRECATED_SMBC_INTERFACE; + smbc_rename_fn rename DEPRECATED_SMBC_INTERFACE; + smbc_lseek_fn lseek DEPRECATED_SMBC_INTERFACE; + smbc_stat_fn stat DEPRECATED_SMBC_INTERFACE; + smbc_fstat_fn fstat DEPRECATED_SMBC_INTERFACE; #if 0 /* internal */ smbc_ftruncate_fn ftruncate_fn; #endif - smbc_close_fn close_fn _DEPRECATED_; - smbc_opendir_fn opendir _DEPRECATED_; - smbc_closedir_fn closedir _DEPRECATED_; - smbc_readdir_fn readdir _DEPRECATED_; - smbc_getdents_fn getdents _DEPRECATED_; - smbc_mkdir_fn mkdir _DEPRECATED_; - smbc_rmdir_fn rmdir _DEPRECATED_; - smbc_telldir_fn telldir _DEPRECATED_; - smbc_lseekdir_fn lseekdir _DEPRECATED_; - smbc_fstatdir_fn fstatdir _DEPRECATED_; - smbc_chmod_fn chmod _DEPRECATED_; - smbc_utimes_fn utimes _DEPRECATED_; - smbc_setxattr_fn setxattr _DEPRECATED_; - smbc_getxattr_fn getxattr _DEPRECATED_; - smbc_removexattr_fn removexattr _DEPRECATED_; - smbc_listxattr_fn listxattr _DEPRECATED_; + smbc_close_fn close_fn DEPRECATED_SMBC_INTERFACE; + smbc_opendir_fn opendir DEPRECATED_SMBC_INTERFACE; + smbc_closedir_fn closedir DEPRECATED_SMBC_INTERFACE; + smbc_readdir_fn readdir DEPRECATED_SMBC_INTERFACE; + smbc_getdents_fn getdents DEPRECATED_SMBC_INTERFACE; + smbc_mkdir_fn mkdir DEPRECATED_SMBC_INTERFACE; + smbc_rmdir_fn rmdir DEPRECATED_SMBC_INTERFACE; + smbc_telldir_fn telldir DEPRECATED_SMBC_INTERFACE; + smbc_lseekdir_fn lseekdir DEPRECATED_SMBC_INTERFACE; + smbc_fstatdir_fn fstatdir DEPRECATED_SMBC_INTERFACE; + smbc_chmod_fn chmod DEPRECATED_SMBC_INTERFACE; + smbc_utimes_fn utimes DEPRECATED_SMBC_INTERFACE; + smbc_setxattr_fn setxattr DEPRECATED_SMBC_INTERFACE; + smbc_getxattr_fn getxattr DEPRECATED_SMBC_INTERFACE; + smbc_removexattr_fn removexattr DEPRECATED_SMBC_INTERFACE; + smbc_listxattr_fn listxattr DEPRECATED_SMBC_INTERFACE; /* Printing-related functions */ - smbc_print_file_fn print_file _DEPRECATED_; - smbc_open_print_job_fn open_print_job _DEPRECATED_; - smbc_list_print_jobs_fn list_print_jobs _DEPRECATED_; - smbc_unlink_print_job_fn unlink_print_job _DEPRECATED_; + smbc_print_file_fn print_file DEPRECATED_SMBC_INTERFACE; + smbc_open_print_job_fn open_print_job DEPRECATED_SMBC_INTERFACE; + smbc_list_print_jobs_fn list_print_jobs DEPRECATED_SMBC_INTERFACE; + smbc_unlink_print_job_fn unlink_print_job DEPRECATED_SMBC_INTERFACE; /* ** Callbacks @@ -2695,7 +2695,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getFunctionAuthData(), smbc_setFunctionAuthData() */ - smbc_get_auth_data_fn auth_fn _DEPRECATED_; + smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE; /** * check if a server is still good @@ -2704,7 +2704,7 @@ struct _SMBCCTX * Use smbc_getFunctionCheckServer(), * smbc_setFunctionCheckServer() */ - smbc_check_server_fn check_server_fn _DEPRECATED_; + smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE; /** * remove a server if unused @@ -2713,7 +2713,7 @@ struct _SMBCCTX * Use smbc_getFunctionRemoveUnusedServer(), * smbc_setFunctionCheckServer() */ - smbc_remove_unused_server_fn remove_unused_server_fn _DEPRECATED_; + smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE; /** Cache subsystem * @@ -2730,7 +2730,7 @@ struct _SMBCCTX * Use smbc_getFunctionAddCachedServer(), * smbc_setFunctionAddCachedServer() */ - smbc_add_cached_srv_fn add_cached_srv_fn _DEPRECATED_; + smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE; /** * server cache lookup @@ -2739,7 +2739,7 @@ struct _SMBCCTX * Use smbc_getFunctionGetCachedServer(), * smbc_setFunctionGetCachedServer() */ - smbc_get_cached_srv_fn get_cached_srv_fn _DEPRECATED_; + smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE; /** * server cache removal @@ -2748,7 +2748,7 @@ struct _SMBCCTX * Use smbc_getFunctionRemoveCachedServer(), * smbc_setFunctionRemoveCachedServer() */ - smbc_remove_cached_srv_fn remove_cached_srv_fn _DEPRECATED_; + smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE; /** * server cache purging, try to remove all cached servers @@ -2758,7 +2758,7 @@ struct _SMBCCTX * Use smbc_getFunctionPurgeCachedServers(), * smbc_setFunctionPurgeCachedServers() */ - smbc_purge_cached_fn purge_cached_fn _DEPRECATED_; + smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE; } callbacks; /** @@ -2767,7 +2767,7 @@ struct _SMBCCTX * DEPRECATED: * Use smbc_getServerCacheData(), smbc_setServerCacheData() */ - void * reserved _DEPRECATED_; + void * reserved DEPRECATED_SMBC_INTERFACE; /* * Very old configuration options. @@ -2781,7 +2781,7 @@ struct _SMBCCTX * smbc_setOptionNoAutoAnonymousLogin() * smbc_getOptionNoAutoAnonymousLogin() */ - int flags _DEPRECATED_; + int flags DEPRECATED_SMBC_INTERFACE; /** * user options selections that apply to this session @@ -2793,10 +2793,10 @@ struct _SMBCCTX * smbc_getOption*() functions. */ struct _smbc_options { - int browse_max_lmb_count _DEPRECATED_; - int urlencode_readdir_entries _DEPRECATED_; - int one_share_per_server _DEPRECATED_; - } options _DEPRECATED_; + int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE; + int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE; + int one_share_per_server DEPRECATED_SMBC_INTERFACE; + } options DEPRECATED_SMBC_INTERFACE; /** INTERNAL DATA * do _NOT_ touch this from your program ! -- cgit From 6398f945e80b25ed43c0128bd581397dfd96136f Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 18 Jun 2008 11:00:46 -0400 Subject: Remove prototype of unimplemented smbc_chown() function. (This used to be commit 0e84e3bb800cec2b63df4692afbf9c40850b108f) --- source3/include/libsmbclient.h | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 2e38944d65..96002643ef 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -1580,32 +1580,6 @@ int smbc_fstat(int fd, struct stat *st); int smbc_ftruncate(int fd, off_t size); -/**@ingroup attribue - * Change the ownership of a file or directory. - * - * @param url The smb url of the file or directory to change - * ownership of. - * - * @param owner I have no idea? - * - * @param group I have not idea? - * - * @return 0 on success, < 0 on error with errno set: - * - EPERM The effective UID does not match the owner - * of the file, and is not zero; or the owner or group - * were specified incorrectly. - * - ENOENT The file does not exist. - * - ENOMEM Insufficient was available. - * - ENOENT file or directory does not exist - * - * @todo Are we actually going to be able to implement this function - * - * @todo How do we abstract owner and group uid and gid? - * - */ -int smbc_chown(const char *url, uid_t owner, gid_t group); - - /**@ingroup attribute * Change the permissions of a file. * -- cgit From e5ac03b0ae22855f7131ba886ef829b7fe44e949 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 23 Jun 2008 16:29:40 +0200 Subject: Add documentation for kerberos support in libsmbclient. Signed-off-by: Andreas Schneider Signed-off-by: Derrell Lipman (This used to be commit fa803ce183376c938f92b0f31a7d89d522fd309f) --- source3/include/libsmbclient.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 96002643ef..74d0d5c9dd 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -259,6 +259,11 @@ typedef struct _SMBCCTX SMBCCTX; * Type for the the authentication function called by the library to * obtain authentication credentals * + * For kerberos support the function should just be called without + * prompting the user for credentials. Which means a simple 'return' + * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h + * and examples/libsmbclient/testbrowse.c. + * * @param srv Server being authenticated to * * @param shr Share being authenticated to @@ -293,6 +298,11 @@ typedef void (*smbc_get_auth_data_fn)(const char *srv, * Type for the the authentication function called by the library to * obtain authentication credentals * + * For kerberos support the function should just be called without + * prompting the user for credentials. Which means a simple 'return' + * should work. Take a look at examples/libsmbclient/get_auth_data_fn.h + * and examples/libsmbclient/testbrowse.c. + * * @param c Pointer to the smb context * * @param srv Server being authenticated to -- cgit From 31262a59bcf1cb04631c2efca169e417ef597bec Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 8 Jul 2008 20:44:39 -0400 Subject: [BUG 5580] Allow access to DFS shares via libsmbclient Brian Sheehan provided a nice patch intended for the 3.0 code base. This commit applies a similar patch for the 3.3 code base. It adds a new public function to libsmbclient -- smbc_set_credentials() -- that may be called from the authentication callback when DFS referrals are in use. Derrell (This used to be commit 888f922bd0d1c84a687d404e95ae314a9dd0aee1) --- source3/include/libsmbclient.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 74d0d5c9dd..2828e9e780 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -2561,6 +2561,33 @@ smbc_version(void); } #endif +/**@ingroup misc + * Set the users credentials globally so they can be used for DFS + * referrals. Probably best to use this function in the smbc_get_auth_data_fn + * callback. + * + * @param workgroup Workgroup of the user. + * + * @param user Username of user. + * + * @param password Password of user. + * + * @param use_kerberos Whether to use Kerberos + * + * @param signing_state One of these strings (all equivalents on same line): + * "off", "no", "false" + * "on", "yes", "true", "auto" + * "force", "required", "forced" + */ + +void +smbc_set_credentials(char *workgroup, + char *user, + char *password, + bool use_kerberos, + char *signing_state); + + /** * @ingroup structure * Structure that contains a client context information -- cgit From a49f6f17c622fbdc3f358a923b6a682ff7504fda Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 16 Jul 2008 09:45:02 -0400 Subject: Fix typos. libsmbclient doesn't have bool defined; rather it uses smbc_bool Derrell (This used to be commit e1ade80f468e8ed827f9d4fd035d79546fa0ee0a) --- source3/include/libsmbclient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 2828e9e780..5fe4fa8c60 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -2584,7 +2584,7 @@ void smbc_set_credentials(char *workgroup, char *user, char *password, - bool use_kerberos, + smbc_bool use_kerberos, char *signing_state); -- cgit From 43892abff68054928312fd54e50d5bdebe604b63 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 16 Jul 2008 12:05:52 +0200 Subject: The buf in the smbclient write function should be const. As we try to provide POSIX function, we should use const like all other POSIX function. Signed-off-by: Andreas Schneider Signed-off-by: Derrell Lipman (This used to be commit 36e5df59544de9df140ca40ad0efd77afd8e1468) --- source3/include/libsmbclient.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/include/libsmbclient.h') diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h index 5fe4fa8c60..a8b27b709e 100644 --- a/source3/include/libsmbclient.h +++ b/source3/include/libsmbclient.h @@ -796,7 +796,7 @@ void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn); typedef ssize_t (*smbc_write_fn)(SMBCCTX *c, SMBCFILE *file, - void *buf, + const void *buf, size_t count); smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c); void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn); @@ -1240,7 +1240,7 @@ ssize_t smbc_read(int fd, void *buf, size_t bufsize); * @see smbc_open(), smbc_read() * */ -ssize_t smbc_write(int fd, void *buf, size_t bufsize); +ssize_t smbc_write(int fd, const void *buf, size_t bufsize); /**@ingroup file -- cgit