|
Thanks. That's the info I was looking for. Did not account for variable length processing. Jim K -----Original Message----- From: McCallion, Martin [mailto:martin.mccallion@misys.com] Sent: Friday, May 17, 2002 3:02 AM To: 'midrange-l@midrange.com' Subject: RE: \home directory 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 * ------------------------------------------------------------------- _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l or email: MIDRANGE-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
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.