libsmbclient
/home/adnan/Downloads/libsmbclient/libsmbclient-dev_2%3a3.5.11~dfsg-1ubuntu2.1_amd64/usr/include/libsmbclient.h
Go to the documentation of this file.
00001 /*=====================================================================
00002   Unix SMB/Netbios implementation.
00003   SMB client library API definitions
00004   Copyright (C) Andrew Tridgell 1998
00005   Copyright (C) Richard Sharpe 2000
00006   Copyright (C) John Terpsra 2000
00007   Copyright (C) Tom Jansen (Ninja ISD) 2002 
00008   Copyright (C) Derrell Lipman 2003-2008
00009 
00010    
00011   This program is free software; you can redistribute it and/or modify
00012   it under the terms of the GNU General Public License as published by
00013   the Free Software Foundation; either version 3 of the License, or
00014   (at your option) any later version.
00015    
00016   This program is distributed in the hope that it will be useful,
00017   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019   GNU General Public License for more details.
00020    
00021   You should have received a copy of the GNU General Public License
00022   along with this program; if not, see <http://www.gnu.org/licenses/>.
00023   =====================================================================*/
00024 
00025 #ifndef SMBCLIENT_H_INCLUDED
00026 #define SMBCLIENT_H_INCLUDED
00027 
00028 #undef DEPRECATED_SMBC_INTERFACE
00029 #if ! defined(__LIBSMBCLIENT_INTERNAL__) && defined(__GNUC__)
00030 # define DEPRECATED_SMBC_INTERFACE      __attribute__ ((deprecated))
00031 #else
00032 # define DEPRECATED_SMBC_INTERFACE
00033 #endif
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 /*-------------------------------------------------------------------*/
00040 /* The following are special comments to instruct DOXYGEN (automated 
00041  * documentation tool:
00042 */
00073 /*-------------------------------------------------------------------*/   
00074 
00075 /* Make sure we have the following includes for now ... */
00076 #include <sys/types.h>
00077 #include <sys/stat.h>
00078 #include <sys/statvfs.h>
00079 #include <fcntl.h>
00080 #include <utime.h>
00081 
00082   /* Debian bug #221618 */
00083 #define _LARGEFILE64_SOURCE
00084 #define _FILE_OFFSET_BITS 64
00085 
00086 #define SMBC_BASE_FD        10000 /* smallest file descriptor returned */
00087 
00088 #define SMBC_WORKGROUP      1
00089 #define SMBC_SERVER         2
00090 #define SMBC_FILE_SHARE     3
00091 #define SMBC_PRINTER_SHARE  4
00092 #define SMBC_COMMS_SHARE    5
00093 #define SMBC_IPC_SHARE      6
00094 #define SMBC_DIR            7
00095 #define SMBC_FILE           8
00096 #define SMBC_LINK           9
00097 
00102 struct smbc_dirent 
00103 {
00114         unsigned int smbc_type; 
00115 
00118         unsigned int dirlen;
00122         unsigned int commentlen;
00125         char *comment;
00129         unsigned int namelen;
00132         char name[1];
00133 };
00134 
00135 /*
00136  * Flags for smbc_setxattr()
00137  *   Specify a bitwise OR of these, or 0 to add or replace as necessary
00138  */
00139 #define SMBC_XATTR_FLAG_CREATE       0x1 /* fail if attr already exists */
00140 #define SMBC_XATTR_FLAG_REPLACE      0x2 /* fail if attr does not exist */
00141 
00142 
00143 /*
00144  * Mappings of the DOS mode bits, as returned by smbc_getxattr() when the
00145  * attribute name "system.dos_attr.mode" (or "system.dos_attr.*" or
00146  * "system.*") is specified.
00147  */
00148 #define SMBC_DOS_MODE_READONLY       0x01
00149 #define SMBC_DOS_MODE_HIDDEN         0x02
00150 #define SMBC_DOS_MODE_SYSTEM         0x04
00151 #define SMBC_DOS_MODE_VOLUME_ID      0x08
00152 #define SMBC_DOS_MODE_DIRECTORY      0x10
00153 #define SMBC_DOS_MODE_ARCHIVE        0x20
00154 
00155 /*
00156  * Valid values for the option "open_share_mode", when calling
00157  * smbc_setOptionOpenShareMode()
00158  */
00159 typedef enum smbc_share_mode
00160 {
00161     SMBC_SHAREMODE_DENY_DOS     = 0,
00162     SMBC_SHAREMODE_DENY_ALL     = 1,
00163     SMBC_SHAREMODE_DENY_WRITE   = 2,
00164     SMBC_SHAREMODE_DENY_READ    = 3,
00165     SMBC_SHAREMODE_DENY_NONE    = 4,
00166     SMBC_SHAREMODE_DENY_FCB     = 7
00167 } smbc_share_mode;
00168 
00169 
00174 typedef enum smbc_smb_encrypt_level
00175 {
00176     SMBC_ENCRYPTLEVEL_NONE      = 0,
00177     SMBC_ENCRYPTLEVEL_REQUEST   = 1,
00178     SMBC_ENCRYPTLEVEL_REQUIRE   = 2
00179 } smbc_smb_encrypt_level;
00180 
00181 
00187 typedef enum smbc_vfs_feature
00188 {
00189     /* Defined by POSIX or in Linux include files (low-order bits) */
00190     SMBC_VFS_FEATURE_RDONLY         = (1 << 0),
00191 
00192     /* Specific to libsmbclient (high-order bits) */
00193     SMBC_VFS_FEATURE_DFS              = (1 << 28),
00194     SMBC_VFS_FEATURE_CASE_INSENSITIVE = (1 << 29),
00195     SMBC_VFS_FEATURE_NO_UNIXCIFS      = (1 << 30)
00196 } smbc_vfs_feature;
00197 
00198 typedef int smbc_bool;
00199 
00200 
00201 #ifndef ENOATTR
00202 # define ENOATTR ENOENT        /* No such attribute */
00203 #endif
00204 
00205 
00206 
00207 
00212 #ifndef _CLIENT_H
00213 struct print_job_info 
00214 {
00217         unsigned short id;
00218     
00221         unsigned short priority;
00222     
00225         size_t size;
00226     
00229         char user[128];
00230   
00234         char name[128];
00235 
00238         time_t t;
00239 };
00240 #endif /* _CLIENT_H */
00241 
00242 
00246 typedef struct _SMBCSRV  SMBCSRV;
00247 
00251 typedef struct _SMBCFILE SMBCFILE;
00252 
00256 typedef struct _SMBCCTX SMBCCTX;
00257 
00258 
00259 /*
00260  * Flags for SMBCCTX->flags
00261  *
00262  * NEW CODE SHOULD NOT DIRECTLY MANIPULATE THE CONTEXT STRUCTURE.
00263  * Instead, use:
00264  *   smbc_setOptionUseKerberos()
00265  *   smbc_getOptionUseKerberos()
00266  *   smbc_setOptionFallbackAfterKerberos()
00267  *   smbc_getOptionFallbackAFterKerberos()
00268  *   smbc_setOptionNoAutoAnonymousLogin()
00269  *   smbc_getOptionNoAutoAnonymousLogin()
00270  *   smbc_setOptionUseCCache()
00271  *   smbc_getOptionUseCCache()
00272  */
00273 # define SMB_CTX_FLAG_USE_KERBEROS (1 << 0)
00274 # define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1)
00275 # define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2)
00276 # define SMB_CTX_FLAG_USE_CCACHE (1 << 3)
00277 
00278 
00279 
00314 typedef void (*smbc_get_auth_data_fn)(const char *srv, 
00315                                       const char *shr,
00316                                       char *wg, int wglen, 
00317                                       char *un, int unlen,
00318                                       char *pw, int pwlen);
00355 typedef void (*smbc_get_auth_data_with_context_fn)(SMBCCTX *c,
00356                                                    const char *srv, 
00357                                                    const char *shr,
00358                                                    char *wg, int wglen, 
00359                                                    char *un, int unlen,
00360                                                    char *pw, int pwlen);
00361 
00362 
00369 typedef void (*smbc_list_print_job_fn)(struct print_job_info *i);
00370                 
00371 
00382 typedef int (*smbc_check_server_fn)(SMBCCTX * c, SMBCSRV *srv);
00383 
00394 typedef int (*smbc_remove_unused_server_fn)(SMBCCTX * c, SMBCSRV *srv);
00395 
00396 
00415 typedef int (*smbc_add_cached_srv_fn)   (SMBCCTX * c, SMBCSRV *srv, 
00416                                     const char * server, const char * share,
00417                                     const char * workgroup, const char * username);
00418 
00435 typedef SMBCSRV * (*smbc_get_cached_srv_fn)   (SMBCCTX * c, const char * server,
00436                                                const char * share, const char * workgroup,
00437                                                const char * username);
00438 
00449 typedef int (*smbc_remove_cached_srv_fn)(SMBCCTX * c, SMBCSRV *srv);
00450 
00451 
00460 typedef int (*smbc_purge_cached_fn)     (SMBCCTX * c);
00461 
00462 
00463 
00464 /*****************************************
00465  * Getters and setters for CONFIGURATION *
00466  *****************************************/
00467 
00469 int
00470 smbc_getDebug(SMBCCTX *c);
00471 
00473 void
00474 smbc_setDebug(SMBCCTX *c, int debug);
00475 
00477 char *
00478 smbc_getNetbiosName(SMBCCTX *c);
00479 
00481 void
00482 smbc_setNetbiosName(SMBCCTX *c, char * netbios_name);
00483 
00485 char *
00486 smbc_getWorkgroup(SMBCCTX *c);
00487 
00489 void smbc_setWorkgroup(SMBCCTX *c, char * workgroup);
00490 
00492 char *
00493 smbc_getUser(SMBCCTX *c);
00494 
00496 void
00497 smbc_setUser(SMBCCTX *c, char * user);
00498 
00503 int
00504 smbc_getTimeout(SMBCCTX *c);
00505 
00510 void
00511 smbc_setTimeout(SMBCCTX *c, int timeout);
00512 
00513 
00514 
00515 /***********************************
00516  * Getters and setters for OPTIONS *
00517  ***********************************/
00518 
00520 smbc_bool
00521 smbc_getOptionDebugToStderr(SMBCCTX *c);
00522 
00524 void
00525 smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b);
00526 
00534 smbc_bool
00535 smbc_getOptionFullTimeNames(SMBCCTX *c);
00536 
00544 void
00545 smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b);
00546 
00551 smbc_share_mode
00552 smbc_getOptionOpenShareMode(SMBCCTX *c);
00553 
00558 void
00559 smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode);
00560 
00562 void *
00563 smbc_getOptionUserData(SMBCCTX *c);
00564 
00566 void
00567 smbc_setOptionUserData(SMBCCTX *c, void *user_data);
00568 
00570 smbc_smb_encrypt_level
00571 smbc_getOptionSmbEncryptionLevel(SMBCCTX *c);
00572 
00574 void
00575 smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level);
00576 
00584 smbc_bool
00585 smbc_getOptionCaseSensitive(SMBCCTX *c);
00586 
00594 void
00595 smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b);
00596 
00597 
00612 int
00613 smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c);
00614 
00629 void
00630 smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count);
00631 
00657 smbc_bool
00658 smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c);
00659 
00685 void
00686 smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b);
00687 
00700 smbc_bool
00701 smbc_getOptionOneSharePerServer(SMBCCTX *c);
00702 
00715 void
00716 smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b);
00717 
00719 smbc_bool
00720 smbc_getOptionUseKerberos(SMBCCTX *c);
00721 
00723 void
00724 smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b);
00725 
00727 smbc_bool
00728 smbc_getOptionFallbackAfterKerberos(SMBCCTX *c);
00729 
00731 void
00732 smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b);
00733 
00735 smbc_bool
00736 smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c);
00737 
00739 void
00740 smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b);
00741 
00743 smbc_bool
00744 smbc_getOptionUseCCache(SMBCCTX *c);
00745 
00747 void
00748 smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b);
00749 
00750 
00751 
00752 /*************************************
00753  * Getters and setters for FUNCTIONS *
00754  *************************************/
00755 
00757 smbc_get_auth_data_fn smbc_getFunctionAuthData(SMBCCTX *c);
00758 
00760 void smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn);
00761 
00763 smbc_get_auth_data_with_context_fn
00764 smbc_getFunctionAuthDataWithContext(SMBCCTX *c);
00765 
00767 void
00768 smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
00769                                     smbc_get_auth_data_with_context_fn fn);
00770 
00772 smbc_check_server_fn smbc_getFunctionCheckServer(SMBCCTX *c);
00773 
00775 void smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn);
00776 
00778 smbc_remove_unused_server_fn smbc_getFunctionRemoveUnusedServer(SMBCCTX *c);
00779 
00781 void smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
00782                                         smbc_remove_unused_server_fn fn);
00783 
00785 smbc_add_cached_srv_fn smbc_getFunctionAddCachedServer(SMBCCTX *c);
00786 
00788 void smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn);
00789 
00791 smbc_get_cached_srv_fn smbc_getFunctionGetCachedServer(SMBCCTX *c);
00792 
00794 void smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn);
00795 
00797 smbc_remove_cached_srv_fn smbc_getFunctionRemoveCachedServer(SMBCCTX *c);
00798 
00800 void smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
00801                                         smbc_remove_cached_srv_fn fn);
00802 
00807 smbc_purge_cached_fn smbc_getFunctionPurgeCachedServers(SMBCCTX *c);
00808 
00813 void smbc_setFunctionPurgeCachedServers(SMBCCTX *c,
00814                                         smbc_purge_cached_fn fn);
00815 
00817 struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c);
00818 
00820 void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache);
00821 
00822 
00823 
00824 /*****************************************************************
00825  * Callable functions for files.                                 *
00826  * Each callable has a function signature typedef, a declaration *
00827  * for the getter, and a declaration for the setter.             *
00828  *****************************************************************/
00829 
00830 typedef SMBCFILE * (*smbc_open_fn)(SMBCCTX *c,
00831                                    const char *fname,
00832                                    int flags,
00833                                    mode_t mode);
00834 smbc_open_fn smbc_getFunctionOpen(SMBCCTX *c);
00835 void smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn);
00836 
00837 typedef SMBCFILE * (*smbc_creat_fn)(SMBCCTX *c,
00838                                     const char *path,
00839                                     mode_t mode);
00840 smbc_creat_fn smbc_getFunctionCreat(SMBCCTX *c);
00841 void smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn);
00842 
00843 typedef ssize_t (*smbc_read_fn)(SMBCCTX *c,
00844                                 SMBCFILE *file,
00845                                 void *buf,
00846                                 size_t count);
00847 smbc_read_fn smbc_getFunctionRead(SMBCCTX *c);
00848 void smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn);
00849 
00850 typedef ssize_t (*smbc_write_fn)(SMBCCTX *c,
00851                                  SMBCFILE *file,
00852                                  const void *buf,
00853                                  size_t count);
00854 smbc_write_fn smbc_getFunctionWrite(SMBCCTX *c);
00855 void smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn);
00856 
00857 typedef int (*smbc_unlink_fn)(SMBCCTX *c,
00858                               const char *fname);
00859 smbc_unlink_fn smbc_getFunctionUnlink(SMBCCTX *c);
00860 void smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn);
00861 
00862 typedef int (*smbc_rename_fn)(SMBCCTX *ocontext,
00863                               const char *oname,
00864                               SMBCCTX *ncontext,
00865                               const char *nname);
00866 smbc_rename_fn smbc_getFunctionRename(SMBCCTX *c);
00867 void smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn);
00868 
00869 typedef off_t (*smbc_lseek_fn)(SMBCCTX *c,
00870                                SMBCFILE * file,
00871                                off_t offset,
00872                                int whence);
00873 smbc_lseek_fn smbc_getFunctionLseek(SMBCCTX *c);
00874 void smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn);
00875 
00876 typedef int (*smbc_stat_fn)(SMBCCTX *c,
00877                             const char *fname,
00878                             struct stat *st);
00879 smbc_stat_fn smbc_getFunctionStat(SMBCCTX *c);
00880 void smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn);
00881 
00882 typedef int (*smbc_fstat_fn)(SMBCCTX *c,
00883                              SMBCFILE *file,
00884                              struct stat *st);
00885 smbc_fstat_fn smbc_getFunctionFstat(SMBCCTX *c);
00886 void smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn);
00887 
00888 typedef int (*smbc_statvfs_fn)(SMBCCTX *c,
00889                                char *path,
00890                                struct statvfs *st);
00891 smbc_statvfs_fn smbc_getFunctionStatVFS(SMBCCTX *c);
00892 void smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn);
00893 
00894 typedef int (*smbc_fstatvfs_fn)(SMBCCTX *c,
00895                                 SMBCFILE *file,
00896                                 struct statvfs *st);
00897 smbc_fstatvfs_fn smbc_getFunctionFstatVFS(SMBCCTX *c);
00898 void smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn);
00899 
00900 typedef int (*smbc_ftruncate_fn)(SMBCCTX *c,
00901                                  SMBCFILE *f,
00902                                  off_t size);
00903 smbc_ftruncate_fn smbc_getFunctionFtruncate(SMBCCTX *c);
00904 void smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn);
00905 
00906 typedef int (*smbc_close_fn)(SMBCCTX *c,
00907                              SMBCFILE *file);
00908 smbc_close_fn smbc_getFunctionClose(SMBCCTX *c);
00909 void smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn);
00910 
00911 
00912 
00913 /*****************************************************************
00914  * Callable functions for directories.                           *
00915  * Each callable has a function signature typedef, a declaration *
00916  * for the getter, and a declaration for the setter.             *
00917  *****************************************************************/
00918 
00919 typedef SMBCFILE * (*smbc_opendir_fn)(SMBCCTX *c,
00920                                       const char *fname);
00921 smbc_opendir_fn smbc_getFunctionOpendir(SMBCCTX *c);
00922 void smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn);
00923 
00924 typedef int (*smbc_closedir_fn)(SMBCCTX *c,
00925                                 SMBCFILE *dir);
00926 smbc_closedir_fn smbc_getFunctionClosedir(SMBCCTX *c);
00927 void smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn);
00928 
00929 typedef struct smbc_dirent * (*smbc_readdir_fn)(SMBCCTX *c,
00930                                                 SMBCFILE *dir);
00931 smbc_readdir_fn smbc_getFunctionReaddir(SMBCCTX *c);
00932 void smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn);
00933 
00934 typedef int (*smbc_getdents_fn)(SMBCCTX *c,
00935                                 SMBCFILE *dir,
00936                                 struct smbc_dirent *dirp,
00937                                 int count);
00938 smbc_getdents_fn smbc_getFunctionGetdents(SMBCCTX *c);
00939 void smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn);
00940 
00941 typedef int (*smbc_mkdir_fn)(SMBCCTX *c,
00942                              const char *fname,
00943                              mode_t mode);
00944 smbc_mkdir_fn smbc_getFunctionMkdir(SMBCCTX *c);
00945 void smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn);
00946 
00947 typedef int (*smbc_rmdir_fn)(SMBCCTX *c,
00948                              const char *fname);
00949 smbc_rmdir_fn smbc_getFunctionRmdir(SMBCCTX *c);
00950 void smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn);
00951 
00952 typedef off_t (*smbc_telldir_fn)(SMBCCTX *c,
00953                                  SMBCFILE *dir);
00954 smbc_telldir_fn smbc_getFunctionTelldir(SMBCCTX *c);
00955 void smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn);
00956 
00957 typedef int (*smbc_lseekdir_fn)(SMBCCTX *c,
00958                                 SMBCFILE *dir,
00959                                 off_t offset);
00960 smbc_lseekdir_fn smbc_getFunctionLseekdir(SMBCCTX *c);
00961 void smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn);
00962 
00963 typedef int (*smbc_fstatdir_fn)(SMBCCTX *c,
00964                                 SMBCFILE *dir,
00965                                 struct stat *st);
00966 smbc_fstatdir_fn smbc_getFunctionFstatdir(SMBCCTX *c);
00967 void smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn);
00968 
00969 
00970 
00971 /*****************************************************************
00972  * Callable functions applicable to both files and directories.  *
00973  * Each callable has a function signature typedef, a declaration *
00974  * for the getter, and a declaration for the setter.             *
00975  *****************************************************************/
00976 
00977 typedef int (*smbc_chmod_fn)(SMBCCTX *c,
00978                              const char *fname,
00979                              mode_t mode);
00980 smbc_chmod_fn smbc_getFunctionChmod(SMBCCTX *c);
00981 void smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn);
00982 
00983 typedef int (*smbc_utimes_fn)(SMBCCTX *c,
00984                               const char *fname,
00985                               struct timeval *tbuf);
00986 smbc_utimes_fn smbc_getFunctionUtimes(SMBCCTX *c);
00987 void smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn);
00988 
00989 typedef int (*smbc_setxattr_fn)(SMBCCTX *context,
00990                                 const char *fname,
00991                                 const char *name,
00992                                 const void *value,
00993                                 size_t size,
00994                                 int flags);
00995 smbc_setxattr_fn smbc_getFunctionSetxattr(SMBCCTX *c);
00996 void smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn);
00997 
00998 typedef int (*smbc_getxattr_fn)(SMBCCTX *context,
00999                                 const char *fname,
01000                                 const char *name,
01001                                 const void *value,
01002                                 size_t size);
01003 smbc_getxattr_fn smbc_getFunctionGetxattr(SMBCCTX *c);
01004 void smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn);
01005 
01006 typedef int (*smbc_removexattr_fn)(SMBCCTX *context,
01007                                    const char *fname,
01008                                    const char *name);
01009 smbc_removexattr_fn smbc_getFunctionRemovexattr(SMBCCTX *c);
01010 void smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn);
01011 
01012 typedef int (*smbc_listxattr_fn)(SMBCCTX *context,
01013                                  const char *fname,
01014                                  char *list,
01015                                  size_t size);
01016 smbc_listxattr_fn smbc_getFunctionListxattr(SMBCCTX *c);
01017 void smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn);
01018 
01019 
01020 
01021 /*****************************************************************
01022  * Callable functions for printing.                              *
01023  * Each callable has a function signature typedef, a declaration *
01024  * for the getter, and a declaration for the setter.             *
01025  *****************************************************************/
01026 
01027 typedef int (*smbc_print_file_fn)(SMBCCTX *c_file,
01028                                   const char *fname,
01029                                   SMBCCTX *c_print,
01030                                   const char *printq);
01031 smbc_print_file_fn smbc_getFunctionPrintFile(SMBCCTX *c);
01032 void smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn);
01033 
01034 typedef SMBCFILE * (*smbc_open_print_job_fn)(SMBCCTX *c,
01035                                              const char *fname);
01036 smbc_open_print_job_fn smbc_getFunctionOpenPrintJob(SMBCCTX *c);
01037 void smbc_setFunctionOpenPrintJob(SMBCCTX *c,
01038                                   smbc_open_print_job_fn fn);
01039 
01040 typedef int (*smbc_list_print_jobs_fn)(SMBCCTX *c,
01041                                        const char *fname,
01042                                        smbc_list_print_job_fn fn);
01043 smbc_list_print_jobs_fn smbc_getFunctionListPrintJobs(SMBCCTX *c);
01044 void smbc_setFunctionListPrintJobs(SMBCCTX *c,
01045                                    smbc_list_print_jobs_fn fn);
01046 
01047 typedef int (*smbc_unlink_print_job_fn)(SMBCCTX *c,
01048                                         const char *fname,
01049                                         int id);
01050 smbc_unlink_print_job_fn smbc_getFunctionUnlinkPrintJob(SMBCCTX *c);
01051 void smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
01052                                     smbc_unlink_print_job_fn fn);
01053 
01054 
01067 SMBCCTX * smbc_new_context(void);
01068 
01090 int smbc_free_context(SMBCCTX * context, int shutdown_ctx);
01091 
01092 
01097 void
01098 smbc_option_set(SMBCCTX *context,
01099                 char *option_name,
01100                 ... /* option_value */);
01101 
01102 /*
01103  * @deprecated.  Use smbc_getOption*() functions instead.
01104  */
01105 void *
01106 smbc_option_get(SMBCCTX *context,
01107                 char *option_name);
01108 
01131 SMBCCTX * smbc_init_context(SMBCCTX * context);
01132 
01151 int smbc_init(smbc_get_auth_data_fn fn, int debug);
01152 
01175 SMBCCTX * smbc_set_context(SMBCCTX * new_context);
01176 
01229 int smbc_open(const char *furl, int flags, mode_t mode);
01230 
01263 int smbc_creat(const char *furl, mode_t mode);
01264 
01287 ssize_t smbc_read(int fd, void *buf, size_t bufsize);
01288 
01289 
01310 ssize_t smbc_write(int fd, const void *buf, size_t bufsize);
01311 
01312 
01341 off_t smbc_lseek(int fd, off_t offset, int whence);
01342 
01343 
01355 int smbc_close(int fd);
01356 
01357 
01379 int smbc_unlink(const char *furl);
01380 
01381 
01422 int smbc_rename(const char *ourl, const char *nurl);
01423 
01424 
01445 int smbc_opendir(const char *durl);
01446 
01447 
01458 int smbc_closedir(int dh);
01459 
01460 
01487 int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count);
01488 
01489 
01502 struct smbc_dirent* smbc_readdir(unsigned int dh);
01503 
01504 
01525 off_t smbc_telldir(int dh);
01526 
01527 
01550 int smbc_lseekdir(int fd, off_t offset);
01551 
01573 int smbc_mkdir(const char *durl, mode_t mode);
01574 
01575 
01594 int smbc_rmdir(const char *durl);
01595 
01596 
01616 int smbc_stat(const char *url, struct stat *st);
01617 
01618 
01638 int smbc_fstat(int fd, struct stat *st);
01639 
01640 
01660 int
01661 smbc_statvfs(char *url,
01662              struct statvfs *st);
01663 
01684 int
01685 smbc_fstatvfs(int fd,
01686               struct statvfs *st);
01687 
01688 
01707 int smbc_ftruncate(int fd, off_t size);
01708 
01709 
01730 int smbc_chmod(const char *url, mode_t mode);
01731 
01749 int smbc_utimes(const char *url, struct timeval *tbuf);
01750 
01751 #ifdef HAVE_UTIME_H
01752 
01768 int smbc_utime(const char *fname, struct utimbuf *utbuf);
01769 #endif
01770 
01870 int smbc_setxattr(const char *url,
01871                   const char *name,
01872                   const void *value,
01873                   size_t size,
01874                   int flags);
01875 
01876 
01980 int smbc_lsetxattr(const char *url,
01981                    const char *name,
01982                    const void *value,
01983                    size_t size,
01984                    int flags);
01985 
01986 
02087 int smbc_fsetxattr(int fd,
02088                    const char *name,
02089                    const void *value,
02090                    size_t size,
02091                    int flags);
02092 
02093 
02150 int smbc_getxattr(const char *url,
02151                   const char *name,
02152                   const void *value,
02153                   size_t size);
02154 
02155 
02215 int smbc_lgetxattr(const char *url,
02216                    const char *name,
02217                    const void *value,
02218                    size_t size);
02219 
02220 
02278 int smbc_fgetxattr(int fd,
02279                    const char *name,
02280                    const void *value,
02281                    size_t size);
02282 
02283 
02327 int smbc_removexattr(const char *url,
02328                      const char *name);
02329 
02330 
02377 int smbc_lremovexattr(const char *url,
02378                       const char *name);
02379 
02380 
02425 int smbc_fremovexattr(int fd,
02426                       const char *name);
02427 
02428 
02459 int smbc_listxattr(const char *url,
02460                    char *list,
02461                    size_t size);
02462 
02497 int smbc_llistxattr(const char *url,
02498                     char *list,
02499                     size_t size);
02500 
02532 int smbc_flistxattr(int fd,
02533                     char *list,
02534                     size_t size);
02535 
02551 int smbc_print_file(const char *fname, const char *printq);
02552 
02566 int smbc_open_print_job(const char *fname);
02567 
02579 int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn);
02580 
02593 int smbc_unlink_print_job(const char *purl, int id);
02594 
02605 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
02606 
02607 #ifdef __cplusplus
02608 }
02609 #endif
02610 
02629 #ifdef __cplusplus
02630 extern "C" {
02631 #endif
02632 int
02633 smbc_urldecode(char *dest, char * src, size_t max_dest_len);
02634 #ifdef __cplusplus
02635 }
02636 #endif
02637 
02638 
02639 /*
02640  * Convert any characters not specifically allowed in a URL into their %xx
02641  * equivalent.
02642  *
02643  * @param dest      A pointer to a buffer in which the resulting encoded
02644  *                  string should be placed.  Unlike smbc_urldecode(), this
02645  *                  must be a buffer unique from src.
02646  * 
02647  * @param src       A pointer to the buffer containing the string to be encoded.
02648  *                  Any character not specifically allowed in a URL is converted
02649  *                  into its hexadecimal value and encoded as %xx.
02650  *
02651  * @param max_dest_len
02652  *                  The size of the buffer pointed to by dest_segment.
02653  * 
02654  * @returns         The remaining buffer length.
02655  */
02656 #ifdef __cplusplus
02657 extern "C" {
02658 #endif
02659 int
02660 smbc_urlencode(char * dest, char * src, int max_dest_len);
02661 #ifdef __cplusplus
02662 }
02663 #endif
02664 
02665 
02672 #ifdef __cplusplus
02673 extern "C" {
02674 #endif
02675 const char *
02676 smbc_version(void);
02677 #ifdef __cplusplus
02678 }
02679 #endif
02680 
02700 void
02701 smbc_set_credentials(const char *workgroup,
02702                      const char *user,
02703                      const char *password,
02704                      smbc_bool use_kerberos,
02705                      const char *signing_state);
02706 
02707 /*
02708  * Wrapper around smbc_set_credentials.
02709  * Used to set correct credentials that will
02710  * be used to connect to DFS target share 
02711  * in libsmbclient
02712  */
02713 
02714 void
02715 smbc_set_credentials_with_fallback(SMBCCTX *ctx,
02716                                    const char *workgroup,
02717                                    const char *user,
02718                                    const char *password);
02719 
02720 
02731 void
02732 smbc_thread_posix(void);
02733 
02802 void
02803 smbc_thread_impl(
02804         /* Mutex functions. */
02805         int (*create_mutex)(const char *lockname,
02806                             void **pplock,
02807                             const char *location),
02808         void (*destroy_mutex)(void *plock,
02809                               const char *location),
02810         int (*lock_mutex)(void *plock,
02811                           int lock_type,
02812                           const char *location),
02813     
02814         /* Thread local storage. */
02815         int (*create_tls)(const char *keyname,
02816                           void **ppkey,
02817                           const char *location),
02818         void (*destroy_tls)(void **ppkey,
02819                             const char *location),
02820         int (*set_tls)(void *pkey,
02821                        const void *pval,
02822                        const char *location),
02823         void *(*get_tls)(void *pkey,
02824                          const char *location)
02825         );
02826 
02827 
02828 
02844 struct _SMBCCTX
02845 {
02852         int     debug DEPRECATED_SMBC_INTERFACE;
02853         
02860         char * netbios_name DEPRECATED_SMBC_INTERFACE;
02861 
02868         char * workgroup DEPRECATED_SMBC_INTERFACE;
02869 
02876         char * user DEPRECATED_SMBC_INTERFACE;
02877 
02885         int timeout DEPRECATED_SMBC_INTERFACE;
02886 
02896         smbc_open_fn                    open DEPRECATED_SMBC_INTERFACE;
02897         smbc_creat_fn                   creat DEPRECATED_SMBC_INTERFACE;
02898         smbc_read_fn                    read DEPRECATED_SMBC_INTERFACE;
02899         smbc_write_fn                   write DEPRECATED_SMBC_INTERFACE;
02900         smbc_unlink_fn                  unlink DEPRECATED_SMBC_INTERFACE;
02901         smbc_rename_fn                  rename DEPRECATED_SMBC_INTERFACE;
02902         smbc_lseek_fn                   lseek DEPRECATED_SMBC_INTERFACE;
02903         smbc_stat_fn                    stat DEPRECATED_SMBC_INTERFACE;
02904         smbc_fstat_fn                   fstat DEPRECATED_SMBC_INTERFACE;
02905 #if 0 /* internal */
02906         smbc_ftruncate_fn               ftruncate_fn;
02907 #endif
02908         smbc_close_fn                   close_fn DEPRECATED_SMBC_INTERFACE;
02909         smbc_opendir_fn                 opendir DEPRECATED_SMBC_INTERFACE;
02910         smbc_closedir_fn                closedir DEPRECATED_SMBC_INTERFACE;
02911         smbc_readdir_fn                 readdir DEPRECATED_SMBC_INTERFACE;
02912         smbc_getdents_fn                getdents DEPRECATED_SMBC_INTERFACE;
02913         smbc_mkdir_fn                   mkdir DEPRECATED_SMBC_INTERFACE;
02914         smbc_rmdir_fn                   rmdir DEPRECATED_SMBC_INTERFACE;
02915         smbc_telldir_fn                 telldir DEPRECATED_SMBC_INTERFACE;
02916         smbc_lseekdir_fn                lseekdir DEPRECATED_SMBC_INTERFACE;
02917         smbc_fstatdir_fn                fstatdir DEPRECATED_SMBC_INTERFACE;
02918         smbc_chmod_fn                   chmod DEPRECATED_SMBC_INTERFACE;
02919         smbc_utimes_fn                  utimes DEPRECATED_SMBC_INTERFACE;
02920         smbc_setxattr_fn                setxattr DEPRECATED_SMBC_INTERFACE;
02921         smbc_getxattr_fn                getxattr DEPRECATED_SMBC_INTERFACE;
02922         smbc_removexattr_fn             removexattr DEPRECATED_SMBC_INTERFACE;
02923         smbc_listxattr_fn               listxattr DEPRECATED_SMBC_INTERFACE;
02924 
02925         /* Printing-related functions */
02926         smbc_print_file_fn              print_file DEPRECATED_SMBC_INTERFACE;
02927         smbc_open_print_job_fn          open_print_job DEPRECATED_SMBC_INTERFACE;
02928         smbc_list_print_jobs_fn         list_print_jobs DEPRECATED_SMBC_INTERFACE;
02929         smbc_unlink_print_job_fn        unlink_print_job DEPRECATED_SMBC_INTERFACE;
02930 
02931         /*
02932         ** Callbacks
02933         *
02934         * DEPRECATED:
02935         *
02936         * See the comment above each field, for the getter and setter
02937         * functions that should now be used.
02938         */
02939         struct _smbc_callbacks
02940         {
02947                 smbc_get_auth_data_fn auth_fn DEPRECATED_SMBC_INTERFACE;
02948                 
02956                 smbc_check_server_fn check_server_fn DEPRECATED_SMBC_INTERFACE;
02957 
02965                 smbc_remove_unused_server_fn remove_unused_server_fn DEPRECATED_SMBC_INTERFACE;
02966 
02982                 smbc_add_cached_srv_fn add_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
02983 
02991                 smbc_get_cached_srv_fn get_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
02992 
03000                 smbc_remove_cached_srv_fn remove_cached_srv_fn DEPRECATED_SMBC_INTERFACE;
03001                 
03010                 smbc_purge_cached_fn purge_cached_fn DEPRECATED_SMBC_INTERFACE;
03011         } callbacks;
03012 
03019         void * reserved DEPRECATED_SMBC_INTERFACE;
03020 
03021         /*
03022          * Very old configuration options.
03023          * 
03024          * DEPRECATED:
03025          * Use one of the following functions instead:
03026          *   smbc_setOptionUseKerberos()
03027          *   smbc_getOptionUseKerberos()
03028          *   smbc_setOptionFallbackAfterKerberos()
03029          *   smbc_getOptionFallbackAfterKerberos()
03030          *   smbc_setOptionNoAutoAnonymousLogin()
03031          *   smbc_getOptionNoAutoAnonymousLogin()
03032          */
03033         int flags DEPRECATED_SMBC_INTERFACE;
03034         
03044         struct _smbc_options {
03045                 int browse_max_lmb_count DEPRECATED_SMBC_INTERFACE;
03046                 int urlencode_readdir_entries DEPRECATED_SMBC_INTERFACE;
03047                 int one_share_per_server DEPRECATED_SMBC_INTERFACE;
03048         } options DEPRECATED_SMBC_INTERFACE;
03049         
03053         struct SMBC_internal_data * internal;
03054 };
03055 
03056 
03057 #endif /* SMBCLIENT_H_INCLUDED */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines