From 3004b518ef57e2598ddf653192c7234a1438af37 Mon Sep 17 00:00:00 2001 From: leitner Date: Tue, 7 Nov 2006 17:56:05 +0000 Subject: [PATCH] switch to size_t and ssize_t --- CHANGES | 1 + buffer.h | 41 ++++++++++-------- buffer/buffer_0.c | 2 +- buffer/buffer_0small.c | 2 +- buffer/buffer_feed.c | 2 +- buffer/buffer_flush.c | 2 +- buffer/buffer_fromsa.c | 2 +- buffer/buffer_get.3 | 2 +- buffer/buffer_get.c | 2 +- buffer/buffer_get_new_token_sa.3 | 2 +- buffer/buffer_get_new_token_sa.c | 2 +- buffer/buffer_get_token.3 | 4 +- buffer/buffer_get_token.c | 4 +- buffer/buffer_get_token_pred.3 | 4 +- buffer/buffer_get_token_pred.c | 2 +- buffer/buffer_get_token_sa.3 | 2 +- buffer/buffer_get_token_sa.c | 2 +- buffer/buffer_getline.3 | 2 +- buffer/buffer_getline.c | 2 +- buffer/buffer_getn.3 | 2 +- buffer/buffer_getn.c | 6 +-- buffer/buffer_init.3 | 4 +- buffer/buffer_init.c | 4 +- buffer/buffer_init_free.3 | 4 +- buffer/buffer_init_free.c | 4 +- buffer/buffer_mmapread.c | 2 +- buffer/buffer_put.3 | 2 +- buffer/buffer_put.c | 4 +- buffer/buffer_putalign.3 | 2 +- buffer/buffer_putalign.c | 2 +- buffer/buffer_putflush.3 | 2 +- buffer/buffer_putflush.c | 2 +- buffer/buffer_seek.3 | 2 +- buffer/buffer_seek.c | 4 +- buffer/buffer_stubborn.c | 2 +- buffer/buffer_stubborn2.c | 2 +- byte.h | 17 ++++---- byte/byte_chr.3 | 2 +- byte/byte_chr.c | 2 +- byte/byte_copy.3 | 2 +- byte/byte_copy.c | 2 +- byte/byte_copyr.3 | 2 +- byte/byte_copyr.c | 2 +- byte/byte_diff.3 | 2 +- byte/byte_diff.c | 2 +- byte/byte_equal.3 | 2 +- byte/byte_rchr.3 | 2 +- byte/byte_rchr.c | 2 +- byte/byte_zero.3 | 2 +- byte/byte_zero.c | 2 +- case.h | 6 ++- case/case_diffb.3 | 2 +- case/case_diffb.c | 2 +- case/case_lowerb.3 | 2 +- case/case_lowerb.c | 2 +- cdb/cdb.c | 12 +++--- cdb/cdb_traverse.c | 6 +-- errmsg.h | 5 --- fmt.h | 38 ++++++++-------- fmt/fmt_8long.3 | 2 +- fmt/fmt_8long.c | 2 +- fmt/fmt_8longlong.c | 2 +- fmt/fmt_double.3 | 4 +- fmt/fmt_double.c | 2 +- fmt/fmt_fill.3 | 6 +-- fmt/fmt_fill.c | 2 +- fmt/fmt_httpdate.3 | 2 +- fmt/fmt_httpdate.c | 4 +- fmt/fmt_human.3 | 2 +- fmt/fmt_human.c | 2 +- fmt/fmt_humank.3 | 2 +- fmt/fmt_humank.c | 4 +- fmt/fmt_long.3 | 2 +- fmt/fmt_long.c | 2 +- fmt/fmt_longlong.3 | 2 +- fmt/fmt_longlong.c | 2 +- fmt/fmt_minus.3 | 2 +- fmt/fmt_minus.c | 2 +- fmt/fmt_pad.3 | 6 +-- fmt/fmt_pad.c | 2 +- fmt/fmt_plusminus.3 | 2 +- fmt/fmt_plusminus.c | 2 +- fmt/fmt_str.3 | 2 +- fmt/fmt_str.c | 2 +- fmt/fmt_strn.3 | 4 +- fmt/fmt_strn.c | 2 +- fmt/fmt_uint.3 | 2 +- fmt/fmt_uint0.3 | 4 +- fmt/fmt_ulong.3 | 2 +- fmt/fmt_ulong.c | 2 +- fmt/fmt_ulong0.3 | 4 +- fmt/fmt_ulong0.c | 2 +- fmt/fmt_ulonglong.3 | 2 +- fmt/fmt_ulonglong.c | 2 +- fmt/fmt_xlong.3 | 2 +- fmt/fmt_xlong.c | 2 +- fmt/fmt_xlonglong.3 | 2 +- fmt/fmt_xlonglong.c | 2 +- mmap.h | 10 +++-- mmap/mmap_private.3 | 2 +- mmap/mmap_private.c | 2 +- mmap/mmap_read.3 | 2 +- mmap/mmap_read.c | 2 +- mmap/mmap_shared.3 | 2 +- mmap/mmap_shared.c | 2 +- mmap/mmap_unmap.c | 2 +- open/open_append.3 | 2 +- open/open_excl.3 | 2 +- open/open_read.3 | 2 +- open/open_rw.3 | 2 +- open/open_trunc.3 | 2 +- open/open_write.3 | 2 +- open/openreadclose.3 | 4 +- open/openreadclose.c | 4 +- open/readclose.3 | 2 +- open/readclose.c | 4 +- open/readclose_append.3 | 2 +- openreadclose.h | 2 +- readclose.h | 4 +- scan.h | 53 +++++++++++------------ scan/scan_8int.3 | 2 +- scan/scan_8int.c | 4 +- scan/scan_8long.3 | 2 +- scan/scan_8long.c | 2 +- scan/scan_8short.3 | 2 +- scan/scan_8short.c | 4 +- scan/scan_charsetnskip.3 | 6 ++- scan/scan_charsetnskip.c | 2 +- scan/scan_double.3 | 2 +- scan/scan_double.c | 2 +- scan/scan_httpdate.3 | 2 +- scan/scan_httpdate.c | 2 +- scan/scan_int.3 | 2 +- scan/scan_int.c | 4 +- scan/scan_long.3 | 2 +- scan/scan_long.c | 2 +- scan/scan_longlong.3 | 2 +- scan/scan_longlong.c | 2 +- scan/scan_noncharsetnskip.3 | 7 ++- scan/scan_noncharsetnskip.c | 2 +- scan/scan_nonwhitenskip.3 | 5 ++- scan/scan_nonwhitenskip.c | 2 +- scan/scan_plusminus.3 | 2 +- scan/scan_plusminus.c | 2 +- scan/scan_short.3 | 2 +- scan/scan_short.c | 4 +- scan/scan_uint.3 | 2 +- scan/scan_uint.c | 2 +- scan/scan_ulong.3 | 2 +- scan/scan_ulong.c | 2 +- scan/scan_ulonglong.3 | 2 +- scan/scan_ulonglong.c | 2 +- scan/scan_ushort.3 | 2 +- scan/scan_ushort.c | 2 +- scan/scan_whitenskip.3 | 2 +- scan/scan_whitenskip.c | 2 +- scan/scan_xint.3 | 2 +- scan/scan_xint.c | 2 +- scan/scan_xlong.3 | 2 +- scan/scan_xlong.c | 2 +- scan/scan_xlonglong.3 | 2 +- scan/scan_xlonglong.c | 2 +- scan/scan_xshort.3 | 2 +- scan/scan_xshort.c | 4 +- socket.h | 10 +++-- socket/socket_recv4.3 | 2 +- socket/socket_recv4.c | 4 +- socket/socket_recv6.3 | 2 +- socket/socket_recv6.c | 4 +- socket/socket_send4.3 | 2 +- socket/socket_send4.c | 2 +- socket/socket_send6.3 | 2 +- socket/socket_send6.c | 2 +- str.h | 14 +++--- str/str_chr.3 | 2 +- str/str_chr.c | 2 +- str/str_copy.3 | 2 +- str/str_copy.c | 2 +- str/str_diff.3 | 2 +- str/str_diffn.3 | 2 +- str/str_diffn.c | 2 +- str/str_equal.3 | 2 +- str/str_len.3 | 2 +- str/str_len.c | 2 +- str/str_rchr.3 | 2 +- str/str_rchr.c | 2 +- str/str_start.3 | 2 +- stralloc.h | 24 +++++------ stralloc/stralloc_catb.3 | 2 +- stralloc/stralloc_catb.c | 2 +- stralloc/stralloc_catlong0.3 | 2 +- stralloc/stralloc_catlong0.c | 2 +- stralloc/stralloc_catulong0.3 | 2 +- stralloc/stralloc_catulong0.c | 2 +- stralloc/stralloc_copyb.3 | 2 +- stralloc/stralloc_copyb.c | 2 +- stralloc/stralloc_ready.3 | 2 +- stralloc/stralloc_ready.c | 2 +- stralloc/stralloc_readyplus.3 | 2 +- stralloc/stralloc_readyplus.c | 2 +- t.c | 5 ++- test/buffer_mmap.c | 1 + test/mult.c | 7 +-- test/unurl.c | 1 + test/uudecode.c | 4 +- textcode.h | 74 ++++++++++++++++---------------- textcode/fmt_base64.c | 2 +- textcode/fmt_cescape.c | 6 +-- textcode/fmt_foldwhitespace.c | 4 +- textcode/fmt_hexdump.c | 4 +- textcode/fmt_html.c | 4 +- textcode/fmt_ldapescape.c | 4 +- textcode/fmt_quotedprintable.c | 6 +-- textcode/fmt_to_array.c | 6 +-- textcode/fmt_to_sa.c | 6 +-- textcode/fmt_tofrom_array.c | 4 +- textcode/fmt_urlencoded.c | 6 +-- textcode/fmt_uuencoded.c | 6 +-- textcode/fmt_yenc.c | 4 +- textcode/scan_base64.c | 2 +- textcode/scan_cescape.c | 4 +- textcode/scan_hexdump.c | 4 +- textcode/scan_html.c | 4 +- textcode/scan_ldapescape.c | 4 +- textcode/scan_quotedprintable.c | 4 +- textcode/scan_to_array.c | 6 +-- textcode/scan_to_sa.c | 6 +-- textcode/scan_tofrom_array.c | 6 +-- textcode/scan_urlencoded.c | 8 ++-- textcode/scan_uuencoded.c | 6 +-- textcode/scan_yenc.c | 4 +- 231 files changed, 456 insertions(+), 443 deletions(-) diff --git a/CHANGES b/CHANGES index eecd219..f3f6abc 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,7 @@ remove support for ip6.int (it's no longer delegated) add asm versions of imult64 and umult64 for x86_64 (22 cycles -> 12 cycles on my Athlon 64) + use size_t and ssize_t instead of unsigned long et al 0.24: fix scan_to_sa (Tim Lorenz) diff --git a/buffer.h b/buffer.h index cf12cf9..3415d8f 100644 --- a/buffer.h +++ b/buffer.h @@ -1,13 +1,18 @@ #ifndef BUFFER_H #define BUFFER_H +/* for size_t: */ +#include +/* for ssize_t: */ +#include + typedef struct buffer { char *x; /* actual buffer space */ - unsigned long int p; /* current position */ - unsigned long int n; /* current size of string in buffer */ - unsigned long int a; /* allocated buffer size */ + size_t p; /* current position */ + size_t n; /* current size of string in buffer */ + size_t a; /* allocated buffer size */ int fd; /* passed as first argument to op */ - int (*op)(); /* use read(2) or write(2) */ + ssize_t (*op)(); /* use read(2) or write(2) */ enum { NOTHING, FREE, MUNMAP } todo; } buffer; @@ -17,15 +22,15 @@ typedef struct buffer { #define BUFFER_INSIZE 8192 #define BUFFER_OUTSIZE 8192 -void buffer_init(buffer* b,int (*op)(),int fd,char* y,unsigned long int ylen); -void buffer_init_free(buffer* b,int (*op)(),int fd,char* y,unsigned long int ylen); +void buffer_init(buffer* b,ssize_t (*op)(),int fd,char* y,size_t ylen); +void buffer_init_free(buffer* b,ssize_t (*op)(),int fd,char* y,size_t ylen); int buffer_mmapread(buffer* b,const char* filename); void buffer_close(buffer* b); int buffer_flush(buffer* b); -int buffer_put(buffer* b,const char* x,unsigned long int len); -int buffer_putalign(buffer* b,const char* x,unsigned long int len); -int buffer_putflush(buffer* b,const char* x,unsigned long int len); +int buffer_put(buffer* b,const char* x,size_t len); +int buffer_putalign(buffer* b,const char* x,size_t len); +int buffer_putflush(buffer* b,const char* x,size_t len); int buffer_puts(buffer* b,const char* x); int buffer_putsalign(buffer* b,const char* x); int buffer_putsflush(buffer* b,const char* x); @@ -44,27 +49,27 @@ int buffer_putnlflush(buffer* b); /* put \n and flush */ : buffer_put((s),&(c),1) \ ) -int buffer_get(buffer* b,char* x,unsigned long int len); +ssize_t buffer_get(buffer* b,char* x,size_t len); int buffer_feed(buffer* b); int buffer_getc(buffer* b,char* x); -int buffer_getn(buffer* b,char* x,unsigned long int len); +ssize_t buffer_getn(buffer* b,char* x,size_t len); /* read bytes until the destination buffer is full (len bytes), end of * file is reached or the read char is in charset (setlen bytes). An * empty line when looking for \n will write '\n' to x and return 0. If * EOF is reached, \0 is written to the buffer */ -int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen); -int buffer_getline(buffer* b,char* x,unsigned long int len); +ssize_t buffer_get_token(buffer* b,char* x,size_t len,const char* charset,size_t setlen); +ssize_t buffer_getline(buffer* b,char* x,size_t len); /* this predicate is given the string as currently read from the buffer * and is supposed to return 1 if the token is complete, 0 if not. */ -typedef int (*string_predicate)(const char* x,unsigned long int len); +typedef int (*string_predicate)(const char* x,size_t len); /* like buffer_get_token but the token ends when your predicate says so */ -int buffer_get_token_pred(buffer* b,char* x,unsigned long int len,string_predicate p); +ssize_t buffer_get_token_pred(buffer* b,char* x,size_t len,string_predicate p); char *buffer_peek(buffer* b); -void buffer_seek(buffer* b,unsigned long int len); +void buffer_seek(buffer* b,size_t len); #define buffer_PEEK(s) ( (s)->x + (s)->p ) #define buffer_SEEK(s,len) ( (s)->p += (len) ) @@ -112,12 +117,12 @@ int buffer_putsaflush(buffer* b,stralloc* sa); * data is available. */ /* read token from buffer to stralloc */ -int buffer_get_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen); +int buffer_get_token_sa(buffer* b,stralloc* sa,const char* charset,size_t setlen); /* read line from buffer to stralloc */ int buffer_getline_sa(buffer* b,stralloc* sa); /* same as buffer_get_token_sa but empty sa first */ -int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen); +int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,size_t setlen); /* same as buffer_getline_sa but empty sa first */ int buffer_getnewline_sa(buffer* b,stralloc* sa); diff --git a/buffer/buffer_0.c b/buffer/buffer_0.c index 258de28..a4326d4 100644 --- a/buffer/buffer_0.c +++ b/buffer/buffer_0.c @@ -1,7 +1,7 @@ #include #include "buffer.h" -static int b0read(int fd,char* buf, unsigned int len) { +static ssize_t b0read(int fd,char* buf, size_t len) { if (buffer_flush(buffer_1)<0) return -1; return read(fd,buf,len); } diff --git a/buffer/buffer_0small.c b/buffer/buffer_0small.c index ff9917b..ee238fc 100644 --- a/buffer/buffer_0small.c +++ b/buffer/buffer_0small.c @@ -1,7 +1,7 @@ #include #include "buffer.h" -static int b0read(int fd,char* buf, unsigned int len) { +static ssize_t b0read(int fd,char* buf, size_t len) { if (buffer_flush(buffer_1small)<0) return -1; return read(fd,buf,len); } diff --git a/buffer/buffer_feed.c b/buffer/buffer_feed.c index 8e35aba..bbae4a3 100644 --- a/buffer/buffer_feed.c +++ b/buffer/buffer_feed.c @@ -1,6 +1,6 @@ #include "buffer.h" -extern int buffer_stubborn_read(int (*op)(),int fd,const char* buf, unsigned int len); +extern int buffer_stubborn_read(ssize_t (*op)(),int fd,const char* buf, size_t len); int buffer_feed(buffer* b) { if (b->p==b->n) { diff --git a/buffer/buffer_flush.c b/buffer/buffer_flush.c index 6db8c7b..e512f5a 100644 --- a/buffer/buffer_flush.c +++ b/buffer/buffer_flush.c @@ -1,6 +1,6 @@ #include "buffer.h" -extern int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned int len); +extern int buffer_stubborn(ssize_t (*op)(),int fd,const char* buf, size_t len); extern int buffer_flush(buffer* b) { register int p; diff --git a/buffer/buffer_fromsa.c b/buffer/buffer_fromsa.c index e57c198..34cf170 100644 --- a/buffer/buffer_fromsa.c +++ b/buffer/buffer_fromsa.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "buffer.h" -static int dummyreadwrite(int fd,char* buf,unsigned long int len) { +static ssize_t dummyreadwrite(int fd,char* buf,size_t len) { (void)fd; (void)buf; (void)len; diff --git a/buffer/buffer_get.3 b/buffer/buffer_get.3 index eef6864..de21c26 100644 --- a/buffer/buffer_get.3 +++ b/buffer/buffer_get.3 @@ -4,7 +4,7 @@ buffer_get \- read binary data from buffer .SH SYNTAX .B #include -int \fBbuffer_get\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR); +ssize_t \fBbuffer_get\fP(buffer* \fIb\fR,char* \fIx\fR,size_t \fIlen\fR); .SH DESCRIPTION Normally buffer_get copies data to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] from the beginning of a string stored in diff --git a/buffer/buffer_get.c b/buffer/buffer_get.c index c9bcec4..5f35009 100644 --- a/buffer/buffer_get.c +++ b/buffer/buffer_get.c @@ -1,7 +1,7 @@ #include "byte.h" #include "buffer.h" -int buffer_get(buffer* b,char* x,unsigned long int len) { +ssize_t buffer_get(buffer* b,char* x,size_t len) { unsigned long done; int blen; done=0; diff --git a/buffer/buffer_get_new_token_sa.3 b/buffer/buffer_get_new_token_sa.3 index 251a5f1..8fb213a 100644 --- a/buffer/buffer_get_new_token_sa.3 +++ b/buffer/buffer_get_new_token_sa.3 @@ -7,7 +7,7 @@ buffer_get_new_token_sa \- read token from buffer .B #include int \fBbuffer_get_new_token_sa\fP(buffer* \fIb\fR,stralloc* \fIsa\fR, - const char* \fIcharset\fR,unsigned int \fIsetlen\fR); + const char* \fIcharset\fR,size_t \fIsetlen\fR); .SH DESCRIPTION buffer_get_new_token_sa copies data from the \fIb\fR to \fIsa\fR until one of the delimiters in \fIcharset\fR is found, overwriting the diff --git a/buffer/buffer_get_new_token_sa.c b/buffer/buffer_get_new_token_sa.c index 8d7302c..5f4f7bc 100644 --- a/buffer/buffer_get_new_token_sa.c +++ b/buffer/buffer_get_new_token_sa.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "buffer.h" -int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen) { +int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,size_t setlen) { stralloc_zero(sa); return buffer_get_token_sa(b,sa,charset,setlen); } diff --git a/buffer/buffer_get_token.3 b/buffer/buffer_get_token.3 index 41e75fa..7ce6439 100644 --- a/buffer/buffer_get_token.3 +++ b/buffer/buffer_get_token.3 @@ -4,8 +4,8 @@ buffer_get_token \- read token from buffer .SH SYNTAX .B #include -int \fBbuffer_get_token\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR, - const char* \fIcharset\fR,unsigned long int \fIsetlen\fR); +ssize_t \fBbuffer_get_token\fP(buffer* \fIb\fR,char* \fIx\fR,size_t \fIlen\fR, + const char* \fIcharset\fR,size_t \fIsetlen\fR); .SH DESCRIPTION buffer_get_token copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been copied or one of diff --git a/buffer/buffer_get_token.c b/buffer/buffer_get_token.c index 795f0a5..25ae46d 100644 --- a/buffer/buffer_get_token.c +++ b/buffer/buffer_get_token.c @@ -2,8 +2,8 @@ #include "buffer.h" #include "scan.h" -int buffer_get_token(buffer* b,char* x,unsigned long int len,const char* charset,unsigned long int setlen) { - unsigned long int blen; +ssize_t buffer_get_token(buffer* b,char* x,size_t len,const char* charset,size_t setlen) { + size_t blen; for (blen=0;blen -int \fBbuffer_get_token_pred\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR, - int (*\fIpredicate\fR)(const char* \fIs\fR,unsigned long int \fIlen\fR)); +ssize_t \fBbuffer_get_token_pred\fP(buffer* \fIb\fR,char* \fIx\fR,size_t \fIlen\fR, + int (*\fIpredicate\fR)(const char* \fIs\fR,size_t \fIlen\fR)); .SH DESCRIPTION buffer_get_token_pred copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been diff --git a/buffer/buffer_get_token_pred.c b/buffer/buffer_get_token_pred.c index cea6526..e992b73 100644 --- a/buffer/buffer_get_token_pred.c +++ b/buffer/buffer_get_token_pred.c @@ -2,7 +2,7 @@ #include "buffer.h" #include "scan.h" -int buffer_get_token_pred(buffer* b,char* x,unsigned long int len, +ssize_t buffer_get_token_pred(buffer* b,char* x,size_t len, string_predicate p) { unsigned int blen; diff --git a/buffer/buffer_get_token_sa.3 b/buffer/buffer_get_token_sa.3 index 209a16e..ccfe104 100644 --- a/buffer/buffer_get_token_sa.3 +++ b/buffer/buffer_get_token_sa.3 @@ -7,7 +7,7 @@ buffer_get_token_sa \- read token from buffer .B #include int \fBbuffer_get_token_sa\fP(buffer* \fIb\fR,stralloc* \fIsa\fR, - const char* \fIcharset\fR,unsigned long int \fIsetlen\fR); + const char* \fIcharset\fR,size_t \fIsetlen\fR); .SH DESCRIPTION buffer_get_token_sa appends data from the \fIb\fR to \fIsa\fR until one of the delimiters in \fIcharset\fR is found, NOT overwriting the diff --git a/buffer/buffer_get_token_sa.c b/buffer/buffer_get_token_sa.c index 972ae61..e312490 100644 --- a/buffer/buffer_get_token_sa.c +++ b/buffer/buffer_get_token_sa.c @@ -5,7 +5,7 @@ int buffer_get_token_sa(buffer* b,stralloc* sa, const char* charset, - unsigned long int setlen) { + size_t setlen) { for (;;) { char x; if (!stralloc_readyplus(sa,1)) goto nomem; diff --git a/buffer/buffer_getline.3 b/buffer/buffer_getline.3 index 1660b68..e9998c9 100644 --- a/buffer/buffer_getline.3 +++ b/buffer/buffer_getline.3 @@ -4,7 +4,7 @@ buffer_getline \- read line from buffer .SH SYNTAX .B #include -int \fBbuffer_getline\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR); +ssize_t \fBbuffer_getline\fP(buffer* \fIb\fR,char* \fIx\fR,size_t \fIlen\fR); .SH DESCRIPTION buffer_getline copies data from \fIb\fR to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] until \fIlen\fR bytes have been copied or a diff --git a/buffer/buffer_getline.c b/buffer/buffer_getline.c index 5f8b60a..e412293 100644 --- a/buffer/buffer_getline.c +++ b/buffer/buffer_getline.c @@ -1,5 +1,5 @@ #include -int buffer_getline(buffer* b,char* x,unsigned long int len) { +ssize_t buffer_getline(buffer* b,char* x,size_t len) { return buffer_get_token(b,x,len,"\n",1); } diff --git a/buffer/buffer_getn.3 b/buffer/buffer_getn.3 index 127b5c7..f6d435f 100644 --- a/buffer/buffer_getn.3 +++ b/buffer/buffer_getn.3 @@ -4,7 +4,7 @@ buffer_getn \- read binary data from buffer .SH SYNTAX .B #include -int \fBbuffer_getn\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned long int \fIlen\fR); +ssize_t \fBbuffer_getn\fP(buffer* \fIb\fR,char* \fIx\fR,size_t \fIlen\fR); .SH DESCRIPTION buffer_getn copies data to \fIx\fR[0], \fIx\fR[1], ..., \fIx\fR[\fIlen\fR-1] from the buffer, calling buffer_feed as needed, and diff --git a/buffer/buffer_getn.c b/buffer/buffer_getn.c index 66f1db6..2c6405a 100644 --- a/buffer/buffer_getn.c +++ b/buffer/buffer_getn.c @@ -1,11 +1,11 @@ #include "byte.h" #include "buffer.h" -int buffer_getn(buffer* b,char* x,unsigned long int len) { - unsigned int blen; +ssize_t buffer_getn(buffer* b,char* x,size_t len) { + size_t blen; for(blen=0;blen void \fBbuffer_init\fR(buffer &\fIb\fR, - int (*\fIop\fR)(int,char*,unsigned int), - int \fIfd\fR, char* \fIy\fR, unsigned long int \fIylen\fR); + ssize_t (*\fIop\fR)(int,char*,size_t), + int \fIfd\fR, char* \fIy\fR, size_t \fIylen\fR); .SH DESCRIPTION buffer_init prepares \fIb\fR to store a string in \fIy\fR[0], \fIy\fR[1], ..., \fIy\fR[\fIylen\fR-1]. Initially the string is empty. diff --git a/buffer/buffer_init.c b/buffer/buffer_init.c index d7c2c6b..2e359d5 100644 --- a/buffer/buffer_init.c +++ b/buffer/buffer_init.c @@ -1,7 +1,7 @@ #include "buffer.h" -void buffer_init(buffer* b,int (*op)(),int fd, - char* y,unsigned long int ylen) { +void buffer_init(buffer* b,ssize_t (*op)(),int fd, + char* y,size_t ylen) { b->op=op; b->fd=fd; b->x=y; diff --git a/buffer/buffer_init_free.3 b/buffer/buffer_init_free.3 index 502b46f..f44c12e 100644 --- a/buffer/buffer_init_free.3 +++ b/buffer/buffer_init_free.3 @@ -5,8 +5,8 @@ buffer_init_free \- initialize buffer structure .B #include void \fBbuffer_init_free\fR(buffer &\fIb\fR, - int (*\fIop\fR)(int,char*,unsigned int), - int \fIfd\fR, char* \fIy\fR, unsigned long int \fIylen\fR); + ssize_t (*\fIop\fR)(int,char*,size_t), + int \fIfd\fR, char* \fIy\fR, size_t \fIylen\fR); .SH DESCRIPTION buffer_init_free is like buffer_init except that the memory (\fIy\fR is marked to be freed by buffer_close(). diff --git a/buffer/buffer_init_free.c b/buffer/buffer_init_free.c index 73fc662..5173008 100644 --- a/buffer/buffer_init_free.c +++ b/buffer/buffer_init_free.c @@ -1,7 +1,7 @@ #include "buffer.h" -void buffer_init_free(buffer* b,int (*op)(),int fd, - char* y,unsigned long int ylen) { +void buffer_init_free(buffer* b,ssize_t (*op)(),int fd, + char* y,size_t ylen) { buffer_init(b,op,fd,y,ylen); b->todo=FREE; } diff --git a/buffer/buffer_mmapread.c b/buffer/buffer_mmapread.c index 858bf9b..901aa57 100644 --- a/buffer/buffer_mmapread.c +++ b/buffer/buffer_mmapread.c @@ -1,7 +1,7 @@ #include #include -static int op() { +static ssize_t op() { return 0; } diff --git a/buffer/buffer_put.3 b/buffer/buffer_put.3 index 59557d8..c9daeb4 100644 --- a/buffer/buffer_put.3 +++ b/buffer/buffer_put.3 @@ -4,7 +4,7 @@ buffer_put \- write binary data to buffer .SH SYNTAX .B #include -int \fBbuffer_put\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_put\fP(buffer* \fIb\fR,const char* \fIx\fR,size_t \fIlen\fR); .SH DESCRIPTION buffer_put writes \fIlen\fR bytes from \fIx\fR to \fIb\fR. diff --git a/buffer/buffer_put.c b/buffer/buffer_put.c index 7c1b637..64fe8ec 100644 --- a/buffer/buffer_put.c +++ b/buffer/buffer_put.c @@ -1,9 +1,9 @@ #include "byte.h" #include "buffer.h" -extern int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned long int len); +extern int buffer_stubborn(ssize_t (*op)(),int fd,const char* buf, size_t len); -int buffer_put(buffer* b,const char* buf,unsigned long int len) { +int buffer_put(buffer* b,const char* buf,size_t len) { if (len>b->a-b->p) { /* doesn't fit */ if (buffer_flush(b)==-1) return -1; if (len>b->a) { diff --git a/buffer/buffer_putalign.3 b/buffer/buffer_putalign.3 index 3f849cf..9a0e69b 100644 --- a/buffer/buffer_putalign.3 +++ b/buffer/buffer_putalign.3 @@ -4,7 +4,7 @@ buffer_putalign \- write binary data to buffer .SH SYNTAX .B #include -int \fBbuffer_putalign\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned long int \fIlen\fR); +int \fBbuffer_putalign\fP(buffer* \fIb\fR,const char* \fIx\fR,size_t \fIlen\fR); .SH DESCRIPTION buffer_putalign is similar to buffer_put. diff --git a/buffer/buffer_putalign.c b/buffer/buffer_putalign.c index ebd9b83..631cd8c 100644 --- a/buffer/buffer_putalign.c +++ b/buffer/buffer_putalign.c @@ -1,7 +1,7 @@ #include "byte.h" #include "buffer.h" -int buffer_putalign(buffer* b,const char* buf,unsigned long int len) { +int buffer_putalign(buffer* b,const char* buf,size_t len) { unsigned int tmp; while (len>(tmp=b->a-b->p)) { byte_copy(b->x+b->p, tmp, buf); diff --git a/buffer/buffer_putflush.3 b/buffer/buffer_putflush.3 index 48e4122..c7dd817 100644 --- a/buffer/buffer_putflush.3 +++ b/buffer/buffer_putflush.3 @@ -5,7 +5,7 @@ buffer_putflush \- write binary data to buffer and flush .B #include int \fBbuffer_putflush\fP(buffer* \fIb\fR, - const char* \fIx\fR,unsigned long int \fIlen\fR); + const char* \fIx\fR,size_t \fIlen\fR); .SH DESCRIPTION buffer_putflush is similar to calling buffer_put(\fIb\fR,\fIx\fR,\fIlen\fR) and then buffer_flush(\fIb\fR). diff --git a/buffer/buffer_putflush.c b/buffer/buffer_putflush.c index f26960d..f33e4dc 100644 --- a/buffer/buffer_putflush.c +++ b/buffer/buffer_putflush.c @@ -1,6 +1,6 @@ #include "buffer.h" -int buffer_putflush(buffer* b,const char* x,unsigned long int len) { +int buffer_putflush(buffer* b,const char* x,size_t len) { if (buffer_put(b,x,len)<0) return -1; if (buffer_flush(b)<0) return -1; return 0; diff --git a/buffer/buffer_seek.3 b/buffer/buffer_seek.3 index 1b0603c..a0dd5ee 100644 --- a/buffer/buffer_seek.3 +++ b/buffer/buffer_seek.3 @@ -4,7 +4,7 @@ buffer_seek \- remove bytes from beginning of string in buffer .SH SYNTAX .B #include -void \fBbuffer_seek\fP(buffer* \fIb\fR,unsigned long int \fIr\fR); +void \fBbuffer_seek\fP(buffer* \fIb\fR,size_t \fIr\fR); .SH DESCRIPTION buffer_seek removes \fIr\fR bytes from the beginning of the string. \fIr\fR must be at most the current length of the string. diff --git a/buffer/buffer_seek.c b/buffer/buffer_seek.c index 7821ac8..b406e77 100644 --- a/buffer/buffer_seek.c +++ b/buffer/buffer_seek.c @@ -1,7 +1,7 @@ #include "buffer.h" -void buffer_seek(buffer* b,unsigned long int len) { - unsigned long int n=b->p+len; +void buffer_seek(buffer* b,size_t len) { + size_t n=b->p+len; if (np) n=b->p; if (n>b->n) n=b->n; b->p=n; diff --git a/buffer/buffer_stubborn.c b/buffer/buffer_stubborn.c index 2ddcbdf..e108cfa 100644 --- a/buffer/buffer_stubborn.c +++ b/buffer/buffer_stubborn.c @@ -1,7 +1,7 @@ #include #include "buffer.h" -int buffer_stubborn(int (*op)(),int fd,const char* buf, unsigned long int len) { +int buffer_stubborn(ssize_t (*op)(),int fd,const char* buf, size_t len) { int w; while (len) { if ((w=op(fd,buf,len))<0) { diff --git a/buffer/buffer_stubborn2.c b/buffer/buffer_stubborn2.c index 0064503..e40a8dd 100644 --- a/buffer/buffer_stubborn2.c +++ b/buffer/buffer_stubborn2.c @@ -1,7 +1,7 @@ #include #include "buffer.h" -int buffer_stubborn_read(int (*op)(),int fd,const char* buf, unsigned long int len) { +int buffer_stubborn_read(ssize_t (*op)(),int fd,const char* buf, size_t len) { int w; for (;;) { if ((w=op(fd,buf,len))<0) diff --git a/byte.h b/byte.h index fe8a3a4..43e03c5 100644 --- a/byte.h +++ b/byte.h @@ -1,9 +1,8 @@ #ifndef BYTE_H #define BYTE_H -#ifdef __dietlibc__ -#include -#endif +/* for size_t: */ +#include #ifndef __pure__ #define __pure__ @@ -11,29 +10,29 @@ /* byte_chr returns the smallest integer i between 0 and len-1 * inclusive such that one[i] equals needle, or len if not found. */ -unsigned long byte_chr(const void* haystack, unsigned long len, char needle) __pure__; +size_t byte_chr(const void* haystack, size_t len, char needle) __pure__; /* byte_rchr returns the largest integer i between 0 and len-1 inclusive * such that one[i] equals needle, or len if not found. */ -unsigned long byte_rchr(const void* haystack,unsigned long len,char needle) __pure__; +size_t byte_rchr(const void* haystack,size_t len,char needle) __pure__; /* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1] * to out[len-1]. */ -void byte_copy(void* out, unsigned long len, const void* in); +void byte_copy(void* out, size_t len, const void* in); /* byte_copyr copies in[len-1] to out[len-1], in[len-2] to out[len-2], * ... and in[0] to out[0] */ -void byte_copyr(void* out, unsigned long len, const void* in); +void byte_copyr(void* out, size_t len, const void* in); /* byte_diff returns negative, 0, or positive, depending on whether the * string a[0], a[1], ..., a[len-1] is lexicographically smaller * than, equal to, or greater than the string b[0], b[1], ..., * b[len-1]. When the strings are different, byte_diff does not read * bytes past the first difference. */ -int byte_diff(const void* a, unsigned long len, const void* b) __pure__; +int byte_diff(const void* a, size_t len, const void* b) __pure__; /* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */ -void byte_zero(void* out, unsigned long len); +void byte_zero(void* out, size_t len); #define byte_equal(s,n,t) (!byte_diff((s),(n),(t))) diff --git a/byte/byte_chr.3 b/byte/byte_chr.3 index 406fc35..50f3527 100644 --- a/byte/byte_chr.3 +++ b/byte/byte_chr.3 @@ -4,7 +4,7 @@ byte_chr \- search for a byte in a string .SH SYNTAX .B #include -long \fBbyte_chr\fP(const char *\fIhaystack\fR,unsigned long \fIlen\fR,char \fIneedle\fR); +size_t \fBbyte_chr\fP(const char *\fIhaystack\fR,size_t \fIlen\fR,char \fIneedle\fR); .SH DESCRIPTION \fIbyte_chr\fR returns the smallest integer \fIi\fR between 0 and \fIlen\fR-1 inclusive such that \fIone\fR[\fIi\fR] equals \fIneedle\fR. diff --git a/byte/byte_chr.c b/byte/byte_chr.c index c7c4c8b..5818427 100644 --- a/byte/byte_chr.c +++ b/byte/byte_chr.c @@ -2,7 +2,7 @@ /* byte_chr returns the smallest integer i between 0 and len-1 * inclusive such that one[i] equals needle, or len if not found. */ -unsigned long byte_chr(const void* haystack, unsigned long len, char needle) { +size_t byte_chr(const void* haystack, size_t len, char needle) { register char c=needle; register const char* s=haystack; register const char* t=s+len; diff --git a/byte/byte_copy.3 b/byte/byte_copy.3 index e606d8e..8bf9604 100644 --- a/byte/byte_copy.3 +++ b/byte/byte_copy.3 @@ -4,7 +4,7 @@ byte_copy \- copy a string .SH SYNTAX .B #include -void \fBbyte_copy\fP(char *\fIout\fR,unsigned long \fIlen\fR,const char *\fIin\fR); +void \fBbyte_copy\fP(char *\fIout\fR,size_t \fIlen\fR,const char *\fIin\fR); .SH DESCRIPTION \fIbyte_copy\fR copies \fIin\fR[0] to \fIout\fR[0], \fIin\fR[1] to \fIout\fR[1], etc., and finally \fIin\fR[\fIlen\fR-1] to diff --git a/byte/byte_copy.c b/byte/byte_copy.c index f0951fa..9c8da7b 100644 --- a/byte/byte_copy.c +++ b/byte/byte_copy.c @@ -2,7 +2,7 @@ /* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1] * to out[len-1]. */ -void byte_copy(void* out, unsigned long len, const void* in) { +void byte_copy(void* out, size_t len, const void* in) { register char* s=out; register const char* t=in; register const char* u=t+len; diff --git a/byte/byte_copyr.3 b/byte/byte_copyr.3 index f23ce63..4de6279 100644 --- a/byte/byte_copyr.3 +++ b/byte/byte_copyr.3 @@ -4,7 +4,7 @@ byte_copyr \- copy a string .SH SYNTAX .B #include -void \fBbyte_copyr\fP(char *\fIout\fR,unsigned long \fIlen\fR,const char *\fIin\fR); +void \fBbyte_copyr\fP(char *\fIout\fR,size_t \fIlen\fR,const char *\fIin\fR); .SH DESCRIPTION \fIbyte_copyr\fR copies \fIin\fR[\fIlen\fR-1] to \fIout\fR[\fIlen\fR-1], \fIin\fR[\fIlen\fR-2] to \fIout\fR[\fIlen\fR-2], etc., and diff --git a/byte/byte_copyr.c b/byte/byte_copyr.c index 85dba7e..018d5c6 100644 --- a/byte/byte_copyr.c +++ b/byte/byte_copyr.c @@ -2,7 +2,7 @@ /* byte_copyr copies in[len-1] to out[len-1], in[len-2] to out[len-2], * ... and in[0] to out[0] */ -void byte_copyr(void* out, unsigned long len, const void* in) { +void byte_copyr(void* out, size_t len, const void* in) { register char* s=(char*)out+len; register const char* t=in; register const char* u=t+len; diff --git a/byte/byte_diff.3 b/byte/byte_diff.3 index bdd78db..fb48601 100644 --- a/byte/byte_diff.3 +++ b/byte/byte_diff.3 @@ -4,7 +4,7 @@ byte_diff \- compare two strings .SH SYNTAX .B #include -int \fBbyte_diff\fP(const char *\fIone\fR,unsigned long \fIlen\fR,const char *\fItwo\fR); +int \fBbyte_diff\fP(const char *\fIone\fR,size_t \fIlen\fR,const char *\fItwo\fR); .SH DESCRIPTION \fIbyte_diff\fR returns negative, 0, or positive, depending on whether the string \fIone\fR[0], \fIone\fR[1], ..., \fIone\fR[\fIlen\fR-1] is diff --git a/byte/byte_diff.c b/byte/byte_diff.c index 55e95b4..70df17a 100644 --- a/byte/byte_diff.c +++ b/byte/byte_diff.c @@ -5,7 +5,7 @@ * than, equal to, or greater than the string one[0], one[1], ..., * one[len-1]. When the strings are different, byte_diff does not read * bytes past the first difference. */ -int byte_diff(const void* a, unsigned long len, const void* b) { +int byte_diff(const void* a, size_t len, const void* b) { register const unsigned char* s=a; register const unsigned char* t=b; register const unsigned char* u=t+len; diff --git a/byte/byte_equal.3 b/byte/byte_equal.3 index e44f0c8..71db45a 100644 --- a/byte/byte_equal.3 +++ b/byte/byte_equal.3 @@ -4,7 +4,7 @@ byte_equal \- compare two strings .SH SYNTAX .B #include -int \fBbyte_equal\fP(const char *\fIone\fR,unsigned long \fIlen\fR,const char *\fItwo\fR); +int \fBbyte_equal\fP(const char *\fIone\fR,size_t \fIlen\fR,const char *\fItwo\fR); .SH DESCRIPTION \fIbyte_equal\fR returns 1 if the strings are equal, 0 otherwise. diff --git a/byte/byte_rchr.3 b/byte/byte_rchr.3 index 66d3390..4d87b45 100644 --- a/byte/byte_rchr.3 +++ b/byte/byte_rchr.3 @@ -4,7 +4,7 @@ byte_rchr \- search for a byte in a string .SH SYNTAX .B #include -long \fBbyte_rchr\fP(const char *\fIhaystack\fR,unsigned long \fIlen\fR,char \fIneedle\fR); +size_t \fBbyte_rchr\fP(const char *\fIhaystack\fR,size_t \fIlen\fR,char \fIneedle\fR); .SH DESCRIPTION \fIbyte_chr\fR returns the largest integer \fIi\fR between 0 and \fIlen\fR-1 inclusive such that \fIone\fR[\fIi\fR] equals \fIneedle\fR. diff --git a/byte/byte_rchr.c b/byte/byte_rchr.c index 06a465b..b5159fc 100644 --- a/byte/byte_rchr.c +++ b/byte/byte_rchr.c @@ -2,7 +2,7 @@ /* byte_rchr returns the largest integer i between 0 and len-1 inclusive * such that one[i] equals needle, or len if not found. */ -unsigned long byte_rchr(const void* haystack,unsigned long len,char needle) { +size_t byte_rchr(const void* haystack,size_t len,char needle) { register char c=needle; register const char* s=haystack; register const char* t=s+len; diff --git a/byte/byte_zero.3 b/byte/byte_zero.3 index 0d3b678..fe98a21 100644 --- a/byte/byte_zero.3 +++ b/byte/byte_zero.3 @@ -4,7 +4,7 @@ byte_zero \- initialize a string .SH SYNTAX .B #include -void \fBbyte_zero\fP(char *\fIout\fR,unsigned long \fIlen\fR); +void \fBbyte_zero\fP(char *\fIout\fR,size_t \fIlen\fR); .SH DESCRIPTION \fIbyte_zero\fR sets \fIout\fR[0], \fIout\fR[1], ..., \fIout\fR[\fIlen\fR-1] to 0. diff --git a/byte/byte_zero.c b/byte/byte_zero.c index 57c6464..5a4ebb4 100644 --- a/byte/byte_zero.c +++ b/byte/byte_zero.c @@ -1,7 +1,7 @@ #include "byte.h" /* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */ -void byte_zero(void* out, unsigned long len) { +void byte_zero(void* out, size_t len) { register char* s=out; register const char* t=s+len; for (;;) { diff --git a/case.h b/case.h index 64b8e54..5019477 100644 --- a/case.h +++ b/case.h @@ -1,15 +1,17 @@ #ifndef CASE_H #define CASE_H +#include + /* turn upper case letters to lower case letters, ASCIIZ */ void case_lowers(char *s); /* turn upper case letters to lower case letters, binary */ -void case_lowerb(void *buf,unsigned long len); +void case_lowerb(void *buf,size_t len); /* like str_diff, ignoring case */ int case_diffs(const char *,const char *); /* like byte_diff, ignoring case */ -int case_diffb(const void *,unsigned long,const void *); +int case_diffb(const void *,size_t ,const void *); /* like str_start, ignoring case */ int case_starts(const char *,const char *); diff --git a/case/case_diffb.3 b/case/case_diffb.3 index 826fa45..caf3284 100644 --- a/case/case_diffb.3 +++ b/case/case_diffb.3 @@ -4,7 +4,7 @@ case_diffb \- compare strings case-insensitively .SH SYNTAX .B #include -int \fBcase_diffb\fP(const void* \fIa\fR,unsigned long \fIlen\fR,const void* \fIb\fR); +int \fBcase_diffb\fP(const void* \fIa\fR,size_t \fIlen\fR,const void* \fIb\fR); .SH DESCRIPTION case_diffb is similar to byte_diff. The difference is that for the comparison 'A' == 'a', 'B' == 'b', ..., 'Z' == 'z'. diff --git a/case/case_diffb.c b/case/case_diffb.c index 569ba8e..822f76b 100644 --- a/case/case_diffb.c +++ b/case/case_diffb.c @@ -1,6 +1,6 @@ #include "case.h" -int case_diffb(register const void* S,register unsigned long len,register const void* T) +int case_diffb(register const void* S,register size_t len,register const void* T) { register unsigned char x; register unsigned char y; diff --git a/case/case_lowerb.3 b/case/case_lowerb.3 index 2363fc6..7860cdd 100644 --- a/case/case_lowerb.3 +++ b/case/case_lowerb.3 @@ -4,7 +4,7 @@ case_lowerb \- compare strings case-insensitively .SH SYNTAX .B #include -void \fBcase_lowerb\fP(void* \fIs\fR,unsigned long \fIlen\fR); +void \fBcase_lowerb\fP(void* \fIs\fR,size_t \fIlen\fR); .SH DESCRIPTION case_lowerb converts each 'A' to 'a', 'B' to 'b', ..., 'Z' to 'z' in \fIs\fR[0], \fIs\fR[1], ..., \fIs\fR[\fIlen\fR]. diff --git a/case/case_lowerb.c b/case/case_lowerb.c index c7461ec..2a2c9e3 100644 --- a/case/case_lowerb.c +++ b/case/case_lowerb.c @@ -1,6 +1,6 @@ #include "case.h" -void case_lowerb(void *S,unsigned long len) { +void case_lowerb(void *S,size_t len) { char* s=(char*)S; unsigned char x; while (len > 0) { diff --git a/cdb/cdb.c b/cdb/cdb.c index ec6b431..3cf521f 100644 --- a/cdb/cdb.c +++ b/cdb/cdb.c @@ -110,9 +110,9 @@ int cdb_findnext(struct cdb *c,const unsigned char *key,unsigned long int len) { if (!c->loop) { u = cdb_hash(key,len); if (cdb_read(c,buf,8,(u << 3) & 2047) == -1) return -1; - uint32_unpack(buf + 4,&c->hslots); + uint32_unpack((char*)buf + 4,&c->hslots); if (!c->hslots) return 0; - uint32_unpack(buf,&c->hpos); + uint32_unpack((char*)buf,&c->hpos); c->khash = u; u >>= 8; u %= c->hslots; @@ -122,21 +122,21 @@ int cdb_findnext(struct cdb *c,const unsigned char *key,unsigned long int len) { while (c->loop < c->hslots) { if (cdb_read(c,buf,8,c->kpos) == -1) return -1; - uint32_unpack(buf + 4,&pos); + uint32_unpack((char*)buf + 4,&pos); if (!pos) return 0; c->loop += 1; c->kpos += 8; if (c->kpos == c->hpos + (c->hslots << 3)) c->kpos = c->hpos; - uint32_unpack(buf,&u); + uint32_unpack((char*)buf,&u); if (u == c->khash) { if (cdb_read(c,buf,8,pos) == -1) return -1; - uint32_unpack(buf,&u); + uint32_unpack((char*)buf,&u); if (u == len) switch(match(c,key,len,pos + 8)) { case -1: return -1; case 1: - uint32_unpack(buf + 4,&c->dlen); + uint32_unpack((char*)buf + 4,&c->dlen); c->dpos = pos + 8 + len; return 1; } diff --git a/cdb/cdb_traverse.c b/cdb/cdb_traverse.c index f393585..5fbfb80 100644 --- a/cdb/cdb_traverse.c +++ b/cdb/cdb_traverse.c @@ -4,15 +4,15 @@ static int doit(struct cdb *c,uint32 *kpos) { unsigned char buf[8]; uint32 eod,klen; if (cdb_read(c,buf,4,0)) return -1; - uint32_unpack(buf,&eod); + uint32_unpack((char*)buf,&eod); if (eod<8 || eod-8<*kpos) return 0; c->kpos=*kpos+8; if (c->kpos<*kpos) return -1; /* wraparound */ cdb_findstart(c); c->hslots=1; if (cdb_read(c,buf,8,*kpos) == -1) return -1; - uint32_unpack(buf,&klen); - uint32_unpack(buf+4,&c->dlen); + uint32_unpack((char*)buf,&klen); + uint32_unpack((char*)buf+4,&c->dlen); c->dpos=c->kpos+klen; *kpos+=8+klen+c->dlen; return 1; diff --git a/errmsg.h b/errmsg.h index d095e5a..92862d1 100644 --- a/errmsg.h +++ b/errmsg.h @@ -1,11 +1,6 @@ #ifndef ERRMSG_H #define ERRMSG_H -#ifdef __dietlibc__ -#include -#else -#define __attribute__(x) -#endif /* for exit(): */ #include diff --git a/fmt.h b/fmt.h index 57e7e1b..2be0f90 100644 --- a/fmt.h +++ b/fmt.h @@ -1,6 +1,8 @@ #ifndef FMT_H #define FMT_H +/* for size_t: */ +#include /* for time_t: */ #include @@ -15,23 +17,23 @@ /* convert signed src integer -23 to ASCII '-','2','3', return length. * If dest is not NULL, write result to dest */ -unsigned int fmt_long(char *dest,signed long src); +size_t fmt_long(char *dest,signed long src); /* convert unsigned src integer 23 to ASCII '2','3', return length. * If dest is not NULL, write result to dest */ -unsigned int fmt_ulong(char *dest,unsigned long src); +size_t fmt_ulong(char *dest,unsigned long src); /* convert unsigned src integer 0x23 to ASCII '2','3', return length. * If dest is not NULL, write result to dest */ -unsigned int fmt_xlong(char *dest,unsigned long src); +size_t fmt_xlong(char *dest,unsigned long src); /* convert unsigned src integer 023 to ASCII '2','3', return length. * If dest is not NULL, write result to dest */ -unsigned int fmt_8long(char *dest,unsigned long src); +size_t fmt_8long(char *dest,unsigned long src); -unsigned int fmt_longlong(char *dest,signed long long src); -unsigned int fmt_ulonglong(char *dest,unsigned long long src); -unsigned int fmt_xlonglong(char *dest,unsigned long long src); +size_t fmt_longlong(char *dest,signed long long src); +size_t fmt_ulonglong(char *dest,unsigned long long src); +size_t fmt_xlonglong(char *dest,unsigned long long src); #define fmt_uint(dest,src) fmt_ulong(dest,src) #define fmt_int(dest,src) fmt_long(dest,src) @@ -40,50 +42,50 @@ unsigned int fmt_xlonglong(char *dest,unsigned long long src); /* Like fmt_ulong, but prepend '0' while length is smaller than padto. * Does not truncate! */ -unsigned int fmt_ulong0(char *,unsigned long src,unsigned int padto); +size_t fmt_ulong0(char *,unsigned long src,size_t padto); #define fmt_uint0(buf,src,padto) fmt_ulong0(buf,src,padto) /* convert src double 1.7 to ASCII '1','.','7', return length. * If dest is not NULL, write result to dest */ -unsigned int fmt_double(char *dest, double d,int max,int prec); +size_t fmt_double(char *dest, double d,int max,int prec); /* if src is negative, write '-' and return 1. * if src is positive, write '+' and return 1. * otherwise return 0 */ -unsigned int fmt_plusminus(char *dest,int src); +size_t fmt_plusminus(char *dest,int src); /* if src is negative, write '-' and return 1. * otherwise return 0. */ -unsigned int fmt_minus(char *dest,int src); +size_t fmt_minus(char *dest,int src); /* copy str to dest until \0 byte, return number of copied bytes. */ -unsigned long fmt_str(char *dest,const char *src); +size_t fmt_str(char *dest,const char *src); /* copy str to dest until \0 byte or limit bytes copied. * return number of copied bytes. */ -unsigned long fmt_strn(char *dest,const char *src,unsigned long limit); +size_t fmt_strn(char *dest,const char *src,size_t limit); /* "foo" -> " foo" * write padlen-srclen spaces, if that is >= 0. Then copy srclen * characters from src. Truncate only if total length is larger than * maxlen. Return number of characters written. */ -unsigned long fmt_pad(char* dest,const char* src,unsigned long srclen,unsigned long padlen,unsigned long maxlen); +size_t fmt_pad(char* dest,const char* src,size_t srclen,size_t padlen,size_t maxlen); /* "foo" -> "foo " * append padlen-srclen spaces after dest, if that is >= 0. Truncate * only if total length is larger than maxlen. Return number of * characters written. */ -unsigned long fmt_fill(char* dest,unsigned long srclen,unsigned long padlen,unsigned long maxlen); +size_t fmt_fill(char* dest,size_t srclen,size_t padlen,size_t maxlen); /* 1 -> "1", 4900 -> "4.9k", 2300000 -> "2.3M" */ -unsigned int fmt_human(char* dest,unsigned long long l); +size_t fmt_human(char* dest,unsigned long long l); /* 1 -> "1", 4900 -> "4.8k", 2300000 -> "2.2M" */ -unsigned int fmt_humank(char* dest,unsigned long long l); +size_t fmt_humank(char* dest,unsigned long long l); /* "Sun, 06 Nov 1994 08:49:37 GMT" */ -unsigned int fmt_httpdate(char* dest,time_t t); +size_t fmt_httpdate(char* dest,time_t t); /* internal functions, may be independently useful */ char fmt_tohex(char c); diff --git a/fmt/fmt_8long.3 b/fmt/fmt_8long.3 index e068f2d..f898738 100644 --- a/fmt/fmt_8long.3 +++ b/fmt/fmt_8long.3 @@ -4,7 +4,7 @@ fmt_8long \- write an octal ASCII representation of an unsigned long integer .SH SYNTAX .B #include -unsigned int \fBfmt_8long\fP(char *\fIdest\fR,unsigned long \fIsource\fR); +size_t \fBfmt_8long\fP(char *\fIdest\fR,size_t \fIsource\fR); .SH DESCRIPTION fmt_8long writes an ASCII representation ('0' to '7', base 8) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_8long.c b/fmt/fmt_8long.c index 66324e8..7660a6a 100644 --- a/fmt/fmt_8long.c +++ b/fmt/fmt_8long.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_8long(char *dest,unsigned long i) { +size_t fmt_8long(char *dest,unsigned long i) { register unsigned long len,tmp; /* first count the number of bytes needed */ for (len=1, tmp=i; tmp>7; ++len) tmp>>=3; diff --git a/fmt/fmt_8longlong.c b/fmt/fmt_8longlong.c index b350242..027c97b 100644 --- a/fmt/fmt_8longlong.c +++ b/fmt/fmt_8longlong.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_8longlong(char *dest,unsigned long long i) { +size_t fmt_8longlong(char *dest,unsigned long long i) { register unsigned long len; unsigned long long tmp; /* first count the number of bytes needed */ diff --git a/fmt/fmt_double.3 b/fmt/fmt_double.3 index f243394..639389b 100644 --- a/fmt/fmt_double.3 +++ b/fmt/fmt_double.3 @@ -4,8 +4,8 @@ fmt_double \- write an ASCII representation of a double .SH SYNTAX .B #include -unsigned int \fBfmt_double\fP(char *\fIdest\fR,double \fId\fR,int -\fImaxlen\fR,int \fIprec\fR); +size_t \fBfmt_double\fP(char *\fIdest\fR,double \fId\fR,size_t +\fImaxlen\fR,size_t \fIprec\fR); .SH DESCRIPTION fmt_double writes an ASCII representation ('0' to '9', base 10) of \fId\fR to \fIdest\fR and returns the number of bytes written. No more diff --git a/fmt/fmt_double.c b/fmt/fmt_double.c index a080293..f6d4d5d 100644 --- a/fmt/fmt_double.c +++ b/fmt/fmt_double.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_double(char *dest, double d,int maxlen,int prec) { +size_t fmt_double(char *dest, double d,int maxlen,int prec) { union { double d; unsigned long long x; diff --git a/fmt/fmt_fill.3 b/fmt/fmt_fill.3 index 2c9651d..489a42e 100644 --- a/fmt/fmt_fill.3 +++ b/fmt/fmt_fill.3 @@ -4,9 +4,9 @@ fmt_fill \- append spaces to a string .SH SYNTAX .B #include -unsigned long \fBfmt_fill\fP(char *\fIdest\fR, - unsigned long \fIsrclen\fR, unsigned long \fIpadlen\fR, - unsigned long \fImaxlen\fR); +size_t \fBfmt_fill\fP(char *\fIdest\fR, + size_t \fIsrclen\fR, size_t \fIpadlen\fR, + size_t \fImaxlen\fR); .SH DESCRIPTION fmt_fill appends \fIpadlen\fR-\fIsrclen\fR spaces (if that number is positive) to \fIdest\fR (which holds \fIsrclen\fR bytes). It truncates diff --git a/fmt/fmt_fill.c b/fmt/fmt_fill.c index 48d31f7..b14bac7 100644 --- a/fmt/fmt_fill.c +++ b/fmt/fmt_fill.c @@ -4,7 +4,7 @@ * append padlen-srclen spaces after dest, if that is >= 0. Truncate * only if total length is larger than maxlen. Return number of * characters written. */ -unsigned long fmt_fill(char* dest,unsigned long srclen,unsigned long padlen,unsigned long maxlen) { +size_t fmt_fill(char* dest,size_t srclen,size_t padlen,size_t maxlen) { long todo; char* olddest=dest; char* max=dest+maxlen; diff --git a/fmt/fmt_httpdate.3 b/fmt/fmt_httpdate.3 index a51a65c..96a0ac7 100644 --- a/fmt/fmt_httpdate.3 +++ b/fmt/fmt_httpdate.3 @@ -4,7 +4,7 @@ fmt_httpdate \- write a date in ASCII as in the HTTP protocol .SH SYNTAX .B #include -unsigned int \fBfmt_httpdate\fP(char *\fIdest\fR,time_t \fIsource\fR); +size_t \fBfmt_httpdate\fP(char *\fIdest\fR,time_t \fIsource\fR); .SH DESCRIPTION fmt_httpdate writes a date in ASCII representation as the HTTP protocol defines it: "Sun, 06 Nov 1994 08:49:37 GMT". diff --git a/fmt/fmt_httpdate.c b/fmt/fmt_httpdate.c index efa7960..ba99dde 100644 --- a/fmt/fmt_httpdate.c +++ b/fmt/fmt_httpdate.c @@ -8,11 +8,11 @@ static unsigned int fmt_2digits(char* dest,int i) { return 2; } -unsigned int fmt_httpdate(char* dest,time_t t) { +size_t fmt_httpdate(char* dest,time_t t) { static const char days[] = "SunMonTueWedThuFriSat"; static const char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; struct tm* x=gmtime(&t); - int i; + size_t i; if (dest==0) return 29; /* "Sun, 06 Nov 1994 08:49:37 GMT" */ diff --git a/fmt/fmt_human.3 b/fmt/fmt_human.3 index 9934637..dd5a6dd 100644 --- a/fmt/fmt_human.3 +++ b/fmt/fmt_human.3 @@ -4,7 +4,7 @@ fmt_human \- write a human readable ASCII representation of a long integer .SH SYNTAX .B #include -unsigned int \fBfmt_human\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); +size_t \fBfmt_human\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); .SH DESCRIPTION fmt_human writes a human readable ASCII representation of \fIsource\fR to \fIdest\fR and returns the number of bytes written. The result diff --git a/fmt/fmt_human.c b/fmt/fmt_human.c index 775b108..585ed9e 100644 --- a/fmt/fmt_human.c +++ b/fmt/fmt_human.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_human(char* dest,unsigned long long l) { +size_t fmt_human(char* dest,unsigned long long l) { char unit; int i; if (l<1000) return fmt_ulong(dest,l); diff --git a/fmt/fmt_humank.3 b/fmt/fmt_humank.3 index 5766ccf..59ea888 100644 --- a/fmt/fmt_humank.3 +++ b/fmt/fmt_humank.3 @@ -4,7 +4,7 @@ fmt_humank \- write a human readable ASCII representation of a long integer .SH SYNTAX .B #include -unsigned int \fBfmt_humank\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); +size_t \fBfmt_humank\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); .SH DESCRIPTION fmt_humank writes a human readable ASCII representation of \fIsource\fR to \fIdest\fR and returns the number of bytes written. The result diff --git a/fmt/fmt_humank.c b/fmt/fmt_humank.c index 70cead8..7b398a0 100644 --- a/fmt/fmt_humank.c +++ b/fmt/fmt_humank.c @@ -1,8 +1,8 @@ #include "fmt.h" -unsigned int fmt_humank(char* dest,unsigned long long l) { +size_t fmt_humank(char* dest,unsigned long long l) { char unit; - int i; + size_t i; if (l<1000) return fmt_ulong(dest,l); if (l>1024*1024*1024*1024ull) { l=(l+(1024*1024*1024*1024ull/20))/(1024*1024*1024*1024ull/10); diff --git a/fmt/fmt_long.3 b/fmt/fmt_long.3 index c58c509..8272683 100644 --- a/fmt/fmt_long.3 +++ b/fmt/fmt_long.3 @@ -4,7 +4,7 @@ fmt_long \- write an ASCII representation of a long integer .SH SYNTAX .B #include -unsigned int \fBfmt_long\fP(char *\fIdest\fR,long \fIsource\fR); +size_t \fBfmt_long\fP(char *\fIdest\fR,long \fIsource\fR); .SH DESCRIPTION fmt_long writes an ASCII representation ('-' and '0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_long.c b/fmt/fmt_long.c index d7ff0f7..f5c1d25 100644 --- a/fmt/fmt_long.c +++ b/fmt/fmt_long.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_long(char *dest,long int i) { +size_t fmt_long(char *dest,long int i) { if (i<0) { if (dest) *dest++='-'; return fmt_ulong(dest,-i)+1; diff --git a/fmt/fmt_longlong.3 b/fmt/fmt_longlong.3 index 1b6c796..a7a71cb 100644 --- a/fmt/fmt_longlong.3 +++ b/fmt/fmt_longlong.3 @@ -4,7 +4,7 @@ fmt_longlong \- write an ASCII representation of a long long integer .SH SYNTAX .B #include -unsigned int \fBfmt_longlong\fP(char *\fIdest\fR,long long \fIsource\fR); +size_t \fBfmt_longlong\fP(char *\fIdest\fR,long long \fIsource\fR); .SH DESCRIPTION fmt_longlong writes an ASCII representation ('-' and '0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_longlong.c b/fmt/fmt_longlong.c index 543afc4..d45d866 100644 --- a/fmt/fmt_longlong.c +++ b/fmt/fmt_longlong.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_longlong(char *dest,signed long long int i) { +size_t fmt_longlong(char *dest,signed long long int i) { if (i<0) { if (dest) *dest++='-'; return fmt_ulonglong(dest,-i)+1; diff --git a/fmt/fmt_minus.3 b/fmt/fmt_minus.3 index 2c439d6..4e963ac 100644 --- a/fmt/fmt_minus.3 +++ b/fmt/fmt_minus.3 @@ -4,7 +4,7 @@ fmt_minus \- write '-' for negative integers .SH SYNTAX .B #include -unsigned int \fBfmt_minus\fP(char *\fIdest\fR,signed int \fIsource\fR); +size_t \fBfmt_minus\fP(char *\fIdest\fR,signed int \fIsource\fR); .SH DESCRIPTION fmt_minus writes '-' if \fIsource\fR is negative, nothing otherwise. It returns the number of bytes written. diff --git a/fmt/fmt_minus.c b/fmt/fmt_minus.c index a227e39..af58369 100644 --- a/fmt/fmt_minus.c +++ b/fmt/fmt_minus.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_minus(char *dest,int i) { +size_t fmt_minus(char *dest,int i) { if (i<0) { if (dest) *dest='-'; return 1; diff --git a/fmt/fmt_pad.3 b/fmt/fmt_pad.3 index 66e6fd1..cf185c8 100644 --- a/fmt/fmt_pad.3 +++ b/fmt/fmt_pad.3 @@ -4,9 +4,9 @@ fmt_pad \- pad a string with spaces. .SH SYNTAX .B #include -unsigned long \fBfmt_pad\fP(char *\fIdest\fR, const char *\fIsource\fR, - unsigned long \fIsrclen\fR, unsigned long \fIpadlen\fR, - unsigned long \fImaxlen\fR); +size_t \fBfmt_pad\fP(char *\fIdest\fR, const char *\fIsource\fR, + size_t \fIsrclen\fR, size_t \fIpadlen\fR, + size_t \fImaxlen\fR); .SH DESCRIPTION fmt_pad writes \fIpadlen\fR-\fIsrclen\fR spaces (if that number is positive) and then \fIsrclen\fR characters from \fIsource\fR. It diff --git a/fmt/fmt_pad.c b/fmt/fmt_pad.c index b54a6b7..27afeef 100644 --- a/fmt/fmt_pad.c +++ b/fmt/fmt_pad.c @@ -4,7 +4,7 @@ * write padlen-srclen spaces, if that is >= 0. Then copy srclen * characters from src. Truncate only if total length is larger than * maxlen. Return number of characters written. */ -unsigned long fmt_pad(char* dest,const char* src,unsigned long srclen,unsigned long padlen,unsigned long maxlen) { +size_t fmt_pad(char* dest,const char* src,size_t srclen,size_t padlen,size_t maxlen) { long todo; char* olddest=dest; char* max=dest+maxlen; diff --git a/fmt/fmt_plusminus.3 b/fmt/fmt_plusminus.3 index de18c2b..c4ef5a8 100644 --- a/fmt/fmt_plusminus.3 +++ b/fmt/fmt_plusminus.3 @@ -4,7 +4,7 @@ fmt_plusminus \- write '+' or '-' .SH SYNTAX .B #include -unsigned int \fBfmt_plusminus\fP(char *\fIdest\fR,signed int \fIsource\fR); +size_t \fBfmt_plusminus\fP(char *\fIdest\fR,signed int \fIsource\fR); .SH DESCRIPTION fmt_plusminus writes '-' to \fIdest\fR if \fIsource\fR is negative, '+' if \fIsource\fR is positive, nothing otherwise. It returns the number diff --git a/fmt/fmt_plusminus.c b/fmt/fmt_plusminus.c index 02e87b8..9fc722a 100644 --- a/fmt/fmt_plusminus.c +++ b/fmt/fmt_plusminus.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_plusminus(char *dest,int i) { +size_t fmt_plusminus(char *dest,int i) { if (i) { if (dest) *dest=(i>=0?'+':'-'); return 1; diff --git a/fmt/fmt_str.3 b/fmt/fmt_str.3 index 32f2651..dbaa69b 100644 --- a/fmt/fmt_str.3 +++ b/fmt/fmt_str.3 @@ -4,7 +4,7 @@ fmt_str \- write an ASCII string .SH SYNTAX .B #include -unsigned long \fBfmt_str\fP(char *\fIdest\fR,const char *\fIsource\fR); +size_t \fBfmt_str\fP(char *\fIdest\fR,const char *\fIsource\fR); .SH DESCRIPTION fmt_str copies all leading nonzero bytes from \fIsource\fR to \fIdest\fR and returns the number of bytes it copied. diff --git a/fmt/fmt_str.c b/fmt/fmt_str.c index dbbda7e..363e651 100644 --- a/fmt/fmt_str.c +++ b/fmt/fmt_str.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned long fmt_str(char *out,const char *in) { +size_t fmt_str(char *out,const char *in) { register char* s=out; register const char* t=in; for (;;) { diff --git a/fmt/fmt_strn.3 b/fmt/fmt_strn.3 index 7abea89..9f00961 100644 --- a/fmt/fmt_strn.3 +++ b/fmt/fmt_strn.3 @@ -4,8 +4,8 @@ fmt_strn \- write an ASCII string .SH SYNTAX .B #include -unsigned long \fBfmt_strn\fP(char *\fIdest\fR,const char *\fIsource\fR, - unsigned long maxlen); +size_t \fBfmt_strn\fP(char *\fIdest\fR,const char *\fIsource\fR, + size_t \fImaxlen\fR); .SH DESCRIPTION fmt_str copies at most \fImaxlen\fR leading nonzero bytes from \fIsource\fR to \fIdest\fR and returns the number of bytes it copied. diff --git a/fmt/fmt_strn.c b/fmt/fmt_strn.c index cfb49bf..b0cc0c4 100644 --- a/fmt/fmt_strn.c +++ b/fmt/fmt_strn.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned long fmt_strn(char *out,const char *in,unsigned long limit) { +size_t fmt_strn(char *out,const char *in,size_t limit) { register char* s=out; register const char* t=in; register const char* u=in+limit; diff --git a/fmt/fmt_uint.3 b/fmt/fmt_uint.3 index 155b4a5..b38a712 100644 --- a/fmt/fmt_uint.3 +++ b/fmt/fmt_uint.3 @@ -4,7 +4,7 @@ fmt_uint \- write an ASCII representation of an unsigned integer .SH SYNTAX .B #include -unsigned int \fBfmt_uint\fP(char *\fIdest\fR,unsigned int \fIsource\fR); +size_t \fBfmt_uint\fP(char *\fIdest\fR,unsigned int \fIsource\fR); .SH DESCRIPTION fmt_uint writes an ASCII representation ('0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_uint0.3 b/fmt/fmt_uint0.3 index f9b2fa8..3096b75 100644 --- a/fmt/fmt_uint0.3 +++ b/fmt/fmt_uint0.3 @@ -4,8 +4,8 @@ fmt_uint0 \- write a zero-padded ASCII representation of an unsigned integer .SH SYNTAX .B #include -unsigned int \fBfmt_uint0\fP(char *\fIdest\fR,unsigned int \fIsource\fR, - unsigned int \fIn\fR); +size_t \fBfmt_uint0\fP(char *\fIdest\fR,unsigned int \fIsource\fR, + size_t \fIn\fR); .SH DESCRIPTION fmt_uint0 writes an ASCII representation ('0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_ulong.3 b/fmt/fmt_ulong.3 index 4baddaf..325b630 100644 --- a/fmt/fmt_ulong.3 +++ b/fmt/fmt_ulong.3 @@ -4,7 +4,7 @@ fmt_ulong \- write an ASCII representation of an unsigned long integer .SH SYNTAX .B #include -unsigned int \fBfmt_ulong\fP(char *\fIdest\fR,unsigned long \fIsource\fR); +size_t \fBfmt_ulong\fP(char *\fIdest\fR,unsigned long \fIsource\fR); .SH DESCRIPTION fmt_ulong writes an ASCII representation ('0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_ulong.c b/fmt/fmt_ulong.c index 712e502..46cbcf2 100644 --- a/fmt/fmt_ulong.c +++ b/fmt/fmt_ulong.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_ulong(char *dest,unsigned long i) { +size_t fmt_ulong(char *dest,unsigned long i) { register unsigned long len,tmp,len2; /* first count the number of bytes needed */ for (len=1, tmp=i; tmp>9; ++len) tmp/=10; diff --git a/fmt/fmt_ulong0.3 b/fmt/fmt_ulong0.3 index e9cf03f..be344ca 100644 --- a/fmt/fmt_ulong0.3 +++ b/fmt/fmt_ulong0.3 @@ -4,8 +4,8 @@ fmt_ulong0 \- write a zero-padded ASCII representation of an unsigned long integ .SH SYNTAX .B #include -unsigned int \fBfmt_ulong0\fP(char *\fIdest\fR, unsigned long \fIsource\fR, - unsigned int \fIn\fR); +size_t \fBfmt_ulong0\fP(char *\fIdest\fR, unsigned long \fIsource\fR, + size_t \fIn\fR); .SH DESCRIPTION fmt_ulong0 writes an ASCII representation ('0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_ulong0.c b/fmt/fmt_ulong0.c index efa2157..575e23f 100644 --- a/fmt/fmt_ulong0.c +++ b/fmt/fmt_ulong0.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_ulong0(char *dest,unsigned long i,unsigned int pad) { +size_t fmt_ulong0(char *dest,unsigned long i,size_t pad) { register unsigned int len; register unsigned long tmp; /* first count the number of bytes needed */ diff --git a/fmt/fmt_ulonglong.3 b/fmt/fmt_ulonglong.3 index f766895..794ccd4 100644 --- a/fmt/fmt_ulonglong.3 +++ b/fmt/fmt_ulonglong.3 @@ -4,7 +4,7 @@ fmt_ulonglong \- write an ASCII representation of an unsigned long long integer .SH SYNTAX .B #include -unsigned int \fBfmt_ulonglong\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); +size_t \fBfmt_ulonglong\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); .SH DESCRIPTION fmt_ulonglong writes an ASCII representation ('0' to '9', base 10) of \fIsource\fR to \fIdest\fR and returns the number of bytes written. diff --git a/fmt/fmt_ulonglong.c b/fmt/fmt_ulonglong.c index c06661d..be93e45 100644 --- a/fmt/fmt_ulonglong.c +++ b/fmt/fmt_ulonglong.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_ulonglong(char *dest,unsigned long long int i) { +size_t fmt_ulonglong(char *dest,unsigned long long int i) { register unsigned long len; unsigned long long tmp,len2; /* first count the number of bytes needed */ diff --git a/fmt/fmt_xlong.3 b/fmt/fmt_xlong.3 index d82f1a8..e2178f6 100644 --- a/fmt/fmt_xlong.3 +++ b/fmt/fmt_xlong.3 @@ -4,7 +4,7 @@ fmt_xlong \- write a hexadecimal ASCII representation of an unsigned long intege .SH SYNTAX .B #include -unsigned int \fBfmt_xlong\fP(char *\fIdest\fR,unsigned long \fIsource\fR); +size_t \fBfmt_xlong\fP(char *\fIdest\fR,unsigned long \fIsource\fR); .SH DESCRIPTION fmt_xlong writes an ASCII representation ('0' to '9' and 'a' to 'f', base 16) of \fIsource\fR to \fIdest\fR and returns the number of bytes diff --git a/fmt/fmt_xlong.c b/fmt/fmt_xlong.c index 5a95c58..6612722 100644 --- a/fmt/fmt_xlong.c +++ b/fmt/fmt_xlong.c @@ -5,7 +5,7 @@ static inline char tohex(char c) { return c>=10?c-10+'a':c+'0'; } -unsigned int fmt_xlong(char *dest,unsigned long i) { +size_t fmt_xlong(char *dest,unsigned long i) { register unsigned long len,tmp; /* first count the number of bytes needed */ for (len=1, tmp=i; tmp>15; ++len) tmp>>=4; diff --git a/fmt/fmt_xlonglong.3 b/fmt/fmt_xlonglong.3 index 42554f6..5c4526b 100644 --- a/fmt/fmt_xlonglong.3 +++ b/fmt/fmt_xlonglong.3 @@ -4,7 +4,7 @@ fmt_xlonglong \- write a hexadecimal ASCII representation of an unsigned long lo .SH SYNTAX .B #include -unsigned int \fBfmt_xlonglong\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); +size_t \fBfmt_xlonglong\fP(char *\fIdest\fR,unsigned long long \fIsource\fR); .SH DESCRIPTION fmt_xlonglong writes an ASCII representation ('0' to '9' and 'a' to 'f', base 16) of \fIsource\fR to \fIdest\fR and returns the number of bytes diff --git a/fmt/fmt_xlonglong.c b/fmt/fmt_xlonglong.c index e925c5a..ff9e9e8 100644 --- a/fmt/fmt_xlonglong.c +++ b/fmt/fmt_xlonglong.c @@ -1,6 +1,6 @@ #include "fmt.h" -unsigned int fmt_xlonglong(char *dest,unsigned long long i) { +size_t fmt_xlonglong(char *dest,unsigned long long i) { int tmp=0; if (i>>32) { tmp=fmt_xlong(dest,i>>32); diff --git a/mmap.h b/mmap.h index 34cccc1..4ed3161 100644 --- a/mmap.h +++ b/mmap.h @@ -1,20 +1,22 @@ #ifndef MMAP_H #define MMAP_H +#include + /* open file for reading, mmap whole file, close file, write length of * map in filesize and return pointer to map. */ -char* mmap_read(const char *filename,unsigned long* filesize); +char* mmap_read(const char *filename,size_t* filesize); /* open file for writing, mmap whole file privately (copy on write), * close file, write length of map in filesize and return pointer to * map. */ -char* mmap_private(const char *filename,unsigned long* filesize); +char* mmap_private(const char *filename,size_t* filesize); /* open file for writing, mmap whole file shared, close file, write * length of map in filesize and return pointer to map. */ -char* mmap_shared(const char *filename,unsigned long* filesize); +char* mmap_shared(const char *filename,size_t* filesize); /* unmap a mapped region */ -int mmap_unmap(char* mapped,unsigned long maplen); +int mmap_unmap(char* mapped,size_t maplen); #endif diff --git a/mmap/mmap_private.3 b/mmap/mmap_private.3 index 6e2273e..19b2efc 100644 --- a/mmap/mmap_private.3 +++ b/mmap/mmap_private.3 @@ -4,7 +4,7 @@ mmap_private \- memory map a file for reading and writing .SH SYNTAX .B #include -extern char* \fBmmap_private\fP(const char* \fIfilename\fR,unsigned long* \fIfilesize\fR); +char* \fBmmap_private\fP(const char* \fIfilename\fR,size_t* \fIfilesize\fR); .SH DESCRIPTION mmap_private opens \fIfilename\fR for reading and writing, maps the whole file into memory, closes the file, writes the length of the file diff --git a/mmap/mmap_private.c b/mmap/mmap_private.c index 09a8b2a..3d6e33c 100644 --- a/mmap/mmap_private.c +++ b/mmap/mmap_private.c @@ -8,7 +8,7 @@ #include "open.h" #include "mmap.h" -char* mmap_private(const char* filename,unsigned long* filesize) { +char* mmap_private(const char* filename,size_t * filesize) { #ifdef __MINGW32__ HANDLE fd,m; char* map; diff --git a/mmap/mmap_read.3 b/mmap/mmap_read.3 index d5363bb..bcb5653 100644 --- a/mmap/mmap_read.3 +++ b/mmap/mmap_read.3 @@ -4,7 +4,7 @@ mmap_read \- memory map a file for reading .SH SYNTAX .B #include -extern char* \fBmmap_read\fP(const char* \fIfilename\fR,unsigned long* \fIfilesize\fR); +char* \fBmmap_read\fP(const char* \fIfilename\fR,size_t* \fIfilesize\fR); .SH DESCRIPTION mmap_read opens \fIfilename\fR for reading, maps the whole file into memory, closes the file, writes the length of the file to \fIfilesize\fR diff --git a/mmap/mmap_read.c b/mmap/mmap_read.c index 3f9cd29..d3ea7f8 100644 --- a/mmap/mmap_read.c +++ b/mmap/mmap_read.c @@ -8,7 +8,7 @@ #include "open.h" #include "mmap.h" -extern char* mmap_read(const char* filename,unsigned long* filesize) { +extern char* mmap_read(const char* filename,size_t * filesize) { #ifdef __MINGW32__ HANDLE fd,m; char* map; diff --git a/mmap/mmap_shared.3 b/mmap/mmap_shared.3 index 7fb9a8b..87a480d 100644 --- a/mmap/mmap_shared.3 +++ b/mmap/mmap_shared.3 @@ -4,7 +4,7 @@ mmap_shared \- memory map a file for reading and writing .SH SYNTAX .B #include -extern char* \fBmmap_shared\fP(const char* \fIfilename\fR,unsigned long* \fIfilesize\fR); +char* \fBmmap_shared\fP(const char* \fIfilename\fR,size_t* \fIfilesize\fR); .SH DESCRIPTION mmap_shared opens \fIfilename\fR for reading and writing, maps the whole file into memory, closes the file, writes the length of the file diff --git a/mmap/mmap_shared.c b/mmap/mmap_shared.c index 96ff0d7..205f122 100644 --- a/mmap/mmap_shared.c +++ b/mmap/mmap_shared.c @@ -8,7 +8,7 @@ #include "open.h" #include "mmap.h" -extern char* mmap_shared(const char* filename,unsigned long* filesize) { +extern char* mmap_shared(const char* filename,size_t * filesize) { #ifdef __MINGW32__ HANDLE fd,m; char* map; diff --git a/mmap/mmap_unmap.c b/mmap/mmap_unmap.c index cc638ed..dd0030f 100644 --- a/mmap/mmap_unmap.c +++ b/mmap/mmap_unmap.c @@ -8,7 +8,7 @@ #include "open.h" #include "mmap.h" -int mmap_unmap(char* mapped,unsigned long maplen) { +int mmap_unmap(char* mapped,size_t maplen) { #ifdef __MINGW32__ (void)maplen; return UnmapViewOfFile(mapped)?0:-1; diff --git a/open/open_append.3 b/open/open_append.3 index cfa4f3e..c8049a2 100644 --- a/open/open_append.3 +++ b/open/open_append.3 @@ -4,7 +4,7 @@ open_append \- open a file for appending .SH SYNTAX .B #include -extern int \fBopen_append\fP(const char *\fIfilename\fR); +int \fBopen_append\fP(const char *\fIfilename\fR); .SH DESCRIPTION open_append opens the file \fIfilename\fR for appending write-only use and returns the file handle. If it does not exist, it will be created diff --git a/open/open_excl.3 b/open/open_excl.3 index 30304cb..7d91c88 100644 --- a/open/open_excl.3 +++ b/open/open_excl.3 @@ -4,7 +4,7 @@ open_excl \- open a file for exclusive writing .SH SYNTAX .B #include -extern int \fBopen_excl\fP(const char *\fIfilename\fR); +int \fBopen_excl\fP(const char *\fIfilename\fR); .SH DESCRIPTION open_excl opens the file \fIfilename\fR for writing and returns the file handle. The file may not exist before the call to \fBopen_excl\fR. The diff --git a/open/open_read.3 b/open/open_read.3 index f26b735..f315153 100644 --- a/open/open_read.3 +++ b/open/open_read.3 @@ -4,7 +4,7 @@ open_read \- open a file for reading .SH SYNTAX .B #include -extern int \fBopen_read\fP(const char *\fIfilename\fR); +int \fBopen_read\fP(const char *\fIfilename\fR); .SH DESCRIPTION open_read opens the file \fIfilename\fR for reading and returns the file handle. If there was an error opening the file, open_read returns -1 diff --git a/open/open_rw.3 b/open/open_rw.3 index 4bf1d27..af85f77 100644 --- a/open/open_rw.3 +++ b/open/open_rw.3 @@ -4,7 +4,7 @@ open_rw \- open a file for reading and writing .SH SYNTAX .B #include -extern int \fBopen_rw\fP(const char *\fIfilename\fR); +int \fBopen_rw\fP(const char *\fIfilename\fR); .SH DESCRIPTION open_rw opens the file \fIfilename\fR for reading and writing use and returns the file handle. If the file does not exist, it will be created diff --git a/open/open_trunc.3 b/open/open_trunc.3 index 3ee9b48..f735e35 100644 --- a/open/open_trunc.3 +++ b/open/open_trunc.3 @@ -4,7 +4,7 @@ open_trunc \- open a file for writing .SH SYNTAX .B #include -extern int \fBopen_trunc\fP(const char *\fIfilename\fR); +int \fBopen_trunc\fP(const char *\fIfilename\fR); .SH DESCRIPTION open_trunc opens the file \fIfilename\fR for write-only use and returns the file handle. If the file exists, it will be truncated diff --git a/open/open_write.3 b/open/open_write.3 index cd1c2e8..e3c8637 100644 --- a/open/open_write.3 +++ b/open/open_write.3 @@ -4,7 +4,7 @@ open_write \- open a file for writing .SH SYNTAX .B #include -extern int \fBopen_write\fP(const char *\fIfilename\fR); +int \fBopen_write\fP(const char *\fIfilename\fR); .SH DESCRIPTION open_write opens the file \fIfilename\fR for write-only use and returns the file handle. If the file does not exist, it will be created with diff --git a/open/openreadclose.3 b/open/openreadclose.3 index eb48992..600410b 100644 --- a/open/openreadclose.3 +++ b/open/openreadclose.3 @@ -4,8 +4,8 @@ openreadclose \- read a whole file into a stralloc .SH SYNTAX .B #include -extern int \fBopenreadclose\fP(const char *\fIfilename\fR, - stralloc* \fIsa\fR,unsigned int \fIbufsize\fR); +int \fBopenreadclose\fP(const char *\fIfilename\fR, + stralloc* \fIsa\fR,size_t \fIbufsize\fR); .SH DESCRIPTION openreadclose opens the file \fIfilename\fR for reading and reads the whole content into the stralloc \fIsa\fR. The file is read in chunks of diff --git a/open/openreadclose.c b/open/openreadclose.c index 6c881f9..93594f3 100644 --- a/open/openreadclose.c +++ b/open/openreadclose.c @@ -3,7 +3,7 @@ #include "readclose.h" #include "openreadclose.h" -int openreadclose(const char *fn,stralloc *sa,unsigned int bufsize) +int openreadclose(const char *fn,stralloc *sa,size_t bufsize) { int fd; fd = open_read(fn); @@ -12,5 +12,5 @@ int openreadclose(const char *fn,stralloc *sa,unsigned int bufsize) return -1; } if (readclose(fd,sa,bufsize) == -1) return -1; - return 1; + return 0; } diff --git a/open/readclose.3 b/open/readclose.3 index 3e3cc14..5399d96 100644 --- a/open/readclose.3 +++ b/open/readclose.3 @@ -4,7 +4,7 @@ readclose \- read a whole file into a stralloc .SH SYNTAX .B #include -int \fBreadclose\fP(int fd,stralloc* \fIsa\fR,unsigned int \fIbufsize\fR); +int \fBreadclose\fP(int fd,stralloc* \fIsa\fR,size_t \fIbufsize\fR); .SH DESCRIPTION readclose reads the whole content into the stralloc \fIsa\fR. The file is read in chunks of diff --git a/open/readclose.c b/open/readclose.c index 9ca110b..c798773 100644 --- a/open/readclose.c +++ b/open/readclose.c @@ -2,7 +2,7 @@ #include #include "readclose.h" -int readclose_append(int fd,stralloc *sa,unsigned int bufsize) +int readclose_append(int fd,stralloc *sa,size_t bufsize) { int r; for (;;) { @@ -14,7 +14,7 @@ int readclose_append(int fd,stralloc *sa,unsigned int bufsize) } } -int readclose(int fd,stralloc *sa,unsigned int bufsize) +int readclose(int fd,stralloc *sa,size_t bufsize) { if (!stralloc_copys(sa,"")) { close(fd); return -1; } return readclose_append(fd,sa,bufsize); diff --git a/open/readclose_append.3 b/open/readclose_append.3 index aa46c65..2b4ad4e 100644 --- a/open/readclose_append.3 +++ b/open/readclose_append.3 @@ -5,7 +5,7 @@ readclose_append \- read a whole file into a stralloc .B #include int \fBreadclose_append\fP(int fd,stralloc* \fIsa\fR, - unsigned int \fIbufsize\fR); + size_t \fIbufsize\fR); .SH DESCRIPTION readclose_append reads the whole content into the stralloc \fIsa\fR, appending it to the existing diff --git a/openreadclose.h b/openreadclose.h index 8867f9f..d9ed394 100644 --- a/openreadclose.h +++ b/openreadclose.h @@ -3,6 +3,6 @@ #include "stralloc.h" -int openreadclose(const char *filename,stralloc *buf,unsigned int initiallength); +int openreadclose(const char *filename,stralloc *buf,size_t initiallength); #endif diff --git a/readclose.h b/readclose.h index ef009d5..cceb301 100644 --- a/readclose.h +++ b/readclose.h @@ -3,7 +3,7 @@ #include "stralloc.h" -int readclose_append(int fd,stralloc *buf,unsigned int initlen); -int readclose(int fd,stralloc *buf,unsigned int initlen); +int readclose_append(int fd,stralloc *buf,size_t initlen); +int readclose(int fd,stralloc *buf,size_t initlen); #endif diff --git a/scan.h b/scan.h index 8bcc8d4..035e4d9 100644 --- a/scan.h +++ b/scan.h @@ -1,69 +1,68 @@ #ifndef SCAN_H #define SCAN_H +/* for size_t: */ +#include +/* for time_t: */ #include -#ifdef __dietlibc__ -#include -#endif - #ifndef __pure__ #define __pure__ #endif /* interpret src as ASCII decimal number, write number to dest and * return the number of bytes that were parsed */ -unsigned int scan_ulong(const char *src,unsigned long *dest); +size_t scan_ulong(const char *src,unsigned long *dest); /* interpret src as ASCII hexadecimal number, write number to dest and * return the number of bytes that were parsed */ -unsigned int scan_xlong(const char *src,unsigned long *dest); +size_t scan_xlong(const char *src,unsigned long *dest); /* interpret src as ASCII octal number, write number to dest and * return the number of bytes that were parsed */ -unsigned int scan_8long(const char *src,unsigned long *dest); +size_t scan_8long(const char *src,unsigned long *dest); /* interpret src as signed ASCII decimal number, write number to dest * and return the number of bytes that were parsed */ -unsigned int scan_long(const char *src,signed long *dest); +size_t scan_long(const char *src,signed long *dest); -unsigned int scan_longlong(const char *src,signed long long *dest); -unsigned int scan_ulonglong(const char *src,unsigned long long *dest); -unsigned int scan_xlonglong(const char *src,unsigned long long *dest); -unsigned int scan_8longlong(const char *src,unsigned long long *dest); +size_t scan_longlong(const char *src,signed long long *dest); +size_t scan_ulonglong(const char *src,unsigned long long *dest); +size_t scan_xlonglong(const char *src,unsigned long long *dest); +size_t scan_8longlong(const char *src,unsigned long long *dest); -unsigned int scan_uint(const char *src,unsigned int *dest); -unsigned int scan_xint(const char *src,unsigned int *dest); -unsigned int scan_8int(const char *src,unsigned int *dest); -unsigned int scan_int(const char *src,signed int *dest); +size_t scan_uint(const char *src,unsigned int *dest); +size_t scan_xint(const char *src,unsigned int *dest); +size_t scan_8int(const char *src,unsigned int *dest); +size_t scan_int(const char *src,signed int *dest); -unsigned int scan_ushort(const char *src,unsigned short *dest); -unsigned int scan_xshort(const char *src,unsigned short *dest); -unsigned int scan_8short(const char *src,unsigned short *dest); -unsigned int scan_short(const char *src,signed short *dest); +size_t scan_ushort(const char *src,unsigned short *dest); +size_t scan_xshort(const char *src,unsigned short *dest); +size_t scan_8short(const char *src,unsigned short *dest); +size_t scan_short(const char *src,signed short *dest); /* interpret src as double precision floating point number, * write number to dest and return the number of bytes that were parsed */ -unsigned int scan_double(const char *in, double *dest); +size_t scan_double(const char *in, double *dest); /* if *src=='-', set *dest to -1 and return 1. * if *src=='+', set *dest to 1 and return 1. * otherwise set *dest to 1 return 0. */ -unsigned int scan_plusminus(const char *src,signed int *dest); +size_t scan_plusminus(const char *src,signed int *dest); /* return the highest integer n<=limit so that isspace(in[i]) for all 0<=i<=n */ -unsigned long scan_whitenskip(const char *in,unsigned long limit) __pure__; +size_t scan_whitenskip(const char *in,size_t limit) __pure__; /* return the highest integer n<=limit so that !isspace(in[i]) for all 0<=i<=n */ -unsigned long scan_nonwhitenskip(const char *in,unsigned long limit) __pure__; +size_t scan_nonwhitenskip(const char *in,size_t limit) __pure__; /* return the highest integer n<=limit so that in[i] is element of * charset (ASCIIZ string) for all 0<=i<=n */ -unsigned long scan_charsetnskip(const char *in,const char *charset,unsigned long limit) __pure__; +size_t scan_charsetnskip(const char *in,const char *charset,size_t limit) __pure__; /* return the highest integer n<=limit so that in[i] is not element of * charset (ASCIIZ string) for all 0<=i<=n */ -unsigned long scan_noncharsetnskip(const char *in,const char *charset,unsigned long limit) __pure__; +size_t scan_noncharsetnskip(const char *in,const char *charset,size_t limit) __pure__; /* try to parse ASCII GMT date; does not understand time zones. */ /* example dates: @@ -71,7 +70,7 @@ unsigned long scan_noncharsetnskip(const char *in,const char *charset,unsigned l * "Sunday, 06-Nov-94 08:49:37 GMT" * "Sun Nov 6 08:49:37 1994" */ -unsigned int scan_httpdate(const char *in,time_t *t) __pure__; +size_t scan_httpdate(const char *in,time_t *t) __pure__; /* a few internal function that might be useful independently */ /* convert from hex ASCII, return 0 to 15 for success or -1 for failure */ diff --git a/scan/scan_8int.3 b/scan/scan_8int.3 index 61fe010..585eedb 100644 --- a/scan/scan_8int.3 +++ b/scan/scan_8int.3 @@ -4,7 +4,7 @@ scan_8int \- parse an unsigned integer in octal ASCII representation .SH SYNTAX .B #include -int \fBscan_8int\fP(const char *\fIsrc\fR,int *\fIdest\fR); +size_t \fBscan_8int\fP(const char *\fIsrc\fR,int *\fIdest\fR); .SH DESCRIPTION scan_8int parses an unsigned integer in octal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_8int.c b/scan/scan_8int.c index f5390e0..dba3be4 100644 --- a/scan/scan_8int.c +++ b/scan/scan_8int.c @@ -1,8 +1,8 @@ #include "scan.h" -unsigned int scan_8int(const char* src,unsigned int* dest) { +size_t scan_8int(const char* src,unsigned int* dest) { unsigned long l; - register int len=scan_8long(src,&l); + size_t len=scan_8long(src,&l); *dest=l; return len; } diff --git a/scan/scan_8long.3 b/scan/scan_8long.3 index 53c5574..830d14b 100644 --- a/scan/scan_8long.3 +++ b/scan/scan_8long.3 @@ -4,7 +4,7 @@ scan_8long \- parse an unsigned long integer in octal ASCII representation .SH SYNTAX .B #include -int \fBscan_8long\fP(const char *\fIsrc\fR,unsigned long *\fIdest\fR); +size_t \fBscan_8long\fP(const char *\fIsrc\fR,unsigned long *\fIdest\fR); .SH DESCRIPTION scan_8long parses an unsigned long integer in octal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_8long.c b/scan/scan_8long.c index 1acb8f9..14136c8 100644 --- a/scan/scan_8long.c +++ b/scan/scan_8long.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_8long(const char *src,unsigned long *dest) { +size_t scan_8long(const char *src,unsigned long *dest) { register const char *tmp=src; register unsigned long l=0; register unsigned char c; diff --git a/scan/scan_8short.3 b/scan/scan_8short.3 index c363a5e..4f7ef66 100644 --- a/scan/scan_8short.3 +++ b/scan/scan_8short.3 @@ -4,7 +4,7 @@ scan_8short \- parse an unsigned short integer in octal ASCII representation .SH SYNTAX .B #include -int \fBscan_8short\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR); +size_t \fBscan_8short\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR); .SH DESCRIPTION scan_8short parses an unsigned short integer in octal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_8short.c b/scan/scan_8short.c index 5e9d4a1..b3cf0f3 100644 --- a/scan/scan_8short.c +++ b/scan/scan_8short.c @@ -1,8 +1,8 @@ #include "scan.h" -unsigned int scan_8short(const char* src,unsigned short* dest) { +size_t scan_8short(const char* src,unsigned short* dest) { unsigned long l; - register int len=scan_8long(src,&l); + size_t len=scan_8long(src,&l); *dest=l; return len; } diff --git a/scan/scan_charsetnskip.3 b/scan/scan_charsetnskip.3 index b0801b9..e041eb9 100644 --- a/scan/scan_charsetnskip.3 +++ b/scan/scan_charsetnskip.3 @@ -4,10 +4,12 @@ scan_charsetnskip \- skip characters from set .SH SYNTAX .B #include -long \fBscan_charsetnskip\fP(const char* \fIsrc\fR, const char* \fIcharset\fR, unsigned long* \fIlimit\fR); +size_t \fBscan_charsetnskip\fP(const char* \fIsrc\fR, const char* \fIcharset\fR, + size_t \fIlimit\fR); .SH DESCRIPTION scan_charsetnskip returns the length of the maximum prefix of \fIsrc\fR that consists solely of characters that occur in \fIcharset\fR (up to -and not including the \\0). +and not including the \\0). \fIsrc\fR is considered to end at \\0 or +after \fIlimit\fR characters. .SH "SEE ALSO" scan_noncharsetnskip(3) diff --git a/scan/scan_charsetnskip.c b/scan/scan_charsetnskip.c index fc80e42..2961732 100644 --- a/scan/scan_charsetnskip.c +++ b/scan/scan_charsetnskip.c @@ -1,7 +1,7 @@ #include "scan.h" #include -unsigned long scan_charsetnskip(const char *s,const char *charset,unsigned long limit) { +size_t scan_charsetnskip(const char *s,const char *charset,size_t limit) { register const char *t=s; register const char *u=t+limit; register const char* i; diff --git a/scan/scan_double.3 b/scan/scan_double.3 index 43b8ba1..c1ce7c6 100644 --- a/scan/scan_double.3 +++ b/scan/scan_double.3 @@ -4,7 +4,7 @@ scan_double \- parse a floating point number in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_double\fP(const char *\fIsrc\fR,double *\fIdest\fR); +size_t \fBscan_double\fP(const char *\fIsrc\fR,double *\fIdest\fR); .SH DESCRIPTION scan_double parses a floating point number in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_double.c b/scan/scan_double.c index 179ce60..1ccb5f8 100644 --- a/scan/scan_double.c +++ b/scan/scan_double.c @@ -6,7 +6,7 @@ static inline int isdigit(int c) { return (c>='0' && c<='9'); } #include #endif -unsigned int scan_double(const char *in, double *dest) { +size_t scan_double(const char *in, double *dest) { double d=0; register const char *c=in; char neg=0; diff --git a/scan/scan_httpdate.3 b/scan/scan_httpdate.3 index e14271d..4edd0e6 100644 --- a/scan/scan_httpdate.3 +++ b/scan/scan_httpdate.3 @@ -4,7 +4,7 @@ scan_httpdate \- parse a HTTP date .SH SYNTAX .B #include -int \fBscan_httpdate\fP(const char *\fIsrc\fR,time_t *\fIdest\fR); +size_t \fBscan_httpdate\fP(const char *\fIsrc\fR,time_t *\fIdest\fR); .SH DESCRIPTION scan_httpdate parses a date as defined in the HTTP standard into a time_t. It returns the number of bytes read from \fIsrc\fR (0 for parse diff --git a/scan/scan_httpdate.c b/scan/scan_httpdate.c index 2dd4d7c..0d641e1 100644 --- a/scan/scan_httpdate.c +++ b/scan/scan_httpdate.c @@ -21,7 +21,7 @@ static int parsetime(const char*c,struct tm* x) { return 0; } -unsigned int scan_httpdate(const char *in,time_t *t) { +size_t scan_httpdate(const char *in,time_t *t) { struct tm x; int i; unsigned long tmp; diff --git a/scan/scan_int.3 b/scan/scan_int.3 index 4dd8586..8e84e54 100644 --- a/scan/scan_int.3 +++ b/scan/scan_int.3 @@ -4,7 +4,7 @@ scan_int \- parse an integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_int\fP(const char *\fIsrc\fR,int *\fIdest\fR); +size_t \fBscan_int\fP(const char *\fIsrc\fR,int *\fIdest\fR); .SH DESCRIPTION scan_int parses an integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_int.c b/scan/scan_int.c index c4e8a10..137cf55 100644 --- a/scan/scan_int.c +++ b/scan/scan_int.c @@ -1,8 +1,8 @@ #include "scan.h" -unsigned int scan_int(const char* src,int* dest) { +size_t scan_int(const char* src,int* dest) { long l; - register int len=scan_long(src,&l); + size_t len=scan_long(src,&l); if (len) *dest=l; return len; } diff --git a/scan/scan_long.3 b/scan/scan_long.3 index a3d2d8b..085730c 100644 --- a/scan/scan_long.3 +++ b/scan/scan_long.3 @@ -4,7 +4,7 @@ scan_long \- parse an long integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_long\fP(const char *\fIsrc\fR,long *\fIdest\fR); +size_t \fBscan_long\fP(const char *\fIsrc\fR,long *\fIdest\fR); .SH DESCRIPTION scan_long parses a long integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_long.c b/scan/scan_long.c index 8f2148d..05801a9 100644 --- a/scan/scan_long.c +++ b/scan/scan_long.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_long(const char *src,long *dest) { +size_t scan_long(const char *src,long *dest) { register const char *tmp; register long int l; register unsigned char c; diff --git a/scan/scan_longlong.3 b/scan/scan_longlong.3 index b749e0d..7c03577 100644 --- a/scan/scan_longlong.3 +++ b/scan/scan_longlong.3 @@ -4,7 +4,7 @@ scan_longlong \- parse a long integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_longlong\fP(const char *\fIsrc\fR,long long *\fIdest\fR); +size_t \fBscan_longlong\fP(const char *\fIsrc\fR,long long *\fIdest\fR); .SH DESCRIPTION scan_longlong parses a long long integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_longlong.c b/scan/scan_longlong.c index 2d57328..c089ab3 100644 --- a/scan/scan_longlong.c +++ b/scan/scan_longlong.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_longlong(const char* src,signed long long* dest) { +size_t scan_longlong(const char* src,signed long long* dest) { unsigned int i,o; unsigned long long l; char c=src[0]; diff --git a/scan/scan_noncharsetnskip.3 b/scan/scan_noncharsetnskip.3 index a47c4cf..e4d9985 100644 --- a/scan/scan_noncharsetnskip.3 +++ b/scan/scan_noncharsetnskip.3 @@ -4,10 +4,13 @@ scan_noncharsetnskip \- skip characters not from set .SH SYNTAX .B #include -long \fBscan_noncharsetnskip\fP(const char* \fIsrc\fR, const char* \fIcharset\fR, unsigned long* \fIlimit\fR); +size_t \fBscan_noncharsetnskip\fP(const char* \fIsrc\fR, const char* \fIcharset\fR, + size_t \fIlimit\fR); .SH DESCRIPTION scan_noncharsetnskip returns the length of the maximum prefix of \fIsrc\fR that consists solely of characters that do not occur in \fIcharset\fR -(up to and not including the \\0). +(up to and not including the \\0). \fIsrc\fR is considered to end at +\\0 or after \fIlimit\fR characters. + .SH "SEE ALSO" scan_charsetnskip(3) diff --git a/scan/scan_noncharsetnskip.c b/scan/scan_noncharsetnskip.c index 7bac0e0..35acdb1 100644 --- a/scan/scan_noncharsetnskip.c +++ b/scan/scan_noncharsetnskip.c @@ -1,7 +1,7 @@ #include "scan.h" #include -unsigned long scan_noncharsetnskip(const char *s,const char *charset,unsigned long limit) { +size_t scan_noncharsetnskip(const char *s,const char *charset,size_t limit) { register const char *t=s; register const char *u=t+limit; register const char* i; diff --git a/scan/scan_nonwhitenskip.3 b/scan/scan_nonwhitenskip.3 index 1480bcb..236f31b 100644 --- a/scan/scan_nonwhitenskip.3 +++ b/scan/scan_nonwhitenskip.3 @@ -4,12 +4,15 @@ scan_nonwhitenskip \- skip non-whitespace .SH SYNTAX .B #include -long \fBscan_nonwhitenskip\fP(const char *\fIsrc\fR,unsigned long *\fIlimit\fR); +size_t \fBscan_nonwhitenskip\fP(const char *\fIsrc\fR,size_t \fIlimit\fR); .SH DESCRIPTION scan_nonwhitenskip returns the length of the maximum prefix of \fIsrc\fR that consists solely of non-whitespace characters as defined by \fB!isspace\fR. Normally, this is everything but ' ', '\\f', '\\n', '\\r', '\\t', '\\v'. + +\fIsrc\fR is considered to end at \\0 or after \fIlimit\fR characters. + .SH "SEE ALSO" scan_nonwhitenskip(3) diff --git a/scan/scan_nonwhitenskip.c b/scan/scan_nonwhitenskip.c index f183013..541b2e4 100644 --- a/scan/scan_nonwhitenskip.c +++ b/scan/scan_nonwhitenskip.c @@ -1,7 +1,7 @@ #include "scan.h" #include -unsigned long scan_nonwhitenskip(const char *s,unsigned long limit) { +size_t scan_nonwhitenskip(const char *s,size_t limit) { register const char *t=s; register const char *u=t+limit; while (t -int \fBscan_plusminus\fP(const char *\fIsrc\fR,int *\fIdest\fR); +size_t \fBscan_plusminus\fP(const char *\fIsrc\fR,int *\fIdest\fR); .SH DESCRIPTION scan_plusminus parses an ASCII '+' or '-' sign from \fIsrc\fR, sets \fIdest\fR 1 or -1, respectively, and returns 1. diff --git a/scan/scan_plusminus.c b/scan/scan_plusminus.c index 2906042..2ebe871 100644 --- a/scan/scan_plusminus.c +++ b/scan/scan_plusminus.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_plusminus(const char *src,signed int *dest) { +size_t scan_plusminus(const char *src,signed int *dest) { *dest=1; switch (*src) { case '-': *dest=-1; diff --git a/scan/scan_short.3 b/scan/scan_short.3 index 9e1f82e..15768cb 100644 --- a/scan/scan_short.3 +++ b/scan/scan_short.3 @@ -4,7 +4,7 @@ scan_short \- parse an integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_short\fP(const char *\fIsrc\fR,short int *\fIdest\fR); +size_t \fBscan_short\fP(const char *\fIsrc\fR,short int *\fIdest\fR); .SH DESCRIPTION scan_short parses a short integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_short.c b/scan/scan_short.c index c4f8331..a029ccf 100644 --- a/scan/scan_short.c +++ b/scan/scan_short.c @@ -1,8 +1,8 @@ #include "scan.h" -unsigned int scan_short(const char* src,short* dest) { +size_t scan_short(const char* src,short* dest) { long l; - register int len=scan_long(src,&l); + size_t len=scan_long(src,&l); *dest=l; return len; } diff --git a/scan/scan_uint.3 b/scan/scan_uint.3 index dc77589..6fb11ff 100644 --- a/scan/scan_uint.3 +++ b/scan/scan_uint.3 @@ -4,7 +4,7 @@ scan_uint \- parse an unsigned integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_uint\fP(const char *\fIsrc\fR,int *\fIdest\fR); +size_t \fBscan_uint\fP(const char *\fIsrc\fR,int *\fIdest\fR); .SH DESCRIPTION scan_uint parses an unsigned integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_uint.c b/scan/scan_uint.c index 656bc33..cb661af 100644 --- a/scan/scan_uint.c +++ b/scan/scan_uint.c @@ -5,7 +5,7 @@ * not fit into an unsigned int (as opposed to not fitting in an * unsigned long) */ -unsigned int scan_uint(const char* src,unsigned int* dest) { +size_t scan_uint(const char* src,unsigned int* dest) { if (sizeof(unsigned int) == sizeof(unsigned long)) { /* a good optimizing compiler should remove the else clause when not * needed */ diff --git a/scan/scan_ulong.3 b/scan/scan_ulong.3 index 2bb02de..16e5d55 100644 --- a/scan/scan_ulong.3 +++ b/scan/scan_ulong.3 @@ -4,7 +4,7 @@ scan_ulong \- parse an unsigned long integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_ulong\fP(const char *\fIsrc\fR,unsigned long *\fIdest\fR); +size_t \fBscan_ulong\fP(const char *\fIsrc\fR,unsigned long *\fIdest\fR); .SH DESCRIPTION scan_ulong parses an unsigned long integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_ulong.c b/scan/scan_ulong.c index 5d38bc2..b312c52 100644 --- a/scan/scan_ulong.c +++ b/scan/scan_ulong.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_ulong(const char* src,unsigned long int* dest) { +size_t scan_ulong(const char* src,unsigned long int* dest) { register const char *tmp=src; register unsigned long int l=0; register unsigned char c; diff --git a/scan/scan_ulonglong.3 b/scan/scan_ulonglong.3 index da497ed..3de4476 100644 --- a/scan/scan_ulonglong.3 +++ b/scan/scan_ulonglong.3 @@ -4,7 +4,7 @@ scan_ulonglong \- parse an unsigned long integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_ulonglong\fP(const char *\fIsrc\fR,unsigned long long *\fIdest\fR); +size_t \fBscan_ulonglong\fP(const char *\fIsrc\fR,unsigned long long *\fIdest\fR); .SH DESCRIPTION scan_ulonglong parses an unsigned long long integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_ulonglong.c b/scan/scan_ulonglong.c index 3ef5ce5..27e2634 100644 --- a/scan/scan_ulonglong.c +++ b/scan/scan_ulonglong.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_ulonglong(const char *src,unsigned long long *dest) { +size_t scan_ulonglong(const char *src,unsigned long long *dest) { register const char *tmp=src; register unsigned long long l=0; register unsigned char c; diff --git a/scan/scan_ushort.3 b/scan/scan_ushort.3 index d61c254..f9fdd0e 100644 --- a/scan/scan_ushort.3 +++ b/scan/scan_ushort.3 @@ -4,7 +4,7 @@ scan_ushort \- parse an unsigned short integer in decimal ASCII representation .SH SYNTAX .B #include -int \fBscan_ushort\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR); +size_t \fBscan_ushort\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR); .SH DESCRIPTION scan_ushort parses an unsigned short integer in decimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_ushort.c b/scan/scan_ushort.c index 483319b..8b969a9 100644 --- a/scan/scan_ushort.c +++ b/scan/scan_ushort.c @@ -5,7 +5,7 @@ * not fit into an unsigned short (as opposed to not fitting in an * unsigned long) */ -unsigned int scan_ushort(const char* src,unsigned short* dest) { +size_t scan_ushort(const char* src,unsigned short* dest) { if (sizeof(unsigned short) == sizeof(unsigned int)) { /* a good optimizing compiler should remove the else clause when not * needed */ diff --git a/scan/scan_whitenskip.3 b/scan/scan_whitenskip.3 index 38ecaf9..67ec7db 100644 --- a/scan/scan_whitenskip.3 +++ b/scan/scan_whitenskip.3 @@ -4,7 +4,7 @@ scan_whitenskip \- skip whitespace .SH SYNTAX .B #include -long \fBscan_whitenskip\fP(const char *\fIsrc\fR,unsigned long *\fIlimit\fR); +size_t \fBscan_whitenskip\fP(const char *\fIsrc\fR,size_t \fIlimit\fR); .SH DESCRIPTION scan_whitenskip returns the length of the maximum prefix of \fIsrc\fR that consists solely of whitespace characters as defined by diff --git a/scan/scan_whitenskip.c b/scan/scan_whitenskip.c index 7261021..bc50a99 100644 --- a/scan/scan_whitenskip.c +++ b/scan/scan_whitenskip.c @@ -1,7 +1,7 @@ #include "scan.h" #include -unsigned long scan_whitenskip(const char *s,unsigned long limit) { +size_t scan_whitenskip(const char *s,size_t limit) { register const char *t=s; register const char *u=t+limit; while (t -int \fBscan_xint\fP(const char *\fIsrc\fR,int *\fIdest\fR); +size_t \fBscan_xint\fP(const char *\fIsrc\fR,int *\fIdest\fR); .SH DESCRIPTION scan_xint parses an unsigned integer in hexadecimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It returns the diff --git a/scan/scan_xint.c b/scan/scan_xint.c index 412892e..f55f9fc 100644 --- a/scan/scan_xint.c +++ b/scan/scan_xint.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_xint(const char* src,unsigned int* dest) { +size_t scan_xint(const char* src,unsigned int* dest) { unsigned long l; register int len=scan_xlong(src,&l); *dest=l; diff --git a/scan/scan_xlong.3 b/scan/scan_xlong.3 index 414cece..a10cbb8 100644 --- a/scan/scan_xlong.3 +++ b/scan/scan_xlong.3 @@ -4,7 +4,7 @@ scan_xlong \- parse an unsigned long integer in hexadecimal ASCII representation .SH SYNTAX .B #include -int \fBscan_xlong\fP(const char *\fIsrc\fR,unsigned long *\fIdest\fR); +size_t \fBscan_xlong\fP(const char *\fIsrc\fR,unsigned long *\fIdest\fR); .SH DESCRIPTION scan_xlong parses an unsigned long integer in hexadecimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It diff --git a/scan/scan_xlong.c b/scan/scan_xlong.c index c885790..cca6d47 100644 --- a/scan/scan_xlong.c +++ b/scan/scan_xlong.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_xlong(const char *src,unsigned long *dest) { +size_t scan_xlong(const char *src,unsigned long *dest) { register const char *tmp=src; register unsigned long l=0; register unsigned char c; diff --git a/scan/scan_xlonglong.3 b/scan/scan_xlonglong.3 index 426170b..18c6d8e 100644 --- a/scan/scan_xlonglong.3 +++ b/scan/scan_xlonglong.3 @@ -4,7 +4,7 @@ scan_xlonglong \- parse an unsigned long long integer in hexadecimal ASCII repre .SH SYNTAX .B #include -int \fBscan_xlonglong\fP(const char *\fIsrc\fR,unsigned long long* \fIdest\fR); +size_t \fBscan_xlonglong\fP(const char *\fIsrc\fR,unsigned long long* \fIdest\fR); .SH DESCRIPTION scan_xlonglong parses an unsigned long long integer in hexadecimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It diff --git a/scan/scan_xlonglong.c b/scan/scan_xlonglong.c index 0c547a8..bd6d9b9 100644 --- a/scan/scan_xlonglong.c +++ b/scan/scan_xlonglong.c @@ -1,6 +1,6 @@ #include "scan.h" -unsigned int scan_xlonglong(const char* src,unsigned long long* dest) { +size_t scan_xlonglong(const char* src,unsigned long long* dest) { register const char *tmp=src; register long long l=0; register unsigned char c; diff --git a/scan/scan_xshort.3 b/scan/scan_xshort.3 index 91131c4..3fd46ce 100644 --- a/scan/scan_xshort.3 +++ b/scan/scan_xshort.3 @@ -4,7 +4,7 @@ scan_xshort \- parse an unsigned short integer in hexadecimal ASCII representati .SH SYNTAX .B #include -int \fBscan_xshort\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR); +size_t \fBscan_xshort\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR); .SH DESCRIPTION scan_xshort parses an unsigned short integer in hexadecimal ASCII representation from \fIsrc\fR and writes the result into \fIdest\fR. It diff --git a/scan/scan_xshort.c b/scan/scan_xshort.c index 52415e8..a66ef5a 100644 --- a/scan/scan_xshort.c +++ b/scan/scan_xshort.c @@ -1,8 +1,8 @@ #include "scan.h" -unsigned int scan_xshort(const char* src,unsigned short* dest) { +size_t scan_xshort(const char* src,unsigned short* dest) { unsigned long l; - register int len=scan_xlong(src,&l); + size_t len=scan_xlong(src,&l); *dest=l; return len; } diff --git a/socket.h b/socket.h index ddb7b89..b357213 100644 --- a/socket.h +++ b/socket.h @@ -1,6 +1,8 @@ #ifndef SOCKET_H #define SOCKET_H +#include + #include "uint16.h" #include "uint32.h" @@ -24,10 +26,10 @@ int socket_bind6_reuse(int s,const char* ip,uint16 port,uint32 scope_id); int socket_listen(int s,unsigned int backlog); int socket_accept4(int s,char* ip,uint16* port); int socket_accept6(int s,char* ip,uint16* port,uint32* scope_id); -int socket_recv4(int s,char* buf,unsigned int len,char* ip,uint16* port); -int socket_recv6(int s,char* buf,unsigned int len,char* ip,uint16* port,uint32* scope_id); -int socket_send4(int s,const char* buf,unsigned int len,const char* ip,uint16 port); -int socket_send6(int s,const char* buf,unsigned int len,const char* ip,uint16 port,uint32 scope_id); +ssize_t socket_recv4(int s,char* buf,size_t len,char* ip,uint16* port); +ssize_t socket_recv6(int s,char* buf,size_t len,char* ip,uint16* port,uint32* scope_id); +ssize_t socket_send4(int s,const char* buf,size_t len,const char* ip,uint16 port); +ssize_t socket_send6(int s,const char* buf,size_t len,const char* ip,uint16 port,uint32 scope_id); int socket_local4(int s,char* ip,uint16* port); int socket_local6(int s,char* ip,uint16* port,uint32* scope_id); int socket_remote4(int s,char* ip,uint16* port); diff --git a/socket/socket_recv4.3 b/socket/socket_recv4.3 index 1d3d204..225324b 100644 --- a/socket/socket_recv4.3 +++ b/socket/socket_recv4.3 @@ -4,7 +4,7 @@ socket_recv4 \- receive a UDP datagram .SH SYNTAX .B #include -int \fBsocket_recv4\fP(int \fIs\fR, char* \fIbuf\fR, unsigned int \fIlen\fR, +ssize_t \fBsocket_recv4\fP(int \fIs\fR, char* \fIbuf\fR, size_t \fIlen\fR, char \fIip\fR[4],uint16* \fIport\fR); .SH DESCRIPTION socket_recv4 receives up to \fIlen\fR bytes starting at \fIbuf\fR from a UDP diff --git a/socket/socket_recv4.c b/socket/socket_recv4.c index 8f1065b..2353afd 100644 --- a/socket/socket_recv4.c +++ b/socket/socket_recv4.c @@ -8,10 +8,10 @@ #include "socket.h" #include "havesl.h" -int socket_recv4(int s,char *buf,unsigned int len,char ip[4],uint16 *port) { +ssize_t socket_recv4(int s,char *buf,size_t len,char ip[4],uint16 *port) { struct sockaddr_in si; socklen_t Len = sizeof si; - int r; + ssize_t r; if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return winsock2errno(-1); if (ip) *(uint32*)ip = *(uint32*)&si.sin_addr; diff --git a/socket/socket_recv6.3 b/socket/socket_recv6.3 index 5d3c5ac..a8f42f8 100644 --- a/socket/socket_recv6.3 +++ b/socket/socket_recv6.3 @@ -4,7 +4,7 @@ socket_recv6 \- receive a UDP datagram .SH SYNTAX .B #include -int \fBsocket_recv6\fP(int \fIs\fR, char* \fIbuf\fR, unsigned int \fIlen\fR, +ssize_t \fBsocket_recv6\fP(int \fIs\fR, char* \fIbuf\fR, size_t \fIlen\fR, char \fIip\fR[16], uint16* \fIport\fR, uint32* \fIscope_id\fR); .SH DESCRIPTION socket_recv6 receives up to \fIlen\fR bytes starting at \fIbuf\fR from a UDP diff --git a/socket/socket_recv6.c b/socket/socket_recv6.c index 43c5f90..7b1a94c 100644 --- a/socket/socket_recv6.c +++ b/socket/socket_recv6.c @@ -12,7 +12,7 @@ #include "havesl.h" #include "havescope.h" -int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id) +ssize_t socket_recv6(int s,char *buf,size_t len,char ip[16],uint16 *port,uint32 *scope_id) { #ifdef LIBC_HAS_IP6 struct sockaddr_in6 si; @@ -20,7 +20,7 @@ int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint3 struct sockaddr_in si; #endif socklen_t Len = sizeof si; - int r; + ssize_t r; byte_zero(&si,Len); if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return winsock2errno(-1); diff --git a/socket/socket_send4.3 b/socket/socket_send4.3 index 5f20a9f..13cc779 100644 --- a/socket/socket_send4.3 +++ b/socket/socket_send4.3 @@ -4,7 +4,7 @@ socket_send4 \- send a UDP datagram .SH SYNTAX .B #include -int \fBsocket_send4\fP(int \fIs\fR, const char* \fIbuf\fR, unsigned int \fIlen\fR, +ssize_t \fBsocket_send4\fP(int \fIs\fR, const char* \fIbuf\fR, size_t \fIlen\fR, const char \fIip\fR[4],uint16 \fIport\fR); .SH DESCRIPTION socket_send4 sends \fIlen\fR bytes starting at \fIbuf\fR in a UDP diff --git a/socket/socket_send4.c b/socket/socket_send4.c index 69be15e..c2ace8b 100644 --- a/socket/socket_send4.c +++ b/socket/socket_send4.c @@ -8,7 +8,7 @@ #include "byte.h" #include "socket.h" -int socket_send4(int s,const char *buf,unsigned int len,const char ip[4],uint16 port) { +ssize_t socket_send4(int s,const char *buf,size_t len,const char ip[4],uint16 port) { struct sockaddr_in si; byte_zero(&si,sizeof si); diff --git a/socket/socket_send6.3 b/socket/socket_send6.3 index dd4c759..9fddb57 100644 --- a/socket/socket_send6.3 +++ b/socket/socket_send6.3 @@ -4,7 +4,7 @@ socket_send6 \- send a UDP datagram .SH SYNTAX .B #include -int \fBsocket_send6\fP(int \fIs\fR, const char* \fIbuf\fR, unsigned int \fIlen\fR, +ssize_t \fBsocket_send6\fP(int \fIs\fR, const char* \fIbuf\fR, size_t \fIlen\fR, const char \fIip\fR[16], uint16 \fIport\fR, uint32 \fIscope_id\fR); .SH DESCRIPTION socket_send6 sends \fIlen\fR bytes starting at \fIbuf\fR in a UDP diff --git a/socket/socket_send6.c b/socket/socket_send6.c index 475d62f..f30bbc5 100644 --- a/socket/socket_send6.c +++ b/socket/socket_send6.c @@ -13,7 +13,7 @@ #include "ip4.h" #include "havescope.h" -int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 port,uint32 scope_id) +ssize_t socket_send6(int s,const char *buf,size_t len,const char ip[16],uint16 port,uint32 scope_id) { #ifdef LIBC_HAS_IP6 struct sockaddr_in6 si; diff --git a/str.h b/str.h index eeaaafb..172042e 100644 --- a/str.h +++ b/str.h @@ -1,16 +1,14 @@ #ifndef STR_H #define STR_H -#ifdef __dietlibc__ -#include -#endif +#include #ifndef __pure__ #define __pure__ #endif /* str_copy copies leading bytes from in to out until \0. * return number of copied bytes. */ -unsigned long str_copy(char *out,const char *in); +size_t str_copy(char *out,const char *in); /* str_diff returns negative, 0, or positive, depending on whether the * string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than, @@ -25,21 +23,21 @@ int str_diff(const char *a,const char *b) __pure__; * If the strings are different, str_diffn does not read bytes past the * first difference. The strings will be considered equal if the first * limit characters match. */ -int str_diffn(const char *a,const char *b,unsigned long limit) __pure__; +int str_diffn(const char *a,const char *b,size_t limit) __pure__; #ifdef __dietlibc__ #include #define str_len(foo) strlen(foo) #else /* str_len returns the index of \0 in s */ -unsigned long str_len(const char *s) __pure__; +size_t str_len(const char *s) __pure__; #endif /* str_chr returns the index of the first occurance of needle or \0 in haystack */ -unsigned long str_chr(const char *haystack,char needle) __pure__; +size_t str_chr(const char *haystack,char needle) __pure__; /* str_rchr returns the index of the last occurance of needle or \0 in haystack */ -unsigned long str_rchr(const char *haystack,char needle) __pure__; +size_t str_rchr(const char *haystack,char needle) __pure__; /* str_start returns 1 if the b is a prefix of a, 0 otherwise */ int str_start(const char *a,const char *b) __pure__; diff --git a/str/str_chr.3 b/str/str_chr.3 index 069389a..8dc0de6 100644 --- a/str/str_chr.3 +++ b/str/str_chr.3 @@ -4,7 +4,7 @@ str_chr \- find character in ASCIIZ string .SH SYNTAX .B #include -extern long \fBstr_chr\fP(const char* \fIhaystack\fR,char \fIneedle\fR); +size_t \fBstr_chr\fP(const char* \fIhaystack\fR,char \fIneedle\fR); .SH DESCRIPTION str_chr returns the index of the first occurrance of \fIneedle\fR or \\0 in \fIstring\fR. diff --git a/str/str_chr.c b/str/str_chr.c index 4c093b9..9338065 100644 --- a/str/str_chr.c +++ b/str/str_chr.c @@ -1,6 +1,6 @@ #include "str.h" -unsigned long str_chr(const char *in, char needle) { +size_t str_chr(const char *in, char needle) { register const char* t=in; register const char c=needle; for (;;) { diff --git a/str/str_copy.3 b/str/str_copy.3 index 9154c9f..ad9e893 100644 --- a/str/str_copy.3 +++ b/str/str_copy.3 @@ -4,7 +4,7 @@ str_copy \- copy an ASCIIZ string .SH SYNTAX .B #include -extern long \fBstr_copy\fP(char* \fIout\fR,const char* \fIin\fR); +size_t \fBstr_copy\fP(char* \fIout\fR,const char* \fIin\fR); .SH DESCRIPTION str_copy copies the leading bytes of \fIin\fR to \fIout\fR up to and including the first occurrance of \\0. diff --git a/str/str_copy.c b/str/str_copy.c index d5a127a..2244267 100644 --- a/str/str_copy.c +++ b/str/str_copy.c @@ -1,6 +1,6 @@ #include "str.h" -unsigned long str_copy(char *out,const char *in) { +size_t str_copy(char *out,const char *in) { register char* s=out; register const char* t=in; for (;;) { diff --git a/str/str_diff.3 b/str/str_diff.3 index 563c610..42dcf9a 100644 --- a/str/str_diff.3 +++ b/str/str_diff.3 @@ -4,7 +4,7 @@ str_diff \- compare two ASCIIZ strings .SH SYNTAX .B #include -extern int \fBstr_diff\fP(const char* \fIa\fR,const char* \fIb\fR); +int \fBstr_diff\fP(const char* \fIa\fR,const char* \fIb\fR); .SH DESCRIPTION \fBstr_diff\fR returns negative, 0, or positive, depending on whether the string \fIa\fR[0], \fIa\fR[1], ..., \fIa\fR[n]=='\\0' is diff --git a/str/str_diffn.3 b/str/str_diffn.3 index c6cea59..35916ab 100644 --- a/str/str_diffn.3 +++ b/str/str_diffn.3 @@ -4,7 +4,7 @@ str_diffn \- compare two ASCIIZ strings .SH SYNTAX .B #include -extern int \fBstr_diffn\fP(const char* \fIa\fR,const char* \fIb\fR,unsigned long \fIlimit\fR); +int \fBstr_diffn\fP(const char* \fIa\fR,const char* \fIb\fR,size_t \fIlimit\fR); .SH DESCRIPTION \fBstr_diffn\fR returns negative, 0, or positive, depending on whether the string \fIa\fR[0], \fIa\fR[1], ..., \fIa\fR[n]=='\\0' is diff --git a/str/str_diffn.c b/str/str_diffn.c index 5f9e5e7..e7dd98c 100644 --- a/str/str_diffn.c +++ b/str/str_diffn.c @@ -5,7 +5,7 @@ * equal to, or greater than the string b[0], b[1], ..., b[m-1]=='\0'. * When the strings are different, str_diff does not read bytes past the * first difference. */ -int str_diffn(const char* a, const char* b, unsigned long limit) { +int str_diffn(const char* a, const char* b, size_t limit) { register const unsigned char* s=(const unsigned char*)a; register const unsigned char* t=(const unsigned char*)b; register const unsigned char* u=t+limit; diff --git a/str/str_equal.3 b/str/str_equal.3 index 352ac4c..1da6af3 100644 --- a/str/str_equal.3 +++ b/str/str_equal.3 @@ -4,7 +4,7 @@ str_equal \- compare two ASCIIZ strings .SH SYNTAX .B #include -extern int \fBstr_equal\fP(const char* \fIa\fR,const char* \fIb\fR); +size_t \fBstr_equal\fP(const char* \fIa\fR,const char* \fIb\fR); .SH DESCRIPTION \fBstr_equal\fR returns nonzero if \fIa\fR and \fIb\fR match up to and including the first occurrance of \\0. diff --git a/str/str_len.3 b/str/str_len.3 index 0394929..e6044c7 100644 --- a/str/str_len.3 +++ b/str/str_len.3 @@ -4,7 +4,7 @@ str_len \- find length of ASCIIZ string .SH SYNTAX .B #include -extern long \fBstr_len\fP(const char* \fIstring\fR); +size_t \fBstr_len\fP(const char* \fIstring\fR); .SH DESCRIPTION str_len returns the index of the first occurrance of \\0 in \fIstring\fR. diff --git a/str/str_len.c b/str/str_len.c index a6b8c8d..b40af18 100644 --- a/str/str_len.c +++ b/str/str_len.c @@ -1,7 +1,7 @@ #undef __dietlibc__ #include "str.h" -unsigned long str_len(const char* in) { +size_t str_len(const char* in) { register const char* t=in; for (;;) { if (!*t) break; ++t; diff --git a/str/str_rchr.3 b/str/str_rchr.3 index 08d7caa..78be80b 100644 --- a/str/str_rchr.3 +++ b/str/str_rchr.3 @@ -4,7 +4,7 @@ str_rchr \- find character in ASCIIZ string .SH SYNTAX .B #include -extern long \fBstr_rchr\fP(const char* \fIhaystack\fR,char \fIneedle\fR); +size_t \fBstr_rchr\fP(const char* \fIhaystack\fR,char \fIneedle\fR); .SH DESCRIPTION str_rchr returns the index of the last occurrance of needle or the first occurrance of \\0 in \fIstring\fR. diff --git a/str/str_rchr.c b/str/str_rchr.c index 9586cb4..533f0a4 100644 --- a/str/str_rchr.c +++ b/str/str_rchr.c @@ -1,6 +1,6 @@ #include "str.h" -unsigned long str_rchr(const char *in, char needle) { +size_t str_rchr(const char *in, char needle) { register const char* t=in; register const char c=needle; register const char* found=0; diff --git a/str/str_start.3 b/str/str_start.3 index 2595f85..26f31c1 100644 --- a/str/str_start.3 +++ b/str/str_start.3 @@ -4,7 +4,7 @@ str_start \- compare prefixes of strings .SH SYNTAX .B #include -extern int \fBstr_start\fP(const char* \fIa\fR,const char* \fIb\fR); +size_t \fBstr_start\fP(const char* \fIa\fR,const char* \fIb\fR); .SH DESCRIPTION str_start returns 1 if \fIb\fR is a prefix of \fIa\fR, 0 otherwise. .SH "SEE ALSO" diff --git a/stralloc.h b/stralloc.h index 0eba946..85e6a0e 100644 --- a/stralloc.h +++ b/stralloc.h @@ -1,9 +1,7 @@ #ifndef STRALLOC_H #define STRALLOC_H -#ifdef __dietlibc__ -#include -#endif +#include #ifndef __pure__ #define __pure__ #endif @@ -16,8 +14,8 @@ typedef struct stralloc { char* s; - unsigned long int len; - unsigned long int a; + size_t len; + size_t a; } stralloc; /* stralloc_init will initialize a stralloc. @@ -32,17 +30,17 @@ void stralloc_init(stralloc* sa); * bytes of space, copies the old string into the new space, frees the * old space, and returns 1. Note that this changes sa.s. If the * allocation fails, stralloc_ready leaves sa alone and returns 0. */ -int stralloc_ready(stralloc* sa,unsigned long int len); +int stralloc_ready(stralloc* sa,size_t len); /* stralloc_readyplus is like stralloc_ready except that, if sa is * already allocated, stralloc_readyplus adds the current length of sa * to len. */ -int stralloc_readyplus(stralloc* sa,unsigned long int len); +int stralloc_readyplus(stralloc* sa,size_t len); /* stralloc_copyb copies the string buf[0], buf[1], ..., buf[len-1] into * sa, allocating space if necessary, and returns 1. If it runs out of * memory, stralloc_copyb leaves sa alone and returns 0. */ -int stralloc_copyb(stralloc* sa,const char* buf,unsigned long int len); +int stralloc_copyb(stralloc* sa,const char* buf,size_t len); /* stralloc_copys copies a \0-terminated string from buf into sa, * without the \0. It is the same as @@ -58,7 +56,7 @@ int stralloc_copy(stralloc* sa,const stralloc* sa2); * returns 1. If sa is unallocated, stralloc_catb is the same as * stralloc_copyb. If it runs out of memory, stralloc_catb leaves sa * alone and returns 0. */ -int stralloc_catb(stralloc* sa,const char* in,unsigned long int len); +int stralloc_catb(stralloc* sa,const char* in,size_t len); /* stralloc_cats is analogous to stralloc_copys */ int stralloc_cats(stralloc* sa,const char* in); @@ -100,10 +98,10 @@ int stralloc_diffs(const stralloc* a,const char* b) __pure__; #define stralloc_0(sa) stralloc_append(sa,"") /* stralloc_catulong0 appends a '0' padded ASCII representation of in */ -int stralloc_catulong0(stralloc* sa,unsigned long int in,unsigned long int n); +int stralloc_catulong0(stralloc* sa,unsigned long int in,size_t n); /* stralloc_catlong0 appends a '0' padded ASCII representation of in */ -int stralloc_catlong0(stralloc* sa,signed long int in,unsigned long int n); +int stralloc_catlong0(stralloc* sa,signed long int in,size_t n); /* stralloc_free frees the storage associated with sa */ void stralloc_free(stralloc* sa); @@ -137,12 +135,12 @@ int buffer_putsaflush(buffer* b,stralloc* sa); * data is available. */ /* read token from buffer to stralloc */ -int buffer_get_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen); +int buffer_get_token_sa(buffer* b,stralloc* sa,const char* charset,size_t setlen); /* read line from buffer to stralloc */ int buffer_getline_sa(buffer* b,stralloc* sa); /* same as buffer_get_token_sa but empty sa first */ -int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,unsigned long int setlen); +int buffer_get_new_token_sa(buffer* b,stralloc* sa,const char* charset,size_t setlen); /* same as buffer_getline_sa but empty sa first */ int buffer_getnewline_sa(buffer* b,stralloc* sa); diff --git a/stralloc/stralloc_catb.3 b/stralloc/stralloc_catb.3 index 1fc7bbf..c4cc47e 100644 --- a/stralloc/stralloc_catb.3 +++ b/stralloc/stralloc_catb.3 @@ -4,7 +4,7 @@ stralloc_catb \- append data to a stralloc .SH SYNTAX .B #include -int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned long int \fIlen\fR); +int \fBstralloc_catb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,size_t \fIlen\fR); .SH DESCRIPTION stralloc_catb adds the string \fIbuf\fR[0], \fIbuf\fR[1], ... \fIbuf\fR[\fIlen\fR-1] to the end of the string stored in \fIsa\fR, allocating space if necessary, and diff --git a/stralloc/stralloc_catb.c b/stralloc/stralloc_catb.c index 368a9ba..04d7614 100644 --- a/stralloc/stralloc_catb.c +++ b/stralloc/stralloc_catb.c @@ -6,7 +6,7 @@ * returns 1. If sa is unallocated, stralloc_catb is the same as * stralloc_copyb. If it runs out of memory, stralloc_catb leaves sa * alone and returns 0. */ -int stralloc_catb(stralloc *sa,const char *buf,unsigned long int len) { +int stralloc_catb(stralloc *sa,const char *buf,size_t len) { if (stralloc_readyplus(sa,len)) { byte_copy(sa->s+sa->len,len,buf); sa->len+=len; diff --git a/stralloc/stralloc_catlong0.3 b/stralloc/stralloc_catlong0.3 index 29b5061..6a7b346 100644 --- a/stralloc/stralloc_catlong0.3 +++ b/stralloc/stralloc_catlong0.3 @@ -4,7 +4,7 @@ stralloc_catlong0 \- append an integer to a stralloc .SH SYNTAX .B #include -int \fBstralloc_catlong0\fP(stralloc* \fIsa\fR, unsigned long int \fIin\fR, unsigned long int \fIn\fR); +int \fBstralloc_catlong0\fP(stralloc* \fIsa\fR, unsigned long int \fIin\fR, size_t \fIn\fR); .SH DESCRIPTION stralloc_catlong0 converts in to a string using \fBfmt_long0\fR and appends the result to \fIsa\fR, allocating memory as necessary. diff --git a/stralloc/stralloc_catlong0.c b/stralloc/stralloc_catlong0.c index aa50c3e..b0e03a7 100644 --- a/stralloc/stralloc_catlong0.c +++ b/stralloc/stralloc_catlong0.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "fmt.h" -int stralloc_catlong0(stralloc *sa,signed long int in,unsigned long int n) { +int stralloc_catlong0(stralloc *sa,signed long int in,size_t n) { if (stralloc_readyplus(sa,fmt_minus(0,in)+fmt_ulong0(0,in,n))) { sa->len+=fmt_minus(sa->s+sa->len,in); sa->len+=fmt_ulong0(sa->s+sa->len,in>=0?in:-in,n); diff --git a/stralloc/stralloc_catulong0.3 b/stralloc/stralloc_catulong0.3 index 57ce3c0..4d98008 100644 --- a/stralloc/stralloc_catulong0.3 +++ b/stralloc/stralloc_catulong0.3 @@ -4,7 +4,7 @@ stralloc_catulong0 \- append an integer to a stralloc .SH SYNTAX .B #include -int \fBstralloc_catulong0\fP(stralloc* \fIsa\fR, unsigned long int \fIin\fR, unsigned long int \fIn\fR); +int \fBstralloc_catulong0\fP(stralloc* \fIsa\fR, unsigned long int \fIin\fR, size_t \fIn\fR); .SH DESCRIPTION stralloc_catulong0 converts in to a string using \fBfmt_ulong0\fR and appends the result to \fIsa\fR, allocating memory as necessary. diff --git a/stralloc/stralloc_catulong0.c b/stralloc/stralloc_catulong0.c index 8a35bdf..295e6dc 100644 --- a/stralloc/stralloc_catulong0.c +++ b/stralloc/stralloc_catulong0.c @@ -1,7 +1,7 @@ #include "stralloc.h" #include "fmt.h" -int stralloc_catulong0(stralloc *sa,unsigned long int in,unsigned long int n) { +int stralloc_catulong0(stralloc *sa,unsigned long int in,size_t n) { if (stralloc_readyplus(sa,fmt_ulong0(0,in,n))) { sa->len+=fmt_ulong0(sa->s+sa->len,in,n); return 1; diff --git a/stralloc/stralloc_copyb.3 b/stralloc/stralloc_copyb.3 index c5ba390..0b54887 100644 --- a/stralloc/stralloc_copyb.3 +++ b/stralloc/stralloc_copyb.3 @@ -4,7 +4,7 @@ stralloc_copyb \- copy data into a stralloc .SH SYNTAX .B #include -int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,unsigned long int \fIlen\fR); +int \fBstralloc_copyb\fP(stralloc* \fIsa\fR,const char* \fIbuf\fR,size_t \fIlen\fR); .SH DESCRIPTION stralloc_copyb makes sure that \fIsa\fR has enough space allocated to hold \fIlen\fR bytes. Then it copies the first \fIlen\fR bytes from diff --git a/stralloc/stralloc_copyb.c b/stralloc/stralloc_copyb.c index 70e4a71..0dc76de 100644 --- a/stralloc/stralloc_copyb.c +++ b/stralloc/stralloc_copyb.c @@ -4,7 +4,7 @@ /* stralloc_copyb copies the string buf[0], buf[1], ..., buf[len-1] into * sa, allocating space if necessary, and returns 1. If it runs out of * memory, stralloc_copyb leaves sa alone and returns 0. */ -int stralloc_copyb(stralloc *sa,const char *buf,unsigned long int len) { +int stralloc_copyb(stralloc *sa,const char *buf,size_t len) { if (stralloc_ready(sa,len)) { sa->len=len; byte_copy(sa->s,len,buf); diff --git a/stralloc/stralloc_ready.3 b/stralloc/stralloc_ready.3 index 0b8f8cc..65e2cd9 100644 --- a/stralloc/stralloc_ready.3 +++ b/stralloc/stralloc_ready.3 @@ -4,7 +4,7 @@ stralloc_ready \- provide space in a stralloc .SH SYNTAX .B #include -int \fBstralloc_ready\fP(stralloc* \fIsa\fR,unsigned long int \fIlen\fR); +int \fBstralloc_ready\fP(stralloc* \fIsa\fR,size_t \fIlen\fR); .SH DESCRIPTION stralloc_ready makes sure that \fIsa\fR has enough space allocated to hold \fIlen\fR bytes: If \fIsa\fR is not allocated, stralloc_ready allocates at least diff --git a/stralloc/stralloc_ready.c b/stralloc/stralloc_ready.c index dc44cb5..7d0c36b 100644 --- a/stralloc/stralloc_ready.c +++ b/stralloc/stralloc_ready.c @@ -7,7 +7,7 @@ * not enough to hold len bytes, stralloc_ready allocates at least len * bytes of space, copies the old string into the new space, frees the * old space, and returns 1. Note that this changes sa.s. */ -int stralloc_ready(stralloc *sa,unsigned long int len) { +int stralloc_ready(stralloc *sa,size_t len) { register int wanted=len+(len>>3)+30; /* heuristic from djb */ if (!sa->s || sa->a -int \fBstralloc_readyplus\fP(stralloc* \fIsa\fR,unsigned long int \fIlen\fR); +int \fBstralloc_readyplus\fP(stralloc* \fIsa\fR,size_t \fIlen\fR); .SH DESCRIPTION stralloc_readyplus makes sure that \fIsa\fR has enough space allocated to hold an additional \fIlen\fR bytes: If \fIsa\fR is not allocated, diff --git a/stralloc/stralloc_readyplus.c b/stralloc/stralloc_readyplus.c index f8603f0..6c47f3e 100644 --- a/stralloc/stralloc_readyplus.c +++ b/stralloc/stralloc_readyplus.c @@ -4,7 +4,7 @@ /* stralloc_readyplus is like stralloc_ready except that, if sa is * already allocated, stralloc_readyplus adds the current length of sa * to len. */ -int stralloc_readyplus(stralloc *sa,unsigned long len) { +int stralloc_readyplus(stralloc *sa,size_t len) { if (sa->s) { if (sa->len + len < len) return 0; /* catch integer overflow */ return stralloc_ready(sa,sa->len+len); diff --git a/t.c b/t.c index 2b452d9..17185b1 100644 --- a/t.c +++ b/t.c @@ -319,7 +319,7 @@ int main(int argc,char* argv[]) { printf("%lu %lu\n",b-a,c-b); #endif #if 1 - unsigned long size; + size_t size; char* buf=mmap_read(argv[1],&size); if (buf) { unsigned int x=fmt_urlencoded2(0,buf,size,"x"); @@ -332,7 +332,6 @@ int main(int argc,char* argv[]) { #if 0 printf("%d %d\n",strcmp("foo","bar"),str_diff("foo","bar")); printf("%d %d\n",strcmp("foo","üar"),str_diff("foo","üar")); - return 0; #endif { int16 a; @@ -349,5 +348,7 @@ int main(int argc,char* argv[]) { assert(imult64(0x4000000000000000ll,2,&c)==0); assert(imult64(0x3fffffffffffffffll,2,&c)==1 && c==0x7ffffffffffffffell); } + + return 0; } diff --git a/test/buffer_mmap.c b/test/buffer_mmap.c index 78fedf6..60ddbe2 100644 --- a/test/buffer_mmap.c +++ b/test/buffer_mmap.c @@ -10,4 +10,5 @@ int main() { } buffer_flush(buffer_1); buffer_close(&input); + return 0; } diff --git a/test/mult.c b/test/mult.c index 6566e7f..c772db0 100644 --- a/test/mult.c +++ b/test/mult.c @@ -5,9 +5,6 @@ int main() { int16 a; int32 b; int64 c; - uint16 d; - uint32 e; - uint64 f; assert(imult16(4,10000,&a)==0); assert(imult16(-4,10000,&a)==0); @@ -15,11 +12,11 @@ int main() { assert(imult16(-3,10000,&a)==1 && a==-30000); assert(imult32(0x40000000,2,&b)==0); - assert(imult32(-0x40000000,2,&b)==1 && b==-0x80000000); + assert(imult32(-0x40000000,2,&b)==1 && b==-0x80000000ll); assert(imult32(0x3fffffff,2,&b)==1 && b==0x7ffffffe); assert(imult64(0x4000000000000000ll,2,&c)==0); - assert(imult64(-0x4000000000000000ll,2,&c)==1 && c==-0x8000000000000000ll); + assert(imult64(-0x4000000000000000ll,2,&c)==1 && c==(int64)-0x8000000000000000ll); assert(imult64(0x3fffffffffffffffll,2,&c)==1 && c==0x7ffffffffffffffell); return 0; diff --git a/test/unurl.c b/test/unurl.c index dea940b..4863c4e 100644 --- a/test/unurl.c +++ b/test/unurl.c @@ -3,6 +3,7 @@ #include "textcode.h" #include "havealloca.h" #include +#include void unurl(const char* s) { char* buf; diff --git a/test/uudecode.c b/test/uudecode.c index cebfa29..75c00c9 100644 --- a/test/uudecode.c +++ b/test/uudecode.c @@ -96,7 +96,7 @@ int main(int argc,char* argv[]) { enum { NONE, BASE64, QP} mimeenc=NONE; char filename[1024]; unsigned long fmode=0,lineno=0; - unsigned long offset,endoffset,totalsize,linelen,part,reconstructed; /* used only for yenc */ + unsigned long offset,endoffset,totalsize,linelen,part,reconstructed=0; /* used only for yenc */ static stralloc yencpart; unsigned int crc; @@ -375,7 +375,7 @@ writeerror: state=BEFOREBEGIN; continue; } else { - unsigned long scanned,x; + unsigned long scanned,x=0; char tmp[1000]; switch (mode) { case MIME: diff --git a/textcode.h b/textcode.h index a0735e6..886b926 100644 --- a/textcode.h +++ b/textcode.h @@ -1,65 +1,67 @@ #ifndef TEXTCODE_H #define TEXTCODE_H +#include + /* These take len bytes from src and write them in encoded form to * dest (if dest != NULL), returning the number of bytes written. */ /* needs len/3*4 bytes */ -unsigned long fmt_uuencoded(char* dest,const char* src,unsigned long len); +size_t fmt_uuencoded(char* dest,const char* src,size_t len); /* needs len/3*4 bytes */ -unsigned long fmt_base64(char* dest,const char* src,unsigned long len); +size_t fmt_base64(char* dest,const char* src,size_t len); /* worst case: len*3 */ -unsigned long fmt_quotedprintable(char* dest,const char* src,unsigned long len); +size_t fmt_quotedprintable(char* dest,const char* src,size_t len); /* worst case: len*3 */ -unsigned long fmt_quotedprintable2(char* dest,const char* src,unsigned long len,const char* escapeme); +size_t fmt_quotedprintable2(char* dest,const char* src,size_t len,const char* escapeme); /* worst case: len*3 */ -unsigned long fmt_urlencoded(char* dest,const char* src,unsigned long len); +size_t fmt_urlencoded(char* dest,const char* src,size_t len); /* worst case: len*3 */ -unsigned long fmt_urlencoded2(char* dest,const char* src,unsigned long len,const char* escapeme); +size_t fmt_urlencoded2(char* dest,const char* src,size_t len,const char* escapeme); /* worst case: len*2 */ -unsigned long fmt_yenc(char* dest,const char* src,unsigned long len); +size_t fmt_yenc(char* dest,const char* src,size_t len); /* needs len*2 bytes */ -unsigned long fmt_hexdump(char* dest,const char* src,unsigned long len); +size_t fmt_hexdump(char* dest,const char* src,size_t len); /* change '<' to '<' and '&' to '&'; worst case: len*5 */ -unsigned long fmt_html(char* dest,const char* src,unsigned long len); +size_t fmt_html(char* dest,const char* src,size_t len); /* change '\' to "\\", '\n' to "\n", ^A to "\x01" etc; worst case: len*4 */ -unsigned long fmt_cescape(char* dest,const char* src,unsigned long len); +size_t fmt_cescape(char* dest,const char* src,size_t len); /* worst case: len*4 */ -unsigned long fmt_cescape2(char* dest,const char* src,unsigned long len,const char* escapeme); +size_t fmt_cescape2(char* dest,const char* src,size_t len,const char* escapeme); /* fold awk whitespace to '_'; this is great for writing fields with * white spaces to a log file and still allow awk to do log analysis */ /* worst case: same size */ -unsigned long fmt_foldwhitespace(char* dest,const char* src,unsigned long len); +size_t fmt_foldwhitespace(char* dest,const char* src,size_t len); /* worst case: len*3 */ -unsigned long fmt_ldapescape(char* dest,const char* src,unsigned long len); +size_t fmt_ldapescape(char* dest,const char* src,size_t len); /* These read one line from src, decoded it, and write the result to * dest. The number of decoded bytes is written to destlen. dest * should be able to hold strlen(src) bytes as a rule of thumb. */ -unsigned long scan_uuencoded(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_base64(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_quotedprintable(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_urlencoded(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_urlencoded2(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_yenc(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_hexdump(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_html(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_cescape(const char *src,char *dest,unsigned long *destlen); -unsigned long scan_ldapescape(const char* src,char* dest,unsigned long *destlen); +size_t scan_uuencoded(const char *src,char *dest,size_t *destlen); +size_t scan_base64(const char *src,char *dest,size_t *destlen); +size_t scan_quotedprintable(const char *src,char *dest,size_t *destlen); +size_t scan_urlencoded(const char *src,char *dest,size_t *destlen); +size_t scan_urlencoded2(const char *src,char *dest,size_t *destlen); +size_t scan_yenc(const char *src,char *dest,size_t *destlen); +size_t scan_hexdump(const char *src,char *dest,size_t *destlen); +size_t scan_html(const char *src,char *dest,size_t *destlen); +size_t scan_cescape(const char *src,char *dest,size_t *destlen); +size_t scan_ldapescape(const char* src,char* dest,size_t *destlen); #ifdef STRALLOC_H /* WARNING: these functions _append_ to the stralloc, not overwrite! */ /* stralloc wrappers; return 1 on success, 0 on failure */ /* arg 1 is one of the fmt_* functions from above */ -int fmt_to_sa(unsigned long (*func)(char*,const char*,unsigned long), - stralloc* sa,const char* src,unsigned long len); +int fmt_to_sa(size_t (*func)(char*,const char*,size_t), + stralloc* sa,const char* src,size_t len); -int fmt_to_sa2(unsigned long (*func)(char*,const char*,unsigned long,const char*), - stralloc* sa,const char* src,unsigned long len,const char* escapeme); +int fmt_to_sa2(size_t (*func)(char*,const char*,size_t,const char*), + stralloc* sa,const char* src,size_t len,const char* escapeme); /* arg 1 is one of the scan_* functions from above */ /* return number of bytes scanned */ -unsigned long scan_to_sa(unsigned long (*func)(const char*,char*,unsigned long*), +size_t scan_to_sa(size_t (*func)(const char*,char*,size_t*), const char* src,stralloc* sa); #define fmt_uuencoded_sa(sa,src,len) fmt_to_sa(fmt_uuencoded,sa,src,len) @@ -86,22 +88,22 @@ unsigned long scan_to_sa(unsigned long (*func)(const char*,char*,unsigned long*) #endif #ifdef ARRAY_H -void fmt_to_array(unsigned long (*func)(char*,const char*,unsigned long), - array* a,const char* src,unsigned long len); +void fmt_to_array(size_t (*func)(char*,const char*,size_t), + array* a,const char* src,size_t len); -void fmt_tofrom_array(unsigned long (*func)(char*,const char*,unsigned long), +void fmt_tofrom_array(size_t (*func)(char*,const char*,size_t), array* dest,array* src); -void fmt_to_array2(unsigned long (*func)(char*,const char*,unsigned long,const char*), - array* a,const char* src,unsigned long len,const char* escapeme); +void fmt_to_array2(size_t (*func)(char*,const char*,size_t,const char*), + array* a,const char* src,size_t len,const char* escapeme); -void fmt_tofrom_array2(unsigned long (*func)(char*,const char*,unsigned long,const char*), +void fmt_tofrom_array2(size_t (*func)(char*,const char*,size_t,const char*), array* dest,array* src,const char* escapeme); -unsigned long scan_to_array(unsigned long (*func)(const char*,char*,unsigned long*), +size_t scan_to_array(size_t (*func)(const char*,char*,size_t*), const char* src,array* dest); -unsigned long scan_tofrom_array(unsigned long (*func)(const char*,char*,unsigned long*), +size_t scan_tofrom_array(size_t (*func)(const char*,char*,size_t*), array* src,array* dest); #endif diff --git a/textcode/fmt_base64.c b/textcode/fmt_base64.c index 4753445..cda07ec 100644 --- a/textcode/fmt_base64.c +++ b/textcode/fmt_base64.c @@ -2,7 +2,7 @@ #include "textcode.h" #include "haveinline.h" -unsigned long fmt_base64(char* dest,const char* src,unsigned long len) { +size_t fmt_base64(char* dest,const char* src,size_t len) { register const unsigned char* s=(const unsigned char*) src; unsigned short bits=0,temp=0; unsigned long written=0,i; diff --git a/textcode/fmt_cescape.c b/textcode/fmt_cescape.c index cc6efe2..4624344 100644 --- a/textcode/fmt_cescape.c +++ b/textcode/fmt_cescape.c @@ -3,9 +3,9 @@ #include "str.h" #include "haveinline.h" -unsigned long fmt_cescape2(char* dest,const char* src,unsigned long len,const char* escapeme) { +size_t fmt_cescape2(char* dest,const char* src,size_t len,const char* escapeme) { register const unsigned char* s=(const unsigned char*) src; - unsigned long written=0,i; + size_t written=0,i; char c; for (i=0; i>4); dest[written+1]=fmt_tohex(s[i]&15); diff --git a/textcode/fmt_html.c b/textcode/fmt_html.c index ca97541..2a2aecf 100644 --- a/textcode/fmt_html.c +++ b/textcode/fmt_html.c @@ -3,9 +3,9 @@ #include "str.h" #include "haveinline.h" -unsigned long fmt_html(char* dest,const char* src,unsigned long len) { +size_t fmt_html(char* dest,const char* src,size_t len) { register const unsigned char* s=(const unsigned char*) src; - unsigned long written=0,i; + size_t written=0,i; const char* seq; for (i=0; is+sa->len,src,len); sa->len+=needed; diff --git a/textcode/fmt_tofrom_array.c b/textcode/fmt_tofrom_array.c index e38bf6b..e8956d2 100644 --- a/textcode/fmt_tofrom_array.c +++ b/textcode/fmt_tofrom_array.c @@ -1,9 +1,9 @@ #include "array.h" #include "textcode.h" -void fmt_tofrom_array(unsigned long (*func)(char*,const char*,unsigned long), +void fmt_tofrom_array(size_t (*func)(char*,const char*,size_t), array* dest,array* src) { - unsigned long needed; + size_t needed; char* x; if (array_failed(dest) || array_failed(src)) { array_fail(dest); return; } needed=func(0,array_start(src),array_bytes(src)); diff --git a/textcode/fmt_urlencoded.c b/textcode/fmt_urlencoded.c index 32a0dd5..17dfd5e 100644 --- a/textcode/fmt_urlencoded.c +++ b/textcode/fmt_urlencoded.c @@ -11,9 +11,9 @@ static inline int issafe(unsigned char c) { safe[str_chr(safe,c)]); } -unsigned long fmt_urlencoded2(char* dest,const char* src,unsigned long len,const char* escapeme) { +size_t fmt_urlencoded2(char* dest,const char* src,size_t len,const char* escapeme) { register const unsigned char* s=(const unsigned char*) src; - unsigned long written=0,i; + size_t written=0,i; for (i=0; is+sa->len,&written))) sa->len+=written; diff --git a/textcode/scan_tofrom_array.c b/textcode/scan_tofrom_array.c index 2519d82..8879ffc 100644 --- a/textcode/scan_tofrom_array.c +++ b/textcode/scan_tofrom_array.c @@ -2,10 +2,10 @@ #include "array.h" #include "textcode.h" -unsigned long scan_tofrom_array(unsigned long (*func)(const char*,char*,unsigned long*), +size_t scan_tofrom_array(size_t (*func)(const char*,char*,size_t*), array* src,array* dest) { - unsigned long scanned; - unsigned long needed; + size_t scanned; + size_t needed; char* x; array_cat0(src); if (array_failed(src) || array_failed(dest)) return 0; diff --git a/textcode/scan_urlencoded.c b/textcode/scan_urlencoded.c index 2e0dd2c..4b953e9 100644 --- a/textcode/scan_urlencoded.c +++ b/textcode/scan_urlencoded.c @@ -2,9 +2,9 @@ #include "textcode.h" #include "scan.h" -static unsigned long inner_scan_urlencoded(const char *src,char *dest,unsigned long *destlen,int plus) { +static size_t inner_scan_urlencoded(const char *src,char *dest,size_t *destlen,int plus) { register const unsigned char* s=(const unsigned char*) src; - unsigned long written=0,i; + size_t written=0,i; for (i=0; s[i]; ++i) { if (s[i]=='%') { int j=scan_fromhex(s[i+1]); @@ -24,10 +24,10 @@ static unsigned long inner_scan_urlencoded(const char *src,char *dest,unsigned l return i; } -unsigned long scan_urlencoded(const char *src,char *dest,unsigned long *destlen) { +size_t scan_urlencoded(const char *src,char *dest,size_t *destlen) { return inner_scan_urlencoded(src,dest,destlen,1); } -unsigned long scan_urlencoded2(const char *src,char *dest,unsigned long *destlen) { +size_t scan_urlencoded2(const char *src,char *dest,size_t *destlen) { return inner_scan_urlencoded(src,dest,destlen,0); } diff --git a/textcode/scan_uuencoded.c b/textcode/scan_uuencoded.c index 04e0197..326ef76 100644 --- a/textcode/scan_uuencoded.c +++ b/textcode/scan_uuencoded.c @@ -1,8 +1,8 @@ #include "textcode.h" -unsigned long scan_uuencoded(const char *src,char *dest,unsigned long *destlen) { - unsigned int len; - unsigned long tmp; +size_t scan_uuencoded(const char *src,char *dest,size_t *destlen) { + size_t len; + size_t tmp; register const unsigned char* s=(const unsigned char*) src; const char* orig=dest; if ((len=*s-' ')>64) return 0; len&=63; diff --git a/textcode/scan_yenc.c b/textcode/scan_yenc.c index 6ee10ca..43103d2 100644 --- a/textcode/scan_yenc.c +++ b/textcode/scan_yenc.c @@ -1,9 +1,9 @@ #include "fmt.h" #include "textcode.h" -unsigned long scan_yenc(const char *src,char *dest,unsigned long *destlen) { +size_t scan_yenc(const char *src,char *dest,size_t *destlen) { register const unsigned char* s=(const unsigned char*) src; - unsigned long written=0,i; + size_t written=0,i; for (i=0; s[i]; ++i) { if (s[i]=='=') { ++i;