ObjFW  Check-in [9d883d2ff6]

Overview
Comment:Pass the hash for OFHashAlreadyCalculatedExceptions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9d883d2ff6b5781e72d1f5beddb53c8e18fb5fe862e549d8960255469782f551
User & Date: js on 2011-03-25 03:14:19
Other Links: manifest | tags
Context
2011-03-25
03:28
Export LIBRARY_PATH (for Haiku). check-in: ffad44fe10 user: js tags: trunk
03:14
Pass the hash for OFHashAlreadyCalculatedExceptions. check-in: 9d883d2ff6 user: js tags: trunk
02:52
Add Haiku to PLATFORMS. check-in: 0dc253f076 user: js tags: trunk
Changes

Modified src/OFMD5Hash.m from [a683cdb443] to [8c8aeaf4bf].

151
152
153
154
155
156
157
158


159
160
161
162
163
164
165
151
152
153
154
155
156
157

158
159
160
161
162
163
164
165
166







-
+
+







{
	uint32_t t;

	if (size == 0)
		return;

	if (isCalculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];
		@throw [OFHashAlreadyCalculatedException newWithClass: isa
								 hash: self];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)
		/* Carry from low to high */
		bits[1]++;
	bits[1] += (uint32_t)size >> 29;

Modified src/OFSHA1Hash.m from [e9824a1431] to [c68eae11dd].

160
161
162
163
164
165
166
167


168
169
170
171
172
173
174
160
161
162
163
164
165
166

167
168
169
170
171
172
173
174
175







-
+
+







- (void)updateWithBuffer: (const char*)buf
		  ofSize: (size_t)size
{
	if (size == 0)
		return;

	if (isCalculated)
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];
		@throw [OFHashAlreadyCalculatedException newWithClass: isa
								 hash: self];

	sha1_update(state, &count, buffer, buf, size);
}

- (uint8_t*)digest
{
	size_t i;

Modified src/exceptions/OFHashAlreadyCalculatedException.h from [70006c7f3f] to [2e897eadfa].

12
13
14
15
16
17
18


19
20
21
22




























23
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53







+
+




+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFHash;

/**
 * \brief An exception indicating that the hash has already been calculated.
 */
@interface OFHashAlreadyCalculatedException: OFException
{
	OFHash *hash;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFHash *hash;
#endif

/**
 * \param hash The hash which has already been calculated
 * \return A new hash already calculated exception
 */
+ newWithClass: (Class)class_
	  hash: (OFHash*)hash;

/**
 * Initializes an already allocated hash already calculated exception.
 *
 * \param hash The hash which has already been calculated
 * \return An initialized hash already calculated exception
 */
- initWithClass: (Class)class_
	   hash: (OFHash*)hash;

/**
 * \return The hash which has already been calculated
 */
- (OFHash*)hash;
@end

Modified src/exceptions/OFHashAlreadyCalculatedException.m from [335ea6194f] to [2396ce4fe7].

14
15
16
17
18
19
20
21


22





































23
24
25
26
27
28
29
30
31
32
33





34
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78








+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+











+
+
+
+
+

 * file.
 */

#include "config.h"

#import "OFHashAlreadyCalculatedException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFHashAlreadyCalculatedException
+ newWithClass: (Class)class_
	  hash: (OFHash*)hash
{
	return [[self alloc] initWithClass: class_
				      hash: hash];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	   hash: (OFHash*)hash_
{
	self = [super initWithClass: class_];

	@try {
		hash = [hash_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[hash release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"The hash has already been calculated in class %@ and thus no new "
	    @"data can be added", inClass];

	return description;
}

- (OFHash*)hash
{
	return hash;
}
@end