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