remove a machinedep function
This commit is contained in:
		
							parent
							
								
									099418e509
								
							
						
					
					
						commit
						86289e3609
					
				
							
								
								
									
										23
									
								
								rogue/init.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								rogue/init.c
									
									
									
									
									
								
							@ -46,6 +46,9 @@
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <unistd.h> /* getuid(2) */
 | 
			
		||||
#include <sys/types.h> /* <pwd.h> */
 | 
			
		||||
#include <pwd.h> /* getpwuid(3) */
 | 
			
		||||
 | 
			
		||||
#include "rogue.h"
 | 
			
		||||
 | 
			
		||||
@ -74,7 +77,6 @@ gid_t gid, egid;
 | 
			
		||||
int
 | 
			
		||||
init(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
	const char *pn;
 | 
			
		||||
	int seed;
 | 
			
		||||
	int fd;
 | 
			
		||||
 | 
			
		||||
@ -88,12 +90,21 @@ init(int argc, char *argv[])
 | 
			
		||||
	close(fd);
 | 
			
		||||
 | 
			
		||||
	seed = 0;
 | 
			
		||||
	pn = md_gln();
 | 
			
		||||
	if ((!pn) || (strlen(pn) >= MAX_OPT_LEN)) {
 | 
			
		||||
		clean_up("Hey!  Who are you?");
 | 
			
		||||
	{
 | 
			
		||||
		char *ps;
 | 
			
		||||
		struct passwd *p;
 | 
			
		||||
		if((p = getpwuid(getuid())) != NULL
 | 
			
		||||
				|| strlen(p->pw_name)
 | 
			
		||||
					>= (sizeof login_name)
 | 
			
		||||
						/ (sizeof *login_name))
 | 
			
		||||
			clean_up("Hey!  Who are you?");
 | 
			
		||||
		else
 | 
			
		||||
			ps = p->pw_name;
 | 
			
		||||
		strncpy(login_name, ps,
 | 
			
		||||
			(sizeof login_name)/(sizeof *login_name) - 1);
 | 
			
		||||
		login_name[(sizeof login_name)/(sizeof *login_name) - 1]
 | 
			
		||||
			= '\0';
 | 
			
		||||
	}
 | 
			
		||||
	/* LOGIN_NAME_SIZE == MAX_OPT_LEN now, but just in case... */
 | 
			
		||||
	(void)strlcpy(login_name, pn, sizeof(login_name));
 | 
			
		||||
 | 
			
		||||
	do_args(argc, argv);
 | 
			
		||||
	do_opts();
 | 
			
		||||
 | 
			
		||||
@ -294,25 +294,6 @@ md_df(const char *fname)
 | 
			
		||||
	return(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* md_gln: (Get login name)
 | 
			
		||||
 *
 | 
			
		||||
 * This routine returns the login name of the user.  This string is
 | 
			
		||||
 * used mainly for identifying users in score files.
 | 
			
		||||
 *
 | 
			
		||||
 * A dummy string may be returned if you are unable to implement this
 | 
			
		||||
 * function, but then the score file would only have one name in it.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
md_gln(void)
 | 
			
		||||
{
 | 
			
		||||
	struct passwd *p;
 | 
			
		||||
 | 
			
		||||
	if (!(p = getpwuid(getuid())))
 | 
			
		||||
		return NULL;
 | 
			
		||||
	return p->pw_name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* md_sleep:
 | 
			
		||||
 *
 | 
			
		||||
 * This routine causes the game to pause for the specified number of
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user