From 45e93c19ef95978f908f5b14962770510634cd3b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 29 May 2004 08:11:46 +0000 Subject: r943: change samba4 to use 'uint8_t' instead of 'unsigned char' metze (This used to be commit b5378803fdcb3b3afe7c2932a38828e83470f61a) --- source4/lib/crypto/md4.c | 8 ++--- source4/lib/crypto/md5.c | 12 +++---- source4/lib/genrand.c | 42 +++++++++++----------- source4/lib/iconv.c | 8 ++--- source4/lib/ldb/common/ldb_ldif.c | 6 ++-- source4/lib/ldb/ldb_tdb/ldb_pack.c | 4 +-- source4/lib/registry/common/reg_util.c | 2 +- .../lib/registry/reg_backend_nt4/reg_backend_nt4.c | 16 ++++----- source4/lib/registry/tools/regpatch.c | 4 +-- source4/lib/replace.c | 2 +- source4/lib/snprintf.c | 4 +-- source4/lib/tdb/common/tdb.c | 4 +-- source4/lib/tdb/tools/tdbdump.c | 2 +- source4/lib/tdb/tools/tdbtool.c | 4 +-- source4/lib/util.c | 4 +-- source4/lib/util_file.c | 6 ++-- source4/lib/util_sock.c | 2 +- source4/lib/util_str.c | 20 +++++------ source4/lib/xfile.c | 2 +- 19 files changed, 76 insertions(+), 76 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/crypto/md4.c b/source4/lib/crypto/md4.c index cc8b9b6841..98fcabf224 100644 --- a/source4/lib/crypto/md4.c +++ b/source4/lib/crypto/md4.c @@ -107,7 +107,7 @@ static void mdfour64(struct mdfour_state *s, uint32_t *M) X[j] = 0; } -static void copy64(uint32_t *M, const unsigned char *in) +static void copy64(uint32_t *M, const uint8_t *in) { int i; @@ -116,7 +116,7 @@ static void copy64(uint32_t *M, const unsigned char *in) (in[i*4+1]<<8) | (in[i*4+0]<<0); } -static void copy4(unsigned char *out, uint32_t x) +static void copy4(uint8_t *out, uint32_t x) { out[0] = x&0xFF; out[1] = (x>>8)&0xFF; @@ -125,9 +125,9 @@ static void copy4(unsigned char *out, uint32_t x) } /* produce a md4 message digest from data of length n bytes */ -void mdfour(unsigned char *out, const unsigned char *in, int n) +void mdfour(uint8_t *out, const uint8_t *in, int n) { - unsigned char buf[128]; + uint8_t buf[128]; uint32_t M[16]; uint32_t b = n * 8; int i; diff --git a/source4/lib/crypto/md5.c b/source4/lib/crypto/md5.c index dbb3462bd4..a393fc2532 100644 --- a/source4/lib/crypto/md5.c +++ b/source4/lib/crypto/md5.c @@ -27,7 +27,7 @@ static void MD5Transform(uint32_t buf[4], uint32_t const in[16]); /* * Note: this code is harmless on little-endian machines. */ -static void byteReverse(unsigned char *buf, unsigned longs) +static void byteReverse(uint8_t *buf, unsigned longs) { uint32_t t; do { @@ -57,7 +57,7 @@ void MD5Init(struct MD5Context *ctx) * Update context to reflect the concatenation of another buffer full * of bytes. */ -void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) +void MD5Update(struct MD5Context *ctx, uint8_t const *buf, unsigned len) { register uint32_t t; @@ -73,7 +73,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) /* Handle any leading odd-sized chunks */ if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; + uint8_t *p = (uint8_t *) ctx->in + t; t = 64 - t; if (len < t) { @@ -105,10 +105,10 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ -void MD5Final(unsigned char digest[16], struct MD5Context *ctx) +void MD5Final(uint8_t digest[16], struct MD5Context *ctx) { unsigned int count; - unsigned char *p; + uint8_t *p; /* Compute number of bytes mod 64 */ count = (ctx->bits[0] >> 3) & 0x3F; @@ -141,7 +141,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) ((uint32_t *) ctx->in)[15] = ctx->bits[1]; MD5Transform(ctx->buf, (uint32_t *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); + byteReverse((uint8_t *) ctx->buf, 4); memmove(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } diff --git a/source4/lib/genrand.c b/source4/lib/genrand.c index a5002969bd..b37078b284 100644 --- a/source4/lib/genrand.c +++ b/source4/lib/genrand.c @@ -22,21 +22,21 @@ #include "includes.h" -static unsigned char hash[258]; +static uint8_t hash[258]; static uint32_t counter; -static unsigned char *reseed_data; +static uint8_t *reseed_data; static size_t reseed_data_size; /**************************************************************** Copy any user given reseed data. *****************************************************************/ -void set_rand_reseed_data(unsigned char *data, size_t len) +void set_rand_reseed_data(uint8_t *data, size_t len) { SAFE_FREE(reseed_data); reseed_data_size = 0; - reseed_data = (unsigned char *)memdup(data, len); + reseed_data = (uint8_t *)memdup(data, len); if (reseed_data) reseed_data_size = len; } @@ -45,16 +45,16 @@ void set_rand_reseed_data(unsigned char *data, size_t len) Setup the seed. *****************************************************************/ -static void seed_random_stream(unsigned char *seedval, size_t seedlen) +static void seed_random_stream(uint8_t *seedval, size_t seedlen) { - unsigned char j = 0; + uint8_t j = 0; size_t ind; for (ind = 0; ind < 256; ind++) - hash[ind] = (unsigned char)ind; + hash[ind] = (uint8_t)ind; for( ind = 0; ind < 256; ind++) { - unsigned char tc; + uint8_t tc; j += (hash[ind] + seedval[ind%seedlen]); @@ -71,15 +71,15 @@ static void seed_random_stream(unsigned char *seedval, size_t seedlen) Get datasize bytes worth of random data. *****************************************************************/ -static void get_random_stream(unsigned char *data, size_t datasize) +static void get_random_stream(uint8_t *data, size_t datasize) { - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; + uint8_t index_i = hash[256]; + uint8_t index_j = hash[257]; size_t ind; for( ind = 0; ind < datasize; ind++) { - unsigned char tc; - unsigned char t; + uint8_t tc; + uint8_t t; index_i++; index_j += hash[index_i]; @@ -101,10 +101,10 @@ static void get_random_stream(unsigned char *data, size_t datasize) Note that the hash is not initialised. *****************************************************************/ -static void do_filehash(const char *fname, unsigned char *the_hash) +static void do_filehash(const char *fname, uint8_t *the_hash) { - unsigned char buf[1011]; /* deliberate weird size */ - unsigned char tmp_md4[16]; + uint8_t buf[1011]; /* deliberate weird size */ + uint8_t tmp_md4[16]; int fd, n; fd = sys_open(fname,O_RDONLY,0); @@ -133,7 +133,7 @@ static void do_filehash(const char *fname, unsigned char *the_hash) static int do_reseed(BOOL use_fd, int fd) { - unsigned char seed_inbuf[40]; + uint8_t seed_inbuf[40]; uint32_t v1, v2; struct timeval tval; pid_t mypid; if (use_fd) { @@ -181,13 +181,13 @@ static int do_reseed(BOOL use_fd, int fd) Interface to the (hopefully) good crypto random number generator. ********************************************************************/ -void generate_random_buffer( unsigned char *out, int len, BOOL do_reseed_now) +void generate_random_buffer( uint8_t *out, int len, BOOL do_reseed_now) { static BOOL done_reseed = False; static int urand_fd = -1; - unsigned char md4_buf[64]; - unsigned char tmp_buf[16]; - unsigned char *p; + uint8_t md4_buf[64]; + uint8_t tmp_buf[16]; + uint8_t *p; if(!done_reseed || do_reseed_now) { urand_fd = do_reseed(True, urand_fd); diff --git a/source4/lib/iconv.c b/source4/lib/iconv.c index 3f37583e39..65fa45248f 100644 --- a/source4/lib/iconv.c +++ b/source4/lib/iconv.c @@ -458,8 +458,8 @@ static size_t utf8_pull(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { while (*inbytesleft >= 1 && *outbytesleft >= 2) { - const unsigned char *c = (const unsigned char *)*inbuf; - unsigned char *uc = (unsigned char *)*outbuf; + const uint8_t *c = (const uint8_t *)*inbuf; + uint8_t *uc = (uint8_t *)*outbuf; int len = 1; if ((c[0] & 0x80) == 0) { @@ -505,8 +505,8 @@ static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { while (*inbytesleft >= 2 && *outbytesleft >= 1) { - unsigned char *c = (unsigned char *)*outbuf; - const unsigned char *uc = (const unsigned char *)*inbuf; + uint8_t *c = (uint8_t *)*outbuf; + const uint8_t *uc = (const uint8_t *)*inbuf; int len=1; if (uc[1] & 0xf8) { diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index c120ee5f4e..b08c616a05 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -47,7 +47,7 @@ static int base64_decode(char *s) { const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int bit_offset, byte_offset, idx, i, n; - unsigned char *d = (unsigned char *)s; + uint8_t *d = (uint8_t *)s; char *p; n=i=0; @@ -90,7 +90,7 @@ char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len) { const char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int bit_offset, byte_offset, idx, i; - const unsigned char *d = (const unsigned char *)buf; + const uint8_t *d = (const uint8_t *)buf; int bytes = (len*8 + 5)/6; char *out; @@ -123,7 +123,7 @@ char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len) int ldb_should_b64_encode(const struct ldb_val *val) { int i; - unsigned char *p = val->data; + uint8_t *p = val->data; if (val->length == 0 || p[0] == ' ' || p[0] == ':') { return 1; diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index e71679646e..fcbc9bd56d 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -42,7 +42,7 @@ #define LTDB_PACKING_FORMAT_NODN 0x26011966 /* use a portable integer format */ -static void put_uint32(unsigned char *p, int ofs, unsigned int val) +static void put_uint32(uint8_t *p, int ofs, unsigned int val) { p += ofs; p[0] = val&0xFF; @@ -51,7 +51,7 @@ static void put_uint32(unsigned char *p, int ofs, unsigned int val) p[3] = (val>>24) & 0xFF; } -static unsigned int pull_uint32(unsigned char *p, int ofs) +static unsigned int pull_uint32(uint8_t *p, int ofs) { p += ofs; return p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24); diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c index 01d75f1b90..db5e97bf7f 100644 --- a/source4/lib/registry/common/reg_util.c +++ b/source4/lib/registry/common/reg_util.c @@ -55,7 +55,7 @@ char *reg_val_data_string(REG_VAL *v) asciip = ret; for (i=0; i 0) *asciip = ' '; asciip++; } diff --git a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c index 627b5a8f13..fa4b3e4d18 100644 --- a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c +++ b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c @@ -1268,10 +1268,10 @@ static void *nt_alloc_regf_space(REG_HANDLE *h, int size, unsigned int *off) /* * Store a SID at the location provided */ -static int nt_store_SID(REG_HANDLE *regf, DOM_SID *sid, unsigned char *locn) +static int nt_store_SID(REG_HANDLE *regf, DOM_SID *sid, uint8_t *locn) { int i; - unsigned char *p = locn; + uint8_t *p = locn; if (!regf || !sid || !locn) return 0; @@ -1290,11 +1290,11 @@ static int nt_store_SID(REG_HANDLE *regf, DOM_SID *sid, unsigned char *locn) } -static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, unsigned char *locn) +static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, uint8_t *locn) { int size = 0; SEC_ACE *reg_ace = (SEC_ACE *)locn; - unsigned char *p; + uint8_t *p; if (!regf || !ace || !locn) return 0; @@ -1303,7 +1303,7 @@ static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, unsigned char *locn) /* Deal with the length when we have stored the SID */ - p = (unsigned char *)®_ace->info.mask; + p = (uint8_t *)®_ace->info.mask; SIVAL(p, 0, ace->info.mask); p += 4; @@ -1311,7 +1311,7 @@ static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, unsigned char *locn) size += 8; /* Size of the fixed header */ - p = (unsigned char *)®_ace->size; + p = (uint8_t *)®_ace->size; SSVAL(p, 0, size); @@ -1321,9 +1321,9 @@ static int nt_store_ace(REG_HANDLE *regf, SEC_ACE *ace, unsigned char *locn) /* * Store an ACL at the location provided */ -static int nt_store_acl(REG_HANDLE *regf, SEC_ACL *acl, unsigned char *locn) { +static int nt_store_acl(REG_HANDLE *regf, SEC_ACL *acl, uint8_t *locn) { int size = 0, i; - unsigned char *p = locn, *s; + uint8_t *p = locn, *s; if (!regf || !acl || !locn) return 0; diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c index 77c0f710c1..af869d1cfa 100644 --- a/source4/lib/registry/tools/regpatch.c +++ b/source4/lib/registry/tools/regpatch.c @@ -155,7 +155,7 @@ static struct cmd_line *get_cmd_line(int fd) { struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE)); int i = 0, rc; - unsigned char ch; + uint8_t ch; cl->len = INIT_ALLOC; @@ -662,7 +662,7 @@ static CMD_FILE *cmd_file_create(const char *file) * Sec Desc print functions */ -char *str_type(unsigned char type); +char *str_type(uint8_t type); static int nt_apply_reg_command_file(REG_HANDLE *r, const char *cmd_file_name) { diff --git a/source4/lib/replace.c b/source4/lib/replace.c index 189c5bc04d..c186d307e6 100644 --- a/source4/lib/replace.c +++ b/source4/lib/replace.c @@ -328,7 +328,7 @@ duplicate a string #ifdef REPLACE_INET_NTOA char *rep_inet_ntoa(struct in_addr ip) { - unsigned char *p = (unsigned char *)&ip.s_addr; + uint8_t *p = (uint8_t *)&ip.s_addr; static char buf[18]; slprintf(buf, 17, "%d.%d.%d.%d", (int)p[0], (int)p[1], (int)p[2], (int)p[3]); diff --git a/source4/lib/snprintf.c b/source4/lib/snprintf.c index fd31870162..3b04228c42 100644 --- a/source4/lib/snprintf.c +++ b/source4/lib/snprintf.c @@ -219,7 +219,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args } break; case DP_S_MIN: - if (isdigit((unsigned char)ch)) { + if (isdigit((uint8_t)ch)) { min = 10*min + char_to_int (ch); ch = *format++; } else if (ch == '*') { @@ -239,7 +239,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args } break; case DP_S_MAX: - if (isdigit((unsigned char)ch)) { + if (isdigit((uint8_t)ch)) { if (max < 0) max = 0; max = 10*max + char_to_int (ch); diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c index c8ac7babad..b7b9631444 100644 --- a/source4/lib/tdb/common/tdb.c +++ b/source4/lib/tdb/common/tdb.c @@ -1762,7 +1762,7 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, TDB_CONTEXT *tdb; struct stat st; int rev = 0, locked = 0; - unsigned char *vp; + uint8_t *vp; u32 vertest; if (!(tdb = calloc(1, sizeof *tdb))) { @@ -1841,7 +1841,7 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, } rev = (tdb->flags & TDB_CONVERT); } - vp = (unsigned char *)&tdb->header.version; + vp = (uint8_t *)&tdb->header.version; vertest = (((u32)vp[0]) << 24) | (((u32)vp[1]) << 16) | (((u32)vp[2]) << 8) | (u32)vp[3]; tdb->flags |= (vertest==TDB_VERSION) ? TDB_BIGENDIAN : 0; diff --git a/source4/lib/tdb/tools/tdbdump.c b/source4/lib/tdb/tools/tdbdump.c index 9c1dc2761b..1a7128c473 100644 --- a/source4/lib/tdb/tools/tdbdump.c +++ b/source4/lib/tdb/tools/tdbdump.c @@ -35,7 +35,7 @@ static void print_data(TDB_DATA d) { - unsigned char *p = d.dptr; + uint8_t *p = d.dptr; int len = d.dsize; while (len--) { if (isprint(*p) && !strchr("\"\\", *p)) { diff --git a/source4/lib/tdb/tools/tdbtool.c b/source4/lib/tdb/tools/tdbtool.c index 92009dcef4..65bbedf709 100644 --- a/source4/lib/tdb/tools/tdbtool.c +++ b/source4/lib/tdb/tools/tdbtool.c @@ -63,7 +63,7 @@ static TDB_CONTEXT *tdb; static int print_rec(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf, void *state); -static void print_asc(unsigned char *buf,int len) +static void print_asc(uint8_t *buf,int len) { int i; @@ -77,7 +77,7 @@ static void print_asc(unsigned char *buf,int len) printf("%c",isprint(buf[i])?buf[i]:'.'); } -static void print_data(unsigned char *buf,int len) +static void print_data(uint8_t *buf,int len) { int i=0; if (len<=0) return; diff --git a/source4/lib/util.c b/source4/lib/util.c index a4be8f8bf8..dd53d2b174 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -677,7 +677,7 @@ void set_remote_arch(struct server_context *smb, enum remote_arch_types type) } -void print_asc(int level, const unsigned char *buf,int len) +void print_asc(int level, const uint8_t *buf,int len) { int i; for (i=0;i> 4]; - s[j+2] = hex[((unsigned char)buf[i]) & 0xF]; + s[j+1] = hex[((uint8_t)buf[i]) >> 4]; + s[j+2] = hex[((uint8_t)buf[i]) & 0xF]; j += 3; } s[j] = 0; @@ -1210,7 +1210,7 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex) { size_t i; size_t num_chars = 0; - unsigned char lonybble, hinybble; + uint8_t lonybble, hinybble; const char *hexchars = "0123456789ABCDEF"; char *p1 = NULL, *p2 = NULL; @@ -1302,7 +1302,7 @@ DATA_BLOB base64_decode_data_blob(const char *s) { int bit_offset, byte_offset, idx, i, n; DATA_BLOB decoded = data_blob(s, strlen(s)+1); - unsigned char *d = decoded.data; + uint8_t *d = decoded.data; char *p; n=i=0; @@ -1357,7 +1357,7 @@ char * base64_encode_data_blob(DATA_BLOB data) char *result = malloc(output_len); /* get us plenty of space */ while (len-- && out_cnt < (data.length * 2) - 5) { - int c = (unsigned char) *(data.data++); + int c = (uint8_t) *(data.data++); bits += c; char_count++; if (char_count == 3) { diff --git a/source4/lib/xfile.c b/source4/lib/xfile.c index 1534dd855e..de4cf4b12a 100644 --- a/source4/lib/xfile.c +++ b/source4/lib/xfile.c @@ -306,7 +306,7 @@ int x_fgetc(XFILE *f) return EOF; } - ret = *(unsigned char *)(f->next); + ret = *(uint8_t *)(f->next); f->next++; f->bufused--; return ret; -- cgit