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

📄 fdopen.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
/* * Posix stdio -- fdopen */#include "iolib.h"/* * Open the named file with the given mode, using the given FILE * Legal modes are given below, `additional characters may follow these sequences': * r rb		open to read * w wb		open to write, truncating * a ab		open to write positioned at eof, creating if non-existant * r+ r+b rb+	open to read and write, creating if non-existant * w+ w+b wb+	open to read and write, truncating * a+ a+b ab+	open to read and write, positioned at eof, creating if non-existant. */FILE *fdopen(const int fd, const char *mode){	FILE *f;		qlock(&_stdiolk);	for(f=_IO_stream;f!=&_IO_stream[FOPEN_MAX];f++)		if(f->state==CLOSED)			break;	if(f==&_IO_stream[FOPEN_MAX]) {		qunlock(&_stdiolk);		return NULL;	}	f->fd=fd;	if(mode[0]=='a')		seek(f->fd, 0L, 2);	if(f->fd==-1) return NULL;	f->flags=0;	f->state=OPEN;	f->buf=0;	f->rp=0;	f->wp=0;	f->lp=0;	qunlock(&_stdiolk);	return f;}

⌨️ 快捷键说明

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