ObjFW  Check-in [b96b150ce3]

Overview
Comment:OFStream: Add property for writeBufferEnabled.

This also renames the getter to -[isWriteBufferEnabled].

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b96b150ce3568766f9aff98359c7fe3822946f5394bf90b80754b25c2eb102b0
User & Date: js on 2013-01-22 02:31:22
Other Links: manifest | tags
Context
2013-01-23
18:32
extra.mk.in: Remove variables not used anymore. check-in: c7d7db5486 user: js tags: trunk
2013-01-22
02:31
OFStream: Add property for writeBufferEnabled. check-in: b96b150ce3 user: js tags: trunk
2013-01-19
06:36
OFMutableArray: Fix quicksort. check-in: 48f316733e user: js tags: trunk
Changes

Modified src/OFObject.m from [4617a114d5] to [9691c753e2].

803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824

	return method_getTypeEncoding(m);
#endif
}

- (BOOL)isEqual: (id)object
{
	/* Classes containing data should reimplement this! */
	return (self == object);
}

- (uint32_t)hash
{
	/* Classes containing data should reimplement this! */

	uintptr_t ptr = (uintptr_t)self;
	uint32_t hash;

	OF_HASH_INIT(hash);

	while (ptr != 0) {
		OF_HASH_ADD(hash, ptr & 0xFF);







<





<
<







803
804
805
806
807
808
809

810
811
812
813
814


815
816
817
818
819
820
821

	return method_getTypeEncoding(m);
#endif
}

- (BOOL)isEqual: (id)object
{

	return (self == object);
}

- (uint32_t)hash
{


	uintptr_t ptr = (uintptr_t)self;
	uint32_t hash;

	OF_HASH_INIT(hash);

	while (ptr != 0) {
		OF_HASH_ADD(hash, ptr & 0xFF);

Modified src/OFStream.h from [7c8c68988a] to [79e322d7a8].

62
63
64
65
66
67
68

69
70
71
72
73
74
75
	size_t cacheLength, writeBufferLength;
	BOOL   writeBufferEnabled;
	BOOL   blocking;
	BOOL   waitingForDelimiter;
}

#ifdef OF_HAVE_PROPERTIES

@property (getter=isBlocking) BOOL blocking;
@property (readonly, getter=isAtEndOfStream) BOOL atEndOfStream;
#endif

/*!
 * @brief Returns a boolean whether the end of the stream has been reached.
 *







>







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
	size_t cacheLength, writeBufferLength;
	BOOL   writeBufferEnabled;
	BOOL   blocking;
	BOOL   waitingForDelimiter;
}

#ifdef OF_HAVE_PROPERTIES
@property (getter=isWriteBufferEnabled) BOOL writeBufferEnabled;
@property (getter=isBlocking) BOOL blocking;
@property (readonly, getter=isAtEndOfStream) BOOL atEndOfStream;
#endif

/*!
 * @brief Returns a boolean whether the end of the stream has been reached.
 *
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
			 encoding: (of_string_encoding_t)encoding;

/*!
 * @brief Returns a boolen whether writes are buffered.
 *
 * @return A boolean whether writes are buffered
 */
- (BOOL)writeBufferEnabled;

/*!
 * @brief Enables or disables the write buffer.
 *
 * @param enable Whether the write buffer should be enabled or disabled
 */
- (void)setWriteBufferEnabled: (BOOL)enable;







|







690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
			 encoding: (of_string_encoding_t)encoding;

/*!
 * @brief Returns a boolen whether writes are buffered.
 *
 * @return A boolean whether writes are buffered
 */
- (BOOL)isWriteBufferEnabled;

/*!
 * @brief Enables or disables the write buffer.
 *
 * @param enable Whether the write buffer should be enabled or disabled
 */
- (void)setWriteBufferEnabled: (BOOL)enable;

Modified src/OFStream.m from [94745f6f8c] to [bb57582da1].

932
933
934
935
936
937
938
939
940
941
942
943
944
945
946

- (OFString*)tryReadTillDelimiter: (OFString*)delimiter
{
	return [self tryReadTillDelimiter: delimiter
				 encoding: OF_STRING_ENCODING_UTF_8];
}

- (BOOL)writeBufferEnabled
{
	return writeBufferEnabled;
}

- (void)setWriteBufferEnabled: (BOOL)enable
{
	writeBufferEnabled = enable;







|







932
933
934
935
936
937
938
939
940
941
942
943
944
945
946

- (OFString*)tryReadTillDelimiter: (OFString*)delimiter
{
	return [self tryReadTillDelimiter: delimiter
				 encoding: OF_STRING_ENCODING_UTF_8];
}

- (BOOL)isWriteBufferEnabled
{
	return writeBufferEnabled;
}

- (void)setWriteBufferEnabled: (BOOL)enable
{
	writeBufferEnabled = enable;

Modified src/OFTCPSocket+SOCKS5.m from [b1ffa26ad7] to [34ea1ba63e].

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

@implementation OFTCPSocket (SOCKS5)
- (void)OF_SOCKS5ConnectToHost: (OFString*)host
			  port: (uint16_t)port
{
	const char request[] = { 5, 1, 0, 3 };
	char reply[256];
	BOOL oldWriteBufferEnabled;

	/* 5 1 0 -> no authentication */
	[self writeBuffer: request
		   length: 3];

	[self readIntoBuffer: reply
		 exactLength: 2];

	if (reply[0] != 5 || reply[1] != 0) {
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
	}

	oldWriteBufferEnabled = [self writeBufferEnabled];
	[self setWriteBufferEnabled: YES];

	/* CONNECT request */
	[self writeBuffer: request
		   length: 4];
	[self writeInt8: [host UTF8StringLength]];
	[self writeBuffer: [host UTF8String]
		   length: [host UTF8StringLength]];
	[self writeBigEndianInt16: port];

	[self flushWriteBuffer];
	[self setWriteBufferEnabled: oldWriteBufferEnabled];

	[self readIntoBuffer: reply
		 exactLength: 4];

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];
		@throw [OFConnectionFailedException







|

















|











|







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

@implementation OFTCPSocket (SOCKS5)
- (void)OF_SOCKS5ConnectToHost: (OFString*)host
			  port: (uint16_t)port
{
	const char request[] = { 5, 1, 0, 3 };
	char reply[256];
	BOOL wasWriteBufferEnabled;

	/* 5 1 0 -> no authentication */
	[self writeBuffer: request
		   length: 3];

	[self readIntoBuffer: reply
		 exactLength: 2];

	if (reply[0] != 5 || reply[1] != 0) {
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
	}

	wasWriteBufferEnabled = [self isWriteBufferEnabled];
	[self setWriteBufferEnabled: YES];

	/* CONNECT request */
	[self writeBuffer: request
		   length: 4];
	[self writeInt8: [host UTF8StringLength]];
	[self writeBuffer: [host UTF8String]
		   length: [host UTF8StringLength]];
	[self writeBigEndianInt16: port];

	[self flushWriteBuffer];
	[self setWriteBufferEnabled: wasWriteBufferEnabled];

	[self readIntoBuffer: reply
		 exactLength: 4];

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];
		@throw [OFConnectionFailedException