Blame data_blob.h

Packit Service 09cdfc
/* 
Packit Service 09cdfc
   Unix SMB/CIFS implementation.
Packit Service 09cdfc
   DATA BLOB
Packit Service 09cdfc
   
Packit Service 09cdfc
   This program is free software; you can redistribute it and/or modify
Packit Service 09cdfc
   it under the terms of the GNU General Public License as published by
Packit Service 09cdfc
   the Free Software Foundation; either version 3 of the License, or
Packit Service 09cdfc
   (at your option) any later version.
Packit Service 09cdfc
   
Packit Service 09cdfc
   This program is distributed in the hope that it will be useful,
Packit Service 09cdfc
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 09cdfc
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 09cdfc
   GNU General Public License for more details.
Packit Service 09cdfc
   
Packit Service 09cdfc
   You should have received a copy of the GNU General Public License
Packit Service 09cdfc
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 09cdfc
*/
Packit Service 09cdfc
Packit Service 09cdfc
/* This is a public header file that is installed as part of Samba. 
Packit Service 09cdfc
 * If you remove any functions or change their signature, update 
Packit Service 09cdfc
 * the so version number. */
Packit Service 09cdfc
Packit Service 09cdfc
#ifndef _SAMBA_DATABLOB_H_
Packit Service 09cdfc
#define _SAMBA_DATABLOB_H_
Packit Service 09cdfc
Packit Service 09cdfc
#include <talloc.h>
Packit Service 09cdfc
#include <stdint.h>
Packit Service 09cdfc
Packit Service 09cdfc
/* used to hold an arbitrary blob of data */
Packit Service 09cdfc
typedef struct datablob {
Packit Service 09cdfc
	uint8_t *data;
Packit Service 09cdfc
	size_t length;
Packit Service 09cdfc
} DATA_BLOB;
Packit Service 09cdfc
Packit Service 09cdfc
struct data_blob_list_item {
Packit Service 09cdfc
	struct data_blob_list_item *prev,*next;
Packit Service 09cdfc
	DATA_BLOB blob;
Packit Service 09cdfc
};
Packit Service 09cdfc
Packit Service 09cdfc
/* by making struct ldb_val and DATA_BLOB the same, we can simplify
Packit Service 09cdfc
   a fair bit of code */
Packit Service 09cdfc
#define ldb_val datablob
Packit Service 09cdfc
Packit Service 09cdfc
#define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__)
Packit Service 09cdfc
#define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__)
Packit Service 09cdfc
#define data_blob_dup_talloc(ctx, blob) data_blob_talloc_named(ctx, (blob)->data, (blob)->length, "DATA_BLOB: "__location__)
Packit Service 09cdfc
Packit Service 09cdfc
/**
Packit Service 09cdfc
 construct a data blob, must be freed with data_blob_free()
Packit Service 09cdfc
 you can pass NULL for p and get a blank data blob
Packit Service 09cdfc
**/
Packit Service 09cdfc
DATA_BLOB data_blob_named(const void *p, size_t length, const char *name);
Packit Service 09cdfc
Packit Service 09cdfc
/**
Packit Service 09cdfc
 construct a data blob, using supplied TALLOC_CTX
Packit Service 09cdfc
**/
Packit Service 09cdfc
DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name);
Packit Service 09cdfc
Packit Service 09cdfc
/**
Packit Service 09cdfc
free a data blob
Packit Service 09cdfc
**/
Packit Service 09cdfc
void data_blob_free(DATA_BLOB *d);
Packit Service 09cdfc
Packit Service 09cdfc
extern const DATA_BLOB data_blob_null;
Packit Service 09cdfc
Packit Service 09cdfc
#endif /* _SAMBA_DATABLOB_H_ */