1 /** 2 * URL Support 3 * 4 * Copyright (C) 2013-2016 by 5 * Jeffrey Fulmer - <jeff@joedog.org>, et al. 6 * This file is distributed as part of Siege 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program; if not, write to the Free Software Foundation, Inc. 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 *-- 22 */ 23 #ifndef __URL_H 24 #define __URL_H 25 #include <stdlib.h> 26 #include <joedog/defs.h> 27 #include <joedog/boolean.h> 28 29 /** 30 * a URL object 31 */ 32 typedef struct URL_T *URL; 33 34 /** 35 * For memory allocation; URLSIZE 36 * provides the object size 37 */ 38 extern size_t URLSIZE; 39 40 /** 41 * HTTP method 42 */ 43 typedef enum { 44 NOMETHOD = 0, 45 HEAD = 1, 46 GET = 2, 47 POST = 3, 48 PUT = 4, 49 DELETE = 5, 50 TRACE = 6, 51 OPTIONS = 7, 52 CONNECT = 8, 53 PATCH = 9, 54 } METHOD; 55 56 /** 57 * enum SCHEME 58 */ 59 typedef enum { 60 UNSUPPORTED = 0, 61 HTTP = 1, 62 HTTPS = 2, 63 FTP = 3, 64 PROXY = 4 65 } SCHEME; 66 67 68 /* Constructor / destructor */ 69 URL new_url(char *str); 70 URL url_destroy(URL this); 71 void url_dump(URL this); 72 73 void url_set_ID(URL this, int id); 74 void url_set_scheme(URL this, SCHEME scheme); 75 void url_set_hostname(URL this, char *hostname); 76 void url_set_redirect(URL this, BOOLEAN redir); 77 void url_set_conttype(URL this, char *type); 78 void url_set_postdata(URL this, char *postdata, size_t postlen); 79 void url_set_method(URL this, METHOD method); 80 81 int url_get_ID(URL this); 82 METHOD url_get_method(URL this); 83 char * url_get_method_name(URL this) ; 84 BOOLEAN url_is_redirect(URL this); 85 86 /* <scheme>://<username>:<password>@<hostname>:<port>/<path>;<params>?<query>#<frag> */ 87 char * url_get_absolute(URL this); 88 89 /* <SCHEME>://<username>:<password>@<hostname>:<port>/<path>;<params>?<query>#<frag> */ 90 SCHEME url_get_scheme(URL this); 91 char * url_get_scheme_name(URL this); 92 93 /* <scheme>://<USERNAME>:<password>@<hostname>:<port>/<path>;<params>?<query>#<frag> */ 94 char * url_get_username(URL this); 95 96 /* <scheme>://<username>:<PASSWORD>@<hostname>:<port>/<path>;<params>?<query>#<frag> */ 97 char * url_get_password(URL this); 98 99 /* <scheme>://<username>:<password>@<HOSTNAME>:<port>/<path>;<params>?<query>#<frag> */ 100 char * url_get_hostname(URL this); 101 102 /* <scheme>://<username>:<password>@<hostname>:<PORT>/<path>;<params>?<query>#<frag> */ 103 int url_get_port(URL this); 104 105 /* <scheme>://<username>:<password>@<hostname>:<port>/<PATH>;<params>?<query>#<frag> */ 106 char * url_get_path(URL this); 107 108 /* <scheme>://<username>:<password>@<hostname>:<port>/<FILE>;<params>?<query>#<frag> */ 109 char * url_get_file(URL this); 110 char * url_get_request(URL this); // "<PATH><FILE>" 111 112 /* <scheme>://<username>:<password>@<hostname>:<port>/<file>;<PARAMS>?<query>#<frag> */ 113 char * url_get_parameters(URL this); 114 115 /* <scheme>://<username>:<password>@<hostname>:<port>/<path>;<params>?<QUERY>#<frag> */ 116 char * url_get_query(URL this); 117 118 /* <scheme>://<username>:<password>@<hostname>:<port>/<path>;<params>?<query>#<FRAG> */ 119 char * url_get_fragment(URL this); 120 121 122 /* 123 * Make a decision about what to display. Will show absolute url when fullurl 124 * is set to ture. Otherwise we check the HTTP method to display the submitted 125 * URI or the respective line provided from the urls file. 126 */ 127 char * url_get_display(URL this); 128 129 /** 130 * POST method getters 131 * <scheme>://<username>:<password>@<hostname>:<port>/<path> POST <params>?<query>#<frag> 132 */ 133 size_t url_get_postlen(URL this); 134 char * url_get_postdata(URL this); 135 char * url_get_posttemp(URL this); 136 char * url_get_conttype(URL this); 137 char * url_get_if_modified_since(URL this); 138 char * url_get_etag(URL this); 139 char * url_get_realm(URL this); 140 void url_set_realm(URL this, char *realm); 141 void url_set_username(URL this, char *username); 142 void url_set_password(URL this, char *password); 143 URL url_normalize(URL req, char *location); 144 char * url_normalize_string(URL req, char *location); 145 146 147 #endif/*__URL_H*/ 148