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

📄 display.c

📁 tvapp用于播放tv程序
💻 C
📖 第 1 页 / 共 2 页
字号:
voidatchange(void){	move(PRLINE, (int) sizeof(selprompt) - 1);}/* search for the symbol or text pattern *//*ARGSUSED*/static RETSIGTYPEjumpback(int sig){	(void) sig;		/* 'use' sig, to avoid warning from compiler */	longjmp(env, 1);}BOOLsearch(void){	char	*subsystem;		/* OGS subsystem name */	char 	*book;			/* OGS book name */	char	file[PATHLEN + 1];	/* file name */	char	function[PATLEN + 1];	/* function name */	char	linenum[NUMLEN + 1];	/* line number */	char	*findresult = NULL;	/* find function output */	BOOL	funcexist = YES;		/* find "function" error */	FINDINIT rc = NOERROR;		/* findinit return code */	RETSIGTYPE	(*savesig)(int);		/* old value of signal */	FP	f;			/* searching function */	int	c, i;		/* open the references found file for writing */	if (writerefsfound() == NO) {		return(NO);	}	/* find the pattern - stop on an interrupt */	if (linemode == NO) {		postmsg("Searching");	}	searchcount = 0;	if (setjmp(env) == 0) {		savesig = signal(SIGINT, jumpback);		f = fields[field].findfcn;		if (f == findregexp || f == findstring) {			findresult = (*f)(pattern);		}		else {			if ((nonglobalrefs = myfopen(temp2, "wb")) == NULL) {				cannotopen(temp2);				return(NO);			}			if ((rc = findinit(pattern)) == NOERROR) {				(void) dbseek(0L); /* read the first block */				findresult = (*f)(pattern);				if (f == findcalledby) 					funcexist = (*findresult == 'y');				findcleanup();				/* append the non-global references */				(void) fclose(nonglobalrefs);				if ( (nonglobalrefs = myfopen(temp2, "rb")) == NULL) {				  cannotopen(temp2);				  return(NO);				}				while ((c = getc(nonglobalrefs)) != EOF) {					(void) putc(c, refsfound);				}			}			(void) fclose(nonglobalrefs);		}	}	signal(SIGINT, savesig);	/* rewind the cross-reference file */	(void) lseek(symrefs, (long) 0, 0);		/* reopen the references found file for reading */	(void) fclose(refsfound);	if ( (refsfound = myfopen(temp1, "rb")) == NULL) {		cannotopen(temp1);		return(NO);	}	nextline = 1;	totallines = 0;	disprefs = 0;		/* see if it is empty */	if ((c = getc(refsfound)) == EOF) {		if (findresult != NULL) {			(void) sprintf(lastmsg, "Egrep %s in this pattern: %s", 				findresult, pattern);		}		else if (rc == NOTSYMBOL) {			(void) sprintf(lastmsg, "This is not a C symbol: %s", 				pattern);		}		else if (rc == REGCMPERROR) {			(void) sprintf(lastmsg, "Error in this regcomp(3) regular expression: %s", 				pattern);					}		else if (funcexist == NO) {			(void) sprintf(lastmsg, "Function definition does not exist: %s", 				pattern);		}		else {			(void) sprintf(lastmsg, "Could not find the %s: %s", 				fields[field].text2, pattern);		}		return(NO);	}	/* put back the character read */	(void) ungetc(c, refsfound);	/* count the references found and find the length of the file,	   function, and line number display fields */	subsystemlen = 9;	/* strlen("Subsystem") */	booklen = 4;		/* strlen("Book") */	filelen = 4;		/* strlen("File") */	fcnlen = 8;		/* strlen("Function") */	numlen = 0;	while (fscanf(refsfound, "%s%s%s", file, function, linenum) == 3) {		if ((i = strlen(pathcomponents(file, dispcomponents))) > filelen) {			filelen = i;		}		if (ogs == YES) {			ogsnames(file, &subsystem, &book);			if ((i = strlen(subsystem)) > subsystemlen) {				subsystemlen = i;			}			if ((i = strlen(book)) > booklen) {				booklen = i;			}		}		if ((i = strlen(function)) > fcnlen) {			fcnlen = i;		}		if ((i = strlen(linenum)) > numlen) {			numlen = i;		}		/* skip the line text */		while ((c = getc(refsfound)) != EOF && c != '\n') {			;		}		++totallines;	}	rewind(refsfound);	return(YES);}/* display search progress with default custom format */voidprogress(char *what, long current, long max){	static	long	start;	long	now;	char	msg[MSGLEN + 1];	int	i;	/* save the start time */	if (searchcount == 0) {		start = time(NULL);	}	if ((now = time(NULL)) - start >= 1)	{		if (linemode == NO)		{			move(MSGLINE, 0);			clrtoeol();			addstr(what);			sprintf(msg, "%ld", current);			move(MSGLINE, (COLS / 2) - (strlen(msg) / 2));			addstr(msg);			sprintf(msg, "%ld", max);			move(MSGLINE, COLS - strlen(msg));			addstr(msg);			refresh();		}		else if (verbosemode == YES)		{			sprintf(msg, "> %s %ld of %ld", what, current, max);		}		start = now;		if ((linemode == NO) && (incurses == YES))		{			move(MSGLINE, 0);			i = (float)COLS * (float)current / (float)max;			standout();			for (; i > 0; i--)				addch(inch());			standend();			refresh();		}		else			if (linemode == NO || verbosemode == YES)				postmsg(msg);	}	++searchcount;}/* print error message on system call failure */voidmyperror(char *text) {	char	msg[MSGLEN + 1];	/* message */	char	*s;	s = "Unknown error";#ifdef HAVE_STRERROR        s = strerror(errno);#else	if (errno < sys_nerr) {		s = sys_errlist[errno];	}#endif	(void) sprintf(msg, "%s: %s", text, s);	postmsg(msg);}/* postmsg clears the message line and prints the message *//* VARARGS */voidpostmsg(char *msg) {	if (linemode == YES || incurses == NO) {		(void) printf("%s\n", msg);		fflush(stdout);	}	else {		move(MSGLINE, 0);		clrtoeol();		addstr(msg);		refresh();	}	(void) strncpy(lastmsg, msg, sizeof(lastmsg) - 1);}/* clearmsg2 clears the second message line */voidclearmsg2(void){	if (linemode == NO) {		move(MSGLINE + 1, 0);		clrtoeol();	}}/* postmsg2 clears the second message line and prints the message */voidpostmsg2(char *msg) {	if (linemode == YES) {		(void) printf("%s\n", msg);	}	else {		clearmsg2();		addstr(msg);	}}/* display an error mesg - stdout or on second msg line */voidposterr(char *msg, ...) {    va_list ap;    char errbuf[MSGLEN];        va_start(ap, msg);    if (linemode == YES || incurses == NO)    {        (void) vfprintf(stderr, msg, ap); 	(void) fputc('\n', stderr);    }    else    {#if HAVE_VSNPRINTF        vsnprintf(errbuf, sizeof(errbuf), msg, ap);#else        vsprintf(errbuf, msg, ap);#endif        postmsg2(errbuf);     }}/* position references found file at specified line */voidseekline(int line) {	int	c;	/* verify that there is a references found file */	if (refsfound == NULL) {		return;	}	/* go to the beginning of the file */	rewind(refsfound);		/* find the requested line */	nextline = 1;	while (nextline < line && (c = getc(refsfound)) != EOF) {		if (c == '\n') {			nextline++;		}	}}/* get the OGS subsystem and book names */voidogsnames(char *file, char **subsystem, char **book){	static	char	buf[PATHLEN + 1];	char	*s, *slash;	*subsystem = *book = "";	(void) strcpy(buf,file);	s = buf;	if (*s == '/') {		++s;	}	while ((slash = strchr(s, '/')) != NULL) {		*slash = '\0';		if ((int)strlen(s) >= 3 && strncmp(slash - 3, ".ss", 3) == 0) {			*subsystem = s;			s = slash + 1;			if ((slash = strchr(s, '/')) != NULL) {				*book = s;				*slash = '\0';			}			break;		}		s = slash + 1;	}}/* get the requested path components */char *pathcomponents(char *path, int components){	int	i;	char	*s;		s = path + strlen(path) - 1;	for (i = 0; i < components; ++i) {		while (s > path && *--s != '/') {			;		}	}	if (s > path && *s == '/') {		++s;	}	return(s);}/* open the references found file for writing */BOOLwriterefsfound(void){	if (refsfound == NULL) {		if ((refsfound = myfopen(temp1, "wb")) == NULL) {			cannotopen(temp1);			return(NO);		}	} else {		(void) fclose(refsfound);		if ( (refsfound = myfopen(temp1, "wb")) == NULL) {			postmsg("Cannot reopen temporary file");			return(NO);		}	}	return(YES);}

⌨️ 快捷键说明

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