Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
9643b798
Commit
9643b798
authored
Mar 22, 2004
by
Mike McCormack
Committed by
Alexandre Julliard
Mar 22, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement setlocal/endlocal.
parent
9d61aee3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
2 deletions
+149
-2
builtins.c
programs/wcmd/builtins.c
+135
-0
wcmd.h
programs/wcmd/wcmd.h
+6
-1
wcmdmain.c
programs/wcmd/wcmdmain.c
+8
-1
No files found.
programs/wcmd/builtins.c
View file @
9643b798
...
...
@@ -36,6 +36,14 @@
void
WCMD_execute
(
char
*
orig_command
,
char
*
parameter
,
char
*
substitution
);
struct
env_stack
{
struct
env_stack
*
next
;
WCHAR
*
strings
;
};
struct
env_stack
*
saved_environment
;
extern
HINSTANCE
hinst
;
extern
char
*
inbuilt
[];
extern
char
nyi
[];
...
...
@@ -507,6 +515,133 @@ int status;
}
/*****************************************************************************
* WCMD_dupenv
*
* Make a copy of the environment.
*/
WCHAR
*
WCMD_dupenv
(
const
WCHAR
*
env
)
{
WCHAR
*
env_copy
;
int
len
;
if
(
!
env
)
return
NULL
;
len
=
0
;
while
(
env
[
len
]
)
len
+=
(
lstrlenW
(
&
env
[
len
])
+
1
);
env_copy
=
LocalAlloc
(
LMEM_FIXED
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
!
env_copy
)
{
WCMD_output
(
"out of memory
\n
"
);
return
env_copy
;
}
memcpy
(
env_copy
,
env
,
len
*
sizeof
(
WCHAR
));
env_copy
[
len
]
=
0
;
return
env_copy
;
}
/*****************************************************************************
* WCMD_setlocal
*
* setlocal pushes the environment onto a stack
* Save the environment as unicode so we don't screw anything up.
*/
void
WCMD_setlocal
(
const
char
*
s
)
{
WCHAR
*
env
;
struct
env_stack
*
env_copy
;
/* DISABLEEXTENSIONS ignored */
env_copy
=
LocalAlloc
(
LMEM_FIXED
,
sizeof
(
struct
env_stack
));
if
(
!
env_copy
)
{
WCMD_output
(
"out of memory
\n
"
);
return
;
}
env
=
GetEnvironmentStringsW
();
env_copy
->
strings
=
WCMD_dupenv
(
env
);
if
(
env_copy
->
strings
)
{
env_copy
->
next
=
saved_environment
;
saved_environment
=
env_copy
;
}
else
LocalFree
(
env_copy
);
FreeEnvironmentStringsW
(
env
);
}
/*****************************************************************************
* WCMD_strchrW
*/
inline
WCHAR
*
WCMD_strchrW
(
WCHAR
*
str
,
WCHAR
ch
)
{
while
(
*
str
)
{
if
(
*
str
==
ch
)
return
str
;
str
++
;
}
return
NULL
;
}
/*****************************************************************************
* WCMD_endlocal
*
* endlocal pops the environment off a stack
*/
void
WCMD_endlocal
(
void
)
{
WCHAR
*
env
,
*
old
,
*
p
;
struct
env_stack
*
temp
;
int
len
,
n
;
if
(
!
saved_environment
)
return
;
/* pop the old environment from the stack */
temp
=
saved_environment
;
saved_environment
=
temp
->
next
;
/* delete the current environment, totally */
env
=
GetEnvironmentStringsW
();
old
=
WCMD_dupenv
(
GetEnvironmentStringsW
());
len
=
0
;
while
(
old
[
len
])
{
n
=
lstrlenW
(
&
old
[
len
])
+
1
;
p
=
WCMD_strchrW
(
&
old
[
len
],
'='
);
if
(
p
)
{
*
p
++
=
0
;
SetEnvironmentVariableW
(
&
old
[
len
],
NULL
);
}
len
+=
n
;
}
LocalFree
(
old
);
FreeEnvironmentStringsW
(
env
);
/* restore old environment */
env
=
temp
->
strings
;
len
=
0
;
while
(
env
[
len
])
{
n
=
lstrlenW
(
&
env
[
len
])
+
1
;
p
=
WCMD_strchrW
(
&
env
[
len
],
'='
);
if
(
p
)
{
*
p
++
=
0
;
SetEnvironmentVariableW
(
&
env
[
len
],
p
);
}
len
+=
n
;
}
LocalFree
(
env
);
LocalFree
(
temp
);
}
/*****************************************************************************
* WCMD_setshow_attrib
*
* Display and optionally sets DOS attributes on a file or directory
...
...
programs/wcmd/wcmd.h
View file @
9643b798
...
...
@@ -35,6 +35,7 @@ void WCMD_create_dir (void);
void
WCMD_delete
(
int
recurse
);
void
WCMD_directory
(
void
);
void
WCMD_echo
(
const
char
*
);
void
WCMD_endlocal
(
void
);
void
WCMD_enter_paged_mode
(
void
);
void
WCMD_for
(
char
*
);
void
WCMD_give_help
(
char
*
command
);
...
...
@@ -53,6 +54,7 @@ int WCMD_read_console (char *string, int str_len);
void
WCMD_remove_dir
(
void
);
void
WCMD_rename
(
void
);
void
WCMD_run_program
(
char
*
command
);
void
WCMD_setlocal
(
const
char
*
command
);
void
WCMD_setshow_attrib
(
void
);
void
WCMD_setshow_date
(
void
);
void
WCMD_setshow_default
(
void
);
...
...
@@ -130,5 +132,8 @@ typedef struct {
#define WCMD_VER 34
#define WCMD_VOL 35
#define WCMD_ENDLOCAL 36
#define WCMD_SETLOCAL 37
/* Must be last in list */
#define WCMD_EXIT 3
6
#define WCMD_EXIT 3
8
programs/wcmd/wcmdmain.c
View file @
9643b798
...
...
@@ -31,7 +31,8 @@ const char *inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY", "CTTY",
"DATE"
,
"DEL"
,
"DIR"
,
"ECHO"
,
"ERASE"
,
"FOR"
,
"GOTO"
,
"HELP"
,
"IF"
,
"LABEL"
,
"MD"
,
"MKDIR"
,
"MOVE"
,
"PATH"
,
"PAUSE"
,
"PROMPT"
,
"REM"
,
"REN"
,
"RENAME"
,
"RD"
,
"RMDIR"
,
"SET"
,
"SHIFT"
,
"TIME"
,
"TITLE"
,
"TYPE"
,
"VERIFY"
,
"VER"
,
"VOL"
,
"EXIT"
};
"TIME"
,
"TITLE"
,
"TYPE"
,
"VERIFY"
,
"VER"
,
"VOL"
,
"ENDLOCAL"
,
"SETLOCAL"
,
"EXIT"
};
HINSTANCE
hinst
;
DWORD
errorlevel
;
...
...
@@ -427,6 +428,12 @@ void WCMD_process_command (char *command)
case
WCMD_RMDIR
:
WCMD_remove_dir
();
break
;
case
WCMD_SETLOCAL
:
WCMD_setlocal
(
p
);
break
;
case
WCMD_ENDLOCAL
:
WCMD_endlocal
();
break
;
case
WCMD_SET
:
WCMD_setshow_env
(
p
);
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment