From 249866e3d1e11dc72eaa1305f4bb479ded92ef38 Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Tue, 9 Jul 2024 13:58:20 +0200 Subject: reorganized file structure Moved c files into src/. Corrected VERSION file. Removed BUILD and FILES. --- src/seek.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/seek.c (limited to 'src/seek.c') diff --git a/src/seek.c b/src/seek.c new file mode 100644 index 0000000..ac761a9 --- /dev/null +++ b/src/seek.c @@ -0,0 +1,30 @@ +#include +#include "seek.h" + +/** + @file seek.c + @author djb + @source qmail + @brief seek in an open file descritor +*/ + +off_t lseek(int fd,off_t offset,int whence); +int ftruncate(int fd, off_t length); + +#define CUR 1 /* sigh */ + +seek_pos seek_cur(int fd) +{ return lseek(fd,(off_t) 0,CUR); } + +#define END 2 /* sigh */ + +int seek_end(int fd) +{ if (lseek(fd,(off_t) 0,END) == -1) return -1; return 0; } + +#define SET 0 /* sigh */ + +int seek_set(int fd,seek_pos pos) +{ if (lseek(fd,(off_t) pos,SET) == -1) return -1; return 0; } + +int seek_trunc(int fd,seek_pos pos) +{ return ftruncate(fd,(off_t) pos); } -- cgit v1.2.3