Re: UID <-> Login name <-> Full name
Re: UID <-> Login name <-> Full name
- Subject: Re: UID <-> Login name <-> Full name
- From: Hasan Diwan <email@hidden>
- Date: Tue, 6 Aug 2002 13:43:22 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
#include <pwd.h>
#include <stdlib.h>
char *getFullName (uid_t t) {
static struct pw *p;
if (p) {
free(p);
p = malloc(sizeof(struct pw));
}
p = getpwuid(t);
return &(p->pw_gecos);
}
char *getLoginName (uid_t t) {
static struct pw *p;
if (p) {
free(p);
p = malloc(sizeof(struct pw));
}
p = getpwuid(t);
return &(p -> pw_name);
}
The two functions written above will return the "short name" (eg hdiwan
instead of "Hasan Diwan"). Also, getFullName(uid_t) will return the
whole gecos field, possibly more than the full name.
On Tuesday, August 6, 2002, at 04:23 PM, Pierre-Olivier Latour wrote:
Hi,
Is there any Cocoa, CoreFoundation or Unix function to map a UID to a
login
name, a login name to full name, etc?
I didn't find anything, and looking at the code of UNIX utilities like
"ps",
it seems the method to do this is quite complicated...
_____________________________________________________________
Pierre-Olivier Latour email@hidden
Lausanne, Switzerland http://www.pol-online.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
Hasan Diwan
OpenPGP KeyID: 0xBE42DCA6
Fingerprint: 1CB0 47E3 0A24 DAC1 DCCA 4225 F166 40C2 BE42 DCA6
http://hasandiwan.net/~hdiwan/gpg.key
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)
iD8DBQE9UArE8WZAwr5C3KYRAgvnAJ9DU80M2xCndsLqH/QaG7vbl/snmACfULZH
Pm1OkgA3doQ4yCAYuk9bP58=
=KIUc
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.