_bgetcmd

get the original parameters to a program, as a string

Synopsis:

#include <process.h>
int _bgetcmd( char *cmd_line, int len );

Description:

The _bgetcmd() function causes the command line information, with the program name removed, to be copied to cmd_line. The argument len specifies the size of cmd_line. The information is terminated with a “\0” character. This provides a method of obtaining the original parameters to a program as a single string of text.

This information can also be obtained by examining the vector of program parameters passed to the main function in the program.

Returns:

If cmd_line is NULL then the number of bytes required to store the command line, excluding the terminating NULL character, is returned; otherwise the number of bytes stored in cmd_line, excluding the terminating NULL character, is returned.

See also:

abort(), atexit() , close() , exec... Function, exit(), _exit(), getcmd(), getenv(), main(), onexit(), putenv() , sigaction(), signal() , spawn... functions, system() , wait(), waitpid()

Examples:

Suppose a program is invoked with the command line:

myprog arg-1 ( my   stuff ) here

where that program contains:

#include <stdio.h>
#include <stdlib.h>
#include <process.h>

void main()
  {
    char *cmdline;
    int   cmdlen;

    cmdlen = _bgetcmd( NULL, 0 ) + 1;
    cmdline = malloc( cmdlen );
    if( cmdline != NULL ) {
      cmdlen = _bgetcmd( cmdline, cmdlen );
      printf( "%s\n", cmdline );
    }
  }

The output is as follows:

arg-1 ( my stuff ) here

Classification:

WATCOM

Systems:

All (except DOS/PM)