home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************/
- /* */
- /* set.c */
- /* */
- /* Copyright (c) 2000 */
- /* Pasquale J. Villani */
- /* All Rights Reserved */
- /* */
- /* This file is part of CMD32. */
- /* */
- /* CMD32 is free software; you can redistribute it and/or */
- /* modify it under the terms of the GNU General Public License */
- /* as published by the Free Software Foundation; either version */
- /* 2, or (at your option) any later version. */
- /* */
- /* CMD32 is distributed in the hope that it will be useful, but */
- /* WITHOUT ANY WARRANTY; without even the implied warranty of */
- /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
- /* the GNU General Public License for more details. */
- /* */
- /* You should have received a copy of the GNU General Public */
- /* License along with CMD32; see the file COPYING. If not, */
- /* write to the Free Software Foundation, 675 Mass Ave, */
- /* Cambridge, MA 02139, USA. */
- /****************************************************************/
-
- /* $Logfile$ */
-
- /* $Log$
- * $EndLog$ */
-
- #ifdef VERSION_STRINGS
- static char *RcsId = "$Header$";
- #endif
-
- #include <windows.h>
- #include "globals.h"
- #include "proto.h"
-
- extern BYTE *dflt_pr_string;
-
- void EnvDump(void);
-
- BOOL set_bat(INT argc, BYTE *argv[])
- {
- BYTE env_var[MAX_CMDLINE];
- BYTE *lp, *p;
-
- lp = skipwh(tail);
- if(*lp == '\0')
- {
- EnvDump();
- printf("\n");
- return TRUE;
- }
-
- lp = scanspl(tail, env_var, '=');
- if(!lp && *lp != '=')
- {
- error_message(INV_SYNTAX);
- return FALSE;
- }
- else
- ++lp;
-
- if(*lp == '\r' || *lp == '\n')
- {
- /* set env_var in environment to empty */
- SetEnvironmentVariable(env_var, NULL);
-
- /* Update system PROMPT immediately */
- if(strcmp(env_var,"PROMPT") == 0)
- strcpy(szPrompt, dflt_pr_string);
-
- }
- else
- {
- /* Trim trailing newline */
-
- for(p = lp; (*p != '\r') && (*p != '\n'); p++)
- ;
- *p = '\0';
-
- SetEnvironmentVariable(env_var, lp);
-
- /* Update system PROMPT immediately */
- if(strcmp(env_var,"PROMPT") == 0)
- strcpy(szPrompt, lp);
-
- /* Update system PATH immediately */
- if(strcmp(env_var,"PATH") == 0)
- strcpy(pszPath, lp);
- }
- return TRUE;
- }
-
-
- void EnvDump(void)
- {
- BYTE *pszEnvStrings;
-
- pszEnvStrings = GetEnvironmentStrings();
- while(*pszEnvStrings)
- {
- printf("%s\n", pszEnvStrings);
- pszEnvStrings += (strlen(pszEnvStrings) + 1);
- }
- }
-
-