mount.cifs: fix max buffer size when parsing snapshot option
[cifs-utils.git] / data_blob.h
1 /* 
2    Unix SMB/CIFS implementation.
3    DATA BLOB
4    
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9    
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14    
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /* This is a public header file that is installed as part of Samba. 
20  * If you remove any functions or change their signature, update 
21  * the so version number. */
22
23 #ifndef _SAMBA_DATABLOB_H_
24 #define _SAMBA_DATABLOB_H_
25
26 #include <talloc.h>
27 #include <stdint.h>
28
29 /* used to hold an arbitrary blob of data */
30 typedef struct datablob {
31         uint8_t *data;
32         size_t length;
33 } DATA_BLOB;
34
35 struct data_blob_list_item {
36         struct data_blob_list_item *prev,*next;
37         DATA_BLOB blob;
38 };
39
40 /* by making struct ldb_val and DATA_BLOB the same, we can simplify
41    a fair bit of code */
42 #define ldb_val datablob
43
44 #define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__)
45 #define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__)
46 #define data_blob_dup_talloc(ctx, blob) data_blob_talloc_named(ctx, (blob)->data, (blob)->length, "DATA_BLOB: "__location__)
47
48 /**
49  construct a data blob, must be freed with data_blob_free()
50  you can pass NULL for p and get a blank data blob
51 **/
52 DATA_BLOB data_blob_named(const void *p, size_t length, const char *name);
53
54 /**
55  construct a data blob, using supplied TALLOC_CTX
56 **/
57 DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name);
58
59 /**
60 free a data blob
61 **/
62 void data_blob_free(DATA_BLOB *d);
63
64 extern const DATA_BLOB data_blob_null;
65
66 #endif /* _SAMBA_DATABLOB_H_ */