summaryrefslogtreecommitdiff
path: root/src/tools/genunicode.c
blob: 0329ace326960db3fa7668f4c5e656d91e701d05 (plain) (blame)
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
/* 
 * Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com>
 *
 * This file is part of aplwc.
 *
 * Aplwc is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Aplwc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with aplwc.  If not, see <https://www.gnu.org/licenses/>.
 */

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

static char *files[] = {
	"DerivedCoreProperties.txt",
	"PropList.txt"
};

int
main(int argc, char *argv[])
{
	FILE *f;
	char *dir, *buf;
	size_t dir_size, tmp_size, max_size, i, nfiles;

	assert(argc == 2);
	dir = argv[1];
	dir_size = strlen(dir);

	if(dir[dir_size-1] == '/')
		dir_size--;

	nfiles = sizeof(files)/sizeof(files[0]);

	max_size = 0;
	for(i = 0; i < nfiles; i++){
		tmp_size = strlen(files[i]);
		if(tmp_size > max_size)
			max_size = tmp_size;
	}
	max_size += dir_size + 2;
	buf = malloc(max_size);
	assert(buf != NULL);
	memcpy(buf, dir, dir_size);
	buf[dir_size] = '/';

	for(i = 0; i < sizeof(files)/sizeof(files[0]); i++){
		memcpy(buf+dir_size+1, files[i], strlen(files[i])+1);
		f = fopen(buf, "r");
		assert(f != NULL);
		fclose(f);

		printf("/* Unicode file %s read from %s */\n", files[i], buf);
	}

	return 0;
}