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