ObjFW  Check-in [1483709ab2]

Overview
Comment:Add support for embedding files into binaries

Embedded files are available via the objfw-embedded: URL scheme.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1483709ab2993c9cb4060e3c88d662edb76855dae57ba7a0275c2b334448d61e
User & Date: js on 2022-08-01 21:20:54
Other Links: manifest | tags
Context
2022-08-01
21:25
tests: Remove dependency on files for a few tests check-in: 71d2ab694e user: js tags: trunk
21:20
Add support for embedding files into binaries check-in: 1483709ab2 user: js tags: trunk
2022-07-31
20:33
OFMemoryStream: Remove spurious OF_UNAVAILABLE check-in: 244a072ccf user: js tags: trunk
Changes

Modified .fossil-settings/clean-glob from [fba2645b54] to [52880493af].

35
36
37
38
39
40
41

42

43
44
45
46
47
48
49
50
51
52
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54







+

+










src/tls/Info.plist
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
tests/tests.nro
utils/objfw-config
utils/ofarc/ofarc
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp

Modified .fossil-settings/ignore-glob from [a8ddbc70d8] to [f286c82d30].

40
41
42
43
44
45
46

47

48
49
50
51
52
53
54
55
56
57
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59







+

+










tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
tests/tests.nro
utils/objfw-config
utils/ofarc/ofarc
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp

Modified .gitignore from [30dcd26802] to [c5473b5067].

40
41
42
43
44
45
46

47

48
49
50
51
52
53
54
55
56
57
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59







+

+










tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
tests/tests.nro
utils/objfw-config
utils/ofarc/ofarc
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp

Modified src/Makefile from [d9404b9361] to [1871f1fc55].

18
19
20
21
22
23
24

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







+







       OFConstantString.m		\
       OFCountedSet.m			\
       OFData.m				\
       OFData+CryptographicHashing.m	\
       OFData+MessagePackParsing.m	\
       OFDate.m				\
       OFDictionary.m			\
       OFEmbeddedFileURLHandler.m	\
       OFEnumerator.m			\
       OFFileManager.m			\
       OFGZIPStream.m			\
       OFHMAC.m				\
       OFInflate64Stream.m		\
       OFInflateStream.m		\
       OFInvocation.m			\

Added src/OFEmbeddedFileURLHandler.h version [b889d68d61].
























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * 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 "OFURLHandler.h"

OF_ASSUME_NONNULL_BEGIN

@interface OFEmbeddedFileURLHandler: OFURLHandler
@end

OF_ASSUME_NONNULL_END

Added src/OFEmbeddedFileURLHandler.m version [d67588543e].



















































































































1
2
3
4
5
6
7
8
9
10
11
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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/*
 * Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * 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.
 */

#include "config.h"

#include <stdlib.h>
#include <string.h>

#import "OFEmbeddedFileURLHandler.h"
#import "OFMemoryStream.h"
#import "OFURL.h"

#import "OFInvalidArgumentException.h"
#import "OFOpenItemFailedException.h"

#ifdef OF_HAVE_THREADS
# import "OFOnce.h"
# import "OFPlainMutex.h"
#endif

struct EmbeddedFile {
	const char *name;
	const uint8_t *bytes;
	size_t size;
} *embeddedFiles = NULL;
size_t numEmbeddedFiles = 0;
#ifdef OF_HAVE_THREADS
static OFPlainMutex mutex;

static void
init(void)
{
	OFEnsure(OFPlainMutexNew(&mutex) == 0);
}
#endif

void
OFRegisterEmbeddedFile(const char *name, const uint8_t *bytes, size_t size)
{
#ifdef OF_HAVE_THREADS
	static OFOnceControl onceControl = OFOnceControlInitValue;
	OFOnce(&onceControl, init);

	OFEnsure(OFPlainMutexLock(&mutex) == 0);
#endif

	embeddedFiles = realloc(embeddedFiles,
	    sizeof(*embeddedFiles) * (numEmbeddedFiles + 1));
	OFEnsure(embeddedFiles != NULL);

	embeddedFiles[numEmbeddedFiles].name = name;
	embeddedFiles[numEmbeddedFiles].bytes = bytes;
	embeddedFiles[numEmbeddedFiles].size = size;
	numEmbeddedFiles++;

#ifdef OF_HAVE_THREADS
	OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
#endif
}

