Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / programs / wcmd / wcmdmain.c
blobceab860808539ae168ea2e53f82e4f24dcc96c54
1 /*
2 * WCMD - Wine-compatible command line interface.
4 * Copyright (C) 1999 - 2001 D A Pickles
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * FIXME:
23 * - Cannot handle parameters in quotes
24 * - Lots of functionality missing from builtins
27 #include "ntstatus.h"
28 #include "wcmd.h"
30 char *inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY", "CTTY",
31 "DATE", "DEL", "DIR", "ECHO", "ERASE", "FOR", "GOTO",
32 "HELP", "IF", "LABEL", "MD", "MKDIR", "MOVE", "PATH", "PAUSE",
33 "PROMPT", "REM", "REN", "RENAME", "RD", "RMDIR", "SET", "SHIFT",
34 "TIME", "TITLE", "TYPE", "VERIFY", "VER", "VOL", "EXIT" };
36 HINSTANCE hinst;
37 DWORD errorlevel;
38 int echo_mode = 1, verify_mode = 0;
39 char nyi[] = "Not Yet Implemented\n\n";
40 char newline[] = "\n";
41 char version_string[] = "WCMD Version 0.17\n\n";
42 char anykey[] = "Press Return key to continue: ";
43 char quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH];
44 BATCH_CONTEXT *context = NULL;
46 /*****************************************************************************
47 * Main entry point. This is a console application so we have a main() not a
48 * winmain().
51 int main (int argc, char *argv[])
53 char string[1024];
54 char* cmd=NULL;
55 DWORD count;
56 HANDLE h;
57 int opt_c, opt_k, opt_q;
59 argv++;
60 opt_c=opt_k=opt_q=0;
61 while (*argv!=NULL)
63 if (lstrcmpi(*argv,"/c")==0) {
64 opt_c=1;
65 argv++;
66 break;
67 } else if (lstrcmpi(*argv,"/q")==0) {
68 opt_q=1;
69 } else if (lstrcmpi(*argv,"/k")==0) {
70 opt_k=1;
71 argv++;
72 break;
73 } else if (lstrcmpi(*argv,"/t")==0 || lstrcmpi(*argv,"/x")==0 ||
74 lstrcmpi(*argv,"/y")==0) {
75 /* Ignored for compatibility with Windows */
76 } else {
77 break;
79 argv++;
82 if (opt_q) {
83 WCMD_echo("OFF");
86 if (opt_c || opt_k) {
87 int len;
88 char** arg;
89 char* p;
91 /* Build the command to execute */
92 len = 0;
93 for (arg = argv; *arg; arg++)
95 int has_space,bcount;
96 char* a;
98 has_space=0;
99 bcount=0;
100 a=*arg;
101 if( !*a ) has_space=1;
102 while (*a!='\0') {
103 if (*a=='\\') {
104 bcount++;
105 } else {
106 if (*a==' ' || *a=='\t') {
107 has_space=1;
108 } else if (*a=='"') {
109 /* doubling of '\' preceeding a '"',
110 * plus escaping of said '"'
112 len+=2*bcount+1;
114 bcount=0;
116 a++;
118 len+=(a-*arg)+1 /* for the separating space */;
119 if (has_space)
120 len+=2; /* for the quotes */
123 cmd = HeapAlloc(GetProcessHeap(), 0, len);
124 if (!cmd)
125 exit(1);
127 p = cmd;
128 for (arg = argv; *arg; arg++)
130 int has_space,has_quote;
131 char* a;
133 /* Check for quotes and spaces in this argument */
134 has_space=has_quote=0;
135 a=*arg;
136 if( !*a ) has_space=1;
137 while (*a!='\0') {
138 if (*a==' ' || *a=='\t') {
139 has_space=1;
140 if (has_quote)
141 break;
142 } else if (*a=='"') {
143 has_quote=1;
144 if (has_space)
145 break;
147 a++;
150 /* Now transfer it to the command line */
151 if (has_space)
152 *p++='"';
153 if (has_quote) {
154 int bcount;
155 char* a;
157 bcount=0;
158 a=*arg;
159 while (*a!='\0') {
160 if (*a=='\\') {
161 *p++=*a;
162 bcount++;
163 } else {
164 if (*a=='"') {
165 int i;
167 /* Double all the '\\' preceeding this '"', plus one */
168 for (i=0;i<=bcount;i++)
169 *p++='\\';
170 *p++='"';
171 } else {
172 *p++=*a;
174 bcount=0;
176 a++;
178 } else {
179 strcpy(p,*arg);
180 p+=strlen(*arg);
182 if (has_space)
183 *p++='"';
184 *p++=' ';
186 if (p > cmd)
187 p--; /* remove last space */
188 *p = '\0';
191 if (opt_c) {
192 /* If we do a "wcmd /c command", we don't want to allocate a new
193 * console since the command returns immediately. Rather, we use
194 * the currently allocated input and output handles. This allows
195 * us to pipe to and read from the command interpreter.
197 if (strchr(cmd,'|') != NULL)
198 WCMD_pipe(cmd);
199 else
200 WCMD_process_command(cmd);
201 HeapFree(GetProcessHeap(), 0, cmd);
202 return 0;
205 SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_LINE_INPUT |
206 ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT);
207 SetConsoleTitle("Wine Command Prompt");
209 if (opt_k) {
210 WCMD_process_command(cmd);
211 HeapFree(GetProcessHeap(), 0, cmd);
215 * If there is an AUTOEXEC.BAT file, try to execute it.
218 GetFullPathName ("\\autoexec.bat", sizeof(string), string, NULL);
219 h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
220 if (h != INVALID_HANDLE_VALUE) {
221 CloseHandle (h);
222 #if 0
223 WCMD_batch_command (string);
224 #endif
228 * Loop forever getting commands and executing them.
231 WCMD_version ();
232 while (TRUE) {
233 WCMD_show_prompt ();
234 ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL);
235 if (count > 1) {
236 string[count-1] = '\0'; /* ReadFile output is not null-terminated! */
237 if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */
238 if (lstrlen (string) != 0) {
239 if (strchr(string,'|') != NULL) {
240 WCMD_pipe (string);
242 else {
243 WCMD_process_command (string);
251 /*****************************************************************************
252 * Process one command. If the command is EXIT this routine does not return.
253 * We will recurse through here executing batch files.
257 void WCMD_process_command (char *command)
259 char *cmd, *p;
260 int status, i, len;
261 DWORD count;
262 HANDLE old_stdin = 0, old_stdout = 0, h;
263 char *whichcmd;
264 SECURITY_ATTRIBUTES sa;
267 * Expand up environment variables.
269 len = ExpandEnvironmentStrings (command, NULL, 0);
270 cmd = HeapAlloc( GetProcessHeap(), 0, len );
271 status = ExpandEnvironmentStrings (command, cmd, len);
272 if (!status) {
273 WCMD_print_error ();
274 HeapFree( GetProcessHeap(), 0, cmd );
275 return;
279 * Changing default drive has to be handled as a special case.
282 if ((cmd[1] == ':') && IsCharAlpha (cmd[0]) && (strlen(cmd) == 2)) {
283 status = SetCurrentDirectory (cmd);
284 if (!status) WCMD_print_error ();
285 HeapFree( GetProcessHeap(), 0, cmd );
286 return;
289 /* Dont issue newline WCMD_output (newline); @JED*/
291 sa.nLength = sizeof(sa);
292 sa.lpSecurityDescriptor = NULL;
293 sa.bInheritHandle = TRUE;
295 * Redirect stdin and/or stdout if required.
298 if ((p = strchr(cmd,'<')) != NULL) {
299 h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, FILE_SHARE_READ, &sa, OPEN_EXISTING,
300 FILE_ATTRIBUTE_NORMAL, NULL);
301 if (h == INVALID_HANDLE_VALUE) {
302 WCMD_print_error ();
303 HeapFree( GetProcessHeap(), 0, cmd );
304 return;
306 old_stdin = GetStdHandle (STD_INPUT_HANDLE);
307 SetStdHandle (STD_INPUT_HANDLE, h);
309 if ((p = strchr(cmd,'>')) != NULL) {
310 h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
311 FILE_ATTRIBUTE_NORMAL, NULL);
312 if (h == INVALID_HANDLE_VALUE) {
313 WCMD_print_error ();
314 HeapFree( GetProcessHeap(), 0, cmd );
315 return;
317 old_stdout = GetStdHandle (STD_OUTPUT_HANDLE);
318 SetStdHandle (STD_OUTPUT_HANDLE, h);
319 *--p = '\0';
321 if ((p = strchr(cmd,'<')) != NULL) *p = '\0';
324 * Strip leading whitespaces, and a '@' if supplied
326 whichcmd = WCMD_strtrim_leading_spaces(cmd);
327 if (whichcmd[0] == '@') whichcmd++;
330 * Check if the command entered is internal. If it is, pass the rest of the
331 * line down to the command. If not try to run a program.
334 count = 0;
335 while (IsCharAlphaNumeric(whichcmd[count])) {
336 count++;
338 for (i=0; i<=WCMD_EXIT; i++) {
339 if (CompareString (LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
340 whichcmd, count, inbuilt[i], -1) == 2) break;
342 p = WCMD_strtrim_leading_spaces (&whichcmd[count]);
343 WCMD_parse (p, quals, param1, param2);
344 switch (i) {
346 case WCMD_ATTRIB:
347 WCMD_setshow_attrib ();
348 break;
349 case WCMD_CALL:
350 WCMD_batch (param1, p, 1);
351 break;
352 case WCMD_CD:
353 case WCMD_CHDIR:
354 WCMD_setshow_default ();
355 break;
356 case WCMD_CLS:
357 WCMD_clear_screen ();
358 break;
359 case WCMD_COPY:
360 WCMD_copy ();
361 break;
362 case WCMD_CTTY:
363 WCMD_change_tty ();
364 break;
365 case WCMD_DATE:
366 WCMD_setshow_date ();
367 break;
368 case WCMD_DEL:
369 case WCMD_ERASE:
370 WCMD_delete (0);
371 break;
372 case WCMD_DIR:
373 WCMD_directory ();
374 break;
375 case WCMD_ECHO:
376 /* Use the unstripped version of the following data - step over the space */
377 /* but only if a parameter follows */
378 if (strlen(&whichcmd[count]) > 0)
379 WCMD_echo(&whichcmd[count+1]);
380 else
381 WCMD_echo(&whichcmd[count]);
382 break;
383 case WCMD_FOR:
384 WCMD_for (p);
385 break;
386 case WCMD_GOTO:
387 WCMD_goto ();
388 break;
389 case WCMD_HELP:
390 WCMD_give_help (p);
391 break;
392 case WCMD_IF:
393 WCMD_if (p);
394 break;
395 case WCMD_LABEL:
396 WCMD_volume (1, p);
397 break;
398 case WCMD_MD:
399 case WCMD_MKDIR:
400 WCMD_create_dir ();
401 break;
402 case WCMD_MOVE:
403 WCMD_move ();
404 break;
405 case WCMD_PATH:
406 WCMD_setshow_path (p);
407 break;
408 case WCMD_PAUSE:
409 WCMD_pause ();
410 break;
411 case WCMD_PROMPT:
412 WCMD_setshow_prompt ();
413 break;
414 case WCMD_REM:
415 break;
416 case WCMD_REN:
417 case WCMD_RENAME:
418 WCMD_rename ();
419 break;
420 case WCMD_RD:
421 case WCMD_RMDIR:
422 WCMD_remove_dir ();
423 break;
424 case WCMD_SET:
425 WCMD_setshow_env (p);
426 break;
427 case WCMD_SHIFT:
428 WCMD_shift ();
429 break;
430 case WCMD_TIME:
431 WCMD_setshow_time ();
432 break;
433 case WCMD_TITLE:
434 if (strlen(&whichcmd[count]) > 0)
435 WCMD_title(&whichcmd[count+1]);
436 break;
437 case WCMD_TYPE:
438 WCMD_type ();
439 break;
440 case WCMD_VER:
441 WCMD_version ();
442 break;
443 case WCMD_VERIFY:
444 WCMD_verify (p);
445 break;
446 case WCMD_VOL:
447 WCMD_volume (0, p);
448 break;
449 case WCMD_EXIT:
450 ExitProcess (0);
451 default:
452 WCMD_run_program (whichcmd);
454 HeapFree( GetProcessHeap(), 0, cmd );
455 if (old_stdin) {
456 CloseHandle (GetStdHandle (STD_INPUT_HANDLE));
457 SetStdHandle (STD_INPUT_HANDLE, old_stdin);
459 if (old_stdout) {
460 CloseHandle (GetStdHandle (STD_OUTPUT_HANDLE));
461 SetStdHandle (STD_OUTPUT_HANDLE, old_stdout);
465 /******************************************************************************
466 * WCMD_run_program
468 * Execute a command line as an external program. If no extension given then
469 * precedence is given to .BAT files. Must allow recursion.
471 * FIXME: Case sensitivity in suffixes!
474 void WCMD_run_program (char *command) {
476 STARTUPINFO st;
477 PROCESS_INFORMATION pe;
478 SHFILEINFO psfi;
479 DWORD console;
480 BOOL status;
481 HANDLE h;
482 HINSTANCE hinst;
483 char filetorun[MAX_PATH];
485 WCMD_parse (command, quals, param1, param2); /* Quick way to get the filename */
486 if (!(*param1) && !(*param2))
487 return;
488 if (strpbrk (param1, "/\\:") == NULL) { /* No explicit path given */
489 char *ext = strrchr( param1, '.' );
490 if (!ext || !strcasecmp( ext, ".bat"))
492 if (SearchPath (NULL, param1, ".bat", sizeof(filetorun), filetorun, NULL)) {
493 WCMD_batch (filetorun, command, 0);
494 return;
497 if (!ext || !strcasecmp( ext, ".cmd"))
499 if (SearchPath (NULL, param1, ".cmd", sizeof(filetorun), filetorun, NULL)) {
500 WCMD_batch (filetorun, command, 0);
501 return;
505 else { /* Explicit path given */
506 char *ext = strrchr( param1, '.' );
507 if (ext && (!strcasecmp( ext, ".bat" ) || !strcasecmp( ext, ".cmd" )))
509 WCMD_batch (param1, command, 0);
510 return;
513 if (ext && strpbrk( ext, "/\\:" )) ext = NULL;
514 if (!ext)
516 strcpy (filetorun, param1);
517 strcat (filetorun, ".bat");
518 h = CreateFile (filetorun, GENERIC_READ, FILE_SHARE_READ,
519 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
520 if (h != INVALID_HANDLE_VALUE) {
521 CloseHandle (h);
522 WCMD_batch (param1, command, 0);
523 return;
528 /* No batch file found, assume executable */
530 hinst = FindExecutable (param1, NULL, filetorun);
531 if ((int)hinst < 32) {
532 WCMD_print_error ();
533 return;
535 console = SHGetFileInfo (filetorun, 0, &psfi, sizeof(psfi), SHGFI_EXETYPE);
536 ZeroMemory (&st, sizeof(STARTUPINFO));
537 st.cb = sizeof(STARTUPINFO);
538 status = CreateProcess (NULL, command, NULL, NULL, TRUE,
539 0, NULL, NULL, &st, &pe);
540 if (!status) {
541 WCMD_print_error ();
542 return;
544 if (!console) errorlevel = 0;
545 else
547 if (!HIWORD(console)) WaitForSingleObject (pe.hProcess, INFINITE);
548 GetExitCodeProcess (pe.hProcess, &errorlevel);
549 if (errorlevel == STILL_ACTIVE) errorlevel = 0;
551 CloseHandle(pe.hProcess);
552 CloseHandle(pe.hThread);
555 /******************************************************************************
556 * WCMD_show_prompt
558 * Display the prompt on STDout
562 void WCMD_show_prompt (void) {
564 int status;
565 char out_string[MAX_PATH], curdir[MAX_PATH], prompt_string[MAX_PATH];
566 char *p, *q;
568 status = GetEnvironmentVariable ("PROMPT", prompt_string, sizeof(prompt_string));
569 if ((status == 0) || (status > sizeof(prompt_string))) {
570 lstrcpy (prompt_string, "$P$G");
572 p = prompt_string;
573 q = out_string;
574 *q = '\0';
575 while (*p != '\0') {
576 if (*p != '$') {
577 *q++ = *p++;
578 *q = '\0';
580 else {
581 p++;
582 switch (toupper(*p)) {
583 case '$':
584 *q++ = '$';
585 break;
586 case 'B':
587 *q++ = '|';
588 break;
589 case 'D':
590 GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, q, MAX_PATH);
591 while (*q) q++;
592 break;
593 case 'E':
594 *q++ = '\E';
595 break;
596 case 'G':
597 *q++ = '>';
598 break;
599 case 'L':
600 *q++ = '<';
601 break;
602 case 'N':
603 status = GetCurrentDirectory (sizeof(curdir), curdir);
604 if (status) {
605 *q++ = curdir[0];
607 break;
608 case 'P':
609 status = GetCurrentDirectory (sizeof(curdir), curdir);
610 if (status) {
611 lstrcat (q, curdir);
612 while (*q) q++;
614 break;
615 case 'Q':
616 *q++ = '=';
617 break;
618 case 'T':
619 GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL, q, MAX_PATH);
620 while (*q) q++;
621 break;
622 case 'V':
623 lstrcat (q, version_string);
624 while (*q) q++;
625 break;
626 case '_':
627 *q++ = '\n';
628 break;
630 p++;
631 *q = '\0';
634 WCMD_output (out_string);
637 /****************************************************************************
638 * WCMD_print_error
640 * Print the message for GetLastError
643 void WCMD_print_error (void) {
644 LPVOID lpMsgBuf;
645 DWORD error_code;
646 int status;
648 error_code = GetLastError ();
649 status = FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
650 NULL, error_code, 0, (LPTSTR) &lpMsgBuf, 0, NULL);
651 if (!status) {
652 WCMD_output ("FIXME: Cannot display message for error %d, status %d\n",
653 error_code, GetLastError());
654 return;
656 WCMD_output (lpMsgBuf);
657 LocalFree ((HLOCAL)lpMsgBuf);
658 WCMD_output (newline);
659 return;
662 /*******************************************************************
663 * WCMD_parse - parse a command into parameters and qualifiers.
665 * On exit, all qualifiers are concatenated into q, the first string
666 * not beginning with "/" is in p1 and the
667 * second in p2. Any subsequent non-qualifier strings are lost.
668 * Parameters in quotes are handled.
671 void WCMD_parse (char *s, char *q, char *p1, char *p2) {
673 int p = 0;
675 *q = *p1 = *p2 = '\0';
676 while (TRUE) {
677 switch (*s) {
678 case '/':
679 *q++ = *s++;
680 while ((*s != '\0') && (*s != ' ') && *s != '/') {
681 *q++ = toupper (*s++);
683 *q = '\0';
684 break;
685 case ' ':
686 s++;
687 break;
688 case '"':
689 s++;
690 while ((*s != '\0') && (*s != '"')) {
691 if (p == 0) *p1++ = *s++;
692 else if (p == 1) *p2++ = *s++;
693 else s++;
695 if (p == 0) *p1 = '\0';
696 if (p == 1) *p2 = '\0';
697 p++;
698 if (*s == '"') s++;
699 break;
700 case '\0':
701 return;
702 default:
703 while ((*s != '\0') && (*s != ' ')) {
704 if (p == 0) *p1++ = *s++;
705 else if (p == 1) *p2++ = *s++;
706 else s++;
708 if (p == 0) *p1 = '\0';
709 if (p == 1) *p2 = '\0';
710 p++;
715 /*******************************************************************
716 * WCMD_output - send output to current standard output device.
720 void WCMD_output (char *format, ...) {
722 va_list ap;
723 char string[1024];
725 va_start(ap,format);
726 vsprintf (string, format, ap);
727 va_end(ap);
728 WCMD_output_asis(string);
732 static int line_count;
733 static int max_height;
734 static BOOL paged_mode;
736 void WCMD_enter_paged_mode(void)
738 CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
740 if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &consoleInfo))
741 max_height = consoleInfo.dwSize.Y;
742 else
743 max_height = 25;
744 paged_mode = TRUE;
745 line_count = 5; /* keep 5 lines from previous output */
748 void WCMD_leave_paged_mode(void)
750 paged_mode = FALSE;
753 /*******************************************************************
754 * WCMD_output_asis - send output to current standard output device.
755 * without formatting eg. when message contains '%'
758 void WCMD_output_asis (char *message) {
759 DWORD count;
760 char* ptr;
761 char string[1024];
763 if (paged_mode) {
764 do {
765 if ((ptr = strchr(message, '\n')) != NULL) ptr++;
766 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), message,
767 (ptr) ? ptr - message : lstrlen(message), &count, NULL);
768 if (ptr) {
769 if (++line_count >= max_height - 1) {
770 line_count = 0;
771 WCMD_output_asis (anykey);
772 ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL);
775 } while ((message = ptr) != NULL);
776 } else {
777 WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), message, lstrlen(message), &count, NULL);
782 /***************************************************************************
783 * WCMD_strtrim_leading_spaces
785 * Remove leading spaces from a string. Return a pointer to the first
786 * non-space character. Does not modify the input string
789 char *WCMD_strtrim_leading_spaces (char *string) {
791 char *ptr;
793 ptr = string;
794 while (*ptr == ' ') ptr++;
795 return ptr;
798 /*************************************************************************
799 * WCMD_strtrim_trailing_spaces
801 * Remove trailing spaces from a string. This routine modifies the input
802 * string by placing a null after the last non-space character
805 void WCMD_strtrim_trailing_spaces (char *string) {
807 char *ptr;
809 ptr = string + lstrlen (string) - 1;
810 while ((*ptr == ' ') && (ptr >= string)) {
811 *ptr = '\0';
812 ptr--;
816 /*************************************************************************
817 * WCMD_pipe
819 * Handle pipes within a command - the DOS way using temporary files.
822 void WCMD_pipe (char *command) {
824 char *p;
825 char temp_path[MAX_PATH], temp_file[MAX_PATH], temp_file2[MAX_PATH], temp_cmd[1024];
827 GetTempPath (sizeof(temp_path), temp_path);
828 GetTempFileName (temp_path, "WCMD", 0, temp_file);
829 p = strchr(command, '|');
830 *p++ = '\0';
831 wsprintf (temp_cmd, "%s > %s", command, temp_file);
832 WCMD_process_command (temp_cmd);
833 command = p;
834 while ((p = strchr(command, '|'))) {
835 *p++ = '\0';
836 GetTempFileName (temp_path, "WCMD", 0, temp_file2);
837 wsprintf (temp_cmd, "%s < %s > %s", command, temp_file, temp_file2);
838 WCMD_process_command (temp_cmd);
839 DeleteFile (temp_file);
840 lstrcpy (temp_file, temp_file2);
841 command = p;
843 wsprintf (temp_cmd, "%s < %s", command, temp_file);
844 WCMD_process_command (temp_cmd);
845 DeleteFile (temp_file);