2 * CMD - Wine-compatible command line interface - built-in functions.
4 * Copyright (C) 1999 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * On entry to each function, global variables quals, param1, param2 contain
24 * the qualifiers (uppercased and concatenated) and parameters entered, with
25 * environment-variable and batch parameter substitution already done.
30 * - No support for pipes, shell parameters
31 * - Lots of functionality missing from builtins
32 * - Messages etc need international support
35 #define WIN32_LEAN_AND_MEAN
39 void WCMD_execute (char *orig_command, char *parameter, char *substitution);
43 struct env_stack *next;
47 struct env_stack *saved_environment;
49 extern HINSTANCE hinst;
50 extern char *inbuilt[];
51 extern int echo_mode, verify_mode;
52 extern char quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH];
53 extern BATCH_CONTEXT *context;
54 extern DWORD errorlevel;
58 /****************************************************************************
61 * Clear the terminal screen.
64 void WCMD_clear_screen (void) {
66 /* Emulate by filling the screen from the top left to bottom right with
67 spaces, then moving the cursor to the top left afterwards */
68 CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
69 HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
71 if (GetConsoleScreenBufferInfo(hStdOut, &consoleInfo))
76 screenSize = consoleInfo.dwSize.X * (consoleInfo.dwSize.Y + 1);
80 FillConsoleOutputCharacter(hStdOut, ' ', screenSize, topLeft, &screenSize);
81 SetConsoleCursorPosition(hStdOut, topLeft);
85 /****************************************************************************
88 * Change the default i/o device (ie redirect STDin/STDout).
91 void WCMD_change_tty (void) {
97 /****************************************************************************
100 * Copy a file or wildcarded set.
101 * FIXME: No wildcard support
104 void WCMD_copy (void) {
110 static const char overwrite[] = "Overwrite file (Y/N)?";
111 char string[8], outpath[MAX_PATH], inpath[MAX_PATH], *infile;
113 if (param1[0] == 0x00) {
114 WCMD_output ("Argument missing\n");
118 if ((strchr(param1,'*') != NULL) && (strchr(param1,'%') != NULL)) {
119 WCMD_output ("Wildcards not yet supported\n");
123 /* If no destination supplied, assume current directory */
124 if (param2[0] == 0x00) {
128 GetFullPathName (param2, sizeof(outpath), outpath, NULL);
129 hff = FindFirstFile (outpath, &fd);
130 if (hff != INVALID_HANDLE_VALUE) {
131 if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
132 GetFullPathName (param1, sizeof(inpath), inpath, &infile);
133 strcat (outpath, "\\");
134 strcat (outpath, infile);
139 force = (strstr (quals, "/Y") != NULL);
141 hff = FindFirstFile (outpath, &fd);
142 if (hff != INVALID_HANDLE_VALUE) {
144 WCMD_output (overwrite);
145 ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL);
146 if (toupper(string[0]) == 'Y') force = TRUE;
151 status = CopyFile (param1, outpath, FALSE);
152 if (!status) WCMD_print_error ();
156 /****************************************************************************
159 * Create a directory.
161 * this works recursivly. so mkdir dir1\dir2\dir3 will create dir1 and dir2 if
162 * they do not already exist.
165 BOOL create_full_path(CHAR* path)
171 new_path = HeapAlloc(GetProcessHeap(),0,strlen(path)+1);
172 strcpy(new_path,path);
174 while ((len = strlen(new_path)) && new_path[len - 1] == '\\')
175 new_path[len - 1] = 0;
177 while (!CreateDirectory(new_path,NULL))
180 DWORD last_error = GetLastError();
181 if (last_error == ERROR_ALREADY_EXISTS)
184 if (last_error != ERROR_PATH_NOT_FOUND)
190 if (!(slash = strrchr(new_path,'\\')) && ! (slash = strrchr(new_path,'/')))
196 len = slash - new_path;
198 if (!create_full_path(new_path))
203 new_path[len] = '\\';
205 HeapFree(GetProcessHeap(),0,new_path);
209 void WCMD_create_dir (void) {
211 if (param1[0] == 0x00) {
212 WCMD_output ("Argument missing\n");
215 if (!create_full_path(param1)) WCMD_print_error ();
218 /****************************************************************************
221 * Delete a file or wildcarded set.
225 void WCMD_delete (int recurse) {
229 char fpath[MAX_PATH];
232 if (param1[0] == 0x00) {
233 WCMD_output ("Argument missing\n");
236 hff = FindFirstFile (param1, &fd);
237 if (hff == INVALID_HANDLE_VALUE) {
238 WCMD_output ("%s :File Not Found\n",param1);
241 if ((strchr(param1,'*') == NULL) && (strchr(param1,'?') == NULL)
242 && (!recurse) && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
243 strcat (param1, "\\*");
248 if ((strchr(param1,'*') != NULL) || (strchr(param1,'?') != NULL)) {
249 strcpy (fpath, param1);
251 p = strrchr (fpath, '\\');
254 strcat (fpath, fd.cFileName);
256 else strcpy (fpath, fd.cFileName);
257 if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
258 if (!DeleteFile (fpath)) WCMD_print_error ();
260 } while (FindNextFile(hff, &fd) != 0);
264 if (!DeleteFile (param1)) WCMD_print_error ();
269 /****************************************************************************
272 * Echo input to the screen (or not). We don't try to emulate the bugs
273 * in DOS (try typing "ECHO ON AGAIN" for an example).
276 void WCMD_echo (const char *command) {
278 static const char eon[] = "Echo is ON\n", eoff[] = "Echo is OFF\n";
281 if ((command[0] == '.') && (command[1] == 0)) {
282 WCMD_output (newline);
287 count = strlen(command);
289 if (echo_mode) WCMD_output (eon);
290 else WCMD_output (eoff);
293 if (lstrcmpi(command, "ON") == 0) {
297 if (lstrcmpi(command, "OFF") == 0) {
301 WCMD_output_asis (command);
302 WCMD_output (newline);
306 /**************************************************************************
309 * Batch file loop processing.
310 * FIXME: We don't exhaustively check syntax. Any command which works in MessDOS
311 * will probably work here, but the reverse is not necessarily the case...
314 void WCMD_for (char *p) {
319 char set[MAX_PATH], param[MAX_PATH];
322 if (lstrcmpi (WCMD_parameter (p, 1, NULL), "in")
323 || lstrcmpi (WCMD_parameter (p, 3, NULL), "do")
324 || (param1[0] != '%')) {
325 WCMD_output ("Syntax error\n");
328 lstrcpyn (set, WCMD_parameter (p, 2, NULL), sizeof(set));
329 WCMD_parameter (p, 4, &cmd);
330 lstrcpy (param, param1);
333 * If the parameter within the set has a wildcard then search for matching files
334 * otherwise do a literal substitution.
338 while (*(item = WCMD_parameter (set, i, NULL))) {
339 if (strpbrk (item, "*?")) {
340 hff = FindFirstFile (item, &fd);
341 if (hff == INVALID_HANDLE_VALUE) {
345 WCMD_execute (cmd, param, fd.cFileName);
346 } while (FindNextFile(hff, &fd) != 0);
350 WCMD_execute (cmd, param, item);
356 /*****************************************************************************
359 * Execute a command after substituting variable text for the supplied parameter
362 void WCMD_execute (char *orig_cmd, char *param, char *subst) {
364 char *new_cmd, *p, *s, *dup;
367 size = lstrlen (orig_cmd);
368 new_cmd = (char *) LocalAlloc (LMEM_FIXED | LMEM_ZEROINIT, size);
369 dup = s = strdup (orig_cmd);
371 while ((p = strstr (s, param))) {
373 size += lstrlen (subst);
374 new_cmd = (char *) LocalReAlloc ((HANDLE)new_cmd, size, 0);
376 strcat (new_cmd, subst);
377 s = p + lstrlen (param);
380 WCMD_process_command (new_cmd);
382 LocalFree ((HANDLE)new_cmd);
386 /**************************************************************************
389 * Simple on-line help. Help text is stored in the resource file.
392 void WCMD_give_help (char *command) {
397 command = WCMD_strtrim_leading_spaces(command);
398 if (lstrlen(command) == 0) {
399 LoadString (hinst, 1000, buffer, sizeof(buffer));
400 WCMD_output_asis (buffer);
403 for (i=0; i<=WCMD_EXIT; i++) {
404 if (CompareString (LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
405 param1, -1, inbuilt[i], -1) == 2) {
406 LoadString (hinst, i, buffer, sizeof(buffer));
407 WCMD_output_asis (buffer);
411 WCMD_output ("No help available for %s\n", param1);
416 /****************************************************************************
419 * Batch file jump instruction. Not the most efficient algorithm ;-)
420 * Prints error message if the specified label cannot be found - the file pointer is
421 * then at EOF, effectively stopping the batch file.
422 * FIXME: DOS is supposed to allow labels with spaces - we don't.
425 void WCMD_goto (void) {
427 char string[MAX_PATH];
429 if (param1[0] == 0x00) {
430 WCMD_output ("Argument missing\n");
433 if (context != NULL) {
434 SetFilePointer (context -> h, 0, NULL, FILE_BEGIN);
435 while (WCMD_fgets (string, sizeof(string), context -> h)) {
436 if ((string[0] == ':') && (strcmp (&string[1], param1) == 0)) return;
438 WCMD_output ("Target to GOTO not found\n");
444 /****************************************************************************
447 * Batch file conditional.
448 * FIXME: Much more syntax checking needed!
451 void WCMD_if (char *p) {
453 int negate = 0, test = 0;
454 char condition[MAX_PATH], *command, *s;
456 if (!lstrcmpi (param1, "not")) {
458 lstrcpy (condition, param2);
461 lstrcpy (condition, param1);
463 if (!lstrcmpi (condition, "errorlevel")) {
464 if (errorlevel >= atoi(WCMD_parameter (p, 1+negate, NULL))) test = 1;
466 WCMD_parameter (p, 2+negate, &command);
468 else if (!lstrcmpi (condition, "exist")) {
469 if (GetFileAttributesA(WCMD_parameter (p, 1+negate, NULL)) != INVALID_FILE_ATTRIBUTES) {
472 WCMD_parameter (p, 2+negate, &command);
474 else if ((s = strstr (p, "=="))) {
476 if (!lstrcmpi (condition, WCMD_parameter (s, 0, NULL))) test = 1;
477 WCMD_parameter (s, 1, &command);
480 WCMD_output ("Syntax error\n");
483 if (test != negate) {
484 command = strdup (command);
485 WCMD_process_command (command);
490 /****************************************************************************
493 * Move a file, directory tree or wildcarded set of files.
494 * FIXME: Needs input and output files to be fully specified.
497 void WCMD_move (void) {
500 char outpath[MAX_PATH], inpath[MAX_PATH], *infile;
504 if (param1[0] == 0x00) {
505 WCMD_output ("Argument missing\n");
509 if ((strchr(param1,'*') != NULL) || (strchr(param1,'%') != NULL)) {
510 WCMD_output ("Wildcards not yet supported\n");
514 /* If no destination supplied, assume current directory */
515 if (param2[0] == 0x00) {
519 /* If 2nd parm is directory, then use original filename */
520 GetFullPathName (param2, sizeof(outpath), outpath, NULL);
521 hff = FindFirstFile (outpath, &fd);
522 if (hff != INVALID_HANDLE_VALUE) {
523 if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
524 GetFullPathName (param1, sizeof(inpath), inpath, &infile);
525 strcat (outpath, "\\");
526 strcat (outpath, infile);
531 status = MoveFile (param1, outpath);
532 if (!status) WCMD_print_error ();
535 /****************************************************************************
538 * Wait for keyboard input.
541 void WCMD_pause (void) {
546 WCMD_output (anykey);
547 ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL);
550 /****************************************************************************
553 * Delete a directory.
556 void WCMD_remove_dir (void) {
558 if (param1[0] == 0x00) {
559 WCMD_output ("Argument missing\n");
562 if (!RemoveDirectory (param1)) WCMD_print_error ();
565 /****************************************************************************
569 * FIXME: Needs input and output files to be fully specified.
572 void WCMD_rename (void) {
576 if (param1[0] == 0x00 || param2[0] == 0x00) {
577 WCMD_output ("Argument missing\n");
580 if ((strchr(param1,'*') != NULL) || (strchr(param1,'%') != NULL)) {
581 WCMD_output ("Wildcards not yet supported\n");
584 status = MoveFile (param1, param2);
585 if (!status) WCMD_print_error ();
588 /*****************************************************************************
591 * Make a copy of the environment.
593 static WCHAR *WCMD_dupenv( const WCHAR *env )
603 len += (lstrlenW(&env[len]) + 1);
605 env_copy = LocalAlloc (LMEM_FIXED, (len+1) * sizeof (WCHAR) );
608 WCMD_output ("out of memory\n");
611 memcpy (env_copy, env, len*sizeof (WCHAR));
617 /*****************************************************************************
620 * setlocal pushes the environment onto a stack
621 * Save the environment as unicode so we don't screw anything up.
623 void WCMD_setlocal (const char *s) {
625 struct env_stack *env_copy;
627 /* DISABLEEXTENSIONS ignored */
629 env_copy = LocalAlloc (LMEM_FIXED, sizeof (struct env_stack));
632 WCMD_output ("out of memory\n");
636 env = GetEnvironmentStringsW ();
638 env_copy->strings = WCMD_dupenv (env);
639 if (env_copy->strings)
641 env_copy->next = saved_environment;
642 saved_environment = env_copy;
645 LocalFree (env_copy);
647 FreeEnvironmentStringsW (env);
650 /*****************************************************************************
653 static inline WCHAR *WCMD_strchrW(WCHAR *str, WCHAR ch)
664 /*****************************************************************************
667 * endlocal pops the environment off a stack
669 void WCMD_endlocal (void) {
670 WCHAR *env, *old, *p;
671 struct env_stack *temp;
674 if (!saved_environment)
677 /* pop the old environment from the stack */
678 temp = saved_environment;
679 saved_environment = temp->next;
681 /* delete the current environment, totally */
682 env = GetEnvironmentStringsW ();
683 old = WCMD_dupenv (GetEnvironmentStringsW ());
686 n = lstrlenW(&old[len]) + 1;
687 p = WCMD_strchrW(&old[len], '=');
691 SetEnvironmentVariableW (&old[len], NULL);
696 FreeEnvironmentStringsW (env);
698 /* restore old environment */
702 n = lstrlenW(&env[len]) + 1;
703 p = WCMD_strchrW(&env[len], '=');
707 SetEnvironmentVariableW (&env[len], p);
715 /*****************************************************************************
716 * WCMD_setshow_attrib
718 * Display and optionally sets DOS attributes on a file or directory
720 * FIXME: Wine currently uses the Unix stat() function to get file attributes.
721 * As a result only the Readonly flag is correctly reported, the Archive bit
722 * is always set and the rest are not implemented. We do the Right Thing anyway.
724 * FIXME: No SET functionality.
728 void WCMD_setshow_attrib (void) {
733 char flags[9] = {" "};
735 if (param1[0] == '-') {
740 if (lstrlen(param1) == 0) {
741 GetCurrentDirectory (sizeof(param1), param1);
742 strcat (param1, "\\*");
745 hff = FindFirstFile (param1, &fd);
746 if (hff == INVALID_HANDLE_VALUE) {
747 WCMD_output ("%s: File Not Found\n",param1);
751 if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
752 if (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) {
755 if (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) {
758 if (fd.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) {
761 if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
764 if (fd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) {
767 if (fd.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) {
770 WCMD_output ("%s %s\n", flags, fd.cFileName);
771 for (count=0; count < 8; count++) flags[count] = ' ';
773 } while (FindNextFile(hff, &fd) != 0);
778 /*****************************************************************************
779 * WCMD_setshow_default
781 * Set/Show the current default directory
784 void WCMD_setshow_default (void) {
789 if (strlen(param1) == 0) {
790 GetCurrentDirectory (sizeof(string), string);
791 strcat (string, "\n");
792 WCMD_output (string);
795 status = SetCurrentDirectory (param1);
804 /****************************************************************************
807 * Set/Show the system date
808 * FIXME: Can't change date yet
811 void WCMD_setshow_date (void) {
813 char curdate[64], buffer[64];
816 if (lstrlen(param1) == 0) {
817 if (GetDateFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL,
818 curdate, sizeof(curdate))) {
819 WCMD_output ("Current Date is %s\nEnter new date: ", curdate);
820 ReadFile (GetStdHandle(STD_INPUT_HANDLE), buffer, sizeof(buffer), &count, NULL);
825 else WCMD_print_error ();
832 /****************************************************************************
835 static int WCMD_compare( const void *a, const void *b )
838 const char * const *str_a = a, * const *str_b = b;
839 r = CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
840 *str_a, -1, *str_b, -1 );
841 if( r == CSTR_LESS_THAN ) return -1;
842 if( r == CSTR_GREATER_THAN ) return 1;
846 /****************************************************************************
847 * WCMD_setshow_sortenv
849 * sort variables into order for display
851 static void WCMD_setshow_sortenv(const char *s)
853 UINT count=0, len=0, i;
856 /* count the number of strings, and the total length */
858 len += (lstrlen(&s[len]) + 1);
862 /* add the strings to an array */
863 str = LocalAlloc (LMEM_FIXED | LMEM_ZEROINIT, count * sizeof (char*) );
867 for( i=1; i<count; i++ )
868 str[i] = str[i-1] + lstrlen(str[i-1]) + 1;
871 qsort( str, count, sizeof (char*), WCMD_compare );
874 for( i=0; i<count; i++ ) {
875 WCMD_output_asis(str[i]);
876 WCMD_output_asis("\n");
882 /****************************************************************************
885 * Set/Show the environment variables
888 void WCMD_setshow_env (char *s) {
895 if (strlen(param1) == 0) {
896 env = GetEnvironmentStrings ();
897 WCMD_setshow_sortenv( env );
903 /* FIXME: Emulate Win98 for now, ie "SET C" looks ONLY for an
904 environment variable C, whereas on NT it shows ALL variables
907 status = GetEnvironmentVariable(s, buffer, sizeof(buffer));
909 WCMD_output_asis( s);
910 WCMD_output_asis( "=");
911 WCMD_output_asis( buffer);
912 WCMD_output_asis( "\n");
914 WCMD_output ("Environment variable %s not defined\n", s);
920 if (strlen(p) == 0) p = NULL;
921 status = SetEnvironmentVariable (s, p);
922 if ((!status) & (GetLastError() != ERROR_ENVVAR_NOT_FOUND)) WCMD_print_error();
924 /* WCMD_output (newline); @JED*/
927 /****************************************************************************
930 * Set/Show the path environment variable
933 void WCMD_setshow_path (char *command) {
938 if (strlen(param1) == 0) {
939 status = GetEnvironmentVariable ("PATH", string, sizeof(string));
941 WCMD_output_asis ( "PATH=");
942 WCMD_output_asis ( string);
943 WCMD_output_asis ( "\n");
946 WCMD_output ("PATH not found\n");
950 status = SetEnvironmentVariable ("PATH", command);
951 if (!status) WCMD_print_error();
955 /****************************************************************************
956 * WCMD_setshow_prompt
958 * Set or show the command prompt.
961 void WCMD_setshow_prompt (void) {
965 if (strlen(param1) == 0) {
966 SetEnvironmentVariable ("PROMPT", NULL);
970 while ((*s == '=') || (*s == ' ')) s++;
971 if (strlen(s) == 0) {
972 SetEnvironmentVariable ("PROMPT", NULL);
974 else SetEnvironmentVariable ("PROMPT", s);
978 /****************************************************************************
981 * Set/Show the system time
982 * FIXME: Can't change time yet
985 void WCMD_setshow_time (void) {
987 char curtime[64], buffer[64];
991 if (strlen(param1) == 0) {
993 if (GetTimeFormat (LOCALE_USER_DEFAULT, 0, &st, NULL,
994 curtime, sizeof(curtime))) {
995 WCMD_output ("Current Time is %s\nEnter new time: ", curtime);
996 ReadFile (GetStdHandle(STD_INPUT_HANDLE), buffer, sizeof(buffer), &count, NULL);
1001 else WCMD_print_error ();
1008 /****************************************************************************
1011 * Shift batch parameters.
1014 void WCMD_shift (void) {
1016 if (context != NULL) context -> shift_count++;
1020 /****************************************************************************
1023 * Set the console title
1025 void WCMD_title (char *command) {
1026 SetConsoleTitle(command);
1029 /****************************************************************************
1032 * Copy a file to standard output.
1035 void WCMD_type (void) {
1041 if (param1[0] == 0x00) {
1042 WCMD_output ("Argument missing\n");
1045 h = CreateFile (param1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
1046 FILE_ATTRIBUTE_NORMAL, NULL);
1047 if (h == INVALID_HANDLE_VALUE) {
1048 WCMD_print_error ();
1051 while (ReadFile (h, buffer, sizeof(buffer), &count, NULL)) {
1052 if (count == 0) break; /* ReadFile reports success on EOF! */
1054 WCMD_output_asis (buffer);
1059 /****************************************************************************
1062 * Display verify flag.
1063 * FIXME: We don't actually do anything with the verify flag other than toggle
1067 void WCMD_verify (char *command) {
1069 static const char von[] = "Verify is ON\n", voff[] = "Verify is OFF\n";
1072 count = strlen(command);
1074 if (verify_mode) WCMD_output (von);
1075 else WCMD_output (voff);
1078 if (lstrcmpi(command, "ON") == 0) {
1082 else if (lstrcmpi(command, "OFF") == 0) {
1086 else WCMD_output ("Verify must be ON or OFF\n");
1089 /****************************************************************************
1092 * Display version info.
1095 void WCMD_version (void) {
1097 WCMD_output (version_string);
1101 /****************************************************************************
1104 * Display volume info and/or set volume label. Returns 0 if error.
1107 int WCMD_volume (int mode, char *path) {
1109 DWORD count, serial;
1110 char string[MAX_PATH], label[MAX_PATH], curdir[MAX_PATH];
1113 if (lstrlen(path) == 0) {
1114 status = GetCurrentDirectory (sizeof(curdir), curdir);
1116 WCMD_print_error ();
1119 status = GetVolumeInformation (NULL, label, sizeof(label), &serial, NULL,
1123 if ((path[1] != ':') || (lstrlen(path) != 2)) {
1124 WCMD_output_asis("Syntax Error\n\n");
1127 wsprintf (curdir, "%s\\", path);
1128 status = GetVolumeInformation (curdir, label, sizeof(label), &serial, NULL,
1132 WCMD_print_error ();
1135 WCMD_output ("Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n",
1136 curdir[0], label, HIWORD(serial), LOWORD(serial));
1138 WCMD_output ("Volume label (11 characters, ENTER for none)?");
1139 ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL);
1141 string[count-1] = '\0'; /* ReadFile output is not null-terminated! */
1142 if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */
1144 if (lstrlen(path) != 0) {
1145 if (!SetVolumeLabel (curdir, string)) WCMD_print_error ();
1148 if (!SetVolumeLabel (NULL, string)) WCMD_print_error ();