亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? file.c

?? 早期freebsd實現
?? C
字號:
/* * Copyright (c) 1994 David I. Bell * Permission is granted to use, distribute, or modify this source, * provided that this copyright notice remains intact. * * File I/O routines callable by users. */#include "stdarg.h"#include "calc.h"#define	READSIZE	1024	/* buffer size for reading *//* * Definition of opened files. */typedef struct {	FILEID id;		/* id to identify this file */	FILE *fp;		/* real file structure for I/O */	char *name;		/* file name */	BOOL reading;		/* TRUE if opened for reading */	BOOL writing;		/* TRUE if opened for writing */	char *mode;		/* open mode */} FILEIO;/* * Table of opened files. * The first three entries always correspond to stdin, stdout, and stderr, * and cannot be closed.  Their file ids are always 0, 1, and 2. */static FILEIO files[MAXFILES] = {	FILEID_STDIN,  NULL,  "(stdin)",  TRUE, FALSE, "reading",	FILEID_STDOUT, NULL, "(stdout)", FALSE, TRUE, "writing",	FILEID_STDERR, NULL, "(stderr)", FALSE, TRUE, "writing"};static FILEID lastid = FILEID_STDERR;		/* last allocated file id *//* * file_init - perform needed initilization work * * On some systems, one cannot initialize a pointer to a FILE *. * This routine, called once at startup is a work-a-round for * systems with such bogons. */voidfile_init(){    static int done = 0;	/* 1 => routine already called */    if (!done) {	files[0].fp = stdin;	files[1].fp = stdout;	files[2].fp = stderr;	done = 1;    }}/* * Open the specified file name for reading or writing as determined by * the specified mode ("r", "w", or "a").  Returns a file id which can be * used to do I/O to the file, or else FILEID_NONE if the open failed. * Aborts with an error if too many files are opened or the mode is illegal. */FILEIDopenid(name, mode)	char *name;		/* file name */	char *mode;		/* open mode */{	FILEIO *fiop;		/* file structure */	FILEID id;		/* new file id */	int count;	if (((*mode != 'r') && (*mode != 'w') && (*mode != 'a')) || mode[1])		math_error("Illegal mode for fopen");	count = MAXFILES;	do {		if (--count < 0)			math_error("Too many open files");		id = ++lastid;		fiop = &files[id % MAXFILES];	} while (fiop->reading || fiop->writing);	fiop->name = (char *)malloc(strlen(name) + 1);	if (fiop->name == NULL) {		lastid--;		math_error("No memory for filename");	}	strcpy(fiop->name, name);	fiop->fp = f_open(name, mode);	if (fiop->fp == NULL) {		free(fiop->name);		fiop->name = NULL;		lastid--;		return FILEID_NONE;	}	switch (*mode) {		case 'r':			fiop->mode = "reading";			fiop->reading = TRUE;			break;		case 'w':			fiop->mode = "writing";			fiop->writing = TRUE;			break;		case 'a':			fiop->mode = "appending";			fiop->writing = TRUE;			break;	}	fiop->id = id;	return id;}/* * Find the file I/O structure for the specified file id, and verify that * it is opened in the required manner ('r' for reading or 'w' for writing). * If mode is 0, then no open checks are made at all, and NULL is then * returned if the id represents a closed file. */static FILEIO *findid(id, mode)	int mode;	FILEID id;{	FILEIO *fiop;		/* file structure */	static char *msg;	BOOL flag = 0;	if ((id < 0) || (id > lastid))		math_error("Illegal file id");	fiop = &files[id % MAXFILES];	switch (mode) {		case 'r':			msg = "Reading from";			flag = fiop->reading;			break;		case 'w':			msg = "Writing to";			flag = fiop->writing;			break;		case 0:			msg = NULL;			break;		default:			math_error("Unknown findid mode");	}	if (fiop->id != id) {		if (msg)			math_error("%s closed file", msg);		return NULL;	}	if (msg && !flag)		math_error("%s file not opened that way", msg);		return fiop;}/* * Return whether or not a file id is valid.  This is used for if tests. */BOOLvalidid(id)	FILEID id;{	return (findid(id, 0) != NULL);}/* * Return the file id for the entry in the file table at the specified index. * Returns FILEID_NONE if the index is illegal or the file is closed. */FILEIDindexid(index)	long index;{	FILEIO *fiop;		/* file structure */	if ((index < 0) || (index >= MAXFILES))		return FILEID_NONE;	fiop = &files[index];	if (fiop->reading || fiop->writing)		return fiop->id;	return FILEID_NONE;}/* * Close the specified file id.  Returns TRUE if there was an error. * Closing of stdin, stdout, or stderr is illegal, but closing of already * closed files is allowed. */BOOLcloseid(id)	FILEID id;{	FILEIO *fiop;		/* file structure */	int err;	if ((id == FILEID_STDIN) || (id == FILEID_STDOUT) ||		(id == FILEID_STDERR))			math_error("Cannot close stdin, stdout, or stderr");	fiop = findid(id, 0);	if (fiop == NULL)		return FALSE;	fiop->id = FILEID_NONE;	if (!fiop->reading && !fiop->writing)		math_error("Closing non-opened file");	fiop->reading = FALSE;	fiop->writing = FALSE;	if (fiop->name)		free(fiop->name);	fiop->name = NULL;	err = ferror(fiop->fp);	err |= fclose(fiop->fp);	fiop->fp = NULL;	return (err != 0);}/* * Return whether or not an error occurred to a file. */BOOLerrorid(id)	FILEID id;{	FILEIO *fiop;		/* file structure */	fiop = findid(id, 0);	if (fiop == NULL)		math_error("Closed file for ferror");	return (ferror(fiop->fp) != 0);}/* * Return whether or not end of file occurred to a file. */BOOLeofid(id)	FILEID id;{	FILEIO *fiop;		/* file structure */	fiop = findid(id, 0);	if (fiop == NULL)		math_error("Closed file for feof");	return (feof(fiop->fp) != 0);}/* * Flush output to an opened file. */voidflushid(id)	FILEID id;{	FILEIO *fiop;		/* file structure */	fiop = findid(id, 'w');	fflush(fiop->fp);}/* * Read the next line from an opened file. * Returns a pointer to an allocated string holding the null-terminated * line (without any terminating newline), or else a NULL pointer on an * end of file or error. */voidreadid(id, retptr)	FILEID	id;		/* file to read from */	char **retptr;		/* returned pointer to string */{	FILEIO *fiop;		/* file structure */	char *str;		/* current string */	int len;		/* current length of string */	int totlen;		/* total length of string */	char buf[READSIZE];	/* temporary buffer */	totlen = 0;	str = NULL;	fiop = findid(id, 'r');	while (fgets(buf, READSIZE, fiop->fp) && buf[0]) {		len = strlen(buf);		if (totlen)			str = (char *)realloc(str, totlen + len + 1);		else			str = (char *)malloc(len + 1);		if (str == NULL)			math_error("No memory in freadline");		strcpy(&str[totlen], buf);		totlen += len;		if (buf[len - 1] == '\n') {			str[totlen - 1] = '\0';			*retptr = str;			return;		}	}	if (totlen && ferror(fiop->fp)) {		free(str);		str = NULL;	}	*retptr = str;}/* * Return the next character from an opened file. * Returns EOF if there was an error or end of file. */intgetcharid(id)	FILEID id;{	return fgetc(findid(id, 'r')->fp);}/* * Print out the name of an opened file. * If the file has been closed, a null name is printed. * If flags contain PRINT_UNAMBIG then extra information is printed * identifying the output as a file and some data about it. */voidprintid(id, flags)	int flags;	FILEID id;{	FILEIO *fiop;		/* file structure */	FILE *fp;	fiop = findid(id, 0);	if (fiop == NULL) {		math_str((flags & PRINT_UNAMBIG) ? "FILE (closed)" : "\"\"");		return;	}	if ((flags & PRINT_UNAMBIG) == 0) {		math_chr('"');		math_str(fiop->name);		math_chr('"');		return;	}	fp = fiop->fp;	math_fmt("FILE \"%s\" (%s, pos %ld", fiop->name,  fiop->mode,		ftell(fp));	if (ferror(fp))		math_str(", error");	if (feof(fp))		math_str(", eof");	math_chr(')');}/* * Print a formatted string similar to printf.  Various formats of output * are possible, depending on the format string AND the actual types of the * values.  Mismatches do not cause errors, instead something reasonable is * printed instead.  The output goes to the file with the specified id. */voididprintf(id, fmt, count, vals)	int count;	FILEID id;			/* file id to print to */	char *fmt;			/* standard format string */	VALUE **vals;			/* table of values to print */{	FILEIO *fiop;	VALUE *vp;	char *str;	int ch, len;	int oldmode, newmode;	long olddigits, newdigits;	long width, precision;	BOOL didneg, didprecision;	fiop = findid(id, 'w');	math_setfp(fiop->fp);	while ((ch = *fmt++) != '\0') {		if (ch == '\\') {			ch = *fmt++;			switch (ch) {				case 'n': ch = '\n'; break;				case 'r': ch = '\r'; break;				case 't': ch = '\t'; break;				case 'f': ch = '\f'; break;				case 'v': ch = '\v'; break;				case 'b': ch = '\b'; break;				case 0:					math_setfp(stdout);					return;			}			math_chr(ch);			continue;		}		if (ch != '%') {			math_chr(ch);			continue;		}		/*		 * Here to handle formats.		 */		didneg = FALSE;		didprecision = FALSE;		width = 0;		precision = 0;		ch = *fmt++;		if (ch == '-') {			didneg = TRUE;			ch = *fmt++;		}		while ((ch >= '0') && (ch <= '9')) {			width = width * 10 + (ch - '0');			ch = *fmt++;		}		if (ch == '.') {			didprecision = TRUE;			ch = *fmt++;			while ((ch >= '0') && (ch <= '9')) {				precision = precision * 10 + (ch - '0');				ch = *fmt++;			}		}		if (ch == 'l')			ch = *fmt++;		oldmode = _outmode_;		newmode = oldmode;		olddigits = _outdigits_;		newdigits = olddigits;		if (didprecision)			newdigits = precision;		switch (ch) {			case 'd':			case 's':			case 'c':				break;			case 'f':				newmode = MODE_REAL;				break;			case 'e':				newmode = MODE_EXP;				break;			case 'r':				newmode = MODE_FRAC;				break;			case 'o':				newmode = MODE_OCTAL;				break;			case 'x':				newmode = MODE_HEX;				break;			case 'b':				newmode = MODE_BINARY;				break;			case 0:				math_setfp(stdout);				return;			default:				math_chr(ch);				continue;		}		if (--count < 0)			math_error("Not enough arguments for fprintf");		vp = *vals++;		math_setdigits(newdigits);		math_setmode(newmode);		/*		 * If there is no width specification, or if the type of		 * value requires multiple lines, then just output the		 * value directly.		 */		if ((width == 0) ||			(vp->v_type == V_MAT) || (vp->v_type == V_LIST))		{			printvalue(vp, PRINT_NORMAL);			math_setmode(oldmode);			math_setdigits(olddigits);			continue;		}		/*		 * There is a field width.  Collect the output in a string,		 * print it padded appropriately with spaces, and free it.		 * However, if the output contains a newline, then ignore		 * the field width.		 */		math_divertio();		printvalue(vp, PRINT_NORMAL);		str = math_getdivertedio();		if (strchr(str, '\n'))			width = 0;		len = strlen(str);		while (!didneg && (width > len)) {			width--;			math_chr(' ');		}		math_str(str);		free(str);		while (didneg && (width > len)) {			width--;			math_chr(' ');		}		math_setmode(oldmode);		math_setdigits(olddigits);	}	math_setfp(stdout);}/* END CODE */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精一区二区三区| 国产精品久久久久毛片软件| 亚洲黄一区二区三区| av不卡在线观看| 亚洲色图20p| 欧美三级蜜桃2在线观看| 亚洲成在人线免费| 欧美一区二区三区四区久久 | 国产一区二区三区不卡在线观看| 精品少妇一区二区三区| 成人永久免费视频| 亚洲黄色免费电影| 欧美精品在线观看一区二区| 免费观看在线综合色| 久久久久亚洲综合| 91欧美激情一区二区三区成人| 亚洲一区免费观看| 精品成人一区二区三区| 波多野结衣精品在线| 亚洲国产精品久久一线不卡| 91精品免费观看| 国产一区二区精品久久91| 一区在线播放视频| 欧美另类久久久品| 国产精品888| 亚洲一区二区三区四区五区黄| 91精品蜜臀在线一区尤物| 国产在线麻豆精品观看| 亚洲色图在线视频| 精品少妇一区二区三区在线视频| 成人av手机在线观看| 午夜久久久久久久久| 国产欧美日产一区| 欧美日韩视频在线第一区| 国产麻豆精品久久一二三| 一区二区三区在线免费播放| 欧美大胆一级视频| 色诱亚洲精品久久久久久| 激情综合色综合久久综合| 亚洲欧美日韩国产另类专区| 精品久久人人做人人爽| 欧美午夜免费电影| 国产成人自拍在线| 日韩电影一区二区三区四区| 国产精品成人一区二区艾草| 欧美绝品在线观看成人午夜影视| 国产成a人无v码亚洲福利| 亚洲18女电影在线观看| 国产片一区二区| 在线播放国产精品二区一二区四区 | 精品国产百合女同互慰| 欧美做爰猛烈大尺度电影无法无天| 国产一区在线看| 奇米色一区二区三区四区| 亚洲精品免费视频| 国产精品人妖ts系列视频| 日韩欧美一二三四区| 欧美午夜在线观看| 99re这里只有精品6| 国产精品综合av一区二区国产馆| 一区二区久久久| 中文字幕亚洲成人| 中文字幕精品一区| 亚洲精品一区在线观看| 日韩一区二区中文字幕| 欧美精品粉嫩高潮一区二区| 一本久久a久久精品亚洲| 成人av午夜电影| 成人午夜伦理影院| 成人免费高清在线观看| 国产成人一区二区精品非洲| 精品一区二区三区蜜桃| 精品一区二区三区视频在线观看| 午夜影视日本亚洲欧洲精品| 亚洲成人一区二区| 亚洲国产精品久久一线不卡| 亚洲国产欧美另类丝袜| 亚洲国产综合色| 亚洲一区二区精品3399| 一区二区三区欧美激情| 亚洲黄网站在线观看| 亚洲一区二区三区免费视频| 一区二区三区中文字幕电影| 亚洲精品大片www| 夜夜亚洲天天久久| 亚洲成av人片在www色猫咪| 亚洲国产美女搞黄色| 五月综合激情日本mⅴ| 免费日韩伦理电影| 狠狠色丁香久久婷婷综合_中 | 色呦呦日韩精品| 在线观看亚洲一区| 欧美日高清视频| 91精品午夜视频| 精品成a人在线观看| 欧美激情在线看| 亚洲欧美日韩中文字幕一区二区三区 | 一区二区三区欧美日| 午夜精品免费在线观看| 蜜臀av性久久久久蜜臀aⅴ四虎| 美腿丝袜一区二区三区| 国产成人午夜片在线观看高清观看| 丰满放荡岳乱妇91ww| 91成人看片片| 日韩一级欧美一级| 国产精品女同一区二区三区| 一区二区三区鲁丝不卡| 麻豆精品国产91久久久久久| 风间由美性色一区二区三区| 91浏览器在线视频| 日韩一区国产二区欧美三区| 欧美韩国日本综合| 亚洲va中文字幕| 精品一区二区三区日韩| 91蝌蚪porny| 在线不卡中文字幕| 国产精品麻豆久久久| 亚洲一区二区三区小说| 国产一区二区在线免费观看| 一本到高清视频免费精品| 日韩一级二级三级精品视频| 国产精品三级久久久久三级| 亚洲一级电影视频| 国产成人午夜精品影院观看视频| 日本道免费精品一区二区三区| 日韩欧美一区二区三区在线| 亚洲天堂免费看| 激情综合网av| 欧美日韩三级一区| 国产精品色哟哟| 免费观看一级欧美片| 色婷婷精品大在线视频| 久久久一区二区三区| 五月婷婷综合激情| 91在线小视频| 久久夜色精品国产噜噜av| 午夜精品爽啪视频| 99久久国产免费看| 久久久久99精品国产片| 日本vs亚洲vs韩国一区三区二区| 99久久99久久精品免费观看| 精品日韩成人av| 三级精品在线观看| 91成人免费在线视频| 欧美国产精品一区| 黄色日韩三级电影| 欧美一区二区三区啪啪| 亚洲电影一区二区三区| 91美女在线观看| 国产精品美女视频| 国产一区二区91| 日韩精品一区国产麻豆| 日韩一区欧美二区| 欧美日韩亚洲国产综合| 亚洲人成亚洲人成在线观看图片 | 国产精品久久久久永久免费观看 | 91国偷自产一区二区三区观看| 久久精品一区二区| 精品一区二区av| 欧美一区二区视频网站| 亚洲超碰精品一区二区| 色呦呦日韩精品| 亚洲女厕所小便bbb| 99精品视频中文字幕| 国产精品美女久久久久久久| 国产一本一道久久香蕉| 精品国产乱码久久久久久闺蜜| 首页综合国产亚洲丝袜| 91麻豆精品久久久久蜜臀| 天堂成人国产精品一区| 538在线一区二区精品国产| 香蕉加勒比综合久久 | 制服丝袜在线91| 日韩av在线发布| 91精品国产综合久久精品| 日韩精品高清不卡| 日韩欧美精品在线| 国产麻豆精品久久一二三| 中文子幕无线码一区tr| 99视频一区二区| 亚洲三级久久久| 欧美日韩在线直播| 免播放器亚洲一区| 久久精品亚洲麻豆av一区二区 | 国产精品乡下勾搭老头1| 国产亚洲1区2区3区| voyeur盗摄精品| 一区二区成人在线| 欧美疯狂性受xxxxx喷水图片| 青青草成人在线观看| 亚洲精品一区二区三区在线观看| 国产伦精一区二区三区| 中文字幕一区二区三区不卡在线| 91免费版在线| 日本va欧美va精品发布| 国产日产欧美一区| 欧美性大战xxxxx久久久| 美女网站视频久久| 国产精品久久久久久久第一福利| 色激情天天射综合网|