2003-07-29 15:48:06 +00:00
|
|
|
/*
|
2005-01-15 17:36:25 +00:00
|
|
|
* Copyright (C) 1999 - 2005 Tomasz Kojm <tkojm@clamav.net>
|
2003-07-29 15:48:06 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2004-07-19 17:54:40 +00:00
|
|
|
#ifndef __OTHERS_H_LC
|
|
|
|
#define __OTHERS_H_LC
|
2003-07-29 15:48:06 +00:00
|
|
|
|
2003-10-08 12:51:07 +00:00
|
|
|
#include <stdio.h>
|
2003-07-29 15:48:06 +00:00
|
|
|
#include <stdlib.h>
|
2004-07-09 02:23:11 +00:00
|
|
|
#include "cltypes.h"
|
2003-07-29 15:48:06 +00:00
|
|
|
|
2006-01-09 18:49:41 +00:00
|
|
|
#define CLI_ISCONTAINED(bb, bb_size, sb, sb_size) \
|
|
|
|
(bb_size > 0 && sb_size > 0 && sb_size <= bb_size \
|
|
|
|
&& sb >= bb && sb + sb_size <= bb + bb_size && sb + sb_size > bb)
|
|
|
|
|
2006-01-14 18:57:41 +00:00
|
|
|
#define CLI_ISCONTAINED2(bb, bb_size, sb, sb_size) \
|
|
|
|
(bb_size > 0 && sb_size >= 0 && sb_size <= bb_size \
|
2006-01-16 14:11:13 +00:00
|
|
|
&& sb >= bb && sb + sb_size <= bb + bb_size && sb + sb_size >= bb)
|
2006-01-14 18:57:41 +00:00
|
|
|
|
2005-10-18 10:32:06 +00:00
|
|
|
typedef struct bitset_tag
|
|
|
|
{
|
|
|
|
unsigned char *bitset;
|
|
|
|
unsigned long length;
|
|
|
|
} bitset_t;
|
|
|
|
|
2003-07-29 15:48:06 +00:00
|
|
|
void cli_warnmsg(const char *str, ...);
|
|
|
|
void cli_errmsg(const char *str, ...);
|
|
|
|
void cli_dbgmsg(const char *str, ...);
|
|
|
|
void *cli_malloc(size_t nmemb);
|
|
|
|
void *cli_calloc(size_t nmemb, size_t size);
|
2003-09-29 11:44:52 +00:00
|
|
|
void *cli_realloc(void *ptr, size_t size);
|
2003-07-29 15:48:06 +00:00
|
|
|
int cli_rmdirs(const char *dirname);
|
2005-03-06 23:40:57 +00:00
|
|
|
unsigned char *cli_md5digest(int desc);
|
2004-09-01 14:14:21 +00:00
|
|
|
char *cli_md5stream(FILE *fs, unsigned char *digcpy);
|
|
|
|
char *cli_md5file(const char *filename);
|
2004-03-26 09:37:09 +00:00
|
|
|
int cli_readn(int fd, void *buff, unsigned int count);
|
2005-08-02 02:07:46 +00:00
|
|
|
int cli_writen(int fd, const void *buff, unsigned int count);
|
2004-07-09 02:23:11 +00:00
|
|
|
int32_t cli_readint32(const char *buff);
|
2005-01-08 01:29:48 +00:00
|
|
|
void cli_writeint32(char *offset, uint32_t value);
|
2004-07-19 17:54:40 +00:00
|
|
|
char *cli_gentemp(const char *dir);
|
2005-05-21 00:39:13 +00:00
|
|
|
char *cli_gentempdir(const char *dir);
|
|
|
|
char *cli_gentempdesc(const char *dir, int *fd);
|
|
|
|
char *cli_gentempstream(const char *dir, FILE **fs);
|
2004-07-19 17:54:40 +00:00
|
|
|
unsigned int cli_rndnum(unsigned int max);
|
2004-12-20 02:04:58 +00:00
|
|
|
int cli_filecopy(const char *src, const char *dest);
|
2005-12-10 18:50:26 +00:00
|
|
|
bitset_t *cli_bitset_init(void);
|
2005-10-18 10:32:06 +00:00
|
|
|
void cli_bitset_free(bitset_t *bs);
|
|
|
|
int cli_bitset_set(bitset_t *bs, unsigned long bit_offset);
|
|
|
|
int cli_bitset_test(bitset_t *bs, unsigned long bit_offset);
|
2003-07-29 15:48:06 +00:00
|
|
|
#endif
|