From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 13-SEP-1989 12:24
To:	MRGATE::"ARISIA::EVERHART"
Subj:	vms command line buffer

Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Wed, 13 SEP 89 08:50:46 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.37)
	id AA10253; Wed, 13 Sep 89 08:39:05 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 13 Sep 89 12:51:04 GMT
From: soleil!ahearn@rutgers.edu  (John Ahearn)
Organization: Harris Semiconductor, Somerville, NJ
Subject: vms command line buffer
Message-Id: <791@soleil.UUCP>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


	For all those who asked, Mike Sieweke was kind enough to send
me the source to extract the recall buffer.  Below is his version.
Be warned that Mike also noted, in a followup mail message, that there
is a problem with the recall buffer wrapping at the end.



From rutgers!colorm.gatech.edu!SYSMIKE Tue Sep 12 21:30:25 1989
Return-Path: <rutgers!colorm.gatech.edu!SYSMIKE>
Received: by soleil.uucp (3.2/SMI-3.2)
	id AA00509; Tue, 12 Sep 89 21:30:23 EDT
From: rutgers!colorm.gatech.edu!SYSMIKE
Received: from colorm.gatech.edu by rutgers.edu (5.59/SMI4.0/RU1.2/3.04) 
	id AA19570; Tue, 12 Sep 89 13:48:07 EDT
Message-Id: <8909121748.AA19570@rutgers.edu>
Date: Tue, 12 Sep 89 13:48 EDT
Subject: RE: DCL and the command line
To: ahearn@soleil
X-Vms-To: IN%"soleil!ahearn@rutgers.EDU",SYSMIKE
Status: RO

>	I would greatly appreciate it if anyone could tell me, or point
>me in the right direction, as to how I can obtain the DCL command line
>data untainted (ie. without the CLI having converted it to either
>uppercase (except for quoted strings) for DCL or lowercase (except
>for quoted strings) for argv/C.  I am trying to implement a call compatible
>CC command for VMS equivalent to Unix and need to be able to handle arguments
>that may be expressed in upper or lowercase.
>
>	Thanks again for the help.
>
>							John Ahearn
>							rutgers!soleil!ahearn

There isn't a supported method to do this.  The only way I know is to pull
the data out of the recall buffer.  Here is a program that will print the
command used to execute it.

#include syidef
#include stdio
#include ssdef
#include string

typedef struct {
   unsigned short buflen;
   unsigned short item_code;
   char           *buf_adr;
   int            *retlenadr;
} item;

typedef struct {
   item    list;
   int     terminator;
} jpi_item_list;

jpi_item_list jpi_list;
char          version[9];
int           version_len;
int           status;
char          v40[] = "V4.0";
char          v50[] = "V5.0";
char          v60[] = "V6.0";
int           *base = 0;
char          *first;
char          *cmd;
int           cmdlen;
char          temp[256];

main()
{

  jpi_list.list.buflen = 8;
  jpi_list.list.item_code = SYI$_VERSION;
  jpi_list.list.buf_adr = version;
  jpi_list.list.retlenadr = &version_len;

  jpi_list.terminator = 0;

  status = sys$getsyiw( 0, 0, 0, &jpi_list, 0,0,0 );
  version[version_len] = 0;

  if ( strcmp( version, v40 ) >= 0 && strcmp( version, v50 ) < 0 )
    base = 0x7ffe350b;
  if ( strcmp( version, v50 ) >= 0 )
    base = 0x7ffe2d0b;
  if ( strcmp( version, v40 ) < 0 || strcmp( version, v60 ) >= 0 ) {
    printf( "VMS version %s not supported.\n", version );
    return;
  }

  first = *base;
  printf( "first command length at %x\n", first );
  cmdlen = *(first-1) + 256 * *(first);
  cmd = first - *(first-1) - 256 * *(first) - 1;
  printf( "first command at %x\n", cmd );
  strncpy( temp, cmd, cmdlen );
  temp[cmdlen] = 0;
  printf( "first command was %s\n", temp );
}

I hope this helps.

Mike Sieweke                           Internet: sysmike@colorm.gatech.edu
Georgia Tech Research Institute        Bitnet:   msieweke@gtri01
Atlanta, Georgia                       Usenet:   uunet!gatech!colorm!sysmike

