diff options
Diffstat (limited to 'src/microspdy/daemon.h')
-rw-r--r-- | src/microspdy/daemon.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/src/microspdy/daemon.h b/src/microspdy/daemon.h new file mode 100644 index 00000000..d3f7f2ff --- /dev/null +++ b/src/microspdy/daemon.h | |||
@@ -0,0 +1,121 @@ | |||
1 | /* | ||
2 | This file is part of libmicrospdy | ||
3 | Copyright (C) 2012 Andrey Uzunov | ||
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 3 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, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /** | ||
20 | * @file daemon.h | ||
21 | * @brief daemon functionality | ||
22 | * @author Andrey Uzunov | ||
23 | */ | ||
24 | |||
25 | #ifndef DAEMON_H | ||
26 | #define DAEMON_H | ||
27 | |||
28 | #include "platform.h" | ||
29 | |||
30 | |||
31 | /** | ||
32 | * Start a SPDDY webserver on the given port. | ||
33 | * | ||
34 | * @param port port to bind to | ||
35 | * @param certfile path to the certificate that will be used by server | ||
36 | * @param keyfile path to the keyfile for the certificate | ||
37 | * @param nscb callback called when a new SPDY session is | ||
38 | * established by a client | ||
39 | * @param sccb callback called when a client closes the session | ||
40 | * @param nrcb callback called when a client sends request | ||
41 | * @param npdcb callback called when HTTP POST params are received | ||
42 | * after request | ||
43 | * @param fnscb callback called when new stream is opened by a client | ||
44 | * @param cls extra argument to all of the callbacks without those | ||
45 | * specific only for the framing layer | ||
46 | * @param fcls extra argument to all of the callbacks, specific only for | ||
47 | * the framing layer (those vars starting with 'f'). | ||
48 | * @param valist va_list of options (type-value pairs, | ||
49 | * terminated with SPDY_DAEMON_OPTION_END). | ||
50 | * @return NULL on error, handle to daemon on success | ||
51 | */ | ||
52 | struct SPDY_Daemon * | ||
53 | SPDYF_start_daemon_va (uint16_t port, | ||
54 | const char *certfile, | ||
55 | const char *keyfile, | ||
56 | SPDY_NewSessionCallback nscb, | ||
57 | SPDY_SessionClosedCallback sccb, | ||
58 | SPDY_NewRequestCallback nrcb, | ||
59 | SPDY_NewPOSTDataCallback npdcb, | ||
60 | SPDYF_NewStreamCallback fnscb, | ||
61 | void * cls, | ||
62 | void * fcls, | ||
63 | va_list valist); | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Run webserver operations (without blocking unless | ||
68 | * in client callbacks). This method must be called in the client event | ||
69 | * loop. | ||
70 | * | ||
71 | * @param daemon daemon to run | ||
72 | */ | ||
73 | void | ||
74 | SPDYF_run (struct SPDY_Daemon *daemon); | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Obtain timeout value for select for this daemon. The returned value | ||
79 | * is how long select | ||
80 | * should at most block, not the timeout value set for connections. | ||
81 | * | ||
82 | * @param daemon daemon to query for timeout | ||
83 | * @param timeout set to the timeout (in seconds) | ||
84 | * @return SPDY_YES on success, SPDY_NO if no connections exist that | ||
85 | * would necessiate the use of a timeout right now | ||
86 | */ | ||
87 | int | ||
88 | SPDYF_get_timeout (struct SPDY_Daemon *daemon, | ||
89 | unsigned long long *timeout); | ||
90 | |||
91 | |||
92 | /** | ||
93 | * Obtain the select sets for this daemon. The idea of SPDYF_get_fdset | ||
94 | * is to return such descriptors that the select in the application can | ||
95 | * return and SPDY_run can be called only when this is really needed. | ||
96 | * That means not all sockets will be added to write_fd_set. | ||
97 | * | ||
98 | * @param daemon daemon to get sets from | ||
99 | * @param read_fd_set read set | ||
100 | * @param write_fd_set write set | ||
101 | * @param except_fd_set except set | ||
102 | * @param all add all session's descriptors to write_fd_set or not | ||
103 | * @return largest FD added | ||
104 | */ | ||
105 | int | ||
106 | SPDYF_get_fdset (struct SPDY_Daemon *daemon, | ||
107 | fd_set *read_fd_set, | ||
108 | fd_set *write_fd_set, | ||
109 | fd_set *except_fd_set, | ||
110 | bool all); | ||
111 | |||
112 | |||
113 | /** | ||
114 | * Shutdown the daemon. | ||
115 | * | ||
116 | * @param daemon daemon to stop | ||
117 | */ | ||
118 | void | ||
119 | SPDYF_stop_daemon (struct SPDY_Daemon *daemon); | ||
120 | |||
121 | #endif | ||