s3: smbd: Sanitize any "server" and "share" components of SMB1 DFS paths to remove...
[Samba.git] / lib / util / util.h
blob59d24a8babf394a22565723b54920b74d88b1aed
1 /*
2 Unix SMB/CIFS implementation.
3 Utility functions for Samba
4 Copyright (C) Andrew Tridgell 1992-1999
5 Copyright (C) Jelmer Vernooij 2005
6 Copyright (C) Swen Schillig 2019
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef __UTIL_SAMBA_UTIL_H__
23 #define __UTIL_SAMBA_UTIL_H__
25 /**
26 * Write dump of binary data to a callback
28 void dump_data_cb(const uint8_t *buf, int len,
29 bool omit_zero_bytes,
30 void (*cb)(const char *buf, void *private_data),
31 void *private_data);
33 /**
34 * Write dump of binary data to a FILE
36 void dump_data_file(const uint8_t *buf, int len, bool omit_zero_bytes,
37 FILE *f);
39 /**
40 * Write dump of binary data to the log file.
42 * The data is only written if the log level is at least level.
44 _PUBLIC_ void dump_data(int level, const uint8_t *buf,int len);
46 /**
47 * Write dump of binary data to the log file.
49 * The data is only written if the log level is at least level for
50 * debug class dbgc_class.
52 _PUBLIC_ void dump_data_dbgc(int dbgc_class, int level, const uint8_t *buf, int len);
54 /**
55 * Write dump of compared binary data to a callback
57 void dump_data_diff_cb(const uint8_t *buf1, size_t len1,
58 const uint8_t *buf2, size_t len2,
59 bool omit_zero_bytes,
60 void (*cb)(const char *buf, void *private_data),
61 void *private_data);
63 /**
64 * Write dump of compared binary data to the log file.
66 * The data is only written if the log level is at least level for
67 * debug class dbgc_class.
69 _PUBLIC_ void dump_data_diff(int dbgc_class, int level,
70 bool omit_zero_bytes,
71 const uint8_t *buf1, size_t len1,
72 const uint8_t *buf2, size_t len2);
74 /**
75 * Write dump of compared binary data to the given file handle
77 _PUBLIC_ void dump_data_file_diff(FILE *f,
78 bool omit_zero_bytes,
79 const uint8_t *buf1, size_t len1,
80 const uint8_t *buf2, size_t len2);
82 /**
83 * Write a password to the log file.
85 * @note Only actually does something if DEBUG_PASSWORD was defined during
86 * compile-time.
88 _PUBLIC_ void dump_data_pw(const char *msg, const uint8_t * data, size_t len);
90 /**
91 * Dump data to "str" via talloc_asprintf_addbuf()
93 _PUBLIC_ void dump_data_addbuf(const uint8_t *buf, size_t buflen, char **str);
94 #endif