]> git.saurik.com Git - redis.git/blame - src/rio.h
Version bumped to 2.9.5
[redis.git] / src / rio.h
CommitLineData
2e4b0e77
PN
1#ifndef __REDIS_RIO_H
2#define __REDIS_RIO_H
3
4#include <stdio.h>
5#include "sds.h"
6
7struct _rio {
4c046297 8 /* Backend functions.
9 * Since this functions do not tolerate short writes or reads the return
10 * value is simplified to: zero on error, non zero on complete success. */
2e4b0e77
PN
11 size_t (*read)(struct _rio *, void *buf, size_t len);
12 size_t (*write)(struct _rio *, const void *buf, size_t len);
13 off_t (*tell)(struct _rio *);
14
15 /* Backend-specific vars. */
16 union {
17 struct {
18 sds ptr;
19 off_t pos;
20 } buffer;
21 struct {
22 FILE *fp;
23 } file;
24 } io;
25};
26
27typedef struct _rio rio;
28
29#define rioWrite(rio,buf,len) ((rio)->write((rio),(buf),(len)))
30#define rioRead(rio,buf,len) ((rio)->read((rio),(buf),(len)))
31
f96a8a80 32void rioInitWithFile(rio *r, FILE *fp);
33void rioInitWithBuffer(rio *r, sds s);
2e4b0e77
PN
34
35size_t rioWriteBulkCount(rio *r, char prefix, int count);
36size_t rioWriteBulkString(rio *r, const char *buf, size_t len);
37size_t rioWriteBulkLongLong(rio *r, long long l);
38size_t rioWriteBulkDouble(rio *r, double d);
39
40#endif