1 /*
2  * http_upload.h
3  * vim: expandtab:ts=4:sts=4:sw=4
4  *
5  * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
6  *
7  * This file is part of Profanity.
8  *
9  * Profanity is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * Profanity is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Profanity.  If not, see <https://www.gnu.org/licenses/>.
21  *
22  * In addition, as a special exception, the copyright holders give permission to
23  * link the code of portions of this program with the OpenSSL library under
24  * certain conditions as described in each individual source file, and
25  * distribute linked combinations including the two.
26  *
27  * You must obey the GNU General Public License in all respects for all of the
28  * code used other than OpenSSL. If you modify file(s) with this exception, you
29  * may extend this exception to your version of the file(s), but you are not
30  * obligated to do so. If you do not wish to do so, delete this exception
31  * statement from your version. If you delete this exception statement from all
32  * source files in the program, then also delete it here.
33  *
34  */
35 
36 #ifndef TOOLS_HTTP_UPLOAD_H
37 #define TOOLS_HTTP_UPLOAD_H
38 
39 #ifdef PLATFORM_CYGWIN
40 #define SOCKET int
41 #endif
42 
43 #include <sys/select.h>
44 #include <curl/curl.h>
45 
46 #include "ui/win_types.h"
47 
48 typedef struct http_upload_t
49 {
50     char* filename;
51     FILE* filehandle;
52     off_t filesize;
53     curl_off_t bytes_sent;
54     char* mime_type;
55     char* get_url;
56     char* put_url;
57     char* alt_scheme;
58     char* alt_fragment;
59     ProfWin* window;
60     pthread_t worker;
61     int cancel;
62     // Additional headers
63     // (NULL if they shouldn't be send in the PUT)
64     char* authorization;
65     char* cookie;
66     char* expires;
67 } HTTPUpload;
68 
69 void* http_file_put(void* userdata);
70 
71 char* file_mime_type(const char* const filename);
72 off_t file_size(int filedes);
73 
74 void http_upload_cancel_processes(ProfWin* window);
75 void http_upload_add_upload(HTTPUpload* upload);
76 
77 #endif
78