diff --git a/reactos/subsys/system/cmd/En.rc b/reactos/subsys/system/cmd/En.rc index 0d03ad2f356..431600aa6ad 100644 --- a/reactos/subsys/system/cmd/En.rc +++ b/reactos/subsys/system/cmd/En.rc @@ -1,5 +1,6 @@ #include "resource.h" -/* Start move all hard code string to En.rc +/* + * Moved all hardcoded strings to En.rc. * By Magnus Olsen 2005 */ @@ -7,60 +8,60 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { -STRING_ATTRIB_HELP, "Displays or changes file attributes.\n\n \ -ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] file ...\n \ - [/S [/D]]\n\n \ - + Sets an attribute\n \ - - Clears an attribute\n \ - R Read-only file attribute\n \ - A Archive file attribute\n \ - S System file attribute\n \ - H Hidden file attribute\n \ - /S Processes matching files in the current directory\n \ - and all subdirectories\n \ - /D Processes direcories as well\n\n \ +STRING_ATTRIB_HELP, "Displays or changes file attributes.\n\n\ +ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] file ...\n\ + [/S [/D]]\n\n\ + + Sets an attribute\n\ + - Clears an attribute\n\ + R Read-only file attribute\n\ + A Archive file attribute\n\ + S System file attribute\n\ + H Hidden file attribute\n\ + /S Processes matching files in the current directory\n\ + and all subdirectories\n\ + /D Processes direcories as well\n\n\ Type ATTRIB without a parameter to display the attributes of all files." -STRING_ALIAS_HELP, "Sets, removes or shows aliases.\n\n \ -ALIAS [alias=[command]]\n\n \ - alias Name for an alias.\n \ - command Text to be substituted for an alias.\n\n \ -To list all aliases:\n \ - ALIAS\n\n \ -To set a new or replace an existing alias:\n \ - ALIAS da=dir a:\n\n \ -To remove an alias from the alias list:\n \ +STRING_ALIAS_HELP, "Sets, removes or shows aliases.\n\n\ +ALIAS [alias=[command]]\n\n\ + alias Name for an alias.\n\ + command Text to be substituted for an alias.\n\n\ +To list all aliases:\n\ + ALIAS\n\n\ +To set a new or replace an existing alias:\n\ + ALIAS da=dir a:\n\n\ +To remove an alias from the alias list:\n\ ALIAS da=" STRING_BEEP_HELP, "Beep the speaker.\n\nBEEP" -STRING_CALL_HELP, "Calls one batch program from another.\n\n \ -CALL [drive:][path]filename [batch-parameter]\n\n \ - batch-parameter Specifies any command-line information required by the\n \ +STRING_CALL_HELP, "Calls one batch program from another.\n\n\ +CALL [drive:][path]filename [batch-parameter]\n\n\ + batch-parameter Specifies any command-line information required by the\n\ batch program." -STRING_CD_HELP, "Changes the current directory or displays it's name\n\n \ -CHDIR [drive:][path]\n \ -CHDIR[..|-]\n \ -CD [drive:][path]\n \ -CD[..|-]\n\n \ - .. parent directory\n \ - - previous directory\n\n \ -Type CD drive: to display the current directory on the specified drive.\n \ -Type CD without a parameter to display the current drive and directory. " +STRING_CD_HELP, "Changes the current directory or displays it's name\n\n\ +CHDIR [drive:][path]\n\ +CHDIR[..|-]\n\ +CD [drive:][path]\n\ +CD[..|-]\n\n\ + .. parent directory\n\ + - previous directory\n\n\ +Type CD drive: to display the current directory on the specified drive.\n\ +Type CD without a parameter to display the current drive and directory." -STRING_CHCP_HELP, "Displays or sets the active code page number.\n\n \ -CHCP [nnn]\n\n \ - nnn Specifies the active code page number.\n\n \ +STRING_CHCP_HELP, "Displays or sets the active code page number.\n\n\ +CHCP [nnn]\n\n\ + nnn Specifies the active code page number.\n\n\ Type CHCP without a parameter to display the active code page number." -STRING_CHOICE_HELP, "Waits for the user to choose one of a set of choices.\n\n \ -CHOICE [/C[:]choices][/N][/S][/T[:]c,nn][text]\n\n \ - /C[:]choices Specifies allowable keys. Default is YN.\n \ - /N Do not display choices and ? at the end of the prompt string.\n \ - /S Treat choice keys as case sensitive.\n \ - /T[:]c,nn Default choice to c after nn seconds.\n \ - text Prompt string to display.\n\n \ +STRING_CHOICE_HELP, "Waits for the user to choose one of a set of choices.\n\n\ +CHOICE [/C[:]choices][/N][/S][/T[:]c,nn][text]\n\n\ + /C[:]choices Specifies allowable keys. Default is YN.\n\ + /N Do not display choices and ? at the end of the prompt string.\n\ + /S Treat choice keys as case sensitive.\n\ + /T[:]c,nn Default choice to c after nn seconds.\n\ + text Prompt string to display.\n\n\ ERRORLEVEL is set to offset of key user presses in choices." STRING_CLS_HELP, "Clears the screen.\n\nCLS" @@ -79,48 +80,48 @@ STRING_CMD_HELP6," [directory stack]" STRING_CMD_HELP7," [redirections and piping]" -STRING_CMD_HELP8, "Starts a new instance of the ReactOS command line interpreter.\n\n \ -CMD [/[C|K] command][/P][/Q][/T:bf]\n\n \ - /C command Runs the specified command and terminates.\n \ - /K command Runs the specified command and remains.\n \ - /P CMD becomes permanent and runs autoexec.bat\n \ - (cannot be terminated).\n \ +STRING_CMD_HELP8, "Starts a new instance of the ReactOS command line interpreter.\n\n\ +CMD [/[C|K] command][/P][/Q][/T:bf]\n\n\ + /C command Runs the specified command and terminates.\n\ + /K command Runs the specified command and remains.\n\ + /P CMD becomes permanent and runs autoexec.bat\n\ + (cannot be terminated).\n\ /T:bf Sets the background/foreground color (see COLOR command)." -STRING_COLOR_HELP1, "Sets the default foreground and background colors.\n\n \ -COLOR [attr [/F]] \n\n \ - attr Specifies color attribute of console output\n \ - /F fill the console with color attribute\n\n \ -There are three ways to specify the colors:\n \ -1) [bright] name on [bright] name (only the first three letters are required)\n \ -2) decimal on decimal\n \ -3) two hex digits\n\n \ -Colors are:\n \ -dec hex name dec hex name\n \ -0 0 Black 8 8 Gray(Bright black)\n \ -1 1 Blue 9 9 Bright Blue\n \ -2 2 Green 10 A Bright Green\n \ -3 3 Cyan 11 B Bright Cyan\n \ -4 4 Red 12 C Bright Red\n \ -5 5 Magenta 13 D Bright Magenta\n \ -6 6 Yellow 14 E Bright Yellow\n \ +STRING_COLOR_HELP1, "Sets the default foreground and background colors.\n\n\ +COLOR [attr [/F]] \n\n\ + attr Specifies color attribute of console output\n\ + /F fill the console with color attribute\n\n\ +There are three ways to specify the colors:\n\ +1) [bright] name on [bright] name (only the first three letters are required)\n\ +2) decimal on decimal\n\ +3) two hex digits\n\n\ +Colors are:\n\ +dec hex name dec hex name\n\ +0 0 Black 8 8 Gray(Bright black)\n\ +1 1 Blue 9 9 Bright Blue\n\ +2 2 Green 10 A Bright Green\n\ +3 3 Cyan 11 B Bright Cyan\n\ +4 4 Red 12 C Bright Red\n\ +5 5 Magenta 13 D Bright Magenta\n\ +6 6 Yellow 14 E Bright Yellow\n\ 7 7 White 15 F Bright White" STRING_COPY_HELP1, "Overwrite %s (Yes/No/All)? " -STRING_COPY_HELP2, "Copies one or more files to another location.\n\n \ -COPY [/V][/Y|/-Y][/A|/B] source [/A|/B]\n \ - [+ source [/A|/B] [+ ...]] [destination [/A|/B]]\n\n \ - source Specifies the file or files to be copied.\n \ - /A Indicates an ASCII text file.\n \ - /B Indicates a binary file.\n \ - destination Specifies the directory and/or filename for the new file(s).\n \ - /V Verifies that new files are written correctly.\n \ - /Y Suppresses prompting to confirm you want to overwrite an\n \ - existing destination file.\n \ - /-Y Causes prompting to confirm you want to overwrite an\n \ - existing destination file.\n\n \ -The switch /Y may be present in the COPYCMD environment variable.\n \ +STRING_COPY_HELP2, "Copies one or more files to another location.\n\n\ +COPY [/V][/Y|/-Y][/A|/B] source [/A|/B]\n\ + [+ source [/A|/B] [+ ...]] [destination [/A|/B]]\n\n\ + source Specifies the file or files to be copied.\n\ + /A Indicates an ASCII text file.\n\ + /B Indicates a binary file.\n\ + destination Specifies the directory and/or filename for the new file(s).\n\ + /V Verifies that new files are written correctly.\n\ + /Y Suppresses prompting to confirm you want to overwrite an\n\ + existing destination file.\n\ + /-Y Causes prompting to confirm you want to overwrite an\n\ + existing destination file.\n\n\ +The switch /Y may be present in the COPYCMD environment variable.\n\ ..." STRING_DATE_HELP1, "\nEnter new date (mm%cdd%cyyyy): " @@ -129,67 +130,67 @@ STRING_DATE_HELP2, "\nEnter new date (dd%cmm%cyyyy): " STRING_DATE_HELP3, "\nEnter new date (yyyy%cmm%cdd): " -STRING_DATE_HELP4, "Displays or sets the date.\n\n \ -DATE [/T][date]\n\n \ - /T display only\n\n \ -Type DATE without parameters to display the current date setting and\n \ +STRING_DATE_HELP4, "Displays or sets the date.\n\n\ +DATE [/T][date]\n\n\ + /T display only\n\n\ +Type DATE without parameters to display the current date setting and\n\ a prompt for a new one. Press ENTER to keep the same date." -STRING_DEL_HELP1, "Deletes one or more files.\n\n \ -DEL [/%c /%c /%c /%c /%c /%c /%c] file ...\n \ -DELETE [/%c /%c /%c /%c /%c /%c /%c] file ...\n \ -ERASE [/%c /%c /%c /%c /%c /%c /%c] file ...\n\n \ - file Specifies the file(s) to delete.\n\n \ - /%c Nothing.\n \ - /%c Prompt. Ask before deleting each file.\n \ - /%c Total. Display total number of deleted files and freed disk space.\n \ - /%c Quiet.\n \ - /%c Wipe. Overwrite the file with random numbers before deleting it.\n \ - /%c Yes. Kill even *.* without asking.\n \ - /%c Zap. Delete hidden, read-only and system files).\n" +STRING_DEL_HELP1, "Deletes one or more files.\n\n\ +DEL [/N /P /T /Q /W /Y /Z] file ...\n\ +DELETE [/N /P /T /Q /W /Y /Z] file ...\n\ +ERASE [/N /P /T /Q /W /Y /Z] file ...\n\n\ + file Specifies the file(s) to delete.\n\n\ + /N Nothing.\n\ + /P Prompt. Ask before deleting each file.\n\ + /T Total. Display total number of deleted files and freed disk space.\n\ + /Q Quiet.\n\ + /W Wipe. Overwrite the file with random numbers before deleting it.\n\ + /Y Yes. Kill even *.* without asking.\n\ + /Z Zap. Delete hidden, read-only and system files.\n" STRING_DEL_HELP2, "All files in the directory will be deleted!\nAre you sure (Y/N)?" STRING_DEL_HELP3, " %lu file deleted\n" STRING_DEL_HELP4, " %lu files deleted\n" -STRING_DELAY_HELP, "pause for n seconds or milliseconds\n \ -DELAY [/m]n\n\n \ - /m specifiy than n are milliseconds\n \ +STRING_DELAY_HELP, "pause for n seconds or milliseconds\n\ +DELAY [/m]n\n\n\ + /m specifiy than n are milliseconds\n\ otherwise n are seconds" -STRING_DIR_HELP1, "DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]\n \ - [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]\n\n \ - [drive:][path][filename]\n \ - Specifies drive, directory, and/or files to list.\n\n \ - /A Displays files with specified attributes.\n \ - attributes D Directories R Read-only files\n \ - H Hidden files A Files ready for archiving\n \ - S System files - Prefix meaning not\n \ - /B Uses bare format (no heading information or summary).\n \ - /C Display the thousand separator in file sizes. This is the\n \ - default. Use /-C to disable display of separator.\n \ - /D Same as wide but files are list sorted by column.\n \ - /L Uses lowercase.\n \ - /N New long list format where filenames are on the far right.\n \ - /O List by files in sorted order.\n \ - sortorder N By name (alphabetic) S By size (smallest first)\n \ - E By extension (alphabetic) D By date/time (oldest first)\n \ - G Group directories first - Prefix to reverse order\n \ - /P Pauses after each screenful of information.\n \ - /Q Display the owner of the file.\n \ - /S Displays files in specified directory and all subdirectories.\n \ - /T Controls which time field displayed or used for sorting\n \ - timefield C Creation\n \ - A Last Access\n \ - W Last Written\n \ - /W Uses wide list format.\n \ - /X This displays the short names generated for non-8dot3 file\n \ - names. The format is that of /N with the short name inserted\n \ - before the long name. If no short name is present, blanks are\n \ - displayed in its place.\n \ - /4 Displays four-digit years\n\n \ -Switches may be preset in the DIRCMD environment variable. Override\n \ -preset switches by prefixing any switch with - (hyphen)--for example, /-W.\n " +STRING_DIR_HELP1, "DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]\n\ + [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]\n\n\ + [drive:][path][filename]\n\ + Specifies drive, directory, and/or files to list.\n\n\ + /A Displays files with specified attributes.\n\ + attributes D Directories R Read-only files\n\ + H Hidden files A Files ready for archiving\n\ + S System files - Prefix meaning not\n\ + /B Uses bare format (no heading information or summary).\n\ + /C Display the thousand separator in file sizes. This is the\n\ + default. Use /-C to disable display of separator.\n\ + /D Same as wide but files are list sorted by column.\n\ + /L Uses lowercase.\n\ + /N New long list format where filenames are on the far right.\n\ + /O List by files in sorted order.\n\ + sortorder N By name (alphabetic) S By size (smallest first)\n\ + E By extension (alphabetic) D By date/time (oldest first)\n\ + G Group directories first - Prefix to reverse order\n\ + /P Pauses after each screenful of information.\n\ + /Q Display the owner of the file.\n\ + /S Displays files in specified directory and all subdirectories.\n\ + /T Controls which time field displayed or used for sorting\n\ + timefield C Creation\n\ + A Last Access\n\ + W Last Written\n\ + /W Uses wide list format.\n\ + /X This displays the short names generated for non-8dot3 file\n\ + names. The format is that of /N with the short name inserted\n\ + before the long name. If no short name is present, blanks are\n\ + displayed in its place.\n\ + /4 Displays four-digit years\n\n\ +Switches may be preset in the DIRCMD environment variable. Override\n\ +preset switches by prefixing any switch with - (hyphen)--for example, /-W.\n" STRING_DIR_HELP2, " Volume in drive %c is %s" STRING_DIR_HELP3, " Volume in drive %c has no label" @@ -199,9 +200,9 @@ STRING_DIR_HELP6, "%16i Dir(s)% 15s bytes\n" STRING_DIR_HELP7, "\n Directory of %s\n\n" STRING_DIR_HELP8, "%16i Dir(s)% 14s bytes\n" -STRING_DIRSTACK_HELP1, "Stores the current directory for use by the POPD command, then\n \ -changes to the specified directory.\n\n \ -PUSHD [path | ..]\n\n \ +STRING_DIRSTACK_HELP1, "Stores the current directory for use by the POPD command, then\n\ +changes to the specified directory.\n\n\ +PUSHD [path | ..]\n\n\ path Specifies the directory to make the current directory" STRING_DIRSTACK_HELP2, "Changes to the directory stored by the PUSHD command.\n\nPOPD" @@ -210,61 +211,61 @@ STRING_DIRSTACK_HELP3, "Prints the contents of the directory stack.\n\nDIRS" STRING_DIRSTACK_HELP4, "Directory stack empty" -STRING_ECHO_HELP1, "Display a messages without trailing carridge return and line feed.\n\n \ +STRING_ECHO_HELP1, "Display a messages without trailing carridge return and line feed.\n\n\ ECHOS message" -STRING_ECHO_HELP2, "Displays a message to the standard error.\n\n \ - ECHOERR message\n \ +STRING_ECHO_HELP2, "Displays a message to the standard error.\n\n\ + ECHOERR message\n\ ECHOERR. prints an empty line" -STRING_ECHO_HELP3, "Prints a messages to standard error output without trailing carridge return and line feed.\n\n \ +STRING_ECHO_HELP3, "Prints a messages to standard error output without trailing carridge return and line feed.\n\n\ ECHOSERR message" -STRING_ECHO_HELP4, "Displays a message or switches command echoing on or off.\n\n \ - ECHO [ON | OFF]\n \ - ECHO [message]\n \ - ECHO. prints an empty line\n\n \ +STRING_ECHO_HELP4, "Displays a message or switches command echoing on or off.\n\n\ + ECHO [ON | OFF]\n\ + ECHO [message]\n\ + ECHO. prints an empty line\n\n\ Type ECHO without a parameter to display the current ECHO setting." STRING_ECHO_HELP5, "ECHO is %s\n" STRING_EXIT_HELP, "Exits the command line interpreter.\n\nEXIT" -STRING_FOR_HELP1, "Runs a specified command for each file in a set of files\n\n \ -FOR %variable IN (set) DO command [parameters]\n\n \ - %variable Specifies a replaceable parameter.\n \ - (set) Specifies a set of one or more files. Wildcards may be used.\n \ - command Specifies the command to carry out for each file.\n \ - parameters Specifies parameters or switches for the specified command.\n\n \ -To user the FOR comamnd in a batch program, specify %%variable instead of\n \ +STRING_FOR_HELP1, "Runs a specified command for each file in a set of files\n\n\ +FOR %variable IN (set) DO command [parameters]\n\n\ + %variable Specifies a replaceable parameter.\n\ + (set) Specifies a set of one or more files. Wildcards may be used.\n\ + command Specifies the command to carry out for each file.\n\ + parameters Specifies parameters or switches for the specified command.\n\n\ +To user the FOR comamnd in a batch program, specify %%variable instead of\n\ %variable." -STRING_FREE_HELP1, "\n Volume in drive %s is %-11s Serial number is %s\n \ - %16s bytes total disk space\n \ - %16s bytes used\n \ +STRING_FREE_HELP1, "\n Volume in drive %s is %-11s Serial number is %s\n\ + %16s bytes total disk space\n\ + %16s bytes used\n\ %16s bytes free\n" STRING_FREE_HELP2, "Displays drive information.\n\nFREE [drive: ...]" -STRING_IF_HELP1, "Performs conditional processing in batch programs.\n\n \ - IF [NOT] ERRORLEVEL number command\n \ - IF [NOT] string1==string2 command\n \ - IF [NOT] EXIST filename command\n \ - IF [NOT] DEFINED variable command\n\n \ -NOT Specifies that CMD should carry out the command only if\n \ - the condition is false\n \ -ERRORLEVEL number Specifies a true condition if the last program run returned\n \ - an exit code equal or greater than the number specified.\n \ -command Specifies the command to carry out if the condition is met.\n \ -string1==string2 Specifies a true condition if the specified text strings\n \ - match.\n \ -EXIST filename Specifies a true condition if the specified filename exists.\n \ -DEFINED variable Specifies a true condition if the specified variable is\n \ +STRING_IF_HELP1, "Performs conditional processing in batch programs.\n\n\ + IF [NOT] ERRORLEVEL number command\n\ + IF [NOT] string1==string2 command\n\ + IF [NOT] EXIST filename command\n\ + IF [NOT] DEFINED variable command\n\n\ +NOT Specifies that CMD should carry out the command only if\n\ + the condition is false\n\ +ERRORLEVEL number Specifies a true condition if the last program run returned\n\ + an exit code equal or greater than the number specified.\n\ +command Specifies the command to carry out if the condition is met.\n\ +string1==string2 Specifies a true condition if the specified text strings\n\ + match.\n\ +EXIST filename Specifies a true condition if the specified filename exists.\n\ +DEFINED variable Specifies a true condition if the specified variable is\n\ defined." - -STRING_GOTO_HELP1, "Directs CMD to a labeled line in a batch script.\n\n \ -GOTO label\n\n \ - label Specifies a text string used in a batch script as a label.\n\n \ + +STRING_GOTO_HELP1, "Directs CMD to a labeled line in a batch script.\n\n\ +GOTO label\n\n\ + label Specifies a text string used in a batch script as a label.\n\n\ You type a label on a line by itself, beginning with a colon." STRING_LABEL_HELP1, "Displays or changes drive label.\n\nLABEL [drive:][label]" @@ -276,74 +277,74 @@ STRING_LABEL_HELP5, "Drive label (11 Characters, ENTER if none)? " STRING_LOCALE_HELP1, "Current time is" -STRING_MKDIR_HELP, "Creates a directory.\n\n \ +STRING_MKDIR_HELP, "Creates a directory.\n\n\ MKDIR [drive:]path\nMD [drive:]path" STRING_MEMMORY_HELP1, "Displays the amount of system memory.\n\nMEMORY" -STRING_MEMMORY_HELP2, "\n %12s%% memory load.\n\n \ - %13s bytes total physical RAM.\n \ - %13s bytes available physical RAM.\n\n \ - %13s bytes total page file.\n \ - %13s bytes available page file.\n\n \ - %13s bytes total virtual memory.\n \ +STRING_MEMMORY_HELP2, "\n %12s%% memory load.\n\n\ + %13s bytes total physical RAM.\n\ + %13s bytes available physical RAM.\n\n\ + %13s bytes total page file.\n\ + %13s bytes available page file.\n\n\ + %13s bytes total virtual memory.\n\ %13s bytes available virtual memory.\n" STRING_MISC_HELP1, "Press a key to continue...\n" STRING_MOVE_HELP1, "Overwrite %s (Yes/No/All)? " -STRING_MOVE_HELP2, "Moves files and renames files and directories.\n\n \ -To move one or more files:\n \ -MOVE [/N][drive:][path]filename1[,...] destination\n\n \ -To rename a directory:\n \ -MOVE [/N][drive:][path]dirname1 dirname2\n\n \ - [drive:][path]filename1 Specifies the location and name of the file\n \ - or files you want to move.\n \ - /N Nothing. Don everthing but move files or direcories.\n\n \ -Current limitations:\n \ +STRING_MOVE_HELP2, "Moves files and renames files and directories.\n\n\ +To move one or more files:\n\ +MOVE [/N][drive:][path]filename1[,...] destination\n\n\ +To rename a directory:\n\ +MOVE [/N][drive:][path]dirname1 dirname2\n\n\ + [drive:][path]filename1 Specifies the location and name of the file\n\ + or files you want to move.\n\ + /N Nothing. Do everything but move files or direcories.\n\n\ +Current limitations:\n\ - You can't move a file or directory from one drive to another.\n" -STRING_MSGBOX_HELP, "display a message box and return user responce\n\n \ -MSGBOX type ['title'] prompt\n\n \ -type button displayed\n \ - possible values are: OK, OKCANCEL,\n \ - YESNO, YESNOCANCEL\n \ -title title of message box\n \ -prompt text displayed by the message box\n\n\n \ -ERRORLEVEL is set according the button pressed:\n\n \ -YES : 10 | NO : 11\n \ +STRING_MSGBOX_HELP, "display a message box and return user responce\n\n\ +MSGBOX type ['title'] prompt\n\n\ +type button displayed\n\ + possible values are: OK, OKCANCEL,\n\ + YESNO, YESNOCANCEL\n\ +title title of message box\n\ +prompt text displayed by the message box\n\n\n\ +ERRORLEVEL is set according the button pressed:\n\n\ +YES : 10 | NO : 11\n\ OK : 10 | CANCEL : 12\n" -STRING_PATH_HELP1, "Displays or sets a search path for executable files.\n\n \ -PATH [[drive:]path[;...]]\nPATH ;\n\n \ -Type PATH ; to clear all search-path settings and direct the command shell\n \ -to search only in the current directory.\n \ +STRING_PATH_HELP1, "Displays or sets a search path for executable files.\n\n\ +PATH [[drive:]path[;...]]\nPATH ;\n\n\ +Type PATH ; to clear all search-path settings and direct the command shell\n\ +to search only in the current directory.\n\ Type PATH without parameters to display the current path.\n" -STRING_PROMPT_HELP1, "Changes the command prompt.\n\n \ -PROMPT [text]\n\n \ - text Specifies a new command prompt.\n\n \ -Prompt can be made up of normal characters and the following special codes:\n\n \ - $A & (Ampersand)\n \ - $B | (pipe)\n \ - $C ( (Left parenthesis)\n \ - $D Current date\n \ - $E Escape code (ASCII code 27)\n \ - $F ) (Right parenthesis)\n \ - $G > (greater-than sign)\n \ - $H Backspace (erases previous character)\n \ - $L < (less-than sign)\n \ - $N Current drive\n \ - $P Current drive and path\n \ - $Q = (equal sign)\n \ - $T Current time\n \ - $V OS version number\n \ - $_ Carriage return and linefeed\n \ +STRING_PROMPT_HELP1, "Changes the command prompt.\n\n\ +PROMPT [text]\n\n\ + text Specifies a new command prompt.\n\n\ +Prompt can be made up of normal characters and the following special codes:\n\n\ + $A & (Ampersand)\n\ + $B | (pipe)\n\ + $C ( (Left parenthesis)\n\ + $D Current date\n\ + $E Escape code (ASCII code 27)\n\ + $F ) (Right parenthesis)\n\ + $G > (greater-than sign)\n\ + $H Backspace (erases previous character)\n\ + $L < (less-than sign)\n\ + $N Current drive\n\ + $P Current drive and path\n\ + $Q = (equal sign)\n\ + $T Current time\n\ + $V OS version number\n\ + $_ Carriage return and linefeed\n\ $$ $ (dollar sign)" -STRING_PAUSE_HELP1, "Stops the execution of a batch file and shows the following message:\n \ -'Press any key to continue...' or a user defined message.\n\n \ +STRING_PAUSE_HELP1, "Stops the execution of a batch file and shows the following message:\n\ +'Press any key to continue...' or a user defined message.\n\n\ PAUSE [message]" STRING_PROMPT_HELP2, " $+ Displays the current depth of the directory stack" @@ -352,53 +353,53 @@ STRING_PROMPT_HELP3, "\nType PROMPT without parameters to reset the prompt to th STRING_REM_HELP, "Starts a comment line in a batch file.\n\nREM [Comment]" -STRING_RMDIR_HELP, "Removes a directory.\n\n \ -RMDIR [drive:]path\nRD [drive:]path" +STRING_RMDIR_HELP, "Removes a directory.\n\n\ +RMDIR [drive:]path\nRD [drive:]path" -STRING_REN_HELP1, "Renames a file/directory or files/directories.\n\n \ -RENAME [/E /N /P /Q /S /T] old_name ... new_name\n \ -REN [/E /N /P /Q /S /T] old_name ... new_name\n\n \ - /E No eror messages.\n \ - /N Nothing.\n \ - /P Prompts for confirmation before renaming each file.\n \ - (Not implemented yet!)\n \ - /Q Quiet.\n \ - /S Rename subdirectories.\n \ - /T Display total number of renamed files.\n\n \ -Note that you cannot specify a new drive or path for your destination. Use\n \ +STRING_REN_HELP1, "Renames a file/directory or files/directories.\n\n\ +RENAME [/E /N /P /Q /S /T] old_name ... new_name\n\ +REN [/E /N /P /Q /S /T] old_name ... new_name\n\n\ + /E No eror messages.\n\ + /N Nothing.\n\ + /P Prompts for confirmation before renaming each file.\n\ + (Not implemented yet!)\n\ + /Q Quiet.\n\ + /S Rename subdirectories.\n\ + /T Display total number of renamed files.\n\n\ +Note that you cannot specify a new drive or path for your destination. Use\n\ the MOVE command for that purpose." STRING_REN_HELP2, " %lu file renamed\n" STRING_REN_HELP3, " %lu files renamed\n" -STRING_SHIFT_HELP, "Changes the position of replaceable parameters in a batch file.\n\n \ +STRING_SHIFT_HELP, "Changes the position of replaceable parameters in a batch file.\n\n\ SHIFT [DOWN]" -STRING_SCREEN_HELP, "move cursor and optionally print text\n\n \ -SCREEN row col [text]\n\n \ - row row to wich move the cursor\n \ +STRING_SCREEN_HELP, "move cursor and optionally print text\n\n\ +SCREEN row col [text]\n\n\ + row row to wich move the cursor\n\ col column to wich move the cursor" -STRING_SET_HELP, "Displays, sets, or removes environment variables.\n\n \ -SET [variable[=][string]]\n\n \ - variable Specifies the environment-variable name.\n \ - string Specifies a series of characters to assign to the variable.\n\n \ +STRING_SET_HELP, "Displays, sets, or removes environment variables.\n\n\ +SET [variable[=][string]]\n\n\ + variable Specifies the environment-variable name.\n\ + string Specifies a series of characters to assign to the variable.\n\n\ Type SET without parameters to display the current environment variables.\n" -STRING_START_HELP1, "Starts a command.\n\n \ -START command \n\n \ - command Specifies the command to run.\n\n \ +STRING_START_HELP1, "Starts a command.\n\n\ +START command\n\n\ + command Specifies the command to run.\n\n\ At the moment all commands are started asynchronously.\n" -STRING_TITLE_HELP, "Sets the window title for the command prompt window.\n\n \ -TITLE [string]\n\n \ +STRING_TITLE_HELP, "Sets the window title for the command prompt window.\n\n\ +TITLE [string]\n\n\ string Specifies the title for the command prompt window." -STRING_TIME_HELP1, "Displays or sets the system time.\n\n \ -TIME [/T][time]\n\n \ - /T display only\n\n \ -Type TIME with no parameters to display the current time setting and a prompt\n \ +STRING_TIME_HELP1, "Displays or sets the system time.\n\n\ +TIME [/T][time]\n\n\ + /T display only\n\n\ +Type TIME with no parameters to display the current time setting and a prompt\n\ for a new one. Press ENTER to keep the same time." STRING_TIME_HELP2, "Enter new time: " @@ -407,88 +408,88 @@ STRING_TIMER_HELP1, "Elapsed %d msecs\n" STRING_TIMER_HELP2, "Elapsed %02d%c%02d%c%02d%c%02d\n" -STRING_TIMER_HELP3, "allow the use of ten stopwaches.\n\n \ -TIMER [ON|OFF] [/S] [/n] [/Fn]\n\n \ - ON set stopwach ON\n \ - OFF set stopwach OFF\n \ - /S Split time. Return stopwach split\n \ - time without changing its value\n \ - /n Specifiy the stopwach number.\n \ - Stopwaches avaliable are 0 to 10\n \ - If it is not specified default is 1\n \ - /Fn Format for output\n \ - n can be:\n \ - 0 milliseconds\n \ - 1 hh%cmm%css%cdd\n\n \ -if none of ON, OFF or /S is specified the command\n \ +STRING_TIMER_HELP3, "allow the use of ten stopwaches.\n\n\ +TIMER [ON|OFF] [/S] [/n] [/Fn]\n\n\ + ON set stopwach ON\n\ + OFF set stopwach OFF\n\ + /S Split time. Return stopwach split\n\ + time without changing its value\n\ + /n Specifiy the stopwach number.\n\ + Stopwaches avaliable are 0 to 10\n\ + If it is not specified default is 1\n\ + /Fn Format for output\n\ + n can be:\n\ + 0 milliseconds\n\ + 1 hh%cmm%css%cdd\n\n\ +if none of ON, OFF or /S is specified the command\n\ will toggle stopwach state\n\n" - + STRING_TYPE_HELP1, "Displays the contents of text files.\n\nTYPE [drive:][path]filename" -STRING_VERIFY_HELP1, "This command is just a dummy!!\n \ -Sets whether to verify that your files are written correctly to a\n \ -disk.\n\n \ -VERIFY [ON | OFF]\n\n \ +STRING_VERIFY_HELP1, "This command is just a dummy!!\n\ +Sets whether to verify that your files are written correctly to a\n\ +disk.\n\n\ +VERIFY [ON | OFF]\n\n\ Type VERIFY without a parameter to display the current VERIFY setting." STRING_VERIFY_HELP2, "VERIFY is %s.\n" STRING_VERIFY_HELP3, "Must specify ON or OFF." -STRING_VERSION_HELP1, "Displays shell version information\n\n \ -VER [/C][/R][/W]\n\n \ - /C Displays credits.\n \ - /R Displays redistribution information.\n \ +STRING_VERSION_HELP1, "Displays shell version information\n\n\ +VER [/C][/R][/W]\n\n\ + /C Displays credits.\n\ + /R Displays redistribution information.\n\ /W Displays warranty information." -STRING_VERSION_HELP2, " comes with ABSOLUTELY NO WARRANTY; for details\n \ -type: `ver /w'. This is free software, and you are welcome to redistribute\n \ -it under certain conditions; type `ver /r' for details. Type `ver /c' for a\n \ +STRING_VERSION_HELP2, " comes with ABSOLUTELY NO WARRANTY; for details\n\ +type: `ver /w'. This is free software, and you are welcome to redistribute\n\ +it under certain conditions; type `ver /r' for details. Type `ver /c' for a\n\ listing of credits." -STRING_VERSION_HELP3, "\n This program is distributed in the hope that it will be useful,\n \ - but WITHOUT ANY WARRANTY; without even the implied warranty of\n \ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n \ +STRING_VERSION_HELP3, "\n This program is distributed in the hope that it will be useful,\n\ + but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ GNU General Public License for more details." - STRING_VERSION_HELP4, "\n This program is free software; you can redistribute it and/or modify\n \ - it under the terms of the GNU General Public License as published by\n \ - the Free Software Foundation; either version 2 of the License, or\n \ +STRING_VERSION_HELP4, "\n This program is free software; you can redistribute it and/or modify\n\ + it under the terms of the GNU General Public License as published by\n\ + the Free Software Foundation; either version 2 of the License, or\n\ (at your option) any later version." -STRING_VERSION_HELP5, "\nSend bug reports to .\n \ +STRING_VERSION_HELP5, "\nSend bug reports to .\n\ Updates are available at: http://www.reactos.com" -STRING_VERSION_HELP6, "FreeDOS version written by:\n%s\nReactOS version written by:\n%s\n" +STRING_VERSION_HELP6, "\nFreeDOS version written by:\n" + +STRING_VERSION_HELP7, "\nReactOS version written by:\n" STRING_VOL_HELP1, " Volume in drive %c: is %s" STRING_VOL_HELP2, " Volume in drive %c: has no label" STRING_VOL_HELP3, " Volume Serial Number is %04X-%04X\n" STRING_VOL_HELP4, "Displays the disk volume label and serial number, if they exist.\n\nVOL [drive:]" -STRING_WINDOW_HELP1, "change console window aspect\n\n \ -WINDOW [/POS[=]left,top,width,heigth]\n \ - [MIN|MAX|RESTORE] ['title']\n\n \ -/POS specify window placement and dimensions\n \ -MIN minimize the window\n \ -MAX maximize the window\n \ +STRING_WINDOW_HELP1, "change console window aspect\n\n\ +WINDOW [/POS[=]left,top,width,heigth]\n\ + [MIN|MAX|RESTORE] ['title']\n\n\ +/POS specify window placement and dimensions\n\ +MIN minimize the window\n\ +MAX maximize the window\n\ RESTORE restore the window" -STRING_WINDOW_HELP2, "change console window aspect\n\n \ -ACTIAVTE 'window' [/POS[=]left,top,width,heigth]\n \ - [MIN|MAX|RESTORE] ['title']\n\n \ -window tile of window on wich perform actions\n \ -/POS specify window placement and dimensions\n \ -MIN minimize the window\n \ -MAX maximize the window\n \ -RESTORE restore the window\n \ -title new title" +STRING_WINDOW_HELP2, "change console window aspect\n\n\ +ACTIAVTE 'window' [/POS[=]left,top,width,heigth]\n\ + [MIN|MAX|RESTORE] ['title']\n\n\ +window tile of window on wich perform actions\n\ +/POS specify window placement and dimensions\n\ +MIN minimize the window\n\ +MAX maximize the window\n\ +RESTORE restore the window\n\ +title new title" - STRING_CHOICE_OPTION, "YN" STRING_COPY_OPTION, "YNA" -STRING_DEL_OPTION, "AENPQSTWXYZ" STRING_ALIAS_ERROR, "Command line too long after alias expansion!\n" @@ -515,20 +516,15 @@ STRING_COPY_ERROR2, "Error: Can't copy onto itself!\n" STRING_COPY_ERROR3, "Error writing destination!\n" STRING_COPY_ERROR4, "Error: Not implemented yet!\n" STRING_DATE_ERROR, "Invalid date." -STRING_DEL_ERROR1, "Wildcards!\n\n" -STRING_DEL_ERROR2, "Full path: %s\n" -STRING_DEL_ERROR3, "File part: %s\n" -STRING_DEL_ERROR4, "Full filename: %s\n" STRING_DEL_ERROR5, "The file %s will be deleted! " STRING_DEL_ERROR6, "Are you sure (Y/N)?" STRING_DEL_ERROR7, "Deleting: %s\n" -STRING_DEL_ERROR8, "No Wildcards!\n" STRING_ERROR_ERROR1, "Unknown error! Error code: 0x%lx\n" STRING_ERROR_ERROR2, "Syntax error" STRING_FOR_ERROR1, "'in' missing in for statement." STRING_FOR_ERROR2, "no brackets found." STRING_FOR_ERROR3, "'do' missing." -STRING_FOR_ERROR4, "no command after 'do'." +STRING_FOR_ERROR4, "no command after 'do'." STRING_FREE_ERROR1, "Invalid drive" STRING_FREE_ERROR2, "unlabeled" STRING_GOTO_ERROR1, "No label specified for GOTO" @@ -552,18 +548,17 @@ STRING_TYPE_ERROR1, "Invalid option '/%s'\n" STRING_WINDOW_ERROR1, "window not found" -STRING_ERROR_PARAMETERF_ERROR, "Parameter format not correct - %c\n" +STRING_ERROR_PARAMETERF_ERROR, "Parameter format not correct - %c\n" STRING_ERROR_INVALID_SWITCH, "Invalid switch - /%c\n" STRING_ERROR_TOO_MANY_PARAMETERS, "Too many parameters - %s\n" -STRING_ERROR_PATH_NOT_FOUND, "Path not found\n" -STRING_ERROR_FILE_NOT_FOUND, "File not found\n" -STRING_ERROR_REQ_PARAM_MISSING, "Required parameter missing\n" -STRING_ERROR_INVALID_DRIVE, "Invalid drive specification\n" +STRING_ERROR_PATH_NOT_FOUND, "Path not found\n" +STRING_ERROR_FILE_NOT_FOUND, "File not found\n" +STRING_ERROR_REQ_PARAM_MISSING, "Required parameter missing\n" +STRING_ERROR_INVALID_DRIVE, "Invalid drive specification\n" STRING_ERROR_INVALID_PARAM_FORMAT, "Invalid parameter format - %s\n" -STRING_ERROR_BADCOMMAND, "Bad command or filename\n" -STRING_ERROR_OUT_OF_MEMORY, "Out of memory error.\n" -STRING_ERROR_CANNOTPIPE, "Error! Cannot pipe! Cannot open temporary file!\n" -STRING_ERROR_D_PAUSEMSG, "Press any key to continue . . ." -STRING_ERROR_DRIVER_NOT_READY "Drive not ready" - +STRING_ERROR_BADCOMMAND, "Bad command or filename\n" +STRING_ERROR_OUT_OF_MEMORY, "Out of memory error.\n" +STRING_ERROR_CANNOTPIPE, "Error! Cannot pipe! Cannot open temporary file!\n" +STRING_ERROR_D_PAUSEMSG, "Press any key to continue . . ." +STRING_ERROR_DRIVER_NOT_READY "Drive not ready" } diff --git a/reactos/subsys/system/cmd/alias.c b/reactos/subsys/system/cmd/alias.c index 00d71220cf8..8eb1695bf0f 100644 --- a/reactos/subsys/system/cmd/alias.c +++ b/reactos/subsys/system/cmd/alias.c @@ -281,8 +281,9 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen) m = _tcslen (ptr->lpSubst); if ((int)(_tcslen (cmd) - len + m - n) > maxlen) { - LoadString( GetModuleHandle(NULL), STRING_ALIAS_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_ALIAS_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); + /* the parser won't cause any problems with an empty line */ cmd[0] = _T('\0'); } @@ -305,13 +306,13 @@ VOID ExpandAlias (LPTSTR cmd, INT maxlen) INT CommandAlias (LPTSTR cmd, LPTSTR param) { - LPTSTR ptr; TCHAR szMsg[RC_STRING_MAX_SIZE]; + LPTSTR ptr; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_ALIAS_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_ALIAS_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/attrib.c b/reactos/subsys/system/cmd/attrib.c index e43742ad0e8..650a58a81d4 100644 --- a/reactos/subsys/system/cmd/attrib.c +++ b/reactos/subsys/system/cmd/attrib.c @@ -44,7 +44,7 @@ PrintAttribute (LPTSTR pszPath, LPTSTR pszFile, BOOL bRecurse) WIN32_FIND_DATA findData; HANDLE hFind; TCHAR szFullName[MAX_PATH]; - LPTSTR pszFileName; + LPTSTR pszFileName; /* prepare full file name buffer */ _tcscpy (szFullName, pszPath); @@ -112,7 +112,7 @@ PrintAttribute (LPTSTR pszPath, LPTSTR pszFile, BOOL bRecurse) static VOID ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask, - DWORD dwAttrib, BOOL bRecurse, BOOL bDirectories) + DWORD dwAttrib, BOOL bRecurse, BOOL bDirectories) { WIN32_FIND_DATA findData; HANDLE hFind; @@ -143,7 +143,7 @@ ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask, if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (!_tcscmp (findData.cFileName, _T(".")) || - !_tcscmp (findData.cFileName, _T(".."))) + !_tcscmp (findData.cFileName, _T(".."))) continue; _tcscpy (pszFileName, findData.cFileName); @@ -189,6 +189,7 @@ ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask, INT CommandAttrib (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR *arg; INT argc, i; TCHAR szPath[MAX_PATH]; @@ -197,7 +198,6 @@ INT CommandAttrib (LPTSTR cmd, LPTSTR param) BOOL bDirectories = FALSE; DWORD dwAttrib = 0; DWORD dwMask = 0; - TCHAR szMsg[RC_STRING_MAX_SIZE]; /* initialize strings */ szPath[0] = _T('\0'); @@ -206,8 +206,8 @@ INT CommandAttrib (LPTSTR cmd, LPTSTR param) /* print help */ if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_ATTRIB_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_ATTRIB_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -321,7 +321,7 @@ INT CommandAttrib (LPTSTR cmd, LPTSTR param) /* get full file name */ for (i = 0; i < argc; i++) { - if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/'))) + if ((*arg[i] != _T('+')) && (*arg[i] != _T('-')) && (*arg[i] != _T('/'))) { LPTSTR p; GetFullPathName (arg[i], MAX_PATH, szPath, NULL); @@ -333,7 +333,7 @@ INT CommandAttrib (LPTSTR cmd, LPTSTR param) PrintAttribute (szPath, szFileName, bRecurse); else ChangeAttribute (szPath, szFileName, dwMask, - dwAttrib, bRecurse, bDirectories); + dwAttrib, bRecurse, bDirectories); } } diff --git a/reactos/subsys/system/cmd/batch.c b/reactos/subsys/system/cmd/batch.c index 35e62e29d63..e2ad269bd89 100644 --- a/reactos/subsys/system/cmd/batch.c +++ b/reactos/subsys/system/cmd/batch.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * BATCH.C - batch file processor for CMD.EXE. * * @@ -218,12 +217,12 @@ VOID ExitBatch (LPTSTR msg) BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param) { - HANDLE hFile; TCHAR szMsg[RC_STRING_MAX_SIZE]; + HANDLE hFile; hFile = CreateFile (fullname, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_SEQUENTIAL_SCAN, NULL); + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | + FILE_FLAG_SEQUENTIAL_SCAN, NULL); #ifdef _DEBUG DebugPrintf (_T("Batch: (\'%s\', \'%s\', \'%s\') hFile = %x\n"), @@ -232,8 +231,8 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param) if (hFile == INVALID_HANDLE_VALUE) { - LoadString( GetModuleHandle(NULL), STRING_BATCH_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_BATCH_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); return FALSE; } diff --git a/reactos/subsys/system/cmd/beep.c b/reactos/subsys/system/cmd/beep.c index ad2f6a69a97..e14334e3aff 100644 --- a/reactos/subsys/system/cmd/beep.c +++ b/reactos/subsys/system/cmd/beep.c @@ -36,8 +36,8 @@ INT cmd_beep (LPTSTR cmd, LPTSTR param) if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_ALIAS_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts ((LPTSTR)szMsg); + LoadString(GetModuleHandle(NULL), STRING_ALIAS_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/call.c b/reactos/subsys/system/cmd/call.c index 19e4aa420a9..4429eb2471e 100644 --- a/reactos/subsys/system/cmd/call.c +++ b/reactos/subsys/system/cmd/call.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * CALL.C - call internal batch command. * * @@ -44,17 +43,16 @@ INT cmd_call (LPTSTR cmd, LPTSTR param) { - LPBATCH_CONTEXT n = NULL; TCHAR szMsg[RC_STRING_MAX_SIZE]; + LPBATCH_CONTEXT n = NULL; #ifdef _DEBUG DebugPrintf (_T("cmd_call: (\'%s\',\'%s\')\n"), cmd, param); #endif if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_CALL_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts ((LPTSTR)szMsg); - + LoadString(GetModuleHandle(NULL), STRING_CALL_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/chcp.c b/reactos/subsys/system/cmd/chcp.c index 3ec21082f1b..1b3e7a9b099 100644 --- a/reactos/subsys/system/cmd/chcp.c +++ b/reactos/subsys/system/cmd/chcp.c @@ -18,17 +18,17 @@ INT CommandChcp (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR *arg; INT args; UINT uOldCodePage; UINT uNewCodePage; - TCHAR szMsg[RC_STRING_MAX_SIZE]; /* print help */ if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_CHCP_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CHCP_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -38,39 +38,37 @@ INT CommandChcp (LPTSTR cmd, LPTSTR param) if (args == 0) { /* display active code page number */ - LoadString( GetModuleHandle(NULL), STRING_CHCP_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, GetConsoleCP ()); - + LoadString(GetModuleHandle(NULL), STRING_CHCP_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, GetConsoleCP()); return 0; } if (args >= 2) { /* too many parameters */ - LoadString( GetModuleHandle(NULL), STRING_CHCP_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, param); - + LoadString(GetModuleHandle(NULL), STRING_CHCP_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, param); return 1; } /* save old code page */ - uOldCodePage = GetConsoleCP (); + uOldCodePage = GetConsoleCP(); - uNewCodePage = (UINT)_ttoi (arg[0]); + uNewCodePage = (UINT)_ttoi(arg[0]); if (uNewCodePage == 0) { - LoadString( GetModuleHandle(NULL), STRING_CHCP_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, arg[0]); + LoadString(GetModuleHandle(NULL), STRING_CHCP_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, arg[0]); freep (arg); return 1; } - if (!SetConsoleCP (uNewCodePage)) + if (!SetConsoleCP(uNewCodePage)) { - LoadString( GetModuleHandle(NULL), STRING_CHCP_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CHCP_ERROR4, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } else { diff --git a/reactos/subsys/system/cmd/choice.c b/reactos/subsys/system/cmd/choice.c index 2ae006a3a3f..f2721861c35 100644 --- a/reactos/subsys/system/cmd/choice.c +++ b/reactos/subsys/system/cmd/choice.c @@ -103,6 +103,7 @@ IsKeyInString (LPTSTR lpString, TCHAR cKey, BOOL bCaseSensitive) INT CommandChoice (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR lpOptions; TCHAR Options[2]; LPTSTR lpText = NULL; @@ -121,16 +122,15 @@ CommandChoice (LPTSTR cmd, LPTSTR param) INT GCret; TCHAR Ch; DWORD amount,clk; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_CHOICE_OPTION, Options,sizeof(lpOptions)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_CHOICE_OPTION, Options, 2); lpOptions = Options; if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_CHOICE_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - return 0; + LoadString(GetModuleHandle(NULL), STRING_CHOICE_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); + return 0; } /* retrieve text */ @@ -169,9 +169,8 @@ CommandChoice (LPTSTR cmd, LPTSTR param) if (_tcslen (lpOptions) == 0) { - - LoadString( GetModuleHandle(NULL), STRING_CHOICE_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CHOICE_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); freep (arg); return 1; } @@ -201,8 +200,8 @@ CommandChoice (LPTSTR cmd, LPTSTR param) if (*s != _T(',')) { - LoadString( GetModuleHandle(NULL), STRING_CHOICE_ERROR_TXT, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CHOICE_ERROR_TXT, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); freep (arg); return 1; } @@ -213,8 +212,8 @@ CommandChoice (LPTSTR cmd, LPTSTR param) } else if (arg[i][0] == _T('/')) { - LoadString( GetModuleHandle(NULL), STRING_CHOICE_ERROR_OPTION, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, arg[i]); + LoadString(GetModuleHandle(NULL), STRING_CHOICE_ERROR_OPTION, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, arg[i]); freep (arg); return 1; } diff --git a/reactos/subsys/system/cmd/cls.c b/reactos/subsys/system/cmd/cls.c index 7c7418ec625..e96d33038a9 100644 --- a/reactos/subsys/system/cmd/cls.c +++ b/reactos/subsys/system/cmd/cls.c @@ -33,29 +33,29 @@ INT cmd_cls (LPTSTR cmd, LPTSTR param) { - DWORD dwWritten; + TCHAR szMsg[RC_STRING_MAX_SIZE]; CONSOLE_SCREEN_BUFFER_INFO csbi; COORD coPos; - TCHAR szMsg[RC_STRING_MAX_SIZE]; + DWORD dwWritten; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_CLS_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CLS_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } - GetConsoleScreenBufferInfo (hConsole, &csbi); + GetConsoleScreenBufferInfo(hConsole, &csbi); coPos.X = 0; coPos.Y = 0; - FillConsoleOutputAttribute (hConsole, wColor, - (csbi.dwSize.X)*(csbi.dwSize.Y), - coPos, &dwWritten); - FillConsoleOutputCharacter (hConsole, _T(' '), - (csbi.dwSize.X)*(csbi.dwSize.Y), - coPos, &dwWritten); - SetConsoleCursorPosition (hConsole, coPos); + FillConsoleOutputAttribute(hConsole, wColor, + csbi.dwSize.X * csbi.dwSize.Y, + coPos, &dwWritten); + FillConsoleOutputCharacter(hConsole, _T(' '), + csbi.dwSize.X * csbi.dwSize.Y, + coPos, &dwWritten); + SetConsoleCursorPosition(hConsole, coPos); bIgnoreEcho = TRUE; diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index be6d1b083d1..2399496e3f1 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * CMD.C - command-line interface. * * @@ -550,9 +549,9 @@ DoCommand (LPTSTR line) VOID ParseCommandLine (LPTSTR cmd) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR cmdline[CMDLINE_LENGTH]; LPTSTR s; - TCHAR szMsg[RC_STRING_MAX_SIZE]; #ifdef FEATURE_REDIRECTION TCHAR in[CMDLINE_LENGTH] = _T(""); TCHAR out[CMDLINE_LENGTH] = _T(""); @@ -634,15 +633,15 @@ VOID ParseCommandLine (LPTSTR cmd) FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, in); + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, in); return; } if (!SetStdHandle (STD_INPUT_HANDLE, hFile)) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, in); + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, in); return; } #ifdef _DEBUG @@ -664,13 +663,12 @@ VOID ParseCommandLine (LPTSTR cmd) /* Set current stdout to temporary file */ hFile[1] = CreateFile (szFileName[1], GENERIC_WRITE, 0, &sa, TRUNCATE_EXISTING, FILE_ATTRIBUTE_TEMPORARY, NULL); - - if (hFile[1] == INVALID_HANDLE_VALUE){ - - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); - return; - } + if (hFile[1] == INVALID_HANDLE_VALUE) + { + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); + return; + } SetStdHandle (STD_OUTPUT_HANDLE, hFile[1]); @@ -720,16 +718,15 @@ VOID ParseCommandLine (LPTSTR cmd) FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, out); - + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, out); return; } if (!SetStdHandle (STD_OUTPUT_HANDLE, hFile)) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, out); + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, out); return; } @@ -782,17 +779,16 @@ VOID ParseCommandLine (LPTSTR cmd) NULL); if (hFile == INVALID_HANDLE_VALUE) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, err); - + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, err); return; } } + if (!SetStdHandle (STD_ERROR_HANDLE, hFile)) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, err); - + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, err); return; } @@ -1079,35 +1075,35 @@ ShowCommands (VOID) TCHAR szMsg[RC_STRING_MAX_SIZE]; /* print command list */ - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg); - PrintCommandList (); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); + PrintCommandList(); /* print feature list */ - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #ifdef FEATURE_ALIASES - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif #ifdef FEATURE_HISTORY - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif #ifdef FEATURE_UNIX_FILENAME_COMPLETION - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP5, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif #ifdef FEATURE_DIRECTORY_STACK - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP6, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP6, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif #ifdef FEATURE_REDIRECTION - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP7, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP7, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif - ConOutChar (_T('\n')); + ConOutChar(_T('\n')); } #endif @@ -1121,10 +1117,10 @@ ShowCommands (VOID) static VOID Initialize (int argc, TCHAR* argv[]) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR commandline[CMDLINE_LENGTH]; TCHAR ModuleName[_MAX_PATH + 1]; INT i; - TCHAR szMsg[RC_STRING_MAX_SIZE]; //INT len; //TCHAR *ptr, *cmdLine; @@ -1154,9 +1150,9 @@ Initialize (int argc, TCHAR* argv[]) if (argc >= 2 && !_tcsncmp (argv[1], _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_CMD_HELP8, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - ExitProcess (0); + LoadString(GetModuleHandle(NULL), STRING_CMD_HELP8, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); + ExitProcess(0); } SetConsoleMode (hIn, ENABLE_PROCESSED_INPUT); @@ -1259,8 +1255,8 @@ Initialize (int argc, TCHAR* argv[]) if (IsExistingFile (_T("commandline"))) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, commandline); + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR4, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, commandline); ParseCommandLine (commandline); } } @@ -1296,15 +1292,15 @@ static VOID Cleanup (int argc, TCHAR *argv[]) /* run cmdexit.bat */ if (IsExistingFile (_T("cmdexit.bat"))) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR5, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); ParseCommandLine (_T("cmdexit.bat")); } else if (IsExistingFile (_T("\\cmdexit.bat"))) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR5, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf ((LPTSTR)szMsg); ParseCommandLine (_T("\\cmdexit.bat")); } #ifndef __REACTOS__ @@ -1320,8 +1316,8 @@ static VOID Cleanup (int argc, TCHAR *argv[]) if (IsExistingFile (_T("commandline"))) { - LoadString( GetModuleHandle(NULL), STRING_CMD_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, commandline); + LoadString(GetModuleHandle(NULL), STRING_CMD_ERROR4, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, commandline); ParseCommandLine (commandline); } } diff --git a/reactos/subsys/system/cmd/cmd.h b/reactos/subsys/system/cmd/cmd.h index 4beb8148198..5730d8a3f05 100644 --- a/reactos/subsys/system/cmd/cmd.h +++ b/reactos/subsys/system/cmd/cmd.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * CMD.H - header file for the modules in CMD.EXE * * @@ -170,7 +169,7 @@ VOID ConOutPrintf (LPTSTR, ...); VOID ConErrChar (TCHAR); VOID ConErrPuts (LPTSTR); VOID ConErrPrintf (LPTSTR, ...); -VOID ConOutFormatMessage (DWORD MessageId, ...); +VOID ConOutFormatMessage (DWORD MessageId, ...); SHORT GetCursorX (VOID); SHORT GetCursorY (VOID); diff --git a/reactos/subsys/system/cmd/cmd.rc b/reactos/subsys/system/cmd/cmd.rc index 3563a94ca95..1f886f12cb0 100644 --- a/reactos/subsys/system/cmd/cmd.rc +++ b/reactos/subsys/system/cmd/cmd.rc @@ -5,26 +5,25 @@ #define REACTOS_STR_INTERNAL_NAME "cmd\0" #define REACTOS_STR_ORIGINAL_FILENAME "cmd.exe\0" #define REACTOS_STR_ORIGINAL_COPYRIGHT "Copyright (C) 1994-1998 Tim Norman and others\0" -#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright (C) 1998-2001 Eric Kohl and others\0" +#define REACTOS_STR_LEGAL_COPYRIGHT "Copyright (C) 1998-2005 Eric Kohl and others\0" + #include #include "En.rc" + STRINGTABLE DISCARDABLE { - STRING_FreeDOS_DEV, " Tim Norman Matt Rains\n \ - Evan Jeffrey Steffen Kaiser\n \ - Svante Frey Oliver Mueller\n \ - Aaron Kaufman Marc Desrochers\n \ - Rob Lake John P Price\n \ + STRING_FREEDOS_DEV, " Tim Norman Matt Rains\n\ + Evan Jeffrey Steffen Kaiser\n\ + Svante Frey Oliver Mueller\n\ + Aaron Kaufman Marc Desrochers\n\ + Rob Lake John P Price\n\ Hans B Pufal\n" - STRING_REACTOS_DEV, " Eric Kohl Emanuele Aliberti\n \ + STRING_REACTOS_DEV, " Eric Kohl Emanuele Aliberti\n\ Paolo Pantaleo Phillip Susi\n" - } - - -1 ICON DISCARDABLE res/terminal.ico +1 ICON DISCARDABLE res/terminal.ico diff --git a/reactos/subsys/system/cmd/cmdinput.c b/reactos/subsys/system/cmd/cmdinput.c index daa5c71d602..ca704ad4bc6 100644 --- a/reactos/subsys/system/cmd/cmdinput.c +++ b/reactos/subsys/system/cmd/cmdinput.c @@ -332,7 +332,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen) { if (((charcount + orgx) / maxx) + orgy > maxy - 1) orgy += maxy - ((charcount + orgx) / maxx + orgy + 1); - } + } /* set cursor position */ SetCursorXY ((orgx + current) % maxx, diff --git a/reactos/subsys/system/cmd/color.c b/reactos/subsys/system/cmd/color.c index 446b967e4a8..716eb86e80d 100644 --- a/reactos/subsys/system/cmd/color.c +++ b/reactos/subsys/system/cmd/color.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * COLOR.C - color internal command. * * @@ -15,10 +14,10 @@ * Redirection ready! * * 14-Oct-1999 (Paolo Pantaleo ) - * 4nt's syntax implemented + * 4nt's syntax implemented. * * 03-Apr-2005 (Magnus Olsen) ) - * Remove all hardcode string to En.rc + * Move all hardcoded strings to En.rc. */ #include "precomp.h" @@ -30,9 +29,9 @@ static VOID ColorHelp (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_COLOR_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COLOR_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } @@ -45,24 +44,24 @@ VOID SetScreenColor (WORD wColor, BOOL bFill) if ((wColor & 0xF) == (wColor &0xF0) >> 4) { - LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COLOR_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); } - else + else { - if (bFill == TRUE) - { - GetConsoleScreenBufferInfo (hConsole, &csbi); + if (bFill == TRUE) + { + GetConsoleScreenBufferInfo (hConsole, &csbi); - coPos.X = 0; - coPos.Y = 0; - FillConsoleOutputAttribute (hConsole, - (WORD)(wColor & 0x00FF), - (csbi.dwSize.X)*(csbi.dwSize.Y), - coPos, - &dwWritten); - } - SetConsoleTextAttribute (hConsole, (WORD)(wColor & 0x00FF)); + coPos.X = 0; + coPos.Y = 0; + FillConsoleOutputAttribute (hConsole, + (WORD)(wColor & 0x00FF), + (csbi.dwSize.X)*(csbi.dwSize.Y), + coPos, + &dwWritten); + } + SetConsoleTextAttribute (hConsole, (WORD)(wColor & 0x00FF)); } } @@ -90,26 +89,26 @@ INT CommandColor (LPTSTR first, LPTSTR rest) return 0; } - if (StringToColor (&wColor, &rest) == FALSE) + if (StringToColor(&wColor, &rest) == FALSE) { - LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COLOR_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); return 1; } - LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, wColor); + LoadString(GetModuleHandle(NULL), STRING_COLOR_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, wColor); if ((wColor & 0xF) == (wColor &0xF0) >> 4) { - LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, wColor); + LoadString(GetModuleHandle(NULL), STRING_COLOR_ERROR4, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, wColor); return 1; } /* set color */ - SetScreenColor (wColor, - (_tcsstr (rest,_T("/F")) || _tcsstr (rest,_T("/f")))); + SetScreenColor(wColor, + (_tcsstr (rest,_T("/F")) || _tcsstr (rest,_T("/f")))); return 0; } diff --git a/reactos/subsys/system/cmd/console.c b/reactos/subsys/system/cmd/console.c index 4066e2b9b84..b9b31d63488 100644 --- a/reactos/subsys/system/cmd/console.c +++ b/reactos/subsys/system/cmd/console.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * CONSOLE.C - console input/output functions. * * @@ -211,11 +210,11 @@ VOID ConPrintf(LPTSTR szFormat, va_list arg_ptr, DWORD nStdHandle) VOID ConOutFormatMessage (DWORD MessageId, ...) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; DWORD ret; LPTSTR text; va_list arg_ptr; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - + va_start (arg_ptr, MessageId); ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -233,8 +232,8 @@ VOID ConOutFormatMessage (DWORD MessageId, ...) } else { - LoadString( GetModuleHandle(NULL), STRING_CONSOLE_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_CONSOLE_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } } diff --git a/reactos/subsys/system/cmd/copy.c b/reactos/subsys/system/cmd/copy.c index cf8b86065dc..01be1cfadf6 100644 --- a/reactos/subsys/system/cmd/copy.c +++ b/reactos/subsys/system/cmd/copy.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * COPY.C -- copy internal command. * * @@ -296,29 +295,26 @@ DeleteFileList (LPFILES f) static INT Overwrite (LPTSTR fn) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR inp[10]; LPTSTR p; - - LPTSTR lpOptions; - TCHAR Options[3]; - TCHAR szMsg[RC_STRING_MAX_SIZE]; + TCHAR szOptions[4]; - LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, Options,sizeof(Options)/sizeof(TCHAR)); - lpOptions = Options; + LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, szOptions, 4); - LoadString( GetModuleHandle(NULL), STRING_COPY_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COPY_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); - ConInString (inp, 10); - ConOutPuts (_T("")); + ConInString(inp, 10); + ConOutPuts(_T("")); _tcsupr (inp); for (p = inp; _istspace (*p); p++) ; - if (*p != lpOptions[0] && *p != lpOptions[2]) + if (*p != szOptions[0] && *p != szOptions[2]) return 0; - if (*p == lpOptions[2]) + if (*p == szOptions[2]) return 2; return 1; @@ -330,6 +326,7 @@ Overwrite (LPTSTR fn) int copy (LPTSTR source, LPTSTR dest, int append, LPDWORD lpdwFlags) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; FILETIME srctime; HANDLE hFileSrc; HANDLE hFileDest; @@ -339,7 +336,6 @@ int copy (LPTSTR source, LPTSTR dest, int append, LPDWORD lpdwFlags) DWORD dwWritten; DWORD i; BOOL bEof = FALSE; - TCHAR szMsg[RC_STRING_MAX_SIZE]; #ifdef _DEBUG DebugPrintf (_T("checking mode\n")); @@ -351,8 +347,8 @@ int copy (LPTSTR source, LPTSTR dest, int append, LPDWORD lpdwFlags) NULL, OPEN_EXISTING, 0, NULL); if (hFileSrc == INVALID_HANDLE_VALUE) { - LoadString( GetModuleHandle(NULL), STRING_COPY_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, source); + LoadString(GetModuleHandle(NULL), STRING_COPY_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, source); return 0; } @@ -379,8 +375,8 @@ int copy (LPTSTR source, LPTSTR dest, int append, LPDWORD lpdwFlags) { if (!_tcscmp (dest, source)) { - LoadString( GetModuleHandle(NULL), STRING_COPY_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, source); + LoadString(GetModuleHandle(NULL), STRING_COPY_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, source); CloseHandle (hFileSrc); return 0; @@ -456,8 +452,8 @@ int copy (LPTSTR source, LPTSTR dest, int append, LPDWORD lpdwFlags) if (dwWritten != dwRead) { - LoadString( GetModuleHandle(NULL), STRING_COPY_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COPY_ERROR3, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); free (buffer); CloseHandle (hFileDest); @@ -633,12 +629,12 @@ SetupCopy (LPFILES sources, TCHAR **p, BOOL bMultiple, INT cmd_copy (LPTSTR first, LPTSTR rest) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR **p; TCHAR drive_d[_MAX_DRIVE]; TCHAR dir_d[_MAX_DIR]; TCHAR file_d[_MAX_FNAME]; TCHAR ext_d[_MAX_EXT]; - TCHAR szMsg[RC_STRING_MAX_SIZE]; int argc; int append; @@ -655,8 +651,8 @@ INT cmd_copy (LPTSTR first, LPTSTR rest) if (!_tcsncmp (rest, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_COPY_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COPY_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 1; } @@ -728,8 +724,8 @@ INT cmd_copy (LPTSTR first, LPTSTR rest) } else if (bDestFound && bWildcards) { - LoadString( GetModuleHandle(NULL), STRING_COPY_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_COPY_ERROR4, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); DeleteFileList (sources); freep (p); diff --git a/reactos/subsys/system/cmd/date.c b/reactos/subsys/system/cmd/date.c index 739027ebabd..3bffcbdedd7 100644 --- a/reactos/subsys/system/cmd/date.c +++ b/reactos/subsys/system/cmd/date.c @@ -53,18 +53,18 @@ PrintDateString (VOID) { case 0: /* mmddyy */ default: - LoadString( GetModuleHandle(NULL), STRING_DATE_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, cDateSeparator, cDateSeparator); + LoadString(GetModuleHandle(NULL), STRING_DATE_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, cDateSeparator, cDateSeparator); break; case 1: /* ddmmyy */ - LoadString( GetModuleHandle(NULL), STRING_DATE_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, cDateSeparator, cDateSeparator); + LoadString(GetModuleHandle(NULL), STRING_DATE_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, cDateSeparator, cDateSeparator); break; case 2: /* yymmdd */ - LoadString( GetModuleHandle(NULL), STRING_DATE_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, cDateSeparator, cDateSeparator); + LoadString(GetModuleHandle(NULL), STRING_DATE_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, cDateSeparator, cDateSeparator); break; } } @@ -157,7 +157,7 @@ ParseDate (LPTSTR s) break; } - /* if only entered two digits: */ + /* if only entered two digits: */ /* assume 2000's if value less than 80 */ /* assume 1900's if value greater or equal 80 */ if (d.wYear <= 99) @@ -184,17 +184,17 @@ ParseDate (LPTSTR s) INT cmd_date (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR *arg; INT argc; INT i; BOOL bPrompt = TRUE; INT nDateString = -1; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_DATE_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts ((LPTSTR)szMsg); + LoadString(GetModuleHandle(NULL), STRING_DATE_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -247,14 +247,15 @@ INT cmd_date (LPTSTR cmd, LPTSTR param) freep (arg); return 0; } - LoadString( GetModuleHandle(NULL), STRING_DATE_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); - + + LoadString(GetModuleHandle(NULL), STRING_DATE_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); } freep (arg); return 0; } -#endif +#endif /* INCLUDE_CMD_DATE */ +/* EOF */ diff --git a/reactos/subsys/system/cmd/del.c b/reactos/subsys/system/cmd/del.c index dc431408f53..09cf6fc8ca0 100644 --- a/reactos/subsys/system/cmd/del.c +++ b/reactos/subsys/system/cmd/del.c @@ -96,6 +96,7 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags) INT CommandDelete (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szFullPath[MAX_PATH]; LPTSTR pFilePart; LPTSTR *arg = NULL; @@ -105,29 +106,14 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) INT nEvalArgs = 0; /* nunber of evaluated arguments */ DWORD dwFlags = 0; DWORD dwFiles = 0; - HANDLE hFile; WIN32_FIND_DATA f; - - LPTSTR lpOptions; - TCHAR Options[11]; - TCHAR szMsg[RC_STRING_MAX_SIZE]; LONG ch; - - - - LoadString( GetModuleHandle(NULL), STRING_DEL_OPTION, Options,sizeof(Options)/sizeof(TCHAR)); - lpOptions = Options; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_DEL_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, - lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10], - lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10], - lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10], - lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10] - ); + LoadString(GetModuleHandle(NULL), STRING_DEL_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); return 0; } @@ -142,49 +128,39 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) { if (_tcslen (arg[i]) >= 2) { - - ch = _totupper (arg[i][1]); - - if (_totupper (lpOptions[2]) == ch) - { - dwFlags |= DEL_NOTHING; - } - - else if (_totupper (lpOptions[3]) == ch) - { - dwFlags |= DEL_PROMPT; - } - - else if (_totupper (lpOptions[4]) == ch) - { - dwFlags |= DEL_QUIET; - } - - else if (_totupper (lpOptions[5]) == ch) - { - dwFlags |= DEL_SUBDIR; - } - - else if (_totupper (lpOptions[6]) == ch) - { - dwFlags |= DEL_TOTAL; - } - - else if (_totupper (lpOptions[7]) == ch) - { - dwFlags |= DEL_WIPE; - } - - else if (_totupper (lpOptions[9]) == ch) - { - dwFlags |= DEL_YES; - } - - else if (_totupper (lpOptions[10]) == ch) - { - dwFlags |= DEL_ZAP; - } - + ch = _totupper (arg[i][1]); + if (ch == _T('N')) + { + dwFlags |= DEL_NOTHING; + } + else if (ch == _T('P')) + { + dwFlags |= DEL_PROMPT; + } + else if (ch == _T('Q')) + { + dwFlags |= DEL_QUIET; + } + else if (ch == _T('S')) + { + dwFlags |= DEL_SUBDIR; + } + else if (ch == _T('T')) + { + dwFlags |= DEL_TOTAL; + } + else if (ch == _T('W')) + { + dwFlags |= DEL_WIPE; + } + else if (ch == _T('Y')) + { + dwFlags |= DEL_YES; + } + else if (ch == _T('Z')) + { + dwFlags |= DEL_ZAP; + } } nEvalArgs++; @@ -211,11 +187,9 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) { if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT))) { - - LoadString( GetModuleHandle(NULL), STRING_DEL_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString( GetModuleHandle(NULL), STRING_DEL_HELP2, szMsg, RC_STRING_MAX_SIZE); res = FilePromptYN (szMsg); - if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) break; } @@ -231,8 +205,7 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) { /* wildcards in filespec */ #ifdef _DEBUG - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf ((LPTSTR)szMsg); + ConErrPrintf(_T("Wildcards!\n\n")); #endif GetFullPathName (arg[i], @@ -241,12 +214,8 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) &pFilePart); #ifdef _DEBUG - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, szFullPath); - - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (pFilePart); - + ConErrPrintf(_T("Full path: %s\n"), szFullPath); + ConErrPrintf(_T("File part: %s\n"), pFilePart); #endif hFile = FindFirstFile (szFullPath, &f); @@ -268,18 +237,17 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) _tcscpy (pFilePart, f.cFileName); #ifdef _DEBUG - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); - + ConErrPrintf(_T("Full filename: %s\n"), szFullPath); #endif + /* ask for deleting */ if (dwFlags & DEL_PROMPT) - { - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szFullPath); + { + LoadString(GetModuleHandle(NULL), STRING_DEL_ERROR5, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, szFullPath); - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR6, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - res = FilePromptYN (szMsg); + LoadString(GetModuleHandle(NULL), STRING_DEL_ERROR6, szMsg, RC_STRING_MAX_SIZE); + res = FilePromptYN ((LPTSTR)szMsg); if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) { @@ -289,8 +257,8 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) { - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR7, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, szFullPath); + LoadString(GetModuleHandle(NULL), STRING_DEL_ERROR7, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, szFullPath); } /* delete the file */ @@ -334,22 +302,22 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) { /* no wildcards in filespec */ #ifdef _DEBUG - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR8, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + ConErrPrintf(_T("No Wildcards!\n")); #endif GetFullPathName (arg[i], MAX_PATH, szFullPath, &pFilePart); - /*ask for deleting */ - if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) //Don't ask if the file doesn't exist, the following code will make the error-msg + /* ask for deleting */ + // Don't ask if the file doesn't exist, the following code will make the error-msg + if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) { - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, szFullPath); - - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR6, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - res = FilePromptYN (szMsg); + LoadString(GetModuleHandle(NULL), STRING_DEL_ERROR5, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, szFullPath); + + LoadString(GetModuleHandle(NULL), STRING_DEL_ERROR6, szMsg, RC_STRING_MAX_SIZE); + res = FilePromptYN ((LPTSTR)szMsg); if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) { @@ -358,13 +326,12 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) } #ifdef _DEBUG - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, szFullPath); + ConErrPrintf(_T("Full path: %s\n"), szFullPath); #endif if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) { - LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR7, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, szFullPath); + LoadString(GetModuleHandle(NULL), STRING_DEL_ERROR7, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, szFullPath); } if (!(dwFlags & DEL_NOTHING)) @@ -417,14 +384,14 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param) { if (dwFiles < 2) { - LoadString( GetModuleHandle(NULL), STRING_DEL_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_DEL_HELP3, szMsg, RC_STRING_MAX_SIZE); } else { - LoadString( GetModuleHandle(NULL), STRING_DEL_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_DEL_HELP4, szMsg, RC_STRING_MAX_SIZE); } - - ConOutPrintf (szMsg, dwFiles); + + ConOutPrintf(szMsg, dwFiles); } return 0; diff --git a/reactos/subsys/system/cmd/delay.c b/reactos/subsys/system/cmd/delay.c index 8240e387599..00c2fe873b8 100644 --- a/reactos/subsys/system/cmd/delay.c +++ b/reactos/subsys/system/cmd/delay.c @@ -17,16 +17,15 @@ INT CommandDelay (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; DWORD val; DWORD mul=1000; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_DELAY_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - - return 0; + LoadString(GetModuleHandle(NULL), STRING_DELAY_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); + return 0; } if (*param==0) @@ -42,7 +41,7 @@ INT CommandDelay (LPTSTR cmd, LPTSTR param) } val = _ttoi(param); - Sleep(val*mul); + Sleep(val * mul); return 0; } diff --git a/reactos/subsys/system/cmd/dir.c b/reactos/subsys/system/cmd/dir.c index d960180e244..efab42b8dfc 100644 --- a/reactos/subsys/system/cmd/dir.c +++ b/reactos/subsys/system/cmd/dir.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * DIR.C - dir internal command. * * @@ -115,7 +114,7 @@ * dir /s now works in deeper trees * * 28-Jan-2004 (Michael Fritscher ) - * Fix for /p, so it is working under Windows in GUI-mode, too. + * Fix for /p, so it is working under Windows in GUI-mode, too. * * 30-Apr-2004 (Filip Navara ) * Fix /w to print long names. @@ -125,7 +124,7 @@ * the ros dir very similar to windows dir. Major part of * the code is rewritten. /p is removed, to be rewriten in * the main cmd code. - * + * */ #include "precomp.h" @@ -154,7 +153,7 @@ enum EOrderBy }; /* The struct for holding the switches */ -typedef struct TDirSwitchesFlags +typedef struct _DirSwitchesFlags { BOOL bBareFormat; /* Bare Format */ BOOL bTSeperator; /* Thousands seperator */ @@ -188,7 +187,15 @@ typedef struct TDirSwitchesFlags BOOL bUnSet; /* A helper flag if "-" was given with the switch */ BOOL bParSetted; /* A helper flag if parameters of switch were given */ } stTimeField; /* The time field to display or use for sorting */ -}DIRSWITCHFLAGS, * LPDIRSWITCHFLAGS; +} DIRSWITCHFLAGS, *LPDIRSWITCHFLAGS; + + +typedef struct _DIRFINDLISTNODE +{ + WIN32_FIND_DATA stFindInfo; + struct _DIRFINDLISTNODE *ptrNext; +} DIRFINDLISTNODE, *PDIRFINDLISTNODE; + typedef BOOL STDCALL (*PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); @@ -207,12 +214,11 @@ static ULARGE_INTEGER recurse_bytes; * displays help screen for dir * Rob Lake */ -static VOID - DirHelp (VOID) +static VOID DirHelp(VOID) { - TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + TCHAR szMsg[RC_STRING_MAX_SIZE]; + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } @@ -222,19 +228,18 @@ static VOID * * Parse the parameters and switches of the command line and exports them */ -static BOOL -DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ - LPTSTR *param, /* [OUT] The parameters after parsing */ - LPDIRSWITCHFLAGS lpFlags /* [IN/OUT] The flags after calculating switches */ - ) +static BOOL +DirReadParam(LPTSTR Line, /* [IN] The line with the parameters & switches */ + LPTSTR *param, /* [OUT] The parameters after parsing */ + LPDIRSWITCHFLAGS lpFlags) /* [IN/OUT] The flags after calculating switches */ { - TCHAR cCurSwitch; /* The current switch */ - TCHAR cCurChar; /* Current examing character */ - TCHAR cCurUChar; /* Current upper examing character */ - BOOL bNegative; /* Negative switch */ - BOOL bPNegative; /* Negative switch parameter */ - BOOL bIntoQuotes; /* A flag showing if we are in quotes (") */ - LPTSTR ptrLast; /* A pointer to the last character of param */ + TCHAR cCurSwitch; /* The current switch */ + TCHAR cCurChar; /* Current examing character */ + TCHAR cCurUChar; /* Current upper examing character */ + BOOL bNegative; /* Negative switch */ + BOOL bPNegative; /* Negative switch parameter */ + BOOL bIntoQuotes; /* A flag showing if we are in quotes (") */ + LPTSTR ptrLast; /* A pointer to the last character of param */ /* Initialize variables; */ cCurSwitch = _T(' '); @@ -255,18 +260,18 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ /* Main Loop (see README_DIR.txt) */ /* scan the command line char per char, and we process its char */ - while (*line) + while (*Line) { /* we save current character as it is and its upper case */ - cCurChar = *line; - cCurUChar = _toupper(*line); + cCurChar = *Line; + cCurUChar = _toupper(*Line); /* 1st section (see README_DIR.txt) */ /* When a switch is expecting */ if (cCurSwitch == _T('/')) { if ((cCurUChar == _T('A')) ||(cCurUChar == _T('T')) || (cCurUChar == _T('O'))) - { + { cCurSwitch = cCurUChar; switch (cCurUChar) { @@ -284,38 +289,40 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ break; } } - else if (cCurUChar == _T('L')) + else if (cCurUChar == _T('L')) lpFlags->bLowerCase = ! bNegative; - else if (cCurUChar == _T('B')) + else if (cCurUChar == _T('B')) lpFlags->bBareFormat = ! bNegative; - else if (cCurUChar == _T('C')) + else if (cCurUChar == _T('C')) lpFlags->bTSeperator = ! bNegative; - else if (cCurUChar == _T('W')) - lpFlags->bWideList = ! bNegative; - else if (cCurUChar == _T('D')) - lpFlags->bWideListColSort = ! bNegative; - else if (cCurUChar == _T('N')) + else if (cCurUChar == _T('W')) + lpFlags->bWideList = ! bNegative; + else if (cCurUChar == _T('D')) + lpFlags->bWideListColSort = ! bNegative; + else if (cCurUChar == _T('N')) lpFlags->bNewLongList = ! bNegative; - else if (cCurUChar == _T('P')) + else if (cCurUChar == _T('P')) lpFlags->bPause = ! bNegative; - else if (cCurUChar == _T('Q')) + else if (cCurUChar == _T('Q')) lpFlags->bUser = ! bNegative; - else if (cCurUChar == _T('S')) + else if (cCurUChar == _T('S')) lpFlags->bRecursive = ! bNegative; - else if (cCurUChar == _T('X')) + else if (cCurUChar == _T('X')) lpFlags->bShortName = ! bNegative; else if (cCurChar == _T('4')) lpFlags->b4Digit = ! bNegative; - else if (cCurChar == _T('?')) + else if (cCurChar == _T('?')) { DirHelp(); - return FALSE; + return FALSE; } else if (cCurChar == _T('-')) - bNegative = TRUE; - else { - error_invalid_switch ((TCHAR)_totupper (*line)); + bNegative = TRUE; + } + else + { + error_invalid_switch ((TCHAR)_totupper (*Line)); return FALSE; } @@ -328,10 +335,11 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ cCurSwitch = _T(' '); } - /* 2nd section (see README_DIR.txt) */ - /* We are expecting parameter or the unknown */ else if ((cCurSwitch == _T(' ')) || (cCurSwitch == _T('P'))) { + /* 2nd section (see README_DIR.txt) */ + /* We are expecting parameter or the unknown */ + if (cCurChar == _T('/')) cCurSwitch = _T('/'); @@ -342,34 +350,34 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ { cCurSwitch = _T(' '); if ((*param) && !(ptrLast)) - ptrLast = line; - } - + ptrLast = Line; + } + } - /* Process a quote */ else if (cCurChar == _T('\"')) { + /* Process a quote */ bIntoQuotes = !bIntoQuotes; - if (!bIntoQuotes) ptrLast = line; + if (!bIntoQuotes) ptrLast = Line; } - /* Process a character for parameter */ - else + else { + /* Process a character for parameter */ if ((cCurSwitch == _T(' ')) && (*param)) { - error_too_many_parameters(line); + error_too_many_parameters(Line); return FALSE; } cCurSwitch = _T('P'); if (!(*param)) - *param = line; + *param = Line; } - } - /* 3rd section (see README_DIR.txt) */ - /* We are waiting for switch parameters */ else { + /* 3rd section (see README_DIR.txt) */ + /* We are waiting for switch parameters */ + /* Check if there are no more switch parameters */ if ((cCurChar == _T('/')) || ( cCurChar == _T(' '))) { @@ -431,7 +439,7 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ } else { - error_parameter_format((TCHAR)_totupper (*line)); + error_parameter_format((TCHAR)_totupper (*Line)); return FALSE; } break; @@ -451,7 +459,7 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ lpFlags->stTimeField.eTimeField= TF_MODIFIEDDATE ; else { - error_parameter_format((TCHAR)_totupper (*line)); + error_parameter_format((TCHAR)_totupper (*Line)); return FALSE; } break; @@ -497,7 +505,7 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ else { - error_parameter_format((TCHAR)_totupper (*line)); + error_parameter_format((TCHAR)_totupper (*Line)); return FALSE; } @@ -508,7 +516,7 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ bPNegative = FALSE; } - line++; + Line++; } /* Terminate the parameters */ if (ptrLast) *ptrLast = 0; @@ -548,6 +556,7 @@ DirReadParam (LPTSTR line, /* [IN] The line with the parameters & switches */ return TRUE; } + /* * ExtendFilespec * @@ -691,7 +700,6 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec) } else { - *tmp = _T('\0'); /* change to this directory */ @@ -704,7 +712,8 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec) return 1; } } - /* get the full name of the directory */ + + /* get the full name of the directory */ if (!GetCurrentDirectory (MAX_PATH, szPath)) { *tmp = _T('\\'); @@ -726,32 +735,35 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec) * incline * * increment our line if paginating, display message at end of screen - *//*Maybe needed in future + */ +#if 0 static BOOL IncLine (LPINT pLine, LPDIRSWITCHFLAGS lpFlags) { - BOOL error; + BOOL bError; CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo; LONG WindowHeight; - error = GetConsoleScreenBufferInfo(hConsole, &lpConsoleScreenBufferInfo); - - WindowHeight= lpConsoleScreenBufferInfo.srWindow.Bottom - lpConsoleScreenBufferInfo.srWindow.Top; - //That prevents bad behave if WindowHeight couln't calc - if (!WindowHeight) + bError = GetConsoleScreenBufferInfo(hConsole, &lpConsoleScreenBufferInfo); + + WindowHeight = lpConsoleScreenBufferInfo.srWindow.Bottom - lpConsoleScreenBufferInfo.srWindow.Top; + + /* That prevents bad behiour if WindowHeight could not be calculated */ + if (!WindowHeight) { WindowHeight= 1000000; } + if (!(lpFlags->bPause)) return FALSE; (*pLine)++; - // Because I don't know if WindowsHeight - work under all cases, perhaps then maxy - is the right value - - if (*pLine >= (int)maxy - 2 || *pLine >= WindowHeight) + /* + * Because I don't know if WindowsHeight work in all cases, + * perhaps then maxy is the right value + */ + if (*pLine >= (int)maxy - 2 || *pLine >= WindowHeight) { *pLine = 0; return (PagePrompt () == PROMPT_BREAK); @@ -759,7 +771,7 @@ IncLine (LPINT pLine, LPDIRSWITCHFLAGS lpFlags) return FALSE; } -*/ +#endif /* * PrintDirectoryHeader @@ -767,16 +779,16 @@ IncLine (LPINT pLine, LPDIRSWITCHFLAGS lpFlags) * print the header for the dir command */ static BOOL -PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, LPDIRSWITCHFLAGS lpFlags) +PrintDirectoryHeader(LPTSTR szPath, LPINT pLine, LPDIRSWITCHFLAGS lpFlags) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szRootName[MAX_PATH]; TCHAR szVolName[80]; DWORD dwSerialNr; LPTSTR p; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (lpFlags->bBareFormat) - return(TRUE); + return TRUE; /* build usable root path */ if (szPath[1] == _T(':') && szPath[2] == _T('\\')) @@ -825,29 +837,24 @@ PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, LPDIRSWITCHFLAGS lpFlags) } /* print drive info */ - if (szVolName[0] != _T('\0')) - { - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, szRootName[0], szVolName); - } + { + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf((LPTSTR)szMsg, szRootName[0], szVolName); + } else - { - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, szRootName[0]); - } - - - + { + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, szRootName[0]); + } /* print the volume serial number if the return was successful */ - - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, - HIWORD(dwSerialNr), - LOWORD(dwSerialNr)); + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP4, (LPTSTR) szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf((LPTSTR)szMsg, + HIWORD(dwSerialNr), + LOWORD(dwSerialNr)); - return(TRUE); + return TRUE; } @@ -855,7 +862,9 @@ PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, LPDIRSWITCHFLAGS lpFlags) * convert * * insert commas into a number - *//* Maybe needed in future + * + */ +#if 0 static INT ConvertULong (ULONG num, LPTSTR des, INT len) { @@ -886,7 +895,7 @@ ConvertULong (ULONG num, LPTSTR des, INT len) return n; } -*/ +#endif static INT ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len, BOOL bPutSeperator) @@ -921,10 +930,10 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len, BOOL bPutSeperato static VOID -DirPrintFileDateTime (TCHAR * lpDate, - TCHAR * lpTime, - LPWIN32_FIND_DATA lpFile, - LPDIRSWITCHFLAGS lpFlags) +DirPrintFileDateTime(TCHAR *lpDate, + TCHAR *lpTime, + LPWIN32_FIND_DATA lpFile, + LPDIRSWITCHFLAGS lpFlags) { FILETIME ft; SYSTEMTIME dt; @@ -935,21 +944,23 @@ DirPrintFileDateTime (TCHAR * lpDate, /* Select the right time field */ switch (lpFlags->stTimeField.eTimeField) { - case TF_CREATIONDATE: - if (!FileTimeToLocalFileTime(&lpFile->ftCreationTime, &ft)) - return; - FileTimeToSystemTime(&ft, &dt); - break; - case TF_LASTACCESSEDDATE : - if (!FileTimeToLocalFileTime(&lpFile->ftLastAccessTime, &ft)) - return; - FileTimeToSystemTime(&ft, &dt); - break; - case TF_MODIFIEDDATE: - if (!FileTimeToLocalFileTime(&lpFile->ftLastWriteTime, &ft)) - return; - FileTimeToSystemTime(&ft, &dt); - break; + case TF_CREATIONDATE: + if (!FileTimeToLocalFileTime(&lpFile->ftCreationTime, &ft)) + return; + FileTimeToSystemTime(&ft, &dt); + break; + + case TF_LASTACCESSEDDATE : + if (!FileTimeToLocalFileTime(&lpFile->ftLastAccessTime, &ft)) + return; + FileTimeToSystemTime(&ft, &dt); + break; + + case TF_MODIFIEDDATE: + if (!FileTimeToLocalFileTime(&lpFile->ftLastWriteTime, &ft)) + return; + FileTimeToSystemTime(&ft, &dt); + break; } /* Format date */ @@ -958,7 +969,7 @@ DirPrintFileDateTime (TCHAR * lpDate, { case 0: /* mmddyy */ default: - _stprintf (szDate,_T("%02d%c%02d%c%0*d"), + _stprintf (szDate, _T("%02d%c%02d%c%0*d"), dt.wMonth, cDateSeparator, dt.wDay, cDateSeparator, lpFlags->b4Digit?4:2, wYear); @@ -984,7 +995,7 @@ DirPrintFileDateTime (TCHAR * lpDate, _stprintf (szTime,_T(" %02d%c%02u%c"), (dt.wHour == 0 ? 12 : (dt.wHour <= 12 ? dt.wHour : dt.wHour - 12)), cTimeSeparator, - dt.wMinute, (dt.wHour <= 11 ? 'a' : 'p')); + dt.wMinute, (dt.wHour <= 11 ? _T('a') : _T('p'))); break; case 1: /* 24 hour format */ @@ -1053,10 +1064,10 @@ PrintSummary(LPTSTR szPath, LPINT pLine, LPDIRSWITCHFLAGS lpFlags) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szBuffer[64]; ULARGE_INTEGER uliFree; TCHAR szRoot[] = _T("A:\\"); - TCHAR szMsg[RC_STRING_MAX_SIZE]; /* Here we check if we didn't find anything */ @@ -1065,6 +1076,7 @@ PrintSummary(LPTSTR szPath, error_file_not_found(); return 1; } + /* In bare format we don't print results */ if (lpFlags->bBareFormat) return 0; @@ -1072,20 +1084,20 @@ PrintSummary(LPTSTR szPath, /* Print recursive specific results */ if (lpFlags->bRecursive) { - ConvertULargeInteger (u64Bytes, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator); - - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg,ulFiles, szBuffer); + ConvertULargeInteger(u64Bytes, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator); + + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP5, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg,ulFiles, szBuffer); } /* Print total directories and freespace */ szRoot[0] = szPath[0]; GetUserDiskFreeSpace(szRoot, &uliFree); - ConvertULargeInteger (uliFree, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator); - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP6, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg,ulDirs, szBuffer); + ConvertULargeInteger(uliFree, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator); + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP6, (LPTSTR) szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf((LPTSTR)szMsg,ulDirs, szBuffer); - return 0; + return 0; } /* @@ -1096,8 +1108,8 @@ PrintSummary(LPTSTR szPath, TCHAR* getExt(const TCHAR* file) { - TCHAR* tmp = _tcsrchr(file,_T('.')); - return tmp?tmp+1:_T(""); + TCHAR* tmp = _tcsrchr(file, _T('.')); + return tmp?tmp+1:""; } /* @@ -1105,23 +1117,23 @@ TCHAR* getExt(const TCHAR* file) * * Get the name of the file without extension */ -TCHAR * getName(const TCHAR* file, TCHAR * dest) +static LPTSTR getName(const TCHAR* file, TCHAR * dest) { -int iLen; -TCHAR* end; - + int iLen; + LPTSTR end; + /* Check for "." and ".." folders */ - if ((_tcscmp(file, _T(".")) == 0) - || (_tcscmp(file, _T("..")) == 0)) + if ((_tcscmp(file, _T(".")) == 0) || + (_tcscmp(file, _T("..")) == 0)) { _tcscpy(dest,file); return dest; } - end = _tcsrchr(file,'.'); + end = _tcsrchr(file, _T('.')); if (!end) - iLen = _tcslen(file); - else + iLen = _tcslen(file); + else iLen = (end - file); @@ -1130,156 +1142,172 @@ TCHAR* end; return dest; } + + /* * DirPrintNewList * * The function that prints in new style */ -static int +static VOID DirPrintNewList(LPWIN32_FIND_DATA ptrFiles[], /* [IN]Files' Info */ - DWORD dwCount, /* [IN] The quantity of files */ - TCHAR * szCurPath, /* [IN] Full path of current directory */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ + DWORD dwCount, /* [IN] The quantity of files */ + TCHAR *szCurPath, /* [IN] Full path of current directory */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ { -DWORD i; /* An indexer for "for"s */ -TCHAR szSize[30]; /* The size of file */ -TCHAR szShortName[15]; /* The sort name */ -TCHAR szDate[20], szTime[20]; /* Date and time strings */ -int iSizeFormat; /* The format of size field */ -ULARGE_INTEGER u64FileSize; /* The file size */ + DWORD i; + TCHAR szSize[30]; + TCHAR szShortName[15]; + TCHAR szDate[20]; + TCHAR szTime[20]; + INT iSizeFormat; + ULARGE_INTEGER u64FileSize; - for(i = 0;i < dwCount;i++) - { + for (i = 0;i < dwCount;i++) + { + /* Calculate size */ + if (ptrFiles[i]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + /* Directory */ + iSizeFormat = -14; + _tcscpy(szSize, _T("")); + } + else + { + /* File */ + iSizeFormat = 14; + u64FileSize.HighPart = ptrFiles[i]->nFileSizeHigh; + u64FileSize.LowPart = ptrFiles[i]->nFileSizeLow; + ConvertULargeInteger(u64FileSize, szSize, 20, lpFlags->bTSeperator); + } - /* Calculate size */ - if (ptrFiles[i]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - /* Directory */ - { - iSizeFormat = -14; - _tcscpy(szSize, _T("")); - } - else - /* File */ - { - iSizeFormat = 14; - u64FileSize.HighPart = ptrFiles[i]->nFileSizeHigh; - u64FileSize.LowPart = ptrFiles[i]->nFileSizeLow; - ConvertULargeInteger(u64FileSize, szSize, 20,lpFlags->bTSeperator); - } - /* Calculate short name */ - szShortName[0] = _T('\0'); - if (lpFlags->bShortName) - _stprintf(szShortName,_T(" %-12s"), ptrFiles[i]->cAlternateFileName); - - /* Format date and time */ - DirPrintFileDateTime(szDate,szTime,ptrFiles[i],lpFlags); + /* Calculate short name */ + szShortName[0] = _T('\0'); + if (lpFlags->bShortName) + _stprintf(szShortName, _T(" %-12s"), ptrFiles[i]->cAlternateFileName); - /* Print the line */ - ConOutPrintf(_T("%10s %-8s %*s%s %s\n"), - szDate, - szTime, - iSizeFormat, - szSize, - szShortName, - ptrFiles[i]->cFileName ); - - } - return 0; + /* Format date and time */ + DirPrintFileDateTime(szDate, szTime, ptrFiles[i], lpFlags); + + /* Print the line */ + ConOutPrintf(_T("%10s %-8s %*s%s %s\n"), + szDate, + szTime, + iSizeFormat, + szSize, + szShortName, + ptrFiles[i]->cFileName); + } } + + /* * DirPrintWideList * * The function that prints in wide list */ -static int +static VOID DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */ - DWORD dwCount, /* [IN] The quantity of files */ - TCHAR * szCurPath, /* [IN] Full path of current directory */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ + DWORD dwCount, /* [IN] The quantity of files */ + TCHAR *szCurPath, /* [IN] Full path of current directory */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ { -DWORD i,j; /* An indexer for "for"s */ -short iScreenWidth; /* The screen width */ -short iColumns; /* The columns (used by wide list) */ -short iLines; /* The lines (used by the wide list /d) */ -int iBiggestName; /* The biggest name, used for wide list */ -TCHAR szTempFname[MAX_PATH]; /* Temporary string */ + USHORT iScreenWidth; + USHORT iColumns; + USHORT iLines; + INT iLongestName; + TCHAR szTempFname[MAX_PATH]; + DWORD i; + DWORD j; + DWORD temp; - /* Calculate biggest name */ - iBiggestName = 1; - for(i = 0;i < dwCount;i++) - { - if (ptrFiles[i]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - /* Directories need 2 additinal characters for brackets */ - if ((_tcslen(ptrFiles[i]->cFileName) + 2) > iBiggestName) - iBiggestName = _tcslen(ptrFiles[i]->cFileName) + 2; - } - else - { - if (_tcslen(ptrFiles[i]->cFileName) > iBiggestName) - iBiggestName = _tcslen(ptrFiles[i]->cFileName); - } - } - - /* Count the highest number of columns */ - GetScreenSize(&iScreenWidth, 0); - iColumns = iScreenWidth / iBiggestName; + /* Calculate longest name */ + iLongestName = 1; + for (i = 0; i < dwCount; i++) + { + if (ptrFiles[i]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + /* Directories need 2 additinal characters for brackets */ + if ((_tcslen(ptrFiles[i]->cFileName) + 2) > iLongestName) + iLongestName = _tcslen(ptrFiles[i]->cFileName) + 2; + } + else + { + if (_tcslen(ptrFiles[i]->cFileName) > iLongestName) + iLongestName = _tcslen(ptrFiles[i]->cFileName); + } + } - /* Check if there is enough space for spaces between names */ - if (((iBiggestName * iColumns) + iColumns) >= iScreenWidth) - iColumns --; - /* A last check at iColumns to avoid division by zero */ - if (!(iColumns)) iColumns = 1; + /* Count the highest number of columns */ + GetScreenSize(&iScreenWidth, 0); + iColumns = iScreenWidth / iLongestName; - /* Print Column sorted */ - if (lpFlags->bWideListColSort) - { - /* Calculate the lines that will be printed */ - iLines = ceil((float)dwCount/(float)iColumns); + /* Check if there is enough space for spaces between names */ + if (((iLongestName * iColumns) + iColumns) >= iScreenWidth) + iColumns --; - for (i = 0;i < iLines;i++) - { - for (j = 0;j < iColumns;j++) - { - DWORD temp = (j*iLines)+i; - if (temp >= dwCount) break; - if (ptrFiles[temp]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - _stprintf(szTempFname, _T("[%s]"), ptrFiles[temp]->cFileName); - else - _stprintf(szTempFname, _T("%s"), ptrFiles[temp]->cFileName); + /* A last check at iColumns to avoid division by zero */ + if (!(iColumns)) + iColumns = 1; - ConOutPrintf(_T("%-*s"),iBiggestName + 1 , szTempFname ); - } - ConOutPrintf(_T("\n")); - } - } - /* Print Line sorted */ - else - { - for (i = 0;i < dwCount;i++) - { - if (ptrFiles[i]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - _stprintf(szTempFname, _T("[%s]"), ptrFiles[i]->cFileName); - else - _stprintf(szTempFname, _T("%s"), ptrFiles[i]->cFileName); + /* Print Column sorted */ + if (lpFlags->bWideListColSort) + { + /* Calculate the lines that will be printed */ +// iLines = ceil((float)dwCount/(float)iColumns); + iLines = dwCount / iColumns; - ConOutPrintf(_T("%-*s"), iBiggestName + 1, szTempFname ); - /* We print a new line at the end of each column - except for the case that it is the last item.*/ - if (!((i+1)%iColumns) && (i < (dwCount-1))) - ConOutPrintf(_T("\n")); - } - /* Add a new line after the last item */ - ConOutPrintf(_T("\n")); - } - return 0; + for (i = 0;i < iLines;i++) + { + for (j = 0; j < iColumns; j++) + { + temp = (j * iLines) + i; + if (temp >= dwCount) + break; + + if (ptrFiles[temp]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + _stprintf(szTempFname, _T("[%s]"), ptrFiles[temp]->cFileName); + else + _stprintf(szTempFname, _T("%s"), ptrFiles[temp]->cFileName); + + ConOutPrintf(_T("%-*s"), iLongestName + 1 , szTempFname); + } + + ConOutPrintf(_T("\n")); + } + } + else + { + /* Print Line sorted */ + for (i = 0; i < dwCount; i++) + { + if (ptrFiles[i]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + _stprintf(szTempFname, _T("[%s]"), ptrFiles[i]->cFileName); + else + _stprintf(szTempFname, _T("%s"), ptrFiles[i]->cFileName); + + ConOutPrintf(_T("%-*s"), iLongestName + 1, szTempFname ); + + /* + * We print a new line at the end of each column + * except for the case that it is the last item. + */ + if (!((i + 1) % iColumns) && (i < (dwCount - 1))) + ConOutPrintf(_T("\n")); + } + + /* Add a new line after the last item */ + ConOutPrintf(_T("\n")); + } } + + /* * DirPrintOldList * * The function that prints in old style */ -static int +static VOID DirPrintOldList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */ DWORD dwCount, /* [IN] The quantity of files */ TCHAR * szCurPath, /* [IN] Full path of current directory */ @@ -1337,7 +1365,6 @@ ULARGE_INTEGER u64FileSize; /* The file size */ szDate, /* The date of file/dir */ szTime); /* The time of file/dir */ } - return 0; } /* @@ -1345,90 +1372,93 @@ ULARGE_INTEGER u64FileSize; /* The file size */ * * The function that prints in bare format */ -static int +static VOID DirPrintBareList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */ - DWORD dwCount, /* [IN] The quantity of files */ - TCHAR * szCurPath, /* [IN] Full path of current directory */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ + DWORD dwCount, /* [IN] The number of files */ + LPTSTR lpCurPath, /* [IN] Full path of current directory */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ { -DWORD i; /* An indexer for "for"s */ -TCHAR szFullName[MAX_PATH]; /* The fullpath name of file */ - - for(i = 0;i < dwCount;i++) + TCHAR szFullName[MAX_PATH]; + DWORD i; + + for (i = 0; i < dwCount; i++) { if ((_tcscmp(ptrFiles[i]->cFileName, _T(".")) == 0) || - (_tcscmp(ptrFiles[i]->cFileName, _T("..")) == 0)) + (_tcscmp(ptrFiles[i]->cFileName, _T("..")) == 0)) { - /* at bare format we don't print "." and ".." folder */ + /* at bare format we don't print "." and ".." folder */ continue; } - /* at recursive mode we print full path of file */ if (lpFlags->bRecursive) { - _tcscpy(szFullName, szCurPath); + /* at recursive mode we print full path of file */ + _tcscpy(szFullName, lpCurPath); _tcscat(szFullName, ptrFiles[i]->cFileName); - ConOutPrintf(_T("%s\n"), szFullName); + ConOutPrintf("%s\n", szFullName); } - /* if we are not in recursive mode we print the file names */ else - ConOutPrintf(_T("%s\n"),ptrFiles[i]->cFileName); + { + /* if we are not in recursive mode we print the file names */ + ConOutPrintf("%s\n",ptrFiles[i]->cFileName); + } } - return 0; } + /* * DirPrintFiles * * The functions that prints the files list */ -static int +static VOID DirPrintFiles(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */ - DWORD dwCount, /* [IN] The quantity of files */ - TCHAR * szCurPath, /* [IN] Full path of current directory */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ + DWORD dwCount, /* [IN] The quantity of files */ + TCHAR *szCurPath, /* [IN] Full path of current directory */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */ { -TCHAR szTemp[MAX_PATH]; /* A buffer to format the directory header */ -TCHAR szMsg[RC_STRING_MAX_SIZE]; + TCHAR szMsg[RC_STRING_MAX_SIZE]; + TCHAR szTemp[MAX_PATH]; /* A buffer to format the directory header */ /* Print directory header */ _tcscpy(szTemp, szCurPath); + /* We cut the trailing \ of the full path */ szTemp[_tcslen(szTemp)-1] = _T('\0'); + /* Condition to print header: We are not printing in bare format and if we are in recursive mode... we must have results */ if (!(lpFlags->bBareFormat ) && !((lpFlags->bRecursive) && (dwCount <= 0))) { - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP7, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, szTemp); + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP7, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, szTemp); } - /* Bare format */ if (lpFlags->bBareFormat) { + /* Bare format */ DirPrintBareList(ptrFiles, dwCount, szCurPath, lpFlags); } - /* New list style / Short names */ else if(lpFlags->bShortName) { + /* New list style / Short names */ DirPrintNewList(ptrFiles, dwCount, szCurPath, lpFlags); } - /* Wide list */ else if(lpFlags->bWideListColSort || lpFlags->bWideList) { + /* Wide list */ DirPrintWideList(ptrFiles, dwCount, szCurPath, lpFlags); } - /* New list style*/ else if (lpFlags->bNewLongList ) { + /* New list style*/ DirPrintNewList(ptrFiles, dwCount, szCurPath, lpFlags); } - /* If nothing is selected old list is the default */ else { + /* If nothing is selected old list is the default */ DirPrintOldList(ptrFiles, dwCount, szCurPath, lpFlags); } - return 0; } @@ -1438,16 +1468,15 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; * * Compares 2 files based on the order criteria */ -static int - CompareFiles( - LPWIN32_FIND_DATA lpFile1, /* [IN] A pointer to WIN32_FIND_DATA of file 1 */ - LPWIN32_FIND_DATA lpFile2, /* [IN] A pointer to WIN32_FIND_DATA of file 2 */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags that we use to list */ +static BOOL +CompareFiles(LPWIN32_FIND_DATA lpFile1, /* [IN] A pointer to WIN32_FIND_DATA of file 1 */ + LPWIN32_FIND_DATA lpFile2, /* [IN] A pointer to WIN32_FIND_DATA of file 2 */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags that we use to list */ { -/* u64 variables used to translate some broken 32bit info */ -ULARGE_INTEGER u64File1, u64File2; -int i; /* An indexer for "for"s */ -long iComp = 0; /* The comparison result */ + ULARGE_INTEGER u64File1; + ULARGE_INTEGER u64File2; + int i; + long iComp = 0; /* The comparison result */ /* Calculate critiries by order given from user */ for (i = 0;i < lpFlags->stOrderBy.sCriteriaCount;i++) @@ -1472,19 +1501,20 @@ long iComp = 0; /* The comparison result */ iComp = 0; break; - break; case ORDER_DIRECTORY: /* Order by directory attribute /o:g */ iComp = ((lpFile2->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)- (lpFile1->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); break; - case ORDER_EXTENSION: /* Order by extension name /o:e */ - iComp = _tcsicmp(getExt(lpFile1->cFileName),getExt(lpFile2->cFileName)); - break; - case ORDER_NAME: /* Order by filename /o:n */ - iComp = _tcsicmp(lpFile1->cFileName, lpFile2->cFileName); - break; - case ORDER_TIME: /* Order by file's time /o:t */ + case ORDER_EXTENSION: /* Order by extension name /o:e */ + iComp = _stricmp(getExt(lpFile1->cFileName),getExt(lpFile2->cFileName)); + break; + + case ORDER_NAME: /* Order by filename /o:n */ + iComp = _stricmp(lpFile1->cFileName, lpFile2->cFileName); + break; + + case ORDER_TIME: /* Order by file's time /o:t */ /* We compare files based on the time field selected by /t */ switch(lpFlags->stTimeField.eTimeField) { @@ -1520,13 +1550,14 @@ long iComp = 0; /* The comparison result */ iComp = 0; break; } + /* Reverse if desired */ if (lpFlags->stOrderBy.bCriteriaRev[i]) iComp *= -1; /* If that criteria was enough for distinguishing the files/dirs,there is no need to calculate the others*/ - if (iComp != 0) break; + if (iComp != 0) break; } /* Translate the value of iComp to boolean */ @@ -1541,21 +1572,21 @@ long iComp = 0; /* The comparison result */ * * Sort files by the order criterias using quicksort method */ -static void -QsortFiles( - LPWIN32_FIND_DATA ptrArray[], /* [IN/OUT] The array with file info pointers */ - int i, /* [IN] The index of first item in array */ - int j, /* [IN] The index to last item in array */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags that we will use to sort */ +static VOID +QsortFiles(LPWIN32_FIND_DATA ptrArray[], /* [IN/OUT] The array with file info pointers */ + int i, /* [IN] The index of first item in array */ + int j, /* [IN] The index to last item in array */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags that we will use to sort */ { -LPWIN32_FIND_DATA lpTemp; /* A temporary pointer */ - /* used for exchangin pointers */ -int First, Last, Temp; -BOOL Way; + LPWIN32_FIND_DATA lpTemp; /* A temporary pointer */ + int First, Last, Temp; + BOOL Way; if (i < j) { - First = i, Last = j, Way = TRUE; + First = i; + Last = j; + Way = TRUE; while (i != j) { if (Way == CompareFiles(ptrArray[i], ptrArray[j], lpFlags)) @@ -1564,13 +1595,18 @@ BOOL Way; lpTemp = ptrArray[i]; ptrArray[i]= ptrArray[j]; ptrArray[j] = lpTemp; - /* Swap the indexers for inverting sorting */ - Temp = i, i=j,j =Temp; + + /* Swap the indexes for inverting sorting */ + Temp = i; + i = j; + j =Temp; + Way = !Way; } - j += (!Way - Way); + j += (!Way - Way); } + QsortFiles(ptrArray,First, i-1, lpFlags); QsortFiles(ptrArray,i+1,Last, lpFlags); } @@ -1583,25 +1619,18 @@ BOOL Way; * * The functions that does everything except for printing results */ -static INT DirList (LPTSTR szPath, /* [IN] The path that dir starts */ - LPTSTR szFilespec, /* [IN] The type of file that we are looking for */ - LPINT pLine, /* FIXME: Maybe used for paginating */ - LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags of the listing */ +static INT +DirList(LPTSTR szPath, /* [IN] The path that dir starts */ + LPTSTR szFilespec, /* [IN] The type of file that we are looking for */ + LPINT pLine, /* FIXME: Maybe used for paginating */ + LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags of the listing */ { - -/* Internal linked list */ -struct TDirFindListNode - { - WIN32_FIND_DATA stFindInfo; - struct TDirFindListNode * ptrNext; -}; - -HANDLE hSearch; /* The handle of the search */ -HANDLE hRecSearch; /* The handle for searching recursivly */ -WIN32_FIND_DATA wfdFileInfo; /* The info of file that found */ -LPWIN32_FIND_DATA * ptrFileArray; /* An array of pointers with all the files */ -struct TDirFindListNode * ptrStartNode; /* The pointer to the first node */ -struct TDirFindListNode * ptrNextNode; /* A pointer used for relatives refernces */ + HANDLE hSearch; /* The handle of the search */ + HANDLE hRecSearch; /* The handle for searching recursivly */ + WIN32_FIND_DATA wfdFileInfo; /* The info of file that found */ + LPWIN32_FIND_DATA * ptrFileArray; /* An array of pointers with all the files */ + PDIRFINDLISTNODE ptrStartNode; /* The pointer to the first node */ + PDIRFINDLISTNODE ptrNextNode; /* A pointer used for relatives refernces */ TCHAR szFullPath[MAX_PATH]; /* The full path that we are listing with trailing \ */ TCHAR szFullFileSpec[MAX_PATH]; /* The full path with file specs that we ll request\ */ TCHAR szBytes[20]; /* A string for converting ULARGE integer */ @@ -1618,7 +1647,7 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; dwCount = 0; dwCountFiles = 0; dwCountDirs = 0; - u64CountBytes.QuadPart = 0; + u64CountBytes.QuadPart = 0; /* Create szFullPath and szFullFileSpec */ _tcscpy (szFullPath, szPath); @@ -1628,7 +1657,8 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; _tcscat (szFullFileSpec, szFilespec); /* Prepare the linked list, first node is allocated */ - if ((ptrStartNode = malloc(sizeof(struct TDirFindListNode))) == NULL) + ptrStartNode = malloc(sizeof(DIRFINDLISTNODE)); + if (ptrStartNode == NULL) { #ifdef _DEBUG ConErrPrintf("DEBUG: Cannot allocate memory for ptrStartNode!\n"); @@ -1638,7 +1668,7 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; ptrNextNode = ptrStartNode; /* Collect the results for the current folder */ - hSearch = FindFirstFile (szFullFileSpec, &wfdFileInfo); + hSearch = FindFirstFile(szFullFileSpec, &wfdFileInfo); do { if (hSearch != INVALID_HANDLE_VALUE) @@ -1647,15 +1677,31 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; if ((wfdFileInfo.dwFileAttributes & lpFlags->stAttribs.dwAttribMask ) == (lpFlags->stAttribs.dwAttribMask & lpFlags->stAttribs.dwAttribVal )) { - ptrNextNode->ptrNext = malloc(sizeof(struct TDirFindListNode)); + ptrNextNode->ptrNext = malloc(sizeof(DIRFINDLISTNODE)); + if (ptrNextNode->ptrNext == NULL) + { +#ifdef _DEBUG + ConErrPrintf("DEBUG: Cannot allocate memory for ptrNextNode->ptrNext!\n"); +#endif + while (ptrStartNode) + { + ptrNextNode = ptrStartNode->ptrNext; + free(ptrStartNode); + ptrStartNode = ptrNextNode; + dwCount --; + } + return 1; + } + /* If malloc fails we go to next file in hope it works, without braking the linked list! */ if (ptrNextNode->ptrNext) { /* Copy the info of search at linked list */ - memcpy((void *)&ptrNextNode->ptrNext->stFindInfo, - (void *)&wfdFileInfo,sizeof(WIN32_FIND_DATA)); - + memcpy(&ptrNextNode->ptrNext->stFindInfo, + &wfdFileInfo, + sizeof(WIN32_FIND_DATA)); + /* If lower case is selected do it here */ if (lpFlags->bLowerCase) { @@ -1676,37 +1722,45 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; else { /* File */ - dwCountFiles++; + dwCountFiles++; u64Temp.HighPart = wfdFileInfo.nFileSizeHigh; u64Temp.LowPart = wfdFileInfo.nFileSizeLow; u64CountBytes.QuadPart += u64Temp.QuadPart; - } + } } } - - } - }while(FindNextFile(hSearch,&wfdFileInfo)); + } + }while(FindNextFile(hSearch, &wfdFileInfo)); FindClose(hSearch); /* Terminate list */ ptrNextNode->ptrNext = NULL; /* Calculate and allocate space need for making an array of pointers */ - ptrFileArray = malloc(sizeof(LPWIN32_FIND_DATA)*dwCount); - if (!(ptrFileArray)) + ptrFileArray = malloc(sizeof(LPWIN32_FIND_DATA) * dwCount); + if (ptrFileArray == NULL) { #ifdef _DEBUG ConErrPrintf("DEBUG: Cannot allocate memory for ptrFileArray!\n"); #endif - goto _DirList_clear_n_exit; + while (ptrStartNode) + { + ptrNextNode = ptrStartNode->ptrNext; + free(ptrStartNode); + ptrStartNode = ptrNextNode; + dwCount --; + } + return 1; } - /* Create an array of pointers from the linked list - this will be used to sort and print data, rather than the list */ + /* + * Create an array of pointers from the linked list + * this will be used to sort and print data, rather than the list + */ ptrNextNode = ptrStartNode; dwCount = 0; - while(ptrNextNode->ptrNext) - { + while (ptrNextNode->ptrNext) + { *(ptrFileArray + dwCount) = &ptrNextNode->ptrNext->stFindInfo; ptrNextNode = ptrNextNode->ptrNext; dwCount++; @@ -1728,8 +1782,8 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!(lpFlags->bBareFormat) && (dwCount > 0)) { ConvertULargeInteger(u64CountBytes, szBytes, 20, lpFlags->bTSeperator); - LoadString( GetModuleHandle(NULL), STRING_DIR_HELP8, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg,dwCountFiles, szBytes); + LoadString(GetModuleHandle(NULL), STRING_DIR_HELP8, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg,dwCountFiles, szBytes); } /* Add statistics to recursive statistics*/ @@ -1751,9 +1805,9 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; if (hRecSearch != INVALID_HANDLE_VALUE) { /* We search for directories other than "." and ".." */ - if ((_tcsicmp(wfdFileInfo.cFileName, _T(".")) != 0) - && (_tcsicmp(wfdFileInfo.cFileName, _T("..")) != 0 ) - && (wfdFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + if ((_tcsicmp(wfdFileInfo.cFileName, _T(".")) != 0) && + (_tcsicmp(wfdFileInfo.cFileName, _T("..")) != 0 ) && + (wfdFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { /* Concat the path and the directory to do recursive */ _tcscpy(szFullFileSpec, szFullPath); @@ -1766,8 +1820,6 @@ TCHAR szMsg[RC_STRING_MAX_SIZE]; FindClose(hRecSearch); } -_DirList_clear_n_exit: -/* Deallocate memory */ /* Free linked list */ while (ptrStartNode) { @@ -1787,9 +1839,9 @@ _DirList_clear_n_exit: * * internal dir command */ -INT CommandDir (LPTSTR first, LPTSTR rest) +INT CommandDir(LPTSTR first, LPTSTR rest) { - TCHAR dircmd[256]; /* A variable to store the DIRCMD enviroment variable */ + TCHAR dircmd[256]; /* A variable to store the DIRCMD enviroment variable */ TCHAR szPath[MAX_PATH]; TCHAR szFilespec[MAX_PATH]; LPTSTR param; @@ -1822,9 +1874,9 @@ INT CommandDir (LPTSTR first, LPTSTR rest) stFlags.stOrderBy.bUnSet = FALSE; /* read the parameters from the DIRCMD environment variable */ - if (GetEnvironmentVariable (_T("DIRCMD"), dircmd, 256)) + if (GetEnvironmentVariable (_T("DIRCMD"), dircmd, 256)) if (!DirReadParam(dircmd, ¶m, &stFlags)) - return 1; + return 1; /* read the parameters */ if (!DirReadParam(rest, ¶m, &stFlags)) @@ -1869,7 +1921,7 @@ INT CommandDir (LPTSTR first, LPTSTR rest) if (DirList (szPath, szFilespec, &nLine, &stFlags)) return 1; - /* print the footer */ + /* print the footer */ PrintSummary(szPath, recurse_file_cnt, recurse_dir_cnt, diff --git a/reactos/subsys/system/cmd/dirstack.c b/reactos/subsys/system/cmd/dirstack.c index 9ed61a03c52..b34d5027999 100644 --- a/reactos/subsys/system/cmd/dirstack.c +++ b/reactos/subsys/system/cmd/dirstack.c @@ -137,16 +137,15 @@ INT GetDirectoryStackDepth (VOID) */ INT CommandPushd (LPTSTR first, LPTSTR rest) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR curPath[MAX_PATH]; TCHAR newPath[MAX_PATH]; BOOL bChangePath = FALSE; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (rest, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_DIRSTACK_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts ((LPTSTR)szMsg); - + LoadString(GetModuleHandle(NULL), STRING_DIRSTACK_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -172,14 +171,13 @@ INT CommandPushd (LPTSTR first, LPTSTR rest) */ INT CommandPopd (LPTSTR first, LPTSTR rest) { - TCHAR szPath[MAX_PATH]; TCHAR szMsg[RC_STRING_MAX_SIZE]; + TCHAR szPath[MAX_PATH]; if (!_tcsncmp(rest, _T("/?"), 2)) - { - LoadString( GetModuleHandle(NULL), STRING_DIRSTACK_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + { + LoadString(GetModuleHandle(NULL), STRING_DIRSTACK_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -200,14 +198,13 @@ INT CommandPopd (LPTSTR first, LPTSTR rest) */ INT CommandDirs (LPTSTR first, LPTSTR rest) { - LPDIRENTRY lpDir; TCHAR szMsg[RC_STRING_MAX_SIZE]; + LPDIRENTRY lpDir; if (!_tcsncmp(rest, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_DIRSTACK_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_DIRSTACK_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -216,9 +213,8 @@ INT CommandDirs (LPTSTR first, LPTSTR rest) if (lpDir == NULL) { - LoadString( GetModuleHandle(NULL), STRING_DIRSTACK_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_DIRSTACK_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/echo.c b/reactos/subsys/system/cmd/echo.c index c38687ebfd9..c1ecc5fbddb 100644 --- a/reactos/subsys/system/cmd/echo.c +++ b/reactos/subsys/system/cmd/echo.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * ECHO.C - internal echo commands. * * @@ -41,8 +40,8 @@ INT CommandEcho (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_ECHO_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_ECHO_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -61,15 +60,17 @@ INT CommandEcho (LPTSTR cmd, LPTSTR param) bEcho = TRUE; else if (*param) ConOutPuts (param); - else { - LoadString( GetModuleHandle(NULL), STRING_ECHO_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, bEcho ? D_ON : D_OFF); - } + else + { + LoadString(GetModuleHandle(NULL), STRING_ECHO_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, bEcho ? D_ON : D_OFF); + } } return 0; } + INT CommandEchos (LPTSTR cmd, LPTSTR param) { TCHAR szMsg[RC_STRING_MAX_SIZE]; @@ -80,9 +81,8 @@ INT CommandEchos (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_ECHO_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); - + LoadString(GetModuleHandle(NULL), STRING_ECHO_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -103,9 +103,8 @@ INT CommandEchoerr (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_ECHO_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts((LPTSTR)szMsg); - + LoadString(GetModuleHandle(NULL), STRING_ECHO_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -124,6 +123,7 @@ INT CommandEchoerr (LPTSTR cmd, LPTSTR param) return 0; } + INT CommandEchoserr (LPTSTR cmd, LPTSTR param) { TCHAR szMsg[RC_STRING_MAX_SIZE]; @@ -132,13 +132,10 @@ INT CommandEchoserr (LPTSTR cmd, LPTSTR param) DebugPrintf (_T("CommandEchoserr '%s' : '%s'\n"), cmd, param); #endif - - if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_ECHO_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); - + LoadString(GetModuleHandle(NULL), STRING_ECHO_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts((LPTSTR)szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/error.c b/reactos/subsys/system/cmd/error.c index 4529524f231..354e707cce3 100644 --- a/reactos/subsys/system/cmd/error.c +++ b/reactos/subsys/system/cmd/error.c @@ -42,12 +42,12 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szMessage[1024]; #ifndef __REACTOS__ LPTSTR szError; #endif va_list arg_ptr; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (dwErrorCode == ERROR_SUCCESS) return; @@ -71,8 +71,8 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...) } else { - LoadString( GetModuleHandle(NULL), STRING_ERROR_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, dwErrorCode); + LoadString(GetModuleHandle(NULL), STRING_ERROR_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, dwErrorCode); return; } @@ -80,21 +80,21 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...) switch (dwErrorCode) { - case ERROR_FILE_NOT_FOUND: - LoadString( GetModuleHandle(NULL), STRING_ERROR_FILE_NOT_FOUND, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + case ERROR_FILE_NOT_FOUND: + LoadString(GetModuleHandle(NULL), STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); break; case ERROR_PATH_NOT_FOUND: - LoadString( GetModuleHandle(NULL), STRING_ERROR_PATH_NOT_FOUND, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_ERROR_PATH_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); break; case ERROR_NOT_READY: - LoadString( GetModuleHandle(NULL), STRING_ERROR_DRIVER_NOT_READY, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_ERROR_DRIVER_NOT_READY, szMsg, RC_STRING_MAX_SIZE); break; default: - LoadString( GetModuleHandle(NULL), STRING_ERROR_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_ERROR_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); return; } @@ -108,107 +108,121 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...) VOID error_parameter_format(TCHAR ch) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_PARAMETERF_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, ch); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_PARAMETERF_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, ch); } VOID error_invalid_switch (TCHAR ch) -{ +{ TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_INVALID_SWITCH, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, ch); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_INVALID_SWITCH, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, ch); } VOID error_too_many_parameters (LPTSTR s) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_TOO_MANY_PARAMETERS, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, s); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_TOO_MANY_PARAMETERS, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, s); } VOID error_path_not_found (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_PATH_NOT_FOUND, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_PATH_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_file_not_found (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_FILE_NOT_FOUND, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf ((LPTSTR)szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_sfile_not_found (LPTSTR f) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_FILE_NOT_FOUND, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (_T("%s - %s\n"), szMsg,f); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(_T("%s - %s\n"), szMsg, f); } VOID error_req_param_missing (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_REQ_PARAM_MISSING, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_REQ_PARAM_MISSING, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_invalid_drive (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_INVALID_DRIVE, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_INVALID_DRIVE, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_bad_command (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_BADCOMMAND, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_BADCOMMAND, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_no_pipe (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_CANNOTPIPE, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_CANNOTPIPE, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_out_of_memory (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_OUT_OF_MEMORY, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_OUT_OF_MEMORY, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); } VOID error_invalid_parameter_format (LPTSTR s) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_INVALID_PARAM_FORMAT, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, s); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_INVALID_PARAM_FORMAT, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, s); } VOID error_syntax (LPTSTR s) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + + LoadString(GetModuleHandle(NULL), STRING_ERROR_ERROR2, szMsg, RC_STRING_MAX_SIZE); + if (s) - ConErrPrintf (_T("%s - %s\n"),szMsg, s); + ConErrPrintf(_T("%s - %s\n"), szMsg, s); else - ConErrPrintf (_T("%s.\n"), szMsg ); + ConErrPrintf(_T("%s.\n"), szMsg); } @@ -216,6 +230,8 @@ VOID msg_pause (VOID) { TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_ERROR_D_PAUSEMSG, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_ERROR_D_PAUSEMSG, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } + +/* EOF */ diff --git a/reactos/subsys/system/cmd/for.c b/reactos/subsys/system/cmd/for.c index 37ddeea26db..06f128fd11b 100644 --- a/reactos/subsys/system/cmd/for.c +++ b/reactos/subsys/system/cmd/for.c @@ -50,10 +50,10 @@ INT cmd_for (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPBATCH_CONTEXT lpNew; LPTSTR pp; TCHAR var; - TCHAR szMsg[RC_STRING_MAX_SIZE]; #ifdef _DEBUG DebugPrintf (_T("cmd_for (\'%s\', \'%s\'\n"), cmd, param); @@ -61,9 +61,8 @@ INT cmd_for (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_FOR_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts ((LPTSTR)szMsg); - + LoadString(GetModuleHandle(NULL), STRING_FOR_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -83,8 +82,8 @@ INT cmd_for (LPTSTR cmd, LPTSTR param) /* Check next element is 'IN' */ if ((_tcsnicmp (param, _T("in"), 2) != 0) || !_istspace (*(param + 2))) { - LoadString( GetModuleHandle(NULL), STRING_FOR_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - error_syntax (szMsg); + LoadString(GetModuleHandle(NULL), STRING_FOR_ERROR1, szMsg, RC_STRING_MAX_SIZE); + error_syntax(szMsg); return 1; } @@ -95,9 +94,8 @@ INT cmd_for (LPTSTR cmd, LPTSTR param) /* Folowed by a '(', find also matching ')' */ if ((*param != _T('(')) || (NULL == (pp = _tcsrchr (param, _T(')'))))) { - LoadString( GetModuleHandle(NULL), STRING_FOR_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - error_syntax (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_FOR_ERROR2, szMsg, RC_STRING_MAX_SIZE); + error_syntax(szMsg); return 1; } @@ -110,8 +108,8 @@ INT cmd_for (LPTSTR cmd, LPTSTR param) /* Check DO follows */ if ((_tcsnicmp (pp, _T("do"), 2) != 0) || !_istspace (*(pp + 2))) { - LoadString( GetModuleHandle(NULL), STRING_FOR_ERROR3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - error_syntax (szMsg); + LoadString(GetModuleHandle(NULL), STRING_FOR_ERROR3, szMsg, RC_STRING_MAX_SIZE); + error_syntax(szMsg); return 1; } @@ -122,9 +120,8 @@ INT cmd_for (LPTSTR cmd, LPTSTR param) /* Check that command tail is not empty */ if (*pp == _T('\0')) { - LoadString( GetModuleHandle(NULL), STRING_FOR_ERROR4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - error_syntax (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_FOR_ERROR4, szMsg, RC_STRING_MAX_SIZE); + error_syntax(szMsg); return 1; } diff --git a/reactos/subsys/system/cmd/free.c b/reactos/subsys/system/cmd/free.c index be1b3792a81..44cf613aadc 100644 --- a/reactos/subsys/system/cmd/free.c +++ b/reactos/subsys/system/cmd/free.c @@ -58,6 +58,7 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len) static VOID PrintDiskInfo (LPTSTR szDisk) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szRootPath[4] = _T("A:\\"); TCHAR szDrive[2] = _T("A"); TCHAR szVolume[64]; @@ -71,14 +72,11 @@ PrintDiskInfo (LPTSTR szDisk) DWORD dwBytPerSec; DWORD dwFreeCl; DWORD dwTotCl; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (_tcslen (szDisk) < 2 || szDisk[1] != _T(':')) { - - LoadString( GetModuleHandle(NULL), STRING_FREE_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); return; } @@ -88,16 +86,16 @@ PrintDiskInfo (LPTSTR szDisk) if (!GetVolumeInformation (szRootPath, szVolume, 64, &dwSerial, NULL, NULL, NULL, 0)) { - LoadString( GetModuleHandle(NULL), STRING_FREE_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (_T("%s %s:\n"),szMsg, szDrive); + LoadString(GetModuleHandle(NULL), STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive); return; } if (szVolume[0] == _T('\0')) { - LoadString( GetModuleHandle(NULL), STRING_FREE_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - _tcscpy (szVolume, szMsg); + LoadString(GetModuleHandle(NULL), STRING_FREE_ERROR2, szMsg, RC_STRING_MAX_SIZE); + _tcscpy (szVolume, szMsg); } _stprintf (szSerial, @@ -108,8 +106,8 @@ PrintDiskInfo (LPTSTR szDisk) if (!GetDiskFreeSpace (szRootPath, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl)) { - LoadString( GetModuleHandle(NULL), STRING_FREE_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (_T("%s %s:\n"),szMsg, szDrive); + LoadString(GetModuleHandle(NULL), STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf (_T("%s %s:\n"), szMsg, szDrive); return; } @@ -123,24 +121,23 @@ PrintDiskInfo (LPTSTR szDisk) ConvertULargeInteger (uliSize, szFree, 40); - LoadString( GetModuleHandle(NULL), STRING_FREE_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg,szDrive, szVolume, szSerial,szTotal, szUsed, szFree); + LoadString(GetModuleHandle(NULL), STRING_FREE_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, szDrive, szVolume, szSerial, szTotal, szUsed, szFree); } INT CommandFree (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR szParam; TCHAR szDefPath[MAX_PATH]; INT argc, i; LPTSTR *arg; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_FREE_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_FREE_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/goto.c b/reactos/subsys/system/cmd/goto.c index cfa2e48942d..c7ce8cbcf7a 100644 --- a/reactos/subsys/system/cmd/goto.c +++ b/reactos/subsys/system/cmd/goto.c @@ -39,9 +39,9 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR tmp; LONG lNewPosHigh; - TCHAR szMsg[RC_STRING_MAX_SIZE]; #ifdef _DEBUG DebugPrintf (_T("cmd_goto (\'%s\', \'%s\'\n"), cmd, param); @@ -49,9 +49,8 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_GOTO_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_GOTO_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -63,9 +62,8 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param) if (*param == _T('\0')) { - - LoadString( GetModuleHandle(NULL), STRING_GOTO_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ExitBatch (szMsg); + LoadString(GetModuleHandle(NULL), STRING_GOTO_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ExitBatch(szMsg); return 1; } @@ -97,9 +95,11 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param) return 0; } - LoadString( GetModuleHandle(NULL), STRING_GOTO_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg,param); - ExitBatch (NULL); + LoadString(GetModuleHandle(NULL), STRING_GOTO_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, param); + ExitBatch(NULL); return 1; } + +/* EOF */ diff --git a/reactos/subsys/system/cmd/history.c b/reactos/subsys/system/cmd/history.c index 345bb3fb2f6..9b7be8417d4 100644 --- a/reactos/subsys/system/cmd/history.c +++ b/reactos/subsys/system/cmd/history.c @@ -120,7 +120,7 @@ INT CommandHistory (LPTSTR cmd, LPTSTR param) } else { - for(h_tmp=Top->prev;h_tmp!=Bottom;h_tmp=h_tmp->prev) + for (h_tmp = Top->prev; h_tmp != Bottom; h_tmp = h_tmp->prev) ConErrPuts(h_tmp->string); } return 0; @@ -128,11 +128,9 @@ INT CommandHistory (LPTSTR cmd, LPTSTR param) VOID set_size(INT new_size) { - - while(new_sizeprev); - - + max_size=new_size; } @@ -140,19 +138,16 @@ VOID set_size(INT new_size) VOID InitHistory(VOID) { size=0; - - - Top = malloc(sizeof(HIST_ENTRY)); - Bottom = malloc(sizeof(HIST_ENTRY)); + Top = malloc(sizeof(HIST_ENTRY)); + Bottom = malloc(sizeof(HIST_ENTRY)); Top->prev = Bottom; Top->next = NULL; Top->string = NULL; - Bottom->prev = NULL; - Bottom->next = Top; + Bottom->next = Top; Bottom->string = NULL; curr_ptr=Bottom; @@ -163,49 +158,44 @@ VOID InitHistory(VOID) VOID CleanHistory(VOID) { - while (Bottom->next!=Top) del(Bottom->next); free(Top); free(Bottom); - } VOID History_del_current_entry(LPTSTR str) { LPHIST_ENTRY tmp; - - if (size==0) + + if (size == 0) return; - if(curr_ptr==Bottom) + if (curr_ptr == Bottom) curr_ptr=Bottom->next; - if(curr_ptr==Top) + if (curr_ptr == Top) curr_ptr=Top->prev; - tmp=curr_ptr; - curr_ptr=curr_ptr->prev; + tmp = curr_ptr; + curr_ptr = curr_ptr->prev; del(tmp); - History(-1,str); - + History(-1, str); } static VOID del(LPHIST_ENTRY item) { - - if( item==NULL || item==Top || item==Bottom ) + if (item==NULL || item==Top || item==Bottom) { #ifdef _DEBUG DebugPrintf(_T("del in " __FILE__ ": retrning\n" "item is 0x%08x (Bottom is0x%08x)\n"), - item, Bottom); - + item, Bottom); #endif return; } @@ -215,10 +205,6 @@ VOID del(LPHIST_ENTRY item) /*free string's mem*/ if (item->string) free(item->string); - - - - /*set links in prev and next item*/ item->next->prev=item->prev; @@ -227,17 +213,15 @@ VOID del(LPHIST_ENTRY item) free(item); size--; - } + #if 0 static VOID add_before_last(LPTSTR string) -{ - +{ LPHIST_ENTRY tmp,before,after; - /*delete first entry if maximum number of entries is reached*/ while(size>=max_size) del(Top->prev); @@ -248,14 +232,11 @@ VOID add_before_last(LPTSTR string) if (*string==_T('\0')) return; - - /*allocte entry and string*/ tmp=malloc(sizeof(HIST_ENTRY)); tmp->string=malloc((_tcslen(string)+1)*sizeof(TCHAR)); - _tcscpy(tmp->string,string); - - + _tcscpy(tmp->string,string); + /*set links*/ before=Bottom->next; after=before->next; @@ -266,12 +247,6 @@ VOID add_before_last(LPTSTR string) after->prev=tmp; before->next=tmp; - - - - - - /*set new size*/ size++; diff --git a/reactos/subsys/system/cmd/if.c b/reactos/subsys/system/cmd/if.c index ac0e49573ee..b0a235b15ee 100644 --- a/reactos/subsys/system/cmd/if.c +++ b/reactos/subsys/system/cmd/if.c @@ -39,9 +39,9 @@ INT cmd_if (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; INT x_flag = 0; /* when set cause 'then' clause to be executed */ LPTSTR pp; - TCHAR szMsg[RC_STRING_MAX_SIZE]; #ifdef _DEBUG DebugPrintf (_T("cmd_if: (\'%S\', \'%S\')\n"), cmd, param); @@ -49,7 +49,7 @@ INT cmd_if (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_IF_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_IF_HELP1, szMsg, RC_STRING_MAX_SIZE); ConOutPuts(szMsg); return 0; } @@ -90,10 +90,9 @@ INT cmd_if (LPTSTR cmd, LPTSTR param) else return 0; } - - /* Check for 'defined' form */ else if (!_tcsnicmp (param, _T("defined"), 7) && _istspace (*(param + 7))) { + /* Check for 'defined' form */ TCHAR Value [1]; INT ValueSize = 0; @@ -121,10 +120,9 @@ INT cmd_if (LPTSTR cmd, LPTSTR param) else return 0; } - - /* Check for 'errorlevel' form */ else if (!_tcsnicmp (param, _T("errorlevel"), 10) && _istspace (*(param + 10))) { + /* Check for 'errorlevel' form */ INT n = 0; pp = param + 10; @@ -138,14 +136,12 @@ INT cmd_if (LPTSTR cmd, LPTSTR param) x_flag |= X_EMPTY; /* Syntax error if comd empty */ } - - /* Check that '==' is present, syntax error if not */ else if (NULL == (pp = _tcsstr (param, _T("==")))) { + /* Check that '==' is present, syntax error if not */ error_syntax (NULL); return 1; } - else { /* Change first '='to space to terminate comparison loop */ @@ -193,3 +189,5 @@ INT cmd_if (LPTSTR cmd, LPTSTR param) return 0; } + +/* EOF */ diff --git a/reactos/subsys/system/cmd/internal.c b/reactos/subsys/system/cmd/internal.c index 3cb7471e66c..e6a27def6fa 100644 --- a/reactos/subsys/system/cmd/internal.c +++ b/reactos/subsys/system/cmd/internal.c @@ -154,19 +154,19 @@ VOID FreeLastPath (VOID) */ INT cmd_chdir (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR dir; /* pointer to the directory to change to */ LPTSTR lpOldPath; LPTSTR endofstring; /* pointer to the null character in the directory to change to */ LPTSTR lastquote; /* pointer to the last quotation mark in the directory to change to */ - TCHAR szMsg[RC_STRING_MAX_SIZE]; /*Should we better declare a variable containing _tsclen(dir) ? It's used a few times, but on the other hand paths are generally not very long*/ if (!_tcsncmp (param, _T("/?"), 2)) - { - LoadString(GetModuleHandle(NULL), STRING_CD_HELP, szMsg, sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + { + LoadString(GetModuleHandle(NULL), STRING_CD_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -190,10 +190,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) TCHAR szPath[MAX_PATH]; GetCurrentDirectory (MAX_PATH, szPath); - ConOutPuts (szPath); - - return 0; } @@ -275,17 +272,16 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param) */ INT cmd_mkdir (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR dir; /* pointer to the directory to change to */ LPTSTR place; /* used to search for the \ when no space is used */ LPTSTR *p = NULL; INT argc; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_MKDIR_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_MKDIR_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -320,8 +316,8 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param) if (!dir) { - LoadString( GetModuleHandle(NULL), STRING_PARAM_ERROR, szMsg, sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString( GetModuleHandle(NULL), STRING_PARAM_ERROR, (LPTSTR) szMsg,sizeof(szMsg)); + ConErrPrintf (_T((LPTSTR)szMsg)); return 1; } @@ -351,21 +347,17 @@ INT cmd_mkdir (LPTSTR cmd, LPTSTR param) */ INT cmd_rmdir (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR dir; /* pointer to the directory to change to */ LPTSTR place; /* used to search for the \ when no space is used */ LPTSTR *p = NULL; INT argc; - - TCHAR szMsg[RC_STRING_MAX_SIZE]; - if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_RMDIR_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_RMDIR_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -399,9 +391,8 @@ INT cmd_rmdir (LPTSTR cmd, LPTSTR param) if (!dir) { - LoadString( GetModuleHandle(NULL), STRING_PARAM_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_PARAM_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); return 1; } @@ -434,8 +425,8 @@ INT CommandExit (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_EXIT_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_EXIT_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -455,8 +446,8 @@ INT CommandRem (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_REM_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_REM_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } return 0; diff --git a/reactos/subsys/system/cmd/label.c b/reactos/subsys/system/cmd/label.c index 3b452215f17..d71b379888d 100644 --- a/reactos/subsys/system/cmd/label.c +++ b/reactos/subsys/system/cmd/label.c @@ -25,13 +25,13 @@ INT cmd_label (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szRootPath[] = _T("A:\\"); TCHAR szLabel[80]; TCHAR szOldLabel[80]; DWORD dwSerialNr; LPTSTR *arg; INT args; - TCHAR szMsg[RC_STRING_MAX_SIZE]; /* set empty label string */ szLabel[0] = _T('\0'); @@ -39,9 +39,8 @@ INT cmd_label (LPTSTR cmd, LPTSTR param) /* print help */ if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_LABEL_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_LABEL_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); return 0; } @@ -88,40 +87,40 @@ INT cmd_label (LPTSTR cmd, LPTSTR param) return 1; } - GetVolumeInformation (szRootPath, szOldLabel, 80, &dwSerialNr, - NULL, NULL, NULL, 0); + GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr, + NULL, NULL, NULL, 0); /* print drive info */ if (szOldLabel[0] != _T('\0')) { - LoadString( GetModuleHandle(NULL), STRING_LABEL_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, _totupper (szRootPath[0]), szOldLabel); + LoadString(GetModuleHandle(NULL), STRING_LABEL_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, _totupper(szRootPath[0]), szOldLabel); } else { - LoadString( GetModuleHandle(NULL), STRING_LABEL_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, _totupper (szRootPath[0])); + LoadString(GetModuleHandle(NULL), STRING_LABEL_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, _totupper(szRootPath[0])); } - - /* print the volume serial number */ - LoadString( GetModuleHandle(NULL), STRING_LABEL_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, HIWORD(dwSerialNr), LOWORD(dwSerialNr)); + LoadString(GetModuleHandle(NULL), STRING_LABEL_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, HIWORD(dwSerialNr), LOWORD(dwSerialNr)); if (szLabel[0] == _T('\0')) { - LoadString( GetModuleHandle(NULL), STRING_LABEL_HELP5, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg); - - ConInString (szLabel, 80); + LoadString(GetModuleHandle(NULL), STRING_LABEL_HELP5, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); + + ConInString(szLabel, 80); } - SetVolumeLabel (szRootPath, szLabel); + SetVolumeLabel(szRootPath, szLabel); - freep (arg); + freep(arg); return 0; } #endif /* INCLUDE_CMD_LABEL */ + +/* EOF */ diff --git a/reactos/subsys/system/cmd/locale.c b/reactos/subsys/system/cmd/locale.c index 3e3a67d88c6..cdd683d9a35 100644 --- a/reactos/subsys/system/cmd/locale.c +++ b/reactos/subsys/system/cmd/locale.c @@ -33,32 +33,24 @@ VOID InitLocale (VOID) /* date settings */ GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDATE, szBuffer, 256); -#if !defined(_UNICODE) && !defined(UNICODE) - CharToOem (szBuffer, szBuffer); -#endif + CharToOem (szBuffer, szBuffer); cDateSeparator = szBuffer[0]; GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDATE, szBuffer, 256); nDateFormat = _ttoi (szBuffer); /* time settings */ GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STIME, szBuffer, 256); -#if !defined(_UNICODE) && !defined(UNICODE) CharToOem (szBuffer, szBuffer); -#endif cTimeSeparator = szBuffer[0]; GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ITIME, szBuffer, 256); nTimeFormat = _ttoi (szBuffer); /* number settings */ GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szBuffer, 256); -#if !defined(_UNICODE) && !defined(UNICODE) CharToOem (szBuffer, szBuffer); -#endif cThousandSeparator = szBuffer[0]; GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szBuffer, 256); -#if !defined(_UNICODE) && !defined(UNICODE) CharToOem (szBuffer, szBuffer); -#endif cDecimalSeparator = szBuffer[0]; GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SGROUPING, szBuffer, 256); nNumberGroups = _ttoi (szBuffer); @@ -67,9 +59,7 @@ VOID InitLocale (VOID) for (i = 0; i < 7; i++) { GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1 + i, szBuffer, 256); -#if !defined(_UNICODE) && !defined(UNICODE) CharToOem (szBuffer, szBuffer); -#endif _tcscpy (aszDayNames[(i+1)%7], szBuffer); /* little hack */ } #endif @@ -93,11 +83,11 @@ VOID InitLocale (VOID) /* days of week */ for (i = 0; i < 7; i++) - _tcscpy (aszDayNames[i], names[i]); + _tcscpy(aszDayNames[i], names[i]); #endif #ifdef LOCALE_DEFAULT - LPTSTR names [7] = {_T("Sun"), _T("Mon"), _T("Tue"), _T("Wed"), _T("Thu"), _T("Fri"), _T("Sat")}; + LPTSTR names [7] = {_T("Sun"), _T("Mon"), _T("Tue"), _T("Wed"), _T("Thu"), _T("Fri"), _T("Sat")}; INT i; /* date settings */ @@ -131,63 +121,63 @@ VOID PrintDate (VOID) { case 0: /* mmddyy */ default: - ConOutPrintf (_T("%s %02d%c%02d%c%04d"), - aszDayNames[st.wDayOfWeek], st.wMonth, cDateSeparator, st.wDay, cDateSeparator, st.wYear); + ConOutPrintf(_T("%s %02d%c%02d%c%04d"), + aszDayNames[st.wDayOfWeek], st.wMonth, cDateSeparator, st.wDay, cDateSeparator, st.wYear); break; case 1: /* ddmmyy */ - ConOutPrintf (_T("%s %02d%c%02d%c%04d"), - aszDayNames[st.wDayOfWeek], st.wDay, cDateSeparator, st.wMonth, cDateSeparator, st.wYear); + ConOutPrintf(_T("%s %02d%c%02d%c%04d"), + aszDayNames[st.wDayOfWeek], st.wDay, cDateSeparator, st.wMonth, cDateSeparator, st.wYear); break; case 2: /* yymmdd */ - ConOutPrintf (_T("%s %04d%c%02d%c%02d"), - aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay); + ConOutPrintf(_T("%s %04d%c%02d%c%02d"), + aszDayNames[st.wDayOfWeek], st.wYear, cDateSeparator, st.wMonth, cDateSeparator, st.wDay); break; } #else TCHAR szDate[32]; - GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, - szDate, sizeof (szDate)); - ConOutPrintf (_T("%s"), szDate); + GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, + szDate, sizeof (szDate)); + ConOutPrintf(_T("%s"), szDate); #endif } VOID PrintTime (VOID) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; #ifdef __REACTOS__ SYSTEMTIME st; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - GetLocalTime (&st); + GetLocalTime(&st); - LoadString( GetModuleHandle(NULL), STRING_LOCALE_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_LOCALE_HELP1, szMsg, RC_STRING_MAX_SIZE); switch (nTimeFormat) { case 0: /* 12 hour format */ - default: - ConOutPrintf (_T("%s %2d%c%02d%c%02d%c%02d%c\n"),szMsg, - (st.wHour == 0 ? 12 : (st.wHour <= 12 ? st.wHour : st.wHour - 12)), - cTimeSeparator, st.wMinute, cTimeSeparator, st.wSecond, cDecimalSeparator, - st.wMilliseconds / 10, (st.wHour <= 11 ? 'a' : 'p')); + default: + ConOutPrintf(_T("%s %2d%c%02d%c%02d%c%02d%c\n"), szMsg, + (st.wHour == 0 ? 12 : (st.wHour <= 12 ? st.wHour : st.wHour - 12)), + cTimeSeparator, st.wMinute, cTimeSeparator, st.wSecond, cDecimalSeparator, + st.wMilliseconds / 10, (st.wHour <= 11 ? _T('a') : _T('p'))); break; case 1: /* 24 hour format */ - ConOutPrintf (_T("%s %2d%c%02d%c%02d%c%02d\n"),szMsg, - st.wHour, cTimeSeparator, st.wMinute, cTimeSeparator, - st.wSecond, cDecimalSeparator, st.wMilliseconds / 10); + ConOutPrintf(_T("%s %2d%c%02d%c%02d%c%02d\n"), szMsg, + st.wHour, cTimeSeparator, st.wMinute, cTimeSeparator, + st.wSecond, cDecimalSeparator, st.wMilliseconds / 10); break; } #else - TCHAR szTime[32]; + TCHAR szTime[32]; - GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL, NULL, - szTime, sizeof (szTime)); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, NULL, + szTime, sizeof(szTime)); - LoadString( GetModuleHandle(NULL), STRING_LOCALE_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (_T("%s: %s\n"),(LPTSTR)szMsg, szTime); + LoadString(GetModuleHandle(NULL), STRING_LOCALE_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(_T("%s: %s\n"), szMsg, szTime); #endif } diff --git a/reactos/subsys/system/cmd/memory.c b/reactos/subsys/system/cmd/memory.c index 0f37958932b..de821a05222 100644 --- a/reactos/subsys/system/cmd/memory.c +++ b/reactos/subsys/system/cmd/memory.c @@ -56,6 +56,7 @@ ConvertDWord (DWORD num, LPTSTR des, INT len, BOOL bSeparator) INT CommandMemory (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; MEMORYSTATUS ms; TCHAR szMemoryLoad[20]; TCHAR szTotalPhys[20]; @@ -64,12 +65,11 @@ INT CommandMemory (LPTSTR cmd, LPTSTR param) TCHAR szAvailPageFile[20]; TCHAR szTotalVirtual[20]; TCHAR szAvailVirtual[20]; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_MEMMORY_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_MEMMORY_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -85,10 +85,10 @@ INT CommandMemory (LPTSTR cmd, LPTSTR param) ConvertDWord (ms.dwTotalVirtual, szTotalVirtual, 20, TRUE); ConvertDWord (ms.dwAvailVirtual, szAvailVirtual, 20, TRUE); - LoadString( GetModuleHandle(NULL), STRING_MEMMORY_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, - szMemoryLoad, szTotalPhys, szAvailPhys, szTotalPageFile, - szAvailPageFile, szTotalVirtual, szAvailVirtual); + LoadString(GetModuleHandle(NULL), STRING_MEMMORY_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, + szMemoryLoad, szTotalPhys, szAvailPhys, szTotalPageFile, + szAvailPageFile, szTotalVirtual, szAvailVirtual); return 0; } diff --git a/reactos/subsys/system/cmd/misc.c b/reactos/subsys/system/cmd/misc.c index e91fe374d75..161dc4a6ed6 100644 --- a/reactos/subsys/system/cmd/misc.c +++ b/reactos/subsys/system/cmd/misc.c @@ -387,7 +387,7 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength) ReadFile (hFile, &ch, 1, &dwRead, NULL); break; } - lpString[len++] = ch; + lpString[len++] = ch; } if (!dwRead && !len) @@ -437,11 +437,11 @@ HWND GetConsoleWindow (VOID) INT PagePrompt (VOID) { - INPUT_RECORD ir; TCHAR szMsg[RC_STRING_MAX_SIZE]; + INPUT_RECORD ir; - LoadString( GetModuleHandle(NULL), STRING_MISC_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf(szMsg); + LoadString(GetModuleHandle(NULL), STRING_MISC_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); RemoveBreakHandler (); ConInDisable (); @@ -468,39 +468,35 @@ INT PagePrompt (VOID) INT FilePromptYN (LPTSTR szFormat, ...) { - TCHAR szOut[512]; - va_list arg_ptr; TCHAR szMsg[RC_STRING_MAX_SIZE]; + TCHAR szOut[512]; + va_list arg_ptr; +// TCHAR cKey = 0; +// LPTSTR szKeys = _T("yna"); -// TCHAR cKey = 0; -// LPTSTR szKeys = _T("yna"); - - TCHAR szIn[10]; + TCHAR szIn[10]; LPTSTR p; va_start (arg_ptr, szFormat); _vstprintf (szOut, szFormat, arg_ptr); va_end (arg_ptr); - ConOutPrintf (szFormat); + ConOutPrintf (szFormat); -/* preliminary fix */ - ConInString (szIn, 10); - ConOutPrintf (_T("\n")); + /* preliminary fix */ + ConInString (szIn, 10); + ConOutPrintf (_T("\n")); - _tcsupr (szIn); - for (p = szIn; _istspace (*p); p++); + _tcsupr (szIn); + for (p = szIn; _istspace (*p); p++) + ; - LoadString( GetModuleHandle(NULL), STRING_CHOICE_OPTION, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - + LoadString(GetModuleHandle(NULL), STRING_CHOICE_OPTION, szMsg, RC_STRING_MAX_SIZE); - - if (_tcsncmp(p,&szMsg[0],1)==0) - return PROMPT_YES; - else if (_tcsncmp(p,&szMsg[1],1)==0) - return PROMPT_NO; - - + if (_tcsncmp(p, &szMsg[0], 1) == 0) + return PROMPT_YES; + else if (_tcsncmp(p, &szMsg[1], 1) == 0) + return PROMPT_NO; #if 0 else if (*p == _T('\03')) return PROMPT_BREAK; @@ -509,7 +505,7 @@ INT FilePromptYN (LPTSTR szFormat, ...) return PROMPT_NO; -/* unfinished sollution */ + /* unfinished sollution */ #if 0 RemoveBreakHandler (); ConInDisable (); @@ -517,9 +513,9 @@ INT FilePromptYN (LPTSTR szFormat, ...) do { ConInKey (&ir); - cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar); - if (_tcschr (szKeys, cKey[0]) == NULL) - cKey = 0; + cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar); + if (_tcschr (szKeys, cKey[0]) == NULL) + cKey = 0; } @@ -542,38 +538,37 @@ INT FilePromptYN (LPTSTR szFormat, ...) INT FilePromptYNA (LPTSTR szFormat, ...) { - TCHAR szOut[512]; - va_list arg_ptr; -// TCHAR cKey = 0; -// LPTSTR szKeys = _T("yna"); TCHAR szMsg[RC_STRING_MAX_SIZE]; - + TCHAR szOut[512]; + va_list arg_ptr; +// TCHAR cKey = 0; +// LPTSTR szKeys = _T("yna"); - TCHAR szIn[10]; + TCHAR szIn[10]; LPTSTR p; va_start (arg_ptr, szFormat); _vstprintf (szOut, szFormat, arg_ptr); va_end (arg_ptr); - ConOutPrintf (szFormat); + ConOutPrintf (szFormat); -/* preliminary fix */ - ConInString (szIn, 10); - ConOutPrintf (_T("\n")); + /* preliminary fix */ + ConInString (szIn, 10); + ConOutPrintf (_T("\n")); - _tcsupr (szIn); - for (p = szIn; _istspace (*p); p++); + _tcsupr (szIn); + for (p = szIn; _istspace (*p); p++) + ; - LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - + LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, szMsg, RC_STRING_MAX_SIZE); - if (_tcsncmp(p,&szMsg[0],1)==0) - return PROMPT_YES; - else if (_tcsncmp(p,&szMsg[1],1)==0) - return PROMPT_NO; - else if (_tcsncmp(p,&szMsg[2],1)==0) - return PROMPT_ALL; + if (_tcsncmp(p, &szMsg[0], 1) == 0) + return PROMPT_YES; + else if (_tcsncmp(p, &szMsg[1], 1) == 0) + return PROMPT_NO; + else if (_tcsncmp(p, &szMsg[2], 1) == 0) + return PROMPT_ALL; #if 0 else if (*p == _T('\03')) @@ -591,11 +586,9 @@ INT FilePromptYNA (LPTSTR szFormat, ...) do { ConInKey (&ir); - cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar); - if (_tcschr (szKeys, cKey[0]) == NULL) - cKey = 0; - - + cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar); + if (_tcschr (szKeys, cKey[0]) == NULL) + cKey = 0; } while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) || (ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) || diff --git a/reactos/subsys/system/cmd/move.c b/reactos/subsys/system/cmd/move.c index 2827da62d27..9ad3684a705 100644 --- a/reactos/subsys/system/cmd/move.c +++ b/reactos/subsys/system/cmd/move.c @@ -39,21 +39,21 @@ static INT Overwrite (LPTSTR fn) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR inp[10]; LPTSTR p; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - LoadString( GetModuleHandle(NULL), STRING_MOVE_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, fn); - ConInString (inp, 10); + LoadString(GetModuleHandle(NULL), STRING_MOVE_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, fn); + ConInString(inp, 10); _tcsupr (inp); - for (p=inp; _istspace (*p); p++) + for (p = inp; _istspace(*p); p++) ; - if (*p != _T('Y') && *p != _T('A')) + if (*p != szMsg[0] && *p != szMsg[2]) return OVERWRITE_NO; - if (*p == _T('A')) + if (*p == szMsg[2]) return OVERWRITE_ALL; return OVERWRITE_YES; @@ -63,6 +63,7 @@ static INT Overwrite (LPTSTR fn) INT cmd_move (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR *arg; INT argc, i, nFiles; TCHAR szDestPath[MAX_PATH]; @@ -72,8 +73,7 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) WIN32_FIND_DATA findBuffer; HANDLE hFile; LPTSTR pszFile; - BOOL bNothing = FALSE; - TCHAR szMsg[RC_STRING_MAX_SIZE]; + BOOL bNothing = FALSE; if (!_tcsncmp (param, _T("/?"), 2)) { @@ -92,8 +92,8 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) " /-Y\n" "...")); #else - LoadString( GetModuleHandle(NULL), STRING_MOVE_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_MOVE_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif return 0; } @@ -101,8 +101,6 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) arg = split (param, &argc, FALSE); nFiles = argc; - LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - /* read options */ for (i = 0; i < argc; i++) { @@ -114,14 +112,14 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) if (*p == _T('-')) { p++; - if (_totupper (*p) == szMsg[0]) + if (_totupper (*p) == _T('Y')) bPrompt = TRUE; } else { - if (_totupper (*p) == szMsg[0]) + if (_totupper (*p) == _T('Y')) bPrompt = FALSE; - else if (_totupper (*p) == szMsg[1]) + else if (_totupper (*p) == _T('N')) bNothing = TRUE; } nFiles--; @@ -194,11 +192,10 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) if (!bNothing) { if (MoveFile (szSrcPath, szFullDestPath)) - LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_MOVE_ERROR1, szMsg, RC_STRING_MAX_SIZE); else - LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - - ConOutPrintf ((LPTSTR)szMsg); + LoadString(GetModuleHandle(NULL), STRING_MOVE_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); } } else @@ -218,10 +215,10 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) if (!bNothing) { if (MoveFile (szSrcPath, szDestPath)) - LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_MOVE_ERROR1, szMsg, RC_STRING_MAX_SIZE); else - LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf ((LPTSTR)szMsg); + LoadString(GetModuleHandle(NULL), STRING_MOVE_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); } } } @@ -238,10 +235,10 @@ INT cmd_move (LPTSTR cmd, LPTSTR param) if (!bNothing) { if (MoveFile (szSrcPath, szFullDestPath)) - LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - else - LoadString( GetModuleHandle(NULL), STRING_MOVE_ERROR2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf ((LPTSTR)szMsg); + LoadString(GetModuleHandle(NULL), STRING_MOVE_ERROR1, szMsg, RC_STRING_MAX_SIZE); + else + LoadString(GetModuleHandle(NULL), STRING_MOVE_ERROR2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); } } } diff --git a/reactos/subsys/system/cmd/msgbox.c b/reactos/subsys/system/cmd/msgbox.c index 769924dc559..fd9cc65f450 100644 --- a/reactos/subsys/system/cmd/msgbox.c +++ b/reactos/subsys/system/cmd/msgbox.c @@ -25,6 +25,8 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; + //used to parse command line LPTSTR tmp; @@ -32,20 +34,19 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) //and to find window handle to pass to MessageBox HWND hWnd; TCHAR buff[128]; - TCHAR szMsg[RC_STRING_MAX_SIZE]; //these are MessabeBox() parameters - LPTSTR title, prompt=""; - UINT uType=U_TYPE_INIT; + LPTSTR title, prompt = ""; + UINT uType = U_TYPE_INIT; - //set default title to window title - GetConsoleTitle(buff,128); + /* set default title to window title */ + GetConsoleTitle(buff, 128); title = buff; if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_MSGBOX_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); + LoadString(GetModuleHandle(NULL), STRING_MSGBOX_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -56,27 +57,28 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) param++; //search for type of messagebox (ok, okcancel, ...) - if (_tcsnicmp(param, _T("ok "),3 ) == 0) - { + if (_tcsnicmp(param, _T("ok "), 3) == 0) + { uType |= MB_ICONEXCLAMATION | MB_OK; - param+=3; + param += 3; } - else if (_tcsnicmp(param, _T("okcancel "),9 ) == 0) + else if (_tcsnicmp(param, _T("okcancel "), 9) == 0) { uType |= MB_ICONQUESTION | MB_OKCANCEL; - param+=9; + param += 9; } - else if (_tcsnicmp(param, _T("yesno "),6 ) == 0) + else if (_tcsnicmp(param, _T("yesno "), 6) == 0) { uType |= MB_ICONQUESTION | MB_YESNO; - param+=6; + param += 6; } - else if (_tcsnicmp(param, _T("yesnocancel "), 12 ) == 0) + else if (_tcsnicmp(param, _T("yesnocancel "), 12) == 0) { uType |= MB_ICONQUESTION | MB_YESNOCANCEL; - param+=12; + param += 12; } - else{ + else + { #ifdef _SYNTAX_CHECK error_req_param_missing (); return 1; @@ -93,7 +95,7 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) #ifdef _SYNTAX_CHECK //if reached end of string //it is an error becuase we do not yet have prompt - if ( *param == 0) + if (*param == 0) { error_req_param_missing (); return 1; @@ -103,24 +105,25 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) //search for "title" tmp = param; - if(*param == '"') + if (*param == '"') { - tmp = _tcschr(param+1,'"'); + tmp = _tcschr(param + 1, '"'); if (tmp) { *tmp = 0; - title = param+1; - tmp++; - param = tmp; + title = param + 1; + tmp++; + param = tmp; } } //skip spaces while(_istspace(*param)) param++; + #ifdef _SYNTAX_CHECK //get prompt - if ( *param == 0) + if (*param == 0) { error_req_param_missing (); return 1; @@ -130,28 +133,28 @@ INT CommandMsgbox (LPTSTR cmd, LPTSTR param) prompt = param; hWnd=GetConsoleWindow (); -// DebugPrintf("FindWindow hWnd = %d\n",hWnd); - ConErrPrintf("FindWindow hWnd = %d\n",hWnd); +// DebugPrintf("FindWindow hWnd = %d\n",hWnd); +// ConErrPrintf("FindWindow hWnd = %d\n",hWnd); - switch ( - MessageBox(hWnd,prompt,title,uType) - ) + switch (MessageBox(hWnd, prompt, title, uType)) { - case IDYES: - case IDOK: - nErrorLevel = 10; - break; + case IDYES: + case IDOK: + nErrorLevel = 10; + break; - case IDNO: - nErrorLevel = 11; - break; + case IDNO: + nErrorLevel = 11; + break; - case IDCANCEL: - nErrorLevel = 12; - break; + case IDCANCEL: + nErrorLevel = 12; + break; } return 0; } #endif /* INCLUDE_CMD_MSGBOX */ + +/* EOF */ diff --git a/reactos/subsys/system/cmd/path.c b/reactos/subsys/system/cmd/path.c index 3978e3546ff..d737bf880e3 100644 --- a/reactos/subsys/system/cmd/path.c +++ b/reactos/subsys/system/cmd/path.c @@ -39,10 +39,9 @@ INT cmd_path (LPTSTR cmd, LPTSTR param) TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (param, _T("/?"), 2)) - { - LoadString( GetModuleHandle(NULL), STRING_PATH_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + { + LoadString(GetModuleHandle(NULL), STRING_PATH_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -56,8 +55,8 @@ INT cmd_path (LPTSTR cmd, LPTSTR param) dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE); if (dwBuffer == 0) { - LoadString( GetModuleHandle(NULL), STRING_PATH_ERROR, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_PATH_ERROR, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg); return 0; } else if (dwBuffer > ENV_BUFFER_SIZE) @@ -84,3 +83,5 @@ INT cmd_path (LPTSTR cmd, LPTSTR param) } #endif + +/* EOF */ diff --git a/reactos/subsys/system/cmd/pause.c b/reactos/subsys/system/cmd/pause.c index 4f6565a217a..faa3d6789b1 100644 --- a/reactos/subsys/system/cmd/pause.c +++ b/reactos/subsys/system/cmd/pause.c @@ -45,9 +45,8 @@ INT cmd_pause (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_PAUSE_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_PAUSE_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -62,3 +61,5 @@ INT cmd_pause (LPTSTR cmd, LPTSTR param) } #endif + +/* EOF */ diff --git a/reactos/subsys/system/cmd/prompt.c b/reactos/subsys/system/cmd/prompt.c index adf4851ee3e..2d6e2b5789b 100644 --- a/reactos/subsys/system/cmd/prompt.c +++ b/reactos/subsys/system/cmd/prompt.c @@ -51,7 +51,6 @@ /* * print the command-line prompt - * */ VOID PrintPrompt(VOID) { @@ -186,15 +185,15 @@ INT cmd_prompt (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_PROMPT_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_PROMPT_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #ifdef FEATURE_DIRECTORY_STACK - LoadString( GetModuleHandle(NULL), STRING_PROMPT_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_PROMPT_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); #endif - LoadString( GetModuleHandle(NULL), STRING_PROMPT_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_PROMPT_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -205,3 +204,5 @@ INT cmd_prompt (LPTSTR cmd, LPTSTR param) return 0; } #endif + +/* EOF */ diff --git a/reactos/subsys/system/cmd/ren.c b/reactos/subsys/system/cmd/ren.c index 2f301bdb70f..848f5a90e47 100644 --- a/reactos/subsys/system/cmd/ren.c +++ b/reactos/subsys/system/cmd/ren.c @@ -43,6 +43,7 @@ enum */ INT cmd_rename (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR *arg = NULL; INT args = 0; INT nEvalArgs = 0; /* nunber of evaluated arguments */ @@ -58,15 +59,13 @@ INT cmd_rename (LPTSTR cmd, LPTSTR param) HANDLE hFile; WIN32_FIND_DATA f; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp(param, _T("/?"), 2)) - { - LoadString( GetModuleHandle(NULL), STRING_REN_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); - - return(0); - } + { + LoadString(GetModuleHandle(NULL), STRING_REN_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); + return 0; + } /* split the argument list */ arg = split(param, &args, FALSE); @@ -76,7 +75,7 @@ INT cmd_rename (LPTSTR cmd, LPTSTR param) if (!(dwFlags & REN_ERROR)) error_req_param_missing(); freep(arg); - return(1); + return 1; } /* read options */ @@ -127,7 +126,7 @@ INT cmd_rename (LPTSTR cmd, LPTSTR param) if (!(dwFlags & REN_ERROR)) error_req_param_missing(); freep(arg); - return(1); + return 1; } /* get destination pattern */ @@ -239,8 +238,8 @@ INT cmd_rename (LPTSTR cmd, LPTSTR param) { if (!(dwFlags & REN_ERROR)) { - LoadString( GetModuleHandle(NULL), STRING_REN_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPrintf (szMsg, GetLastError()); + LoadString(GetModuleHandle(NULL), STRING_REN_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, GetLastError()); } } } @@ -250,20 +249,17 @@ INT cmd_rename (LPTSTR cmd, LPTSTR param) } if (!(dwFlags & REN_QUIET)) - { - if (dwFiles == 1) - LoadString( GetModuleHandle(NULL), STRING_REN_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - else - LoadString( GetModuleHandle(NULL), STRING_REN_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - - ConOutPrintf(szMsg,dwFiles); - } + { + if (dwFiles == 1) + LoadString( GetModuleHandle(NULL), STRING_REN_HELP2, szMsg, RC_STRING_MAX_SIZE); + else + LoadString( GetModuleHandle(NULL), STRING_REN_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf((LPTSTR)szMsg,dwFiles); + } - - freep(arg); - return(0); + return 0; } #endif diff --git a/reactos/subsys/system/cmd/resource.h b/reactos/subsys/system/cmd/resource.h index 2756f1c972c..820b5d079a4 100644 --- a/reactos/subsys/system/cmd/resource.h +++ b/reactos/subsys/system/cmd/resource.h @@ -4,24 +4,23 @@ #define STRING_ERROR_PARAMETERF_ERROR 100 #define STRING_ERROR_INVALID_SWITCH 101 #define STRING_ERROR_TOO_MANY_PARAMETERS 102 -#define STRING_ERROR_PATH_NOT_FOUND 103 -#define STRING_ERROR_FILE_NOT_FOUND 104 -#define STRING_ERROR_REQ_PARAM_MISSING 105 -#define STRING_ERROR_INVALID_DRIVE 106 +#define STRING_ERROR_PATH_NOT_FOUND 103 +#define STRING_ERROR_FILE_NOT_FOUND 104 +#define STRING_ERROR_REQ_PARAM_MISSING 105 +#define STRING_ERROR_INVALID_DRIVE 106 #define STRING_ERROR_INVALID_PARAM_FORMAT 107 -#define STRING_ERROR_BADCOMMAND 108 -#define STRING_ERROR_OUT_OF_MEMORY 109 -#define STRING_ERROR_CANNOTPIPE 110 -#define STRING_ERROR_D_PAUSEMSG 111 +#define STRING_ERROR_BADCOMMAND 108 +#define STRING_ERROR_OUT_OF_MEMORY 109 +#define STRING_ERROR_CANNOTPIPE 110 +#define STRING_ERROR_D_PAUSEMSG 111 #define STRING_ERROR_DRIVER_NOT_READY 112 #define STRING_CHOICE_OPTION 200 #define STRING_COPY_OPTION 201 -#define STRING_DEL_OPTION 202 #define STRING_ALIAS_ERROR 300 #define STRING_BATCH_ERROR 301 -#define STRING_CHCP_ERROR1 302 +#define STRING_CHCP_ERROR1 302 #define STRING_CHCP_ERROR2 303 #define STRING_CHCP_ERROR3 304 #define STRING_CHCP_ERROR4 305 @@ -43,17 +42,12 @@ #define STRING_COPY_ERROR3 321 #define STRING_COPY_ERROR4 322 #define STRING_DATE_ERROR 323 -#define STRING_DEL_ERROR1 324 -#define STRING_DEL_ERROR2 325 -#define STRING_DEL_ERROR3 326 -#define STRING_DEL_ERROR4 327 #define STRING_DEL_ERROR5 328 #define STRING_DEL_ERROR6 329 #define STRING_DEL_ERROR7 330 -#define STRING_DEL_ERROR8 331 #define STRING_ERROR_ERROR1 332 #define STRING_ERROR_ERROR2 333 -#define STRING_FOR_ERROR1 334 +#define STRING_FOR_ERROR1 334 #define STRING_FOR_ERROR2 335 #define STRING_FOR_ERROR3 336 #define STRING_FOR_ERROR4 337 @@ -61,7 +55,7 @@ #define STRING_FREE_ERROR2 339 #define STRING_GOTO_ERROR1 340 #define STRING_GOTO_ERROR2 341 -#define STRING_MOVE_ERROR1 342 +#define STRING_MOVE_ERROR1 342 #define STRING_MOVE_ERROR2 343 #define STRING_PARAM_ERROR 344 #define STRING_PATH_ERROR 345 @@ -81,7 +75,7 @@ #define STRING_CHCP_HELP 605 #define STRING_CHOICE_HELP 606 #define STRING_CLS_HELP 607 -#define STRING_CMD_HELP1 608 +#define STRING_CMD_HELP1 608 #define STRING_CMD_HELP2 609 #define STRING_CMD_HELP3 610 #define STRING_CMD_HELP4 611 @@ -97,12 +91,12 @@ #define STRING_DATE_HELP3 621 #define STRING_DATE_HELP4 622 #define STRING_DEL_HELP1 623 -#define STRING_DEL_HELP2 624 +#define STRING_DEL_HELP2 624 #define STRING_DEL_HELP3 625 #define STRING_DEL_HELP4 626 -#define STRING_DELAY_HELP 627 +#define STRING_DELAY_HELP 627 -#define STRING_DIR_HELP1 628 +#define STRING_DIR_HELP1 628 #define STRING_DIR_HELP2 629 #define STRING_DIR_HELP3 630 #define STRING_DIR_HELP4 631 @@ -119,14 +113,14 @@ #define STRING_ECHO_HELP1 640 #define STRING_ECHO_HELP2 641 #define STRING_ECHO_HELP3 642 -#define STRING_ECHO_HELP4 643 -#define STRING_ECHO_HELP5 644 +#define STRING_ECHO_HELP4 643 +#define STRING_ECHO_HELP5 644 #define STRING_EXIT_HELP 645 #define STRING_FOR_HELP1 646 -#define STRING_FREE_HELP1 647 +#define STRING_FREE_HELP1 647 #define STRING_FREE_HELP2 648 #define STRING_IF_HELP1 650 @@ -151,7 +145,7 @@ #define STRING_MOVE_HELP1 662 #define STRING_MOVE_HELP2 663 -#define STRING_MSGBOX_HELP 664 +#define STRING_MSGBOX_HELP 664 #define STRING_PATH_HELP1 665 @@ -198,24 +192,18 @@ #define STRING_VERSION_HELP4 690 #define STRING_VERSION_HELP5 691 #define STRING_VERSION_HELP6 692 +#define STRING_VERSION_HELP7 693 -#define STRING_VOL_HELP1 693 -#define STRING_VOL_HELP2 694 -#define STRING_VOL_HELP3 695 -#define STRING_VOL_HELP4 696 +#define STRING_VOL_HELP1 694 +#define STRING_VOL_HELP2 695 +#define STRING_VOL_HELP3 696 +#define STRING_VOL_HELP4 697 -#define STRING_WINDOW_HELP1 697 -#define STRING_WINDOW_HELP2 698 +#define STRING_WINDOW_HELP1 698 +#define STRING_WINDOW_HELP2 699 -#define STRING_FreeDOS_DEV 800 +/* These strings are language independent (cmd.rc) */ +#define STRING_FREEDOS_DEV 800 #define STRING_REACTOS_DEV 801 - - - - - - - - - +/* EOF */ diff --git a/reactos/subsys/system/cmd/screen.c b/reactos/subsys/system/cmd/screen.c index 9f788205eab..5693fae1a76 100644 --- a/reactos/subsys/system/cmd/screen.c +++ b/reactos/subsys/system/cmd/screen.c @@ -19,15 +19,14 @@ INT CommandScreen (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; SHORT x,y; BOOL bSkipText = FALSE; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_SCREEN_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts((LPTSTR)szMsg); - + LoadString(GetModuleHandle(NULL), STRING_SCREEN_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/set.c b/reactos/subsys/system/cmd/set.c index 99dbffcb197..1ff7c166587 100644 --- a/reactos/subsys/system/cmd/set.c +++ b/reactos/subsys/system/cmd/set.c @@ -46,14 +46,13 @@ INT cmd_set (LPTSTR cmd, LPTSTR param) { - LPTSTR p; TCHAR szMsg[RC_STRING_MAX_SIZE]; + LPTSTR p; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_SET_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_SET_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/shift.c b/reactos/subsys/system/cmd/shift.c index d5459975199..e18a1b5f41c 100644 --- a/reactos/subsys/system/cmd/shift.c +++ b/reactos/subsys/system/cmd/shift.c @@ -47,9 +47,8 @@ INT cmd_shift (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_SHIFT_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString(GetModuleHandle(NULL), STRING_SHIFT_HELP, szMsg, RC_STRING_MAX_SIZE); ConOutPuts(szMsg); - return 0; } @@ -69,3 +68,5 @@ INT cmd_shift (LPTSTR cmd, LPTSTR param) return 0; } + +/* EOF */ diff --git a/reactos/subsys/system/cmd/start.c b/reactos/subsys/system/cmd/start.c index 5af74421405..2065459c4cd 100644 --- a/reactos/subsys/system/cmd/start.c +++ b/reactos/subsys/system/cmd/start.c @@ -19,17 +19,15 @@ INT cmd_start (LPTSTR first, LPTSTR rest) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szFullName[MAX_PATH]; BOOL bWait = FALSE; TCHAR *param; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (_tcsncmp (rest, _T("/?"), 2) == 0) { - - LoadString( GetModuleHandle(NULL), STRING_START_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); - + LoadString(GetModuleHandle(NULL), STRING_START_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -47,11 +45,13 @@ INT cmd_start (LPTSTR first, LPTSTR rest) return 0; } + if( !*rest ) { // FIXME: use comspec instead rest = _T("cmd"); } + /* get the PATH environment variable and parse it */ /* search the PATH environment variable for the binary */ param = _tcschr( rest, _T(' ') ); // skip program name to reach parameters @@ -60,21 +60,23 @@ INT cmd_start (LPTSTR first, LPTSTR rest) *param = 0; param++; } + if (!SearchForExecutable (rest, szFullName)) { error_bad_command (); return 1; } + /* check if this is a .BAT or .CMD file */ if (!_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".bat")) || - !_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".cmd"))) + !_tcsicmp (_tcsrchr (szFullName, _T('.')), _T(".cmd"))) { #ifdef _DEBUG DebugPrintf (_T("[BATCH: %s %s]\n"), szFullName, rest); #endif - LoadString( GetModuleHandle(NULL), STRING_START_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_START_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); } else { @@ -101,7 +103,7 @@ INT cmd_start (LPTSTR first, LPTSTR rest) stui.wShowWindow = SW_SHOWDEFAULT; if (CreateProcess (szFullName, szFullCmdLine, NULL, NULL, FALSE, - CREATE_NEW_CONSOLE, NULL, NULL, &stui, &prci)) + CREATE_NEW_CONSOLE, NULL, NULL, &stui, &prci)) { if (bWait) { @@ -115,8 +117,8 @@ INT cmd_start (LPTSTR first, LPTSTR rest) } else { - ErrorMessage (GetLastError (), - _T("Error executing CreateProcess()!!\n")); + ErrorMessage(GetLastError (), + _T("Error executing CreateProcess()!!\n")); } } diff --git a/reactos/subsys/system/cmd/strtoclr.c b/reactos/subsys/system/cmd/strtoclr.c index 3f08c67035c..5aee0c10326 100644 --- a/reactos/subsys/system/cmd/strtoclr.c +++ b/reactos/subsys/system/cmd/strtoclr.c @@ -174,11 +174,11 @@ static WORD txt_clr(LPTSTR str) { INT i; - - for(i=0;*(clrtable[i].name);i++) - if( _tcsnicmp(str,clrtable[i].name,_tcslen(clrtable[i].name)) == 0) + + for(i = 0; *(clrtable[i].name); i++) + if (_tcsnicmp(str, clrtable[i].name, _tcslen(clrtable[i].name)) == 0) return clrtable[i].val; - + return (WORD)-1; } @@ -188,37 +188,35 @@ WORD txt_clr(LPTSTR str) static WORD str_to_color(LPTSTR* arg_str) { - LPTSTR str; + LPTSTR str; BOOL bBri; WORD tmp_clr,ret_clr; str = *arg_str; - - - if(!(*str)) + if (!(*str)) return (WORD)-1; /*foreground*/ - bBri = FALSE; + bBri = FALSE; - if(_tcsnicmp(str,_T("bri"),3) == 0 ) + if (_tcsnicmp(str,_T("bri"),3) == 0) { bBri = TRUE; - if(chop_blank(&str)) + if (chop_blank(&str)) return (WORD)-1; } - if( (tmp_clr = txt_clr(str)) == (WORD)-1 ) + if ((tmp_clr = txt_clr(str)) == (WORD)-1) { return (WORD)-1; } - /*skip spaces and "on"*/ - if ( chop_blank(&str) || chop_blank(&str) ) + /*skip spaces and "on"*/ + if (chop_blank(&str) || chop_blank(&str)) return (WORD)-1; ret_clr = tmp_clr | (bBri << 3); diff --git a/reactos/subsys/system/cmd/time.c b/reactos/subsys/system/cmd/time.c index 9c484f168f8..3a9e99c2003 100644 --- a/reactos/subsys/system/cmd/time.c +++ b/reactos/subsys/system/cmd/time.c @@ -21,7 +21,7 @@ * Fixed time input bug. * * 30-Apr-2005 (Magnus Olsen) ) - * Remove all hardcode string to En.rc + * Remove all hardcode string to En.rc. */ #include "precomp.h" @@ -132,18 +132,17 @@ static BOOL ParseTime (LPTSTR s) INT cmd_time (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; LPTSTR *arg; INT argc; INT i; BOOL bPrompt = TRUE; INT nTimeString = -1; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_TIME_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); + LoadString(GetModuleHandle(NULL), STRING_TIME_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -175,8 +174,8 @@ INT cmd_time (LPTSTR cmd, LPTSTR param) { TCHAR s[40]; - LoadString( GetModuleHandle(NULL), STRING_TIME_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg); + LoadString(GetModuleHandle(NULL), STRING_TIME_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); ConInString (s, 40); @@ -204,8 +203,9 @@ INT cmd_time (LPTSTR cmd, LPTSTR param) /* force input the next time around. */ nTimeString = -1; } - LoadString( GetModuleHandle(NULL), STRING_TIME_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + + LoadString(GetModuleHandle(NULL), STRING_TIME_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); } freep (arg); diff --git a/reactos/subsys/system/cmd/timer.c b/reactos/subsys/system/cmd/timer.c index 235dc900727..84b1217d03b 100644 --- a/reactos/subsys/system/cmd/timer.c +++ b/reactos/subsys/system/cmd/timer.c @@ -47,8 +47,8 @@ PrintElapsedTime (DWORD time,INT format) switch (format) { case 0: - LoadString( GetModuleHandle(NULL), STRING_TIMER_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf(szMsg,time); + LoadString(GetModuleHandle(NULL), STRING_TIMER_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, time); break; case 1: @@ -56,13 +56,13 @@ PrintElapsedTime (DWORD time,INT format) time /= 1000; s = time % 60; time /=60; - m = time % 60; + m = time % 60; h = time / 60; - LoadString( GetModuleHandle(NULL), STRING_TIMER_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); + LoadString( GetModuleHandle(NULL), STRING_TIMER_HELP2, szMsg, RC_STRING_MAX_SIZE); ConOutPrintf(szMsg, - h,cTimeSeparator, - m,cTimeSeparator, - s,cDecimalSeparator,ms/10); + h, cTimeSeparator, + m, cTimeSeparator, + s, cDecimalSeparator, ms/10); break; } } @@ -104,8 +104,8 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param) if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_TIMER_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg,cTimeSeparator,cTimeSeparator,cDecimalSeparator); + LoadString(GetModuleHandle(NULL), STRING_TIMER_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, cTimeSeparator, cTimeSeparator, cDecimalSeparator); return 0; } @@ -132,7 +132,6 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param) // other options if (p[i][0] == _T('/')) { - // set timer number if (_istdigit(p[i][1]) && bCanNSet) { @@ -149,7 +148,7 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param) } // specify format - if(_totupper(p[i][1]) == _T('F')) + if (_totupper(p[i][1]) == _T('F')) { iFormat = p[i][2] - _T('0'); continue; @@ -184,9 +183,10 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param) return 0; } - if(NewClkStatus == NCS_NOT_SPECIFIED) - { - if(cS){ + if (NewClkStatus == NCS_NOT_SPECIFIED) + { + if (cS) + { cS=FALSE; PS; PrintElapsedTime(GetTickCount()-cT, iFormat); @@ -202,9 +202,9 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param) } - if(NewClkStatus == NCS_OFF) + if (NewClkStatus == NCS_OFF) { - if(cS) + if (cS) { cS=FALSE; PS; diff --git a/reactos/subsys/system/cmd/title.c b/reactos/subsys/system/cmd/title.c index 424f1581b1d..93eb9e92524 100644 --- a/reactos/subsys/system/cmd/title.c +++ b/reactos/subsys/system/cmd/title.c @@ -26,8 +26,8 @@ INT cmd_title (LPTSTR cmd, LPTSTR param) /* Asking help? */ if (!_tcsncmp(param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_TITLE_HELP, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts(szMsg); + LoadString(GetModuleHandle(NULL), STRING_TITLE_HELP, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/type.c b/reactos/subsys/system/cmd/type.c index 286f14947f1..a187f798887 100644 --- a/reactos/subsys/system/cmd/type.c +++ b/reactos/subsys/system/cmd/type.c @@ -34,6 +34,7 @@ INT cmd_type (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR buff[256]; HANDLE hFile, hConsoleOut; DWORD dwRead; @@ -42,14 +43,13 @@ INT cmd_type (LPTSTR cmd, LPTSTR param) INT argc,i; LPTSTR *argv; LPTSTR errmsg; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - + hConsoleOut=GetStdHandle (STD_OUTPUT_HANDLE); if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_TYPE_HELP1, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_TYPE_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -65,10 +65,11 @@ INT cmd_type (LPTSTR cmd, LPTSTR param) { if (_T('/') == argv[i][0]) { - LoadString( GetModuleHandle(NULL), STRING_TYPE_ERROR1, (LPTSTR) szMsg,sizeof(szMsg)); - ConErrPrintf (szMsg, argv[i] + 1); + LoadString(GetModuleHandle(NULL), STRING_TYPE_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg, argv[i] + 1); continue; } + hFile = CreateFile(argv[i], GENERIC_READ, FILE_SHARE_READ,NULL, @@ -101,8 +102,8 @@ INT cmd_type (LPTSTR cmd, LPTSTR param) } while(dwRead>0 && bRet); CloseHandle(hFile); - } - + } + freep (argv); return 0; diff --git a/reactos/subsys/system/cmd/ver.c b/reactos/subsys/system/cmd/ver.c index ae399887cb4..1f250dde45e 100644 --- a/reactos/subsys/system/cmd/ver.c +++ b/reactos/subsys/system/cmd/ver.c @@ -63,29 +63,26 @@ VOID ShortVersion (VOID) */ INT cmd_ver (LPTSTR cmd, LPTSTR param) { - INT i; TCHAR szMsg[RC_STRING_MAX_SIZE]; - TCHAR rosdev[RC_STRING_MAX_SIZE]; - TCHAR fredev[RC_STRING_MAX_SIZE]; + INT i; if (_tcsstr (param, _T("/?")) != NULL) { - LoadString( GetModuleHandle(NULL), STRING_VERSION_HELP1, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } ShortVersion(); ConOutPuts (_T("Copyright (C) 1994-1998 Tim Norman and others.")); - ConOutPuts (_T("Copyright (C) 1998-2001 Eric Kohl and others.")); + ConOutPuts (_T("Copyright (C) 1998-2005 Eric Kohl and others.")); /* Basic copyright notice */ if (param[0] == _T('\0')) { - ConOutPuts (_T("\n"SHELLINFO)); - LoadString( GetModuleHandle(NULL), STRING_VERSION_HELP2, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPuts (szMsg); + ConOutPuts(_T("\n"SHELLINFO)); + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } else { @@ -109,38 +106,26 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param) if (_totupper (param[i]) == _T('W')) { /* Warranty notice */ - LoadString( GetModuleHandle(NULL), STRING_VERSION_HELP3, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } else if (_totupper (param[i]) == _T('R')) { /* Redistribution notice */ - LoadString( GetModuleHandle(NULL), STRING_VERSION_HELP4, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); } else if (_totupper (param[i]) == _T('C')) { /* Developer listing */ - - LoadString( GetModuleHandle(NULL), STRING_REACTOS_DEV, rosdev,sizeof(rosdev)/sizeof(TCHAR)); - LoadString( GetModuleHandle(NULL), STRING_FreeDOS_DEV, fredev,sizeof(fredev)/sizeof(TCHAR)); - LoadString( GetModuleHandle(NULL), STRING_VERSION_HELP6, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPrintf ((LPTSTR)szMsg,fredev,rosdev); - - /* - ConOutPuts (_T("\n" - "FreeDOS version written by:\n" - " Tim Norman Matt Rains\n" - " Evan Jeffrey Steffen Kaiser\n" - " Svante Frey Oliver Mueller\n" - " Aaron Kaufman Marc Desrochers\n" - " Rob Lake John P Price\n" - " Hans B Pufal\n" - "\n" - "ReactOS version written by:\n" - " Eric Kohl Emanuele Aliberti\n" - " Paolo Pantaleo Phillip Susi\n")); - */ + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP6, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); + LoadString(GetModuleHandle(NULL), STRING_FREEDOS_DEV, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP7, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); + LoadString(GetModuleHandle(NULL), STRING_REACTOS_DEV, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg); } else { @@ -150,8 +135,8 @@ INT cmd_ver (LPTSTR cmd, LPTSTR param) } } - LoadString( GetModuleHandle(NULL), STRING_VERSION_HELP5, (LPTSTR) szMsg,sizeof(szMsg)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_VERSION_HELP5, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/verify.c b/reactos/subsys/system/cmd/verify.c index ed7ce70ae6d..0ac13efe257 100644 --- a/reactos/subsys/system/cmd/verify.c +++ b/reactos/subsys/system/cmd/verify.c @@ -34,23 +34,25 @@ INT cmd_verify (LPTSTR cmd, LPTSTR param) if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_VERIFY_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_VERIFY_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } if (!*param) { - LoadString( GetModuleHandle(NULL), STRING_VERIFY_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, bVerify ? D_ON : D_OFF); + LoadString(GetModuleHandle(NULL), STRING_VERIFY_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf((LPTSTR)szMsg, bVerify ? D_ON : D_OFF); } else if (_tcsicmp (param, D_OFF) == 0) bVerify = FALSE; else if (_tcsicmp (param, D_ON) == 0) bVerify = TRUE; - else - LoadString( GetModuleHandle(NULL), STRING_VERIFY_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + else + { + LoadString(GetModuleHandle(NULL), STRING_VERIFY_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); + } return 0; } diff --git a/reactos/subsys/system/cmd/vol.c b/reactos/subsys/system/cmd/vol.c index c58d2369a1e..45bf0f4cdd8 100644 --- a/reactos/subsys/system/cmd/vol.c +++ b/reactos/subsys/system/cmd/vol.c @@ -29,10 +29,9 @@ static INT PrintVolumeHeader (LPTSTR pszRootPath) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szVolName[80]; DWORD dwSerialNr; - TCHAR szMsg[RC_STRING_MAX_SIZE]; - /* get the volume information of the drive */ if(!GetVolumeInformation (pszRootPath, @@ -49,44 +48,34 @@ PrintVolumeHeader (LPTSTR pszRootPath) } /* print drive info */ - - - - if (szVolName[0] != '\0') { - LoadString( GetModuleHandle(NULL), STRING_VOL_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, pszRootPath[0],szVolName); + LoadString(GetModuleHandle(NULL), STRING_VOL_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, pszRootPath[0],szVolName); } else { - LoadString( GetModuleHandle(NULL), STRING_VOL_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, pszRootPath[0]); + LoadString(GetModuleHandle(NULL), STRING_VOL_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, pszRootPath[0]); } - - - /* print the volume serial number */ - LoadString( GetModuleHandle(NULL), STRING_VOL_HELP3, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPrintf (szMsg, - HIWORD(dwSerialNr), - LOWORD(dwSerialNr)); + LoadString(GetModuleHandle(NULL), STRING_VOL_HELP3, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, HIWORD(dwSerialNr), LOWORD(dwSerialNr)); return 0; } INT cmd_vol (LPTSTR cmd, LPTSTR param) { + TCHAR szMsg[RC_STRING_MAX_SIZE]; TCHAR szRootPath[] = _T("A:\\"); TCHAR szPath[MAX_PATH]; - TCHAR szMsg[RC_STRING_MAX_SIZE]; if (!_tcsncmp (param, _T("/?"), 2)) { - LoadString( GetModuleHandle(NULL), STRING_VOL_HELP4, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts ((LPTSTR)szMsg); - + LoadString(GetModuleHandle(NULL), STRING_VOL_HELP4, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } diff --git a/reactos/subsys/system/cmd/where.c b/reactos/subsys/system/cmd/where.c index 30396afede0..ec2a37eaebd 100644 --- a/reactos/subsys/system/cmd/where.c +++ b/reactos/subsys/system/cmd/where.c @@ -233,29 +233,29 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) DebugPrintf (_T("SearchForExecutable(): Loaded PATHEXT: %s\n"), pszBuffer); #endif - pExt = _tcsrchr(pFileName, _T('.')); + pExt = _tcsrchr(pFileName, _T('.')); if (pExt != NULL) { - LPTSTR pszBuffer2; - pszBuffer2 = _tcsdup(pszBuffer); - if (pszBuffer2) - { - pCh = _tcstok(pszBuffer2, _T(";")); - while (pCh) - { - if (0 == _tcsicmp(pCh, pExt)) - { + LPTSTR pszBuffer2; + pszBuffer2 = _tcsdup(pszBuffer); + if (pszBuffer2) + { + pCh = _tcstok(pszBuffer2, _T(";")); + while (pCh) + { + if (0 == _tcsicmp(pCh, pExt)) + { free(pszBuffer); free(pszBuffer2); - return SearchForExecutableSingle(pFileName, pFullName, NULL); - } - pCh = _tcstok(NULL, _T(";")); - } - free(pszBuffer2); - } + return SearchForExecutableSingle(pFileName, pFullName, NULL); + } + pCh = _tcstok(NULL, _T(";")); + } + free(pszBuffer2); + } } - pCh = _tcstok(pszBuffer, _T(";")); + pCh = _tcstok(pszBuffer, _T(";")); while (pCh) { if (SearchForExecutableSingle(pFileName, pFullName, pCh)) @@ -269,3 +269,5 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) free(pszBuffer); return FALSE; } + +/* EOF */ diff --git a/reactos/subsys/system/cmd/window.c b/reactos/subsys/system/cmd/window.c index 85cd4f80590..5c3254d0940 100644 --- a/reactos/subsys/system/cmd/window.c +++ b/reactos/subsys/system/cmd/window.c @@ -37,53 +37,52 @@ */ -static -INT ServiceActivate (LPTSTR param, HWND hWnd) +static INT ServiceActivate (LPTSTR param, HWND hWnd) { - LPTSTR *p=0,p_tmp; - INT argc=0,i; - INT iAction=0; - LPTSTR title=0; + LPTSTR *p = 0, p_tmp; + INT argc = 0, i; + INT iAction = 0; + LPTSTR title = 0; WINDOWPLACEMENT wp; RECT pos; LPTSTR tmp; - if(*param) - p=split(param,&argc); + if (*param) + p = split(param, &argc); - for(i = 0; i < argc; i++) + for (i = 0; i < argc; i++) { - p_tmp=p[i]; + p_tmp = p[i]; if (*p_tmp == _T('/')) p_tmp++; - if (_tcsicmp(p_tmp,_T("min"))==0) + if (_tcsicmp(p_tmp, _T("min")) == 0) { iAction |= A_MIN; continue; } - if (_tcsicmp(p_tmp,_T("max"))==0) + if (_tcsicmp(p_tmp, _T("max")) == 0) { iAction |= A_MAX; continue; } - if (_tcsicmp(p_tmp,_T("restore"))==0) + if (_tcsicmp(p_tmp, _T("restore")) == 0) { iAction |= A_RESTORE; continue; } - if (_tcsicmp(p_tmp,_T("close"))==0) + if (_tcsicmp(p_tmp, _T("close")) == 0) { iAction |= A_CLOSE; continue; } - if (_tcsnicmp(p_tmp,_T("pos"),3)==0) + if (_tcsnicmp(p_tmp, _T("pos"), 3) == 0) { iAction |= A_POS; tmp = p_tmp+3; @@ -91,7 +90,7 @@ INT ServiceActivate (LPTSTR param, HWND hWnd) tmp++; pos.left= _ttoi(tmp); - if(!(tmp=_tcschr(tmp,_T(',')))) + if(!(tmp=_tcschr(tmp, _T(',')))) { error_invalid_parameter_format(p[i]); freep(p); @@ -99,15 +98,15 @@ INT ServiceActivate (LPTSTR param, HWND hWnd) } pos.top = _ttoi (++tmp); - if(!(tmp=_tcschr(tmp,_T(',')))) + if(!(tmp=_tcschr(tmp, _T(',')))) { error_invalid_parameter_format(p[i]); freep(p); return 1; } - pos.right = _ttoi(++tmp)+pos.left; - if(!(tmp=_tcschr(tmp,_T(',')))) + pos.right = _ttoi(++tmp) + pos.left; + if (!(tmp = _tcschr(tmp, _T(',')))) { error_invalid_parameter_format(p[i]); freep(p); @@ -117,13 +116,13 @@ INT ServiceActivate (LPTSTR param, HWND hWnd) continue; } - if (_tcsnicmp(p_tmp,_T("size"),4)==0) + if (_tcsnicmp(p_tmp, _T("size"), 4)==0) { iAction |=A_SIZE; continue; } - /*none of them=window title*/ + /* none of them=window title */ if (title) { error_invalid_parameter_format(p[i]); @@ -133,39 +132,39 @@ INT ServiceActivate (LPTSTR param, HWND hWnd) if (p_tmp[0] == _T('"')) { - title = (p_tmp+1); - *_tcschr(p_tmp+1,_T('"'))=0; + title = (p_tmp + 1); + *_tcschr(p_tmp + 1, _T('"')) = 0; continue; } title = p_tmp; } - if(title) - SetWindowText(hWnd,title); + if (title) + SetWindowText(hWnd, title); - wp.length=sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hWnd,&wp); + wp.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(hWnd, &wp); - if(iAction & A_POS) - wp.rcNormalPosition = pos; + if (iAction & A_POS) + wp.rcNormalPosition = pos; - if(iAction & A_MIN) - wp.showCmd=SW_MINIMIZE; + if (iAction & A_MIN) + wp.showCmd = SW_MINIMIZE; - if(iAction & A_MAX) - wp.showCmd=SW_SHOWMAXIMIZED; + if (iAction & A_MAX) + wp.showCmd = SW_SHOWMAXIMIZED; /*if no actions are specified default is SW_RESTORE*/ - if( (iAction & A_RESTORE) || (!iAction) ) - wp.showCmd=SW_RESTORE; + if ((iAction & A_RESTORE) || (!iAction)) + wp.showCmd = SW_RESTORE; - if(iAction & A_CLOSE) + if (iAction & A_CLOSE) ConErrPrintf(_T("!!!FIXME: CLOSE Not implemented!!!\n")); - wp.length=sizeof(WINDOWPLACEMENT); - SetWindowPlacement(hWnd,&wp); + wp.length = sizeof(WINDOWPLACEMENT); + SetWindowPlacement(hWnd, &wp); - if(p) + if (p) freep(p); return 0; @@ -176,33 +175,32 @@ INT ServiceActivate (LPTSTR param, HWND hWnd) INT CommandWindow (LPTSTR cmd, LPTSTR param) { - HWND h; TCHAR szMsg[RC_STRING_MAX_SIZE]; + HWND hwnd; if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_WINDOW_HELP1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); - + LoadString(GetModuleHandle(NULL), STRING_WINDOW_HELP1, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } h = GetConsoleWindow(); Sleep(0); - return ServiceActivate(param,h); + return ServiceActivate(param, hwnd); } INT CommandActivate (LPTSTR cmd, LPTSTR param) { - LPTSTR str; - HWND h; TCHAR szMsg[RC_STRING_MAX_SIZE]; + LPTSTR str; + HWND hwnd; if (_tcsncmp (param, _T("/?"), 2) == 0) { - LoadString( GetModuleHandle(NULL), STRING_WINDOW_HELP2, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConOutPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_WINDOW_HELP2, szMsg, RC_STRING_MAX_SIZE); + ConOutPuts(szMsg); return 0; } @@ -219,15 +217,15 @@ INT CommandActivate (LPTSTR cmd, LPTSTR param) else str = ""; - h=FindWindow(NULL, param); - if (!h) + hwnd = FindWindow(NULL, param); + if (hwnd == NULL) { - LoadString( GetModuleHandle(NULL), STRING_WINDOW_ERROR1, szMsg,sizeof(szMsg)/sizeof(TCHAR)); - ConErrPuts (szMsg); + LoadString(GetModuleHandle(NULL), STRING_WINDOW_ERROR1, szMsg, RC_STRING_MAX_SIZE); + ConErrPuts(szMsg); return 1; } - return ServiceActivate(str,h); + return ServiceActivate(str, hwnd); } #endif /* ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) ) */