Commit f2aff08b authored by deuce's avatar deuce
Browse files

64-bit

The CRC headers now include gen_defs.h
parent 238c48dd
......@@ -38,7 +38,7 @@
#include <string.h> /* strlen */
#include "crc16.h"
unsigned short crc16tbl[] = {
uint16_t crc16tbl[] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
......@@ -73,10 +73,10 @@ unsigned short crc16tbl[] = {
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
unsigned short crc16(char* data, unsigned long len)
uint16_t crc16(char* data, unsigned long len)
{
unsigned short crc = 0;
unsigned long l;
uint16_t crc = 0;
uint32_t l;
if(len==0 && data!=NULL)
len=strlen(data);
......
......@@ -38,13 +38,15 @@
#ifndef _CRC16_H_
#define _CRC16_H_
#include "gen_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern unsigned short crc16tbl[];
extern uint16_t crc16tbl[];
unsigned short crc16(char *data, unsigned long len);
uint16_t crc16(char *data, uint32_t len);
#ifdef __cplusplus
}
......
......@@ -38,7 +38,7 @@
#include <string.h> /* strlen */
#include "crc32.h"
long crc32tbl[]={ /* CRC polynomial 0xedb88320 */
int32_t crc32tbl[]={ /* CRC polynomial 0xedb88320 */
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
......@@ -78,9 +78,9 @@ long crc32tbl[]={ /* CRC polynomial 0xedb88320 */
/* Pass len of 0 to auto-determine ASCIIZ string length */
/* or non-zero for arbitrary binary data */
/****************************************************************************/
unsigned long crc32i(unsigned long crc, char *buf, unsigned long len)
uint32_t crc32i(uint32_t crc, char *buf, uint32_t len)
{
unsigned long l;
uint32_t l;
if(len==0 && buf!=NULL)
len=strlen(buf);
......@@ -89,10 +89,10 @@ unsigned long crc32i(unsigned long crc, char *buf, unsigned long len)
return(~crc);
}
unsigned long fcrc32(FILE* fp, unsigned long len)
uint32_t fcrc32(FILE* fp, uint32_t len)
{
int ch;
unsigned long l,crc=0xffffffff;
uint32_t l,crc=0xffffffff;
rewind(fp);
for(l=0;(len==0 || l<len) && !feof(fp);l++) {
......
......@@ -39,15 +39,16 @@
#define _CRC32_H_
#include <stdio.h> /* FILE */
#include "gen_defs.h" /* uint32_t */
#ifdef __cplusplus
extern "C" {
#endif
extern long crc32tbl[];
extern int32_t crc32tbl[];
unsigned long crc32i(unsigned long crc, char* buf, unsigned long len);
unsigned long fcrc32(FILE* fp, unsigned long len);
uint32_t crc32i(uint32_t crc, char* buf, uint32_t len);
uint32_t fcrc32(FILE* fp, uint32_t len);
#ifdef __cplusplus
}
......
......@@ -55,7 +55,7 @@ int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hash
size_t bodylen=0;
size_t chklen=0;
long offset;
ulong crc=0xffffffff;
uint32_t crc=0xffffffff;
hash_t found;
hash_t** hashes=NULL; /* This is a NULL-terminated list of hashes */
smbmsg_t remsg;
......
......@@ -47,9 +47,9 @@
/* smb_close_da() should be called after */
/* Returns negative on error */
/****************************************************************************/
long SMBCALL smb_allocdat(smb_t* smb, ulong length, ushort refs)
long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t refs)
{
ushort i;
uint16_t i;
ulong j,l,blocks,offset=0L;
if(smb->sda_fp==NULL) {
......@@ -95,7 +95,7 @@ long SMBCALL smb_allocdat(smb_t* smb, ulong length, ushort refs)
/* Allocates space for data, but doesn't search for unused blocks */
/* Returns negative on error */
/****************************************************************************/
long SMBCALL smb_fallocdat(smb_t* smb, ulong length, ushort refs)
long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs)
{
ulong l,blocks,offset;
......@@ -132,11 +132,11 @@ long SMBCALL smb_fallocdat(smb_t* smb, ulong length, ushort refs)
/* De-allocates space for data */
/* Returns non-zero on error */
/****************************************************************************/
int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, ushort refs)
int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs)
{
BOOL da_opened=FALSE;
int retval=SMB_SUCCESS;
ushort i;
uint16_t i;
ulong l,blocks;
ulong sda_offset;
......@@ -200,9 +200,9 @@ int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, ushort refs)
/* Adds to data allocation records for blocks starting at 'offset' */
/* Returns non-zero on error */
/****************************************************************************/
int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, ushort refs)
int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, uint16_t refs)
{
ushort i;
uint16_t i;
ulong l,blocks;
if(smb->sda_fp==NULL) {
......@@ -242,7 +242,7 @@ int SMBCALL smb_incdat(smb_t* smb, ulong offset, ulong length, ushort refs)
/* header references specified (usually 1) */
/* The opposite function of smb_freemsg() */
/****************************************************************************/
int SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs)
int SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs)
{
int i=SMB_SUCCESS;
BOOL da_opened=FALSE;
......@@ -297,7 +297,7 @@ int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length)
/****************************************************************************/
/****************************************************************************/
int SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs)
int SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs)
{
int i;
ushort x;
......
......@@ -331,10 +331,10 @@ int SMBCALL smb_getmsghdr_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
return(retval);
}
ushort SMBCALL smb_subject_crc(const char* subj)
uint16_t SMBCALL smb_subject_crc(const char* subj)
{
char* str;
ushort crc;
uint16_t crc;
if(subj==NULL)
return(0xffff);
......@@ -355,10 +355,10 @@ ushort SMBCALL smb_subject_crc(const char* subj)
return(crc);
}
ushort SMBCALL smb_name_crc(const char* name)
uint16_t SMBCALL smb_name_crc(const char* name)
{
char* str;
ushort crc;
uint16_t crc;
if(name==NULL)
return(0xffff);
......
......@@ -1268,7 +1268,7 @@ int SMBCALL smb_dfield(smbmsg_t* msg, ushort type, ulong length)
/* Checks CRC history file for duplicate crc. If found, returns 1. */
/* If no dupe, adds to CRC history and returns 0, or negative if error. */
/****************************************************************************/
int SMBCALL smb_addcrc(smb_t* smb, ulong crc)
int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
{
char str[MAX_PATH+1];
int file;
......
......@@ -122,7 +122,7 @@ SMBEXPORT ulong SMBCALL smb_getmsgtxtlen(smbmsg_t* msg);
SMBEXPORT int SMBCALL smb_lockmsghdr(smb_t* smb, smbmsg_t* msg);
SMBEXPORT int SMBCALL smb_getmsghdr(smb_t* smb, smbmsg_t* msg);
SMBEXPORT int SMBCALL smb_unlockmsghdr(smb_t* smb, smbmsg_t* msg);
SMBEXPORT int SMBCALL smb_addcrc(smb_t* smb, ulong crc);
SMBEXPORT int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc);
SMBEXPORT int SMBCALL smb_hfield(smbmsg_t* msg, ushort type, size_t length, void* data);
SMBEXPORT int SMBCALL smb_hfield_str(smbmsg_t* msg, ushort type, const char* str);
......@@ -151,20 +151,20 @@ SMBEXPORT int SMBCALL smb_init_idx(smb_t* smb, smbmsg_t* msg);
/* smbadd.c */
SMBEXPORT int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes
,ushort xlat, const uchar* body, const uchar* tail);
,uint16_t xlat, const uchar* body, const uchar* tail);
/* smballoc.c */
SMBEXPORT long SMBCALL smb_allochdr(smb_t* smb, ulong length);
SMBEXPORT long SMBCALL smb_fallochdr(smb_t* smb, ulong length);
SMBEXPORT long SMBCALL smb_hallochdr(smb_t* smb);
SMBEXPORT long SMBCALL smb_allocdat(smb_t* smb, ulong length, ushort refs);
SMBEXPORT long SMBCALL smb_fallocdat(smb_t* smb, ulong length, ushort refs);
SMBEXPORT long SMBCALL smb_allocdat(smb_t* smb, ulong length, uint16_t int16_trefs);
SMBEXPORT long SMBCALL smb_fallocdat(smb_t* smb, ulong length, uint16_t refs);
SMBEXPORT long SMBCALL smb_hallocdat(smb_t* smb);
SMBEXPORT int SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs);
SMBEXPORT int SMBCALL smb_incmsgdat(smb_t* smb, ulong offset, ulong length, ushort refs);
SMBEXPORT int SMBCALL smb_incmsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs);
SMBEXPORT int SMBCALL smb_incmsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs);
SMBEXPORT int SMBCALL smb_freemsg(smb_t* smb, smbmsg_t* msg);
SMBEXPORT int SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, ushort refs);
SMBEXPORT int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, ushort refs);
SMBEXPORT int SMBCALL smb_freemsg_dfields(smb_t* smb, smbmsg_t* msg, uint16_t refs);
SMBEXPORT int SMBCALL smb_freemsgdat(smb_t* smb, ulong offset, ulong length, uint16_t refs);
SMBEXPORT int SMBCALL smb_freemsghdr(smb_t* smb, ulong offset, ulong length);
SMBEXPORT void SMBCALL smb_freemsgtxt(char* buf);
......@@ -179,8 +179,8 @@ SMBEXPORT hash_t* SMBCALL smb_hashstr(ulong msgnum, ulong time, unsigned source
SMBEXPORT hash_t** SMBCALL smb_msghashes(smbmsg_t* msg, const uchar* text);
SMBEXPORT int SMBCALL smb_addhashes(smb_t* smb, hash_t** hash_list, BOOL skip_marked);
SMBEXPORT ushort SMBCALL smb_name_crc(const char* name);
SMBEXPORT ushort SMBCALL smb_subject_crc(const char *subj);
SMBEXPORT uint16_t SMBCALL smb_name_crc(const char* name);
SMBEXPORT uint16_t SMBCALL smb_subject_crc(const char *subj);
/* Fast look-up functions (using hashes) */
SMBEXPORT int SMBCALL smb_getmsgidx_by_hash(smb_t* smb, smbmsg_t* msg, unsigned source
......
......@@ -48,7 +48,7 @@ char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode)
char* lzhbuf;
char* p;
char* str;
ushort xlat;
uint16_t xlat;
uint i;
int lzh; /* BOOL */
long l=0,lzhlen,length;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment