2 * gen-unicode-version.c - generate fribidi-unicode-version.h
5 * Behdad Esfahbod, 2001, 2002, 2004
7 * Copyright (C) 2004 Sharif FarsiWeb, Inc
8 * Copyright (C) 2004 Behdad Esfahbod
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library, in a file named COPYING; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA
25 * For licensing issues, contact <fribidi.license@gmail.com>.
40 # if !STDC_HEADERS && HAVE_MEMORY_H
51 #define appname "gen-unicode-version"
52 #define outputname "fribidi-unicode-version.h"
59 fprintf (stderr, appname ": %s\n", msg);
69 fprintf (stderr, appname ": ");
70 fprintf (stderr, fmt, p);
71 fprintf (stderr, "\n");
75 int version_major, version_minor, version_micro;
76 char unicode_version[100];
84 version_major = version_minor = version_micro = 0;
85 strcpy (unicode_version, "(unknown)");
88 #define READ_VERSION(prefix) ((where = strstr(buf, prefix)) && \
89 (3 == sscanf (where, \
90 prefix"%d.%d.%d", &version_major, &version_minor, &version_micro)))
101 while (fgets (buf, sizeof buf, f))
105 if (READ_VERSION ("Version ") || READ_VERSION ("Unicode "))
115 sprintf (unicode_version, "%d.%d.%d", version_major, version_minor,
122 const char *data_file_type,
123 const char *data_file_name
129 if (!(f = fopen (data_file_name, "rt")))
130 die2 ("error: cannot open `%s' for reading", data_file_name);
132 status = read_file (f);
140 gen_unicode_version (
141 const char *data_file_type
144 printf ("/* " outputname "\n * generated by " appname " (" FRIBIDI_NAME " "
145 FRIBIDI_VERSION ")\n" " * from the file %s */\n\n", data_file_type);
147 printf ("#define FRIBIDI_UNICODE_VERSION \"%s\"\n"
148 "#define FRIBIDI_UNICODE_MAJOR_VERSION %d\n"
149 "#define FRIBIDI_UNICODE_MINOR_VERSION %d\n"
150 "#define FRIBIDI_UNICODE_MICRO_VERSION %d\n"
153 version_major, version_minor, version_micro);
155 printf ("/* End of generated " outputname " */\n");
164 const char *data_file_type;
169 die ("usage:\n " appname
170 " /path/to/a/UCD/file [/path/to/more/UCD/files ...]");
173 const char *data_file_name;
176 for (i = 1; i < argc && !found; i++)
178 data_file_name = argv[i];
179 data_file_type = strrchr (data_file_name, '/');
183 data_file_type = data_file_name;
184 found = read_data (data_file_type, data_file_name);
187 die ("error: version not found");
188 gen_unicode_version (data_file_type);