1 /* 2 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 3 * Version 2, December 2004 4 * 5 * Copyright (C) 2012-2013 Sebastien Tricaud <sebastien@honeynet.org> 6 * 7 * Everyone is permitted to copy and distribute verbatim or modified 8 * copies of this license document, and changing it is allowed as long 9 * as the name is changed. 10 * 11 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 12 * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 13 * 14 * 0. You just DO WHAT THE FUCK YOU WANT TO. 15 */ 16 17 #ifndef _FAUP_FAUP_H_ 18 #define _FAUP_FAUP_H_ 19 20 #include <faup/errors.h> 21 #include <faup/features.h> 22 #include <faup/handler.h> 23 #include <faup/options.h> 24 #include <faup/portable.h> 25 #include <faup/tld.h> 26 #include <faup/version.h> 27 28 #include <stdio.h> 29 #include <stdint.h> 30 #include <stddef.h> 31 #include <sys/types.h> 32 33 #ifndef __cplusplus 34 #ifdef WIN32 35 #ifndef bool 36 #define bool int 37 #endif // bool 38 #ifndef true 39 #define true 1 40 #endif // true 41 #ifndef false 42 #define false 0 43 #endif // false 44 #else 45 #include <stdbool.h> 46 #endif // WIN32 47 #endif // __cplusplus 48 49 #ifdef WIN32 50 #include <windows.h> 51 #endif 52 53 #ifdef WIN32 54 #define ssize_t SSIZE_T 55 #endif 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 61 #define FAUP_MAXLEN 8192 62 #define FAUP_MAXPATHLEN 1024 /* Because MAXPATHLEN, MAX_PATH, PATH_MAX are all different 'standards' (ahah!) */ 63 64 #define FAUP_OS_DIRSEP "/" 65 #define FAUP_OS_DIRSEP_C '/' 66 67 68 69 enum _faup_url_type_t { 70 FAUP_URL_HAS_NO_TLD, 71 FAUP_URL_HAS_MOZILLA_TLD, 72 FAUP_URL_HAS_UNKNOWN_TLD, 73 FAUP_URL_IPV4, 74 FAUP_URL_IPV6, 75 }; 76 typedef enum _faup_url_type_t faup_url_type_t; 77 78 struct _faup_t { 79 const char *org_str; 80 size_t org_str_len; 81 bool decoded; 82 faup_features_t features; 83 faup_url_type_t url_type; 84 }; 85 typedef struct _faup_t faup_t; 86 87 struct _faup_handler_t { 88 faup_t faup; 89 faup_options_t *options; 90 #ifdef FAUP_LUA_MODULES 91 void *modules; // faup_modules_t 92 #endif 93 }; 94 95 enum _faup_last_slash_t { 96 FAUP_LAST_SLASH_NOTFOUND, 97 FAUP_LAST_SLASH_HIERARCHICAL, 98 FAUP_LAST_SLASH_AFTER_DOMAIN, 99 }; 100 typedef enum _faup_last_slash_t faup_last_slash_t; 101 102 #define faup_get_pos(fh, name) (fh)->faup.features.name.pos 103 #define faup_get_size(fh, name) (fh)->faup.features.name.size 104 105 faup_handler_t *faup_init(faup_options_t *options); 106 char *faup_get_version(void); 107 void faup_terminate(faup_handler_t *fh); 108 109 int32_t faup_get_scheme_pos(faup_handler_t *fh); 110 uint32_t faup_get_scheme_size(faup_handler_t *fh); 111 int32_t faup_get_credential_pos(faup_handler_t *fh); 112 uint32_t faup_get_credential_size(faup_handler_t *fh); 113 int32_t faup_get_subdomain_pos(faup_handler_t *fh); 114 uint32_t faup_get_subdomain_size(faup_handler_t *fh); 115 int32_t faup_get_domain_pos(faup_handler_t *fh); 116 uint32_t faup_get_domain_size(faup_handler_t *fh); 117 int32_t faup_get_domain_without_tld_pos(faup_handler_t *fh); 118 uint32_t faup_get_domain_without_tld_size(faup_handler_t *fh); 119 int32_t faup_get_host_pos(faup_handler_t *fh); 120 uint32_t faup_get_host_size(faup_handler_t *fh); 121 int32_t faup_get_tld_pos(faup_handler_t *fh); 122 uint32_t faup_get_tld_size(faup_handler_t *fh); 123 int32_t faup_get_port_pos(faup_handler_t *fh); 124 uint32_t faup_get_port_size(faup_handler_t *fh); 125 int32_t faup_get_resource_path_pos(faup_handler_t *fh); 126 uint32_t faup_get_resource_path_size(faup_handler_t *fh); 127 int32_t faup_get_query_string_pos(faup_handler_t *fh); 128 uint32_t faup_get_query_string_size(faup_handler_t *fh); 129 int32_t faup_get_fragment_pos(faup_handler_t *fh); 130 uint32_t faup_get_fragment_size(faup_handler_t *fh); 131 132 #ifdef __cplusplus 133 } 134 #endif 135 136 #endif /* _FAUP_FAUP_H_ */ 137