ObjFW  Check-in [1d19a5586b]

Overview
Comment:Always write abbreviations uppercase in method names.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1d19a5586b544267e0cdfef3909de6ca261e5b4e339ce2fdd1a63bf783f3a8ba
User & Date: js on 2010-10-24 13:30:16
Other Links: manifest | tags
Context
2010-10-24
13:31
Hide an internal protocol from Doxygen. check-in: eb7788d3de user: js tags: trunk
13:30
Always write abbreviations uppercase in method names. check-in: 1d19a5586b user: js tags: trunk
13:15
Rename a few methods returning BOOL. check-in: b6a39dd3d1 user: js tags: trunk
Changes

Modified src/OFMD5Hash.h from [06018586de] to [c66d914130].

22
23
24
25
26
27
28
29
30
	uint32_t bits[2];
	uint8_t	 in[64];
}

/**
 * \return A new autoreleased MD5 Hash
 */
+ md5Hash;
@end







|

22
23
24
25
26
27
28
29
30
	uint32_t bits[2];
	uint8_t	 in[64];
}

/**
 * \return A new autoreleased MD5 Hash
 */
+ MD5Hash;
@end

Modified src/OFMD5Hash.m from [e3c55f9a8d] to [de7c13bd7c].

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
	buf[0] += a;
	buf[1] += b;
	buf[2] += c;
	buf[3] += d;
}

@implementation OFMD5Hash
+ md5Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];







|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
	buf[0] += a;
	buf[1] += b;
	buf[2] += c;
	buf[3] += d;
}

@implementation OFMD5Hash
+ MD5Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

Modified src/OFSHA1Hash.h from [27f80634e2] to [57be483b7f].

23
24
25
26
27
28
29
30
31
	char	 buffer[64];
	uint8_t	 digest[OF_SHA1_DIGEST_SIZE];
}

/**
 * \return A new autoreleased SHA1 Hash
 */
+ sha1Hash;
@end







|

23
24
25
26
27
28
29
30
31
	char	 buffer[64];
	uint8_t	 digest[OF_SHA1_DIGEST_SIZE];
}

/**
 * \return A new autoreleased SHA1 Hash
 */
+ SHA1Hash;
@end

Modified src/OFSHA1Hash.m from [0f9a7bf269] to [67e6e5137b].

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
	} else
		i = 0;

	memcpy(&buffer[j], &buf[i], size - i);
}

@implementation OFSHA1Hash
+ sha1Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];







|







122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
	} else
		i = 0;

	memcpy(&buffer[j], &buf[i], size - i);
}

@implementation OFSHA1Hash
+ SHA1Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

Modified src/OFString+Hashing.h from [04e6b3c3c1] to [b69535aff5].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
 * The OFString (OFHashing) category provides methods to calculate hashes for
 * strings.
 */
@interface OFString (Hashing)
/**
 * \return The MD5 hash of the string as an autoreleased OFString
 */
- (OFString*)md5Hash;

/**
 * \return The SHA1 hash of the string as an autoreleased OFString
 */
- (OFString*)sha1Hash;
@end







|




|

17
18
19
20
21
22
23
24
25
26
27
28
29
30
 * The OFString (OFHashing) category provides methods to calculate hashes for
 * strings.
 */
@interface OFString (Hashing)
/**
 * \return The MD5 hash of the string as an autoreleased OFString
 */
- (OFString*)MD5Hash;

/**
 * \return The SHA1 hash of the string as an autoreleased OFString
 */
- (OFString*)SHA1Hash;
@end

Modified src/OFString+Hashing.m from [55b99ed0be] to [43e21d118e].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OFMD5Hash.h"
#import "OFSHA1Hash.h"
#import "OFAutoreleasePool.h"

int _OFString_Hashing_reference;

@implementation OFString (Hashing)
- (OFString*)md5Hash
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *hash = [OFMD5Hash md5Hash];
	uint8_t *digest;
	char ret_c[32];
	size_t i;

	[hash updateWithBuffer: string
			ofSize: length];
	digest = [hash digest];







|


|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "OFMD5Hash.h"
#import "OFSHA1Hash.h"
#import "OFAutoreleasePool.h"

int _OFString_Hashing_reference;

@implementation OFString (Hashing)
- (OFString*)MD5Hash
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *hash = [OFMD5Hash MD5Hash];
	uint8_t *digest;
	char ret_c[32];
	size_t i;

	[hash updateWithBuffer: string
			ofSize: length];
	digest = [hash digest];
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

	[pool release];

	return [OFString stringWithCString: ret_c
				    length: 32];
}

- (OFString*)sha1Hash
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *hash = [OFSHA1Hash sha1Hash];
	uint8_t *digest;
	char ret_c[40];
	size_t i;

	[hash updateWithBuffer: string
			ofSize: length];
	digest = [hash digest];







|


|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

	[pool release];

	return [OFString stringWithCString: ret_c
				    length: 32];
}

- (OFString*)SHA1Hash
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *hash = [OFSHA1Hash SHA1Hash];
	uint8_t *digest;
	char ret_c[40];
	size_t i;

	[hash updateWithBuffer: string
			ofSize: length];
	digest = [hash digest];

Modified tests/OFMD5HashTests.m from [38087890ea] to [a1e904da57].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
- (void)MD5HashTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *md5;
	OFFile *f = [OFFile fileWithPath: @"testfile.bin"
				    mode: @"rb"];

	TEST(@"+[md5Hash]", (md5 = [OFMD5Hash md5Hash]))

	while (![f isAtEndOfStream]) {
		char buf[64];
		size_t len = [f readNBytes: 64
				intoBuffer: buf];
		[md5 updateWithBuffer: buf
			       ofSize: len];







|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
- (void)MD5HashTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMD5Hash *md5;
	OFFile *f = [OFFile fileWithPath: @"testfile.bin"
				    mode: @"rb"];

	TEST(@"+[md5Hash]", (md5 = [OFMD5Hash MD5Hash]))

	while (![f isAtEndOfStream]) {
		char buf[64];
		size_t len = [f readNBytes: 64
				intoBuffer: buf];
		[md5 updateWithBuffer: buf
			       ofSize: len];

Modified tests/OFSHA1HashTests.m from [04c4da8f40] to [3b66f80231].

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
- (void)SHA1HashTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFSHA1Hash *sha1;
	OFFile *f = [OFFile fileWithPath: @"testfile.bin"
				    mode: @"rb"];

	TEST(@"+[sha1Hash]", (sha1 = [OFSHA1Hash sha1Hash]))

	while (![f isAtEndOfStream]) {
		char buf[64];
		size_t len = [f readNBytes: 64
				intoBuffer: buf];
		[sha1 updateWithBuffer: buf
				ofSize: len];







|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
- (void)SHA1HashTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFSHA1Hash *sha1;
	OFFile *f = [OFFile fileWithPath: @"testfile.bin"
				    mode: @"rb"];

	TEST(@"+[sha1Hash]", (sha1 = [OFSHA1Hash SHA1Hash]))

	while (![f isAtEndOfStream]) {
		char buf[64];
		size_t len = [f readNBytes: 64
				intoBuffer: buf];
		[sha1 updateWithBuffer: buf
				ofSize: len];

Modified tests/OFStringTests.m from [c0a35cb08c] to [4069c78118].

259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
	    [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	     @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	    hexadecimalValueAsInteger])

	TEST(@"-[unicodeString]", (ua = [@"fööbär" unicodeString]) &&
	    !memcmp(ua, ucstr, 7 * sizeof(of_unichar_t)) && R(free(ua)))

	TEST(@"-[md5Hash]", [[@"asdfoobar" md5Hash]
	    isEqual: @"184dce2ec49b5422c7cfd8728864db4c"])

	TEST(@"-[sha1Hash]", [[@"asdfoobar" sha1Hash]
	    isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"])

	TEST(@"-[stringByURLEncoding]",
	    [[@"foo\"ba'_~$" stringByURLEncoding] isEqual: @"foo%22ba%27_~%24"])

	TEST(@"-[stringByURLDecoding]",
	    [[@"foo%20bar%22+%24" stringByURLDecoding] isEqual: @"foo bar\" $"])







|


|







259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
	    [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	     @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
	    hexadecimalValueAsInteger])

	TEST(@"-[unicodeString]", (ua = [@"fööbär" unicodeString]) &&
	    !memcmp(ua, ucstr, 7 * sizeof(of_unichar_t)) && R(free(ua)))

	TEST(@"-[MD5Hash]", [[@"asdfoobar" MD5Hash]
	    isEqual: @"184dce2ec49b5422c7cfd8728864db4c"])

	TEST(@"-[SHA1Hash]", [[@"asdfoobar" SHA1Hash]
	    isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"])

	TEST(@"-[stringByURLEncoding]",
	    [[@"foo\"ba'_~$" stringByURLEncoding] isEqual: @"foo%22ba%27_~%24"])

	TEST(@"-[stringByURLDecoding]",
	    [[@"foo%20bar%22+%24" stringByURLDecoding] isEqual: @"foo bar\" $"])