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