fgetpos64.c

来自「Newlib 嵌入式 C库 标准实现代码」· C语言 代码 · 共 85 行

C
85
字号
/*FUNCTION<<fgetpos64>>---record position in a large stream or fileINDEX	fgetpos64INDEX	_fgetpos64_rANSI_SYNOPSIS	#include <stdio.h>	int fgetpos64(FILE *<[fp]>, _fpos64_t *<[pos]>);	int _fgetpos64_r(struct _reent *<[ptr]>, FILE *<[fp]>, 	                 _fpos64_t *<[pos]>);TRAD_SYNOPSIS	#include <stdio.h>	int fgetpos64(<[fp]>, <[pos]>)	FILE *<[fp]>;	_fpos64_t *<[pos]>;	int _fgetpos64_r(<[ptr]>, <[fp]>, <[pos]>)	FILE *<[fp]>;	_fpos64_t *<[pos]>;DESCRIPTIONObjects of type <<FILE>> can have a ``position'' that records how muchof the file your program has already read.  Many of the <<stdio>> functionsdepend on this position, and many change it as a side effect.You can use <<fgetpos64>> to report on the current position for a fileidentified by <[fp]> that was opened by <<fopen64>>; <<fgetpos>> will write a value representing that position at <<*<[pos]>>>.  Later, you canuse this value with <<fsetpos64>> to return the file to thisposition.In the current implementation, <<fgetpos64>> simply uses a charactercount to represent the file position; this is the same number thatwould be returned by <<ftello64>>.RETURNS<<fgetpos64>> returns <<0>> when successful.  If <<fgetpos64>> fails, theresult is <<1>>.  Failure occurs on streams that do not supportpositioning or streams not opened via <<fopen64>>; the global <<errno>> indicates these conditions with the value <<ESPIPE>>.PORTABILITY<<fgetpos64>> is a glibc extension.No supporting OS subroutines are required.*/#include <stdio.h>#ifdef __LARGE64_FILESint_DEFUN (_fgetpos64_r, (ptr, fp, pos),	struct _reent * ptr _AND	FILE * fp _AND	_fpos64_t * pos){  *pos = (_fpos64_t)_ftello64_r (ptr, fp);  if (*pos != -1)    {      return 0;    }  return 1;}#ifndef _REENT_ONLYint_DEFUN (fgetpos64, (fp, pos),	FILE * fp _AND	_fpos64_t * pos){  return _fgetpos64_r (_REENT, fp, pos);}#endif /* !_REENT_ONLY */#endif /* __LARGE64_FILES */

⌨️ 快捷键说明

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