home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 22063 < prev    next >
Encoding:
Text File  |  1993-01-27  |  1.4 KB  |  35 lines

  1. Path: sparky!uunet!europa.eng.gtefsd.com!gatech!paladin.american.edu!howland.reston.ans.net!spool.mu.edu!agate!doc.ic.ac.uk!uknet!miclon!nreadwin
  2. From: nreadwin@micrognosis.co.uk (Neil Readwin)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: Need C program to get default directory
  5. Message-ID: <C1J5CC.9zw@micrognosis.co.uk>
  6. Date: 27 Jan 93 20:38:35 GMT
  7. References: <1993Jan26.073901.1636@galaxy.gov.bc.ca>
  8. Sender: news@micrognosis.co.uk
  9. Organization: Micrognosis, a division of CSK(UK) Ltd
  10. Lines: 23
  11.  
  12. rforster@galaxy.gov.bc.ca (Russ Forster) writes:
  13. |>     I am looking for a very small VAXC routine to find the default
  14. |>     directory given a username.  All the GETUAI examples I've seen
  15. |>     have been ~100 lines.
  16.  
  17. One HUNDRED lines? Sheesh! Five lines to do it, one line to test it...
  18.  
  19. #include <descrip.h>
  20. #include <string.h>
  21. #include <uaidef.h>
  22.  
  23. char*g(char*u){char q[64];int retlen,st;struct dsc$descriptor_s u_d =
  24. {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0}; struct {short i,bl;int ba,ra,z;}it={64,
  25. UAI$_DEFDIR,q,&retlen,0};u_d.dsc$w_length=strlen(u); u_d.dsc$a_pointer=u;
  26. st=sys$getuai(0,0,&u_d,&it,0,0,0);if(!(st&1))return 0;u=malloc(q[0]);
  27. return u?(u[q[0]]=0,strncpy(u,&q[1],q[0])):u;}
  28.  
  29. main(int ac,char*av[]){if(ac>1){char*d=g(av[1]);printf("%s\n",d?d:"Unknown");}}
  30.  
  31. Run it using "MC SYS$DISK:[]foo.EXE username". Neil
  32. -- 
  33.  Phone: +44 71 815 5283  E-mail: nreadwin@micrognosis.co.uk
  34.  Anything is a cause for sorrow that my mind or body has made
  35.