From: Theodore Tso Date: Wed, 12 Jun 1996 03:06:50 +0000 (+0000) Subject: Revamp program to make it more extensible. Now will uncomment lines X-Git-Tag: krb5-1.0-beta7~396 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fd6907d8186b05ea556ea79b2b493c2a5948e5a8;p=krb5.git 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index 1ab852ca0..d8cc0cd67 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +Mon Jun 10 17:11:45 1996 Theodore Ts'o + + * wconfig.c: 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. + Sat Jun 8 10:01:11 1996 Ezra Peisach * aclocal.m4: Remove WITH_KDB4 and USE_KDB4_LIBRARY support 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 #include -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);