fix crashes reported by Debian Cylab Mayhem Team
[swftools.git] / lib / art / gen_art_config.c
blob8d88815d7ccdc5eb4f582e6145c42b232cfac877
1 #include <stdio.h>
2 #include "config.h"
3 #include <stdlib.h>
5 /**
6 * A little utility function to generate header info.
8 * Yes, it would be possible to do this using more "native" autoconf
9 * features, but I personally find this approach to be cleaner.
11 * The output of this program is generally written to art_config.h,
12 * which is installed in libart's include dir.
13 **/
15 static void
16 die (char *why)
18 fprintf (stderr, "gen_art_config: %s\n", why);
19 exit (1);
22 int
23 main (int argc, char **argv)
25 printf ("/* Automatically generated by gen_art_config.c */\n"
26 "\n"
27 "#define ART_SIZEOF_CHAR %d\n"
28 "#define ART_SIZEOF_SHORT %d\n"
29 "#define ART_SIZEOF_INT %d\n"
30 "#define ART_SIZEOF_LONG %d\n"
31 "\n",
32 (int)sizeof(char), (int)sizeof(short), (int)sizeof(int), (int)sizeof(long));
34 if (sizeof(char) == 1)
35 printf ("typedef unsigned char art_u8;\n");
36 else
37 die ("sizeof(char) != 1");
39 if (sizeof(short) == 2)
40 printf ("typedef unsigned short art_u16;\n");
41 else
42 die ("sizeof(short) != 2");
44 if (sizeof(int) == 4)
45 printf ("typedef unsigned int art_u32;\n");
46 else if (sizeof(long) == 4)
47 printf ("typedef unsigned long art_u32;\n");
48 else
49 die ("sizeof(int) != 4 and sizeof(long) != 4");
51 return 0;