Article 157417 of comp.os.vms:
Jim Tsetsos <jtse@ozemail.com.au> writes:

>> Can someone please provide me wirh a simple call using the
>> sys$getuai system service routine to extract the user
>> default device and default directory.

yes.

#include <stdio.h>
#include <string.h>
#include <descrip.h>
#include <uaidef.h>
#include <starlet.h>
#include <lib$routines.h>

struct vmsitemlist {
        unsigned short vi_buflen;
        unsigned short vi_code;
        void *vi_bufadr;
        void *vi_lenadr;
};

int GetLoginPath(char *username, char *path)
{
        long r0;
        int succeeded;
        int tmplen;
        char defdev[1+31+1];
        char defdir[1+63+1];
        struct vmsitemlist thelist[3];
        struct dsc$descriptor_s usersd;

        usersd.dsc$b_dtype = DSC$K_DTYPE_T;
        usersd.dsc$b_class = DSC$K_CLASS_S;
        usersd.dsc$a_pointer = username;
        usersd.dsc$w_length = strlen(username);
        thelist[0].vi_buflen = sizeof(defdev) - 1;
        thelist[0].vi_code   = UAI$_DEFDEV;
        thelist[0].vi_bufadr = defdev;
        thelist[0].vi_lenadr = NULL;
        thelist[1].vi_buflen = sizeof(defdir) - 1;
        thelist[1].vi_code   = UAI$_DEFDIR;
        thelist[1].vi_bufadr = defdir;
        thelist[1].vi_lenadr = NULL;
        thelist[2].vi_buflen = 0;
        thelist[2].vi_code   = 0;
        r0 = sys$getuai(NULL, NULL, &usersd, &thelist[0], NULL, NULL, NULL);
        if ((r0 & 1) == 1) {
                tmplen = (int) defdev[0];  memcpy(path, &defdev[1], tmplen);  path += tmplen;
                tmplen = (int) defdir[0];  memcpy(path, &defdir[1], tmplen);  path += tmplen;
                succeeded = TRUE;
        }
        else {
                lib$signal(r0, 0);
                succeeded = FALSE;
        }
        *path = '\0';

        return(succeeded);
}

ok
dpm
-- 
David P. Murphy             mailto:murphy@connor.datametrics.com     (work)
systems programmer          mailto:dpm@access.digex.net          (personal)
                            http://www.access.digex.net/~dpm
COGITO ERGO DISCLAIMUM       ftp://ftp.access.digex.net/pub/access/dpm


