home *** CD-ROM | disk | FTP | other *** search
- /*
- Convert (possibly editted) output of DOS "SET" command to
- a .BAT file which will make that the current environment.
-
- Each line is of the form: var=string
-
- Case of var does not matter. Case of string will be preserved, and
- may make a difference for some things (like PROMPT) and not others.
-
- Each line except for PROMPT= and PATH= in input is automatically
- prefixed with "SET ". ("SET" is not needed in those cases, and
- sometimes "SET PROMPT=..." is a syntax error. I have no idea why.)
-
- Any variables which exist at time of conversion but which are not in
- the input file are cleared, except for PATH and COMSPEC. Therefore
- when editting the file to be used as input you can drop a variable
- by deleting its line.
-
- Input is standard input (keyboard) and output is standard output
- (video screen). Keyboard input is terminated by a CTRL-Z RETURN.
- Use redirection for disk files.
-
- Written by:
- Bill Mayne
- 9707 Lawndale Dr.
- Silver Spring, MD 20901
- */
- #include <stdio.h>
- #include <string.h>
- _setargv() { }
- main(argc,argv,envp) int argc; char *argv[], *envp[];
- {
- char *p;
- char line[256];
- int i;
- for (i=0; envp[i]; ++i)
- {
- p=strchr(envp[i],'=');
- if (strnicmp(envp[i],"COMSPEC=",8) &&
- strnicmp(envp[i],"PATH=",5))
- {
- *(++p)=0;
- if (strnicmp(envp[i],"PROMPT=",7)) fputs("SET ",stdout);
- puts(envp[i]);
- }
- }
- while (gets(line))
- {
- if (strnicmp(line,"PATH=",5) && strnicmp(line,"PROMPT=",7))
- fputs("SET ",stdout);
- puts(line);
- }
- }