solved a problem with include files
This commit is contained in:
		
							parent
							
								
									141753d598
								
							
						
					
					
						commit
						45bffe9e26
					
				
					 2 changed files with 41 additions and 11 deletions
				
			
		|  | @ -1,8 +1,28 @@ | ||||||
| #define UTMPFILE "/etc/utmp" | #define UTMPFILE "/etc/utmp" | ||||||
| 
 | 
 | ||||||
| /* some systems require inclusion of sys/types.h before utmp.h */ | #ifdef USG | ||||||
| #include <sys/types.h> | struct utmp { | ||||||
| #include <utmp.h> | 	char ut_name[8]; | ||||||
|  | 	char ut_id[4]; | ||||||
|  | 	char ut_line[12]; | ||||||
|  | 	short ut_pid; | ||||||
|  | 	short ut_type; | ||||||
|  | 	struct exit_status { | ||||||
|  | 		short e_termination; | ||||||
|  | 		short e_exit; | ||||||
|  | 	} ut_exit; | ||||||
|  | 	long ut_time; | ||||||
|  | }; | ||||||
|  | #else | ||||||
|  | struct utmp { | ||||||
|  | 	char	ut_line[8]; | ||||||
|  | 	char	ut_name[8]; | ||||||
|  | #ifdef BSD4_2 | ||||||
|  | 	char	ut_host[16]; | ||||||
|  | #endif | ||||||
|  | 	long	ut_time; | ||||||
|  | }; | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| char * | char * | ||||||
| getlogin() | getlogin() | ||||||
|  |  | ||||||
|  | @ -1,11 +1,19 @@ | ||||||
| #ifdef USG | #ifdef USG | ||||||
| /* some systems require inclusion of sys/types.h before utmp.h */ |  | ||||||
| #include <sys/types.h> |  | ||||||
| #include <utmp.h> |  | ||||||
| 
 |  | ||||||
| /*	system V, so no /etc/ttys file. In this case, scan the
 | /*	system V, so no /etc/ttys file. In this case, scan the
 | ||||||
| 	/etc/utmp file | 	/etc/utmp file | ||||||
| */ | */ | ||||||
|  | struct utmp { | ||||||
|  | 	char ut_name[8]; | ||||||
|  | 	char ut_id[4]; | ||||||
|  | 	char ut_line[12]; | ||||||
|  | 	short ut_pid; | ||||||
|  | 	short ut_type; | ||||||
|  | 	struct exit_status { | ||||||
|  | 		short e_termination; | ||||||
|  | 		short e_exit; | ||||||
|  | 	} ut_exit; | ||||||
|  | 	long ut_time; | ||||||
|  | }; | ||||||
| #define FILENAME "/etc/utmp" | #define FILENAME "/etc/utmp" | ||||||
| #else | #else | ||||||
| #define FILENAME "/etc/ttys" | #define FILENAME "/etc/ttys" | ||||||
|  | @ -34,10 +42,12 @@ ttyslot() | ||||||
| 	if ((fd = open(FILENAME, 0)) < 0) return 0; | 	if ((fd = open(FILENAME, 0)) < 0) return 0; | ||||||
| #ifdef USG | #ifdef USG | ||||||
| 	while (read(fd, (char *) &buf, sizeof(buf)) == sizeof(buf)) { | 	while (read(fd, (char *) &buf, sizeof(buf)) == sizeof(buf)) { | ||||||
| 		if ((buf.ut_type == INIT_PROCESS || | 		/* processes associated with a terminal ...
 | ||||||
| 		     buf.ut_type == LOGIN_PROCESS || | 		   unfortunately we cannot use the include file because | ||||||
| 		     buf.ut_type == USER_PROCESS || | 		   some systems have a different one ... | ||||||
| 		     buf.ut_type == DEAD_PROCESS) && | 		   INIT_PROCESS, DEAD_PROCESS, USER_PROCESS, LOGIN_PROCESS | ||||||
|  | 		*/ | ||||||
|  | 		if ((buf.ut_type >= 5 && buf.ut_type <= 8) && | ||||||
| 		    ! strncmp(buf.ut_line, p, sizeof(buf.ut_line))) { | 		    ! strncmp(buf.ut_line, p, sizeof(buf.ut_line))) { | ||||||
| 			close(fd); | 			close(fd); | ||||||
| 			return retval; | 			return retval; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue