Rev | Line | |
---|
[9] | 1 | /* getlogin(3)
|
---|
| 2 | *
|
---|
| 3 | * Author: Terrence W. Holm Aug. 1988
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | #include <lib.h>
|
---|
| 7 | #include <pwd.h>
|
---|
| 8 | #include <unistd.h>
|
---|
| 9 | #include <string.h>
|
---|
| 10 | #include <stdio.h>
|
---|
| 11 |
|
---|
| 12 | #ifndef L_cuserid
|
---|
| 13 | #define L_cuserid 9
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | char *getlogin()
|
---|
| 17 | {
|
---|
| 18 | PRIVATE char userid[L_cuserid];
|
---|
| 19 | struct passwd *pw_entry;
|
---|
| 20 |
|
---|
| 21 | pw_entry = getpwuid(getuid());
|
---|
| 22 |
|
---|
| 23 | if (pw_entry == (struct passwd *)NULL) return((char *)NULL);
|
---|
| 24 |
|
---|
| 25 | strcpy(userid, pw_entry->pw_name);
|
---|
| 26 |
|
---|
| 27 | return(userid);
|
---|
| 28 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.