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

📄 main.c

📁 tvapp用于播放tv程序
💻 C
📖 第 1 页 / 共 2 页
字号:
		}		/* skip the source and include directory lists */		skiplist(oldrefs);		skiplist(oldrefs);		/* get the number of source files */		if (fscanf(oldrefs, "%d", &nsrcfiles) != 1) {			posterr("cscope: cannot read source file size from file %s\n", reffile);			myexit(1);		}		/* get the source file list */		srcfiles = mymalloc(nsrcfiles * sizeof(char *));		if (fileversion >= 9) {			/* allocate the string space */			if (fscanf(oldrefs, "%d", &oldnum) != 1) {				posterr("cscope: cannot read string space size from file %s\n", reffile);				myexit(1);			}			s = (char *)mymalloc((unsigned) oldnum);			(void) getc(oldrefs);	/* skip the newline */						/* read the strings */			if (fread(s, oldnum, 1, oldrefs) != 1) {				posterr("cscope: cannot read source file names from file %s\n", reffile);				myexit(1);			}			/* change newlines to nulls */			for (i = 0; i < nsrcfiles; ++i) {				srcfiles[i] = s;				for (++s; *s != '\n'; ++s) {					;				}				*s = '\0';				++s;			}			/* if there is a file of source file names */			if ((namefile != NULL && (names = vpfopen(namefile, "r")) != NULL)			    || (names = vpfopen(NAMEFILE, "r")) != NULL) {					/* read any -p option from it */				while (fscanf(names, "%s", path) == 1 && *path == '-') {					i = path[1];					s = path + 2;		/* for "-Ipath" */					if (*s == '\0') {	/* if "-I path" */						(void) fscanf(names, "%s", path);						s = path;					}					switch (i) {					case 'p':	/* file path components to display */					    if (*s < '0' || *s > '9') {						posterr("cscope: -p option in file %s: missing or invalid numeric value\n", 								namefile);					    }					    dispcomponents = atoi(s);					}				}				(void) fclose(names);			}		}		else {			for (i = 0; i < nsrcfiles; ++i) {				if (fscanf(oldrefs, "%s", path) != 1) { 					posterr("cscope: cannot read source file name from file %s\n", reffile);					myexit(1);				}				srcfiles[i] = stralloc(path);			}		}		(void) fclose(oldrefs);	}	else {		/* save the file arguments */		fileargc = argc;		fileargv = argv;			/* get source directories from the environment */		if ((s = getenv("SOURCEDIRS")) != NULL) {			sourcedir(s);		}		/* make the source file list */		srcfiles = mymalloc(msrcfiles * sizeof(char *));		makefilelist();		if (nsrcfiles == 0) {			posterr( "cscope: no source files found\n");			myexit(1);		}		/* get include directories from the environment */		if ((s = getenv("INCLUDEDIRS")) != NULL) {			includedir(s);		}		/* add /usr/include to the #include directory list,		   but not in kernelmode... kernels tend not to use it. */		if (kernelmode == NO) {			includedir(DFLT_INCDIR);		}		/* initialize the C keyword table */		initsymtab();		/* Tell build.c about the filenames to create: */		setup_build_filenames(reffile);		/* build the cross-reference */		initcompress();		if (linemode == NO || verbosemode == YES)    /* display if verbose as well */                    postmsg("Building cross-reference...");		build();		if (linemode == NO )                    postmsg("");	/* clear any build progress message */		if (buildonly == YES) {			myexit(0);		}	}	opendatabase();	/* if using the line oriented user interface so cscope can be a 	   subprocess to emacs or samuel */	if (linemode == YES) {		if (*pattern != '\0') {		/* do any optional search */			if (search() == YES) {				while ((c = getc(refsfound)) != EOF) {					(void) putchar(c);				}			}		}		if (onesearch == YES) {			myexit(0);		}		for (;;) {			char buf[PATLEN + 2];						(void) printf(">> ");			(void) fflush(stdout);			if (fgets(buf, sizeof(buf), stdin) == NULL) {				myexit(0);			}			/* remove any trailing newline character */			if (*(s = buf + strlen(buf) - 1) == '\n') {				*s = '\0';			}			switch (*buf) {			case '0':			case '1':			case '2':			case '3':			case '4':			case '5':			case '6':			case '7':			case '8':			case '9':	/* samuel only */				field = *buf - '0';				(void) strcpy(pattern, buf + 1);				(void) search();				(void) printf("cscope: %d lines\n", totallines);				while ((c = getc(refsfound)) != EOF) {					(void) putchar(c);				}				break;			case 'c':	/* toggle caseless mode */			case ctrl('C'):				if (caseless == NO) {					caseless = YES;				}				else {					caseless = NO;				}				egrepcaseless(caseless);				break;			case 'r':	/* rebuild database cscope style */			case ctrl('R'):				freefilelist();				makefilelist();				/* FALLTHROUGH */			case 'R':	/* rebuild database samuel style */				rebuild();				(void) putchar('\n');				break;			case 'C':	/* clear file names */				freefilelist();				(void) putchar('\n');				break;			case 'F':	/* add a file name */				(void) strcpy(path, buf + 1);				if (infilelist(path) == NO &&				    (s = inviewpath(path)) != NULL) {					addsrcfile(s);				}				(void) putchar('\n');				break;			case 'q':	/* quit */			case ctrl('D'):			case ctrl('Z'):				myexit(0);			default:				(void) fprintf(stderr, "cscope: unknown command '%s'\n", buf);				break;			}		}		/* NOTREACHED */	}	/* pause before clearing the screen if there have been error messages */	if (errorsfound == YES) {		errorsfound = NO;		askforreturn();	}	/* do any optional search */	if (*pattern != '\0') {		atfield();		/* move to the input field */		(void) command(ctrl('Y'));	/* search */	}	/* read any symbol reference lines file */	else if (reflines != NULL) {		(void) readrefs(reflines);	}	display();		/* update the display */	for (;;) {		if (!selecting)			atfield();	/* move to the input field */		/* exit if the quit command is entered */		if ((c = mygetch()) == EOF || c == ctrl('D') || c == ctrl('Z')) {			break;		}		/* execute the commmand, updating the display if necessary */		if (command(c) == YES) {			display();		}		if (selecting)		{			move(displine[curdispline], 0);			refresh();		}	}	/* cleanup and exit */	myexit(0);	/* NOTREACHED */	return 0;		/* avoid warning... */}voidcannotopen(char *file){	posterr("Cannot open file %s", file);}voidcannotwrite(char *file){#if HAVE_SNPRINTF	char	msg[MSGLEN + 1];	(void) snprintf(msg, sizeof(msg),            "Removed file %s because write failed", file);#else	char *msg = mymalloc(50+strlen(file));	(void) sprintf(msg, "Removed file %s because write failed", file);#endif	myperror(msg);	/* display the reason */#if !HAVE_SNPRINTF	free(msg);#endif	(void) unlink(file);	myexit(1);	/* calls exit(2), which closes files */}/* set up the digraph character tables for text compression */static voidinitcompress(void){	int	i;		if (compress == YES) {		for (i = 0; i < 16; ++i) {			dicode1[(unsigned char) (dichar1[i])] = i * 8 + 1;		}		for (i = 0; i < 8; ++i) {			dicode2[(unsigned char) (dichar2[i])] = i + 1;		}	}}/* skip the list in the cross-reference file */static voidskiplist(FILE *oldrefs){	int	i;		if (fscanf(oldrefs, "%d", &i) != 1) {		posterr("cscope: cannot read list size from file %s\n", reffile);		myexit(1);	}	while (--i >= 0) {		if (fscanf(oldrefs, "%*s") != 0) {			posterr("cscope: cannot read list name from file %s\n", reffile);			myexit(1);		}	}}/* enter curses mode */voidentercurses(void){	incurses = YES;#ifndef __MSDOS__ /* HBB 20010313 */	(void) nonl();		/* don't translate an output \n to \n\r */#endif	(void) cbreak();	/* single character input */	(void) noecho();	/* don't echo input characters */	(void) clear();		/* clear the screen */	mouseinit();		/* initialize any mouse interface */	drawscrollbar(topline, nextline);}/* exit curses mode */voidexitcurses(void){	/* clear the bottom line */	(void) move(LINES - 1, 0);	(void) clrtoeol();	(void) refresh();	/* exit curses and restore the terminal modes */	(void) endwin();	incurses = NO;	/* restore the mouse */	mousecleanup();	(void) fflush(stdout);}/* normal usage message */static voidusage(void){	(void) fprintf(stderr, "Usage: cscope [-bcCdehklLqRTuUvV] [-f file] [-F file] [-i file] [-I dir] [-s dir]\n");	(void) fprintf(stderr, "              [-p number] [-P path] [-[0-8] pattern] [source files]\n");}/* long usage message */static voidlongusage(void){	(void) usage();	(void) fprintf(stderr, "\n");	(void) fprintf(stderr, "-b            Build the cross-reference only.\n");	(void) fprintf(stderr, "-C            Ignore letter case when searching.\n");	(void) fprintf(stderr, "-c            Use only ASCII characters in the cross-ref file (don't compress).\n");	(void) fprintf(stderr, "-d            Do not update the cross-reference.\n");	(void) fprintf(stderr, "-e            Suppress the <Ctrl>-e command prompt between files.\n");	(void) fprintf(stderr, "-F symfile    Read symbol reference lines from symfile.\n");	(void) fprintf(stderr, "-f reffile    Use reffile as cross-ref file name instead of %s.\n", REFFILE);	(void) fprintf(stderr, "-h            This help screen.\n");	(void) fprintf(stderr, "-I incdir     Look in incdir for any #include files.\n");	(void) fprintf(stderr, "-i namefile   Browse through files listed in namefile, instead of %s\n", NAMEFILE);	(void) fprintf(stderr, "-k            Kernel Mode - don't use %s for #include files.\n", DFLT_INCDIR);	(void) fprintf(stderr, "-L            Do a single search with line-oriented output.\n");	(void) fprintf(stderr, "-l            Line-oriented interface.\n");	(void) fprintf(stderr, "-num pattern  Go to input field num (counting from 0) and find pattern.\n");	(void) fprintf(stderr, "-P path       Prepend path to relative file names in pre-built cross-ref file.\n");	(void) fprintf(stderr, "-p n          Display the last n file path components.\n");	(void) fprintf(stderr, "-q            Build an inverted index for quick symbol searching.\n");	(void) fprintf(stderr, "-R            Recurse directories for files.\n");	(void) fprintf(stderr, "-s dir        Look in dir for additional source  files.\n");	(void) fprintf(stderr, "-T            Use only the first eight characters to match against C symbols.\n");	(void) fprintf(stderr, "-U            Check file time stamps.\n");	(void) fprintf(stderr, "-u            Unconditionally build the cross-reference file.\n");	(void) fprintf(stderr, "-v            Be more verbose in line mode.\n");	(void) fprintf(stderr, "-V            Print the version number.\n");	(void) fprintf(stderr, "\n");	(void) fprintf(stderr, "Please see the manpage for more information.\n");}/* cleanup and exit */voidmyexit(int sig){	/* HBB 20010313; close file before unlinking it. Unix may not care	 * about that, but DOS absolutely needs it */	if (refsfound != NULL)		fclose(refsfound);		/* remove any temporary files */	if (temp1[0] != '\0') {		(void) unlink(temp1);		(void) unlink(temp2);	}	/* restore the terminal to its original mode */	if (incurses == YES) {		exitcurses();	}	/* dump core for debugging on the quit signal */	if (sig == SIGQUIT) {		(void) abort();	}	/* HBB 20000421: be nice: free allocated data */	freefilelist();	freeinclist();	freesrclist();	freecrossref();	free_newbuildfiles();	exit(sig);}

⌨️ 快捷键说明

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