Add fgetpos(3) and fsetpos(3).
This commit is contained in:
parent
3c94199720
commit
12947b0bdf
|
@ -203,10 +203,12 @@ fcloseall.o \
|
||||||
fcntl.o \
|
fcntl.o \
|
||||||
fddir-sortix.o \
|
fddir-sortix.o \
|
||||||
fdio.o \
|
fdio.o \
|
||||||
|
fgetpos.o \
|
||||||
fileno.o \
|
fileno.o \
|
||||||
fork.o \
|
fork.o \
|
||||||
fpipe.o \
|
fpipe.o \
|
||||||
freopen.o \
|
freopen.o \
|
||||||
|
fsetpos.o \
|
||||||
fsm_bootstraprootfd.o \
|
fsm_bootstraprootfd.o \
|
||||||
fsm_closechannel.o \
|
fsm_closechannel.o \
|
||||||
fsm_closeserver.o \
|
fsm_closeserver.o \
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
fgetpos.cpp
|
||||||
|
Get current file position information.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern "C" int fgetpos(FILE* restrict fp, fpos_t* restrict pos)
|
||||||
|
{
|
||||||
|
if ( (*pos = ftello(fp)) < 0 )
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
fsetpos.cpp
|
||||||
|
Set current file position.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern "C" int fsetpos(FILE* restrict fp, const fpos_t* restrict pos)
|
||||||
|
{
|
||||||
|
if ( fseeko(fp, *pos, SEEK_SET) < 0 )
|
||||||
|
return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -40,8 +40,7 @@ __BEGIN_DECLS
|
||||||
@include(NULL.h)
|
@include(NULL.h)
|
||||||
@include(FILE.h)
|
@include(FILE.h)
|
||||||
|
|
||||||
struct _fpos_t;
|
typedef off_t fpos_t;
|
||||||
typedef struct _fpos_t fpos_t;
|
|
||||||
|
|
||||||
/* TODO: Implement L_ctermid */
|
/* TODO: Implement L_ctermid */
|
||||||
#if __POSIX_OBSOLETE <= 200801
|
#if __POSIX_OBSOLETE <= 200801
|
||||||
|
@ -80,6 +79,7 @@ extern int ferror(FILE* stream);
|
||||||
extern int fflush(FILE* stream);
|
extern int fflush(FILE* stream);
|
||||||
extern int fileno(FILE* stream);
|
extern int fileno(FILE* stream);
|
||||||
extern int fgetc(FILE* stream);
|
extern int fgetc(FILE* stream);
|
||||||
|
extern int fgetpos(FILE* __restrict stream, fpos_t* __restrict pos);
|
||||||
extern char* fgets(char* __restrict s, int n, FILE* __restrict stream);
|
extern char* fgets(char* __restrict s, int n, FILE* __restrict stream);
|
||||||
extern FILE* fopen(const char* __restrict filename, const char* __restrict mode);
|
extern FILE* fopen(const char* __restrict filename, const char* __restrict mode);
|
||||||
extern int fprintf(FILE* __restrict stream, const char* __restrict format, ...);
|
extern int fprintf(FILE* __restrict stream, const char* __restrict format, ...);
|
||||||
|
@ -90,6 +90,7 @@ extern FILE* freopen(const char* __restrict filename, const char *__restrict mod
|
||||||
extern int fscanf(FILE* __restrict stream, const char* __restrict format, ... );
|
extern int fscanf(FILE* __restrict stream, const char* __restrict format, ... );
|
||||||
extern int fseek(FILE* stream, long offset, int whence);
|
extern int fseek(FILE* stream, long offset, int whence);
|
||||||
extern int fseeko(FILE* stream, off_t offset, int whence);
|
extern int fseeko(FILE* stream, off_t offset, int whence);
|
||||||
|
extern int fsetpos(FILE* stream, const fpos_t* pos);
|
||||||
extern long ftell(FILE* stream);
|
extern long ftell(FILE* stream);
|
||||||
extern off_t ftello(FILE* stream);
|
extern off_t ftello(FILE* stream);
|
||||||
extern size_t fwrite(const void* __restrict ptr, size_t size, size_t nitems, FILE* __restrict stream);
|
extern size_t fwrite(const void* __restrict ptr, size_t size, size_t nitems, FILE* __restrict stream);
|
||||||
|
@ -133,8 +134,6 @@ extern char* ctermid(char* s);
|
||||||
extern FILE *fmemopen(void* __restrict buf, size_t size, const char* __restrict mode);
|
extern FILE *fmemopen(void* __restrict buf, size_t size, const char* __restrict mode);
|
||||||
extern FILE* open_memstream(char** bufp, size_t* sizep);
|
extern FILE* open_memstream(char** bufp, size_t* sizep);
|
||||||
extern int dprintf(int fildes, const char* __restrict format, ...);
|
extern int dprintf(int fildes, const char* __restrict format, ...);
|
||||||
extern int fgetpos(FILE* __restrict stream, fpos_t* __restrict pos);
|
|
||||||
extern int fsetpos(FILE* stream, const fpos_t* pos);
|
|
||||||
extern int ftrylockfile(FILE* file);
|
extern int ftrylockfile(FILE* file);
|
||||||
extern int getchar_unlocked(void);
|
extern int getchar_unlocked(void);
|
||||||
extern int getc_unlocked(FILE* stream);
|
extern int getc_unlocked(FILE* stream);
|
||||||
|
|
Loading…
Reference in New Issue