3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/mkconfig.c
6 * PURPOSE: No purpose listed.
8 * PROGRAMMERS: No programmer listed.
15 #define max(a, b) ((a) > (b) ? (a) : (b))
18 write_if_change(char* outbuf
, char* filename
)
25 out
= fopen(filename
, "rb");
28 out
= fopen(filename
, "wb");
31 fprintf(stderr
, "Unable to create output file\n");
39 fseek(out
, 0, SEEK_END
);
44 fprintf(stderr
, "Out of memory\n");
49 fseek(out
, 0, SEEK_SET
);
50 stat
= fread(cmpbuf
, 1, end
, out
);
53 fprintf(stderr
, "Failed to read data\n");
57 if (end
== strlen(outbuf
) && memcmp(cmpbuf
, outbuf
, end
) == 0)
64 out
= fopen(filename
, "wb");
67 fprintf(stderr
, "Unable to create output file\n");
71 stat
= fwrite(outbuf
, 1, strlen(outbuf
), out
);
72 if (strlen(outbuf
) != stat
)
74 fprintf(stderr
, "Unable to write output file\n");
83 main(int argc
, char* argv
[])
92 fprintf(stderr
, "Not enough arguments\n");
96 outbuf
= malloc(256 * 1024);
99 fprintf(stderr
, "Out of memory 1\n");
104 s
= s
+ sprintf(s
, "/* Automatically generated, ");
105 s
= s
+ sprintf(s
, "Edit the Makefile to change configuration */\n");
106 s
= s
+ sprintf(s
, "#ifndef __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H\n");
107 s
= s
+ sprintf(s
, "#define __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H\n");
109 for (i
= 2; i
< argc
; i
++)
111 s
= s
+ sprintf(s
, "#define %s\n", argv
[i
]);
112 strcat(config
, argv
[i
]);
118 s
= s
+ sprintf(s
, "#define CONFIG \"%s\"\n", config
);
119 s
= s
+ sprintf(s
, "#endif /* __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H */\n");
121 return(write_if_change(outbuf
, argv
[1]));