On Tue, 24 Sep 2002 chrismorgan@rcn.com wrote:
I have a script that passes a long argument string when calling a command handler(command.com or other comspec replacement). This code inside of MZ_FillPSP()
if(length > 126) { ERR("Command line truncated! (length %d > maximum length 126)\n", length; length = 126; }
is breaking my application by truncating the 200+ character argument at 126 characters. Do we still need to truncate at 126?
Yes, it's an intrinsic DOS limitation from the early DOS days. The PSP is a fixed-length structure of 256 bytes, half of which is reserved for the command line; the layout of it is the same as the PDB16 structure (which is the Win16 version of the PSP) in include/task.h. There's no way to fit a longer command line into it; even trying to make the PSP larger won't help for long since the first byte is the command-line length, so it can't be made longer than 255 characters this way anyway. So apps that need unlimited command lines must use a different protocol to pass them. One way could be to use environment variables - for example, I've noticed before that NT's cmd.exe puts the last command line in the "_" environment variable when invoking apps, so I can imagine that apps that take advantage of this look something like
cmd = dos_cmdline(); env_cmd = getenv("_"); if (strncmp(cmd, env_cmd, strlen(env_cmd)) == 0) cmd = env_cmd; main(cmd);
This is only a guess, though, I don't know to what extent something like this is supported by DOS or Windows itself, nor what protocol they really use.