⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wizard.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
字号:
#/*      Re-coding of advent in C: privileged operations                 */static char sccsid[] = "	wizard.c	4.1	82/05/11	";# include "hdr.h"datime(d,t)int *d,*t;{       int tvec[2],*tptr;	int *localtime();	time(tvec);	tptr=localtime(tvec);	*d=tptr[7]+365*(tptr[5]-77);    /* day since 1977  (mod leap)   */	/* bug: this will overflow in the year 2066 AD                  */	/* it will be attributed to Wm the C's millenial celebration    */	*t=tptr[2]*60+tptr[1];          /* and minutes since midnite    */}                                       /* pretty painless              */char *magic;poof(){       magic="dwarf";	latncy=45;}start(n){       int d,t,delay;	datime(&d,&t);	delay=(d-saved)*1440+(t-savet); /* good for about a month       */	if (delay>=latncy || setup >= 0)	{       saved= -1;		return(FALSE);	}	printf("This adventure was suspended a mere %d minutes ago.",delay);	if (delay<=latncy/3)	{       mspeak(2);		exit(0);	}	mspeak(8);	if (!wizard())	{       mspeak(9);		exit(0);	}	saved = -1;	return(FALSE);}wizard()                /* not as complex as advent/10 (for now)        */{       register int wiz;	char *word,*x;	if (!yesm(16,0,7)) return(FALSE);	mspeak(17);	getin(&word,&x);	if (!weq(word,magic))	{       mspeak(20);		return(FALSE);	}	mspeak(19);	return(TRUE);}ciao(cmdfile)char *cmdfile;{       register char *c;	register int outfd, size;	char fname[80], buf[512];	extern unsigned filesize;	lseek(datfd,(long)filesize,0);	for (;;)	{       printf("What would you like to call the saved version?\n");		for (c=fname;; c++)			if ((*c=getchar())=='\n') break;		*c=0;		if (save(cmdfile,fname)>=0) break;		printf("I can't use that one.\n");		return;	}	outfd=open(fname,1);	lseek(outfd,0L,2);                /* end of executable file       */	while ((size=read(datfd,buf,512))>0)		write(outfd,buf,size);  /* copy the message data        */	printf("                    ^\n");	printf("That should do it.  Gis revido.\n");	exit(0);}ran(range)                              /* uses unix rng                */int range;                              /* can't div by 32768 because   */{	long rand(), i;	i = rand() % range;	return(i);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -