5 #define max(a, b) ((a) > (b) ? (a) : (b))
8 write_if_change(char* outbuf
, char* filename
)
15 out
= fopen(filename
, "rb");
18 out
= fopen(filename
, "wb");
21 fprintf(stderr
, "Unable to create output file\n");
29 fseek(out
, 0, SEEK_END
);
34 fprintf(stderr
, "Out of memory\n");
39 fseek(out
, 0, SEEK_SET
);
40 stat
= fread(cmpbuf
, 1, end
, out
);
43 fprintf(stderr
, "Failed to read data\n");
47 if (end
== strlen(outbuf
) && memcmp(cmpbuf
, outbuf
, end
) == 0)
54 out
= fopen(filename
, "wb");
57 fprintf(stderr
, "Unable to create output file\n");
61 stat
= fwrite(outbuf
, 1, strlen(outbuf
), out
);
62 if (strlen(outbuf
) != stat
)
64 fprintf(stderr
, "Unable to write output file\n");
73 main(int argc
, char* argv
[])
82 fprintf(stderr
, "Not enough arguments\n");
86 outbuf
= malloc(256 * 1024);
89 fprintf(stderr
, "Out of memory 1\n");
94 s
= s
+ sprintf(s
, "/* Automatically generated, ");
95 s
= s
+ sprintf(s
, "Edit the Makefile to change configuration */\n");
96 s
= s
+ sprintf(s
, "#ifndef __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H\n");
97 s
= s
+ sprintf(s
, "#define __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H\n");
99 for (i
= 2; i
< argc
; i
++)
101 s
= s
+ sprintf(s
, "#define %s\n", argv
[i
]);
102 strcat(config
, argv
[i
]);
108 s
= s
+ sprintf(s
, "#define CONFIG \"%s\"\n", config
);
109 s
= s
+ sprintf(s
, "#endif /* __NTOSKRNL_INCLUDE_INTERNAL_CONFIG_H */\n");
111 return(write_if_change(outbuf
, argv
[1]));