ObjFW  Check-in [9d064462a3]

Overview
Comment:Add -[fileDescriptor] to OFStream.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9d064462a331e92a4abe5ec96c41d4df8b3ab990e6a4ea9bc794f5af40f83a77
User & Date: js on 2010-07-07 20:46:43
Other Links: manifest | tags
Context
2010-07-07
20:48
Rename OFSocketObserver to OFStreamObserver and make it more general. check-in: 52dcb22b8c user: js tags: trunk
20:46
Add -[fileDescriptor] to OFStream. check-in: 9d064462a3 user: js tags: trunk
2010-07-03
17:28
Import OFXMLElementBuilder in ObjFW.h. check-in: bc26452995 user: js tags: trunk
Changes

Modified src/Makefile from [42133a0ca4] to [1900e0a870].

21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36







-

+







       OFMutableString.m	\
       OFNumber.m		\
       OFObject.m		\
       ${OFPLUGIN_M}		\
       OFSeekableStream.m	\
       OFSHA1Hash.m		\
       OFSocket.m		\
       OFSocketObserver.m	\
       OFStream.m		\
       OFStreamObserver.m	\
       OFString.m		\
       OFString+Hashing.m	\
       OFString+URLEncoding.m	\
       OFString+XMLEscaping.m	\
       OFString+XMLUnescaping.m	\
       OFTCPSocket.m		\
       ${OFTHREAD_M}		\

Modified src/OFFile.h from [8446a405ae] to [d16324c2ea].

17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31







-
+







@class OFArray;

/**
 * \brief A class which provides functions to read, write and manipulate files.
 */
@interface OFFile: OFSeekableStream
{
	int fd;
	int  fd;
	BOOL closable;
	BOOL eos;
}

/**
 * \param path The path to the file to open as a string
 * \param mode The mode in which the file should be opened as a string

Modified src/OFFile.m from [bf7134d6ef] to [1cd28fbc32].

512
513
514
515
516
517
518





519
520
521
522
523
524
525
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530







+
+
+
+
+







	off_t ret;

	if ((ret = lseek(fd, offset, SEEK_END)) == -1)
		@throw [OFSeekFailedException newWithClass: isa];

	return ret;
}

- (int)fileDescriptor
{
	return fd;
}

- (void)close
{
	if (fd != -1)
		close(fd);
	fd = -1;
}

Modified src/OFSocket.m from [7d46692d8a] to [26b969d2ec].

115
116
117
118
119
120
121





122
115
116
117
118
119
120
121
122
123
124
125
126
127







+
+
+
+
+

#else
	u_long v = enable;

	if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException newWithClass: isa];
#endif
}

- (int)fileDescriptor
{
	return sock;
}
@end

Modified src/OFStream.h from [447ea06b1e] to [c21dc06749].

301
302
303
304
305
306
307





308
309
310
311
312
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317







+
+
+
+
+





 * \param fmt A string used as format
 * \param args The arguments used in the format string
 * \return The number of bytes written
 */
- (size_t)writeFormat: (OFString*)fmt
	withArguments: (va_list)args;

/**
 * \return The file descriptor for the stream.
 */
- (int)fileDescriptor;

/**
 * Closes the stream.
 */
- (void)close;
@end

Modified src/OFStream.m from [451931881c] to [5b369f2077].

643
644
645
646
647
648
649






650
651
652
653
654
655
656
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662







+
+
+
+
+
+







	} @finally {
		free(t);
	}

	/* Get rid of a warning, never reached anyway */
	assert(0);
}

- (int)fileDescriptor
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (void)close
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end

Modified tests/OFXMLElementBuilderTests.m from [cd0adc4059] to [5f20b80e90].

10
11
12
13
14
15
16
17

18

19
20
21
22
23
24
25
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26







-
+

+







 */

#include "config.h"

#include <string.h>
#include <assert.h>

#import "OFXMLElementBuilder.h"
#import "OFXMLElement.h"
#import "OFXMLParser.h"
#import "OFXMLElementBuilder.h"
#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"

static OFString *module = @"OFXMLElementBuilder";
static OFXMLElement *elem = nil;