LCOV - code coverage report
Current view: top level - source3/libsmb - libsmb_setget.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 335 383 87.5 %
Date: 2024-04-21 15:09:00 Functions: 116 135 85.9 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/Netbios implementation.
       3             :    SMB client library implementation
       4             :    Copyright (C) Andrew Tridgell 1998
       5             :    Copyright (C) Richard Sharpe 2000, 2002
       6             :    Copyright (C) John Terpstra 2000
       7             :    Copyright (C) Tom Jansen (Ninja ISD) 2002
       8             :    Copyright (C) Derrell Lipman 2003-2008
       9             :    Copyright (C) Jeremy Allison 2007, 2008
      10             : 
      11             :    This program is free software; you can redistribute it and/or modify
      12             :    it under the terms of the GNU General Public License as published by
      13             :    the Free Software Foundation; either version 3 of the License, or
      14             :    (at your option) any later version.
      15             : 
      16             :    This program is distributed in the hope that it will be useful,
      17             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :    GNU General Public License for more details.
      20             : 
      21             :    You should have received a copy of the GNU General Public License
      22             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      23             : */
      24             : 
      25             : #include "includes.h"
      26             : #define __LIBSMBCLIENT_INTERNAL__
      27             : #include "libsmbclient.h"
      28             : #include "libsmb_internal.h"
      29             : #include "lib/param/param.h"
      30             : 
      31             : 
      32             : /** Get the netbios name used for making connections */
      33             : const char *
      34         362 : smbc_getNetbiosName(SMBCCTX *c)
      35             : {
      36         362 :         return c->netbios_name;
      37             : }
      38             : 
      39             : /** Set the netbios name used for making connections */
      40             : void
      41         150 : smbc_setNetbiosName(SMBCCTX *c, const char *netbios_name)
      42             : {
      43         150 :         SAFE_FREE(c->netbios_name);
      44         150 :         if (netbios_name) {
      45         110 :                 c->netbios_name = SMB_STRDUP(netbios_name);
      46             :         }
      47         150 : }
      48             : 
      49             : /** Get the workgroup used for making connections */
      50             : const char *
      51        3546 : smbc_getWorkgroup(SMBCCTX *c)
      52             : {
      53        3546 :         return c->workgroup;
      54             : }
      55             : 
      56             : /** Set the workgroup used for making connections */
      57             : void
      58         192 : smbc_setWorkgroup(SMBCCTX *c, const char *workgroup)
      59             : {
      60         192 :         SAFE_FREE(c->workgroup);
      61         192 :         if (workgroup) {
      62         152 :                 c->workgroup = SMB_STRDUP(workgroup);
      63             :         }
      64         192 : }
      65             : 
      66             : /** Get the username used for making connections */
      67             : const char *
      68         316 : smbc_getUser(SMBCCTX *c)
      69             : {
      70         316 :         return c->user;
      71             : }
      72             : 
      73             : /** Set the username used for making connections */
      74             : void
      75         192 : smbc_setUser(SMBCCTX *c, const char *user)
      76             : {
      77         192 :         SAFE_FREE(c->user);
      78         192 :         if (user) {
      79         152 :                 c->user = SMB_STRDUP(user);
      80             :         }
      81         192 : }
      82             : 
      83             : /** Get the debug level */
      84             : int
      85         216 : smbc_getDebug(SMBCCTX *c)
      86             : {
      87         216 :         return c->debug;
      88             : }
      89             : 
      90             : /** Set the debug level */
      91             : void
      92         200 : smbc_setDebug(SMBCCTX *c, int debug)
      93             : {
      94           0 :         char buf[32];
      95         200 :         TALLOC_CTX *frame = talloc_stackframe();
      96         200 :         snprintf(buf, sizeof(buf), "%d", debug);
      97         200 :         c->debug = debug;
      98         200 :         lpcfg_set_cmdline(c->internal->lp_ctx, "log level", buf);
      99         200 :         TALLOC_FREE(frame);
     100         200 : }
     101             : 
     102             : /** set callback function which will be called for logging */
     103             : void
     104           8 : smbc_setLogCallback(SMBCCTX *c, void *private_ptr,
     105             :                     smbc_debug_callback_fn fn)
     106             : {
     107           8 :         debug_set_callback(private_ptr, fn);
     108           8 : }
     109             : 
     110             : /** set configuration file */
     111          56 : int smbc_setConfiguration(SMBCCTX *c, const char *file)
     112             : {
     113           0 :         bool ok;
     114             : 
     115          56 :         ok = lp_load_client_no_reinit(file);
     116          56 :         if (!ok) {
     117           0 :                 DBG_WARNING("Could not load config file: %s\n", file);
     118           0 :                 errno = ENOENT;
     119           0 :                 return -1;
     120             :         }
     121             : 
     122          56 :         DBG_NOTICE("Configuration loaded successfully: %s\n", file);
     123          56 :         return 0;
     124             : }
     125             : /**
     126             :  * Get the timeout used for waiting on connections and response data
     127             :  * (in milliseconds)
     128             :  */
     129             : int
     130         314 : smbc_getTimeout(SMBCCTX *c)
     131             : {
     132         314 :         return c->timeout;
     133             : }
     134             : 
     135             : /**
     136             :  * Set the timeout used for waiting on connections and response data
     137             :  * (in milliseconds)
     138             :  */
     139             : void
     140         110 : smbc_setTimeout(SMBCCTX *c, int timeout)
     141             : {
     142         110 :         c->timeout = timeout;
     143         110 : }
     144             : 
     145             : /**
     146             :  * Get the TCP port used to connect.
     147             :  */
     148             : uint16_t
     149        1695 : smbc_getPort(SMBCCTX *c)
     150             : {
     151        1695 :         return c->internal->port;
     152             : }
     153             : 
     154             : /**
     155             :  * Set the TCP port used to connect.
     156             :  */
     157             : void
     158         106 : smbc_setPort(SMBCCTX *c, uint16_t port)
     159             : {
     160         106 :         c->internal->port = port;
     161         106 : }
     162             : 
     163             : 
     164             : /** Get whether to log to standard error instead of standard output */
     165             : smbc_bool
     166           4 : smbc_getOptionDebugToStderr(SMBCCTX *c)
     167             : {
     168           0 :         smbc_bool ret;
     169           4 :         TALLOC_CTX *frame = talloc_stackframe();
     170             : 
     171             :         /* Because this is a global concept, it is better to check
     172             :          * what is really set, rather than what we wanted set
     173             :          * (particularly as you cannot go back to stdout). */
     174           4 :         ret = debug_get_output_is_stderr();
     175           4 :         TALLOC_FREE(frame);
     176           4 :         return ret;
     177             : }
     178             : 
     179             : /** Set whether to log to standard error instead of standard output.
     180             :  * This option is 'sticky' - once set to true, it cannot be set to
     181             :  * false again, as it is global to the process, as once we have been
     182             :  * told that it is not safe to safe to write to stdout, we shouldn't
     183             :  * go back as we don't know it was this context that set it that way.
     184             :  */
     185             : void
     186          46 : smbc_setOptionDebugToStderr(SMBCCTX *c, smbc_bool b)
     187             : {
     188          46 :         TALLOC_CTX *frame = talloc_stackframe();
     189          46 :         if (b) {
     190             :                 /*
     191             :                  * We do not have a unique per-thread debug state? For
     192             :                  * now, we'll just leave it up to the user. If any one
     193             :                  * context specifies debug to stderr then all will be (and
     194             :                  * will stay that way, as it is unsafe to flip back if
     195             :                  * stdout is in use for other things)
     196             :                  */
     197          46 :                 setup_logging("libsmbclient", DEBUG_STDERR);
     198             :         }
     199          46 :         TALLOC_FREE(frame);
     200          46 : }
     201             : 
     202             : /**
     203             :  * Get whether to use new-style time attribute names, e.g. WRITE_TIME rather
     204             :  * than the old-style names such as M_TIME.  This allows also setting/getting
     205             :  * CREATE_TIME which was previously unimplemented.  (Note that the old C_TIME
     206             :  * was supposed to be CHANGE_TIME but was confused and sometimes referred to
     207             :  * CREATE_TIME.)
     208             :  */
     209             : smbc_bool
     210           4 : smbc_getOptionFullTimeNames(SMBCCTX *c)
     211             : {
     212           4 :         return c->internal->full_time_names;
     213             : }
     214             : 
     215             : /**
     216             :  * Set whether to use new-style time attribute names, e.g. WRITE_TIME rather
     217             :  * than the old-style names such as M_TIME.  This allows also setting/getting
     218             :  * CREATE_TIME which was previously unimplemented.  (Note that the old C_TIME
     219             :  * was supposed to be CHANGE_TIME but was confused and sometimes referred to
     220             :  * CREATE_TIME.)
     221             :  */
     222             : void
     223         110 : smbc_setOptionFullTimeNames(SMBCCTX *c, smbc_bool b)
     224             : {
     225         110 :         c->internal->full_time_names = b;
     226         110 : }
     227             : 
     228             : /**
     229             :  * Get the share mode to use for files opened with SMBC_open_ctx().  The
     230             :  * default is SMBC_SHAREMODE_DENY_NONE.
     231             :  */
     232             : smbc_share_mode
     233           4 : smbc_getOptionOpenShareMode(SMBCCTX *c)
     234             : {
     235           4 :         return c->internal->share_mode;
     236             : }
     237             : 
     238             : /**
     239             :  * Set the share mode to use for files opened with SMBC_open_ctx().  The
     240             :  * default is SMBC_SHAREMODE_DENY_NONE.
     241             :  */
     242             : void
     243         110 : smbc_setOptionOpenShareMode(SMBCCTX *c, smbc_share_mode share_mode)
     244             : {
     245         110 :         c->internal->share_mode = share_mode;
     246         110 : }
     247             : 
     248             : /** Retrieve a previously set user data handle */
     249             : void *
     250           4 : smbc_getOptionUserData(SMBCCTX *c)
     251             : {
     252           4 :         return c->internal->user_data;
     253             : }
     254             : 
     255             : /** Save a user data handle */
     256             : void
     257         110 : smbc_setOptionUserData(SMBCCTX *c, void *user_data)
     258             : {
     259         110 :         c->internal->user_data = user_data;
     260         110 : }
     261             : 
     262             : /** Get the encoded value for encryption level. */
     263             : smbc_smb_encrypt_level
     264           4 : smbc_getOptionSmbEncryptionLevel(SMBCCTX *c)
     265             : {
     266           4 :         return c->internal->smb_encryption_level;
     267             : }
     268             : 
     269             : /** Set the encoded value for encryption level. */
     270             : void
     271         158 : smbc_setOptionSmbEncryptionLevel(SMBCCTX *c, smbc_smb_encrypt_level level)
     272             : {
     273         158 :         c->internal->smb_encryption_level = level;
     274         158 : }
     275             : 
     276             : /**
     277             :  * Get whether to treat file names as case-sensitive if we can't determine
     278             :  * when connecting to the remote share whether the file system is case
     279             :  * sensitive. This defaults to FALSE since it's most likely that if we can't
     280             :  * retrieve the file system attributes, it's a very old file system that does
     281             :  * not support case sensitivity.
     282             :  */
     283             : smbc_bool
     284           4 : smbc_getOptionCaseSensitive(SMBCCTX *c)
     285             : {
     286           4 :         return c->internal->case_sensitive;
     287             : }
     288             : 
     289             : /**
     290             :  * Set whether to treat file names as case-sensitive if we can't determine
     291             :  * when connecting to the remote share whether the file system is case
     292             :  * sensitive. This defaults to FALSE since it's most likely that if we can't
     293             :  * retrieve the file system attributes, it's a very old file system that does
     294             :  * not support case sensitivity.
     295             :  */
     296             : void
     297         110 : smbc_setOptionCaseSensitive(SMBCCTX *c, smbc_bool b)
     298             : {
     299         110 :         c->internal->case_sensitive = b;
     300         110 : }
     301             : 
     302             : /**
     303             :  * Get from how many local master browsers should the list of workgroups be
     304             :  * retrieved.  It can take up to 12 minutes or longer after a server becomes a
     305             :  * local master browser, for it to have the entire browse list (the list of
     306             :  * workgroups/domains) from an entire network.  Since a client never knows
     307             :  * which local master browser will be found first, the one which is found
     308             :  * first and used to retrieve a browse list may have an incomplete or empty
     309             :  * browse list.  By requesting the browse list from multiple local master
     310             :  * browsers, a more complete list can be generated.  For small networks (few
     311             :  * workgroups), it is recommended that this value be set to 0, causing the
     312             :  * browse lists from all found local master browsers to be retrieved and
     313             :  * merged.  For networks with many workgroups, a suitable value for this
     314             :  * variable is probably somewhere around 3. (Default: 3).
     315             :  */
     316             : int
     317          12 : smbc_getOptionBrowseMaxLmbCount(SMBCCTX *c)
     318             : {
     319          12 :         return c->options.browse_max_lmb_count;
     320             : }
     321             : 
     322             : /**
     323             :  * Set from how many local master browsers should the list of workgroups be
     324             :  * retrieved.  It can take up to 12 minutes or longer after a server becomes a
     325             :  * local master browser, for it to have the entire browse list (the list of
     326             :  * workgroups/domains) from an entire network.  Since a client never knows
     327             :  * which local master browser will be found first, the one which is found
     328             :  * first and used to retrieve a browse list may have an incomplete or empty
     329             :  * browse list.  By requesting the browse list from multiple local master
     330             :  * browsers, a more complete list can be generated.  For small networks (few
     331             :  * workgroups), it is recommended that this value be set to 0, causing the
     332             :  * browse lists from all found local master browsers to be retrieved and
     333             :  * merged.  For networks with many workgroups, a suitable value for this
     334             :  * variable is probably somewhere around 3. (Default: 3).
     335             :  */
     336             : void
     337         110 : smbc_setOptionBrowseMaxLmbCount(SMBCCTX *c, int count)
     338             : {
     339         110 :         c->options.browse_max_lmb_count = count;
     340         110 : }
     341             : 
     342             : /**
     343             :  * Get whether to url-encode readdir entries.
     344             :  *
     345             :  * There is a difference in the desired return strings from
     346             :  * smbc_readdir() depending upon whether the filenames are to
     347             :  * be displayed to the user, or whether they are to be
     348             :  * appended to the path name passed to smbc_opendir() to call
     349             :  * a further smbc_ function (e.g. open the file with
     350             :  * smbc_open()).  In the former case, the filename should be
     351             :  * in "human readable" form.  In the latter case, the smbc_
     352             :  * functions expect a URL which must be url-encoded.  Those
     353             :  * functions decode the URL.  If, for example, smbc_readdir()
     354             :  * returned a file name of "abc%20def.txt", passing a path
     355             :  * with this file name attached to smbc_open() would cause
     356             :  * smbc_open to attempt to open the file "abc def.txt" since
     357             :  * the %20 is decoded into a space.
     358             :  *
     359             :  * Set this option to True if the names returned by
     360             :  * smbc_readdir() should be url-encoded such that they can be
     361             :  * passed back to another smbc_ call.  Set it to False if the
     362             :  * names returned by smbc_readdir() are to be presented to the
     363             :  * user.
     364             :  *
     365             :  * For backwards compatibility, this option defaults to False.
     366             :  */
     367             : smbc_bool
     368        1274 : smbc_getOptionUrlEncodeReaddirEntries(SMBCCTX *c)
     369             : {
     370        1274 :         return c->options.urlencode_readdir_entries;
     371             : }
     372             : 
     373             : /**
     374             :  * Set whether to url-encode readdir entries.
     375             :  *
     376             :  * There is a difference in the desired return strings from
     377             :  * smbc_readdir() depending upon whether the filenames are to
     378             :  * be displayed to the user, or whether they are to be
     379             :  * appended to the path name passed to smbc_opendir() to call
     380             :  * a further smbc_ function (e.g. open the file with
     381             :  * smbc_open()).  In the former case, the filename should be
     382             :  * in "human readable" form.  In the latter case, the smbc_
     383             :  * functions expect a URL which must be url-encoded.  Those
     384             :  * functions decode the URL.  If, for example, smbc_readdir()
     385             :  * returned a file name of "abc%20def.txt", passing a path
     386             :  * with this file name attached to smbc_open() would cause
     387             :  * smbc_open to attempt to open the file "abc def.txt" since
     388             :  * the %20 is decoded into a space.
     389             :  *
     390             :  * Set this option to True if the names returned by
     391             :  * smbc_readdir() should be url-encoded such that they can be
     392             :  * passed back to another smbc_ call.  Set it to False if the
     393             :  * names returned by smbc_readdir() are to be presented to the
     394             :  * user.
     395             :  *
     396             :  * For backwards compatibility, this option defaults to False.
     397             :  */
     398             : void
     399         110 : smbc_setOptionUrlEncodeReaddirEntries(SMBCCTX *c, smbc_bool b)
     400             : {
     401         110 :         c->options.urlencode_readdir_entries = b;
     402         110 : }
     403             : 
     404             : /**
     405             :  * Get whether to use the same connection for all shares on a server.
     406             :  *
     407             :  * Some Windows versions appear to have a limit to the number
     408             :  * of concurrent SESSIONs and/or TREE CONNECTions.  In
     409             :  * one-shot programs (i.e. the program runs and then quickly
     410             :  * ends, thereby shutting down all connections), it is
     411             :  * probably reasonable to establish a new connection for each
     412             :  * share.  In long-running applications, the limitation can be
     413             :  * avoided by using only a single connection to each server,
     414             :  * and issuing a new TREE CONNECT when the share is accessed.
     415             :  */
     416             : smbc_bool
     417        1360 : smbc_getOptionOneSharePerServer(SMBCCTX *c)
     418             : {
     419        1360 :         return c->options.one_share_per_server;
     420             : }
     421             : 
     422             : /**
     423             :  * Set whether to use the same connection for all shares on a server.
     424             :  *
     425             :  * Some Windows versions appear to have a limit to the number
     426             :  * of concurrent SESSIONs and/or TREE CONNECTions.  In
     427             :  * one-shot programs (i.e. the program runs and then quickly
     428             :  * ends, thereby shutting down all connections), it is
     429             :  * probably reasonable to establish a new connection for each
     430             :  * share.  In long-running applications, the limitation can be
     431             :  * avoided by using only a single connection to each server,
     432             :  * and issuing a new TREE CONNECT when the share is accessed.
     433             :  */
     434             : void
     435         110 : smbc_setOptionOneSharePerServer(SMBCCTX *c, smbc_bool b)
     436             : {
     437         110 :         c->options.one_share_per_server = b;
     438         110 : }
     439             : 
     440             : /** Get whether to enable use of kerberos */
     441             : smbc_bool
     442        3289 : smbc_getOptionUseKerberos(SMBCCTX *c)
     443             : {
     444        3289 :         return c->flags & SMB_CTX_FLAG_USE_KERBEROS ? True : False;
     445             : }
     446             : 
     447             : /** Set whether to enable use of kerberos */
     448             : void
     449          52 : smbc_setOptionUseKerberos(SMBCCTX *c, smbc_bool b)
     450             : {
     451          52 :         if (b) {
     452          44 :                 c->flags |= SMB_CTX_FLAG_USE_KERBEROS;
     453             :         } else {
     454           8 :                 c->flags &= ~SMB_CTX_FLAG_USE_KERBEROS;
     455             :         }
     456          52 : }
     457             : 
     458             : /** Get whether to fallback after kerberos */
     459             : smbc_bool
     460         412 : smbc_getOptionFallbackAfterKerberos(SMBCCTX *c)
     461             : {
     462         412 :         return c->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS ? True : False;
     463             : }
     464             : 
     465             : /** Set whether to fallback after kerberos */
     466             : void
     467          48 : smbc_setOptionFallbackAfterKerberos(SMBCCTX *c, smbc_bool b)
     468             : {
     469          48 :         if (b) {
     470          40 :                 c->flags |= SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
     471             :         } else {
     472           8 :                 c->flags &= ~SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS;
     473             :         }
     474          48 : }
     475             : 
     476             : /** Get whether to automatically select anonymous login */
     477             : smbc_bool
     478           6 : smbc_getOptionNoAutoAnonymousLogin(SMBCCTX *c)
     479             : {
     480           6 :         return c->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON ? True : False;
     481             : }
     482             : 
     483             : /** Set whether to automatically select anonymous login */
     484             : void
     485          10 : smbc_setOptionNoAutoAnonymousLogin(SMBCCTX *c, smbc_bool b)
     486             : {
     487          10 :         if (b) {
     488          10 :                 c->flags |= SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON;
     489             :         } else {
     490           0 :                 c->flags &= ~SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON;
     491             :         }
     492          10 : }
     493             : 
     494             : /** Get whether to enable use of the winbind ccache */
     495             : smbc_bool
     496        3289 : smbc_getOptionUseCCache(SMBCCTX *c)
     497             : {
     498        3289 :         return c->flags & SMB_CTX_FLAG_USE_CCACHE ? True : False;
     499             : }
     500             : 
     501             : /** Set whether to enable use of the winbind ccache */
     502             : void
     503         158 : smbc_setOptionUseCCache(SMBCCTX *c, smbc_bool b)
     504             : {
     505         158 :         if (b) {
     506         110 :                 c->flags |= SMB_CTX_FLAG_USE_CCACHE;
     507             :         } else {
     508          48 :                 c->flags &= ~SMB_CTX_FLAG_USE_CCACHE;
     509             :         }
     510         158 : }
     511             : 
     512             : /** Get indication whether the password supplied is the NT hash */
     513             : smbc_bool
     514          98 : smbc_getOptionUseNTHash(SMBCCTX *c)
     515             : {
     516          98 :         return (c->flags & SMB_CTX_FLAG_USE_NT_HASH) != 0;
     517             : }
     518             : 
     519             : /** Set indication that the password supplied is the NT hash */
     520             : void
     521          48 : smbc_setOptionUseNTHash(SMBCCTX *c, smbc_bool b)
     522             : {
     523          48 :         if (b) {
     524           0 :                 c->flags |= SMB_CTX_FLAG_USE_NT_HASH;
     525             :         } else {
     526          48 :                 c->flags &= ~SMB_CTX_FLAG_USE_NT_HASH;
     527             :         }
     528          48 : }
     529             : 
     530             : smbc_bool
     531          42 : smbc_setOptionProtocols(SMBCCTX *c,
     532             :                         const char *min_proto,
     533             :                         const char *max_proto)
     534             : {
     535          42 :         bool ok = true;
     536             : 
     537          42 :         if (min_proto != NULL) {
     538          42 :                 ok = lpcfg_set_cmdline(c->internal->lp_ctx,
     539             :                                        "client min protocol",
     540             :                                        min_proto);
     541             :         }
     542             : 
     543          42 :         if (max_proto != NULL) {
     544          42 :                 ok &= lpcfg_set_cmdline(c->internal->lp_ctx,
     545             :                                         "client max protocol",
     546             :                                         max_proto);
     547             :         }
     548             : 
     549          42 :         return ok;
     550             : }
     551             : 
     552             : /** Get whether to enable POSIX extensions if available */
     553             : smbc_bool
     554           0 : smbc_getOptionPosixExtensions(SMBCCTX *c)
     555             : {
     556           0 :         return c->internal->posix_extensions;
     557             : }
     558             : 
     559             : /** Set whether to enable POSIX extensions if available */
     560             : void
     561         106 : smbc_setOptionPosixExtensions(SMBCCTX *c, smbc_bool b)
     562             : {
     563         106 :         c->internal->posix_extensions = b;
     564         106 : }
     565             : 
     566             : /** Get the function for obtaining authentication data */
     567             : smbc_get_auth_data_fn
     568         120 : smbc_getFunctionAuthData(SMBCCTX *c)
     569             : {
     570           0 :         smbc_get_auth_data_fn ret;
     571         120 :         TALLOC_CTX *frame = talloc_stackframe();
     572         120 :         ret = c->callbacks.auth_fn;
     573         120 :         TALLOC_FREE(frame);
     574         120 :         return ret;
     575             : }
     576             : 
     577             : /** Set the function for obtaining authentication data */
     578             : void
     579         148 : smbc_setFunctionAuthData(SMBCCTX *c, smbc_get_auth_data_fn fn)
     580             : {
     581         148 :         c->internal->auth_fn_with_context = NULL;
     582         148 :         c->callbacks.auth_fn = fn;
     583         148 : }
     584             : 
     585             : /** Get the new-style authentication function which includes the context. */
     586             : smbc_get_auth_data_with_context_fn
     587         148 : smbc_getFunctionAuthDataWithContext(SMBCCTX *c)
     588             : {
     589         148 :         return c->internal->auth_fn_with_context;
     590             : }
     591             : 
     592             : /** Set the new-style authentication function which includes the context. */
     593             : void
     594          48 : smbc_setFunctionAuthDataWithContext(SMBCCTX *c,
     595             :                                     smbc_get_auth_data_with_context_fn fn)
     596             : {
     597          48 :         c->callbacks.auth_fn = NULL;
     598          48 :         c->internal->auth_fn_with_context = fn;
     599          48 : }
     600             : 
     601             : /** Get the function for checking if a server is still good */
     602             : smbc_check_server_fn
     603        1364 : smbc_getFunctionCheckServer(SMBCCTX *c)
     604             : {
     605        1364 :         return c->callbacks.check_server_fn;
     606             : }
     607             : 
     608             : /** Set the function for checking if a server is still good */
     609             : void
     610         106 : smbc_setFunctionCheckServer(SMBCCTX *c, smbc_check_server_fn fn)
     611             : {
     612         106 :         c->callbacks.check_server_fn = fn;
     613         106 : }
     614             : 
     615             : /** Get the function for removing a server if unused */
     616             : smbc_remove_unused_server_fn
     617           0 : smbc_getFunctionRemoveUnusedServer(SMBCCTX *c)
     618             : {
     619           0 :         return c->callbacks.remove_unused_server_fn;
     620             : }
     621             : 
     622             : /** Set the function for removing a server if unused */
     623             : void
     624         106 : smbc_setFunctionRemoveUnusedServer(SMBCCTX *c,
     625             :                                    smbc_remove_unused_server_fn fn)
     626             : {
     627         106 :         c->callbacks.remove_unused_server_fn = fn;
     628         106 : }
     629             : 
     630             : /** Get the function for adding a cached server */
     631             : smbc_add_cached_srv_fn
     632          98 : smbc_getFunctionAddCachedServer(SMBCCTX *c)
     633             : {
     634          98 :         return c->callbacks.add_cached_srv_fn;
     635             : }
     636             : 
     637             : /** Set the function for adding a cached server */
     638             : void
     639         106 : smbc_setFunctionAddCachedServer(SMBCCTX *c, smbc_add_cached_srv_fn fn)
     640             : {
     641         106 :         c->callbacks.add_cached_srv_fn = fn;
     642         106 : }
     643             : 
     644             : /** Get the function for server cache lookup */
     645             : smbc_get_cached_srv_fn
     646        1594 : smbc_getFunctionGetCachedServer(SMBCCTX *c)
     647             : {
     648        1594 :         return c->callbacks.get_cached_srv_fn;
     649             : }
     650             : 
     651             : /** Set the function for server cache lookup */
     652             : void
     653         106 : smbc_setFunctionGetCachedServer(SMBCCTX *c, smbc_get_cached_srv_fn fn)
     654             : {
     655         106 :         c->callbacks.get_cached_srv_fn = fn;
     656         106 : }
     657             : 
     658             : /** Get the function for server cache removal */
     659             : smbc_remove_cached_srv_fn
     660          32 : smbc_getFunctionRemoveCachedServer(SMBCCTX *c)
     661             : {
     662          32 :         return c->callbacks.remove_cached_srv_fn;
     663             : }
     664             : 
     665             : /** Set the function for server cache removal */
     666             : void
     667         106 : smbc_setFunctionRemoveCachedServer(SMBCCTX *c,
     668             :                                    smbc_remove_cached_srv_fn fn)
     669             : {
     670         106 :         c->callbacks.remove_cached_srv_fn = fn;
     671         106 : }
     672             : 
     673             : /**
     674             :  * Get the function for server cache purging.  This function tries to
     675             :  * remove all cached servers (e.g. on disconnect)
     676             :  */
     677             : smbc_purge_cached_fn
     678          40 : smbc_getFunctionPurgeCachedServers(SMBCCTX *c)
     679             : {
     680          40 :         return c->callbacks.purge_cached_fn;
     681             : }
     682             : 
     683             : /** Set the function to store private data of the server cache */
     684           0 : void smbc_setServerCacheData(SMBCCTX *c, struct smbc_server_cache * cache)
     685             : {
     686           0 :         c->internal->server_cache = cache;
     687           0 : }
     688             : 
     689             : /** Get the function to store private data of the server cache */
     690           0 : struct smbc_server_cache * smbc_getServerCacheData(SMBCCTX *c)
     691             : {
     692           0 :         return c->internal->server_cache;
     693             : }
     694             : 
     695             : 
     696             : /**
     697             :  * Set the function for server cache purging.  This function tries to
     698             :  * remove all cached servers (e.g. on disconnect)
     699             :  */
     700             : void
     701         106 : smbc_setFunctionPurgeCachedServers(SMBCCTX *c, smbc_purge_cached_fn fn)
     702             : {
     703         106 :         c->callbacks.purge_cached_fn = fn;
     704         106 : }
     705             : 
     706             : /**
     707             :  * Callable functions for files.
     708             :  */
     709             : 
     710             : smbc_open_fn
     711          64 : smbc_getFunctionOpen(SMBCCTX *c)
     712             : {
     713          64 :         return c->open;
     714             : }
     715             : 
     716             : void
     717         106 : smbc_setFunctionOpen(SMBCCTX *c, smbc_open_fn fn)
     718             : {
     719         106 :         c->open = fn;
     720         106 : }
     721             : 
     722             : smbc_creat_fn
     723         420 : smbc_getFunctionCreat(SMBCCTX *c)
     724             : {
     725         420 :         return c->creat;
     726             : }
     727             : 
     728             : void
     729         106 : smbc_setFunctionCreat(SMBCCTX *c, smbc_creat_fn fn)
     730             : {
     731         106 :         c->creat = fn;
     732         106 : }
     733             : 
     734             : smbc_read_fn
     735         402 : smbc_getFunctionRead(SMBCCTX *c)
     736             : {
     737         402 :         return c->read;
     738             : }
     739             : 
     740             : void
     741         106 : smbc_setFunctionRead(SMBCCTX *c, smbc_read_fn fn)
     742             : {
     743         106 :         c->read = fn;
     744         106 : }
     745             : 
     746             : smbc_write_fn
     747           0 : smbc_getFunctionWrite(SMBCCTX *c)
     748             : {
     749           0 :         return c->write;
     750             : }
     751             : 
     752             : void
     753         106 : smbc_setFunctionWrite(SMBCCTX *c, smbc_write_fn fn)
     754             : {
     755         106 :         c->write = fn;
     756         106 : }
     757             : 
     758             : smbc_splice_fn
     759           0 : smbc_getFunctionSplice(SMBCCTX *c)
     760             : {
     761           0 :         return c->internal->smb.splice_fn;
     762             : }
     763             : 
     764             : void
     765         106 : smbc_setFunctionSplice(SMBCCTX *c, smbc_splice_fn fn)
     766             : {
     767         106 :         c->internal->smb.splice_fn = fn;
     768         106 : }
     769             : 
     770             : smbc_unlink_fn
     771         848 : smbc_getFunctionUnlink(SMBCCTX *c)
     772             : {
     773         848 :         return c->unlink;
     774             : }
     775             : 
     776             : void
     777         106 : smbc_setFunctionUnlink(SMBCCTX *c, smbc_unlink_fn fn)
     778             : {
     779         106 :         c->unlink = fn;
     780         106 : }
     781             : 
     782             : smbc_rename_fn
     783           4 : smbc_getFunctionRename(SMBCCTX *c)
     784             : {
     785           4 :         return c->rename;
     786             : }
     787             : 
     788             : void
     789         106 : smbc_setFunctionRename(SMBCCTX *c, smbc_rename_fn fn)
     790             : {
     791         106 :         c->rename = fn;
     792         106 : }
     793             : 
     794             : smbc_lseek_fn
     795           2 : smbc_getFunctionLseek(SMBCCTX *c)
     796             : {
     797           2 :         return c->lseek;
     798             : }
     799             : 
     800             : void
     801         106 : smbc_setFunctionLseek(SMBCCTX *c, smbc_lseek_fn fn)
     802             : {
     803         106 :         c->lseek = fn;
     804         106 : }
     805             : 
     806             : smbc_stat_fn
     807          12 : smbc_getFunctionStat(SMBCCTX *c)
     808             : {
     809          12 :         return c->stat;
     810             : }
     811             : 
     812             : void
     813         106 : smbc_setFunctionStat(SMBCCTX *c, smbc_stat_fn fn)
     814             : {
     815         106 :         c->stat = fn;
     816         106 : }
     817             : 
     818             : smbc_fstat_fn
     819          68 : smbc_getFunctionFstat(SMBCCTX *c)
     820             : {
     821          68 :         return c->fstat;
     822             : }
     823             : 
     824             : void
     825         106 : smbc_setFunctionFstat(SMBCCTX *c, smbc_fstat_fn fn)
     826             : {
     827         106 :         c->fstat = fn;
     828         106 : }
     829             : 
     830             : smbc_statvfs_fn
     831           0 : smbc_getFunctionStatVFS(SMBCCTX *c)
     832             : {
     833           0 :         return c->internal->posix_emu.statvfs_fn;
     834             : }
     835             : 
     836             : void
     837         106 : smbc_setFunctionStatVFS(SMBCCTX *c, smbc_statvfs_fn fn)
     838             : {
     839         106 :         c->internal->posix_emu.statvfs_fn = fn;
     840         106 : }
     841             : 
     842             : smbc_fstatvfs_fn
     843           0 : smbc_getFunctionFstatVFS(SMBCCTX *c)
     844             : {
     845           0 :         return c->internal->posix_emu.fstatvfs_fn;
     846             : }
     847             : 
     848             : void
     849         106 : smbc_setFunctionFstatVFS(SMBCCTX *c, smbc_fstatvfs_fn fn)
     850             : {
     851         106 :         c->internal->posix_emu.fstatvfs_fn = fn;
     852         106 : }
     853             : 
     854             : smbc_ftruncate_fn
     855           0 : smbc_getFunctionFtruncate(SMBCCTX *c)
     856             : {
     857           0 :         return c->internal->posix_emu.ftruncate_fn;
     858             : }
     859             : 
     860             : void
     861         106 : smbc_setFunctionFtruncate(SMBCCTX *c, smbc_ftruncate_fn fn)
     862             : {
     863         106 :         c->internal->posix_emu.ftruncate_fn = fn;
     864         106 : }
     865             : 
     866             : smbc_close_fn
     867         486 : smbc_getFunctionClose(SMBCCTX *c)
     868             : {
     869         486 :         return c->close_fn;
     870             : }
     871             : 
     872             : void
     873         106 : smbc_setFunctionClose(SMBCCTX *c, smbc_close_fn fn)
     874             : {
     875         106 :         c->close_fn = fn;
     876         106 : }
     877             : 
     878             : 
     879             : /**
     880             :  * Callable functions for directories.
     881             :  */
     882             : 
     883             : smbc_opendir_fn
     884         120 : smbc_getFunctionOpendir(SMBCCTX *c)
     885             : {
     886         120 :         return c->opendir;
     887             : }
     888             : 
     889             : void
     890         106 : smbc_setFunctionOpendir(SMBCCTX *c, smbc_opendir_fn fn)
     891             : {
     892         106 :         c->opendir = fn;
     893         106 : }
     894             : 
     895             : smbc_closedir_fn
     896          58 : smbc_getFunctionClosedir(SMBCCTX *c)
     897             : {
     898          58 :         return c->closedir;
     899             : }
     900             : 
     901             : void
     902         106 : smbc_setFunctionClosedir(SMBCCTX *c, smbc_closedir_fn fn)
     903             : {
     904         106 :         c->closedir = fn;
     905         106 : }
     906             : 
     907             : smbc_readdir_fn
     908        1154 : smbc_getFunctionReaddir(SMBCCTX *c)
     909             : {
     910        1154 :         return c->readdir;
     911             : }
     912             : 
     913             : void
     914         106 : smbc_setFunctionReaddir(SMBCCTX *c, smbc_readdir_fn fn)
     915             : {
     916         106 :         c->readdir = fn;
     917         106 : }
     918             : 
     919         743 : smbc_readdirplus_fn smbc_getFunctionReaddirPlus(SMBCCTX *c)
     920             : {
     921         743 :         return c->readdirplus;
     922             : }
     923             : 
     924         106 : void smbc_setFunctionReaddirPlus(SMBCCTX *c, smbc_readdirplus_fn fn)
     925             : {
     926         106 :         c->readdirplus = fn;
     927         106 : }
     928             : 
     929         131 : smbc_readdirplus2_fn smbc_getFunctionReaddirPlus2(SMBCCTX *c)
     930             : {
     931         131 :         return c->readdirplus2;
     932             : }
     933             : 
     934         106 : void smbc_setFunctionReaddirPlus2(SMBCCTX *c, smbc_readdirplus2_fn fn)
     935             : {
     936         106 :         c->readdirplus2 = fn;
     937         106 : }
     938             : 
     939             : smbc_getdents_fn
     940           8 : smbc_getFunctionGetdents(SMBCCTX *c)
     941             : {
     942           8 :         return c->getdents;
     943             : }
     944             : 
     945             : void
     946         106 : smbc_setFunctionGetdents(SMBCCTX *c, smbc_getdents_fn fn)
     947             : {
     948         106 :         c->getdents = fn;
     949         106 : }
     950             : 
     951             : smbc_mkdir_fn
     952           4 : smbc_getFunctionMkdir(SMBCCTX *c)
     953             : {
     954           4 :         return c->mkdir;
     955             : }
     956             : 
     957             : void
     958         106 : smbc_setFunctionMkdir(SMBCCTX *c, smbc_mkdir_fn fn)
     959             : {
     960         106 :         c->mkdir = fn;
     961         106 : }
     962             : 
     963             : smbc_rmdir_fn
     964           8 : smbc_getFunctionRmdir(SMBCCTX *c)
     965             : {
     966           8 :         return c->rmdir;
     967             : }
     968             : 
     969             : void
     970         106 : smbc_setFunctionRmdir(SMBCCTX *c, smbc_rmdir_fn fn)
     971             : {
     972         106 :         c->rmdir = fn;
     973         106 : }
     974             : 
     975             : smbc_telldir_fn
     976           8 : smbc_getFunctionTelldir(SMBCCTX *c)
     977             : {
     978           8 :         return c->telldir;
     979             : }
     980             : 
     981             : void
     982         106 : smbc_setFunctionTelldir(SMBCCTX *c, smbc_telldir_fn fn)
     983             : {
     984         106 :         c->telldir = fn;
     985         106 : }
     986             : 
     987             : smbc_lseekdir_fn
     988          20 : smbc_getFunctionLseekdir(SMBCCTX *c)
     989             : {
     990          20 :         return c->lseekdir;
     991             : }
     992             : 
     993             : void
     994         106 : smbc_setFunctionLseekdir(SMBCCTX *c, smbc_lseekdir_fn fn)
     995             : {
     996         106 :         c->lseekdir = fn;
     997         106 : }
     998             : 
     999             : smbc_fstatdir_fn
    1000           0 : smbc_getFunctionFstatdir(SMBCCTX *c)
    1001             : {
    1002           0 :         return c->fstatdir;
    1003             : }
    1004             : 
    1005             : void
    1006         106 : smbc_setFunctionFstatdir(SMBCCTX *c, smbc_fstatdir_fn fn)
    1007             : {
    1008         106 :         c->fstatdir = fn;
    1009         106 : }
    1010             : 
    1011             : smbc_notify_fn
    1012           0 : smbc_getFunctionNotify(SMBCCTX *c)
    1013             : {
    1014           0 :         return c->internal->smb.notify_fn;
    1015             : }
    1016             : 
    1017             : void
    1018         106 : smbc_setFunctionNotify(SMBCCTX *c, smbc_notify_fn fn)
    1019             : {
    1020         106 :         c->internal->smb.notify_fn = fn;
    1021         106 : }
    1022             : 
    1023             : 
    1024             : /**
    1025             :  * Callable functions applicable to both files and directories.
    1026             :  */
    1027             : 
    1028             : smbc_chmod_fn
    1029           0 : smbc_getFunctionChmod(SMBCCTX *c)
    1030             : {
    1031           0 :         return c->chmod;
    1032             : }
    1033             : 
    1034             : void
    1035         106 : smbc_setFunctionChmod(SMBCCTX *c, smbc_chmod_fn fn)
    1036             : {
    1037         106 :         c->chmod = fn;
    1038         106 : }
    1039             : 
    1040             : smbc_utimes_fn
    1041           4 : smbc_getFunctionUtimes(SMBCCTX *c)
    1042             : {
    1043           4 :         return c->utimes;
    1044             : }
    1045             : 
    1046             : void
    1047         106 : smbc_setFunctionUtimes(SMBCCTX *c, smbc_utimes_fn fn)
    1048             : {
    1049         106 :         c->utimes = fn;
    1050         106 : }
    1051             : 
    1052             : smbc_setxattr_fn
    1053           0 : smbc_getFunctionSetxattr(SMBCCTX *c)
    1054             : {
    1055           0 :         return c->setxattr;
    1056             : }
    1057             : 
    1058             : void
    1059         106 : smbc_setFunctionSetxattr(SMBCCTX *c, smbc_setxattr_fn fn)
    1060             : {
    1061         106 :         c->setxattr = fn;
    1062         106 : }
    1063             : 
    1064             : smbc_getxattr_fn
    1065          12 : smbc_getFunctionGetxattr(SMBCCTX *c)
    1066             : {
    1067          12 :         return c->getxattr;
    1068             : }
    1069             : 
    1070             : void
    1071         106 : smbc_setFunctionGetxattr(SMBCCTX *c, smbc_getxattr_fn fn)
    1072             : {
    1073         106 :         c->getxattr = fn;
    1074         106 : }
    1075             : 
    1076             : smbc_removexattr_fn
    1077           0 : smbc_getFunctionRemovexattr(SMBCCTX *c)
    1078             : {
    1079           0 :         return c->removexattr;
    1080             : }
    1081             : 
    1082             : void
    1083         106 : smbc_setFunctionRemovexattr(SMBCCTX *c, smbc_removexattr_fn fn)
    1084             : {
    1085         106 :         c->removexattr = fn;
    1086         106 : }
    1087             : 
    1088             : smbc_listxattr_fn
    1089           0 : smbc_getFunctionListxattr(SMBCCTX *c)
    1090             : {
    1091           0 :         return c->listxattr;
    1092             : }
    1093             : 
    1094             : void
    1095         106 : smbc_setFunctionListxattr(SMBCCTX *c, smbc_listxattr_fn fn)
    1096             : {
    1097         106 :         c->listxattr = fn;
    1098         106 : }
    1099             : 
    1100             : 
    1101             : /**
    1102             :  * Callable functions related to printing
    1103             :  */
    1104             : 
    1105             : smbc_print_file_fn
    1106           0 : smbc_getFunctionPrintFile(SMBCCTX *c)
    1107             : {
    1108           0 :         return c->print_file;
    1109             : }
    1110             : 
    1111             : void
    1112         106 : smbc_setFunctionPrintFile(SMBCCTX *c, smbc_print_file_fn fn)
    1113             : {
    1114         106 :         c->print_file = fn;
    1115         106 : }
    1116             : 
    1117             : smbc_open_print_job_fn
    1118           0 : smbc_getFunctionOpenPrintJob(SMBCCTX *c)
    1119             : {
    1120           0 :         return c->open_print_job;
    1121             : }
    1122             : 
    1123             : void
    1124         106 : smbc_setFunctionOpenPrintJob(SMBCCTX *c,
    1125             :                              smbc_open_print_job_fn fn)
    1126             : {
    1127         106 :         c->open_print_job = fn;
    1128         106 : }
    1129             : 
    1130             : smbc_list_print_jobs_fn
    1131           0 : smbc_getFunctionListPrintJobs(SMBCCTX *c)
    1132             : {
    1133           0 :         return c->list_print_jobs;
    1134             : }
    1135             : 
    1136             : void
    1137         106 : smbc_setFunctionListPrintJobs(SMBCCTX *c,
    1138             :                               smbc_list_print_jobs_fn fn)
    1139             : {
    1140         106 :         c->list_print_jobs = fn;
    1141         106 : }
    1142             : 
    1143             : smbc_unlink_print_job_fn
    1144           0 : smbc_getFunctionUnlinkPrintJob(SMBCCTX *c)
    1145             : {
    1146           0 :         return c->unlink_print_job;
    1147             : }
    1148             : 
    1149             : void
    1150         106 : smbc_setFunctionUnlinkPrintJob(SMBCCTX *c,
    1151             :                                smbc_unlink_print_job_fn fn)
    1152             : {
    1153         106 :         c->unlink_print_job = fn;
    1154         106 : }
    1155             : 

Generated by: LCOV version 1.14