home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / window / miscutil / enved2 / $enved.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-07-15  |  1.6 KB  |  54 lines

  1. /*
  2.     Convert (possibly editted) output of DOS "SET" command to
  3.     a .BAT file which will make that the current environment.
  4.  
  5.     Each line is of the form: var=string
  6.  
  7.     Case of var does not matter. Case of string will be preserved, and
  8.     may make a difference for some things (like PROMPT) and not others.
  9.  
  10.     Each line except for PROMPT= and PATH= in input is automatically
  11.     prefixed with "SET ". ("SET" is not needed in those cases, and
  12.     sometimes "SET PROMPT=..." is a syntax error. I have no idea why.)
  13.  
  14.     Any variables which exist at time of conversion but which are not in
  15.     the input file are cleared, except for PATH and COMSPEC. Therefore
  16.     when editting the file to be used as input you can drop a variable
  17.     by deleting its line.
  18.  
  19.     Input is standard input (keyboard) and output is standard output
  20.     (video screen). Keyboard input is terminated by a CTRL-Z RETURN.
  21.     Use redirection for disk files.
  22.  
  23.     Written by:
  24.         Bill Mayne
  25.         9707 Lawndale Dr.
  26.         Silver Spring, MD  20901
  27. */
  28. #include <stdio.h>
  29. #include <string.h>
  30. _setargv() { }
  31. main(argc,argv,envp) int argc; char *argv[], *envp[];
  32. {
  33. char *p;
  34. char line[256];
  35. int i;
  36. for (i=0; envp[i]; ++i)
  37.   {
  38.   p=strchr(envp[i],'=');
  39.   if (strnicmp(envp[i],"COMSPEC=",8) &&
  40.       strnicmp(envp[i],"PATH=",5))
  41.     {
  42.     *(++p)=0;
  43.     if (strnicmp(envp[i],"PROMPT=",7)) fputs("SET ",stdout);
  44.     puts(envp[i]);
  45.     }
  46.   }
  47. while (gets(line))
  48.   {
  49.   if (strnicmp(line,"PATH=",5) && strnicmp(line,"PROMPT=",7))
  50.     fputs("SET ",stdout);
  51.   puts(line);
  52.   }
  53. }
  54.