- 论坛徽章:
- 0
|
网上找了些linux 命令的源代码来看,结果发现很多宏搞不清楚,自己也不知道如何去跟踪看,还望各位兄弟朋友指点指点,下面是who命令部分代码,
#if HAVE_STRUCT_XTMP_UT_PID
# define UT_PID(U) ((U)->ut_pid)
# define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \
char Var[INT_STRLEN_BOUND (Utmp_ent->ut_pid) + 1]; \
sprintf (Var, "%d", (int) (Utmp_ent->ut_pid))
#else
# define UT_PID(U) 0
# define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \
const char *Var = ""
#endif
#if HAVE_STRUCT_XTMP_UT_ID
# define UT_ID(U) ((U)->ut_id)
#else
/* Of course, sizeof "whatever" is the size of a pointer (often 4),
but that's ok, since the actual string has a length of only 2. */
# define UT_ID(U) "??"
#endif
#define UT_TYPE_UNDEF 255
#if HAVE_STRUCT_XTMP_UT_TYPE
# define UT_TYPE(U) ((U)->ut_type)
#else
# define UT_TYPE(U) UT_TYPE_UNDEF
#endif
#define IS_USER_PROCESS(U) \
(UT_USER (utmp_buf)[0] \
&& (UT_TYPE (utmp_buf) == USER_PROCESS \
|| (UT_TYPE (utmp_buf) == UT_TYPE_UNDEF \
&& UT_TIME_MEMBER (utmp_buf) != 0)))
先谢谢! |
|