Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit bd8c84d7077981e3638812d623d565bec2cd5d68 created 11 years 9 months ago. By Werner Almesberger, ircstat/ML: April 2012 figures (belatedly - forgot to commit) | |
---|---|
1 | /* |
2 | * comm.h - Fakefile IPC functions |
3 | * |
4 | * Copyright 2012 by Werner Almesberger |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | */ |
11 | |
12 | #ifndef COMM_H |
13 | #define COMM_H |
14 | |
15 | #include <sys/types.h> |
16 | |
17 | |
18 | #define FAKEFILE_MASTER_OUT_VAR "FAKEFILE_MASTER_OUT" |
19 | #define FAKEFILE_MASTER_IN_VAR "FAKEFILE_MASTER_IN" |
20 | |
21 | |
22 | struct fakefile_peer; |
23 | struct fakefile_msg; |
24 | |
25 | struct fakefile_peer *fakefile_peer(int in, int out); |
26 | void fakefile_peer_close(struct fakefile_peer *peer); |
27 | int fakefile_peer_fd(const struct fakefile_peer *peer); |
28 | |
29 | struct fakefile_msg *fakefile_msg_new(struct fakefile_peer *peer, |
30 | int size); |
31 | struct fakefile_msg *fakefile_msg_recv(struct fakefile_peer *peer); |
32 | void fakefile_msg_end(struct fakefile_msg *msg); |
33 | |
34 | void fakefile_msg_add(struct fakefile_msg *msg, const void *buf, size_t len); |
35 | void fakefile_msg_get(struct fakefile_msg *msg, void *buf, size_t len); |
36 | |
37 | |
38 | #define decl_add(type) \ |
39 | static inline void fakefile_msg_add_##type( \ |
40 | struct fakefile_msg *msg, type value) \ |
41 | { \ |
42 | fakefile_msg_add(msg, &value, sizeof(value)); \ |
43 | } |
44 | |
45 | #define decl_get(type) \ |
46 | static inline type fakefile_msg_get_##type( \ |
47 | struct fakefile_msg *msg) \ |
48 | { \ |
49 | type value; \ |
50 | \ |
51 | fakefile_msg_get(msg, &value, sizeof(value)); \ |
52 | return value; \ |
53 | } |
54 | |
55 | #define decl_access(type) decl_add(type) decl_get(type) |
56 | |
57 | decl_access(int) |
58 | decl_access(size_t) |
59 | decl_access(ssize_t) |
60 | |
61 | #undef decl_add |
62 | #undef decl_get |
63 | #undef decl_access |
64 | |
65 | #endif /* !COMM_H */ |
66 |
Branches:
master