getcmd

Returns the command line parameters in their original format (unparsed).

Library:LibC
Classification:Other
Service:General C Services

Syntax

  #include <stdlib.h> 
   
  char *getcmd (
     char   *originalCmdLine); 
  

Parameters

originalCmdLine

(OUT) Points to a buffer into which to copy the command line parameters.

Return Values

If successful, returns the system’s copy of the original command line. Otherwise, returns NULL and sets errno to the following:

Decimal

Constant

Description

105

ENOCONTEXT

The calling thread has no library context.

Remarks

The getcmd function copies the command line, with the “load” command and the program name removed, into a buffer specified by originalCmdLine (if originalCmdLine is not NULL).

If originalCmdLine is NULL, getcmd returns a pointer to the system’s copy of the original command line (without the “load” command or the program name). The system’s copy should not be written over.

The information is terminated with a \0 character. This provides a method of obtaining the original parameters to a program unchanged (with the whitespace characters intact).

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

See Also