Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

blob.h

Go to the documentation of this file.
00001 /*
00002  * blob.h
00003  *
00004  * Binary blob handling.
00005  *
00006  * Copyright (c) 2002 Dug Song <dugsong@monkey.org>
00007  *
00008  * $Id: blob.h,v 1.2 2002/04/05 03:06:44 dugsong Exp $
00009  */
00010 
00011 #ifndef DNET_BLOB_H
00012 #define DNET_BLOB_H
00013 
00014 typedef struct blob {
00015         u_char          *base;          /* start of data */
00016         int              off;           /* offset into data */
00017         int              end;           /* end of data */
00018         int              size;          /* size of allocation */
00019 } blob_t;
00020 
00021 __BEGIN_DECLS
00022 blob_t  *blob_new(void);
00023 
00024 int      blob_read(blob_t *b, void *buf, int len);
00025 int      blob_write(blob_t *b, const void *buf, int len);
00026 
00027 int      blob_seek(blob_t *b, int off, int whence);
00028 #define  blob_skip(b, l)        blob_seek(b, l, SEEK_CUR)
00029 #define  blob_rewind(b)         blob_seek(b, 0, SEEK_SET)
00030 
00031 #define  blob_offset(b)         ((b)->off)
00032 #define  blob_left(b)           ((b)->end - (b)->off)
00033 
00034 int      blob_index(blob_t *b, const void *buf, int len);
00035 int      blob_rindex(blob_t *b, const void *buf, int len);
00036 
00037 int      blob_pack(blob_t *b, const char *fmt, ...);
00038 int      blob_unpack(blob_t *b, const char *fmt, ...);
00039 
00040 int      blob_insert(blob_t *b, const void *buf, int len);
00041 int      blob_delete(blob_t *b, void *buf, int len);
00042 
00043 int      blob_print(blob_t *b, char *style, int len);
00044 
00045 blob_t  *blob_free(blob_t *b);
00046 
00047 int      blob_register_alloc(size_t size, void *(*bmalloc)(size_t),
00048             void (*bfree)(void *), void *(*brealloc)(void *, size_t));
00049 #ifdef va_start
00050 typedef int (*blob_fmt_cb)(int pack, int len, blob_t *b, va_list *arg);
00051 
00052 int      blob_register_pack(char c, blob_fmt_cb fmt_cb);
00053 #endif
00054 __END_DECLS
00055 
00056 #endif /* DNET_BLOB_H */

Generated on Sun May 14 14:51:10 2006 by  doxygen 1.4.2