1 /* 2 * Copyright (c) 2019-2021 Free Software Foundation, Inc. 3 * 4 * This file is part of libwget. 5 * 6 * Libwget is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Libwget is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with Libwget. If not, see <https://www.gnu.org/licenses/>. 18 * 19 * 20 * Header file for cookie code 21 */ 22 23 #ifndef LIBWGET_COOKIE_H 24 #define LIBWGET_COOKIE_H 25 26 #include <stdbool.h> 27 #include <stdint.h> 28 #include <wget.h> 29 30 struct wget_cookie_st { 31 const char * 32 name; 33 const char * 34 value; 35 const char * 36 domain; 37 const char * 38 path; 39 int64_t 40 expires; // time of expiration (format YYYYMMDDHHMMSS) 41 int64_t 42 maxage; // like expires, but precedes it if set 43 int64_t 44 last_access; 45 int64_t 46 creation; 47 unsigned int 48 sort_age; // need for sorting on Cookie: header construction 49 bool 50 domain_dot : 1, // for compatibility with Netscape cookie format 51 normalized : 1, 52 persistent : 1, 53 host_only : 1, 54 secure_only : 1, // cookie should be used over secure connections only (TLS/HTTPS) 55 http_only : 1; // just use the cookie via HTTP/HTTPS protocol 56 }; 57 58 WGET_GCC_NONNULL_ALL 59 bool cookie_domain_match(const char *domain, const char *host); 60 61 WGET_GCC_NONNULL((1)) 62 bool cookie_path_match(const char *cookie_path, const char *request_path); 63 64 void cookie_free(void *cookie); 65 66 #endif /* LIBWGET_COOKIE_H */ 67