× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Jim Knight wrote:
> [ Picked text/plain from multipart/alternative ]
> Does anyone have a method for retrieving the "home" directory of
> a user?  The QSYRUSI api shows that it can be retrieved, but I
> can not get it to return anything.  On V5/R1.
> Jim Knight

Assuming you're using RPG, the following might be useful; first  some
variables and a prototype for you to /copy in:

  *--------------------------------------------------------------------
  * The Unix-type API getpwnam(), which returns user information
  *--------------------------------------------------------------------
 D pPasswd         S               *
 D passwd          DS                  based(pPasswd)
  *       The structure returned by the API
 D  pName                          *
  *       User name
 D  uid                          10U 0
  *       User ID
 D  gid                          10U 0
  *       Group ID
 D  pHomeDir                       *
  *       Initial working directory
 D  pShell                         *
  *       Initial user program

  *--------------------------------------------------------------------

 D getpwnam        PR              *   extproc('getpwnam')
 D  pUser                          *   value options(*string)

  *--------------------------------------------------------------------

And now, a procedure that uses it:

  * -------------------------------------------------------------------
  * Returns the home directory of the specified user.
 P GetHomeDir      B                   export
 D GetHomeDir      PI           256A
 D  user                         10A
  * -------------------------------------------------------------------

  * -------------------------------------------------------------------
  * The API returns a pointer to a structure; everything necessary
  * to use it is defined in the MRAPIPROCS include member.
 C                   eval      pPasswd = getpwnam(%addr(user))

  * The structure contains pointers; these point to null-terminated
  * strings; to use these, we must extract the string using the
  * appropriate bif.
 C                   return    %str(pHomeDir)

  * -------------------------------------------------------------------
 P GetHomeDir      E
  * -------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.