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