Index: src/OFFile.h ================================================================== --- src/OFFile.h +++ src/OFFile.h @@ -123,11 +123,11 @@ * The buffer MUST be at least size * nitems big! * \return The number of bytes read */ - (size_t)readNItems: (size_t)nitems ofSize: (size_t)size - intoBuffer: (uint8_t*)buf; + intoBuffer: (char*)buf; /** * Writes from a buffer into the file. * * \param buf The buffer from which the data is written to the file @@ -135,7 +135,7 @@ * \param nitem The number of items to write * \return The number of bytes written */ - (size_t)writeNItems: (size_t)nitems ofSize: (size_t)size - fromBuffer: (const uint8_t*)buf; + fromBuffer: (const char*)buf; @end Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -106,11 +106,11 @@ return (feof(fp) == 0 ? NO : YES); } - (size_t)readNItems: (size_t)nitems ofSize: (size_t)size - intoBuffer: (uint8_t*)buf + intoBuffer: (char*)buf { size_t ret; if ((ret = fread(buf, size, nitems, fp)) == 0 && !feof(fp)) @throw [OFReadFailedException newWithClass: [self class] @@ -119,20 +119,20 @@ return ret; } - (size_t)readNBytes: (size_t)size - intoBuffer: (uint8_t*)buf + intoBuffer: (char*)buf { return [self readNItems: size ofSize: 1 intoBuffer: buf]; } - (size_t)writeNItems: (size_t)nitems ofSize: (size_t)size - fromBuffer: (const uint8_t*)buf + fromBuffer: (const char*)buf { size_t ret; if ((ret = fwrite(buf, size, nitems, fp)) == 0 && size != 0 && nitems != 0) @@ -142,11 +142,11 @@ return ret; } - (size_t)writeNBytes: (size_t)size - fromBuffer: (const uint8_t*)buf + fromBuffer: (const char*)buf { return [self writeNItems: size ofSize: 1 fromBuffer: buf]; } @@ -153,11 +153,11 @@ - (size_t)writeCString: (const char*)str { return [self writeNItems: strlen(str) ofSize: 1 - fromBuffer: (const uint8_t*)str]; + fromBuffer: str]; } - close { fclose(fp); Index: src/OFHashes.h ================================================================== --- src/OFHashes.h +++ src/OFHashes.h @@ -19,11 +19,11 @@ */ @interface OFMD5Hash: OFObject { uint32_t buf[4]; uint32_t bits[2]; - uint8_t in[64]; + char in[64]; BOOL calculated; } /** @@ -37,29 +37,29 @@ * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer */ -- updateWithBuffer: (const uint8_t*)buf +- updateWithBuffer: (const char*)buf ofSize: (size_t)size; /** * \return A buffer containing the hash (MD5_DIGEST_SIZE = 16 bytes). * The buffer is part of object's memory pool. */ -- (uint8_t*)digest; +- (char*)digest; @end /** * The OFSHA1Hash class provides functions to create an SHA1 hash. */ @interface OFSHA1Hash: OFObject { uint32_t state[5]; uint64_t count; - uint8_t buffer[64]; - uint8_t digest[SHA1_DIGEST_SIZE]; + char buffer[64]; + char digest[SHA1_DIGEST_SIZE]; BOOL calculated; } /** @@ -73,14 +73,14 @@ * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer */ -- updateWithBuffer: (const uint8_t*)buf +- updateWithBuffer: (const char*)buf ofSize: (size_t)size; /** * \return A buffer containing the hash (SHA1_DIGEST_SIZE = 20 bytes). * The buffer is part of object's memory pool. */ -- (uint8_t*)digest; +- (char*)digest; @end Index: src/OFHashes.m ================================================================== --- src/OFHashes.m +++ src/OFHashes.m @@ -135,11 +135,11 @@ } return self; } -- updateWithBuffer: (const uint8_t*)buffer +- updateWithBuffer: (const char*)buffer ofSize: (size_t)size { uint32_t t; if (calculated) @@ -157,11 +157,11 @@ /* Bytes already in shsInfo->data */ t = (t >> 3) & 0x3F; /* Handle any leading odd-sized chunks */ if (t) { - uint8_t *p = (uint8_t*)in + t; + char *p = in + t; t = 64 - t; if (size < t) { memcpy(p, buffer, size); @@ -190,17 +190,17 @@ memcpy(in, buffer, size); return self; } -- (uint8_t*)digest +- (char*)digest { - uint8_t *p; + char *p; size_t count; if (calculated) - return (uint8_t*)buf; + return (char*)buf; /* Compute number of bytes mod 64 */ count = (bits[0] >> 3) & 0x3F; /* @@ -231,15 +231,15 @@ /* Append length in bits and transform */ ((uint32_t*)in)[14] = bits[0]; ((uint32_t*)in)[15] = bits[1]; md5_transform(buf, (uint32_t*)in); - OF_BSWAP_V((uint8_t*)buf, 4); + OF_BSWAP_V((char*)buf, 4); calculated = YES; - return (uint8_t*)buf; + return (char*)buf; } @end #undef F1 #undef F2 @@ -280,19 +280,19 @@ #define R4(v, w, x, y, z, i) \ z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + OF_ROL(v, 5); \ w = OF_ROL(w, 30); typedef union { - uint8_t c[64]; + char c[64]; uint32_t l[16]; } sha1_c64l16_t; static inline void -sha1_transform(uint32_t state[5], const uint8_t buffer[64]) +sha1_transform(uint32_t state[5], const char buffer[64]) { uint32_t a, b, c, d, e; - uint8_t workspace[64]; + char workspace[64]; sha1_c64l16_t *block; block = (sha1_c64l16_t*)workspace; memcpy(block, buffer, 64); @@ -332,12 +332,12 @@ state[3] += d; state[4] += e; } static inline void -sha1_update(uint32_t *state, uint64_t *count, uint8_t *buffer, - const uint8_t *buf, size_t size) +sha1_update(uint32_t *state, uint64_t *count, char *buffer, + const char *buf, size_t size) { size_t i, j; j = (size_t)((*count >> 3) & 63); *count += (size << 3); @@ -375,11 +375,11 @@ } return self; } -- updateWithBuffer: (const uint8_t*)buf +- updateWithBuffer: (const char*)buf ofSize: (size_t)size { if (calculated) return self; if (size == 0) @@ -388,30 +388,30 @@ sha1_update(state, &count, buffer, buf, size); return self; } -- (uint8_t*)digest +- (char*)digest { size_t i; - uint8_t finalcount[8]; + char finalcount[8]; if (calculated) return digest; for (i = 0; i < 8; i++) /* Endian independent */ - finalcount[i] = (uint8_t)((count >> ((7 - (i & 7)) * 8)) & 255); - sha1_update(state, &count, buffer, (const uint8_t*)"\200", 1); + finalcount[i] = (char)((count >> ((7 - (i & 7)) * 8)) & 255); + sha1_update(state, &count, buffer, "\200", 1); while ((count & 504) != 448) - sha1_update(state, &count, buffer, (const uint8_t*)"\0", 1); + sha1_update(state, &count, buffer, "\0", 1); /* Should cause a sha1_transform() */ sha1_update(state, &count, buffer, finalcount, 8); for (i = 0; i < SHA1_DIGEST_SIZE; i++) - digest[i] = (uint8_t)((state[i >> 2] >> + digest[i] = (char)((state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); return digest; } @end Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -20,21 +20,21 @@ * \param size The size of the data that should be read. * The buffer MUST be at least size big! * \return The number of bytes read */ - (size_t)readNBytes: (size_t)size - intoBuffer: (uint8_t*)buf; + intoBuffer: (char*)buf; /** * Writes from a buffer into the stream. * * \param buf The buffer from which the data is written to the stream * \param size The size of the data that should be written * \return The number of bytes written */ - (size_t)writeNBytes: (size_t)size - fromBuffer: (const uint8_t*)buf; + fromBuffer: (const char*)buf; /** * Writes a C string into the stream, without the trailing zero. * * \param str The C string from which the data is written to the stream Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -221,18 +221,18 @@ return newsock; } - (size_t)readNBytes: (size_t)size - intoBuffer: (uint8_t*)buf + intoBuffer: (char*)buf { ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: [self class]]; - switch ((ret = recv(sock, (char*)buf, size, 0))) { + switch ((ret = recv(sock, buf, size, 0))) { case 0: @throw [OFNotConnectedException newWithClass: [self class]]; case -1: @throw [OFReadFailedException newWithClass: [self class] andSize: size]; @@ -241,18 +241,18 @@ /* This is safe, as we already checked < 1 */ return ret; } - (size_t)writeNBytes: (size_t)size - fromBuffer: (const uint8_t*)buf + fromBuffer: (const char*)buf { ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: [self class]]; - if ((ret = send(sock, (char*)buf, size, 0)) == -1) + if ((ret = send(sock, buf, size, 0)) == -1) @throw [OFWriteFailedException newWithClass: [self class] andSize: size]; /* This is safe, as we already checked for -1 */ return ret; @@ -262,11 +262,11 @@ { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: [self class]]; return [self writeNBytes: strlen(str) - fromBuffer: (const uint8_t*)str]; + fromBuffer: str]; } - setBlocking: (BOOL)enable { #ifndef _WIN32 Index: tests/OFHashes/OFHashes.m ================================================================== --- tests/OFHashes/OFHashes.m +++ tests/OFHashes/OFHashes.m @@ -24,12 +24,12 @@ "\x94\xE7\x17"; int main() { - uint8_t buf[64]; - size_t len; + char buf[64]; + size_t len; OFMD5Hash *md5 = [OFMD5Hash md5Hash]; OFSHA1Hash *sha1 = [OFSHA1Hash sha1Hash]; OFFile *f = [OFFile fileWithPath: "testfile" andMode: "rb"]; Index: tests/OFTCPSocket/OFTCPSocket.m ================================================================== --- tests/OFTCPSocket/OFTCPSocket.m +++ tests/OFTCPSocket/OFTCPSocket.m @@ -56,11 +56,11 @@ accepted = [server accept]; [client writeCString: "Hallo!"]; [accepted readNBytes: 6 - intoBuffer: (uint8_t*)buf]; + intoBuffer: buf]; buf[6] = 0; if (!strcmp(buf, "Hallo!")) puts("Received correct string!"); else { @@ -88,11 +88,11 @@ accepted = [server accept]; [client writeCString: "IPv6:)"]; [accepted readNBytes: 6 - intoBuffer: (uint8_t*)buf]; + intoBuffer: buf]; buf[6] = 0; if (!strcmp(buf, "IPv6:)")) puts("Received correct string!"); else {