[comp.os.vms] GETUAI program example

SLOANE@UKANVAX.BITNET (Bob Sloane) (06/15/87)

John McMahon writes:

>Just out of curiosity, anyone have a piece of FORTRAN code which shows how to
>call the $GETUAI system service properly ?  I can't get the thing to return
>anything but nulls (or a bugcheck)...

The following FORTRAN program works at our site (VMS4.5). Of course you need
special permissions to use it on usernames other than your own.

                      Bob Sloane
                      University of Kansas
                      Computer Center
                      (913) 864-4291
                      SLOANE@UKANVAX on BITNET
c---------------------------------------------------------------------------
        program getacct
c
c        this program get the ACCOUNT name associated with the user name
c        specified on the command line
c
        character*12 user                                ! user name top query

        character*8  acct                                ! account name return
        integer*4    items(4)                            ! item list built here
        integer*4    sys$getuai                          ! type the function
        integer*4    status                              ! status returned here

        include '($UAIDEF)'                              ! define the UAI names

        status = lib$get_foreign( user, 'User :',user_l) ! get the username
        if ( .not. status ) call lib$stop(%VAL(status))

        items(1) = ISHFT(UAI$_ACCOUNT,16) .or. 8         ! getuai item code,len
        items(2) = %loc(acct)                            ! where to put it
        items(3) = 0                                     ! don't need the size
        items(4) = 0                                     ! end of list

        status = sys$getuai(,,user,items,,,)             ! get the account name
        if ( .not. status ) call lib$stop(%VAL(STATUS))  ! did we get it?

        type *, acct                                     ! write out the result
        stop
        end