Date: Mon, 14 Dec 1998 09:13:13 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Simone Zanella cc: djgpp AT delorie DOT com Subject: Re: DJGPP: finding command line in spawned programs In-Reply-To: <199812132032.VAA06921@mail.prometeo.it> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Note that I'm also posting this to the news group, since I think it might be of interest to others. On Sun, 13 Dec 1998, Simone Zanella wrote: > I need to do special handling on the command line; for example, to deal > with things like this: > > cmd /F"name of file" > > The standard tokenizer wouldn't work ok (I have already written the code to > deal with such cases). Why do you say that the standard command-line parsing is not good for these cases? In the above example, if the spaces are inside quotes, you will get ``/Fname of file'' in argv[1], with all the spaces preserved. Isn't that what you want? What exactly in the standard command-line processing doesn't work okay for your needs? > Moreover, I need to pass a parameter without quotes maintaning all the > spaces specified, as in: > > cmd P Whatever follows.. must be INTERPRETED with all the spaces Why is it necessary to not use quotes? > Is there any way to get the original command line from the (excellent) DJGPP? There is no such thing as ``the original command line'' when a DJGPP program is spawned by another DJGPP program. The "!proxy XXXX YYYY ZZZZ" line specifies a pointer to a block of conventional memory where the command arguments are stored. But each member of the argv[] array is stored there separately, exactly as it was put into the arguments of the `spawnXX' function used to invoke the child program. The DJGPP startup code fetches those arguments one by one, and puts them into the argv[] array passed to the `main' function of the child program. So there's no original command line to look for, in this case. All the information about the command-line arguments is passed exactly from the parent program to the child. That is why I still don't understand why do you think you have a problem with the standard argv[] processing when the program is spawned. It is possible that you are trying to follow the original Borland-compatible code too closely. Other compilers, like Borland's, use an entirely different technique to spawn child programs: they actually reassemble a DOS command line from the arguments of `spawnXX' function, and then pass that reassembled command as if you typed it from the DOS prompt. But DJGPP doesn't work that way, so you probably need to bypass that code altogether when you see "!proxy" in the DOS command tail. If the above still doesn't solve the problem, or is somehow unclear, I suggest that you post an example of a case where a program is spawned by another one, and use that example to explain why the argv[] array in that case is not good enough for your project.