forked from ansemjo/tinyssh-convert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileio.h
45 lines (33 loc) · 1.41 KB
/
fileio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* This file is governed by Licenses which are listed in
* the LICENSE file, which shall be included in all copies
* and redistributions of this project.
*
* For additional notices see the file fileio.c
*/
#ifndef _headerguard_fileio_h_
#define _headerguard_fileio_h_
#include <unistd.h>
#include <errno.h>
#include <poll.h>
#include <fcntl.h>
#include "errors.h"
#include "buffer.h"
/****************************************************************************************/
/* status codes are defined in statuscodes.h */
/* chunk at once before putting it into buffer struct */
#define FILEIO_CHUNKSIZE 1024
/****************************************************************************************/
/* open file descriptors */
extern int openwriting (const char *file);
extern int openreading (const char *file);
/* functions passable to io function (casting the const on write)*/
#define iowrite (ssize_t (*) (int, void *, size_t)) write
#define ioread /*(ssize_t (*) (int, void *, size_t))*/read
/* lowlevel io */
extern int io (ssize_t (*rw) (int, void *, size_t), int fd, void *data, size_t datalen, size_t *iolenptr);
/* load and save files to/from buffer */
extern int loadfile (const char *file, struct buffer **filebuf);
extern int savefile (const char *file, struct buffer *filebuf);
extern int savestring (const char *file, unsigned char *string, size_t stringlen);
#endif /* _headerguard_fileio_h_ */