diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 13:58:20 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 13:58:20 +0200 |
commit | 249866e3d1e11dc72eaa1305f4bb479ded92ef38 (patch) | |
tree | 7118c5f58e29fe61c100e4d067bb90ba8d52589e /src/seek.c | |
parent | 96cf8dffe4f7b0b910f790066ae622dc429eb522 (diff) |
reorganized file structure
Moved c files into src/.
Corrected VERSION file.
Removed BUILD and FILES.
Diffstat (limited to 'src/seek.c')
-rw-r--r-- | src/seek.c | 30 |
1 files changed, 30 insertions, 0 deletions
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 <sys/types.h> +#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); } |