Merging serial model from branch; converting to the hideous indentation style of...
[lwes-journaller.git] / src / queue.h
blobf6a412fa32c8a67f0495b2f47faf008640ac8576
1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
21 #ifndef QUEUE_DOT_H
22 #define QUEUE_DOT_H
24 #include <stddef.h>
26 /* Queue methods:
28 * open() -- opens a queue, return 0 on success, -1 on error
30 * close() -- closes a queue, return 0 on success, -1 on error
32 * read() -- reads "count" bytes from a queue into "buf", return the
33 * number of bytes read on success, -1 on error
35 * write() -- writes "count" bytes from "buf" to a queue, return the
36 * number of bytes written on success, -1 on error
38 * alloc() -- return a buffer suitable for use with read and write
40 * dealloc() -- free a buffer returned by alloc().
44 struct queue;
46 struct queue_vtbl {
47 void (*destructor) (struct queue* this_queue);
49 int (*open) (struct queue* this_queue, int flags);
50 int (*close) (struct queue* this_queue);
52 int (*read) (struct queue* this_queue, void* buf, size_t count, int* pending);
53 int (*write) (struct queue* this_queue, const void* buf, size_t count);
55 void* (*alloc) (struct queue* this_queue, size_t* newcount);
56 void (*dealloc) (struct queue* this_queue, void* buf);
59 struct queue {
60 struct queue_vtbl* vtbl;
61 void* priv;
64 int queue_factory(struct queue* this_queue);
65 typedef int (*lwes_journaller_queue_init_t)(struct queue*, const char*, size_t, size_t) ;
67 #endif /* QUEUE_DOT_H */