Beispiel #1
0
static efi_status_t
fw_efi_get_time (efi_time_t *tm, efi_time_cap_t *tc)
{
#if defined(CONFIG_IA64_HP_SIM) || defined(CONFIG_IA64_GENERIC)
	struct {
		int tv_sec;	/* must be 32bits to work */
		int tv_usec;
	} tv32bits;

	ssc((unsigned long) &tv32bits, 0, 0, 0, SSC_GET_TOD);

	memset(tm, 0, sizeof(*tm));
	offtime(tv32bits.tv_sec, tm);

	if (tc)
		memset(tc, 0, sizeof(*tc));
#else
#	error Not implemented yet...
#endif
	return EFI_SUCCESS;
}
Beispiel #2
0
main()
	{
	register int i;
	register struct passwd *pw;
	struct	itimerval it;
	u_char	c, xxx;
	int	len, tosslen;
	uid_t	uid;

	signal(SIGPIPE, SIG_DFL);
	for	(i = getdtablesize(); --i > 2; )
		close(i);
/*
 * Need a timer running while we disassociate from the control terminal
 * in case of a modem line which has lost carrier.
*/
	timerclear(&it.it_interval);
	it.it_value.tv_sec = 5;
	it.it_value.tv_usec = 0;
	signal(SIGALRM, timeout);
	setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
	if	(setjmp(env) == 0)
		{
		i = open("/dev/tty", 0);
		if	(i >= 0)
			{
			ioctl(i, TIOCNOTTY, NULL);
			close(i);
			}
		}
/*
 * Now start a timer with one minute refresh.  In the signal service
 * routine, check the parent process id to see if this process has
 * been orphaned and if so exit.  This is primarily aimed at removing
 * the 'ctimed' process left behind by 'sendmail's multi-fork startup
 * but may prove useful in preventing accumulation of 'ctimed' processes
 * in other circumstances as well.  Normally this process is short
 * lived.
*/
	it.it_interval.tv_sec = 60;
	it.it_interval.tv_usec = 0;
	it.it_value.tv_sec = 60;
	it.it_value.tv_usec = 0;
	signal(SIGALRM, checkppid);
	setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);

	while	(read(fileno(stdin), &c, 1) == 1)
		{
		switch	(c)
			{
			case	CTIME:
				l = 0L;
				getb(fileno(stdin), &l, sizeof l);
				cp = ctime(&l);
				write(fileno(stdout), cp, 26);
				break;
			case	ASCTIME:
				getb(fileno(stdin), &tmtmp, sizeof tmtmp);
				cp = asctime(&tmtmp);
				write(fileno(stdout), cp, 26);
				break;
			case	TZSET:
				(void) tzset();
				break;
			case	LOCALTIME:
				l = 0L;
				getb(fileno(stdin), &l, sizeof l);
				tp = localtime(&l);
				write(fileno(stdout), tp, sizeof (*tp));
				strcpy(junk, tp->tm_zone);
				junk[24] = '\0';
				write(fileno(stdout), junk, 24);
				break;
			case	GMTIME:
				l = 0L;
				getb(fileno(stdin), &l, sizeof l);
				tp = gmtime(&l);
				write(fileno(stdout), tp, sizeof (*tp));
				strcpy(junk, tp->tm_zone);
				junk[24] = '\0';
				write(fileno(stdout), junk, 24);
				break;
			case	OFFTIME:
				getb(fileno(stdin), &l, sizeof l);
				getb(fileno(stdin), &off, sizeof off);
#ifdef	__bsdi__
				l += off;
				tp = localtime(&l);
#else
				tp = offtime(&l, off);
#endif
				write(fileno(stdout), tp, sizeof (*tp));
				break;
			case	GETPWENT:
				pw = getpwent();
				do_pw(pw);
				break;
			case	GETPWNAM:
				getb(fileno(stdin), &len, sizeof (int));
				if	(len > UT_NAMESIZE)
					{
					tosslen = len - UT_NAMESIZE;
					len = UT_NAMESIZE;
					}
				else
					tosslen = 0;
				getb(fileno(stdin), junk, len);
				for	(;tosslen; tosslen--)
					getb(fileno(stdin), &xxx, 1);
				junk[len] = '\0';
				pw = getpwnam(junk);
				do_pw(pw);
				break;
			case	GETPWUID:
				getb(fileno(stdin), &uid, sizeof (uid_t));
				pw = getpwuid(uid);
				do_pw(pw);
				break;
			case	SETPASSENT:
				getb(fileno(stdin), &len, sizeof (int));
				if	(setpassent(len))
					len = 1;
				else
					len = 0;
				write(fileno(stdout), &len, sizeof (int));
				break;
			case	ENDPWENT:
				endpwent();
				break;
			default:
				abort("switch");
			}
		}
	}