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

📄 ellec.c

📁 操作系统源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
 *		1 if full match, *		-1 if str1 runs out first (partial match) */ustrcmp(s1,s2)register char *s1, *s2;{	register int c;	if ( ! s1 || ! s2 ) return ( 0 );	/* Check for null ptr */	while(c = *s1++)	  { if(c != *s2)		  {	if(((c ^ *s2) != 040)			 || (upcase(c) != upcase(*s2)))				return(0);		  }		s2++;	  }	return(c == *s2 ? 1 : -1);}strueq(s1,s2)char *s1;char *s2;{	return (ustrcmp(s1, s2) > 0 ? 1 : 0);}/* Output C initialization code for default profile (defprf.c) */do_opcod(){	register int i, c, f;	printf("\/* This file defines the initial data for ELLE's default user profile.\n\** It is automatically generated by ELLEC, and should not be edited.\n\*/\n\char charmap[] = {\n");	for(i=0; i < chrcnt; i++)	  {	printf("\t%2d,",(f = chrptr[i]&0377));		printf("\t/* (%3o) %3s",i,charep(i));		printf("  %s",funname(f));		printf(" */\n");	  }	printf("};\n char metamap[] = {\n");	for(i = 0; i < mtacnt; i += 2)	  {	printf("\t0%-3o,%3d,",(c = mtaptr[i]&0377),(f = mtaptr[i+1]&0377));		printf("\t/* %4s",charep(c|CB_META));		printf("  %s",funname(f));		printf(" */\n");	  }	printf("};\n char extmap[] = {\n");	for(i = 0; i < extcnt; i += 2)	  {	printf("\t0%-3o,%3d,",(c = extptr[i]&0377),(f = extptr[i+1]&0377));		printf("\t/* %4s",charep(c|CB_EXT));		printf("  %s",funname(f));		printf(" */\n");	  }	printf("};\n");	printf("struct profile def_prof = {\n");	printf("  %d, /* Ver */\n", format_ver);	printf("  sizeof(charmap),   charmap,\n");	printf("  sizeof(metamap)/2, metamap,\n");	printf("  sizeof(extmap)/2,  extmap, \n");	printf("  0, 0\n");	printf("};\n");}/* Output ASCII version of default profile */int oerrs;do_opasc(){	register int i, c, f;	oerrs = 0;	printf("; ELLE default ASCII profile\n\n");	printf("(keyallunbind)  ; To flush all existing bindings\n\n");	for(i=0; i < chrcnt; i++)		outkbind(i, chrptr[i]&0377);	printf("\n; Meta chars\n\n");	for(i = 0; i < mtacnt; i += 2)		outkbind(CB_META | (mtaptr[i]&0377), mtaptr[i+1]&0377);	printf("\n ; Extended commands\n\n");	for(i = 0; i < extcnt; i += 2)		outkbind(CB_EXT | (extptr[i]&0377), extptr[i+1]&0377);	printf("\n");	if(oerrs)		fatal("%d errors encountered, check output file.", oerrs);}outkbind(c, fx){	if(fx == 0)		/* Allow key to be mapped to nothing. */		return;	if(fx <= 0 || fx > efxmax)		printf(";INTERNAL ERROR: Bad function index %d for key %s\n",			fx, charep(c));	else if(efuntab[fx].ef_name == NULL)		printf(";INTERNAL ERROR: No name for function %d while mapping key %s\n",			fx, charep(c));	else {	  	printf("(keybind %s \"%s\")\n",			qstr(charep(c)),efuntab[fx].ef_name);		return;	  }	oerrs++;}/* Output binary user profile */do_obprof(){	register unsigned int rp;	/* Relative "pointer" */	struct stored_profile st_prof;	rp = sizeof(st_prof);		/* Initialize */	/* Fixed by Kochin Chang, July 1995 */	/* format version should be the first field in compiled profile */	prof_pack(st_prof.version, format_ver);	prof_pack(st_prof.chrvec, rp);	prof_pack(st_prof.chrvcnt, chrcnt);	rp += chrcnt;	prof_pack(st_prof.metavec, rp);	prof_pack(st_prof.metavcnt, mtacnt/2);	rp += mtacnt;	prof_pack(st_prof.extvec, rp);	prof_pack(st_prof.extvcnt, extcnt/2);	rp += extcnt;	prof_pack(st_prof.menuvec, rp);	prof_pack(st_prof.menuvcnt, mnucnt);	rp += mnucnt;	fwrite((char *)&st_prof,sizeof(st_prof),1,stdout);	fwrite(chrptr,sizeof(char),chrcnt,stdout);	if(mtacnt)  fwrite(mtaptr, sizeof(*mtaptr), mtacnt, stdout);	if(extcnt)  fwrite(extptr, sizeof(*extptr), extcnt, stdout);	if(mnucnt) fwrite(mnuptr,sizeof(*mnuptr),mnucnt,stdout);}/* Return upper-case version of character */mupcase(ch)register int ch;{	return((ch&(~0177)) | upcase(ch));}upcase (ch){	register int c;	c = ch&0177;	return((('a' <= c) && (c <= 'z')) ? (c - ('a'-'A')) : c);}char *qstr(str)register char *str;{	register int c;	static char qstrbuf[100];	register char *cp;	cp = str;	while((c = *cp++) && islword(c));	if(c == 0) return(str);	/* No quoting needed */	cp = qstrbuf;	*cp++ = '"';	while(*cp++ = c = *str++)		if(c == '"') *cp++ = c;	/* Double the quotes */	cp[-1] = '"';	*cp = 0;	return(qstrbuf);}char *charep(c)register int c;{	static char chrbuf[10];	register char *cp;	cp = chrbuf;	if(c&CB_EXT)	  {	*cp++ = 'X';		*cp++ = '-';		c &= ~CB_EXT;	  }	if(c&CB_META)	  {	*cp++ = 'M';		*cp++ = '-';		c &= ~CB_META;	  }	if(c <= 037)	  {	*cp++ = '^';		c += 0100;	  }	if(c == 0177)	  {	*cp++ = 'D';		*cp++ = 'E';		*cp++ = 'L';	  }	else *cp++ = c;	*cp = 0;	return(chrbuf);}/* Output config Makefile (makecf.fun) *	If argument is 0 (NULL), does Makefile type output. *	Otherwise uses string for special-purpose output. */do_ocnf(str)char *str;{	register struct fun *fnp;	register int i, mi;	register char *cp;	int fmtab[EFUNMAX];	int nfmods;	char *modtab[EFUNMAX];	char *unknown = "unknown-module";	if(str == NULL)			/* If not V6 version */	  {	printf("# Function module definition file, generated by ELLEC\n");		printf("FUN_OFILES = ");	  }	nfmods = 0;	funcnt(fmtab);		/* Count function occs */	for(i = 1; i <= efxmax; ++i)	  {	if(fmtab[i] == 0) continue;		fnp = &efuntab[i];		if(fnp->ef_name == 0)			fatal("internal error - no name for function %d", i);				/* Got a function, store its module name if not a dup */		if ((cp = fnp->ef_mod) == NULL)	/* Substitute if undef */			cp = unknown;			for(mi=0; mi < nfmods; ++mi)			if(ustrcmp(cp, modtab[mi]) > 0)				break;		if(mi < nfmods) continue;		modtab[nfmods++] = cp;	  }	/* Now have table of all modules used.  Crunch them into output. */	for(mi=0; mi < nfmods; ++mi)	    if (modtab[mi] != unknown)	      {	if(str != NULL)		/* V6 version? */			printf("%s %s\n", str, modtab[mi]);		else printf("\\\n\t%s.o", modtab[mi]);	      }	printf("\n");}/* Output eefdef.h */do_ofcod(){	register struct fun *fnp;	register int i;	char temp[40];	int fmtab[EFUNMAX];	printf("/* .H Function Definition file, generated by ELLEC */\n");	printf("/*   0 */ EFUNHOLE /* Always undefined */\n");	funcnt(fmtab);		/* Count function occs */	for(i = 1; i <= efxmax ; ++i)	  {		fnp = &efuntab[i];		printf("/* %3d */ ", i);		if(fmtab[i] == 0 || fnp->ef_name == 0)			printf("EFUNHOLE\n");		else		  {	sprintf(temp, "\"%s\"", fnp->ef_adr);			printf("EFUN( %-12s, %-14s, \"%s\")\n", fnp->ef_adr,				temp, fnp->ef_name);		  }	  }}/* Output ascii version of function def file*/do_ofasc(){	register struct fun *fnp;	register int i;	register char *fa, *fm;	printf("; Master Function Definition file\n");	for(i = 1; i <= efxmax ; ++i)	  {		fnp = &efuntab[i];		if(fnp->ef_idx == 0)	/* No definition for this index? */			continue;		if(fnp->ef_name == 0)		  {	warn("internal error - no name for function %d", i);			continue;		  }		if ((fa = fnp->ef_adr) == NULL)			fa = "unknown-addr";		if ((fm = fnp->ef_mod) == NULL)			fm = "unknown-module";		printf("(efun %d \"%s\" %s %s)\n",			fnp->ef_idx, fnp->ef_name, fa, fm);	  }}/* Output eefidx.h */do_ofxcod(){	register struct fun *fnp;	register int i;	register char *cp, *cp2;	int fmtab[EFUNMAX];	char tmpstr[100];	printf("\/* .H Function Index Definition file, generated by ELLEC */\n");	printf("\/* FN_ defines Function Numbers (indices) for all known functions */\n");	printf("\/* FX_ defines Function eXistence in this ELLE configuration */\n");	funcnt(fmtab);		/* Count function occs */	for(i = 1; i <= efxmax ; ++i)	  {		fnp = &efuntab[i];		if(fnp->ef_idx == 0)	/* No definition for this index? */			continue;		if(fnp->ef_adr == 0 || fnp->ef_name == 0)		  {	warn("internal error - no addr/name for function %d", i);			continue;		  }		cp2 = fnp->ef_adr;		cp = tmpstr;		while(*cp++ = upcase(*cp2++));		cp = tmpstr;		if((*cp++ != 'F') || (*cp++ != '_'))			cp = tmpstr;		/* Always define FN_ as index */		printf("#define FN_%-14s %3d /* %s */\n",				cp, i, fnp->ef_name);		/* Define FX_ as 0 if unused, else same as FN_ */		printf("#define FX_%-14s %3d\n", cp,			(fmtab[i] == 0) ? 0 : i);	/* 0 if unused */	  }}/* Compile input! */compile_stdin(){	register struct lnode *lp;	while((lp = lread()) != NIL)		eval(lp);	return(1);}#define MAXLINE 300int llstch = -1;int leofflg;#define unlrch(c) llstch = cint lineno = 0;char linebuf[MAXLINE];char *linecp = linebuf;lrch(){	register int c;	if((c = llstch) >= 0)	  {	if(c == 0 && leofflg)			return(EOF);		llstch = -1;		return(c);	  }	if((c = getc(stdin)) == EOF)	  {	leofflg = 1;		llstch = 0;		*linecp = 0;		linecp = linebuf;		return(c);	  }	if(c == '\n')	  {	lineno++;		linecp = linebuf;	  }	else *linecp++ = c;	return(c);}struct lnode *lread(){	register int c;	register struct lnode *lp, *lp2;	struct lnode *head;	wspfls();	if((c = lrch())== EOF)		return(NIL);	if(c == ')')	/* End of a list? */		return(NIL);	if(c == '(')	/* Start of a list? */	  {	head = lp = getln();		lp->ltyp = LT_LIST;		if((head->lval.lvl = lp = lread()) == NIL)			return(head);	/* Return empty list */		while(lp2 = lread())		  {	lp->lnxt = lp2;			lp = lp2;		  }		return(head);	  }	/* Atom of some kind */	if(c=='"')	  {	return(lrstr(1));	  }	unlrch(c);	return(lrstr(0));}wspfls(){	register int c;	for(;;)	  {	c = lrch();		if(isspace(c)) continue;		if(c == ';')			while((c = lrch()) != '\n')				if(c == EOF) return;				break;	  }			if(c != EOF) unlrch(c);}#define LSMAX 300	/* Max # chars in atom string */struct lnode *lrstr(flg){	char cbuf[LSMAX];	register char *cp;	register int c, i;	struct lnode *lp;	cp = cbuf;	i = 0;	while((c = lrch()) != EOF)	  if (flg) switch(c)	  {	case '"':			if((c = lrch()) == EOF)				return(NIL);			if(c != '"')			  {	unlrch(c);				goto out;			  }		default:		ok:			if(++i > LSMAX)				break;

⌨️ 快捷键说明

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