@implementation OFEmbeddedFileURLHandler
- (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode
{
	const char *path;

	if (![mode isEqual: @"r"])
		@throw [OFOpenItemFailedException exceptionWithURL: URL
							      mode: mode
							     errNo: EROFS];

	if (URL.host != nil || URL.port != nil || URL.user != nil ||
	    URL.password != nil || URL.query != nil || URL.fragment != nil)
		@throw [OFInvalidArgumentException exception];

	if ((path = URL.path.UTF8String) == NULL)
		@throw [OFInvalidArgumentException exception];

#ifdef OF_HAVE_THREADS
	OFEnsure(OFPlainMutexLock(&mutex) == 0);
	@try {
		for (size_t i = 0; i < numEmbeddedFiles; i++) {
			if (strcmp(embeddedFiles[i].name, path) != 0)
				continue;

			return [OFMemoryStream
			    streamWithMemoryAddress: (void *)
							 embeddedFiles[i].bytes
					       size: embeddedFiles[i].size
					   writable: false];
		}
#endif
#ifdef OF_HAVE_THREADS
	} @finally {
		OFEnsure(OFPlainMutexUnlock(&mutex) == 0);
	}
#endif

	@throw [OFOpenItemFailedException exceptionWithURL: URL
						      mode: mode
						     errNo: ENOENT];
}
@end

Modified src/OFString.m from [05a5b5b79b] to [0292b59c78].

1080
1081
1082
1083
1084
1085
1086




1087
1088
1089
1090
1091
1092
1093
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097







+
+
+
+








	@try {
		data = [OFData dataWithContentsOfURL: URL];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	/* FIXME: Detect encoding where we can. */
	if (encoding == OFStringEncodingAutodetect)
		encoding = OFStringEncodingUTF8;

	self = [self initWithCString: data.items
			    encoding: encoding
			      length: data.count * data.itemSize];

	objc_autoreleasePoolPop(pool);

Modified src/OFURL.m from [8192f78e14] to [54ccbf7591].

553
554
555
556
557
558
559
560

561
562
563





564


565
566
567
568
569
570
571
553
554
555
556
557
558
559

560
561
562
563
564
565
566
567
568

569
570
571
572
573
574
575
576
577







-
+



+
+
+
+
+
-
+
+







			portString = [OFString stringWithUTF8String: tmp2];

			if (portString.unsignedLongLongValue > 65535)
				@throw [OFInvalidFormatException exception];

			_port = [[OFNumber alloc] initWithUnsignedShort:
			    portString.unsignedLongLongValue];
		} else
		} else {
			_URLEncodedHost = [[OFString alloc]
			    initWithUTF8String: UTF8String];

			if (_URLEncodedHost.length == 0) {
				[_URLEncodedHost release];
				_URLEncodedHost = nil;
			}
		}
		if (!isIPv6Host)

		if (_URLEncodedHost != nil && !isIPv6Host)
			OFURLVerifyIsEscaped(_URLEncodedHost,
			    [OFCharacterSet URLHostAllowedCharacterSet]);

		if ((UTF8String = tmp) != NULL) {
			if ((tmp = strchr(UTF8String, '#')) != NULL) {
				*tmp = '\0';

Modified src/OFURLHandler.m from [0e5a95e00a] to [c3c8bcc62a].

20
21
22
23
24
25
26

27
28
29
30
31
32
33
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34







+







#import "OFNumber.h"
#import "OFURL.h"

#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif

#import "OFEmbeddedFileURLHandler.h"
#ifdef OF_HAVE_FILES
# import "OFFileURLHandler.h"
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
# import "OFHTTPURLHandler.h"
#endif

52
53
54
55
56
57
58


59
60
61
62
63
64
65
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68







+
+








	handlers = [[OFMutableDictionary alloc] init];
#ifdef OF_HAVE_THREADS
	mutex = [[OFMutex alloc] init];
	atexit(releaseMutex);
#endif

	[self registerClass: [OFEmbeddedFileURLHandler class]
		  forScheme: @"objfw-embedded"];
#ifdef OF_HAVE_FILES
	[self registerClass: [OFFileURLHandler class] forScheme: @"file"];
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
	[self registerClass: [OFHTTPURLHandler class] forScheme: @"http"];
	[self registerClass: [OFHTTPURLHandler class] forScheme: @"https"];
#endif

Modified tests/Makefile from [7038754df0] to [a81e7d8878].

1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20










-
+
+
+







include ../extra.mk

SUBDIRS = ${TESTPLUGIN}	\
	  ${OBJC_SYNC}	\
	  terminal

CLEAN = EBOOT.PBP		\
	boot.dol		\
	${PROG_NOINST}.arm9	\
	${PROG_NOINST}.nds	\
	${PROG_NOINST}.nro
	${PROG_NOINST}.nro	\
	serialization_xml.m	\
	testfile_bin.m
DISTCLEAN = Info.plist

PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m		\
       OFArrayTests.m			\
       ${OF_BLOCK_TESTS_M}		\
44
45
46
47
48
49
50
51



52
53
54
55
56
57
58
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60
61
62







-
+
+
+







       RuntimeTests.m			\
       ${RUNTIME_ARC_TESTS_M}		\
       TestsAppDelegate.m		\
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_THREADS}		\
       ${USE_SRCS_WINDOWS}
       ${USE_SRCS_WINDOWS}		\
       serialization_xml.m		\
       testfile_bin.m
SRCS_FILES = OFHMACTests.m		\
	     OFINIFileTests.m		\
	     OFMD5HashTests.m		\
	     OFRIPEMD160HashTests.m	\
	     OFSerializationTests.m	\
	     OFSHA1HashTests.m		\
	     OFSHA224HashTests.m	\
79
80
81
82
83
84
85





86
87
88
89
90
91
92
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101







+
+
+
+
+







SRCS_WINDOWS = OFWindowsRegistryKeyTests.m

IOS_USER ?= mobile
IOS_TMP ?= /tmp/objfw-test

include ../buildsys.mk

serialization_xml.m: serialization.xml
	${SHELL} ../utils/objfw-embed $< /$< $@
testfile_bin.m: testfile.bin
	${SHELL} ../utils/objfw-embed $< /$< $@

.PHONY: run run-on-ios run-on-android
run:
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
	rm -f objfw${OBJFW_LIB_MAJOR}.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
	rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR}
	rm -f libobjfwrt.so.${OBJFWRT_LIB_MAJOR_MINOR}

Modified tests/OFHMACTests.m from [7c5227bed5] to [bac63969c0].

47
48
49
50
51
52
53


54

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

56
57
58
59
60
61
62
63







+
+
-
+







    "\x61\xB3\xF9\x1A\xE3\x09\x43\xA6\x5B\x85\xB1\x50\x5B\xCB\x1A\x2E"
    "\xB7\xE8\x87\xC1\x73\x19\x63\xF6\xA2\x91\x8D\x7E\x2E\xCC\xEC\x99";

@implementation TestsAppDelegate (OFHMACTests)
- (void)HMACTests
{
	void *pool = objc_autoreleasePoolPush();
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];
	OFHMAC *HMACMD5, *HMACSHA1, *HMACRMD160;
	OFHMAC *HMACSHA256, *HMACSHA384, *HMACSHA512;

	TEST(@"+[HMACWithHashClass:] with MD5",
	    (HMACMD5 = [OFHMAC HMACWithHashClass: [OFMD5Hash class]
			   allowsSwappableMemory: true]))
	TEST(@"+[HMACWithHashClass:] with SHA-1",

Modified tests/OFMD5HashTests.m from [6eb26d1d7b] to [66b4d11501].

25
26
27
28
29
30
31


32

33
34
35
36
37
38
39
25
26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41







+
+
-
+







    "\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38";

@implementation TestsAppDelegate (OFMD5HashTests)
- (void)MD5HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFMD5Hash *MD5, *MD5Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (MD5 = [OFMD5Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFRIPEMD160HashTests.m from [4b80756e64] to [d9eb71eb42].

26
27
28
29
30
31
32


33

34
35
36
37
38
39
40
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42







+
+
-
+







	"\xE6\x08\x8B";

@implementation TestsAppDelegate (OFRIPEMD160HashTests)
- (void)RIPEMD160HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFRIPEMD160Hash *RIPEMD160, *RIPEMD160Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (RIPEMD160 = [OFRIPEMD160Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA1HashTests.m from [f5847018f6] to [8dbe2b957f].

26
27
28
29
30
31
32


33

34
35
36
37
38
39
40
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42







+
+
-
+







	"\x94\xE7\x17";

@implementation TestsAppDelegate (SHA1HashTests)
- (void)SHA1HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA1Hash *SHA1, *SHA1Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA1 = [OFSHA1Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA224HashTests.m from [f0d335ef4f] to [3be83604b4].

26
27
28
29
30
31
32


33

34
35
36
37
38
39
40
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42







+
+
-
+







	"\x5F\x4F\x20\x02\x4D\x15\xED\x1C\x61\x1F\xF7";

@implementation TestsAppDelegate (SHA224HashTests)
- (void)SHA224HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA224Hash *SHA224, *SHA224Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA224 = [OFSHA224Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA256HashTests.m from [2075144684] to [2658ed96c0].

26
27
28
29
30
31
32


33

34
35
36
37
38
39
40
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42







+
+
-
+







	"\x67\x93\x8F\x0F\x44\x90\xB8\xF5\x35\x89\xF0\x5A\x23\x7F\x69";

@implementation TestsAppDelegate (SHA256HashTests)
- (void)SHA256HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA256Hash *SHA256, *SHA256Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA256 = [OFSHA256Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[64];
		size_t length = [file readIntoBuffer: buffer length: 64];

Modified tests/OFSHA384HashTests.m from [9815671ea1] to [dd9d5ffdb4].

27
28
29
30
31
32
33


34

35
36
37
38
39
40
41
27
28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43







+
+
-
+







	"\xE9\x1A\xB3\x51\x70\x8C\x1F\x3F\x56\x12\x44\x01\x91\x54";

@implementation TestsAppDelegate (SHA384HashTests)
- (void)SHA384HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA384Hash *SHA384, *SHA384Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA384 = [OFSHA384Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[128];
		size_t length = [file readIntoBuffer: buffer length: 128];

Modified tests/OFSHA512HashTests.m from [8ea1d53446] to [759fed7ea6].

28
29
30
31
32
33
34


35

36
37
38
39
40
41
42
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44







+
+
-
+







	"\xA1\x8A\x41\x64\x33\x69\x21\x8C\x2A\x44\x6D\xF2\xA0";

@implementation TestsAppDelegate (SHA512HashTests)
- (void)SHA512HashTests
{
	void *pool = objc_autoreleasePoolPush();
	OFSHA512Hash *SHA512, *SHA512Copy;
	OFURL *URL = [OFURL URLWithString: @"objfw-embedded:///testfile.bin"];
	OFStream *file = [[OFURLHandler handlerForURL: URL]
	OFFile *file = [OFFile fileWithPath: @"testfile.bin" mode: @"r"];
	    openItemAtURL: URL mode: @"r"];

	TEST(@"+[hashWithAllowsSwappableMemory:]",
	    (SHA512 = [OFSHA512Hash hashWithAllowsSwappableMemory: true]))

	while (!file.atEndOfStream) {
		char buffer[128];
		size_t length = [file readIntoBuffer: buffer length: 128];

Modified tests/OFSerializationTests.m from [5fdb00c13b] to [8a1b6d269b].

57
58
59
60
61
62
63
64


65
66
67
68
69
70
71
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72







-
+
+








	UUID = [OFUUID
	    UUIDWithUUIDString: @"01234567-89AB-CDEF-FEDC-BA9876543210"];
	[dict setObject: @"uuid" forKey: UUID];

	TEST(@"-[stringBySerializing]",
	    (string = dict.stringBySerializing) && [string isEqual:
	    [OFString stringWithContentsOfFile: @"serialization.xml"]])
	    [OFString stringWithContentsOfURL: [OFURL URLWithString:
	    @"objfw-embedded:///serialization.xml"]]])

	TEST(@"-[objectByDeserializing]",
	    [string.objectByDeserializing isEqual: dict])

	objc_autoreleasePoolPop(pool);
}
@end

Modified utils/Makefile from [521b7f89ce] to [4d169fd4a2].

1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21













-
+







include ../extra.mk

SUBDIRS += ${OFARC}	\
	   ${OFDNS}	\
	   ${OFHASH}	\
	   ${OFHTTP}	\
	   completions

include ../buildsys.mk

DISTCLEAN = objfw-config

install-extra: objfw-config objfw-compile objfw-new
	for i in objfw-config objfw-compile objfw-new; do \
	for i in objfw-config objfw-compile objfw-embed objfw-new; do \
		${INSTALL_STATUS}; \
		if ${MKDIR_P} ${DESTDIR}${bindir} && ${INSTALL} -m 755 $$i ${DESTDIR}${bindir}/${BIN_PREFIX}$$i; then \
			${INSTALL_OK}; \
		else \
			${INSTALL_FAILED}; \
		fi \
	done

Added utils/objfw-embed version [e04090f696].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#!/bin/sh
if test $# != 3; then
	echo "Usage: $0 source_file filename output.m" 1>&2
	exit 1
fi

exec 1>$3

cat <<EOF
#include <stddef.h>
#include <stdint.h>

extern void OFRegisterEmbeddedFile(const char *, const uint8_t *, size_t);

static const uint8_t bytes[] = {
EOF
od -tx1 $1 | cut -s -d' ' -f 2- | sed 's/^/	0x/;s/ /, 0x/g;s/$/,/'
cat <<EOF
};

static void __attribute__((__constructor__))
ctor(void)
{
	OFRegisterEmbeddedFile("$2", bytes, sizeof(bytes));
}
EOF