4 * Copyright 1995 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. M.I.T. makes no representations about the suitability of
20 * this software for any purpose. It is provided "as is" without express
21 * or implied warranty.
24 * Program to take the place of the configure shell script under DOS.
25 * The makefile.in files are constructed in such a way that all this
26 * program needs to do is uncomment lines beginning ##DOS by removing the
27 * first 5 characters of the line. This will allow lines like:
28 * ##DOS!include windows.in to become: !include windows.in
30 * We also turn any line beginning with '@' into a blank line.
32 * If a config directory is specified, then the output will be start with
33 * config\pre.in, then the filtered stdin text, and will end with
36 * Syntax: wconfig [config_directory] <input_file >output_file
42 static char buf [1024]; /* Holds line from a file */
43 static int copy_file (char *path, char *fname);
45 int main(int argc, char *argv[]) {
46 char *ptr; /* For parsing the input */
48 if (argc == 2) /* Config directory given */
49 copy_file (argv[1], "\\windows.in"); /* Send out prefix */
51 while ((ptr = gets(buf)) != NULL) { /* Filter stdin */
52 if (memcmp ("##DOS", buf, 5) == 0)
54 else if (*ptr == '@') /* Lines starting w/ '@'... */
55 *ptr = '\0'; /* ...turn into blank lines */
60 if (argc == 2) /* Config directory given */
61 copy_file (argv[1], "\\post.in"); /* Send out postfix */
69 * Copies file 'path\fname' to stdout.
73 copy_file (char *path, char *fname) {
76 strcpy (buf, path); /* Build up name to open */
79 fin = fopen (buf, "r"); /* File to read */
83 while (fgets (buf, sizeof(buf), fin) != NULL) { /* Copy file over */