summaryrefslogtreecommitdiff
path: root/src/libwaitress/waitress.h
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-04-06 12:25:13 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-04-06 12:25:13 +0200
commit4458cbab76fd98989fa2d4260dd20bbbd66297a4 (patch)
tree832c7230129b50c278044cb9f4aabe711697ee69 /src/libwaitress/waitress.h
parentb13b61b77b6d58c8b541bc4628b998681e94875f (diff)
downloadpianobar-4458cbab76fd98989fa2d4260dd20bbbd66297a4.tar.gz
pianobar-4458cbab76fd98989fa2d4260dd20bbbd66297a4.tar.bz2
pianobar-4458cbab76fd98989fa2d4260dd20bbbd66297a4.zip
Switch back to libcurl
Drops libwaitress. Adds the new dependency libcurl and drops gnutls. I wouldn’t say writing my own HTTP library was a mistake – it was not and the experience gained was worth it. Instead I have to acknowledge that libcurl is just better than my own implementation. Sure, it does a lot more than HTTP – one could call that bloat. Yet if you just want to get the job done™ reusing code is the way to go. See #512 and #513.
Diffstat (limited to 'src/libwaitress/waitress.h')
-rw-r--r--src/libwaitress/waitress.h136
1 files changed, 0 insertions, 136 deletions
diff --git a/src/libwaitress/waitress.h b/src/libwaitress/waitress.h
deleted file mode 100644
index b17d3c1..0000000
--- a/src/libwaitress/waitress.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-Copyright (c) 2009-2013
- Lars-Dominik Braun <lars@6xq.net>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#ifndef SRC_LIBWAITRESS_WAITRESS_H_ZE5NT8JI
-#define SRC_LIBWAITRESS_WAITRESS_H_ZE5NT8JI
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <gnutls/gnutls.h>
-
-#define WAITRESS_BUFFER_SIZE 10*1024
-
-typedef enum {
- WAITRESS_METHOD_GET = 0,
- WAITRESS_METHOD_POST,
-} WaitressMethod_t;
-
-typedef enum {
- WAITRESS_CB_RET_ERR,
- WAITRESS_CB_RET_OK,
-} WaitressCbReturn_t;
-
-typedef enum {
- WAITRESS_HANDLER_CONTINUE,
- WAITRESS_HANDLER_DONE,
- WAITRESS_HANDLER_ERR,
- WAITRESS_HANDLER_ABORTED,
-} WaitressHandlerReturn_t;
-
-typedef struct {
- char *url; /* splitted url, unusable */
- bool tls;
- const char *user;
- const char *password;
- const char *host;
- const char *port;
- const char *tlsPort;
- const char *path; /* without leading '/' */
-} WaitressUrl_t;
-
-typedef enum {
- WAITRESS_RET_ERR = 0,
- WAITRESS_RET_OK,
- WAITRESS_RET_CB_ABORT,
- /* http error codes */
- WAITRESS_RET_STATUS_UNKNOWN,
- WAITRESS_RET_NOTFOUND,
- WAITRESS_RET_FORBIDDEN,
- WAITRESS_RET_BAD_REQUEST,
- /* socket errors */
- WAITRESS_RET_CONNECT_REFUSED,
- WAITRESS_RET_SOCK_ERR,
- WAITRESS_RET_GETADDR_ERR,
- WAITRESS_RET_TIMEOUT,
- WAITRESS_RET_READ_ERR,
- WAITRESS_RET_CONNECTION_CLOSED,
- WAITRESS_RET_TLS_WRITE_ERR,
- WAITRESS_RET_TLS_READ_ERR,
- /* protocol errors */
- WAITRESS_RET_PARTIAL_FILE,
- WAITRESS_RET_DECODING_ERR,
- WAITRESS_RET_TLS_HANDSHAKE_ERR,
- WAITRESS_RET_TLS_FINGERPRINT_MISMATCH,
-} WaitressReturn_t;
-
-/* reusable handle
- */
-typedef struct {
- int timeout;
- WaitressMethod_t method;
-
- const char *extraHeaders;
- const char *postData;
- /* extra data handed over to callback function */
- void *data;
- WaitressCbReturn_t (*callback) (void *, size_t, void *);
- const char *tlsFingerprint;
-
- WaitressUrl_t url;
- WaitressUrl_t proxy;
-
- gnutls_certificate_credentials_t tlsCred;
-
- /* per-request data */
- struct {
- int sockfd;
-
- /* temporary return value storage */
- WaitressReturn_t readWriteRet;
-
- size_t contentLength, contentReceived, chunkSize;
- bool contentLengthKnown;
- enum {CHUNKSIZE = 0, DATA = 1} chunkedState;
-
- char *buf;
- /* first argument is WaitressHandle_t, but that's not defined yet */
- WaitressHandlerReturn_t (*dataHandler) (void *, char *, const size_t);
- WaitressReturn_t (*read) (void *, char *, const size_t, size_t *);
- WaitressReturn_t (*write) (void *, const char *, const size_t);
-
- gnutls_session_t tlsSession;
- } request;
-} WaitressHandle_t;
-
-void WaitressInit (WaitressHandle_t *);
-void WaitressFree (WaitressHandle_t *);
-bool WaitressSetProxy (WaitressHandle_t *, const char *);
-char *WaitressUrlEncode (const char *);
-bool WaitressSetUrl (WaitressHandle_t *, const char *);
-WaitressReturn_t WaitressFetchBuf (WaitressHandle_t *, char **);
-WaitressReturn_t WaitressFetchCall (WaitressHandle_t *);
-const char *WaitressErrorToStr (WaitressReturn_t);
-
-#endif /* SRC_LIBWAITRESS_WAITRESS_H_ZE5NT8JI */
-