The method is pretty identical from VAX to Alpha.  The differences
are in the offsets that DCL uses for its structures.

These can be obtained at link time from sys$system:dcldef.stb.
For example, the following DEC C code compiles on both VAX and
Alpha OpenVMS Systems, it is the link that defines the offsets
for DCL.  Thus his procedures would need to do link in DCLDEF.STB
as well as whatever else he links with.


/*
    Abstract:

        Get the users command as it was entered from the command 
        line with the 'case' of the characters unchanged.

    Build:

        $ CC /DECC /STANDARD=RELAX GETCMD
        $ IF vax
        $   then
        $       LINK GETCMD + SYS$SYSTEM:SYS.STB/SEL + DCLDEF/SEL
        $   else
        $       LINK /SYSEXE GETCMD + SYS$LOADABLE_IMAGES:DCLDEF.STB/SEL
        $ endif

    Author:

        Kenneth Blaylock  26-SEP-1995

*/

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

#pragma extern_model save
#pragma extern_model strict_refdef
extern char CTL$AG_CLIDATA ;
#pragma extern_model restore

#pragma extern_model save
#pragma extern_model globalvalue
extern int PPD$L_PRC ;
extern int PRC_L_RECALLPTR ;
extern int PRC_G_COMMANDS ;
extern int WRK_G_BUFFER ;
extern int WRK_G_INPBUF ;
extern int WRK_C_CMDBUFSIZ ;
extern int WRK_L_EXPANDPTR ;
extern int PRC_L_CURWRK ;
extern int PRC_W_PROCLEVEL ;

#pragma extern_model restore

#define GET_VALUE(__size,__ptr,__offset) \
        (*((__size *) ( __ptr + __offset) ) )

void copy_command ( char * user_command ) ;

main(int argc, char *argv[])
{

    char last_command[1024] ;

    copy_command( last_command ) ;

    printf("The last user command was: \"%s\"\n", last_command) ;

}

void copy_command ( char * user_command ) 
/*
    Copy the users command into the buffer.  Find the command
    in the recall buffer and trace backwards to the beginning
    of the command.
*/
{
    char *clidata, *prc, *commands_begin, *wrk ;
    char * rcl_ptr, command_size, *last_command ;

    clidata = &CTL$AG_CLIDATA ;
    prc = (char *) GET_VALUE(int, clidata, PPD$L_PRC ) ;

    if ( GET_VALUE( short, prc, PRC_W_PROCLEVEL) == 0) 
    {
        commands_begin = prc + PRC_G_COMMANDS ;
        rcl_ptr = (char *) GET_VALUE(int, prc, PRC_L_RECALLPTR);

        command_size = *(rcl_ptr - 1) ;

        last_command = rcl_ptr - command_size - 1 ;
    }
    else
    {
        /*
            We are reading from a command file of some sort.  Get the
            work buffer from the user.
        */
        wrk = (char *) GET_VALUE(int, prc, PRC_L_CURWRK ) ;

        last_command = wrk + WRK_G_INPBUF - 2;
        commands_begin = wrk + WRK_G_INPBUF - 2 ;
        command_size = strlen(commands_begin) ;

    }
    /*
        Note for this example that the wraping effect in the 
        command line recall buffer is not taken into account.
    */

    if (last_command >= commands_begin)
        memcpy(user_command, last_command, command_size) ;
    else
        command_size = 0 ;

    user_command[command_size] = '\0' ;

}
