diff options
author | Theodore Tso <tytso@mit.edu> | 1996-06-12 03:06:50 +0000 |
---|---|---|
committer | Theodore Tso <tytso@mit.edu> | 1996-06-12 03:06:50 +0000 |
commit | fd6907d8186b05ea556ea79b2b493c2a5948e5a8 (patch) | |
tree | 4838084340e5c9ada4fa8001a3c0230790c0a57b /src/wconfig.c | |
parent | 902b61aebb105019276cb0cb75b0061a2d8e808f (diff) | |
download | krb5-fd6907d8186b05ea556ea79b2b493c2a5948e5a8.tar.gz krb5-fd6907d8186b05ea556ea79b2b493c2a5948e5a8.tar.xz krb5-fd6907d8186b05ea556ea79b2b493c2a5948e5a8.zip |
Revamp program to make it more extensible. Now will uncomment lines
that begin "##DOS##" as well as "##WIN16##" or "##WIN32##", depending
on whether we are compiling on a Windows 16 or Windows 32 environment.
Also, we now perform this transformation on the windows.in and
win-post.in files as well.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8297 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/wconfig.c')
-rw-r--r-- | src/wconfig.c | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/src/wconfig.c b/src/wconfig.c index 0d1a42898..1974b863e 100644 --- a/src/wconfig.c +++ b/src/wconfig.c @@ -1,7 +1,7 @@ /* * wconfig.c * - * Copyright 1995 by the Massachusetts Institute of Technology. + * Copyright 1995,1996 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -39,29 +39,34 @@ #include <stdio.h> #include <string.h> -static char buf [1024]; /* Holds line from a file */ static int copy_file (char *path, char *fname); -int main(int argc, char *argv[]) { - char *ptr; /* For parsing the input */ +int main(int argc, char *argv[]) +{ if (argc == 2) /* Config directory given */ copy_file (argv[1], "\\windows.in"); /* Send out prefix */ - while ((ptr = gets(buf)) != NULL) { /* Filter stdin */ - if (memcmp ("##DOS", buf, 5) == 0) - ptr += 5; - else if (*ptr == '@') /* Lines starting w/ '@'... */ - *ptr = '\0'; /* ...turn into blank lines */ - - puts (ptr); - } - + copy_file("", "-"); + if (argc == 2) /* Config directory given */ copy_file (argv[1], "\\win-post.in"); /* Send out postfix */ return 0; } + +char *ignore_list[] = { + "DOS##", + "DOS", +#ifdef _MSDOS + "WIN16##", +#endif +#ifdef _WIN32 + "WIN32##", +#endif + 0 + }; + /* * * Copy_file @@ -70,18 +75,42 @@ int main(int argc, char *argv[]) { * */ static int -copy_file (char *path, char *fname) { +copy_file (char *path, char *fname) +{ FILE *fin; + char buf[1024]; + char **cpp, *ptr; + int len; - strcpy (buf, path); /* Build up name to open */ - strcat (buf, fname); - - fin = fopen (buf, "r"); /* File to read */ - if (fin == NULL) - return 1; + if (strcmp(fname, "-") == 0) { + fin = stdin; + } else { + strcpy (buf, path); /* Build up name to open */ + strcat (buf, fname); + fin = fopen (buf, "r"); /* File to read */ + if (fin == NULL) + return 1; + } + while (fgets (buf, sizeof(buf), fin) != NULL) { /* Copy file over */ - fputs (buf, stdout); + if (buf[0] == '@') { + fputs("\n", stdout); + continue; + } + if (buf[0] != '#' || buf[1] != '#') { + fputs(buf, stdout); + continue; + } + ptr = buf; + for (cpp = ignore_list; *cpp; cpp++) { + len = strlen(*cpp); + if (memcmp (*cpp, buf+2, len) == 0) { + ptr += 2+len; + break; + } + } + fputs(ptr, stdout); } fclose (fin); |