Displaying Source Code(s)
|
|
implementing who am i using system calls
--------------------------------------------------------------------------------
Description : This program is used to implement the who am i
program using system calls(utmp struture)
#include<stdio.h>
#include<utmp.h>
int main()
{
char *s,*c;
struct utmp *u;
int i;
c=getlogin();
setutent();
u=getutent();
while(u!=NULL)
{
if(u->ut_type==7 && strcmp(u->ut_user,c)==0)
{
printf("%-12s",u->ut_user);
printf("%-9s",u->ut_line);
s=ctime(&u->ut_time);
for(i=4;i<16;i++)
printf("%c",s[i]);
printf("(%s",u->ut_host);
printf(")<BR>);
}
u=getutent();
}
}
|
|
|