home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name apcomlin -- Return the DOS command line
- *
- * Synopsis clen = apcomlin(pcmd);
- *
- * int clen Length of the command line
- * char *pcmd Buffer in which to put command line
- *
- * Description This function returns the command line typed at the DOS
- * level when the program was invoked. The entire command
- * line (minus the program name) is returned, including all
- * white space. The length of the command line is returned
- * as the value of the function. Space for the command
- * line (as much as 128 bytes, including a trailing NUL)
- * must be allocated by the calling function.
- *
- * Returns clen Length of the command line
- * *pcmd The command line string
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983,1984,1985,1986
- *
- **/
-
- #include <bapplic.h>
- #include <butility.h>
-
- int apcomlin(pcmd)
- char *pcmd;
- {
- int cmdlen = 0;
-
- ADS cmdlen_ads; /* Address of cmdlen */
- ADS cmd_ads; /* Address of command line in the PSP */
- ADS cmdbuf_ads; /* Address of caller's buffer */
-
- utabsptr((char *) &cmdlen,&cmdlen_ads);
-
- cmd_ads.s = utpspseg; /* Location of command line is */
- cmd_ads.r = 0x0080; /* offset hex 80 in the */
- /* program segment prefix. */
-
- utslmove(&cmd_ads,&cmdlen_ads,1);
- cmdlen &= 0x00ff; /* The length is a single byte. */
-
- cmd_ads.r++; /* Move to the next byte */
- utabsptr(pcmd,&cmdbuf_ads);
- utslmove(&cmd_ads,&cmdbuf_ads,cmdlen);
- pcmd[cmdlen] = '\0'; /* Terminating byte */
-
- #if CI201A & LDATA
- for (i = 0; i < cmdlen; i++) /* Fix bug in C86 large model - */
- if (pcmd[i] == '\0') /* it replaced blanks with nulls*/
- pcmd[i] = ' ';
- #endif
-
- return(cmdlen);
- }