wget2 2.2.1
Loading...
Searching...
No Matches
wget.h
1/*
2 * Copyright (c) 2012-2015 Tim Ruehsen
3 * Copyright (c) 2015-2024 Free Software Foundation, Inc.
4 *
5 * This file is part of libwget.
6 *
7 * Libwget is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Libwget is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with libwget. If not, see <https://www.gnu.org/licenses/>.
19 *
20 *
21 * Header file for libwget library routines
22 *
23 * Changelog
24 * 28.12.2012 Tim Ruehsen created (moved wget.h and list.h and into here)
25 *
26 */
27
28#ifndef WGET_WGET_H
29#define WGET_WGET_H
30
31#include <stddef.h> // size_t
32#include <sys/types.h>
33#include <unistd.h>
34#include <stdarg.h> // va_list
35#include <stdio.h> // FILE
36#include <stdlib.h>
37#include <stdbool.h> // bool
38#include <stdint.h> // int64_t
39
40#ifdef WGETVER_FILE
41# include WGETVER_FILE
42#else //not WGETVER_FILE
43# include "wgetver.h"
44#endif //WGETVER_FILE
45
46// see https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html
47#if defined BUILDING_LIBWGET && HAVE_VISIBILITY
48# define WGETAPI __attribute__ ((__visibility__("default")))
49#elif defined BUILDING_LIBWGET && defined _MSC_VER && !defined LIBWGET_STATIC
50# define WGETAPI __declspec(dllexport)
51#elif defined _MSC_VER && !defined LIBWGET_STATIC
52# define WGETAPI __declspec(dllimport)
53#else
54# define WGETAPI
55#endif
56
57/*
58 * Attribute defines specific for clang (especially for improving clang analyzer)
59 * Using G_GNU_ as prefix to let gtk-doc recognize the attributes.
60 */
61
62/*
63 * Attribute defines for GCC and compatible compilers
64 * Using G_GNU_ as prefix to let gtk-doc recognize the attributes.
65 *
66 * Clang also defines __GNUC__. It promotes a GCC version of 4.2.1.
67 */
68
69#if defined __GNUC__ && defined __GNUC_MINOR__
70# define GCC_VERSION_AT_LEAST(major, minor) ((__GNUC__ > (major)) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
71#else
72# define GCC_VERSION_AT_LEAST(major, minor) 0
73#endif
74
75#if defined __clang_major__ && defined __clang_minor__
76# define CLANG_VERSION_AT_LEAST(major, minor) ((__clang_major__ > (major)) || (__clang_major__ == (major) && __clang_minor__ >= (minor)))
77#else
78# define CLANG_VERSION_AT_LEAST(major, minor) 0
79#endif
80
81#if GCC_VERSION_AT_LEAST(2,5)
82# define WGET_GCC_CONST __attribute__ ((const))
83#else
84# define WGET_GCC_CONST
85#endif
86
87#define WGET_GCC_NORETURN_FUNCPTR
88#if GCC_VERSION_AT_LEAST(2,8) || __SUNPRO_C >= 0x5110
89# define WGET_GCC_NORETURN __attribute__ ((__noreturn__))
90# undef WGET_GCC_NORETURN_FUNCPTR
91# define G_GNUC_NORETURN_FUNCPTR WGET_GCC_NORETURN
92#elif _MSC_VER >= 1200
93# define WGET_GCC_NORETURN __declspec (noreturn)
94#elif __STDC_VERSION__ >= 201112
95# define WGET_GCC_NORETURN _Noreturn
96#else
97# define WGET_GCC_NORETURN
98#endif
99
100#if GCC_VERSION_AT_LEAST(2,95)
101# define WGET_GCC_PRINTF_FORMAT(a, b) __attribute__ ((format (printf, a, b)))
102# define WGET_GCC_UNUSED __attribute__ ((unused))
103#else
104# define WGET_GCC_PRINTF_FORMAT(a, b)
105# define WGET_GCC_UNUSED
106#endif
107
108#if GCC_VERSION_AT_LEAST(2,96)
109# define WGET_GCC_PURE __attribute__ ((pure))
110#else
111# define WGET_GCC_PURE
112#endif
113
114#if GCC_VERSION_AT_LEAST(3,0)
115# define WGET_GCC_MALLOC __attribute__ ((malloc))
116# define unlikely(expr) __builtin_expect(!!(expr), 0)
117# define likely(expr) __builtin_expect(!!(expr), 1)
118#else
119# define WGET_GCC_MALLOC
120# define unlikely(expr) expr
121# define likely(expr) expr
122#endif
123
124#if GCC_VERSION_AT_LEAST(3,1)
125# define WGET_GCC_ALWAYS_INLINE __attribute__ ((always_inline))
126# define WGET_GCC_FLATTEN __attribute__ ((flatten))
127# define WGET_GCC_DEPRECATED __attribute__ ((deprecated))
128#else
129# define WGET_GCC_ALWAYS_INLINE
130# define WGET_GCC_FLATTEN
131# define WGET_GCC_DEPRECATED
132#endif
133
134// nonnull is dangerous to use with current gcc <= 4.7.1.
135// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308
136// we have to use e.g. the clang analyzer if we want NONNULL.
137// but even clang is not perfect - don't use nonnull in production
138#if GCC_VERSION_AT_LEAST(3,3)
139# define WGET_GCC_NONNULL_ALL __attribute__ ((nonnull))
140# define WGET_GCC_NONNULL(a) __attribute__ ((nonnull a))
141#else
142# define WGET_GCC_NONNULL_ALL
143# define WGET_GCC_NONNULL(a)
144#endif
145
146#if GCC_VERSION_AT_LEAST(3,4)
147# define WGET_GCC_UNUSED_RESULT __attribute__ ((warn_unused_result))
148#else
149# define WGET_GCC_UNUSED_RESULT
150#endif
151
152#if GCC_VERSION_AT_LEAST(4,0)
153# define WGET_GCC_NULL_TERMINATED __attribute__((__sentinel__))
154#else
155# define WGET_GCC_NULL_TERMINATED
156#endif
157
158#if GCC_VERSION_AT_LEAST(4,9) || CLANG_VERSION_AT_LEAST(7,0)
159# define WGET_GCC_RETURNS_NONNULL __attribute__((returns_nonnull))
160#else
161# define WGET_GCC_RETURNS_NONNULL
162#endif
163
164#if GCC_VERSION_AT_LEAST(4,3) || CLANG_VERSION_AT_LEAST(6,0)
165# define WGET_GCC_ALLOC_SIZE(a) __attribute__ ((__alloc_size__(a)))
166# define WGET_GCC_ALLOC_SIZE2(a, b) __attribute__ ((__alloc_size__(a, b)))
167#else
168# define WGET_GCC_ALLOC_SIZE(a)
169# define WGET_GCC_ALLOC_SIZE2(a, b)
170#endif
171
172#ifdef BUILDING_LIBWGET
173# define LIBWGET_WARN_UNUSED_RESULT WGET_GCC_UNUSED_RESULT
174#else
175# define LIBWGET_WARN_UNUSED_RESULT
176#endif
177
178// Let C++ include C headers
179#ifdef __cplusplus
180# define WGET_BEGIN_DECLS extern "C" {
181# define WGET_END_DECLS }
182#else
183# define WGET_BEGIN_DECLS
184# define WGET_END_DECLS
185#endif
186
187// define MALLOC_RETURNS_NONNULL when using appropriate implementations of the alloc functions
188#ifdef MALLOC_RETURNS_NONNULL
189# define RETURNS_NONNULL WGET_GCC_RETURNS_NONNULL
190# define NULLABLE
191#else
192# define RETURNS_NONNULL
193# if defined __clang_major__ && defined WGET_MANYWARNINGS
194# define NULLABLE _Nullable
195# else
196# define NULLABLE
197# endif
198#endif
199
200#undef GCC_VERSION_AT_LEAST
201#undef CLANG_VERSION_AT_LEAST
202
203WGET_BEGIN_DECLS
204
205/*
206 * Library initialization functions
207 */
208
209// Why not using enum ? Might result in different values if one entry is inserted.
210// And that might break the ABI.
211#define WGET_DEBUG_STREAM 1000
212#define WGET_DEBUG_FUNC 1001
213#define WGET_DEBUG_FILE 1002
214#define WGET_ERROR_STREAM 1003
215#define WGET_ERROR_FUNC 1004
216#define WGET_ERROR_FILE 1005
217#define WGET_INFO_STREAM 1006
218#define WGET_INFO_FUNC 1007
219#define WGET_INFO_FILE 1008
220#define WGET_DNS_CACHING 1009
221#define WGET_COOKIE_SUFFIXES 1010
222#define WGET_COOKIES_ENABLED 1011
223#define WGET_COOKIE_FILE 1012
224#define WGET_COOKIE_DB 1013
225#define WGET_COOKIE_KEEPSESSIONCOOKIES 1014
226#define WGET_BIND_ADDRESS 1015
227#define WGET_NET_FAMILY_EXCLUSIVE 1016
228#define WGET_NET_FAMILY_PREFERRED 1017
229#define WGET_TCP_FASTFORWARD 1018
230#define WGET_BIND_INTERFACE 1019
231
232#define WGET_HTTP_URL 2000
233#define WGET_HTTP_URL_ENCODING 2001
234#define WGET_HTTP_URI 2002
235#define WGET_HTTP_COOKIE_STORE 2003
236#define WGET_HTTP_HEADER_ADD 2004
237//#define WGET_HTTP_HEADER_DEL 2005
238//#define WGET_HTTP_HEADER_SET 2006
239//#define WGET_HTTP_BIND_ADDRESS 2007
240#define WGET_HTTP_CONNECTION_PTR 2008
241#define WGET_HTTP_RESPONSE_KEEPHEADER 2009
242#define WGET_HTTP_MAX_REDIRECTIONS 2010
243#define WGET_HTTP_BODY_SAVEAS_STREAM 2011
244#define WGET_HTTP_BODY_SAVEAS_FILE 2012
245#define WGET_HTTP_BODY_SAVEAS_FD 2013
246#define WGET_HTTP_BODY_SAVEAS_FUNC 2014
247#define WGET_HTTP_HEADER_FUNC 2015
248#define WGET_HTTP_SCHEME 2016
249#define WGET_HTTP_BODY 2017
250#define WGET_HTTP_BODY_SAVEAS 2018
251#define WGET_HTTP_USER_DATA 2019
252#define WGET_HTTP_RESPONSE_IGNORELENGTH 2020
253#define WGET_HTTP_DEBUG_SKIP_BODY 2021
254
255// definition of error conditions
256typedef enum {
257 WGET_E_SUCCESS = 0, /* OK */
258 WGET_E_UNKNOWN = -1, /* general error if nothing else appropriate */
259 WGET_E_MEMORY = -2, /* memory allocation failure */
260 WGET_E_INVALID = -3, /* invalid value to function */
261 WGET_E_TIMEOUT = -4, /* timeout condition */
262 WGET_E_CONNECT = -5, /* connect failure */
263 WGET_E_HANDSHAKE = -6, /* general TLS handshake failure */
264 WGET_E_CERTIFICATE = -7, /* general TLS certificate failure */
265 WGET_E_TLS_DISABLED = -8, /* TLS was not enabled at compile time */
266 WGET_E_XML_PARSE_ERR = -9, /* XML parsing failed */
267 WGET_E_OPEN = -10, /* Failed to open file */
268 WGET_E_IO = -11, /* General I/O error (read/write/stat/...) */
269 WGET_E_UNSUPPORTED = -12, /* Unsupported function */
270} wget_error;
271
272WGETAPI const char *
273 wget_strerror(wget_error err);
274
275typedef void wget_global_func(const char *, size_t);
276
277WGETAPI void
278 wget_global_init(int key, ...);
279WGETAPI void
280 wget_global_deinit(void);
281WGETAPI const void * NULLABLE
282 wget_global_get_ptr(int key);
283WGETAPI int
284 wget_global_get_int(int key);
285WGETAPI wget_global_func *
286 wget_global_get_func(int key);
287
288/*
289 * Utility functions
290 */
291
297
298// <mode> values for wget_ready_to_transfer()
299#define WGET_IO_READABLE 1
300#define WGET_IO_WRITABLE 2
301
302// types for --restrict-file-names / wget_restrict_file_name()
303#define WGET_RESTRICT_NAMES_NONE 0
304#define WGET_RESTRICT_NAMES_UNIX 1<<0
305#define WGET_RESTRICT_NAMES_WINDOWS 1<<1
306#define WGET_RESTRICT_NAMES_NOCONTROL 1<<2
307#define WGET_RESTRICT_NAMES_ASCII 1<<3
308#define WGET_RESTRICT_NAMES_UPPERCASE 1<<4
309#define WGET_RESTRICT_NAMES_LOWERCASE 1<<5
310
311typedef int wget_update_load_fn(void *, FILE *fp);
312typedef int wget_update_save_fn(void *, FILE *fp);
313
314WGETAPI int
315 wget_ready_2_read(int fd, int timeout);
316WGETAPI int
317 wget_ready_2_write(int fd, int timeout);
318WGETAPI int
319 wget_ready_2_transfer(int fd, int timeout, int mode);
320WGETAPI int
321 wget_strcmp(const char *s1, const char *s2) WGET_GCC_PURE;
322WGETAPI int
323 wget_strcasecmp(const char *s1, const char *s2) WGET_GCC_PURE;
324WGETAPI int
325 wget_strcasecmp_ascii(const char *s1, const char *s2) WGET_GCC_PURE;
326WGETAPI int
327 wget_strncasecmp_ascii(const char *s1, const char *s2, size_t n) WGET_GCC_PURE;
328WGETAPI char *
329 wget_strtolower(char *s);
330WGETAPI int
331 wget_strncmp(const char *s1, const char *s2, size_t n) WGET_GCC_PURE;
332WGETAPI int
333 wget_strncasecmp(const char *s1, const char *s2, size_t n) WGET_GCC_PURE;
334WGETAPI void
335 wget_memtohex(const unsigned char * __restrict src, size_t src_len, char * __restrict dst, size_t dst_size);
336WGETAPI void
337 wget_millisleep(int ms);
338WGETAPI long long
340WGETAPI int
341 wget_percent_unescape(char *src);
342WGETAPI int
343 wget_match_tail(const char *s, const char *tail) WGET_GCC_PURE WGET_GCC_NONNULL_ALL;
344WGETAPI int
345 wget_match_tail_nocase(const char *s, const char *tail) WGET_GCC_PURE WGET_GCC_NONNULL_ALL;
346WGETAPI char * NULLABLE
347 wget_strnglob(const char *str, size_t n, int flags) WGET_GCC_PURE;
348WGETAPI char *
349 wget_human_readable(char *buf, size_t bufsize, uint64_t n);
350WGETAPI int
351 wget_get_screen_size(int *width, int *height);
352WGETAPI ssize_t
353 wget_fdgetline(char **buf, size_t *bufsize, int fd);
354WGETAPI ssize_t
355 wget_getline(char **buf, size_t *bufsize, FILE *fp);
356WGETAPI FILE * NULLABLE
357 wget_vpopenf(const char *type, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
358WGETAPI FILE * NULLABLE
359 wget_popenf(const char *type, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
360WGETAPI FILE * NULLABLE
361 wget_popen2f(FILE **fpin, FILE **fpout, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4);
362WGETAPI pid_t
363 wget_fd_popen3(int *fdin, int *fdout, int *fderr, const char *const *argv);
364WGETAPI pid_t
365 wget_popen3(FILE **fpin, FILE **fpout, FILE **fperr, const char *const *argv);
366WGETAPI char * NULLABLE
367 wget_read_file(const char *fname, size_t *size) WGET_GCC_MALLOC;
368WGETAPI int
369 wget_update_file(const char *fname, wget_update_load_fn *load_func, wget_update_save_fn *save_func, void *context);
370WGETAPI int
371 wget_truncate(const char *path, off_t length);
372WGETAPI const char *
373 wget_local_charset_encoding(void);
374WGETAPI int
375 wget_memiconv(const char *src_encoding, const void *src, size_t srclen, const char *dst_encoding, char **out, size_t *outlen);
376WGETAPI char * NULLABLE
377 wget_striconv(const char *src, const char *src_encoding, const char *dst_encoding) WGET_GCC_MALLOC;
378WGETAPI bool
379 wget_str_needs_encoding(const char *s) WGET_GCC_PURE;
380WGETAPI bool
381 wget_str_is_valid_utf8(const char *utf8) WGET_GCC_PURE;
382WGETAPI char * NULLABLE
383 wget_str_to_utf8(const char *src, const char *encoding) WGET_GCC_MALLOC;
384WGETAPI char * NULLABLE
385 wget_utf8_to_str(const char *src, const char *encoding) WGET_GCC_MALLOC;
386WGETAPI const char *
387 wget_str_to_ascii(const char *src);
388
394
395WGETAPI size_t
396 wget_strlcpy(char *__restrict dst, const char *__restrict src, size_t size);
397WGETAPI ssize_t
398 wget_strscpy(char *__restrict dst, const char *__restrict src, size_t size);
399
405typedef struct wget_list_st wget_list;
406typedef int wget_list_browse_fn(void *context, void *elem);
407
408WGETAPI void * NULLABLE
409 wget_list_append(wget_list **list, const void *data, size_t size) WGET_GCC_NONNULL_ALL;
410WGETAPI void * NULLABLE
411 wget_list_prepend(wget_list **list, const void *data, size_t size) WGET_GCC_NONNULL_ALL;
412WGETAPI void * NULLABLE
413 wget_list_getfirst(const wget_list *list) WGET_GCC_CONST;
414WGETAPI void * NULLABLE
415 wget_list_getlast(const wget_list *list) WGET_GCC_PURE;
416WGETAPI void * NULLABLE
417 wget_list_getnext(const void *elem) WGET_GCC_PURE;
418WGETAPI void
419 wget_list_remove(wget_list **list, void *elem) WGET_GCC_NONNULL_ALL;
420WGETAPI void
421 wget_list_free(wget_list **list) WGET_GCC_NONNULL_ALL;
422WGETAPI int
423 wget_list_browse(const wget_list *list, wget_list_browse_fn *browse, void *context) WGET_GCC_NONNULL((2));
424
431
432// Don't leave freed pointers hanging around
433#define wget_xfree(a) do { if (a) { wget_free((void *)(a)); a=NULL; } } while (0)
434
436typedef void *wget_malloc_function(size_t);
437
439typedef void *wget_calloc_function(size_t, size_t);
440
442typedef void *wget_realloc_function(void *, size_t);
443
445typedef void wget_free_function(void *);
446
447/* For use in callbacks */
448extern WGETAPI wget_malloc_function *wget_malloc_fn;
449extern WGETAPI wget_calloc_function *wget_calloc_fn;
450extern WGETAPI wget_realloc_function *wget_realloc_fn;
451extern WGETAPI wget_free_function *wget_free;
452
453// we use (inline) functions here to apply function attributes
454RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(1) WGET_GCC_MALLOC
455static inline void * NULLABLE wget_malloc(size_t size)
456{
457 return wget_malloc_fn(size);
458}
459
460RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE2(1,2) WGET_GCC_MALLOC
461static inline void * NULLABLE wget_calloc(size_t nmemb, size_t size)
462{
463 return wget_calloc_fn(nmemb, size);
464}
465
466RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(2)
467static inline void * NULLABLE wget_realloc(void *ptr, size_t size)
468{
469 return wget_realloc_fn(ptr, size);
470}
471
473
474/*
475 * String/Memory routines, slightly different than standard functions
476 */
477
478LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(2)
479WGETAPI void * NULLABLE
480 wget_memdup(const void *m, size_t n);
481
482LIBWGET_WARN_UNUSED_RESULT WGET_GCC_MALLOC
483WGETAPI char * NULLABLE
484 wget_strdup(const char *s);
485
486LIBWGET_WARN_UNUSED_RESULT WGET_GCC_ALLOC_SIZE(2)
487WGETAPI char * NULLABLE
488 wget_strmemdup(const void *m, size_t n);
489
490WGETAPI size_t
491 wget_strmemcpy(char *__restrict s, size_t ssize, const void *__restrict m, size_t n);
492
493LIBWGET_WARN_UNUSED_RESULT WGET_GCC_NONNULL_ALL
494WGETAPI void * NULLABLE
495 wget_strmemcpy_a(char *s, size_t ssize, const void *m, size_t n);
496
497/*
498 * Base64 routines
499 */
500
501WGETAPI bool
502 wget_base64_is_string(const char *src) WGET_GCC_PURE;
503WGETAPI size_t
504 wget_base64_get_decoded_length(size_t len) WGET_GCC_PURE;
505WGETAPI size_t
506 wget_base64_get_encoded_length(size_t len) WGET_GCC_PURE;
507WGETAPI size_t
508 wget_base64_decode(char *__restrict dst, const char *__restrict src, size_t n) WGET_GCC_NONNULL_ALL;
509WGETAPI size_t
510 wget_base64_encode(char *__restrict dst, const char *__restrict src, size_t n) WGET_GCC_NONNULL_ALL;
511WGETAPI size_t
512 wget_base64_urlencode(char *__restrict dst, const char *__restrict src, size_t n) WGET_GCC_NONNULL_ALL;
513WGETAPI char * NULLABLE
514 wget_base64_decode_alloc(const char *src, size_t n, size_t *outlen) WGET_GCC_NONNULL((1));
515WGETAPI char * NULLABLE
516 wget_base64_encode_alloc(const char *src, size_t n) WGET_GCC_NONNULL_ALL;
517WGETAPI char * NULLABLE
518 wget_base64_encode_vprintf_alloc(const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(1,0) WGET_GCC_NONNULL_ALL;
519WGETAPI char * NULLABLE
520 wget_base64_encode_printf_alloc(const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(1,2) WGET_GCC_NONNULL_ALL;
521
522/*
523 * Bitmap routines
524 */
525
526typedef struct wget_bitmap_st wget_bitmap;
527
528WGETAPI int
529 wget_bitmap_init(wget_bitmap **bitmap, unsigned bits);
530WGETAPI void
531 wget_bitmap_free(wget_bitmap **bitmap);
532WGETAPI void
533 wget_bitmap_set(wget_bitmap *bitmap, unsigned n); // n is the index
534WGETAPI void
535 wget_bitmap_clear(wget_bitmap *bitmap, unsigned n);
536WGETAPI bool
537 wget_bitmap_get(const wget_bitmap *bitmap, unsigned n);
538
539/*
540 * Buffer routines
541 */
542
543typedef struct {
544 char *
546 size_t
548 size_t
550 bool
553 error : 1;
555
556WGETAPI int
557 wget_buffer_init(wget_buffer *buf, char *data, size_t size) WGET_GCC_NONNULL((1));
558WGETAPI wget_buffer *
559 wget_buffer_alloc(size_t size) WGET_GCC_MALLOC WGET_GCC_ALLOC_SIZE(1) RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT;
560WGETAPI int
561 wget_buffer_ensure_capacity(wget_buffer *buf, size_t size) LIBWGET_WARN_UNUSED_RESULT;
562WGETAPI void
563 wget_buffer_deinit(wget_buffer *buf) WGET_GCC_NONNULL((1));
564WGETAPI void
566WGETAPI void
568WGETAPI void
570WGETAPI size_t
571 wget_buffer_memcpy(wget_buffer *buf, const void *data, size_t length);
572WGETAPI size_t
573 wget_buffer_memcat(wget_buffer *buf, const void *data, size_t length);
574WGETAPI size_t
575 wget_buffer_strcpy(wget_buffer *buf, const char *s);
576WGETAPI size_t
577 wget_buffer_strcat(wget_buffer *buf, const char *s);
578WGETAPI size_t
580WGETAPI size_t
582WGETAPI size_t
583 wget_buffer_memset(wget_buffer *buf, char c, size_t length);
584WGETAPI size_t
585 wget_buffer_memset_append(wget_buffer *buf, char c, size_t length);
586WGETAPI char *
588WGETAPI size_t
589 wget_buffer_vprintf_append(wget_buffer *buf, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
590WGETAPI size_t
591 wget_buffer_printf_append(wget_buffer *buf, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
592WGETAPI size_t
593 wget_buffer_vprintf(wget_buffer *buf, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
594WGETAPI size_t
595 wget_buffer_printf(wget_buffer *buf, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
596
597/*
598 * Printf-style routines
599 */
600
601WGETAPI size_t
602 wget_vasprintf(char **__restrict strp, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
603WGETAPI size_t
604 wget_asprintf(char **__restrict strp, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
605WGETAPI char * NULLABLE
606 wget_vaprintf(const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(1,0);
607WGETAPI char * NULLABLE
608 wget_aprintf(const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(1,2);
609WGETAPI size_t
610 wget_vfprintf(FILE *__restrict fp, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
611WGETAPI size_t
612 wget_fprintf(FILE *__restrict fp, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
613WGETAPI size_t
614 wget_printf(const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(1,2);
615WGETAPI size_t
616 wget_vsnprintf(char *__restrict str, size_t size, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(3,0);
617WGETAPI size_t
618 wget_snprintf(char *__restrict str, size_t size, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4);
619
620/*
621 * Logger routines
622 */
623
624typedef struct wget_logger_st wget_logger;
625typedef void wget_logger_func(const char *buf , size_t len) WGET_GCC_NONNULL_ALL;
626
627WGETAPI void
628 wget_logger_set_func(wget_logger *logger, wget_logger_func *func);
629WGETAPI void
630 wget_logger_set_stream(wget_logger *logger, FILE *fp);
631WGETAPI void
632 wget_logger_set_file(wget_logger *logger, const char *fname);
633WGETAPI wget_logger_func * NULLABLE
634 wget_logger_get_func(wget_logger *logger) WGET_GCC_PURE;
635WGETAPI FILE * NULLABLE
636 wget_logger_get_stream(wget_logger *logger) WGET_GCC_PURE;
637WGETAPI const char * NULLABLE
638 wget_logger_get_file(wget_logger *logger) WGET_GCC_PURE;
639WGETAPI bool
640 wget_logger_is_active(wget_logger *logger) WGET_GCC_PURE;
641
642/*
643 * Logging routines
644 */
645
646#define WGET_LOGGER_INFO 1
647#define WGET_LOGGER_ERROR 2
648#define WGET_LOGGER_DEBUG 3
649
650WGETAPI void
651 wget_info_vprintf(const char *__restrict fmt, va_list args) WGET_GCC_NONNULL_ALL WGET_GCC_PRINTF_FORMAT(1,0);
652WGETAPI void
653 wget_info_printf(const char *__restrict fmt, ...) WGET_GCC_NONNULL((1)) WGET_GCC_PRINTF_FORMAT(1,2);
654WGETAPI void
655 wget_error_vprintf(const char *__restrict fmt, va_list args) WGET_GCC_NONNULL_ALL WGET_GCC_PRINTF_FORMAT(1,0);
656WGETAPI void
657 wget_error_printf(const char *__restrict fmt, ...) WGET_GCC_NONNULL((1)) WGET_GCC_PRINTF_FORMAT(1,2);
658WGETAPI void WGET_GCC_NONNULL((1)) WGET_GCC_NORETURN WGET_GCC_PRINTF_FORMAT(1,2)
659 wget_error_printf_exit(const char *__restrict fmt, ...);
660WGETAPI void
661 wget_debug_vprintf(const char *__restrict fmt, va_list args) WGET_GCC_NONNULL_ALL WGET_GCC_PRINTF_FORMAT(1,0);
662WGETAPI void
663 wget_debug_printf(const char *__restrict fmt, ...) WGET_GCC_NONNULL((1)) WGET_GCC_PRINTF_FORMAT(1,2);
664WGETAPI void
665 wget_debug_write(const char *buf, size_t len) WGET_GCC_NONNULL_ALL;
666WGETAPI wget_logger *
667 wget_get_logger(int id) WGET_GCC_CONST;
668
669/*
670 * Vector datatype routines
671 */
672
673typedef struct wget_vector_st wget_vector;
674typedef int wget_vector_compare_fn(const void *elem1, const void *elem2);
675typedef int wget_vector_find_fn(void *elem);
676typedef int wget_vector_browse_fn(void *ctx, void *elem);
677typedef void wget_vector_destructor(void *elem);
678
679WGETAPI wget_vector * NULLABLE
680 wget_vector_create(int max, wget_vector_compare_fn *cmp) WGET_GCC_MALLOC;
681WGETAPI void
682 wget_vector_set_resize_factor(wget_vector *v, float off);
683WGETAPI int
684 wget_vector_find(const wget_vector *v, const void *elem) WGET_GCC_NONNULL((2));
685WGETAPI int
686 wget_vector_findext(const wget_vector *v, int start, int direction, wget_vector_find_fn *find) WGET_GCC_NONNULL((4));
687WGETAPI bool
688 wget_vector_contains(const wget_vector *v, const void *elem) WGET_GCC_NONNULL((2));
689WGETAPI int
690 wget_vector_insert(wget_vector *v, const void *elem, int pos) WGET_GCC_NONNULL((2));
691WGETAPI int
692 wget_vector_insert_sorted(wget_vector *v, const void *elem) WGET_GCC_NONNULL((2));
693WGETAPI int
694 wget_vector_add_memdup(wget_vector *v, const void *elem, size_t size) WGET_GCC_NONNULL((2));
695WGETAPI int
696 wget_vector_add(wget_vector *v, const void *elem) WGET_GCC_NONNULL((2));
697WGETAPI int
698 wget_vector_add_vprintf(wget_vector *v, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
699WGETAPI int
700 wget_vector_add_printf(wget_vector *v, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
701WGETAPI int
702 wget_vector_replace(wget_vector *v, const void *elem, int pos) WGET_GCC_NONNULL((2));
703WGETAPI int
704 wget_vector_move(wget_vector *v, int old_pos, int new_pos);
705WGETAPI int
706 wget_vector_swap(wget_vector *v, int pos1, int pos2);
707WGETAPI int
708 wget_vector_remove(wget_vector *v, int pos);
709WGETAPI int
710 wget_vector_remove_nofree(wget_vector *v, int pos);
711WGETAPI int
712 wget_vector_size(const wget_vector *v) WGET_GCC_PURE;
713WGETAPI int
714 wget_vector_browse(const wget_vector *v, wget_vector_browse_fn *browse, void *ctx) WGET_GCC_NONNULL((2));
715WGETAPI void
716 wget_vector_free(wget_vector **v);
717WGETAPI void
718 wget_vector_clear(wget_vector *v);
719WGETAPI void
720 wget_vector_clear_nofree(wget_vector *v);
721WGETAPI void * NULLABLE
722 wget_vector_get(const wget_vector *v, int pos) WGET_GCC_PURE;
723WGETAPI void
724 wget_vector_setcmpfunc(wget_vector *v, wget_vector_compare_fn *cmp) WGET_GCC_NONNULL((2));
725WGETAPI void
726 wget_vector_set_destructor(wget_vector *v, wget_vector_destructor *destructor);
727WGETAPI void
728 wget_vector_sort(wget_vector *v);
729
735
738
740typedef int wget_hashmap_compare_fn(const void *key1, const void *key2);
741
743typedef unsigned int wget_hashmap_hash_fn(const void *key);
744
746typedef int wget_hashmap_browse_fn(void *ctx, const void *key, void *value);
747
749typedef void wget_hashmap_key_destructor(void *key);
750
752typedef void wget_hashmap_value_destructor(void *value);
754
755WGETAPI wget_hashmap * NULLABLE
756 wget_hashmap_create(int max, wget_hashmap_hash_fn *hash, wget_hashmap_compare_fn *cmp) WGET_GCC_MALLOC;
757WGETAPI void
759WGETAPI int
760 wget_hashmap_put(wget_hashmap *h, const void *key, const void *value);
761WGETAPI int
762 wget_hashmap_size(const wget_hashmap *h) WGET_GCC_PURE;
763WGETAPI int
764 wget_hashmap_browse(const wget_hashmap *h, wget_hashmap_browse_fn *browse, void *ctx);
765WGETAPI void
767WGETAPI void
769WGETAPI int
770 wget_hashmap_get(const wget_hashmap *h, const void *key, void **value) WGET_GCC_UNUSED_RESULT;
771#define wget_hashmap_get(a, b, c) wget_hashmap_get((a), (b), (void **)(c))
772WGETAPI int
773 wget_hashmap_contains(const wget_hashmap *h, const void *key);
774WGETAPI int
775 wget_hashmap_remove(wget_hashmap *h, const void *key);
776WGETAPI int
777 wget_hashmap_remove_nofree(wget_hashmap *h, const void *key);
778WGETAPI void
780WGETAPI int
782WGETAPI void
784WGETAPI void
786WGETAPI void
788
790typedef struct wget_hashmap_iterator_st wget_hashmap_iterator;
791
792WGETAPI wget_hashmap_iterator * NULLABLE
793 wget_hashmap_iterator_alloc(wget_hashmap *h) WGET_GCC_MALLOC;
794WGETAPI void
795 wget_hashmap_iterator_free(wget_hashmap_iterator **iter);
796WGETAPI void * NULLABLE
797 wget_hashmap_iterator_next(wget_hashmap_iterator *iter, void **value);
798
804
807
809typedef int wget_stringmap_compare_fn(const char *key1, const char *key2);
810
812typedef unsigned int wget_stringmap_hash_fn(const char *key);
813
815typedef int wget_stringmap_browse_fn(void *ctx, const char *key, void *value);
816
818typedef void wget_stringmap_key_destructor(char *key);
819
821typedef void wget_stringmap_value_destructor(void *value);
822
824typedef wget_hashmap_iterator wget_stringmap_iterator;
825
827#define wget_stringmap_iterator_alloc wget_hashmap_iterator_alloc
829#define wget_stringmap_iterator_free wget_hashmap_iterator_free
830
831WGETAPI wget_stringmap * NULLABLE
832 wget_stringmap_create(int max) WGET_GCC_MALLOC;
833WGETAPI wget_stringmap * NULLABLE
834 wget_stringmap_create_nocase(int max) WGET_GCC_MALLOC;
836
842
860static inline
861int wget_stringmap_put(wget_stringmap *h, const char *key, const void *value)
862{
863 return wget_hashmap_put(h, key, value);
864}
865
876static inline WGET_GCC_UNUSED_RESULT
877int wget_stringmap_get(const wget_stringmap *h, const char *key, void **value)
878{
879 return wget_hashmap_get(h, key, value);
880}
881#define wget_stringmap_get(h, k, v) wget_stringmap_get((h), (k), (void **)(v))
882
890static inline
891int wget_stringmap_contains(const wget_stringmap *h, const char *key)
892{
893 return wget_hashmap_contains(h, key);
894}
895
906static inline
907int wget_stringmap_remove(wget_stringmap *h, const char *key)
908{
909 return wget_hashmap_remove(h, key);
910}
911
921static inline
922int wget_stringmap_remove_nofree(wget_stringmap *h, const char *key)
923{
924 return wget_hashmap_remove_nofree(h, key);
925}
926
934static inline
935void wget_stringmap_free(wget_stringmap **h)
936{
938}
939
947static inline
948void wget_stringmap_clear(wget_stringmap *h)
949{
951}
952
959static inline
960int wget_stringmap_size(const wget_stringmap *h)
961{
962 return wget_hashmap_size(h);
963}
964
978static inline
979int wget_stringmap_browse(const wget_stringmap *h, wget_stringmap_browse_fn *browse, void *ctx)
980{
981 return wget_hashmap_browse(h, (wget_hashmap_browse_fn *) browse, ctx);
982}
983
990static inline
991void wget_stringmap_setcmpfunc(wget_stringmap *h, wget_stringmap_compare_fn *cmp)
992{
994}
995
1004static inline
1005int wget_stringmap_sethashfunc(wget_stringmap *h, wget_stringmap_hash_fn *hash)
1006{
1008}
1009
1018static inline
1019void wget_stringmap_set_key_destructor(wget_hashmap *h, wget_stringmap_key_destructor *destructor)
1020{
1022}
1023
1032static inline
1033void wget_stringmap_set_value_destructor(wget_hashmap *h, wget_stringmap_value_destructor *destructor)
1034{
1036}
1037
1053static inline
1054void wget_stringmap_set_load_factor(wget_stringmap *h, float factor)
1055{
1057}
1058
1071static inline
1072void wget_stringmap_set_resize_factor(wget_stringmap *h, float factor)
1073{
1075}
1076
1087static inline
1088void * NULLABLE wget_stringmap_iterator_next(wget_stringmap_iterator *h, void **value)
1089{
1090 return wget_hashmap_iterator_next(h, (void **) value);
1091}
1092
1094
1095/*
1096 * Thread wrapper routines
1097 */
1098
1099typedef unsigned long wget_thread_id;
1100typedef struct wget_thread_st *wget_thread;
1101typedef struct wget_thread_mutex_st *wget_thread_mutex;
1102typedef struct wget_thread_cond_st *wget_thread_cond;
1103
1104WGETAPI int
1105 wget_thread_start(wget_thread *thread, void *(*start_routine)(void *), void *arg, int flags);
1106WGETAPI int
1107 wget_thread_mutex_init(wget_thread_mutex *mutex);
1108WGETAPI int
1109 wget_thread_mutex_destroy(wget_thread_mutex *mutex);
1110WGETAPI void
1111 wget_thread_mutex_lock(wget_thread_mutex mutex);
1112WGETAPI void
1113 wget_thread_mutex_unlock(wget_thread_mutex mutex);
1114WGETAPI int
1115 wget_thread_kill(wget_thread thread, int sig);
1116WGETAPI int
1117 wget_thread_cancel(wget_thread thread);
1118WGETAPI int
1119 wget_thread_join(wget_thread *thread);
1120WGETAPI int
1121 wget_thread_cond_init(wget_thread_cond *cond);
1122WGETAPI int
1123 wget_thread_cond_destroy(wget_thread_cond *cond);
1124WGETAPI int
1125 wget_thread_cond_signal(wget_thread_cond cond);
1126WGETAPI int
1127 wget_thread_cond_wait(wget_thread_cond cond, wget_thread_mutex mutex, long long ms);
1128WGETAPI wget_thread_id
1129 wget_thread_self(void) WGET_GCC_CONST;
1130WGETAPI bool
1131 wget_thread_support(void) WGET_GCC_CONST;
1132
1133/*
1134 * Decompressor routines
1135 */
1136
1137typedef struct wget_decompressor_st wget_decompressor;
1138typedef int wget_decompressor_sink_fn(void *context, const char *data, size_t length);
1139typedef int wget_decompressor_error_handler(wget_decompressor *dc, int err);
1140
1141typedef enum {
1142 wget_content_encoding_unknown = -1,
1143 wget_content_encoding_identity = 0,
1144 wget_content_encoding_gzip = 1,
1145 wget_content_encoding_deflate = 2,
1146 wget_content_encoding_xz = 3,
1147 wget_content_encoding_lzma = 4,
1148 wget_content_encoding_bzip2 = 5,
1149 wget_content_encoding_brotli = 6,
1150 wget_content_encoding_zstd = 7,
1151 wget_content_encoding_lzip = 8,
1152 wget_content_encoding_max = 9
1153} wget_content_encoding;
1154
1155WGETAPI WGET_GCC_PURE wget_content_encoding
1156 wget_content_encoding_by_name(const char *name);
1157WGETAPI WGET_GCC_PURE const char * NULLABLE
1158 wget_content_encoding_to_name(wget_content_encoding type);
1159WGETAPI wget_decompressor * NULLABLE
1160 wget_decompress_open(wget_content_encoding encoding, wget_decompressor_sink_fn *data_sink, void *context);
1161WGETAPI void
1162 wget_decompress_close(wget_decompressor *dc);
1163WGETAPI int
1164 wget_decompress(wget_decompressor *dc, const char *src, size_t srclen);
1165WGETAPI void
1166 wget_decompress_set_error_handler(wget_decompressor *dc, wget_decompressor_error_handler *error_handler);
1167WGETAPI void * NULLABLE
1168 wget_decompress_get_context(wget_decompressor *dc);
1169
1170/*
1171 * URI/IRI routines
1172 */
1173
1174typedef enum {
1175 WGET_IRI_SCHEME_HTTP = 0,
1176 WGET_IRI_SCHEME_HTTPS = 1
1177} wget_iri_scheme;
1178
1179// flags for wget_iri_get_basename()
1180#define WGET_IRI_WITH_QUERY 1
1181
1193 const char *
1195
1199 const char *
1204 const char *
1209 const char *
1214 const char *
1219 const char *
1224 const char *
1229 const char *
1234 const char *
1244 const char *
1251 size_t
1254 size_t
1257 uint16_t
1260 wget_iri_scheme
1263 bool
1266 bool
1269 bool
1272 bool
1275 bool
1278 bool
1280};
1281
1282typedef struct wget_iri_st wget_iri;
1284
1285WGETAPI void
1286 wget_iri_test(void);
1287WGETAPI void
1288 wget_iri_free(wget_iri **iri);
1289WGETAPI void
1290 wget_iri_free_content(wget_iri *iri);
1291WGETAPI void
1292 wget_iri_set_defaultpage(const char *page);
1293WGETAPI int
1294 wget_iri_set_defaultport(wget_iri_scheme scheme, unsigned short port);
1295WGETAPI bool
1296 wget_iri_supported(const wget_iri *iri) WGET_GCC_PURE WGET_GCC_NONNULL_ALL;
1297WGETAPI bool
1298 wget_iri_isgendelim(char c) WGET_GCC_CONST;
1299WGETAPI bool
1300 wget_iri_issubdelim(char c) WGET_GCC_CONST;
1301WGETAPI bool
1302 wget_iri_isreserved(char c) WGET_GCC_CONST;
1303WGETAPI bool
1304 wget_iri_isunreserved(char c) WGET_GCC_CONST;
1305WGETAPI int
1306 wget_iri_compare(const wget_iri *iri1, const wget_iri *iri2) WGET_GCC_PURE;
1307WGETAPI char *
1308 wget_iri_unescape_inline(char *src) WGET_GCC_NONNULL_ALL;
1309WGETAPI char *
1310 wget_iri_unescape_url_inline(char *src) WGET_GCC_NONNULL_ALL;
1311WGETAPI wget_iri *
1312 wget_iri_parse(const char *uri, const char *encoding);
1313WGETAPI wget_iri * NULLABLE
1314 wget_iri_parse_base(const wget_iri *base, const char *url, const char *encoding);
1315WGETAPI wget_iri * NULLABLE
1316 wget_iri_clone(const wget_iri *iri);
1317WGETAPI const char * NULLABLE
1318 wget_iri_get_connection_part(const wget_iri *iri, wget_buffer *buf);
1319WGETAPI const char *
1320 wget_iri_relative_to_abs(const wget_iri *base, const char *val, size_t len, wget_buffer *buf);
1321WGETAPI const char *
1322 wget_iri_escape(const char *src, wget_buffer *buf);
1323WGETAPI const char *
1324 wget_iri_escape_path(const char *src, wget_buffer *buf) WGET_GCC_NONNULL_ALL;
1325WGETAPI const char *
1326 wget_iri_escape_query(const char *src, wget_buffer *buf) WGET_GCC_NONNULL_ALL;
1327WGETAPI const char *
1328 wget_iri_get_escaped_host(const wget_iri *iri, wget_buffer *buf) WGET_GCC_NONNULL_ALL;
1329WGETAPI const char *
1330 wget_iri_get_escaped_resource(const wget_iri *iri, wget_buffer *buf) WGET_GCC_NONNULL_ALL;
1331WGETAPI char *
1332 wget_iri_get_path(const wget_iri *iri, wget_buffer *buf, const char *encoding) WGET_GCC_NONNULL((1,2));
1333WGETAPI char *
1334 wget_iri_get_query_as_filename(const wget_iri *iri, wget_buffer *buf, const char *encoding) WGET_GCC_NONNULL((1,2));
1335WGETAPI char *
1336 wget_iri_get_basename(const wget_iri *iri, wget_buffer *buf, const char *encoding, int flags) WGET_GCC_NONNULL((1,2));
1337WGETAPI wget_iri_scheme
1338 wget_iri_set_scheme(wget_iri *iri, wget_iri_scheme scheme);
1339WGETAPI const char * NULLABLE
1340 wget_iri_scheme_get_name(wget_iri_scheme scheme);
1341
1342/*
1343 * Cookie routines
1344 */
1345
1346// typedef for cookie database
1347typedef struct wget_cookie_db_st wget_cookie_db;
1348
1349// typedef for cookie
1350typedef struct wget_cookie_st wget_cookie;
1351
1352WGETAPI wget_cookie * NULLABLE
1353 wget_cookie_init(wget_cookie *cookie);
1354WGETAPI void
1355 wget_cookie_deinit(wget_cookie *cookie);
1356WGETAPI void
1357 wget_cookie_free(wget_cookie **cookie);
1358WGETAPI char *
1359 wget_cookie_to_setcookie(wget_cookie *cookie);
1360WGETAPI const char *
1361 wget_cookie_parse_setcookie(const char *s, wget_cookie **cookie) WGET_GCC_NONNULL((1));
1362WGETAPI void
1363 wget_cookie_normalize_cookies(const wget_iri *iri, const wget_vector *cookies);
1364WGETAPI int
1365 wget_cookie_store_cookie(wget_cookie_db *cookie_db, wget_cookie *cookie);
1366WGETAPI void
1367 wget_cookie_store_cookies(wget_cookie_db *cookie_db, wget_vector *cookies);
1368WGETAPI int
1369 wget_cookie_normalize(const wget_iri *iri, wget_cookie *cookie);
1370WGETAPI int
1371 wget_cookie_check_psl(const wget_cookie_db *cookie_db, const wget_cookie *cookie);
1372WGETAPI wget_cookie_db * NULLABLE
1373 wget_cookie_db_init(wget_cookie_db *cookie_db);
1374WGETAPI void
1375 wget_cookie_db_deinit(wget_cookie_db *cookie_db);
1376WGETAPI void
1377 wget_cookie_db_free(wget_cookie_db **cookie_db);
1378WGETAPI void
1379 wget_cookie_set_keep_session_cookies(wget_cookie_db *cookie_db, bool keep);
1380WGETAPI int
1381 wget_cookie_db_save(wget_cookie_db *cookie_db, const char *fname);
1382WGETAPI int
1383 wget_cookie_db_load(wget_cookie_db *cookie_db, const char *fname);
1384WGETAPI int
1385 wget_cookie_db_load_psl(wget_cookie_db *cookie_db, const char *fname);
1386WGETAPI char *
1387 wget_cookie_create_request_header(wget_cookie_db *cookie_db, const wget_iri *iri);
1388
1389/*
1390 * HTTP Strict Transport Security (HSTS) routines
1391 */
1392
1399
1406
1407typedef int wget_hsts_host_match_fn(const wget_hsts_db *hsts_db, const char *host, uint16_t port);
1408typedef wget_hsts_db *wget_hsts_db_init_fn(wget_hsts_db *hsts_db, const char *fname);
1409typedef void wget_hsts_db_deinit_fn(wget_hsts_db *hsts_db);
1410typedef void wget_hsts_db_free_fn(wget_hsts_db **hsts_db);
1411typedef void wget_hsts_db_add_fn(wget_hsts_db *hsts_db, const char *host, uint16_t port, int64_t maxage, bool include_subdomains);
1412typedef int wget_hsts_db_save_fn(wget_hsts_db *hsts_db);
1413typedef int wget_hsts_db_load_fn(wget_hsts_db *hsts_db);
1414typedef void wget_hsts_db_set_fname_fn(wget_hsts_db *hsts_db, const char *fname);
1415
1416typedef struct {
1420 wget_hsts_db_init_fn *init;
1422 wget_hsts_db_deinit_fn *deinit;
1424 wget_hsts_db_free_fn *free;
1426 wget_hsts_db_add_fn *add;
1428 wget_hsts_db_load_fn *load;
1430 wget_hsts_db_save_fn *save;
1432
1433WGETAPI wget_hsts_host_match_fn wget_hsts_host_match;
1434WGETAPI wget_hsts_db_init_fn wget_hsts_db_init;
1435WGETAPI wget_hsts_db_deinit_fn wget_hsts_db_deinit;
1436WGETAPI wget_hsts_db_free_fn wget_hsts_db_free;
1437WGETAPI wget_hsts_db_add_fn wget_hsts_db_add;
1438WGETAPI wget_hsts_db_load_fn wget_hsts_db_load;
1439WGETAPI wget_hsts_db_save_fn wget_hsts_db_save;
1440WGETAPI void
1441 wget_hsts_db_set_fname(wget_hsts_db *hsts_db, const char *fname);
1442WGETAPI void
1443 wget_hsts_set_plugin(const wget_hsts_db_vtable *vtable);
1444
1445/*
1446 * HTTP Public Key Pinning (HPKP)
1447 */
1448
1455
1461typedef struct wget_hpkp_st wget_hpkp;
1462
1463/* FIXME: the following entries are not used. review the hpkp function return values ! */
1470#define WGET_HPKP_OK 0
1472#define WGET_HPKP_ERROR -1
1474#define WGET_HPKP_ENTRY_EXPIRED -2
1476#define WGET_HPKP_WAS_DELETED -3
1478#define WGET_HPKP_NOT_ENOUGH_PINS -4
1480#define WGET_HPKP_ENTRY_EXISTS -5
1482#define WGET_HPKP_ERROR_FILE_OPEN -6
1484
1491
1492typedef wget_hpkp_db *wget_hpkp_db_init_fn(wget_hpkp_db *hpkp_db, const char *fname);
1493typedef void wget_hpkp_db_deinit_fn(wget_hpkp_db *hpkp_db);
1494typedef void wget_hpkp_db_free_fn(wget_hpkp_db **hpkp_db);
1495typedef int wget_hpkp_db_check_pubkey_fn(wget_hpkp_db *hpkp_db, const char *host, const void *pubkey, size_t pubkeysize);
1496typedef void wget_hpkp_db_add_fn(wget_hpkp_db *hpkp_db, wget_hpkp **hpkp);
1497typedef int wget_hpkp_db_load_fn(wget_hpkp_db *hpkp_db);
1498typedef int wget_hpkp_db_save_fn(wget_hpkp_db *hpkp_db);
1499
1500typedef struct {
1504 wget_hpkp_db_deinit_fn *deinit;
1506 wget_hpkp_db_free_fn *free;
1508 wget_hpkp_db_check_pubkey_fn *check_pubkey;
1510 wget_hpkp_db_add_fn *add;
1512 wget_hpkp_db_load_fn *load;
1514 wget_hpkp_db_save_fn *save;
1516
1517WGETAPI wget_hpkp * NULLABLE
1518 wget_hpkp_new(void);
1519WGETAPI void
1521WGETAPI void
1522 wget_hpkp_pin_add(wget_hpkp *hpkp, const char *pin_type, const char *pin_b64);
1523WGETAPI void
1524 wget_hpkp_set_host(wget_hpkp *hpkp, const char *host);
1525WGETAPI void
1526 wget_hpkp_set_maxage(wget_hpkp *hpkp, int64_t maxage);
1527WGETAPI void
1528 wget_hpkp_set_include_subdomains(wget_hpkp *hpkp, bool include_subdomains);
1529WGETAPI int
1531WGETAPI void
1532 wget_hpkp_get_pins_b64(wget_hpkp *hpkp, const char **pin_types, const char **pins_b64);
1533WGETAPI void
1534 wget_hpkp_get_pins(wget_hpkp *hpkp, const char **pin_types, size_t *sizes, const void **pins);
1535WGETAPI const char *
1537WGETAPI int64_t
1539WGETAPI bool
1541
1542WGETAPI wget_hpkp_db_init_fn wget_hpkp_db_init;
1543WGETAPI wget_hpkp_db_deinit_fn wget_hpkp_db_deinit;
1544WGETAPI wget_hpkp_db_free_fn wget_hpkp_db_free;
1545WGETAPI wget_hpkp_db_check_pubkey_fn wget_hpkp_db_check_pubkey;
1546WGETAPI wget_hpkp_db_add_fn wget_hpkp_db_add;
1547WGETAPI wget_hpkp_db_load_fn wget_hpkp_db_load;
1548WGETAPI wget_hpkp_db_save_fn wget_hpkp_db_save;
1549WGETAPI void
1550 wget_hpkp_db_set_fname(wget_hpkp_db *hpkp_db, const char *fname);
1551WGETAPI void
1552 wget_hpkp_set_plugin(const wget_hpkp_db_vtable *vtable);
1553
1554/*
1555 * TLS session resumption
1556 */
1557
1558// structure for TLS resumption cache entries
1559typedef struct wget_tls_session_st wget_tls_session;
1560typedef struct wget_tls_session_db_st wget_tls_session_db;
1561
1562WGETAPI wget_tls_session * NULLABLE
1563 wget_tls_session_init(wget_tls_session *tls_session);
1564WGETAPI void
1565 wget_tls_session_deinit(wget_tls_session *tls_session);
1566WGETAPI void
1567 wget_tls_session_free(wget_tls_session *tls_session);
1568WGETAPI wget_tls_session * NULLABLE
1569 wget_tls_session_new(const char *host, int64_t maxage, const void *data, size_t data_size);
1570WGETAPI int
1571 wget_tls_session_get(const wget_tls_session_db *tls_session_db, const char *host, void **data, size_t *size);
1572WGETAPI wget_tls_session_db * NULLABLE
1573 wget_tls_session_db_init(wget_tls_session_db *tls_session_db);
1574WGETAPI void
1575 wget_tls_session_db_deinit(wget_tls_session_db *tls_session_db);
1576WGETAPI void
1577 wget_tls_session_db_free(wget_tls_session_db **tls_session_db);
1578WGETAPI void
1579 wget_tls_session_db_add(wget_tls_session_db *tls_session_db, wget_tls_session *tls_session);
1580WGETAPI int
1581 wget_tls_session_db_save(wget_tls_session_db *tls_session_db, const char *fname);
1582WGETAPI int
1583 wget_tls_session_db_load(wget_tls_session_db *tls_session_db, const char *fname);
1584WGETAPI int
1585 wget_tls_session_db_changed(wget_tls_session_db *tls_session_db) WGET_GCC_PURE;
1586
1587/*
1588 * Online Certificate Status Protocol (OCSP) routines
1589 */
1590
1597
1604
1605typedef wget_ocsp_db *wget_ocsp_db_init_fn(wget_ocsp_db *ocsp_db, const char *fname);
1606typedef void wget_ocsp_db_deinit_fn(wget_ocsp_db *ocsp_db);
1607typedef void wget_ocsp_db_free_fn(wget_ocsp_db **ocsp_db);
1608typedef bool wget_ocsp_fingerprint_in_cache_fn(const wget_ocsp_db *ocsp_db, const char *fingerprint, int *valid);
1609typedef bool wget_ocsp_hostname_is_valid_fn(const wget_ocsp_db *ocsp_db, const char *hostname);
1610typedef void wget_ocsp_db_add_fingerprint_fn(wget_ocsp_db *ocsp_db, const char *fingerprint, int64_t maxage, bool valid);
1611typedef void wget_ocsp_db_add_host_fn(wget_ocsp_db *ocsp_db, const char *host, int64_t maxage);
1612typedef int wget_ocsp_db_save_fn(wget_ocsp_db *ocsp_db);
1613typedef int wget_ocsp_db_load_fn(wget_ocsp_db *ocsp_db);
1614
1615typedef struct {
1619 wget_ocsp_db_deinit_fn *deinit;
1621 wget_ocsp_db_free_fn *free;
1623 wget_ocsp_fingerprint_in_cache_fn *fingerprint_in_cache;
1625 wget_ocsp_hostname_is_valid_fn *hostname_is_valid;
1627 wget_ocsp_db_add_fingerprint_fn *add_fingerprint;
1629 wget_ocsp_db_add_host_fn *add_host;
1631 wget_ocsp_db_save_fn *load;
1633 wget_ocsp_db_load_fn *save;
1635
1636WGETAPI wget_ocsp_db_init_fn wget_ocsp_db_init;
1637WGETAPI wget_ocsp_db_deinit_fn wget_ocsp_db_deinit;
1638WGETAPI wget_ocsp_db_free_fn wget_ocsp_db_free;
1639WGETAPI wget_ocsp_fingerprint_in_cache_fn wget_ocsp_fingerprint_in_cache;
1640WGETAPI wget_ocsp_hostname_is_valid_fn wget_ocsp_hostname_is_valid;
1641WGETAPI wget_ocsp_db_add_fingerprint_fn wget_ocsp_db_add_fingerprint;
1642WGETAPI wget_ocsp_db_add_host_fn wget_ocsp_db_add_host;
1643WGETAPI wget_ocsp_db_save_fn wget_ocsp_db_save;
1644WGETAPI wget_ocsp_db_load_fn wget_ocsp_db_load;
1645WGETAPI void
1646 wget_ocsp_db_set_fname(wget_ocsp_db *ocsp_db, const char *fname);
1647WGETAPI void
1648 wget_ocsp_set_plugin(const wget_ocsp_db_vtable *vtable);
1649
1650/*
1651 * .netrc routines
1652 */
1653
1657typedef struct wget_netrc_db_st wget_netrc_db;
1658
1666 const char *
1668 const char *
1670 const char *
1672 uint16_t
1674 bool
1675 force : 1;
1676};
1677typedef struct wget_netrc_st wget_netrc;
1678
1679WGETAPI wget_netrc * NULLABLE
1680 wget_netrc_init(wget_netrc *netrc);
1681WGETAPI void
1682 wget_netrc_deinit(wget_netrc *netrc);
1683WGETAPI void
1684 wget_netrc_free(wget_netrc *netrc);
1685WGETAPI wget_netrc * NULLABLE
1686 wget_netrc_new(const char *machine, const char *login, const char *password);
1687WGETAPI wget_netrc_db *
1688 wget_netrc_db_init(wget_netrc_db *netrc_db);
1689WGETAPI void
1690 wget_netrc_db_deinit(wget_netrc_db *netrc_db);
1691WGETAPI void
1692 wget_netrc_db_free(wget_netrc_db **netrc_db);
1693WGETAPI void
1694 wget_netrc_db_add(wget_netrc_db *netrc_db, wget_netrc *netrc);
1695WGETAPI wget_netrc * NULLABLE
1696 wget_netrc_get(const wget_netrc_db *netrc_db, const char *host);
1697WGETAPI int
1698 wget_netrc_db_load(wget_netrc_db *netrc_db, const char *fname);
1699
1700/*
1701 * CSS parsing routines
1702 */
1703
1705 size_t
1707 size_t
1709 const char *
1711 const char *
1713};
1714typedef struct wget_css_parsed_url_st wget_css_parsed_url;
1715
1716typedef void wget_css_parse_uri_callback(void *user_ctx, const char *url, size_t len, size_t pos);
1717typedef void wget_css_parse_encoding_callback(void *user_ctx, const char *url, size_t len);
1718
1719WGETAPI void
1720 wget_css_parse_buffer(
1721 const char *buf,
1722 size_t len,
1723 wget_css_parse_uri_callback *callback_uri,
1724 wget_css_parse_encoding_callback *callback_encoding,
1725 void *user_ctx) WGET_GCC_NONNULL((1));
1726WGETAPI void
1727 wget_css_parse_file(
1728 const char *fname,
1729 wget_css_parse_uri_callback *callback_uri,
1730 wget_css_parse_encoding_callback *callback_encoding,
1731 void *user_ctx) WGET_GCC_NONNULL((1));
1732WGETAPI wget_vector *
1733 wget_css_get_urls(
1734 const char *css,
1735 size_t len,
1736 wget_iri *base,
1737 const char **encoding) WGET_GCC_NONNULL((1));
1738WGETAPI wget_vector *
1739 wget_css_get_urls_from_localfile(
1740 const char *fname,
1741 wget_iri *base,
1742 const char **encoding) WGET_GCC_NONNULL((1));
1743
1744typedef struct {
1745 const char
1746 *p;
1747 size_t
1749} wget_string;
1750
1751typedef struct {
1756 char
1757 attr[16];
1758 char
1759 tag[16];
1760 bool
1763
1764typedef struct {
1765 wget_vector
1767 const char *
1771 bool
1774
1778typedef struct {
1779 const char *
1781 const char *
1784
1785WGETAPI wget_html_parsed_result * NULLABLE
1786 wget_html_get_urls_inline(const char *html, wget_vector *additional_tags, wget_vector *ignore_tags);
1787WGETAPI void
1788 wget_html_free_urls_inline(wget_html_parsed_result **res);
1789WGETAPI void
1790 wget_sitemap_get_urls_inline(const char *sitemap, wget_vector **urls, wget_vector **sitemap_urls);
1791WGETAPI void
1792 wget_atom_get_urls_inline(const char *atom, wget_vector **urls);
1793WGETAPI void
1794 wget_rss_get_urls_inline(const char *rss, wget_vector **urls);
1795
1796/*
1797 * XML and HTML parsing routines
1798 */
1799
1800#define XML_FLG_BEGIN (1<<0) // <
1801#define XML_FLG_CLOSE (1<<1) // >
1802#define XML_FLG_END (1<<2) // </elem>
1803#define XML_FLG_ATTRIBUTE (1<<3) // attr="value"
1804#define XML_FLG_CONTENT (1<<4)
1805#define XML_FLG_COMMENT (1<<5) // <!-- ... -->
1806//#define XML_FLG_CDATA (1<<6) // <![CDATA[...]]>, now same handling as 'special'
1807#define XML_FLG_PROCESSING (1<<7) // e.g. <? ... ?>
1808#define XML_FLG_SPECIAL (1<<8) // e.g. <!DOCTYPE ...>
1809
1810#define XML_HINT_REMOVE_EMPTY_CONTENT (1<<0) // merge spaces, remove empty content
1811#define XML_HINT_HTML (1<<1) // parse HTML instead of XML
1812
1813#define HTML_HINT_REMOVE_EMPTY_CONTENT XML_HINT_REMOVE_EMPTY_CONTENT
1814
1815typedef void wget_xml_callback(void *, int, const char *, const char *, const char *, size_t, size_t);
1816
1817WGETAPI int
1819 const char *buf,
1820 wget_xml_callback *callback,
1821 void *user_ctx,
1822 int hints) WGET_GCC_NONNULL((1));
1823WGETAPI void
1825 const char *fname,
1826 wget_xml_callback *callback,
1827 void *user_ctx,
1828 int hints) WGET_GCC_NONNULL((1));
1829WGETAPI void
1831 const char *buf,
1832 wget_xml_callback *callback,
1833 void *user_ctx,
1834 int hints) WGET_GCC_NONNULL((1));
1835WGETAPI void
1837 const char *fname,
1838 wget_xml_callback *callback,
1839 void *user_ctx,
1840 int hints) WGET_GCC_NONNULL((1));
1841WGETAPI char *
1842 wget_xml_decode_entities_inline(char *src) WGET_GCC_NONNULL((1));
1843
1844/*
1845 * DNS caching routines
1846 */
1847
1848typedef struct wget_dns_cache_st wget_dns_cache;
1849
1850WGETAPI int
1851 wget_dns_cache_init(wget_dns_cache **cache);
1852WGETAPI void
1853 wget_dns_cache_free(wget_dns_cache **cache);
1854WGETAPI struct addrinfo * NULLABLE
1855 wget_dns_cache_get(wget_dns_cache *cache, const char *host, uint16_t port);
1856WGETAPI int
1857 wget_dns_cache_add(wget_dns_cache *cache, const char *host, uint16_t port, struct addrinfo **addrinfo);
1858
1859/*
1860 * DNS resolving routines
1861 */
1862
1863typedef struct wget_dns_st wget_dns;
1864
1865WGETAPI int
1866 wget_dns_init(wget_dns **dns);
1867WGETAPI void
1868 wget_dns_free(wget_dns **dns);
1869WGETAPI void
1870 wget_dns_set_timeout(wget_dns *dns, int timeout);
1871WGETAPI void
1872 wget_dns_set_cache(wget_dns *dns, wget_dns_cache *cache);
1873WGETAPI wget_dns_cache * NULLABLE
1874 wget_dns_get_cache(wget_dns *dns) WGET_GCC_PURE;
1875WGETAPI struct addrinfo * NULLABLE
1876 wget_dns_resolve(wget_dns *dns, const char *host, uint16_t port, int family, int preferred_family);
1877WGETAPI void
1878 wget_dns_freeaddrinfo(wget_dns *dns, struct addrinfo **addrinfo);
1879WGETAPI int
1880 wget_dns_cache_ip(wget_dns *dns, const char *ip, const char *name, uint16_t port);
1881
1882/*
1883 * TCP network routines
1884 */
1885
1886#define WGET_NET_FAMILY_ANY 0
1887#define WGET_NET_FAMILY_IPV4 1
1888#define WGET_NET_FAMILY_IPV6 2
1889
1890#define WGET_PROTOCOL_HTTP_1_1 0
1891#define WGET_PROTOCOL_HTTP_2_0 1
1892
1893typedef struct wget_tcp_st wget_tcp;
1894
1895WGETAPI int
1896 wget_net_init(void);
1897WGETAPI int
1898 wget_net_deinit(void);
1899WGETAPI wget_tcp * NULLABLE
1900 wget_tcp_init(void);
1901WGETAPI void
1902 wget_tcp_deinit(wget_tcp **tcp);
1903WGETAPI void
1904 wget_tcp_close(wget_tcp *tcp);
1905WGETAPI void
1906 wget_tcp_set_dns(wget_tcp *tcp, wget_dns *dns);
1907WGETAPI void
1908 wget_tcp_set_timeout(wget_tcp *tcp, int timeout);
1909WGETAPI int
1910 wget_tcp_get_timeout(wget_tcp *tcp) WGET_GCC_PURE;
1911WGETAPI void
1912 wget_tcp_set_connect_timeout(wget_tcp *tcp, int timeout);
1913WGETAPI void
1914 wget_tcp_set_tcp_fastopen(wget_tcp *tcp, bool tcp_fastopen);
1915WGETAPI void
1916 wget_tcp_set_tls_false_start(wget_tcp *tcp, bool false_start);
1917WGETAPI void
1918 wget_tcp_set_ssl(wget_tcp *tcp, bool ssl);
1919WGETAPI bool
1920 wget_tcp_get_ssl(wget_tcp *tcp) WGET_GCC_PURE;
1921WGETAPI const char * NULLABLE
1922 wget_tcp_get_ip(wget_tcp *tcp) WGET_GCC_PURE;
1923WGETAPI void
1924 wget_tcp_set_ssl_hostname(wget_tcp *tcp, const char *hostname);
1925WGETAPI const char *
1926 wget_tcp_get_ssl_hostname(wget_tcp *tcp) WGET_GCC_PURE;
1927WGETAPI void
1928 wget_tcp_set_ssl_ca_file(wget_tcp *tcp, const char *cafile);
1929WGETAPI void
1930 wget_tcp_set_ssl_key_file(wget_tcp *tcp, const char *certfile, const char *keyfile);
1931WGETAPI bool
1932 wget_tcp_get_tcp_fastopen(wget_tcp *tcp) WGET_GCC_PURE;
1933WGETAPI bool
1934 wget_tcp_get_tls_false_start(wget_tcp *tcp) WGET_GCC_PURE;
1935WGETAPI int
1936 wget_tcp_get_family(wget_tcp *tcp) WGET_GCC_PURE;
1937WGETAPI int
1938 wget_tcp_get_preferred_family(wget_tcp *tcp) WGET_GCC_PURE;
1939WGETAPI int
1940 wget_tcp_get_protocol(wget_tcp *tcp) WGET_GCC_PURE;
1941WGETAPI int
1942 wget_tcp_get_local_port(wget_tcp *tcp);
1943WGETAPI void
1944 wget_tcp_set_debug(wget_tcp *tcp, int debug);
1945WGETAPI void
1946 wget_tcp_set_family(wget_tcp *tcp, int family);
1947WGETAPI void
1948 wget_tcp_set_preferred_family(wget_tcp *tcp, int family);
1949WGETAPI void
1950 wget_tcp_set_protocol(wget_tcp *tcp, int protocol);
1951WGETAPI void
1952 wget_tcp_set_bind_address(wget_tcp *tcp, const char *bind_address);
1953WGETAPI void
1954 wget_tcp_set_bind_interface(wget_tcp *tcp, const char *bind_interface);
1955WGETAPI int
1956 wget_tcp_connect(wget_tcp *tcp, const char *host, uint16_t port);
1957WGETAPI int
1958 wget_tcp_tls_start(wget_tcp *tcp);
1959WGETAPI void
1960 wget_tcp_tls_stop(wget_tcp *tcp);
1961WGETAPI ssize_t
1962 wget_tcp_vprintf(wget_tcp *tcp, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(2,0);
1963WGETAPI ssize_t
1964 wget_tcp_printf(wget_tcp *tcp, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(2,3);
1965WGETAPI ssize_t
1966 wget_tcp_write(wget_tcp *tcp, const char *buf, size_t count);
1967WGETAPI ssize_t
1968 wget_tcp_read(wget_tcp *tcp, char *buf, size_t count);
1969WGETAPI int
1970 wget_tcp_ready_2_transfer(wget_tcp *tcp, int flags);
1971
1972WGETAPI bool
1973 wget_ip_is_family(const char *host, int family) WGET_GCC_PURE;
1974
1975/*
1976 * SSL routines
1977 */
1978
1979#define WGET_SSL_X509_FMT_PEM 0
1980#define WGET_SSL_X509_FMT_DER 1
1981
1982#define WGET_SSL_SECURE_PROTOCOL 1
1983#define WGET_SSL_CA_DIRECTORY 2
1984#define WGET_SSL_CA_FILE 3
1985#define WGET_SSL_CERT_FILE 4
1986#define WGET_SSL_KEY_FILE 5
1987#define WGET_SSL_CA_TYPE 6
1988#define WGET_SSL_CERT_TYPE 7
1989#define WGET_SSL_KEY_TYPE 8
1990#define WGET_SSL_CHECK_CERTIFICATE 9
1991#define WGET_SSL_CHECK_HOSTNAME 10
1992#define WGET_SSL_PRINT_INFO 11
1993#define WGET_SSL_CRL_FILE 13
1994#define WGET_SSL_OCSP_STAPLING 14
1995#define WGET_SSL_OCSP_SERVER 15
1996#define WGET_SSL_OCSP 16
1997#define WGET_SSL_OCSP_CACHE 17
1998#define WGET_SSL_ALPN 18
1999#define WGET_SSL_SESSION_CACHE 19
2000#define WGET_SSL_HPKP_CACHE 20
2001#define WGET_SSL_OCSP_NONCE 21
2002#define WGET_SSL_OCSP_DATE 22
2003#define WGET_SSL_REPORT_INVALID_CERT 23
2004#define WGET_SSL_DANE 24
2005
2006WGETAPI void
2007 wget_ssl_init(void);
2008WGETAPI void
2009 wget_ssl_deinit(void);
2010WGETAPI void
2011 wget_ssl_set_config_string(int key, const char *value);
2012WGETAPI void
2013 wget_ssl_set_config_object(int key, void *value);
2014WGETAPI void
2015 wget_ssl_set_config_int(int key, int value);
2016WGETAPI int
2017 wget_ssl_open(wget_tcp *tcp);
2018WGETAPI void
2019 wget_ssl_close(void **session);
2020WGETAPI void
2021 wget_ssl_set_check_certificate(char value);
2022WGETAPI ssize_t
2023 wget_ssl_read_timeout(void *session, char *buf, size_t count, int timeout) WGET_GCC_NONNULL_ALL;
2024WGETAPI ssize_t
2025 wget_ssl_write_timeout(void *session, const char *buf, size_t count, int timeout) WGET_GCC_NONNULL_ALL;
2026WGETAPI const char *
2027 wget_ssl_default_cert_dir(void);
2028WGETAPI const char *
2029 wget_ssl_default_ca_bundle_path(void);
2030
2031/*
2032 * HTTP routines
2033 */
2034
2038typedef struct {
2039 const char *
2041 const char *
2044
2048typedef struct {
2049 const char *
2051 const char *
2053 int
2055 enum {
2056 link_rel_none = 0,
2057 link_rel_describedby,
2058 link_rel_duplicate
2059 } rel;
2061
2065typedef struct {
2066 const char *
2068 const char *
2071
2075typedef struct {
2076 const char *
2081
2082typedef enum {
2083 wget_transfer_encoding_identity = 0,
2084 wget_transfer_encoding_chunked = 1
2085} wget_transfer_encoding;
2086
2087typedef struct wget_http_response_st wget_http_response;
2088typedef int wget_http_header_callback(wget_http_response *, void *);
2089typedef int wget_http_body_callback(wget_http_response *, void *, const char *, size_t);
2090
2094typedef struct {
2095 wget_vector *
2097 const char *
2099 wget_http_header_callback
2101 wget_http_body_callback
2103 void *
2105 void *
2107 void *
2113 size_t
2115 int32_t
2117 wget_iri_scheme
2119 char
2121 char
2123 char
2125 bool
2127 bool
2129 bool
2131 long long
2133 long long
2135
2137
2143 req;
2144 wget_vector *
2145 links;
2146 wget_vector *
2147 digests;
2148 wget_vector *
2149 cookies;
2150 wget_vector *
2151 challenges;
2152 wget_hpkp *
2153 hpkp;
2154 const char *
2155 content_type;
2156 const char *
2157 content_type_encoding;
2158 const char *
2159 content_filename;
2160 const char *
2161 location;
2162 const char *
2164 wget_buffer *
2166 wget_buffer *
2168 long long
2170 size_t
2172 size_t
2173 cur_downloaded,
2174 accounted_for; // reported to bar
2175 int64_t
2176 last_modified;
2177 int64_t
2178 hsts_maxage;
2179 char
2181 int
2183 short
2185 short
2187 short
2189 wget_transfer_encoding
2190 transfer_encoding;
2191 char
2192 content_encoding;
2193 bool
2194 hsts_include_subdomains,
2195 keep_alive;
2196 bool
2197 content_length_valid : 1,
2199 hsts : 1,
2200 csp : 1;
2201};
2202
2203typedef struct wget_http_connection_st wget_http_connection;
2204
2205WGETAPI const char *
2206 wget_http_get_host(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL;
2207WGETAPI uint16_t
2208 wget_http_get_port(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL;
2209WGETAPI wget_iri_scheme
2210 wget_http_get_scheme(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL;
2211WGETAPI int
2212 wget_http_get_protocol(const wget_http_connection *conn) WGET_GCC_NONNULL_ALL;
2213
2214WGETAPI bool
2215 wget_http_isseparator(char c) WGET_GCC_CONST;
2216WGETAPI bool
2217 wget_http_istoken(char c) WGET_GCC_CONST;
2218
2219WGETAPI const char *
2220 wget_http_parse_token(const char *s, const char **token) WGET_GCC_NONNULL_ALL;
2221WGETAPI const char *
2222 wget_http_parse_quoted_string(const char *s, const char **qstring) WGET_GCC_NONNULL_ALL;
2223WGETAPI const char *
2224 wget_http_parse_param(const char *s, const char **param, const char **value) WGET_GCC_NONNULL_ALL;
2225WGETAPI const char *
2226 wget_http_parse_name(const char *s, const char **name) WGET_GCC_NONNULL_ALL;
2227WGETAPI const char *
2228 wget_parse_name_fixed(const char *s, const char **name, size_t *namelen) WGET_GCC_NONNULL_ALL;
2229WGETAPI int64_t
2230 wget_http_parse_full_date(const char *s) WGET_GCC_NONNULL_ALL;
2231WGETAPI const char *
2232 wget_http_parse_link(const char *s, wget_http_link *link) WGET_GCC_NONNULL_ALL;
2233WGETAPI const char *
2234 wget_http_parse_digest(const char *s, wget_http_digest *digest) WGET_GCC_NONNULL_ALL;
2235WGETAPI const char *
2236 wget_http_parse_challenge(const char *s, wget_http_challenge *challenge) WGET_GCC_NONNULL_ALL;
2237WGETAPI const char *
2238 wget_http_parse_challenges(const char *s, wget_vector *challenges) WGET_GCC_NONNULL_ALL;
2239WGETAPI const char *
2240 wget_http_parse_location(const char *s, const char **location) WGET_GCC_NONNULL_ALL;
2241WGETAPI const char *
2242 wget_http_parse_transfer_encoding(const char *s, wget_transfer_encoding *transfer_encoding) WGET_GCC_NONNULL_ALL;
2243WGETAPI const char *
2244 wget_http_parse_content_type(const char *s, const char **content_type, const char **charset) WGET_GCC_NONNULL((1));
2245WGETAPI const char *
2246 wget_http_parse_content_encoding(const char *s, char *content_encoding) WGET_GCC_NONNULL_ALL;
2247WGETAPI const char *
2248 wget_http_parse_content_disposition(const char *s, const char **filename) WGET_GCC_NONNULL((1));
2249WGETAPI const char *
2250 wget_http_parse_strict_transport_security(const char *s, int64_t *maxage, bool *include_subdomains) WGET_GCC_NONNULL_ALL;
2251WGETAPI const char *
2252 wget_http_parse_public_key_pins(const char *s, wget_hpkp *hpkp) WGET_GCC_NONNULL((1));
2253WGETAPI const char *
2254 wget_http_parse_connection(const char *s, bool *keep_alive) WGET_GCC_NONNULL_ALL;
2255WGETAPI const char *
2256 wget_http_parse_setcookie(const char *s, wget_cookie **cookie) WGET_GCC_NONNULL((1));
2257WGETAPI const char *
2258 wget_http_parse_etag(const char *s, const char **etag) WGET_GCC_NONNULL((1));
2259
2260WGETAPI char *
2261 wget_http_print_date(int64_t t, char *buf, size_t bufsize) WGET_GCC_NONNULL_ALL;
2262
2263WGETAPI void
2264 wget_http_add_param(wget_vector **params, wget_http_header_param *param) WGET_GCC_NONNULL_ALL;
2265WGETAPI int
2266 wget_http_add_header_vprintf(wget_http_request *req, const char *name, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(3,0) WGET_GCC_NONNULL_ALL;
2267WGETAPI int
2268 wget_http_add_header_printf(wget_http_request *req, const char *name, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4) WGET_GCC_NONNULL((1,2,3));
2269WGETAPI int
2270 wget_http_add_header(wget_http_request *req, const char *name, const char *value) WGET_GCC_NONNULL_ALL;
2271WGETAPI int
2272 wget_http_add_header_param(wget_http_request *req, wget_http_header_param *param) WGET_GCC_NONNULL((1));
2273WGETAPI void
2274 wget_http_add_credentials(wget_http_request *req, wget_http_challenge *challenge, const char *username, const char *password, int proxied) WGET_GCC_NONNULL((1));
2275WGETAPI int
2276 wget_http_set_http_proxy(const char *proxy, const char *encoding);
2277WGETAPI int
2278 wget_http_set_https_proxy(const char *proxy, const char *encoding);
2279WGETAPI int
2280 wget_http_set_no_proxy(const char *no_proxy, const char *encoding);
2281WGETAPI const wget_vector *
2282 wget_http_get_no_proxy(void);
2283WGETAPI int
2284 wget_http_match_no_proxy(const wget_vector *no_proxies, const char *host);
2285WGETAPI void
2286 wget_http_abort_connection(wget_http_connection *conn);
2287WGETAPI bool
2288 wget_http_connection_receive_only(wget_http_connection *conn);
2289
2290WGETAPI void
2291 wget_http_free_param(wget_http_header_param *param);
2292WGETAPI void
2293 wget_http_free_cookie(wget_cookie *cookie);
2294WGETAPI void
2295 wget_http_free_digest(wget_http_digest *digest);
2296WGETAPI void
2297 wget_http_free_challenge(wget_http_challenge *challenge);
2298WGETAPI void
2299 wget_http_free_link(wget_http_link *link);
2300
2301WGETAPI void
2302 wget_http_free_cookies(wget_vector **cookies);
2303WGETAPI void
2304 wget_http_free_hpkp_entries(wget_hpkp **hpkp);
2305WGETAPI void
2306 wget_http_free_digests(wget_vector **digests);
2307WGETAPI void
2308 wget_http_free_challenges(wget_vector **challenges);
2309WGETAPI void
2310 wget_http_free_links(wget_vector **links);
2311//WGETAPI void
2312// wget_http_free_header(HTTP_HEADER **header);
2313WGETAPI void
2314 wget_http_free_request(wget_http_request **req);
2315WGETAPI void
2316 wget_http_free_response(wget_http_response **resp);
2317
2318WGETAPI int
2319 wget_http_parse_header_line(wget_http_response *resp, const char *name, size_t namelen, const char *value, size_t valuelen);
2320WGETAPI wget_http_response * NULLABLE
2321 wget_http_parse_response_header(char *buf) WGET_GCC_NONNULL_ALL;
2322WGETAPI wget_http_response * NULLABLE
2323 wget_http_get_response_cb(wget_http_connection *conn) WGET_GCC_NONNULL((1));
2324//WGETAPI HTTP_RESPONSE *
2325// http_get_response_mem(HTTP_CONNECTION *conn, HTTP_REQUEST *req) NONNULL_ALL;
2326WGETAPI wget_http_response * NULLABLE
2327 wget_http_get_response(wget_http_connection *conn) WGET_GCC_NONNULL((1));
2328
2329WGETAPI void
2330 wget_http_init(void);
2331WGETAPI void
2332 wget_http_exit(void);
2333WGETAPI int
2334 wget_http_open(wget_http_connection **_conn, const wget_iri *iri);
2335WGETAPI wget_http_request * NULLABLE
2336 wget_http_create_request(const wget_iri *iri, const char *method) WGET_GCC_NONNULL_ALL;
2337WGETAPI void
2338 wget_http_close(wget_http_connection **conn) WGET_GCC_NONNULL_ALL;
2339WGETAPI void
2340 wget_http_request_set_header_cb(wget_http_request *req, wget_http_header_callback *cb, void *user_data) WGET_GCC_NONNULL((1));
2341WGETAPI void
2342 wget_http_request_set_body_cb(wget_http_request *req, wget_http_body_callback *cb, void *user_data) WGET_GCC_NONNULL((1));
2343WGETAPI void
2344 wget_http_request_set_int(wget_http_request *req, int key, int value) WGET_GCC_NONNULL((1));
2345WGETAPI int
2346 wget_http_request_get_int(wget_http_request *req, int key) WGET_GCC_NONNULL((1));
2347WGETAPI void
2348 wget_http_request_set_ptr(wget_http_request *req, int key, void *value) WGET_GCC_NONNULL((1));
2349WGETAPI void *
2350 wget_http_request_get_ptr(wget_http_request *req, int key) WGET_GCC_NONNULL((1));
2351WGETAPI void
2352 wget_http_request_set_body(wget_http_request *req, const char *mimetype, char *body, size_t length) WGET_GCC_NONNULL((1));
2353WGETAPI int
2354 wget_http_send_request(wget_http_connection *conn, wget_http_request *req) WGET_GCC_NONNULL_ALL;
2355WGETAPI ssize_t
2356 wget_http_request_to_buffer(wget_http_request *req, wget_buffer *buf, int proxied, int port) WGET_GCC_NONNULL_ALL;
2357
2358/*
2359 * Highlevel HTTP routines
2360 */
2361
2362WGETAPI wget_http_response *
2363 wget_http_get(int first_key, ...);
2364
2365
2366/*
2367 * random routines
2368 */
2369
2370WGETAPI void
2371 wget_random_init(void);
2372WGETAPI void
2373 wget_random_exit(void);
2374WGETAPI int
2375 wget_random(void);
2376WGETAPI void
2377 wget_srandom(unsigned int seed);
2378
2379
2385
2402
2404 wget_hash_get_algorithm(const char *hashname);
2405WGETAPI int
2406 wget_hash_fast(wget_digest_algorithm algorithm, const void *text, size_t textlen, void *digest);
2407WGETAPI int
2408 wget_hash_get_len(wget_digest_algorithm algorithm) WGET_GCC_CONST;
2409WGETAPI int
2410 wget_hash_init(wget_hash_hd **dig, wget_digest_algorithm algorithm);
2411WGETAPI int
2412 wget_hash(wget_hash_hd *handle, const void *text, size_t textlen);
2413WGETAPI int
2414 wget_hash_deinit(wget_hash_hd **handle, void *digest);
2415
2416/*
2417 * Hash file routines
2418 */
2419
2420WGETAPI int
2421 wget_hash_file_fd(const char *hashname, int fd, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length) WGET_GCC_NONNULL_ALL;
2422WGETAPI int
2423 wget_hash_file_offset(const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size, off_t offset, off_t length) WGET_GCC_NONNULL_ALL;
2424WGETAPI int
2425 wget_hash_file(const char *hashname, const char *fname, char *digest_hex, size_t digest_hex_size) WGET_GCC_NONNULL_ALL;
2426
2427/*
2428 * Hash convenience routines
2429 */
2430
2431// don't use 'restrict' here as out, fmt and argument pointers may overlap
2432WGETAPI void WGET_GCC_PRINTF_FORMAT(4,5) WGET_GCC_NONNULL_ALL
2433 wget_hash_printf_hex(wget_digest_algorithm algorithm, char *out, size_t outsize, const char *fmt, ...);
2434
2435
2436/*
2437 * Metalink types and routines
2438 */
2439
2440typedef struct {
2441 const wget_iri
2443 int
2445 char
2448
2449typedef struct {
2450 char
2451 type[16],
2452 hash_hex[128+1];
2454
2455// Metalink piece, for checksumming after download
2456typedef struct {
2459 off_t
2461 off_t
2464
2465typedef struct {
2466 const char
2468 wget_vector
2472 off_t
2475
2476WGETAPI wget_metalink * NULLABLE
2477 wget_metalink_parse(const char *xml);
2478WGETAPI void
2479 wget_metalink_free(wget_metalink **metalink);
2480WGETAPI void
2481 wget_metalink_sort_mirrors(wget_metalink *metalink);
2482
2483/*
2484 * Robots types and routines
2485 */
2486
2487typedef struct wget_robots_st wget_robots;
2488
2489WGETAPI int
2490 wget_robots_parse(wget_robots **robots, const char *data, const char *client);
2491WGETAPI void
2492 wget_robots_free(wget_robots **robots);
2493WGETAPI int
2494 wget_robots_get_path_count(wget_robots *robots);
2495WGETAPI wget_string * NULLABLE
2496 wget_robots_get_path(wget_robots *robots, int index);
2497WGETAPI int
2498 wget_robots_get_sitemap_count(wget_robots *robots);
2499WGETAPI const char * NULLABLE
2500 wget_robots_get_sitemap(wget_robots *robots, int index);
2501
2502/*
2503 * Progress bar routines
2504 */
2505
2506// values for --report-speed and wget_bar_set_speed_type()
2507typedef enum {
2508 WGET_REPORT_SPEED_BYTES,
2509 WGET_REPORT_SPEED_BITS
2510} wget_report_speed;
2511
2512typedef struct wget_bar_st wget_bar;
2513
2514WGETAPI wget_bar * NULLABLE
2515 wget_bar_init(wget_bar *bar, int nslots);
2516WGETAPI void
2517 wget_bar_deinit(wget_bar *bar);
2518WGETAPI void
2519 wget_bar_free(wget_bar **bar);
2520WGETAPI void
2521 wget_bar_print(wget_bar *bar, int slot, const char *s);
2522WGETAPI void
2523 wget_bar_vprintf(wget_bar *bar, int slot, const char *__restrict fmt, va_list args) WGET_GCC_PRINTF_FORMAT(3,0) WGET_GCC_NONNULL_ALL;
2524WGETAPI void
2525 wget_bar_printf(wget_bar *bar, int slot, const char *__restrict fmt, ...) WGET_GCC_PRINTF_FORMAT(3,4) WGET_GCC_NONNULL_ALL;
2526WGETAPI void
2527 wget_bar_slot_begin(wget_bar *bar, int slot, const char *filename, int new_file, ssize_t filesize) WGET_GCC_NONNULL((1));
2528WGETAPI void
2529 wget_bar_slot_downloaded(wget_bar *bar, int slot, size_t nbytes);
2530WGETAPI void
2531 wget_bar_slot_deregister(wget_bar *bar, int slot) WGET_GCC_NONNULL_ALL;
2532WGETAPI void
2533 wget_bar_update(wget_bar *bar) WGET_GCC_NONNULL_ALL;
2534WGETAPI void
2535 wget_bar_set_slots(wget_bar *bar, int nslots) WGET_GCC_NONNULL_ALL;
2536WGETAPI void
2538WGETAPI void
2539 wget_bar_write_line(wget_bar *bar, const char *buf, size_t len) WGET_GCC_NONNULL_ALL;
2540WGETAPI void
2541 wget_bar_write_line_ext(wget_bar *bar, const char *buf, size_t len, const char *pre, const char *post) WGET_GCC_NONNULL_ALL;
2542WGETAPI void
2543 wget_bar_set_speed_type(wget_report_speed type);
2544
2545/*
2546 * Console routines
2547 */
2548
2549// console color definitions
2550typedef enum {
2551 WGET_CONSOLE_COLOR_RESET = 0,
2552 WGET_CONSOLE_COLOR_WHITE = 1,
2553 WGET_CONSOLE_COLOR_BLUE = 2,
2554 WGET_CONSOLE_COLOR_GREEN = 3,
2555 WGET_CONSOLE_COLOR_RED = 4,
2556 WGET_CONSOLE_COLOR_MAGENTA = 5
2557} wget_console_color;
2558
2559WGETAPI int
2560 wget_console_init(void);
2561WGETAPI int
2562 wget_console_deinit(void);
2563WGETAPI void
2564 wget_console_set_fg_color(wget_console_color colorid);
2565WGETAPI void
2567
2568/*
2569 * Plugin support
2570 */
2571
2580#ifdef _WIN32
2581# define WGET_EXPORT __declspec(dllexport)
2582#elif __GNUC__ > 4
2583# define WGET_EXPORT __attribute__ ((__visibility__("default")))
2584#else
2585# define WGET_EXPORT
2586#endif
2587
2588struct wget_plugin_vtable;
2589
2598{
2601
2604};
2605
2606typedef struct wget_plugin_st wget_plugin;
2607
2618typedef int wget_plugin_initializer_fn(wget_plugin *plugin);
2619
2628typedef void wget_plugin_finalizer_fn(wget_plugin *plugin, int exit_status);
2629
2630// Gets the name the plugin is known as.
2631WGETAPI const char *
2632 wget_plugin_get_name(wget_plugin *plugin) WGET_GCC_NONNULL_ALL;
2633
2634// Registers a function to be called when wget exits.
2635WGETAPI void
2636 wget_plugin_register_finalizer(wget_plugin *plugin, wget_plugin_finalizer_fn *fn) WGET_GCC_NONNULL((1));
2637
2648typedef int wget_plugin_option_callback(wget_plugin *plugin, const char *option, const char *value);
2649
2650// Registers a function for command line option forwarding.
2651WGETAPI void
2652 wget_plugin_register_option_callback(wget_plugin *plugin, wget_plugin_option_callback *fn) WGET_GCC_NONNULL((1));
2653
2659typedef struct {
2660 struct wget_plugin_vtable *vtable;
2662
2663// Marks the URL to be rejected.
2664WGETAPI void
2665 wget_intercept_action_reject(wget_intercept_action *action) WGET_GCC_NONNULL_ALL;
2666
2667// Marks the URL to be accepted.
2668WGETAPI void
2669 wget_intercept_action_accept(wget_intercept_action *action) WGET_GCC_NONNULL_ALL;
2670
2671// Specifies an alternative URL to be fetched instead.
2672WGETAPI void
2673 wget_intercept_action_set_alt_url(wget_intercept_action *action, const wget_iri *iri) WGET_GCC_NONNULL((1));
2674
2675// Specifies that the fetched data should be written to an alternative file.
2676WGETAPI void
2677 wget_intercept_action_set_local_filename(wget_intercept_action *action, const char *local_filename) WGET_GCC_NONNULL((1));
2678
2689typedef void wget_plugin_url_filter_callback(wget_plugin *plugin, const wget_iri *iri, wget_intercept_action *action);
2690
2691// Registers a plugin function for intercepting URLs
2692WGETAPI void
2694
2700typedef struct {
2701 struct wget_plugin_vtable *vtable;
2703
2704// Gets the source address the file was downloaded from.
2705WGETAPI const wget_iri *
2707
2708// Gets the file name the downloaded file was written to.
2709WGETAPI const char *
2711
2712// Gets the size of the downloaded file.
2713WGETAPI uint64_t
2715
2716// Reads the downloaded file into memory.
2717WGETAPI int
2718 wget_downloaded_file_get_contents(wget_downloaded_file *file, const void **data, size_t *size);
2719
2720// Opens the downloaded file as a new stream.
2721WGETAPI FILE *
2723
2724// Gets whether the file should be scanned for more URLs.
2725WGETAPI bool
2727
2728// Adds a URL for recursive downloading.
2729WGETAPI void
2731
2741typedef int wget_plugin_post_processor(wget_plugin *plugin, wget_downloaded_file *file);
2742
2743// Registers a plugin function for intercepting downloaded files.
2744WGETAPI void
2746
2753{
2754 const char * (* get_name)(wget_plugin *);
2755 void (* register_finalizer)(wget_plugin *, wget_plugin_finalizer_fn *);
2756 void (* register_argp)(wget_plugin *, wget_plugin_option_callback *);
2757
2758 void (* action_reject)(wget_intercept_action *);
2759 void (* action_accept)(wget_intercept_action *);
2760 void (* action_set_alt_url)(wget_intercept_action *, const wget_iri *);
2761 void (* action_set_local_filename)(wget_intercept_action *, const char *);
2762 void (* register_url_filter)(wget_plugin *, wget_plugin_url_filter_callback *);
2763
2764 const wget_iri *(*file_get_source_url)(wget_downloaded_file *);
2765 const char *(*file_get_local_filename)(wget_downloaded_file *);
2766 uint64_t (*file_get_size)(wget_downloaded_file *);
2767 int (*file_get_contents)(wget_downloaded_file *, const void **data, size_t *size);
2768 FILE *(*file_open_stream)(wget_downloaded_file *);
2769 bool (*file_get_recurse)(wget_downloaded_file *);
2770 void (*file_add_recurse_url)(wget_downloaded_file *, const wget_iri *);
2771 void (*register_post_processor)(wget_plugin *, wget_plugin_post_processor *);
2772};
2773
2781typedef struct
2782{
2783 const char
2786 uint16_t
2788 long long
2791
2792typedef void
2793 wget_dns_stats_callback(wget_dns *dns, wget_dns_stats_data *stats, void *ctx);
2794
2795WGETAPI void
2796 wget_dns_set_stats_callback(wget_dns *dns, wget_dns_stats_callback *fn, void *ctx);
2797
2805typedef struct
2806{
2807 const char
2808 *hostname;
2809 int
2810 nvalid,
2811 nrevoked,
2812 nignored,
2813 stapling;
2815
2816typedef void
2817 wget_ocsp_stats_callback(wget_ocsp_stats_data *stats, void *ctx);
2818
2819WGETAPI void
2820 wget_ssl_set_stats_callback_ocsp(wget_ocsp_stats_callback *fn, void *ctx);
2822
2830typedef struct
2831{
2832 const char
2833 *hostname,
2834 *alpn_protocol;
2835 long long
2836 tls_secs; //milliseconds
2837 int
2838 version,
2839 cert_chain_size;
2840 char
2841 http_protocol;
2842 bool
2843 false_start,
2844 tfo,
2845 tls_con,
2846 resumed;
2848
2849typedef void
2850 wget_tls_stats_callback(wget_tls_stats_data *stats, void *ctx);
2851
2852WGETAPI void
2853 wget_ssl_set_stats_callback_tls(wget_tls_stats_callback *fn, void *ctx);
2855
2856typedef enum {
2857 WGET_STATS_HPKP_NO = 0,
2858 WGET_STATS_HPKP_MATCH = 1,
2859 WGET_STATS_HPKP_NOMATCH = 2,
2860 WGET_STATS_HPKP_ERROR = 3
2861} wget_hpkp_stats_result;
2862
2863typedef void
2864 wget_server_stats_callback(wget_http_connection *conn, wget_http_response *resp);
2865
2866WGETAPI void
2867 wget_server_set_stats_callback(wget_server_stats_callback *fn);
2868
2869typedef enum {
2870 WGET_STATS_FORMAT_HUMAN = 0,
2871 WGET_STATS_FORMAT_CSV = 1,
2872} wget_stats_format;
2873
2874WGET_END_DECLS
2875
2876/*
2877 * Regex Types
2878 */
2879
2880#define WGET_REGEX_TYPE_POSIX 0
2881#define WGET_REGEX_TYPE_PCRE 1
2882
2883#undef RETURNS_NONNULL
2884
2885#endif /* WGET_WGET_H */
WGETAPI size_t wget_base64_get_decoded_length(size_t len) WGET_GCC_PURE
Definition base64.c:316
WGETAPI bool wget_base64_is_string(const char *src) WGET_GCC_PURE
Definition base64.c:78
WGETAPI size_t wget_base64_get_encoded_length(size_t len) WGET_GCC_PURE
Definition base64.c:329
WGETAPI char *NULLABLE wget_base64_decode_alloc(const char *src, size_t n, size_t *outlen) WGET_GCC_NONNULL((1))
Definition base64.c:154
WGETAPI char *NULLABLE wget_base64_encode_alloc(const char *src, size_t n) WGET_GCC_NONNULL_ALL
Definition base64.c:251
WGETAPI void wget_bitmap_clear(wget_bitmap *bitmap, unsigned n)
Definition bitmap.c:79
WGETAPI void wget_bitmap_free(wget_bitmap **bitmap)
Definition bitmap.c:132
WGETAPI bool wget_bitmap_get(const wget_bitmap *bitmap, unsigned n)
Definition bitmap.c:94
WGETAPI int wget_bitmap_init(wget_bitmap **bitmap, unsigned bits)
Definition bitmap.c:110
WGETAPI void wget_bitmap_set(wget_bitmap *bitmap, unsigned n)
Definition bitmap.c:67
WGETAPI size_t wget_buffer_memset(wget_buffer *buf, char c, size_t length)
Definition buffer.c:496
WGETAPI wget_buffer * wget_buffer_alloc(size_t size) WGET_GCC_MALLOC WGET_GCC_ALLOC_SIZE(1) RETURNS_NONNULL LIBWGET_WARN_UNUSED_RESULT
Definition buffer.c:189
WGETAPI size_t wget_buffer_bufcat(wget_buffer *buf, wget_buffer *src)
Definition buffer.c:476
WGETAPI size_t wget_buffer_memset_append(wget_buffer *buf, char c, size_t length)
Definition buffer.c:515
WGETAPI int wget_buffer_ensure_capacity(wget_buffer *buf, size_t size) LIBWGET_WARN_UNUSED_RESULT
Definition buffer.c:245
WGETAPI size_t wget_buffer_strcat(wget_buffer *buf, const char *s)
Definition buffer.c:436
WGETAPI void wget_buffer_free_data(wget_buffer *buf)
Definition buffer.c:311
WGETAPI char * wget_buffer_trim(wget_buffer *buf)
Definition buffer.c:542
WGETAPI size_t wget_buffer_memcpy(wget_buffer *buf, const void *data, size_t length)
Definition buffer.c:356
WGETAPI void wget_buffer_deinit(wget_buffer *buf) WGET_GCC_NONNULL((1))
Definition buffer.c:268
WGETAPI int wget_buffer_init(wget_buffer *buf, char *data, size_t size) WGET_GCC_NONNULL((1))
Definition buffer.c:153
WGETAPI size_t wget_buffer_bufcpy(wget_buffer *buf, wget_buffer *src)
Definition buffer.c:455
WGETAPI void wget_buffer_reset(wget_buffer *buf)
Definition buffer.c:333
WGETAPI size_t wget_buffer_memcat(wget_buffer *buf, const void *data, size_t length)
Definition buffer.c:378
WGETAPI void wget_buffer_free(wget_buffer **buf)
Definition buffer.c:291
WGETAPI size_t wget_buffer_strcpy(wget_buffer *buf, const char *s)
Definition buffer.c:414
WGETAPI int wget_console_deinit(void)
Definition console.c:154
WGETAPI int wget_console_init(void)
Definition console.c:124
WGETAPI void wget_console_reset_fg_color(void)
Definition console.c:98
WGETAPI void wget_dns_cache_free(wget_dns_cache **cache)
Definition dns_cache.c:124
WGETAPI int wget_dns_cache_init(wget_dns_cache **cache)
Definition dns_cache.c:94
WGETAPI int wget_dns_cache_add(wget_dns_cache *cache, const char *host, uint16_t port, struct addrinfo **addrinfo)
Definition dns_cache.c:177
WGETAPI struct addrinfo *NULLABLE wget_dns_cache_get(wget_dns_cache *cache, const char *host, uint16_t port)
Definition dns_cache.c:142
WGETAPI void wget_dns_set_stats_callback(wget_dns *dns, wget_dns_stats_callback *fn, void *ctx)
Definition dns.c:483
WGETAPI void wget_dns_free(wget_dns **dns)
Definition dns.c:126
WGETAPI int wget_dns_init(wget_dns **dns)
Definition dns.c:97
WGETAPI struct addrinfo *NULLABLE wget_dns_resolve(wget_dns *dns, const char *host, uint16_t port, int family, int preferred_family)
Definition dns.c:347
WGETAPI void wget_dns_set_cache(wget_dns *dns, wget_dns_cache *cache)
Definition dns.c:168
WGETAPI void wget_dns_set_timeout(wget_dns *dns, int timeout)
Definition dns.c:155
WGETAPI wget_dns_cache *NULLABLE wget_dns_get_cache(wget_dns *dns) WGET_GCC_PURE
Definition dns.c:181
WGETAPI void wget_dns_freeaddrinfo(wget_dns *dns, struct addrinfo **addrinfo)
Definition dns.c:460
WGETAPI int wget_dns_cache_ip(wget_dns *dns, const char *ip, const char *name, uint16_t port)
Definition dns.c:296
WGETAPI const char * wget_strerror(wget_error err)
Definition error.c:41
void wget_hash_printf_hex(wget_digest_algorithm algorithm, char *out, size_t outsize, const char *fmt,...)
Definition hash_printf.c:56
wget_digest_algorithm
Enumeration of different hash digest algorithms.
Definition wget.h:2390
struct wget_hash_hd_st wget_hash_hd
Type for hash / digest routines.
Definition wget.h:2384
@ WGET_DIGTYPE_MD2
Definition wget.h:2395
@ WGET_DIGTYPE_RMD160
Definition wget.h:2394
@ WGET_DIGTYPE_SHA1
Definition wget.h:2393
@ WGET_DIGTYPE_MD5
Definition wget.h:2392
@ WGET_DIGTYPE_MAX
Definition wget.h:2400
@ WGET_DIGTYPE_SHA256
Definition wget.h:2396
@ WGET_DIGTYPE_SHA512
Definition wget.h:2398
@ WGET_DIGTYPE_SHA224
Definition wget.h:2399
@ WGET_DIGTYPE_UNKNOWN
Definition wget.h:2391
@ WGET_DIGTYPE_SHA384
Definition wget.h:2397
WGETAPI int wget_hashmap_contains(const wget_hashmap *h, const void *key)
Definition hashmap.c:326
WGETAPI void wget_hashmap_set_load_factor(wget_hashmap *h, float factor)
Definition hashmap.c:608
int wget_hashmap_get(const wget_hashmap *h, const void *key, void **value)
Definition hashmap.c:342
WGETAPI void wget_hashmap_clear(wget_hashmap *h)
Definition hashmap.c:451
WGETAPI void *NULLABLE wget_hashmap_iterator_next(wget_hashmap_iterator *iter, void **value)
Definition hashmap.c:125
WGETAPI wget_hashmap_iterator *NULLABLE wget_hashmap_iterator_alloc(wget_hashmap *h) WGET_GCC_MALLOC
Definition hashmap.c:94
struct wget_hashmap_st wget_hashmap
Type of the hashmap.
Definition wget.h:737
WGETAPI void wget_hashmap_set_key_destructor(wget_hashmap *h, wget_hashmap_key_destructor *destructor)
Definition hashmap.c:573
WGETAPI int wget_hashmap_put(wget_hashmap *h, const void *key, const void *value)
Definition hashmap.c:286
void wget_hashmap_key_destructor(void *key)
Type of the hashmap key destructor function.
Definition wget.h:749
WGETAPI void wget_hashmap_set_resize_factor(wget_hashmap *h, float factor)
Definition hashmap.c:629
WGETAPI int wget_hashmap_browse(const wget_hashmap *h, wget_hashmap_browse_fn *browse, void *ctx)
Definition hashmap.c:506
WGETAPI int wget_hashmap_sethashfunc(wget_hashmap *h, wget_hashmap_hash_fn *hash)
Definition hashmap.c:546
WGETAPI void wget_hashmap_set_value_destructor(wget_hashmap *h, wget_hashmap_value_destructor *destructor)
Definition hashmap.c:587
WGETAPI void wget_hashmap_iterator_free(wget_hashmap_iterator **iter)
Definition hashmap.c:109
unsigned int wget_hashmap_hash_fn(const void *key)
Type of the hashmap hash function.
Definition wget.h:743
WGETAPI void wget_hashmap_free(wget_hashmap **h)
Definition hashmap.c:435
WGETAPI void wget_hashmap_setcmpfunc(wget_hashmap *h, wget_hashmap_compare_fn *cmp)
Definition hashmap.c:530
WGETAPI wget_hashmap *NULLABLE wget_hashmap_create(int max, wget_hashmap_hash_fn *hash, wget_hashmap_compare_fn *cmp) WGET_GCC_MALLOC
Definition hashmap.c:167
void wget_hashmap_value_destructor(void *value)
Type of the hashmap value destructor function.
Definition wget.h:752
int wget_hashmap_browse_fn(void *ctx, const void *key, void *value)
Type of the hashmap browse callback function.
Definition wget.h:746
WGETAPI int wget_hashmap_remove_nofree(wget_hashmap *h, const void *key)
Definition hashmap.c:420
WGETAPI int wget_hashmap_remove(wget_hashmap *h, const void *key)
Definition hashmap.c:403
WGETAPI int wget_hashmap_size(const wget_hashmap *h) WGET_GCC_PURE
Definition hashmap.c:488
int wget_hashmap_compare_fn(const void *key1, const void *key2)
Type of the hashmap compare function.
Definition wget.h:740
WGETAPI void wget_hpkp_pin_add(wget_hpkp *hpkp, const char *pin_type, const char *pin_b64)
Definition hpkp.c:82
WGETAPI void wget_hpkp_get_pins(wget_hpkp *hpkp, const char **pin_types, size_t *sizes, const void **pins)
Definition hpkp.c:229
WGETAPI const char * wget_hpkp_get_host(wget_hpkp *hpkp)
Definition hpkp.c:251
wget_hpkp_db * wget_hpkp_db_init_fn(wget_hpkp_db *hpkp_db, const char *fname)
Definition wget.h:1492
WGETAPI void wget_hpkp_set_host(wget_hpkp *hpkp, const char *host)
Definition hpkp.c:145
WGETAPI void wget_hpkp_free(wget_hpkp *hpkp)
Definition hpkp.c:109
WGETAPI int wget_hpkp_get_n_pins(wget_hpkp *hpkp)
Definition hpkp.c:190
WGETAPI void wget_hpkp_get_pins_b64(wget_hpkp *hpkp, const char **pin_types, const char **pins_b64)
Definition hpkp.c:204
struct wget_hpkp_db_st wget_hpkp_db
Definition wget.h:1454
struct wget_hpkp_st wget_hpkp
Definition wget.h:1461
WGETAPI wget_hpkp *NULLABLE wget_hpkp_new(void)
Definition hpkp.c:129
WGETAPI void wget_hpkp_set_maxage(wget_hpkp *hpkp, int64_t maxage)
Definition hpkp.c:158
WGETAPI void wget_hpkp_set_include_subdomains(wget_hpkp *hpkp, bool include_subdomains)
Definition hpkp.c:179
WGETAPI bool wget_hpkp_get_include_subdomains(wget_hpkp *hpkp)
Definition hpkp.c:273
WGETAPI int64_t wget_hpkp_get_maxage(wget_hpkp *hpkp)
Definition hpkp.c:262
WGETAPI void wget_hsts_db_set_fname(wget_hsts_db *hsts_db, const char *fname)
Definition hsts.c:587
int wget_hsts_host_match_fn(const wget_hsts_db *hsts_db, const char *host, uint16_t port)
Definition wget.h:1407
struct wget_hsts_db_st wget_hsts_db
Definition wget.h:1398
WGETAPI int wget_ready_2_transfer(int fd, int timeout, int mode)
Definition io.c:232
WGETAPI int wget_ready_2_read(int fd, int timeout)
Definition io.c:276
WGETAPI int wget_truncate(const char *path, off_t length)
Definition io.c:542
WGETAPI char *NULLABLE wget_read_file(const char *fname, size_t *size) WGET_GCC_MALLOC
Definition io.c:315
WGETAPI ssize_t wget_getline(char **buf, size_t *bufsize, FILE *fp)
Definition io.c:189
WGETAPI ssize_t wget_fdgetline(char **buf, size_t *bufsize, int fd)
Definition io.c:159
WGETAPI int wget_ready_2_write(int fd, int timeout)
Definition io.c:294
WGETAPI int wget_update_file(const char *fname, wget_update_load_fn *load_func, wget_update_save_fn *save_func, void *context)
Definition io.c:394
WGETAPI bool wget_ip_is_family(const char *host, int family) WGET_GCC_PURE
Definition ip.c:50
WGETAPI const char * wget_iri_relative_to_abs(const wget_iri *base, const char *val, size_t len, wget_buffer *buf)
Definition iri.c:889
WGETAPI const char * wget_iri_escape_query(const char *src, wget_buffer *buf) WGET_GCC_NONNULL_ALL
Definition iri.c:1136
WGETAPI char WGETAPI char WGETAPI char WGETAPI wget_iri_scheme wget_iri_set_scheme(wget_iri *iri, wget_iri_scheme scheme)
Definition iri.c:1432
WGETAPI const char * wget_iri_get_escaped_resource(const wget_iri *iri, wget_buffer *buf) WGET_GCC_NONNULL_ALL
Definition iri.c:1193
WGETAPI const char * wget_iri_get_escaped_host(const wget_iri *iri, wget_buffer *buf) WGET_GCC_NONNULL_ALL
Definition iri.c:1168
WGETAPI bool wget_iri_issubdelim(char c) WGET_GCC_CONST
Definition iri.c:238
WGETAPI char * wget_iri_unescape_inline(char *src) WGET_GCC_NONNULL_ALL
Definition iri.c:355
WGETAPI wget_iri * wget_iri_parse(const char *uri, const char *encoding)
Definition iri.c:438
WGETAPI const char *NULLABLE wget_iri_scheme_get_name(wget_iri_scheme scheme)
Definition iri.c:95
WGETAPI int wget_iri_compare(const wget_iri *iri1, const wget_iri *iri2) WGET_GCC_PURE
Definition iri.c:1016
WGETAPI wget_iri *NULLABLE wget_iri_parse_base(const wget_iri *base, const char *url, const char *encoding)
Definition iri.c:984
WGETAPI bool wget_iri_isunreserved(char c) WGET_GCC_CONST
Definition iri.c:271
WGETAPI const char * wget_iri_escape_path(const char *src, wget_buffer *buf) WGET_GCC_NONNULL_ALL
Definition iri.c:1108
WGETAPI bool wget_iri_supported(const wget_iri *iri) WGET_GCC_PURE WGET_GCC_NONNULL_ALL
Definition iri.c:109
WGETAPI void wget_iri_free(wget_iri **iri)
Definition iri.c:418
WGETAPI bool wget_iri_isreserved(char c) WGET_GCC_CONST
Definition iri.c:260
WGETAPI char * wget_iri_unescape_url_inline(char *src) WGET_GCC_NONNULL_ALL
Definition iri.c:373
WGETAPI wget_iri *NULLABLE wget_iri_clone(const wget_iri *iri)
Definition iri.c:711
WGETAPI const char * wget_iri_escape(const char *src, wget_buffer *buf)
Definition iri.c:1073
WGETAPI const char *NULLABLE wget_iri_get_connection_part(const wget_iri *iri, wget_buffer *buf)
Definition iri.c:774
WGETAPI void wget_iri_free_content(wget_iri *iri)
Definition iri.c:392
WGETAPI bool wget_iri_isgendelim(char c) WGET_GCC_CONST
Definition iri.c:225
WGETAPI void *NULLABLE wget_list_append(wget_list **list, const void *data, size_t size) WGET_GCC_NONNULL_ALL
Definition list.c:96
WGETAPI void wget_list_remove(wget_list **list, void *elem) WGET_GCC_NONNULL_ALL
Definition list.c:147
WGETAPI void wget_list_free(wget_list **list) WGET_GCC_NONNULL_ALL
Definition list.c:249
WGETAPI int wget_list_browse(const wget_list *list, wget_list_browse_fn *browse, void *context) WGET_GCC_NONNULL((2))
Definition list.c:230
WGETAPI void *NULLABLE wget_list_prepend(wget_list **list, const void *data, size_t size) WGET_GCC_NONNULL_ALL
Definition list.c:132
struct wget_list_st wget_list
Definition wget.h:405
WGETAPI void *NULLABLE wget_list_getnext(const void *elem) WGET_GCC_PURE
Definition list.c:194
WGETAPI void *NULLABLE wget_list_getfirst(const wget_list *list) WGET_GCC_CONST
Definition list.c:172
WGETAPI void *NULLABLE wget_list_getlast(const wget_list *list) WGET_GCC_PURE
Definition list.c:183
char * wget_strmemdup(const void *m, size_t n)
Definition mem.c:89
LIBWGET_WARN_UNUSED_RESULT WGET_GCC_MALLOC WGETAPI char *NULLABLE wget_strdup(const char *s)
Definition mem.c:74
LIBWGET_WARN_UNUSED_RESULT WGET_GCC_NONNULL_ALL WGETAPI void *NULLABLE wget_strmemcpy_a(char *s, size_t ssize, const void *m, size_t n)
Definition mem.c:146
void * wget_memdup(const void *m, size_t n)
Definition mem.c:54
WGETAPI wget_tcp *NULLABLE wget_tcp_init(void)
Definition net.c:556
WGETAPI void wget_tcp_set_bind_interface(wget_tcp *tcp, const char *bind_interface)
Definition net.c:473
WGETAPI int wget_tcp_ready_2_transfer(wget_tcp *tcp, int flags)
Definition net.c:666
WGETAPI int wget_tcp_get_local_port(wget_tcp *tcp)
Definition net.c:347
WGETAPI ssize_t WGETAPI ssize_t WGETAPI ssize_t wget_tcp_write(wget_tcp *tcp, const char *buf, size_t count)
Definition net.c:950
WGETAPI void wget_tcp_set_ssl(wget_tcp *tcp, bool ssl)
Definition net.c:489
WGETAPI void wget_tcp_set_tls_false_start(wget_tcp *tcp, bool false_start)
Definition net.c:246
WGETAPI void wget_tcp_deinit(wget_tcp **tcp)
Definition net.c:580
WGETAPI bool wget_tcp_get_ssl(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:500
WGETAPI int wget_tcp_get_preferred_family(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:310
WGETAPI const char *NULLABLE wget_tcp_get_ip(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:511
WGETAPI void wget_tcp_set_tcp_fastopen(wget_tcp *tcp, bool tcp_fastopen)
Definition net.c:216
WGETAPI bool wget_tcp_get_tcp_fastopen(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:233
WGETAPI void wget_tcp_set_bind_address(wget_tcp *tcp, const char *bind_address)
Definition net.c:423
WGETAPI int wget_net_init(void)
Definition net.c:149
WGETAPI void wget_tcp_set_connect_timeout(wget_tcp *tcp, int timeout)
Definition net.c:380
WGETAPI void wget_tcp_close(wget_tcp *tcp)
Definition net.c:1072
WGETAPI int wget_tcp_connect(wget_tcp *tcp, const char *host, uint16_t port)
Definition net.c:750
WGETAPI void wget_tcp_set_preferred_family(wget_tcp *tcp, int family)
Definition net.c:299
WGETAPI void wget_tcp_set_dns(wget_tcp *tcp, wget_dns *dns)
Definition net.c:201
WGETAPI bool wget_tcp_get_tls_false_start(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:259
WGETAPI ssize_t wget_tcp_read(wget_tcp *tcp, char *buf, size_t count)
Definition net.c:899
WGETAPI int wget_tcp_get_family(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:336
WGETAPI void wget_tcp_set_protocol(wget_tcp *tcp, int protocol)
Definition net.c:273
WGETAPI int wget_tcp_get_timeout(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:407
WGETAPI void wget_tcp_tls_stop(wget_tcp *tcp)
Definition net.c:867
WGETAPI void wget_tcp_set_family(wget_tcp *tcp, int family)
Definition net.c:325
WGETAPI void wget_tcp_set_timeout(wget_tcp *tcp, int timeout)
Definition net.c:396
WGETAPI int wget_tcp_tls_start(wget_tcp *tcp)
Definition net.c:857
WGETAPI void wget_tcp_set_ssl_hostname(wget_tcp *tcp, const char *hostname)
Definition net.c:526
WGETAPI int wget_tcp_get_protocol(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:284
WGETAPI const char * wget_tcp_get_ssl_hostname(wget_tcp *tcp) WGET_GCC_PURE
Definition net.c:541
WGETAPI int wget_net_deinit(void)
Definition net.c:161
wget_ocsp_db * wget_ocsp_db_init_fn(wget_ocsp_db *ocsp_db, const char *fname)
Definition wget.h:1605
WGETAPI void wget_ocsp_db_set_fname(wget_ocsp_db *ocsp_db, const char *fname)
Definition ocsp.c:681
struct wget_ocsp_db_st wget_ocsp_db
Definition wget.h:1596
WGETAPI void wget_atom_get_urls_inline(const char *atom, wget_vector **urls)
Definition atom_url.c:116
WGETAPI void wget_sitemap_get_urls_inline(const char *sitemap, wget_vector **urls, wget_vector **sitemap_urls)
Definition sitemap_url.c:104
WGETAPI void wget_intercept_action_reject(wget_intercept_action *action) WGET_GCC_NONNULL_ALL
Definition plugin.c:84
WGETAPI const char * wget_plugin_get_name(wget_plugin *plugin) WGET_GCC_NONNULL_ALL
Definition plugin.c:47
WGETAPI void wget_downloaded_file_add_recurse_url(wget_downloaded_file *file, const wget_iri *iri)
Definition plugin.c:222
WGETAPI void wget_plugin_register_option_callback(wget_plugin *plugin, wget_plugin_option_callback *fn) WGET_GCC_NONNULL((1))
Definition plugin.c:72
WGETAPI const wget_iri * wget_downloaded_file_get_source_url(wget_downloaded_file *file)
Definition plugin.c:150
WGETAPI void wget_plugin_register_url_filter_callback(wget_plugin *plugin, wget_plugin_url_filter_callback *filter_fn)
Definition plugin.c:139
void wget_plugin_finalizer_fn(wget_plugin *plugin, int exit_status)
Definition wget.h:2628
int wget_plugin_option_callback(wget_plugin *plugin, const char *option, const char *value)
Definition wget.h:2648
WGETAPI void wget_intercept_action_set_alt_url(wget_intercept_action *action, const wget_iri *iri) WGET_GCC_NONNULL((1))
Definition plugin.c:108
WGETAPI int wget_downloaded_file_get_contents(wget_downloaded_file *file, const void **data, size_t *size)
Definition plugin.c:188
int wget_plugin_post_processor(wget_plugin *plugin, wget_downloaded_file *file)
Definition wget.h:2741
WGETAPI void wget_intercept_action_set_local_filename(wget_intercept_action *action, const char *local_filename) WGET_GCC_NONNULL((1))
Definition plugin.c:119
int wget_plugin_initializer_fn(wget_plugin *plugin)
Definition wget.h:2618
WGETAPI const char * wget_downloaded_file_get_local_filename(wget_downloaded_file *file)
Definition plugin.c:161
void wget_plugin_url_filter_callback(wget_plugin *plugin, const wget_iri *iri, wget_intercept_action *action)
Definition wget.h:2689
WGETAPI FILE * wget_downloaded_file_open_stream(wget_downloaded_file *file)
Definition plugin.c:199
WGETAPI uint64_t wget_downloaded_file_get_size(wget_downloaded_file *file)
Definition plugin.c:172
WGETAPI void wget_intercept_action_accept(wget_intercept_action *action) WGET_GCC_NONNULL_ALL
Definition plugin.c:97
WGETAPI void wget_plugin_register_finalizer(wget_plugin *plugin, wget_plugin_finalizer_fn *fn) WGET_GCC_NONNULL((1))
Definition plugin.c:57
WGETAPI bool wget_downloaded_file_get_recurse(wget_downloaded_file *file)
Definition plugin.c:210
WGETAPI void wget_plugin_register_post_processor(wget_plugin *plugin, wget_plugin_post_processor *fn)
Definition plugin.c:247
WGETAPI wget_bar *NULLABLE wget_bar_init(wget_bar *bar, int nslots)
Definition bar.c:461
void wget_bar_vprintf(wget_bar *bar, int slot, const char *fmt, va_list args)
Definition bar.c:656
WGETAPI void wget_bar_deinit(wget_bar *bar)
Definition bar.c:601
WGETAPI void wget_bar_slot_downloaded(wget_bar *bar, int slot, size_t nbytes)
Definition bar.c:557
WGETAPI void wget_bar_screen_resized(void)
Definition bar.c:696
WGETAPI void wget_bar_slot_deregister(wget_bar *bar, int slot) WGET_GCC_NONNULL_ALL
Definition bar.c:571
WGETAPI void wget_bar_update(wget_bar *bar) WGET_GCC_NONNULL_ALL
Definition bar.c:588
WGETAPI void wget_bar_set_speed_type(wget_report_speed type)
Definition bar.c:756
WGETAPI void wget_bar_write_line(wget_bar *bar, const char *buf, size_t len) WGET_GCC_NONNULL_ALL
Definition bar.c:713
WGETAPI void wget_bar_slot_begin(wget_bar *bar, int slot, const char *filename, int new_file, ssize_t filesize) WGET_GCC_NONNULL((1))
Definition bar.c:526
WGETAPI void wget_bar_print(wget_bar *bar, int slot, const char *s)
Definition bar.c:637
WGETAPI void wget_bar_set_slots(wget_bar *bar, int nslots) WGET_GCC_NONNULL_ALL
Definition bar.c:492
WGETAPI void wget_bar_free(wget_bar **bar)
Definition bar.c:622
WGETAPI void wget_bar_write_line_ext(wget_bar *bar, const char *buf, size_t len, const char *pre, const char *post) WGET_GCC_NONNULL_ALL
Definition bar.c:730
WGETAPI void wget_random_exit(void)
Definition random.c:94
WGETAPI void wget_srandom(unsigned int seed)
Definition random.c:130
WGETAPI void wget_random_init(void)
Definition random.c:81
WGETAPI int wget_random(void)
Definition random.c:105
WGETAPI wget_string *NULLABLE wget_robots_get_path(wget_robots *robots, int index)
Definition robots.c:235
WGETAPI const char *NULLABLE wget_robots_get_sitemap(wget_robots *robots, int index)
Definition robots.c:260
WGETAPI int wget_robots_get_path_count(wget_robots *robots)
Definition robots.c:222
WGETAPI void wget_robots_free(wget_robots **robots)
Definition robots.c:208
WGETAPI int wget_robots_get_sitemap_count(wget_robots *robots)
Definition robots.c:247
WGETAPI int wget_robots_parse(wget_robots **robots, const char *data, const char *client)
Definition robots.c:102
WGETAPI void wget_ssl_set_config_string(int key, const char *value)
Definition ssl_wolfssl.c:194
WGETAPI ssize_t wget_ssl_write_timeout(void *session, const char *buf, size_t count, int timeout) WGET_GCC_NONNULL_ALL
Definition ssl_wolfssl.c:1218
WGETAPI int wget_ssl_open(wget_tcp *tcp)
Definition ssl_wolfssl.c:905
WGETAPI void wget_ssl_set_config_int(int key, int value)
Definition ssl_wolfssl.c:275
WGETAPI void wget_ssl_set_config_object(int key, void *value)
Definition ssl_wolfssl.c:233
WGETAPI void wget_ssl_set_stats_callback_ocsp(wget_ocsp_stats_callback *fn, void *ctx)
Definition ssl_wolfssl.c:1276
WGETAPI void wget_ssl_set_stats_callback_tls(wget_tls_stats_callback *fn, void *ctx)
Definition ssl_wolfssl.c:1264
WGETAPI void wget_ssl_init(void)
Definition ssl_wolfssl.c:579
WGETAPI ssize_t wget_ssl_read_timeout(void *session, char *buf, size_t count, int timeout) WGET_GCC_NONNULL_ALL
Definition ssl_wolfssl.c:1145
WGETAPI void wget_ssl_close(void **session)
Definition ssl_wolfssl.c:1105
WGETAPI void wget_ssl_deinit(void)
Definition ssl_wolfssl.c:738
WGETAPI wget_stringmap *NULLABLE wget_stringmap_create(int max) WGET_GCC_MALLOC
Definition stringmap.c:95
wget_hashmap wget_stringmap
Type of the stringmap.
Definition wget.h:806
WGETAPI wget_stringmap *NULLABLE wget_stringmap_create_nocase(int max) WGET_GCC_MALLOC
Definition stringmap.c:112
int wget_thread_kill(WGET_GCC_UNUSED wget_thread thread, WGET_GCC_UNUSED int sig)
Definition thread.c:250
WGETAPI void wget_thread_mutex_lock(wget_thread_mutex mutex)
Definition thread.c:115
int wget_thread_cancel(WGET_GCC_UNUSED wget_thread thread)
Definition thread.c:231
WGETAPI bool wget_thread_support(void) WGET_GCC_CONST
Definition thread.c:298
WGETAPI int wget_thread_cond_destroy(wget_thread_cond *cond)
Definition thread.c:157
WGETAPI void wget_thread_mutex_unlock(wget_thread_mutex mutex)
Definition thread.c:125
WGETAPI int wget_thread_cond_init(wget_thread_cond *cond)
Definition thread.c:139
WGETAPI int wget_thread_join(wget_thread *thread)
Definition thread.c:270
WGETAPI int wget_thread_cond_signal(wget_thread_cond cond)
Definition thread.c:170
WGETAPI int wget_thread_cond_wait(wget_thread_cond cond, wget_thread_mutex mutex, long long ms)
Definition thread.c:185
int wget_thread_start(wget_thread *thread, void *(*start_routine)(void *), void *arg, WGET_GCC_UNUSED int flags)
Definition thread.c:209
WGETAPI wget_thread_id wget_thread_self(void) WGET_GCC_CONST
Definition thread.c:290
WGETAPI int wget_thread_mutex_destroy(wget_thread_mutex *mutex)
Definition thread.c:101
WGETAPI int wget_thread_mutex_init(wget_thread_mutex *mutex)
Definition thread.c:83
WGETAPI int wget_strcmp(const char *s1, const char *s2) WGET_GCC_PURE
Definition utils.c:77
WGETAPI int wget_match_tail(const char *s, const char *tail) WGET_GCC_PURE WGET_GCC_NONNULL_ALL
Definition utils.c:347
WGETAPI int wget_percent_unescape(char *src)
Definition utils.c:317
WGETAPI int wget_strncasecmp_ascii(const char *s1, const char *s2, size_t n) WGET_GCC_PURE
Definition utils.c:159
WGETAPI int wget_strncmp(const char *s1, const char *s2, size_t n) WGET_GCC_PURE
Definition utils.c:204
WGETAPI int wget_match_tail_nocase(const char *s, const char *tail) WGET_GCC_PURE WGET_GCC_NONNULL_ALL
Definition utils.c:367
WGETAPI int wget_strncasecmp(const char *s1, const char *s2, size_t n) WGET_GCC_PURE
Definition utils.c:231
WGETAPI int wget_strcasecmp(const char *s1, const char *s2) WGET_GCC_PURE
Definition utils.c:104
WGETAPI char *NULLABLE wget_strnglob(const char *str, size_t n, int flags) WGET_GCC_PURE
Definition utils.c:390
WGETAPI int wget_strcasecmp_ascii(const char *s1, const char *s2) WGET_GCC_PURE
Definition utils.c:131
WGETAPI long long wget_get_timemillis(void)
Definition utils.c:293
WGETAPI char * wget_human_readable(char *buf, size_t bufsize, uint64_t n)
Definition utils.c:434
WGETAPI char * wget_strtolower(char *s)
Definition utils.c:180
WGETAPI void wget_millisleep(int ms)
Definition utils.c:282
WGETAPI void wget_vector_setcmpfunc(wget_vector *v, wget_vector_compare_fn *cmp) WGET_GCC_NONNULL((2))
Definition vector.c:549
WGETAPI int WGETAPI int WGETAPI int wget_vector_replace(wget_vector *v, const void *elem, int pos) WGET_GCC_NONNULL((2))
Definition vector.c:315
WGETAPI int wget_vector_size(const wget_vector *v) WGET_GCC_PURE
Definition vector.c:497
WGETAPI int wget_vector_remove_nofree(wget_vector *v, int pos)
Definition vector.c:368
WGETAPI int wget_vector_insert(wget_vector *v, const void *elem, int pos) WGET_GCC_NONNULL((2))
Definition vector.c:164
WGETAPI bool wget_vector_contains(const wget_vector *v, const void *elem) WGET_GCC_NONNULL((2))
Definition vector.c:633
WGETAPI int wget_vector_insert_sorted(wget_vector *v, const void *elem) WGET_GCC_NONNULL((2))
Definition vector.c:182
WGETAPI int wget_vector_browse(const wget_vector *v, wget_vector_browse_fn *browse, void *ctx) WGET_GCC_NONNULL((2))
Definition vector.c:532
WGETAPI int wget_vector_move(wget_vector *v, int old_pos, int new_pos)
Definition vector.c:386
WGETAPI int wget_vector_findext(const wget_vector *v, int start, int direction, wget_vector_find_fn *find) WGET_GCC_NONNULL((4))
Definition vector.c:649
WGETAPI void wget_vector_clear_nofree(wget_vector *v)
Definition vector.c:481
WGETAPI int wget_vector_remove(wget_vector *v, int pos)
Definition vector.c:353
WGETAPI int wget_vector_add(wget_vector *v, const void *elem) WGET_GCC_NONNULL((2))
Definition vector.c:247
WGETAPI void *NULLABLE wget_vector_get(const wget_vector *v, int pos) WGET_GCC_PURE
Definition vector.c:511
WGETAPI void wget_vector_free(wget_vector **v)
Definition vector.c:442
WGETAPI int wget_vector_add_memdup(wget_vector *v, const void *elem, size_t size) WGET_GCC_NONNULL((2))
Definition vector.c:219
WGETAPI wget_vector *NULLABLE wget_vector_create(int max, wget_vector_compare_fn *cmp) WGET_GCC_MALLOC
Definition vector.c:69
WGETAPI void wget_vector_set_resize_factor(wget_vector *v, float off)
Definition vector.c:101
WGETAPI void wget_vector_sort(wget_vector *v)
Definition vector.c:586
WGETAPI int wget_vector_find(const wget_vector *v, const void *elem) WGET_GCC_NONNULL((2))
Definition vector.c:602
WGETAPI void wget_vector_clear(wget_vector *v)
Definition vector.c:459
WGETAPI int wget_vector_swap(wget_vector *v, int pos1, int pos2)
Definition vector.c:417
WGETAPI void wget_vector_set_destructor(wget_vector *v, wget_vector_destructor *destructor)
Definition vector.c:568
void * wget_malloc_function(size_t)
Type of malloc() function.
Definition wget.h:436
void * wget_calloc_function(size_t, size_t)
Type of calloc() function.
Definition wget.h:439
void * wget_realloc_function(void *, size_t)
Type of realloc() function.
Definition wget.h:442
void wget_free_function(void *)
Type of free() function.
Definition wget.h:445
WGETAPI int wget_xml_parse_buffer(const char *buf, wget_xml_callback *callback, void *user_ctx, int hints) WGET_GCC_NONNULL((1))
Definition xml.c:596
WGETAPI char * wget_xml_decode_entities_inline(char *src) WGET_GCC_NONNULL((1))
Definition xml.c:729
WGETAPI void wget_html_parse_file(const char *fname, wget_xml_callback *callback, void *user_ctx, int hints) WGET_GCC_NONNULL((1))
Definition xml.c:709
WGETAPI void wget_xml_parse_file(const char *fname, wget_xml_callback *callback, void *user_ctx, int hints) WGET_GCC_NONNULL((1))
Definition xml.c:643
WGETAPI void wget_html_parse_buffer(const char *buf, wget_xml_callback *callback, void *user_ctx, int hints) WGET_GCC_NONNULL((1))
Definition xml.c:624
Definition bar.c:120
Definition bitmap.c:53
Definition wget.h:543
size_t length
number of bytes in 'data'
Definition wget.h:547
bool release_buf
wget_buffer structure has been malloc'ed and must be freed
Definition wget.h:552
char * data
pointer to internal memory
Definition wget.h:545
bool error
a memory failure occurred, the result in 'data' is likely erroneous
Definition wget.h:553
bool release_data
'data' has been malloc'ed and must be freed
Definition wget.h:551
size_t size
capacity of 'data' (terminating 0 byte doesn't count here)
Definition wget.h:549
Definition wget.h:1704
const char * url
zero-terminated copy the found URL
Definition wget.h:1710
size_t len
length of found URL
Definition wget.h:1706
const char * abs_url
the found URL converted into an absolute URL
Definition wget.h:1712
size_t pos
position of found URL within the scanned CSS data
Definition wget.h:1708
Definition decompressor.c:73
Definition dns_cache.c:50
Definition dns.c:51
Definition wget.h:2782
const char * hostname
hostname/domain to be resolved
Definition wget.h:2784
const char * ip
resulting IP string
Definition wget.h:2785
long long dns_secs
milliseconds it took to resolve
Definition wget.h:2789
uint16_t port
port to be resolved
Definition wget.h:2787
Definition wget.h:2700
Definition hashfile.c:685
Definition hashmap.c:70
Definition hashmap.c:50
Definition hpkp_db.c:42
Definition wget.h:1500
wget_hpkp_db_load_fn * load
Callback replacing wget_hpkp_db_load().
Definition wget.h:1512
wget_hpkp_db_free_fn * free
Callback replacing wget_hpkp_db_free().
Definition wget.h:1506
wget_hpkp_db_check_pubkey_fn * check_pubkey
Callback replacing wget_hpkp_db_check_pubkey().
Definition wget.h:1508
wget_hpkp_db_deinit_fn * deinit
Callback replacing wget_hpkp_db_free().
Definition wget.h:1504
wget_hpkp_db_init_fn * init
Callback replacing wget_hpkp_db_free().
Definition wget.h:1502
wget_hpkp_db_save_fn * save
Callback replacing wget_hpkp_db_save().
Definition wget.h:1514
wget_hpkp_db_add_fn * add
Callback replacing wget_hpkp_db_add().
Definition wget.h:1510
Definition hsts.c:51
Definition wget.h:1416
wget_hsts_db_deinit_fn * deinit
Callback replacing wget_hsts_db_deinit().
Definition wget.h:1422
wget_hsts_db_save_fn * save
Callback replacing wget_hsts_db_save().
Definition wget.h:1430
wget_hsts_db_load_fn * load
Callback replacing wget_hsts_db_load().
Definition wget.h:1428
wget_hsts_db_free_fn * free
Callback replacing wget_hsts_db_free().
Definition wget.h:1424
wget_hsts_db_add_fn * add
Callback replacing wget_hsts_db_add().
Definition wget.h:1426
wget_hsts_db_init_fn * init
Callback replacing wget_hsts_db_init().
Definition wget.h:1420
wget_hsts_host_match_fn * host_match
Callback replacing wget_hsts_host_match().
Definition wget.h:1418
Definition wget.h:1764
bool follow
if the 'follow' attribute was found in a META tag
Definition wget.h:1772
const char * encoding
the charset encoding set by the parsed document or NULL if none
Definition wget.h:1768
wget_vector * uris
list of found URLs (entries: wget_html_parsed_url)
Definition wget.h:1766
wget_string base
the BASE set in the document or NULL if none
Definition wget.h:1770
Definition wget.h:1751
char attr[16]
name of the attribute containing the URL, e.g. 'href'
Definition wget.h:1757
char tag[16]
name of the HTML tag containing the URL, e.g. 'a'
Definition wget.h:1759
bool link_inline
1 = rel was 'stylesheet' or 'shortcut icon'
Definition wget.h:1761
wget_string url
URL within the parsed document (pointer and length).
Definition wget.h:1753
wget_string download
Value of additional 'download' attribute, the name to be saved to disk.
Definition wget.h:1755
Definition wget.h:1778
const char * attribute
attribute of the HTML tag
Definition wget.h:1782
const char * name
name of HTML tag
Definition wget.h:1780
Definition wget.h:2075
wget_stringmap * params
name/value pairs of the challenge
Definition wget.h:2079
const char * auth_scheme
name of the challenge, e.g. 'basic' or 'digest'
Definition wget.h:2077
Definition wget.h:2065
const char * algorithm
name of the digest, e.g. 'md5'
Definition wget.h:2067
const char * encoded_digest
value of the digest
Definition wget.h:2069
Definition wget.h:2038
const char * name
name of the param
Definition wget.h:2040
const char * value
value of the param (might be NULL)
Definition wget.h:2042
Definition wget.h:2094
const char * body
body data to be sent or NULL
Definition wget.h:2098
void * header_user_data
meant to be used in header callback function
Definition wget.h:2106
wget_vector * headers
list of HTTP headers
Definition wget.h:2096
bool debug_skip_body
if set, do not print the request body (e.g. because it's binary)
Definition wget.h:2130
bool response_ignorelength
ignore the Content-Length in the response header
Definition wget.h:2128
int32_t stream_id
HTTP2 stream id.
Definition wget.h:2116
bool response_keepheader
the application wants the response header data
Definition wget.h:2126
char esc_host_buf[64]
static buffer used by esc_host (avoids mallocs)
Definition wget.h:2122
wget_buffer esc_host
URI escaped host.
Definition wget.h:2112
wget_http_header_callback * header_callback
called after HTTP header has been received
Definition wget.h:2100
wget_http_body_callback * body_callback
called for each body data packet received
Definition wget.h:2102
wget_buffer esc_resource
URI escaped resource.
Definition wget.h:2110
void * body_user_data
meant to be used in body callback function
Definition wget.h:2108
char method[8]
currently we just need HEAD, GET and POST
Definition wget.h:2124
long long first_response_start
The time we read the first bytes back.
Definition wget.h:2134
size_t body_length
length of the body data
Definition wget.h:2114
void * user_data
user data for the request (used by async application code)
Definition wget.h:2104
char esc_resource_buf[256]
static buffer used by esc_resource (avoids mallocs)
Definition wget.h:2120
wget_iri_scheme scheme
scheme of the request for proxied connections
Definition wget.h:2118
long long request_start
When this request was sent out.
Definition wget.h:2132
Definition wget.h:2141
const char * etag
ETag value.
Definition wget.h:2163
short major
HTTP major version.
Definition wget.h:2184
short minor
HTTP minor version.
Definition wget.h:2186
short code
request only status code
Definition wget.h:2188
wget_buffer * body
the body data
Definition wget.h:2167
wget_buffer * header
the raw header data if requested by the application
Definition wget.h:2165
bool length_inconsistent
set when length of data received is not same as Content-Length
Definition wget.h:2198
int icy_metaint
value of the SHOUTCAST header 'icy-metaint'
Definition wget.h:2182
long long response_end
when this response was received
Definition wget.h:2169
size_t content_length
length of the body data
Definition wget.h:2171
bool hsts
if hsts_maxage and hsts_include_subdomains are valid
Definition wget.h:2199
char reason[32]
reason string after the status code
Definition wget.h:2180
Definition wget.h:2659
Definition wget.h:1189
bool is_ip_address
If set, the hostname part is a literal IPv4/IPv6 address.
Definition wget.h:1279
bool path_allocated
If set, free path in iri_free().
Definition wget.h:1270
const char * host
Definition wget.h:1220
const char * password
Definition wget.h:1215
bool host_allocated
If set, free host in iri_free().
Definition wget.h:1267
const char * display
Definition wget.h:1205
bool fragment_allocated
If set, free fragment in iri_free().
Definition wget.h:1276
bool port_given
If set, port was explicitly given.
Definition wget.h:1264
const char * path
Definition wget.h:1225
wget_iri_scheme scheme
URI/IRI scheme (http or https).
Definition wget.h:1261
size_t msize
size of memory to hold the parsed URI, it contains 0 bytes
Definition wget.h:1255
const char * query
Definition wget.h:1230
const char * userinfo
Definition wget.h:1210
const char * safe_uri
Definition wget.h:1200
bool query_allocated
If set, free query in iri_free().
Definition wget.h:1273
const char * uri
Definition wget.h:1194
const char * fragment
Definition wget.h:1235
uint16_t port
Port number.
Definition wget.h:1258
const char * connection_part
Definition wget.h:1245
size_t dirlen
Definition wget.h:1252
Definition list.c:54
Definition netrc.c:39
Definition wget.h:1665
const char * password
password for the host
Definition wget.h:1671
uint16_t port
GNU extension: port number.
Definition wget.h:1673
const char * login
login/username for the host
Definition wget.h:1669
const char * host
hostname/domain/ip
Definition wget.h:1667
bool force
GNU extension: unused.
Definition wget.h:1675
Definition ocsp.c:49
Definition wget.h:1615
wget_ocsp_db_add_host_fn * add_host
Callback replacing wget_ocsp_db_add_host().
Definition wget.h:1629
wget_ocsp_db_save_fn * load
Callback replacing wget_ocsp_db_load().
Definition wget.h:1631
wget_ocsp_db_deinit_fn * deinit
Callback replacing wget_ocsp_db_free().
Definition wget.h:1619
wget_ocsp_fingerprint_in_cache_fn * fingerprint_in_cache
Callback replacing wget_ocsp_db_fingerprint_in_cache().
Definition wget.h:1623
wget_ocsp_db_init_fn * init
Callback replacing wget_ocsp_db_free().
Definition wget.h:1617
wget_ocsp_db_add_fingerprint_fn * add_fingerprint
Callback replacing wget_ocsp_db_add_fingerprint().
Definition wget.h:1627
wget_ocsp_db_load_fn * save
Callback replacing wget_ocsp_db_save().
Definition wget.h:1633
wget_ocsp_hostname_is_valid_fn * hostname_is_valid
Callback replacing wget_ocsp_db_hostname_is_valid().
Definition wget.h:1625
wget_ocsp_db_free_fn * free
Callback replacing wget_ocsp_db_free().
Definition wget.h:1621
Definition wget.h:2806
Definition wget.h:2598
void * plugin_data
Plugin specific data. Plugins are free to assign any value to this.
Definition wget.h:2600
struct wget_plugin_vtable * vtable
Pointer to the vtable. Used by wget to implement functions.
Definition wget.h:2603
Definition wget.h:2753
Definition robots.c:49
Definition wget.h:1744
const char * p
pointer to memory region
Definition wget.h:1746
size_t len
length of memory region
Definition wget.h:1748
Definition thread.c:70
gl_cond_t cond
conditional
Definition thread.c:71
Definition thread.c:66
Definition thread.c:62
Definition tls_session.c:41
Definition tls_session.c:52
Definition wget.h:2831
Definition vector.c:37