lseek.c

来自「mips架构的bootloader,99左右的版本 但源代码现在没人更新了」· C语言 代码 · 共 44 行

C
44
字号
/************************************************************* * File: lib/lseek.c * Purpose: Part of C runtime library * Author: Phil Bunce (pjb@carmel.com) * Revision History: *	970304	Start of revision history */#include <termio.h>#include <errno.h>#include <unistd.h>/**************************************************************  lseek(fd,offset,whence)*/lseek(fd,offset,whence)int fd,whence;long offset;{Ramfile *p;if (fd < FILEOFFSET) {	/* can't seek on tty devices */	errno = EINVAL;	return(-1L);	}fd -= FILEOFFSET;if (_mfile[fd].open != 1) {	errno = EBADF;	return(-1L);	}p = &_mfile[fd];switch (whence) {	case SEEK_SET : p->posn = offset; break;	case SEEK_CUR : p->posn += offset; break;	case SEEK_END : p->posn = p->size + offset; break;	default : errno = EINVAL; return(-1L);	}return(p->posn);}

⌨️ 快捷键说明

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