int main(){ struct utmp *utbufp, *utmp_next(); if(utmp_open(UTMP_FILE) == -1){ perror(UTMP_FILE); exit(1); } while((utbufp = utmp_next()) != ((struct tmp *)NULL)) show_info(utbufp); utmp_close(); return 0; }
int main(void) { struct utmp *utbufp, /* holds pointer to next rec */ *utmp_next(); /* returns pointer to next */ if ( utmp_open( UTMP_FILE ) == -1 ) { perror( UTMP_FILE ); exit(1); } while ((utbufp = utmp_next()) != ((struct utmp *)NULL)) show_info( utbufp ); utmp_close(); return 0; }
int main() { struct utmp * utbufp, // holds pointer to next rec * utmp_nex(); // returns pointer to next if (utmp_open(UTMP_FILE) == -1) { perror(UTMP_FILE); // UTMP_FILE is in utmp.h exit(1); } while ((utbufp = utmp_next()) != ((struct utmp *)NULL)) { // printf("%d %d\n", reclen, utmpfd); show_info(utbufp); } utmp_close(); return 0; // went ok }
int main( ) { struct utmp* utbufp, * utmp_next( ); if ( utmp_open( UTMP_FILE ) == -1 ) { perror( UTMP_FILE ); exit( 1 ); } while ( ( utbufp = utmp_next( ) ) != ( (struct utmp*)NULL )) show_info( utbufp ); utmp_close( ); return 0; /* struct utmp current_record; */ /* int utmpfd; */ /* int reclen = sizeof( current_record ); */ /* if ( ( utmpfd = open( UTMP_FILE, O_RDONLY ) ) == -1 ) */ /* { */ /* perror( UTMP_FILE ); */ /* exit( 1 ); */ /* } */ /* while ( read( utmpfd, ¤t_record, reclen ) == reclen ) */ /* { */ /* show_info( ¤t_record ); */ /* } */ /* close( utmpfd ); */ /* return 0; */ }