changed uint32_t to uint32
This commit is contained in:
parent
792ac26b94
commit
4215894073
|
@ -44,7 +44,7 @@ void cdb_free(struct cdb *cdb) {
|
|||
void cdb_findstart(struct cdb *cdb) {
|
||||
}
|
||||
|
||||
int cdb_read(struct cdb *cdb, char *buf,unsigned int len, uint32_t pos) {
|
||||
int cdb_read(struct cdb *cdb, char *buf,unsigned int len, uint32 pos) {
|
||||
/* actually we don't need pos, because the previous findnext
|
||||
postioned us correctly
|
||||
if you want to have a real read - you know what to do */
|
||||
|
@ -53,7 +53,7 @@ int cdb_read(struct cdb *cdb, char *buf,unsigned int len, uint32_t pos) {
|
|||
}
|
||||
|
||||
int cdb_findnext(struct cdb *cdb ,char *key, unsigned int len) {
|
||||
uint32_t dlen;
|
||||
uint32 dlen;
|
||||
int ret = cdb_seek(cdb->fd, key, len, &dlen);
|
||||
if (ret == 1) { /* found */
|
||||
cdb->dlen = dlen;
|
||||
|
@ -78,7 +78,7 @@ int cdb_make_start(struct cdb_make *c,int fd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline uint32_t safeadd(u,v) uint32_t u; uint32_t v;
|
||||
static inline uint32 safeadd(u,v) uint32 u; uint32 v;
|
||||
{
|
||||
u += v;
|
||||
// if (u < v) overflow(); we don't ;-)
|
||||
|
@ -90,12 +90,12 @@ static inline uint32_t safeadd(u,v) uint32_t u; uint32_t v;
|
|||
so no problem.
|
||||
*/
|
||||
int cdb_make_add(struct cdb_make *c,char *key,unsigned int keylen,char *data,unsigned int datalen) {
|
||||
uint32_t h, pos;
|
||||
uint32 h, pos;
|
||||
int i , ch;
|
||||
|
||||
pos = c->pos;
|
||||
cdbmake_pack(packbuf,(uint32_t) keylen);
|
||||
cdbmake_pack(packbuf + 4,(uint32_t) datalen);
|
||||
cdbmake_pack(packbuf,(uint32) keylen);
|
||||
cdbmake_pack(packbuf + 4,(uint32) datalen);
|
||||
if (write(c->fd,packbuf,8) != 8)
|
||||
return -1;
|
||||
h = CDBMAKE_HASHSTART;
|
||||
|
@ -112,16 +112,16 @@ int cdb_make_add(struct cdb_make *c,char *key,unsigned int keylen,char *data,uns
|
|||
}
|
||||
if (!cdbmake_add(&c->cdbm,h,pos,malloc))
|
||||
return -1;
|
||||
pos = safeadd(pos,(uint32_t) 8);
|
||||
pos = safeadd(pos,(uint32_t) keylen);
|
||||
pos = safeadd(pos,(uint32_t) datalen);
|
||||
pos = safeadd(pos,(uint32) 8);
|
||||
pos = safeadd(pos,(uint32) keylen);
|
||||
pos = safeadd(pos,(uint32) datalen);
|
||||
c->pos = pos;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cdb_make_finish(struct cdb_make *c) {
|
||||
int i, u;
|
||||
uint32_t len, pos;
|
||||
uint32 len, pos;
|
||||
|
||||
pos = c->pos;
|
||||
if (!cdbmake_split(&c->cdbm,malloc))
|
||||
|
@ -134,7 +134,7 @@ int cdb_make_finish(struct cdb_make *c) {
|
|||
cdbmake_pack(packbuf + 4,c->cdbm.hash[u].p);
|
||||
if (write(c->fd,packbuf,8) != 8)
|
||||
return -1;
|
||||
pos = safeadd(pos,(uint32_t) 8);
|
||||
pos = safeadd(pos,(uint32) 8);
|
||||
}
|
||||
}
|
||||
lseek(c->fd, 0, SEEK_SET);
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
|
||||
#include "freecdb.h"
|
||||
|
||||
typedef uint32_t uint32;
|
||||
|
||||
struct cdb {
|
||||
int fd;
|
||||
uint32_t dpos;
|
||||
uint32_t dlen;
|
||||
uint32 dpos;
|
||||
uint32 dlen;
|
||||
} ;
|
||||
|
||||
void cdb_init(struct cdb *cdb, int fd);
|
||||
void cdb_free(struct cdb *cdb);
|
||||
int cdb_read(struct cdb *cdb, char *buf,unsigned int len, uint32_t pos);
|
||||
int cdb_read(struct cdb *cdb, char *buf,unsigned int len, uint32 pos);
|
||||
void cdb_findstart(struct cdb *cdb);
|
||||
int cdb_findnext(struct cdb *cdb ,char *key, unsigned int len);
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#include "freecdb.h"
|
||||
|
||||
uint32_t cdb_hash(buf,len)
|
||||
uint32 cdb_hash(buf,len)
|
||||
unsigned char *buf;
|
||||
unsigned int len;
|
||||
{
|
||||
uint32_t h;
|
||||
uint32 h;
|
||||
|
||||
h = 5381;
|
||||
while (len) {
|
||||
--len;
|
||||
h += (h << 5);
|
||||
h ^= (uint32_t) *buf++;
|
||||
h ^= (uint32) *buf++;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
struct cdb_make{
|
||||
int fd;
|
||||
struct cdbmake cdbm;
|
||||
uint32_t pos;
|
||||
uint32 pos;
|
||||
};
|
||||
|
||||
#define cdb_datapos(c) ((c)->dpos)
|
||||
|
|
|
@ -51,15 +51,15 @@ int cdb_seek(fd,key,len,dlen)
|
|||
int fd;
|
||||
char *key;
|
||||
unsigned int len;
|
||||
uint32_t *dlen;
|
||||
uint32 *dlen;
|
||||
{
|
||||
char packbuf[8];
|
||||
uint32_t pos;
|
||||
uint32_t h;
|
||||
uint32_t lenhash;
|
||||
uint32_t h2;
|
||||
uint32_t loop;
|
||||
uint32_t poskd;
|
||||
uint32 pos;
|
||||
uint32 h;
|
||||
uint32 lenhash;
|
||||
uint32 h2;
|
||||
uint32 loop;
|
||||
uint32 poskd;
|
||||
|
||||
h = cdb_hash(key,len);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "freecdb.h"
|
||||
|
||||
uint32_t cdb_unpack(buf)
|
||||
uint32 cdb_unpack(buf)
|
||||
unsigned char *buf;
|
||||
{
|
||||
uint32_t num;
|
||||
uint32 num;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
num = buf[0]; num <<= 8;
|
||||
num += buf[1]; num <<= 8;
|
||||
|
|
|
@ -15,10 +15,10 @@ void readerror()
|
|||
|
||||
int main()
|
||||
{
|
||||
uint32_t eod;
|
||||
uint32_t pos;
|
||||
uint32_t klen;
|
||||
uint32_t dlen;
|
||||
uint32 eod;
|
||||
uint32 pos;
|
||||
uint32 klen;
|
||||
uint32 dlen;
|
||||
char buf[8];
|
||||
int i;
|
||||
int c;
|
||||
|
|
|
@ -5,7 +5,7 @@ int main(argc,argv)
|
|||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
uint32_t len;
|
||||
uint32 len;
|
||||
int c;
|
||||
|
||||
if (!argv[1]) {
|
||||
|
|
|
@ -30,7 +30,7 @@ int get()
|
|||
return c;
|
||||
}
|
||||
|
||||
uint32_t safeadd(u,v) uint32_t u; uint32_t v;
|
||||
uint32 safeadd(u,v) uint32 u; uint32 v;
|
||||
{
|
||||
u += v;
|
||||
if (u < v) overflow();
|
||||
|
@ -38,7 +38,7 @@ uint32_t safeadd(u,v) uint32_t u; uint32_t v;
|
|||
}
|
||||
|
||||
struct cdbmake cdbm;
|
||||
uint32_t pos;
|
||||
uint32 pos;
|
||||
char packbuf[8];
|
||||
|
||||
int main(argc,argv)
|
||||
|
@ -48,9 +48,9 @@ char **argv;
|
|||
char *fntemp;
|
||||
char *fn;
|
||||
FILE *fi;
|
||||
uint32_t len;
|
||||
uint32_t u;
|
||||
uint32_t h;
|
||||
uint32 len;
|
||||
uint32 u;
|
||||
uint32 h;
|
||||
int i;
|
||||
int c;
|
||||
unsigned long keylen;
|
||||
|
@ -77,8 +77,8 @@ char **argv;
|
|||
while ((c = get()) != ',') keylen = keylen * 10 + (c - '0');
|
||||
datalen = 0;
|
||||
while ((c = get()) != ':') datalen = datalen * 10 + (c - '0');
|
||||
cdbmake_pack(packbuf,(uint32_t) keylen);
|
||||
cdbmake_pack(packbuf + 4,(uint32_t) datalen);
|
||||
cdbmake_pack(packbuf,(uint32) keylen);
|
||||
cdbmake_pack(packbuf + 4,(uint32) datalen);
|
||||
|
||||
if (fwrite(packbuf,1,8,fi) < 8) writeerror();
|
||||
|
||||
|
@ -97,9 +97,9 @@ char **argv;
|
|||
if (get() != '\n') format();
|
||||
|
||||
if (!cdbmake_add(&cdbm,h,pos,malloc)) nomem();
|
||||
pos = safeadd(pos,(uint32_t) 8);
|
||||
pos = safeadd(pos,(uint32_t) keylen);
|
||||
pos = safeadd(pos,(uint32_t) datalen);
|
||||
pos = safeadd(pos,(uint32) 8);
|
||||
pos = safeadd(pos,(uint32) keylen);
|
||||
pos = safeadd(pos,(uint32) datalen);
|
||||
}
|
||||
|
||||
if (!cdbmake_split(&cdbm,malloc)) nomem();
|
||||
|
@ -110,7 +110,7 @@ char **argv;
|
|||
cdbmake_pack(packbuf,cdbm.hash[u].h);
|
||||
cdbmake_pack(packbuf + 4,cdbm.hash[u].p);
|
||||
if (fwrite(packbuf,1,8,fi) < 8) writeerror();
|
||||
pos = safeadd(pos,(uint32_t) 8);
|
||||
pos = safeadd(pos,(uint32) 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ struct cdbmake *cdbm;
|
|||
|
||||
int cdbmake_add(cdbm,h,p,alloc)
|
||||
struct cdbmake *cdbm;
|
||||
uint32_t h;
|
||||
uint32_t p;
|
||||
uint32 h;
|
||||
uint32 p;
|
||||
char *(*alloc)();
|
||||
{
|
||||
struct cdbmake_hplist *head;
|
||||
|
@ -37,8 +37,8 @@ struct cdbmake *cdbm;
|
|||
char *(*alloc)();
|
||||
{
|
||||
int i;
|
||||
uint32_t u;
|
||||
uint32_t memsize;
|
||||
uint32 u;
|
||||
uint32 memsize;
|
||||
struct cdbmake_hplist *x;
|
||||
|
||||
for (i = 0;i < 256;++i)
|
||||
|
@ -58,7 +58,7 @@ char *(*alloc)();
|
|||
}
|
||||
|
||||
memsize += cdbm->numentries; /* no overflow possible up to now */
|
||||
u = (uint32_t) 0 - (uint32_t) 1;
|
||||
u = (uint32) 0 - (uint32) 1;
|
||||
u /= sizeof(struct cdbmake_hp);
|
||||
if (memsize > u) return 0;
|
||||
|
||||
|
@ -82,16 +82,16 @@ char *(*alloc)();
|
|||
return 1;
|
||||
}
|
||||
|
||||
uint32_t cdbmake_throw(cdbm,pos,b)
|
||||
uint32 cdbmake_throw(cdbm,pos,b)
|
||||
struct cdbmake *cdbm;
|
||||
uint32_t pos;
|
||||
uint32 pos;
|
||||
int b;
|
||||
{
|
||||
uint32_t len;
|
||||
uint32_t j;
|
||||
uint32_t count;
|
||||
uint32 len;
|
||||
uint32 j;
|
||||
uint32 count;
|
||||
struct cdbmake_hp *hp;
|
||||
uint32_t where;
|
||||
uint32 where;
|
||||
|
||||
count = cdbm->count[b];
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "freecdbmake.h"
|
||||
|
||||
uint32_t cdbmake_hashadd(h,c)
|
||||
uint32_t h;
|
||||
uint32 cdbmake_hashadd(h,c)
|
||||
uint32 h;
|
||||
unsigned int c;
|
||||
{
|
||||
h += (h << 5);
|
||||
h ^= (uint32_t) (unsigned char) c;
|
||||
h ^= (uint32) (unsigned char) c;
|
||||
return h;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
void cdbmake_pack(buf,num)
|
||||
unsigned char *buf;
|
||||
uint32_t num;
|
||||
uint32 num;
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
buf[3] = num; num >>= 8;
|
||||
|
|
|
@ -22,25 +22,25 @@ char buf[8];
|
|||
|
||||
int main()
|
||||
{
|
||||
uint32_t pos;
|
||||
uint32 pos;
|
||||
int i;
|
||||
uint32_t len;
|
||||
uint32_t slot;
|
||||
uint32_t records;
|
||||
uint32_t slots;
|
||||
uint32_t d0;
|
||||
uint32_t d1;
|
||||
uint32_t d2;
|
||||
uint32_t d3;
|
||||
uint32_t d4;
|
||||
uint32_t d5;
|
||||
uint32_t d6;
|
||||
uint32_t d7;
|
||||
uint32_t d8;
|
||||
uint32_t d9;
|
||||
uint32_t dfar;
|
||||
uint32_t h;
|
||||
uint32_t where;
|
||||
uint32 len;
|
||||
uint32 slot;
|
||||
uint32 records;
|
||||
uint32 slots;
|
||||
uint32 d0;
|
||||
uint32 d1;
|
||||
uint32 d2;
|
||||
uint32 d3;
|
||||
uint32 d4;
|
||||
uint32 d5;
|
||||
uint32 d6;
|
||||
uint32 d7;
|
||||
uint32 d8;
|
||||
uint32 d9;
|
||||
uint32 dfar;
|
||||
uint32 h;
|
||||
uint32 where;
|
||||
|
||||
if (fread(pointers,1,2048,stdin) < 2048) readerror();
|
||||
pos = cdb_unpack(pointers);
|
||||
|
|
|
@ -32,11 +32,11 @@ int numfound = 0;
|
|||
int main()
|
||||
{
|
||||
int i;
|
||||
uint32_t eod;
|
||||
uint32_t klen;
|
||||
uint32_t pos;
|
||||
uint32_t dlen;
|
||||
uint32_t dlen2;
|
||||
uint32 eod;
|
||||
uint32 klen;
|
||||
uint32 pos;
|
||||
uint32 dlen;
|
||||
uint32 dlen2;
|
||||
char buf[8];
|
||||
|
||||
if (cdb_bread(0,buf,4) == -1) readerror();
|
||||
|
|
|
@ -13,7 +13,7 @@ dnl Checks for header files.
|
|||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
|
||||
dnl Only look for uint32_t
|
||||
dnl Only look for uint32
|
||||
AC_CHECK_SIZEOF(long,4)
|
||||
AC_CHECK_SIZEOF(int,4)
|
||||
AC_C_BIGENDIAN
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#if SIZEOF_INT==4
|
||||
typedef unsigned int uint32_t ;
|
||||
typedef unsigned int uint32 ;
|
||||
#elif SIZEOF_LONG==4
|
||||
typedef unsigned long uint32_t ;
|
||||
typedef unsigned long uint32 ;
|
||||
#else
|
||||
#error "No uint32"
|
||||
#endif
|
||||
extern uint32_t cdb_hash();
|
||||
extern uint32_t cdb_unpack();
|
||||
extern uint32 cdb_hash();
|
||||
extern uint32 cdb_unpack();
|
||||
|
||||
extern int cdb_bread();
|
||||
extern int cdb_seek();
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#ifndef CDB_H
|
||||
#include "config.h"
|
||||
#if SIZEOF_INT==4
|
||||
typedef unsigned int uint32_t ;
|
||||
typedef unsigned int uint32 ;
|
||||
#elif SIZEOF_LONG==4
|
||||
typedef unsigned long uint32_t ;
|
||||
typedef unsigned long uint32 ;
|
||||
#else
|
||||
#error "No uint32"
|
||||
#endif
|
||||
|
@ -15,7 +15,7 @@ typedef unsigned long uint32_t ;
|
|||
|
||||
#define CDBMAKE_HPLIST 1000
|
||||
|
||||
struct cdbmake_hp { uint32_t h; uint32_t p; } ;
|
||||
struct cdbmake_hp { uint32 h; uint32 p; } ;
|
||||
|
||||
struct cdbmake_hplist {
|
||||
struct cdbmake_hp hp[CDBMAKE_HPLIST];
|
||||
|
@ -25,21 +25,21 @@ struct cdbmake_hplist {
|
|||
|
||||
struct cdbmake {
|
||||
char final[2048];
|
||||
uint32_t count[256];
|
||||
uint32_t start[256];
|
||||
uint32 count[256];
|
||||
uint32 start[256];
|
||||
struct cdbmake_hplist *head;
|
||||
struct cdbmake_hp *split; /* includes space for hash */
|
||||
struct cdbmake_hp *hash;
|
||||
uint32_t numentries;
|
||||
uint32 numentries;
|
||||
} ;
|
||||
|
||||
extern void cdbmake_pack();
|
||||
#define CDBMAKE_HASHSTART ((uint32_t) 5381)
|
||||
extern uint32_t cdbmake_hashadd();
|
||||
#define CDBMAKE_HASHSTART ((uint32) 5381)
|
||||
extern uint32 cdbmake_hashadd();
|
||||
|
||||
extern void cdbmake_init();
|
||||
extern int cdbmake_add();
|
||||
extern int cdbmake_split();
|
||||
extern uint32_t cdbmake_throw();
|
||||
extern uint32 cdbmake_throw();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue