e3aaff8e |
/*
* Copyright (C) 2002 Nigel Horne <njh@bandsman.co.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software |
48b7b4a7 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA. |
e3aaff8e |
*/
|
0e5a0129 |
#ifndef __BLOB_H
#define __BLOB_H
/*
* Resizable chunk of memory
*/ |
e3aaff8e |
typedef struct blob {
char *name; /* filename */
unsigned char *data; /* the stuff itself */ |
b02bab2b |
off_t len; /* number of bytes of data so far */
off_t size; /* number of bytes allocated to data so far */ |
8ef734d4 |
int isClosed; |
e3aaff8e |
#ifdef CL_DEBUG
object_type magic; /* verify that this is a blob */
#endif
} blob;
blob *blobCreate(void);
void blobDestroy(blob *b);
void blobArrayDestroy(blob *b[], int n); |
78e302e1 |
void blobSetFilename(blob *b, const char *dir, const char *filename); |
d73494ef |
int blobAddData(blob *b, const unsigned char *data, size_t len); |
2a4b5c6e |
unsigned char *blobGetData(const blob *b); |
bc6bbeff |
size_t blobGetDataSize(const blob *b); |
8ef734d4 |
void blobClose(blob *b);
int blobcmp(const blob *b1, const blob *b2); |
826864d6 |
int blobGrow(blob *b, size_t len); |
0e5a0129 |
/*
* Like a blob, but associated with a file
*/
typedef struct fileblob {
FILE *fp;
blob b; |
1be8b51f |
unsigned int isNotEmpty : 1;
unsigned int isInfected : 1; |
12751467 |
unsigned long bytes_scanned; |
a603478f |
cli_ctx *ctx; |
0e5a0129 |
} fileblob;
fileblob *fileblobCreate(void);
void fileblobDestroy(fileblob *fb);
void fileblobSetFilename(fileblob *fb, const char *dir, const char *filename);
const char *fileblobGetFilename(const fileblob *fb); |
a603478f |
void fileblobSetCTX(fileblob *fb, cli_ctx *ctx); |
d73494ef |
int fileblobAddData(fileblob *fb, const unsigned char *data, size_t len); |
a603478f |
int fileblobContainsVirus(const fileblob *fb); |
11b50569 |
void sanitiseName(char *name); |
0e5a0129 |
#endif /*_BLOB_H*/ |