grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / muimaster / buildincludes.c
blob21a1980eae21697ab78f370efe46a9381d17ac74
1 /*
2 Copyright © 2002, The AROS Development Team.
3 All rights reserved.
5 $Id$
6 */
8 #include <string.h>
9 #include <stdio.h>
10 #include <stdlib.h>
12 /**************************************************************************
13 This file builds the libraries/mui.h file. It outputs it to stdout
14 so you can redirect them
16 Currently it merges some files but later version might do more
17 things
18 **************************************************************************/
20 static char linebuf[2048];
22 /* array of already included files */
23 char **included;
24 int included_num;
26 static int need_to_be_included(char *filename)
28 int i;
29 for (i = 0; i < included_num; i++)
31 if (!strcmp(included[i], filename))
32 return 0;
34 return 1;
37 static void readfile(FILE *in)
39 while (fgets(linebuf, 2048, in))
41 if (!strstr(linebuf, "PRIV"))
43 if (strchr(linebuf, '#') && strstr(linebuf, "include"))
45 char *start = strchr(linebuf, '"');
46 if (start)
48 char *end;
49 start++;
50 end = strchr(start, '"');
51 if (end)
53 *end = 0;
54 if (need_to_be_included(start))
56 FILE *in2;
57 if (!(included =
58 realloc(included,
59 sizeof(char *) * (included_num +
60 1))))
61 return;
62 included[included_num++] = strdup(start);
63 if ((in2 = fopen(start, "r")))
65 readfile(in2);
66 fclose(in2);
71 else
72 printf("%s", linebuf);
74 else
75 printf("%s", linebuf);
80 int main(void)
82 int i;
84 /* Open the mui.h file */
85 FILE *in = fopen("mui.h", "r");
86 if (in)
88 readfile(in);
89 fclose(in);
92 return 0;