aboutsummaryrefslogtreecommitdiffstats
path: root/rb.h
blob: f519d5a846fe5da8803389a0de784063141e054f (plain)
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
46
47
48
49
50
51
52
53
/* ==========================================================================
    Licensed under BSD 2clause license. See LICENSE file for more information
    Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
   ========================================================================== */


#ifndef LIBRB_H
#define LIBRB_H 1

#include <stddef.h>

#ifndef MSG_PEEK
#define MSG_PEEK 2
#endif

#ifndef O_NONBLOCK
#define O_NONBLOCK 00004000
#endif

#ifndef MSG_DONTWAIT
#define MSG_DONTWAIT 0x40
#endif

#define O_MULTITHREAD 0x10000000L
struct rb;

#define rb_array_size(a) (sizeof(a)/sizeof(*(a)))

struct rb *rb_new(size_t count, size_t object_size, unsigned long flags);
struct rb *rb_init(size_t count, size_t object_size, unsigned long flags,
    void *mem);
long rb_read(struct rb *rb, void *buffer, size_t count);
long rb_recv(struct rb *rb, void *buffer, size_t count, unsigned long flags);
long rb_write(struct rb *rb, const void *buffer, size_t count);
long rb_send(struct rb *rb, const void *buffer, size_t count,
    unsigned long flags);
long rb_posix_read(struct rb *rb, int fd, size_t count);
long rb_posix_recv(struct rb *rb, int fd, size_t count, unsigned long flags);
long rb_posix_write(struct rb *rb, int fd, size_t count);
long rb_posix_send(struct rb *rb, int fd, size_t count, unsigned long flags);

int rb_clear(struct rb *rb, int clear);
int rb_destroy(struct rb *rb);
int rb_cleanup(struct rb *rb);
int rb_stop(struct rb *rb);
int rb_stop_signal(struct rb *rb, int signum);
long rb_discard(struct rb *rb, size_t count);
const char *rb_version(char *major, char *minor, char *patch);
long rb_count(struct rb *rb);
long rb_space(struct rb *rb);
size_t rb_header_size(void);

#endif