当前位置: 首页 > news >正文

安防网站建设/沈阳网络seo公司

安防网站建设,沈阳网络seo公司,企业员工培训内容及计划,安徽网新科技网站建设介绍linux的who命令实际上是能通过读取utmp文件来获得相关的信息然后按格式输出来,很简单,主要用来了utmp结构,下面是他的描述struct utmp {short ut_type; /* type of login */pid_t ut_pid; /* PID of login proces…

linux的who命令实际上是能通过读取utmp文件来获得相关的信息

然后按格式输出来,很简单,主要用来了utmp结构,下面是他的描述

struct utmp {

short ut_type;              /* type of login */

pid_t ut_pid;               /* PID of login process */

char ut_line[UT_LINESIZE]; /* device name of tty - "/dev/" */

char ut_id[4];              /* init id or abbrev. ttyname */

char ut_user[UT_NAMESIZE]; /* user name */

char ut_host[UT_HOSTSIZE]; /* hostname for remote login */

struct exit_status ut_exit; /* The exit status of a process

marked as DEAD_PROCESS */

/* The ut_session and ut_tv fields must be the same size when

compiled 32- and 64-bit. This allows data files and shared

memory to be shared between 32- and 64-bit applications */

#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32

int32_t ut_session;         /* Session ID, used for windowing */

struct {

int32_t tv_sec;         /* Seconds */

int32_t tv_usec;        /* Microseconds */

} ut_tv;                    /* Time entry was made */

#else

long int ut_session;        /* Session ID, used for windowing */

struct timeval ut_tv;       /* Time entry was made */

#endif

int32_t ut_addr_v6[4];       /* IP address of remote host */

char __unused[20];           /* Reserved for future use */

};

具体的可以查看utmp.h文件,,实现就比较简单了,我就贴个源码算了,呵呵

#include #include #include

void showtime(long);

void show_info(struct utmp*);

int

main ( )

{

struct utmp utbuf;

FILE* fd;

int    rdnumber;

if ((fd=fopen(UTMP_FILE,"r"))==NULL )

{

perror(UTMP_FILE);

}

while (fread(&utbuf,sizeof(utbuf),1,fd)==1 )

show_info(&utbuf);

fclose(fd);

return 0;

}   /* ----- end of function main ----- */

void

show_info ( struct utmp* utbufp )

{

if ( utbufp->ut_type!=USER_PROCESS )

return;

printf("% -8.8s",utbufp->ut_name);

printf(" ");

printf("% -8.8s",utbufp->ut_line);

printf(" ");

showtime(utbufp->ut_time);

#ifdef SHOWHOST

if(utbufp->ut_host[0]!='\0')

printf("(%s)",utbufp->ut_host);

#endif

printf("\n");

}   /* ----- end of function show_info ----- */

void

showtime ( long timeval )

{

char* cp;

cp=ctime(&timeeval);

printf("%12.12s",cp+4);

}   /* ----- end of function showtime ----- */

http://www.lbrq.cn/news/1252621.html

相关文章:

  • 重庆招聘网/seo长尾关键词优化
  • 朝阳区网站建设推广seo/北京seo优化wyhseo
  • 网站建设佰金手指科杰二九/百度投放广告
  • 网站建设静态代码/天津seo招聘
  • 网站建设行业/什么是竞价
  • 网站建设公司 南宁/防恶意竞价点击软件
  • 做网站的靠什么挣钱/windows优化大师官方网站
  • 做一名网站编辑要具备什么资格/百度手机网页版入口
  • 销售人员报销网站开发费/站长统计app网站
  • 手机网站制作免费/谷歌浏览器官网下载手机版
  • 建网站需成本多少钱/金华关键词优化平台
  • 基于django电商网站开发课设报告/微信营销系统
  • 建设一个网站多少钱/白帽优化关键词排名seo
  • 用net做新闻网站/网站快速优化排名app
  • 做自己的网站怎么赚钱/长清区seo网络优化软件
  • 企业网站优化之如何做需求分析/新闻热点
  • 二级a做爰片免费网站/营销推广费用方案
  • 青岛公司建网站公司/超级seo外链工具
  • 购物网站建设流程/营销活动策划方案
  • 国外做宠物产品的网站/整合营销方案
  • 网站的面包屑怎么做的/怎么推广产品最有效
  • 网站建设规划方案模板/短视频seo推广
  • 上海做网站的公司多少钱/个人如何推广app
  • 一家专做中式设计的网站/百合seo培训
  • 网站建设 东道网络/推广链接点击器
  • 做网站开发一般用什么语言/太原seo公司
  • 大型网站建设建设公司/如何自己建个网站
  • 最近新闻报道/seo网络营销外包公司
  • 厚街做网站公司/搜索引擎优化工作
  • 网站建设方案怎么做/广州网站快速排名
  • vector使用模拟实现
  • Transwell 细胞迁移与侵袭实验:从原理到操作的详细指南
  • 简单spring boot项目,之前练习的,现在好像没有达到效果
  • Agent安全机制:权限控制与风险防范
  • linux定时器管理 timer_*系统调用及示例
  • Spring-rabbit使用实战六