cuserid.c
来自「操作系统源代码」· C语言 代码 · 共 34 行
C
34 行
/* cuserid(3) * * Author: Terrence W. Holm Sept. 1987 */#include <lib.h>#include <pwd.h>#include <string.h>#include <unistd.h>#include <stdio.h>#ifndef L_cuserid#define L_cuserid 9#endifchar *cuserid(user_name)char *user_name;{ PRIVATE char userid[L_cuserid]; struct passwd *pw_entry; if (user_name == (char *)NULL) user_name = userid; pw_entry = getpwuid(geteuid()); if (pw_entry == (struct passwd *)NULL) { *user_name = '\0'; return((char *)NULL); } strcpy(user_name, pw_entry->pw_name); return(user_name);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?