summaryrefslogtreecommitdiff
path: root/src/libwaitress/waitress.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libwaitress/waitress.h')
-rw-r--r--src/libwaitress/waitress.h53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/libwaitress/waitress.h b/src/libwaitress/waitress.h
index cbf17c1..9523ede 100644
--- a/src/libwaitress/waitress.h
+++ b/src/libwaitress/waitress.h
@@ -25,7 +25,11 @@ THE SOFTWARE.
#define _WAITRESS_H
#include <stdlib.h>
+#include <unistd.h>
#include <stdbool.h>
+#ifdef ENABLE_TLS
+#include <gnutls/gnutls.h>
+#endif
#define WAITRESS_BUFFER_SIZE 10*1024
@@ -48,6 +52,7 @@ typedef enum {
typedef struct {
char *url; /* splitted url, unusable */
+ bool tls;
const char *user;
const char *password;
const char *host;
@@ -55,6 +60,27 @@ typedef struct {
const char *path; /* without leading '/' */
} WaitressUrl_t;
+typedef enum {
+ WAITRESS_RET_ERR = 0,
+ WAITRESS_RET_OK,
+ WAITRESS_RET_STATUS_UNKNOWN,
+ WAITRESS_RET_NOTFOUND,
+ WAITRESS_RET_FORBIDDEN,
+ WAITRESS_RET_CONNECT_REFUSED,
+ WAITRESS_RET_SOCK_ERR,
+ WAITRESS_RET_GETADDR_ERR,
+ WAITRESS_RET_CB_ABORT,
+ WAITRESS_RET_PARTIAL_FILE,
+ WAITRESS_RET_TIMEOUT,
+ WAITRESS_RET_READ_ERR,
+ WAITRESS_RET_CONNECTION_CLOSED,
+ WAITRESS_RET_DECODING_ERR,
+ WAITRESS_RET_TLS_DISABLED,
+ WAITRESS_RET_TLS_WRITE_ERR,
+ WAITRESS_RET_TLS_READ_ERR,
+ WAITRESS_RET_TLS_HANDSHAKE_ERR,
+} WaitressReturn_t;
+
/* reusable handle
*/
typedef struct {
@@ -66,34 +92,25 @@ typedef struct {
/* extra data handed over to callback function */
void *data;
WaitressCbReturn_t (*callback) (void *, size_t, void *);
- int socktimeout;
+ int timeout;
/* per-request data */
struct {
size_t contentLength, contentReceived, chunkSize;
int sockfd;
char *buf;
+#ifdef ENABLE_TLS
+ gnutls_session_t tlsSession;
+ gnutls_certificate_credentials_t tlsCred;
+#endif
/* first argument is WaitressHandle_t, but that's not defined here */
WaitressHandlerReturn_t (*dataHandler) (void *, char *, const size_t);
+ ssize_t (*read) (void *, char *, const size_t, ssize_t *);
+ ssize_t (*write) (void *, const char *, const size_t);
+ /* temporary return value storage */
+ WaitressReturn_t readWriteRet;
} request;
} WaitressHandle_t;
-typedef enum {
- WAITRESS_RET_ERR = 0,
- WAITRESS_RET_OK,
- WAITRESS_RET_STATUS_UNKNOWN,
- WAITRESS_RET_NOTFOUND,
- WAITRESS_RET_FORBIDDEN,
- WAITRESS_RET_CONNECT_REFUSED,
- WAITRESS_RET_SOCK_ERR,
- WAITRESS_RET_GETADDR_ERR,
- WAITRESS_RET_CB_ABORT,
- WAITRESS_RET_PARTIAL_FILE,
- WAITRESS_RET_TIMEOUT,
- WAITRESS_RET_READ_ERR,
- WAITRESS_RET_CONNECTION_CLOSED,
- WAITRESS_RET_DECODING_ERR,
-} WaitressReturn_t;
-
void WaitressInit (WaitressHandle_t *);
void WaitressFree (WaitressHandle_t *);
bool WaitressSetProxy (WaitressHandle_t *, const char *);