getcmd

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

Local Servers:nonblocking
Remote Servers:N/A
Classification:Other
Service:Thread

Syntax

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

Parameters

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

Return Values

The address of originalCmdLine is returned if originalCmdLine is not NULL. Otherwise, the address of the system’s copy of the original command line is returned.

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 white space 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

spawnlp, spawnvp

Example

  #include <stdio.h>  
  #include <string.h>  
  #include <nwthread.h>  
   
  main()  
  {  
     char   originalCmdLine[80];  
     char   cmdPtr;  
     getcmd(originalCmdLine)  
     printf("%s\n",originalCmdLine);  
     cmdPtr=getcmd(NULL);  
     printf("%s\n", cmdPtr);  
   
  /*    If the load command is:  
     "load test param1 param2 param3"  
     The output is:  
     param1 param2 param3  
     param1 param2 param3  
  */  
  }