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>.
44 # if !STDC_HEADERS && HAVE_MEMORY_H
55 #define appname "gen-unicode-version"
56 #define outputname "fribidi-unicode-version.h"
63 fprintf (stderr, appname ": %s\n", msg);
73 fprintf (stderr, appname ": ");
74 fprintf (stderr, fmt, p);
75 fprintf (stderr, "\n");
79 int version_major, version_minor, version_micro;
80 char unicode_version[100];
88 version_major = version_minor = version_micro = 0;
89 strcpy (unicode_version, "(unknown)");
92 #define READ_VERSION(prefix) ((where = strstr(buf, prefix)) && \
93 (3 == sscanf (where, \
94 prefix"%d.%d.%d", &version_major, &version_minor, &version_micro)))
105 while (fgets (buf, sizeof buf, f))
109 if (READ_VERSION ("Version ") || READ_VERSION ("Unicode "))
119 sprintf (unicode_version, "%d.%d.%d", version_major, version_minor,
126 const char *data_file_type,
127 const char *data_file_name
133 if (!(f = fopen (data_file_name, "rt")))
134 die2 ("error: cannot open `%s' for reading", data_file_name);
136 status = read_file (f);
144 gen_unicode_version (
145 const char *data_file_type
148 printf ("/* " outputname "\n * generated by " appname " (" FRIBIDI_NAME " "
149 FRIBIDI_VERSION ")\n" " * from the file %s */\n\n", data_file_type);
151 printf ("#define FRIBIDI_UNICODE_VERSION \"%s\"\n"
152 "#define FRIBIDI_UNICODE_MAJOR_VERSION %d\n"
153 "#define FRIBIDI_UNICODE_MINOR_VERSION %d\n"
154 "#define FRIBIDI_UNICODE_MICRO_VERSION %d\n"
157 version_major, version_minor, version_micro);
159 printf ("/* End of generated " outputname " */\n");
168 const char *data_file_type;
173 die ("usage:\n " appname
174 " /path/to/a/UCD/file [/path/to/more/UCD/files ...]");
177 const char *data_file_name;
180 for (i = 1; i < argc && !found; i++)
182 data_file_name = argv[i];
183 data_file_type = strrchr (data_file_name, '/');
187 data_file_type = data_file_name;
188 found = read_data (data_file_type, data_file_name);
191 die ("error: version not found");
192 gen_unicode_version (data_file_type);