gcrypt: Add support for RFC4716 private keys.
[paraslash.git] / recv.h
1 /* Copyright (C) 2005 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file recv.h Receiver-related structures and exported symbols of recv_common.c. */
4
5 /**
6  * Describes one instance of a receiver.
7  */
8 struct receiver_node {
9         /** Points to the corresponding receiver. */
10         const struct receiver *receiver;
11         /** Receiver-specific data. */
12         void *private_data;
13         /** The parsed command line options for this instance. */
14         struct lls_parse_result *lpr;
15         /** The task associated with this instance. */
16         struct task *task;
17         /** The receiver node is always the root of the buffer tree. */
18         struct btr_node *btrn;
19         /** Each receiver node maintains a buffer pool for the received data. */
20         struct btr_pool *btrp;
21         /**
22          * The file descriptor to receive the stream.
23          *
24          * The pre_select function of the receiver adds this file descriptor to
25          * the set of file descriptors which are watched for readability or
26          * writability, depending on the state of the connection (if any).
27          *
28          * If \a fd is readable, the post_select function of the receiver reads
29          * data from this fd into the buffer pool area of \a btrp.
30          *
31          * \sa \ref receiver.
32          */
33         int fd;
34 };
35
36 /**
37  * Describes one supported paraslash receiver.
38  *
39  * \sa \ref http_recv.c, \ref udp_recv.c.
40  */
41 struct receiver {
42         /**
43          * The optional receiver init function.
44          *
45          * Performs any initialization needed before the receiver can be opened.
46          */
47         void (*init)(void);
48         /**
49          * Open one instance of the receiver.
50          *
51          * This should allocate the output buffer of the given receiver node
52          * and prepare it for retrieving the audio stream according to the
53          * configuration stored in rn->lpr.
54          *
55          * \sa struct \ref receiver_node.
56          */
57         int (*open)(struct receiver_node *rn);
58         /**
59          * Close this instance of the receiver.
60          *
61          * It should free all resources associated with given receiver node
62          * that were allocated during the corresponding open call.
63          *
64          * \sa \ref receiver_node.
65          */
66         void (*close)(struct receiver_node *rn);
67         /**
68          * Add file descriptors to fd_sets and compute timeout for select(2).
69          *
70          * If this is not NULL, the function is called in each iteration of the
71          * scheduler's select loop. The receiver may define it to add file
72          * descriptors to the file descriptor sets given by s. Those will be
73          * monitored in the subsequent call to select(2). The function may also
74          * lower the timeout value of s to make select(2) return earlier if no
75          * file descriptors are ready for I/O.
76          *
77          * \sa select(2), \ref time.c, struct \ref sched.
78          */
79         void (*pre_select)(struct sched *s, void *context);
80         /**
81          * Evaluate the result from select(2).
82          *
83          * This is called after the call to select(2). It should check all file
84          * descriptors which were added to any of the fd sets in the previous
85          * call to ->pre_select() and perform (non-blocking) I/O operations on
86          * those fds which are ready for I/O, for example in order to establish
87          * a connection or to receive a part of the audio stream.
88          *
89          * \sa select(2), struct \ref receiver.
90          */
91         int (*post_select)(struct sched *s, void *context);
92         /**
93          * Answer a buffer tree query.
94          *
95          * This optional function pointer allows for inter node communication
96          * of the buffer tree nodes. See \ref btr_command_handler for details.
97          */
98         btr_command_handler execute;
99 };
100
101 #define RECV_CMD(_num) (lls_cmd(_num, recv_cmd_suite))
102
103 #define RECV_CMD_OPT_RESULT(_recv, _opt, _lpr) \
104         (lls_opt_result(LSG_RECV_CMD_ ## _recv ## _OPT_ ## _opt, _lpr))
105 #define RECV_CMD_OPT_GIVEN(_recv, _opt, _lpr) \
106         (lls_opt_given(RECV_CMD_OPT_RESULT(_recv, _opt, _lpr)))
107 #define RECV_CMD_OPT_STRING_VAL(_recv, _opt, _lpr) \
108         (lls_string_val(0, RECV_CMD_OPT_RESULT(_recv, _opt, _lpr)))
109 #define RECV_CMD_OPT_UINT32_VAL(_recv, _opt, _lpr) \
110         (lls_uint32_val(0, RECV_CMD_OPT_RESULT(_recv, _opt, _lpr)))
111 #define RECV_CMD_OPT_INT32_VAL(_recv, _opt, _lpr) \
112         (lls_int32_val(0, RECV_CMD_OPT_RESULT(_recv, _opt, _lpr)))
113
114 /** Iterate over all available receivers. */
115 #define FOR_EACH_RECEIVER(i) for (i = 1; lls_cmd(i, recv_cmd_suite); i++)
116
117 void recv_init(void);
118 int check_receiver_arg(const char *ra, struct lls_parse_result **lprp);
119 void print_receiver_helps(bool detailed);
120 int generic_recv_pre_select(struct sched *s, struct receiver_node *rn);