set to eol-style native ;)

svn path=/trunk/; revision=18402
This commit is contained in:
Brandon Turner 2005-10-10 19:08:57 +00:00
parent 657a7f0496
commit fbd6bbbf48

View file

@ -1,19 +1,19 @@
General Overview of How THings Work General Overview of How THings Work
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
First it comes into _main in cmd.c(1811). The command line params are taking in and if it is unicode it uses CommandLineToArgvW. This can cause a problem on older machines and that is why we have our own custom _CommandLineToArgvW to help this along. We pull in the launch directory as the inital dir and set that in _tchdir. We make a handle to the default console out using CreateFile. First it comes into _main in cmd.c(1811). The command line params are taking in and if it is unicode it uses CommandLineToArgvW. This can cause a problem on older machines and that is why we have our own custom _CommandLineToArgvW to help this along. We pull in the launch directory as the inital dir and set that in _tchdir. We make a handle to the default console out using CreateFile.
Then we call Initialize(). Here we need to load ntdll.dll if it isnt loaded(windows 9x machines). We also setup some gloabl vars like default io handles and nErrorLevel and set %prompt% to $P$G. This is where all command lines switches given to cmd on startup are done. Then we call Initialize(). Here we need to load ntdll.dll if it isnt loaded(windows 9x machines). We also setup some gloabl vars like default io handles and nErrorLevel and set %prompt% to $P$G. This is where all command lines switches given to cmd on startup are done.
From here main calls ProcessInput(). This is where cmd loops for getting input and doing the commands. First it checks to see if there is a batch file(note: there is agolbal struct "bc" which is NULL when not processing a batch file) and if there is it will pull a new line from that file. If not, thne it will wait for input. Currently there is some stuff for set /a in there, which might stay there or see if we can find a better spot. From here main calls ProcessInput(). This is where cmd loops for getting input and doing the commands. First it checks to see if there is a batch file(note: there is agolbal struct "bc" which is NULL when not processing a batch file) and if there is it will pull a new line from that file. If not, thne it will wait for input. Currently there is some stuff for set /a in there, which might stay there or see if we can find a better spot.
Once there is input taken in from the command line it is sent into ParseCommandLine(). In here we fist check for aliases and convert if need be. THen we look for redirections using GetRedirection() which will remove any redirection symbols. and pass back info about where to redirect. from this info it will do some switching around with the handles for where things go and send them as need be. personally i dont like this code and i tried to chnage it before but failed. it is confusing to me and i dont understand why a lot of it is there but apparently it is needed. Once there is input taken in from the command line it is sent into ParseCommandLine(). In here we fist check for aliases and convert if need be. THen we look for redirections using GetRedirection() which will remove any redirection symbols. and pass back info about where to redirect. from this info it will do some switching around with the handles for where things go and send them as need be. personally i dont like this code and i tried to chnage it before but failed. it is confusing to me and i dont understand why a lot of it is there but apparently it is needed.
It sends the new string without any redirection info into DoCommand(). In this function we just look to see what should be done. There is one of 2 things that could happen. 1) we fnd the matching command and send it off to that commands little section. 2) we dont find it so we send it to Execute() and see if it is a file that we can do something. It sends the new string without any redirection info into DoCommand(). In this function we just look to see what should be done. There is one of 2 things that could happen. 1) we fnd the matching command and send it off to that commands little section. 2) we dont find it so we send it to Execute() and see if it is a file that we can do something.
Execute will try to launch the file using createprocess and falls back on shellexecute. It calls a function called SearchForExecuteable() to find the full path name and looks in all the correct locations like PATH, curreent folder, windows folder. If it cant find it, just fails and prints out a message. Execute will try to launch the file using createprocess and falls back on shellexecute. It calls a function called SearchForExecuteable() to find the full path name and looks in all the correct locations like PATH, curreent folder, windows folder. If it cant find it, just fails and prints out a message.
Some useful functions that are used a lot: Some useful functions that are used a lot:
split() - splits a string into an array of string on spaces that arent inside quotes. which you need to call freep() on later t clean up. split() - splits a string into an array of string on spaces that arent inside quotes. which you need to call freep() on later t clean up.
IsValidPathName(), IsExistingFile(), IsExistingDirectory() - all do what you would expect. IsValidPathName(), IsExistingFile(), IsExistingDirectory() - all do what you would expect.
PagePrompt() - ask them to hit a key to continue PagePrompt() - ask them to hit a key to continue
FilePromptYN[A]() - ask them a yes or no question FilePromptYN[A]() - ask them a yes or no question