Debian Codegraph @

src/clients/spdsend/spdsend.h

raw
1 /* Declarations for spdsend
2 Author: Milan Zamazal <[email protected]>
3 */
4
5 /* Copyright (C) 2004 Brailcom, o.p.s.
6
7 COPYRIGHT NOTICE
8
9 This program is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23 #ifndef __SPDSEND_H
24
25 #define __SPDSEND_H
26
27 #include <stddef.h>
28 #include <stdbool.h>
29
30 /* Configuration */
31
32 #ifndef LISTEN_QUEUE_LENGTH
33 #define LISTEN_QUEUE_LENGTH 100
34 #endif
35
36 /* Types */
37
38 typedef int Stream;
39 typedef int Connection_Id;
40
41 typedef enum { OK, ERROR } Success;
42 #define NONE -1
43
44 /* common.c */
45
46 extern Success write_data(Stream s, const void *buffer, size_t size);
47 extern int read_data(Stream s, void *buffer, size_t max_size);
48 extern Success forward_data(Stream from, Stream to, bool closep);
49
50 typedef enum { A_OPEN, A_CLOSE, A_DATA } Action;
51
52 typedef enum { OK_CODE, ER_CODE } Result;
53
54 extern const long CONNECTION_ID_MIN;
55 extern const long CONNECTION_ID_MAX;
56
57 extern const int EXIT_OK;
58 extern const int EXIT_ERROR;
59
60 /* server.c */
61
62 extern Stream open_server(void);
63
64 /* client.c */
65
66 extern Success open_connection(Stream server, const char *host, int port);
67 extern Success close_connection(Stream server, Connection_Id id);
68 extern Success send_command(Stream server, Connection_Id id);
69
70 #endif