Include the file windows.in instead of pre.in
[krb5.git] / src / wconfig.c
1 /*
2  * wconfig.c
3  *
4  * Copyright 1995 by the Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
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.
11  *
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.
22  *
23  *
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
29  *
30  * We also turn any line beginning with '@' into a blank line.
31  *
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
34  * config\post.in.
35  *
36  * Syntax: wconfig [config_directory] <input_file >output_file
37  *
38  */
39 #include <stdio.h>
40 #include <string.h>
41
42 static char buf [1024];                                                 /* Holds line from a file */
43 static int copy_file (char *path, char *fname);
44
45 int main(int argc, char *argv[]) {
46     char *ptr;                                                                  /* For parsing the input */
47
48     if (argc == 2)                              /* Config directory given */
49         copy_file (argv[1], "\\windows.in");        /* Send out prefix */
50
51     while ((ptr = gets(buf)) != NULL) {         /* Filter stdin */
52         if (memcmp ("##DOS", buf, 5) == 0)
53             ptr += 5;
54                 else if (*ptr == '@')                                   /* Lines starting w/ '@'... */
55                         *ptr = '\0';                                            /* ...turn into blank lines */
56
57         puts (ptr);
58     }
59
60     if (argc == 2)                              /* Config directory given */
61         copy_file (argv[1], "\\post.in");       /* Send out postfix */
62
63     return 0;
64 }
65 /*
66  * 
67  * Copy_file
68  * 
69  * Copies file 'path\fname' to stdout.
70  * 
71  */
72 static int
73 copy_file (char *path, char *fname) {
74     FILE *fin;
75
76     strcpy (buf, path);                         /* Build up name to open */
77     strcat (buf, fname);
78
79     fin = fopen (buf, "r");                     /* File to read */
80     if (fin == NULL)
81         return 1;
82
83     while (fgets (buf, sizeof(buf), fin) != NULL) { /* Copy file over */
84         fputs (buf, stdout);
85     }
86
87     fclose (fin);
88
89     return 0;
90 }