1 /* ------------------------------------------------------------ */ 2 /* 3 HTTrack Website Copier, Offline Browser for Windows and Unix 4 Copyright (C) 1998-2017 Xavier Roche and other contributors 5 6 This program 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 This program 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 General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19 Important notes: 20 21 - We hereby ask people using this source NOT to use it in purpose of grabbing 22 emails addresses, or collecting any other private information on persons. 23 This would disgrace our work, and spoil the many hours we spent on it. 24 25 Please visit our Website: http://www.httrack.com 26 */ 27 28 /* ------------------------------------------------------------ */ 29 /* File: Global #define file */ 30 /* Author: Xavier Roche */ 31 /* ------------------------------------------------------------ */ 32 33 // Fichier réunissant l'ensemble des defines 34 35 #ifndef HTTRACK_GLOBAL_DEFH 36 #define HTTRACK_GLOBAL_DEFH 37 38 // Version (also check external version information) 39 #define HTTRACK_VERSION "3.49-2" 40 #define HTTRACK_VERSIONID "3.49.2" 41 #define HTTRACK_AFF_VERSION "3.x" 42 #define HTTRACK_LIB_VERSION "2.0" 43 44 #ifndef HTS_NOINCLUDES 45 #include <stdio.h> 46 #include <stdlib.h> 47 #endif 48 49 // Définition plate-forme 50 #include "htsconfig.h" 51 52 // WIN32 types 53 #ifdef _WIN32 54 #ifndef SIZEOF_LONG 55 #define SIZEOF_LONG 4 56 #define SIZEOF_LONG_LONG 8 57 #endif 58 #endif 59 60 /* GCC extension */ 61 #ifndef HTS_UNUSED 62 #ifdef __GNUC__ 63 #define HTS_UNUSED __attribute__ ((unused)) 64 #define HTS_STATIC static __attribute__ ((unused)) 65 #define HTS_PRINTF_FUN(fmt, arg) __attribute__ ((format (printf, fmt, arg))) 66 #else 67 #define HTS_UNUSED 68 #define HTS_STATIC static 69 #define HTS_PRINTF_FUN(fmt, arg) 70 #endif 71 #endif 72 73 // config.h 74 #ifdef _WIN32 75 76 /* 77 #define HAVE_SYS_STAT_H 1 78 #define HAVE_SYS_TYPES_H 1 79 #define HAVE_SYS_STAT_H 1 80 */ 81 #ifndef DLLIB 82 #define DLLIB 1 83 #endif 84 #ifndef HTS_INET6 85 #define HTS_INET6 1 86 #endif 87 #ifndef S_ISREG 88 #define S_ISREG(m) ((m) & _S_IFREG) 89 #define S_ISDIR(m) ((m) & _S_IFDIR) 90 #endif 91 92 #else 93 94 #include "config.h" 95 96 #ifndef FTIME 97 #define HTS_DO_NOT_USE_FTIME 98 #endif 99 100 #ifndef SETUID 101 #define HTS_DO_NOT_USE_UID 102 #endif 103 104 #ifndef HTS_LONGLONG 105 #ifdef SIZEOF_LONG_LONG 106 #if SIZEOF_LONG_LONG==8 107 #define HTS_LONGLONG 1 108 #endif 109 #endif 110 111 #ifndef HTS_LONGLONG 112 #ifdef __sun 113 #define HTS_LONGLONG 0 114 #endif 115 #ifdef __osf__ 116 #define HTS_LONGLONG 0 117 #endif 118 #ifdef __linux 119 #define HTS_LONGLONG 1 120 #endif 121 #ifdef _WIN32 122 #define HTS_LONGLONG 1 123 #endif 124 #endif 125 #endif 126 127 #ifdef DLLIB 128 #define HTS_DLOPEN 1 129 #else 130 #define HTS_DLOPEN 0 131 #endif 132 133 #endif 134 135 #ifndef BIGSTK 136 #define BIGSTK 137 #endif 138 139 // compatibilité DOS 140 #ifdef _WIN32 141 #define HTS_DOSNAME 1 142 #else 143 #define HTS_DOSNAME 0 144 #endif 145 146 // utiliser zlib? 147 #ifndef HTS_USEZLIB 148 // autoload 149 #define HTS_USEZLIB 1 150 #endif 151 152 #ifndef HTS_INET6 153 #define HTS_INET6 0 154 #endif 155 156 // utiliser openssl? 157 #ifndef HTS_USEOPENSSL 158 // autoload 159 #define HTS_USEOPENSSL 1 160 #endif 161 162 #ifndef HTS_DLOPEN 163 #define HTS_DLOPEN 1 164 #endif 165 166 #ifndef HTS_USESWF 167 #define HTS_USESWF 1 168 #endif 169 170 #ifdef _WIN32 171 #else 172 #define __cdecl 173 #endif 174 175 /* rc file */ 176 #ifdef _WIN32 177 #define HTS_HTTRACKRC "httrackrc" 178 #else 179 180 #ifndef HTS_ETCPATH 181 #define HTS_ETCPATH "/etc" 182 #endif 183 #ifndef HTS_BINPATH 184 #define HTS_BINPATH "/usr/bin" 185 #endif 186 #ifndef HTS_LIBPATH 187 #define HTS_LIBPATH "/usr/lib" 188 #endif 189 #ifndef HTS_PREFIX 190 #define HTS_PREFIX "/usr" 191 #endif 192 193 #define HTS_HTTRACKRC ".httrackrc" 194 #define HTS_HTTRACKCNF HTS_ETCPATH"/httrack.conf" 195 196 #ifdef DATADIR 197 #define HTS_HTTRACKDIR DATADIR"/httrack/" 198 #else 199 #define HTS_HTTRACKDIR HTS_PREFIX"/share/httrack/" 200 #endif 201 202 #endif 203 204 /* Taille max d'une URL */ 205 #define HTS_URLMAXSIZE 1024 206 /* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */ 207 #define HTS_CDLMAXSIZE 1024 208 209 /* Copyright (C) 1998-2017 Xavier Roche and other contributors */ 210 #define HTTRACK_AFF_AUTHORS "[XR&CO'2014]" 211 #define HTS_DEFAULT_FOOTER "<!-- Mirrored from %s%s by HTTrack Website Copier/"HTTRACK_AFF_VERSION" "HTTRACK_AFF_AUTHORS", %s -->" 212 #define HTTRACK_WEB "http://www.httrack.com" 213 #define HTS_UPDATE_WEBSITE "http://www.httrack.com/update.php3?Product=HTTrack&Version="HTTRACK_VERSIONID"&VersionStr="HTTRACK_VERSION"&Platform=%d&Language=%s" 214 215 #define H_CRLF "\x0d\x0a" 216 #define CRLF "\x0d\x0a" 217 #ifdef _WIN32 218 #define LF "\x0d\x0a" 219 #else 220 #define LF "\x0a" 221 #endif 222 223 /* équivaut à "paramètre vide", par exemple -F (none) */ 224 #define HTS_NOPARAM "(none)" 225 #define HTS_NOPARAM2 "\"(none)\"" 226 227 /* maximum et minimum */ 228 #define maximum(A,B) ( (A) > (B) ? (A) : (B) ) 229 #define minimum(A,B) ( (A) < (B) ? (A) : (B) ) 230 231 /* chaine no empty ? (and not null) */ 232 #define strnotempty(A) (((A) != NULL && (A)[0] != '\0')) 233 234 /* optimisation inline si possible */ 235 #ifdef __cplusplus 236 #define HTS_INLINE inline 237 #else 238 #define HTS_INLINE 239 #endif 240 241 #ifdef _WIN32 242 #ifdef LIBHTTRACK_EXPORTS 243 #define HTSEXT_API __declspec(dllexport) 244 #else 245 #define HTSEXT_API __declspec(dllimport) 246 #endif 247 #else 248 /* See <http://gcc.gnu.org/wiki/Visibility> */ 249 #if ( ( defined(__GNUC__) && ( __GNUC__ >= 4 ) ) \ 250 || ( defined(HAVE_VISIBILITY) && HAVE_VISIBILITY ) ) 251 #define HTSEXT_API __attribute__ ((visibility ("default"))) 252 #else 253 #define HTSEXT_API 254 #endif 255 #endif 256 257 #ifndef HTS_LONGLONG 258 #ifdef HTS_NO_64_BIT 259 #define HTS_LONGLONG 0 260 #else 261 #define HTS_LONGLONG 1 262 #endif 263 #endif 264 265 // long long int? (or int) 266 // (and int cast for system functions like malloc() ) 267 268 #if HTS_LONGLONG 269 #ifdef LLINT_FORMAT 270 typedef LLINT_TYPE LLint; 271 typedef LLINT_TYPE TStamp; 272 273 #define LLintP LLINT_FORMAT 274 #else 275 276 #ifdef _WIN32 277 typedef __int64 LLint; 278 typedef __int64 TStamp; 279 280 #define LLintP "%I64d" 281 #elif (defined(_LP64) || defined(__x86_64__) \ 282 || defined(__powerpc64__) || defined(__64BIT__)) 283 typedef long int LLint; 284 typedef long int TStamp; 285 286 #define LLintP "%ld" 287 #else 288 typedef long long int LLint; 289 typedef long long int TStamp; 290 291 #define LLintP "%lld" 292 #endif 293 294 #endif /* HTS_LONGLONG */ 295 296 #else 297 typedef int LLint; 298 299 #define LLintP "%d" 300 typedef double TStamp; 301 #endif 302 303 #ifdef LFS_FLAG 304 typedef LLint INTsys; 305 306 #define INTsysP LLintP 307 #ifdef __linux 308 #define HTS_FSEEKO 309 #endif 310 #else 311 typedef int INTsys; 312 313 #define INTsysP "%d" 314 #endif 315 316 #ifdef _WIN32 317 #if defined(_WIN64) 318 typedef unsigned __int64 T_SOC; 319 #else 320 typedef unsigned __int32 T_SOC; 321 #endif 322 #else 323 typedef int T_SOC; 324 #endif 325 326 /* IPV4, IPV6 and various unified structures */ 327 #define HTS_MAXADDRLEN 64 328 329 #ifdef _WIN32 330 #else 331 #define __cdecl 332 #endif 333 334 /* mode pour mkdir ET chmod (accès aux fichiers) */ 335 #define HTS_PROTECT_FOLDER (S_IRUSR|S_IWUSR|S_IXUSR) 336 #if HTS_ACCESS 337 #define HTS_ACCESS_FILE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) 338 #define HTS_ACCESS_FOLDER (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) 339 #else 340 #define HTS_ACCESS_FILE (S_IRUSR|S_IWUSR) 341 #define HTS_ACCESS_FOLDER (S_IRUSR|S_IWUSR|S_IXUSR) 342 #endif 343 344 /* vérifier la déclaration des variables préprocesseur */ 345 #ifndef HTS_DOSNAME 346 #error | HTS_DOSNAME Has not been defined. 347 #error | Set it to 1 if you are under DOS, 0 under Unix. 348 #error | Example: place this line in you source, before includes: 349 #error | #define HTS_DOSNAME 0 350 #error 351 #error 352 #endif 353 #ifndef HTS_ACCESS 354 /* Par défaut, accès à tous les utilisateurs */ 355 #define HTS_ACCESS 1 356 #endif 357 358 /* fflush sur stdout */ 359 #define io_flush { fflush(stdout); fflush(stdin); } 360 361 /* HTSLib */ 362 363 // Cache DNS, accélère les résolution d'adresses 364 #define HTS_DNSCACHE 1 365 366 // ID d'une pseudo-socket locale pour les file:// 367 #define LOCAL_SOCKET_ID -2 368 369 // taille de chaque buffer (10 sockets 650 ko) 370 #define TAILLE_BUFFER 65536 371 372 #ifdef HTS_DO_NOT_USE_PTHREAD 373 #error needs threads support 374 #endif 375 #define USE_BEGINTHREAD 1 376 377 #ifdef _DEBUG 378 // trace mallocs 379 //#define HTS_TRACE_MALLOC 380 #ifdef HTS_TRACE_MALLOC 381 typedef unsigned long int t_htsboundary; 382 383 #ifndef HTS_DEF_FWSTRUCT_mlink 384 #define HTS_DEF_FWSTRUCT_mlink 385 typedef struct mlink mlink; 386 #endif 387 struct mlink { 388 char *adr; 389 int len; 390 int id; 391 struct mlink *next; 392 }; 393 static const t_htsboundary htsboundary = 0xDEADBEEF; 394 #endif 395 #endif 396 397 /* strxxx debugging */ 398 #ifndef NOSTRDEBUG 399 #define STRDEBUG 1 400 #endif 401 402 /* ------------------------------------------------------------ */ 403 /* Debugging */ 404 /* ------------------------------------------------------------ */ 405 406 // débuggage types 407 #define DEBUG_SHOWTYPES 0 408 // backing debug 409 #define BDEBUG 0 410 // chunk receive 411 #define CHUNKDEBUG 0 412 // realloc links debug 413 #define MDEBUG 0 414 // cache debug 415 #define DEBUGCA 0 416 // DNS debug 417 #define DEBUGDNS 0 418 // savename debug 419 #define DEBUG_SAVENAME 0 420 // debug robots 421 #define DEBUG_ROBOTS 0 422 // debug hash 423 #define DEBUG_HASH 0 424 // Vérification d'intégrité 425 #define DEBUG_CHECKINT 0 426 // nbr sockets debug 427 #define NSDEBUG 0 428 429 // débuggage HTSLib 430 #define HDEBUG 0 431 // surveillance de la connexion 432 #define CNXDEBUG 0 433 // debuggage cookies 434 #define DEBUG_COOK 0 435 // débuggage hard.. 436 #define HTS_WIDE_DEBUG 0 437 // debuggage deletehttp et cie 438 #define HTS_DEBUG_CLOSESOCK 0 439 // debug tracage mémoire 440 #define MEMDEBUG 0 441 442 // htsmain 443 #define DEBUG_STEPS 0 444 445 // Débuggage de contrôle 446 #if HTS_DEBUG_CLOSESOCK 447 #define _HTS_WIDE 1 448 #endif 449 #if HTS_WIDE_DEBUG 450 #define _HTS_WIDE 1 451 #endif 452 #if _HTS_WIDE 453 extern FILE *DEBUG_fp; 454 455 #define DEBUG_W(A) { if (DEBUG_fp==NULL) DEBUG_fp=fopen("bug.out","wb"); fprintf(DEBUG_fp,":>"A); fflush(DEBUG_fp); } 456 #undef _ 457 #define _ , 458 #endif 459 460 #endif 461