From 540efa3d863717a4a2dfcfbde8e0af107b667e15 Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Sun, 8 Jun 2014 16:17:19 +0000 Subject: [PATCH] Merged revisions 1020-1023,1027-1029,1031,1033-1036,1038,1040,1042,1044-1054,1058-1072,1074-1087,1089-1112,1114-1124,1126-1128,1130-1133,1137,1139-1143,1145,1147-1159,1161,1163-1164 via svnmerge from http://proliant/svn/httrack/trunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ........ r1020 | roche | 2014-05-13 22:08:53 +0200 (mar., 13 mai 2014) | 3 lines #include ........ r1021 | roche | 2014-05-13 22:11:02 +0200 (mar., 13 mai 2014) | 3 lines #include ........ r1022 | roche | 2014-05-13 22:11:41 +0200 (mar., 13 mai 2014) | 3 lines #include ........ r1023 | roche | 2014-05-13 22:12:10 +0200 (mar., 13 mai 2014) | 3 lines Better stdarg.h ........ r1027 | roche | 2014-05-14 19:45:51 +0200 (mer., 14 mai 2014) | 1 line Added debug logging facility. ........ r1028 | roche | 2014-05-14 19:48:04 +0200 (mer., 14 mai 2014) | 3 lines Fixed hashtable corruption because of dirty code directly modifying the host address in memory, leading to have hashtable positions not anymore valid. This issue was especially triggered when a redirect was processed ("Warning moved treated for .." messages) * closes: #43 ........ r1029 | roche | 2014-05-14 19:51:09 +0200 (mer., 14 mai 2014) | 1 line 3.48.7 ........ r1031 | roche | 2014-05-14 19:57:18 +0200 (mer., 14 mai 2014) | 3 lines 3.48.7 ........ r1033 | roche | 2014-05-14 21:51:33 +0200 (mer., 14 mai 2014) | 1 line Missing htsCallbackErr definition ........ r1034 | roche | 2014-05-14 22:12:42 +0200 (mer., 14 mai 2014) | 1 line Clean hts_set_error_callback() and hts_get_error_callback() ........ r1035 | roche | 2014-05-14 22:20:01 +0200 (mer., 14 mai 2014) | 1 line Fixed macro. ........ r1036 | roche | 2014-05-14 22:27:55 +0200 (mer., 14 mai 2014) | 1 line Cosmetic ........ r1038 | roche | 2014-05-15 19:06:59 +0200 (jeu., 15 mai 2014) | 1 line WIN32: zlib 1.2.8 ........ r1040 | roche | 2014-05-15 19:08:29 +0200 (jeu., 15 mai 2014) | 1 line 3.48.8 ........ r1042 | roche | 2014-05-15 19:22:16 +0200 (jeu., 15 mai 2014) | 3 lines 3.48.8-1 ........ r1044 | roche | 2014-05-15 19:26:46 +0200 (jeu., 15 mai 2014) | 3 lines Removed unused variable. ........ r1045 | roche | 2014-05-15 21:24:56 +0200 (jeu., 15 mai 2014) | 1 line Fixed uint64_t vs. long long int ........ r1046 | roche | 2014-05-15 21:25:27 +0200 (jeu., 15 mai 2014) | 1 line Compile-time checks. ........ r1047 | roche | 2014-05-15 21:27:29 +0200 (jeu., 15 mai 2014) | 1 line Cosmetic. ........ r1048 | roche | 2014-05-15 21:33:38 +0200 (jeu., 15 mai 2014) | 3 lines Added some asserts for Android. ........ r1049 | roche | 2014-05-15 21:44:28 +0200 (jeu., 15 mai 2014) | 3 lines tr -d '\r' ........ r1050 | roche | 2014-05-17 14:31:37 +0200 (sam., 17 mai 2014) | 3 lines Fixed potentiel overrun if the user injects a buggy user-defined structure with a non-terminated %[] ........ r1051 | roche | 2014-05-17 15:20:42 +0200 (sam., 17 mai 2014) | 1 line Added hts_set_log_vprint_callback() ........ r1052 | roche | 2014-05-17 15:21:03 +0200 (sam., 17 mai 2014) | 1 line Added hts_set_log_vprint_callback() definition ........ r1053 | roche | 2014-05-17 15:29:45 +0200 (sam., 17 mai 2014) | 1 line Anonymous logging. ........ r1054 | roche | 2014-05-17 15:55:17 +0200 (sam., 17 mai 2014) | 1 line Illegal use of strnlen(..., (size_t) -1) ........ r1058 | roche | 2014-05-18 11:49:24 +0200 (dim., 18 mai 2014) | 1 line Cleanup in socket handling (less ugly casts!) ........ r1059 | roche | 2014-05-18 12:53:29 +0200 (dim., 18 mai 2014) | 1 line Removed size member from SOCaddr ........ r1060 | roche | 2014-05-18 12:59:07 +0200 (dim., 18 mai 2014) | 3 lines libtool: in_port_t and sa_family_t ........ r1061 | roche | 2014-05-18 15:11:40 +0200 (dim., 18 mai 2014) | 5 lines Big cleanup in network address and dns functions: * removed t_fullhostent insanity * removed (struct sockaddr*) casts * use SOCaddr everywhere rather than raw struct hostent* ........ r1062 | roche | 2014-05-18 15:43:09 +0200 (dim., 18 mai 2014) | 1 line Cleanup in callbacks. ........ r1063 | roche | 2014-05-18 15:55:47 +0200 (dim., 18 mai 2014) | 3 lines Backlog for web server to 10. ........ r1064 | roche | 2014-05-18 15:55:54 +0200 (dim., 18 mai 2014) | 3 lines tr -d '\r' ........ r1065 | roche | 2014-05-18 16:02:06 +0200 (dim., 18 mai 2014) | 3 lines Removed unused variable. ........ r1066 | roche | 2014-05-18 16:05:08 +0200 (dim., 18 mai 2014) | 1 line Fixed __builtin___strncat_chk warning ........ r1067 | roche | 2014-05-19 21:12:27 +0200 (lun., 19 mai 2014) | 2 lines Fixed segOutputSize < segSize assertion fails at htscharset.c:993 * closes:#44 ........ r1068 | roche | 2014-05-19 21:15:16 +0200 (lun., 19 mai 2014) | 1 line Added strlcpybuff() macro. ........ r1069 | roche | 2014-05-19 21:17:50 +0200 (lun., 19 mai 2014) | 1 line char* => const char* ........ r1070 | roche | 2014-05-19 21:24:06 +0200 (lun., 19 mai 2014) | 3 lines Added unit test for issue #44 ........ r1071 | roche | 2014-05-19 21:37:40 +0200 (lun., 19 mai 2014) | 3 lines tr -d '\r' ........ r1072 | roche | 2014-05-21 19:01:30 +0200 (mer., 21 mai 2014) | 1 line Cleaner dup ........ r1074 | roche | 2014-05-21 19:21:29 +0200 (mer., 21 mai 2014) | 1 line 3.48.9 ........ r1075 | roche | 2014-05-23 17:23:17 +0200 (ven., 23 mai 2014) | 3 lines 3.48.9-1 changelog ........ r1076 | roche | 2014-05-23 17:24:50 +0200 (ven., 23 mai 2014) | 3 lines 3.48.9 (autoconf) ........ r1077 | roche | 2014-05-23 17:28:55 +0200 (ven., 23 mai 2014) | 3 lines Added symbol visibility features to the build to hide internal symbols (GCC) ........ r1078 | roche | 2014-05-23 23:33:43 +0200 (ven., 23 mai 2014) | 9 lines "const correctness" cleanup added the following default flags: -Wformat -Wformat-security -Wmultichar -Wwrite-strings fixed several other warnings ........ r1079 | roche | 2014-05-24 09:45:12 +0200 (sam., 24 mai 2014) | 3 lines Diff are better. ........ r1080 | roche | 2014-05-24 09:50:51 +0200 (sam., 24 mai 2014) | 3 lines No diff. ........ r1081 | roche | 2014-05-24 09:56:11 +0200 (sam., 24 mai 2014) | 3 lines Upgraded to minizip 1.1 from zlib 1.2.8 ........ r1082 | roche | 2014-05-24 10:17:08 +0200 (sam., 24 mai 2014) | 3 lines Missing zflush_file member. ........ r1083 | roche | 2014-05-24 10:37:21 +0200 (sam., 24 mai 2014) | 3 lines Fixed minizip. ........ r1084 | roche | 2014-05-24 13:31:17 +0200 (sam., 24 mai 2014) | 3 lines Removed ChangeLogUnzip ........ r1085 | roche | 2014-05-24 13:38:11 +0200 (sam., 24 mai 2014) | 3 lines Fixed EXTRA_DIST ........ r1086 | roche | 2014-05-24 13:57:25 +0200 (sam., 24 mai 2014) | 3 lines Minizip warning fixes. ........ r1087 | roche | 2014-05-26 21:27:46 +0200 (lun., 26 mai 2014) | 1 line Big links heap handling cleanup, and removed very old and legacy macros ........ r1089 | roche | 2014-05-26 21:32:34 +0200 (lun., 26 mai 2014) | 3 lines tr -d '\r' ........ r1090 | roche | 2014-05-27 18:05:09 +0200 (mar., 27 mai 2014) | 3 lines Fixed symbol import. ........ r1091 | roche | 2014-05-27 18:05:28 +0200 (mar., 27 mai 2014) | 3 lines tr -d '\r' ........ r1092 | roche | 2014-05-27 18:05:54 +0200 (mar., 27 mai 2014) | 3 lines Export may_unknown and guess_httptype ........ r1093 | roche | 2014-05-27 18:35:57 +0200 (mar., 27 mai 2014) | 3 lines Rewritten UTF8 writer to avoir spurious GCC 4.8.3 warnings. ........ r1094 | roche | 2014-05-27 19:45:18 +0200 (mar., 27 mai 2014) | 3 lines Fixed help option, and too long help line (man: "cannot adjust line") ........ r1095 | roche | 2014-05-27 20:55:13 +0200 (mar., 27 mai 2014) | 1 line Cleanup, const correctness ........ r1096 | roche | 2014-05-28 18:34:06 +0200 (mer., 28 mai 2014) | 3 lines Added Vcs-Browser and Vcs-Svn fields to debian/control ........ r1097 | roche | 2014-05-28 18:36:24 +0200 (mer., 28 mai 2014) | 3 lines Fixed dirty uint32_t cast leading to aliasing issues. ........ r1098 | roche | 2014-05-28 18:50:47 +0200 (mer., 28 mai 2014) | 3 lines Added MD5 self-test ........ r1099 | roche | 2014-05-28 18:51:56 +0200 (mer., 28 mai 2014) | 3 lines Fixed const T ** not being castable to const T ** ........ r1100 | roche | 2014-05-28 18:58:37 +0200 (mer., 28 mai 2014) | 3 lines Fixed build. ........ r1101 | roche | 2014-05-28 19:06:47 +0200 (mer., 28 mai 2014) | 3 lines Really fixed. ........ r1102 | roche | 2014-05-28 19:41:42 +0200 (mer., 28 mai 2014) | 3 lines Bad md5. ........ r1103 | roche | 2014-05-28 19:55:49 +0200 (mer., 28 mai 2014) | 19 lines Added AM_PROG_CC_C_O and AM_PROG_LIBTOOL Removed unused CXX added the following default compiler flags: -Wdeclaration-after-statement -Wsequence-point -Wparentheses -Winit-self -Wuninitialized -Wformat -fstrict-aliasing -Wstrict-aliasing=2 added the following default linker flags: -Wl,--discard-all -Wl,--no-undefined Depending on autoconf-archive because using AX_CHECK_COMPILE_FLAG and AX_CHECK_LINK_FLAG ........ r1104 | roche | 2014-05-28 20:27:45 +0200 (mer., 28 mai 2014) | 3 lines Fixed %%% ........ r1105 | roche | 2014-05-28 20:31:40 +0200 (mer., 28 mai 2014) | 1 line Rewrite template formatting to be format-injection proof. ........ r1106 | roche | 2014-05-28 20:41:59 +0200 (mer., 28 mai 2014) | 1 line Fixed heap crawl overflow ........ r1107 | roche | 2014-05-28 20:58:59 +0200 (mer., 28 mai 2014) | 1 line Rewrite string template formatting to be format-injection proof. ........ r1108 | roche | 2014-05-28 21:03:07 +0200 (mer., 28 mai 2014) | 1 line Fixed NULL terminated string. ........ r1109 | roche | 2014-05-28 21:03:26 +0200 (mer., 28 mai 2014) | 1 line Replaced sprintf() by hts_template_format_str() ........ r1110 | roche | 2014-05-28 21:05:31 +0200 (mer., 28 mai 2014) | 1 line Added assert ........ r1111 | roche | 2014-05-28 21:11:04 +0200 (mer., 28 mai 2014) | 3 lines Added -Wformat-nonliteral flag. ........ r1112 | roche | 2014-05-29 10:20:07 +0200 (jeu., 29 mai 2014) | 1 line Allocation cleanup (why "+2", why ?) ........ r1114 | roche | 2014-05-29 10:30:43 +0200 (jeu., 29 mai 2014) | 1 line Added off_t_to_size_t() ........ r1115 | roche | 2014-05-29 11:34:37 +0200 (jeu., 29 mai 2014) | 3 lines Fixes. ........ r1116 | roche | 2014-05-29 11:41:59 +0200 (jeu., 29 mai 2014) | 1 line Removed duplicate opt->lien_tot and opt->liens members in some functions. ........ r1117 | roche | 2014-05-29 17:42:53 +0200 (jeu., 29 mai 2014) | 1 line Big cleanup: introducing cleaner lien_adrfilsave and lien_adrfil structures holding address/uri or address/uri/filename rather than passing opaque char* of unknown size. ........ r1118 | roche | 2014-05-29 17:53:30 +0200 (jeu., 29 mai 2014) | 1 line Unused function. ........ r1119 | roche | 2014-05-29 17:57:57 +0200 (jeu., 29 mai 2014) | 1 line Fixed API change. ........ r1120 | roche | 2014-05-29 18:03:04 +0200 (jeu., 29 mai 2014) | 3 lines tr -d '\r' ........ r1121 | roche | 2014-05-29 18:14:57 +0200 (jeu., 29 mai 2014) | 1 line Fixed regression over ./ ........ r1122 | roche | 2014-05-29 19:29:02 +0200 (jeu., 29 mai 2014) | 1 line Take in account opt->maxlink is non-zero ........ r1123 | roche | 2014-05-29 19:58:05 +0200 (jeu., 29 mai 2014) | 1 line Allocation failure handling. ........ r1124 | roche | 2014-05-29 20:10:14 +0200 (jeu., 29 mai 2014) | 1 line Better "too many links" reporting. ........ r1126 | roche | 2014-05-30 18:09:02 +0200 (ven., 30 mai 2014) | 3 lines Missing string.h (moe) ........ r1127 | roche | 2014-06-03 18:26:25 +0200 (mar., 03 juin 2014) | 1 line Potential fix for htshash.c:330 assertion failure: "error invalidating hash entry" ........ r1128 | roche | 2014-06-04 18:10:38 +0200 (mer., 04 juin 2014) | 3 lines Do not depend on SetDllDirectory (Windows 2003) as it breaks Windows 2000 * closes: #45 ........ r1130 | roche | 2014-06-04 19:02:44 +0200 (mer., 04 juin 2014) | 3 lines 3.48-10 ........ r1131 | roche | 2014-06-04 19:06:43 +0200 (mer., 04 juin 2014) | 1 line 3.48.10 ........ r1132 | roche | 2014-06-04 19:10:40 +0200 (mer., 04 juin 2014) | 3 lines Updated configure ........ r1133 | roche | 2014-06-04 19:41:42 +0200 (mer., 04 juin 2014) | 3 lines Updated man ........ r1137 | roche | 2014-06-04 21:53:07 +0200 (mer., 04 juin 2014) | 3 lines Fixed "this decimal constant is unsigned only in ISO C90" ........ r1139 | roche | 2014-06-05 17:59:49 +0200 (jeu., 05 juin 2014) | 1 line changelog ........ r1140 | roche | 2014-06-05 18:00:05 +0200 (jeu., 05 juin 2014) | 3 lines Added missing .h to -dev ........ r1141 | roche | 2014-06-06 17:47:38 +0200 (ven., 06 juin 2014) | 7 lines Fixed assertion failure at htscore.c:244 (len + liensbuf->string_buffer_size < liensbuf->string_buffer_capa) * closes:46 -Cette ligne, et les suivantes ci-dessous, seront ignorées-- M trunk/src/htscore.c ........ r1142 | roche | 2014-06-06 17:48:05 +0200 (ven., 06 juin 2014) | 3 lines Additional check. ........ r1143 | roche | 2014-06-06 17:57:02 +0200 (ven., 06 juin 2014) | 1 line 3.48.11 ........ r1145 | roche | 2014-06-06 18:02:35 +0200 (ven., 06 juin 2014) | 3 lines 3.48.11 ........ r1147 | roche | 2014-06-06 20:43:50 +0200 (ven., 06 juin 2014) | 3 lines Splitted typed arrays in htsarrays.h Cleaned-up page generation ........ r1148 | roche | 2014-06-06 20:47:24 +0200 (ven., 06 juin 2014) | 3 lines Updated man ........ r1149 | roche | 2014-06-06 20:47:39 +0200 (ven., 06 juin 2014) | 3 lines tr -d '\r' ........ r1150 | roche | 2014-06-06 20:47:53 +0200 (ven., 06 juin 2014) | 3 lines Added htsarrays.h to Makefile and devel libs ........ r1151 | roche | 2014-06-06 21:03:41 +0200 (ven., 06 juin 2014) | 1 line Progressive power-of-two allocator for linked blocks. ........ r1152 | roche | 2014-06-06 21:08:47 +0200 (ven., 06 juin 2014) | 1 line Cleanup. ........ r1153 | roche | 2014-06-06 22:58:35 +0200 (ven., 06 juin 2014) | 3 lines Fixed initializer. ........ r1154 | roche | 2014-06-07 09:03:08 +0200 (sam., 07 juin 2014) | 3 lines Fixed --advanced-maxlinks broken (Localhost) ........ r1155 | roche | 2014-06-07 09:03:13 +0200 (sam., 07 juin 2014) | 3 lines Better. ........ r1156 | roche | 2014-06-08 11:26:46 +0200 (dim., 08 juin 2014) | 1 line Typos ........ r1157 | roche | 2014-06-08 11:35:34 +0200 (dim., 08 juin 2014) | 3 lines Fixed __cplusplus issues ........ r1158 | roche | 2014-06-08 13:12:21 +0200 (dim., 08 juin 2014) | 4 lines Using subdir-objects for automake Replaced legacy INCLUDES by AM_CPPFLAGS ........ r1159 | roche | 2014-06-08 13:22:41 +0200 (dim., 08 juin 2014) | 3 lines 3.48.12 ........ r1161 | roche | 2014-06-08 15:02:43 +0200 (dim., 08 juin 2014) | 9 lines Public definitions cleanup (especially for httraqt) htsopt.h now has the following definitions: * struct htsrequest_proxy * struct htsrequest * struct htsblk * struct lien_url * struct lien_back ........ r1163 | roche | 2014-06-08 15:58:57 +0200 (dim., 08 juin 2014) | 1 line __cplusplus ........ r1164 | roche | 2014-06-08 17:43:28 +0200 (dim., 08 juin 2014) | 3 lines 3.48.13 ........ --- Makefile.in | 9 +- compile | 241 +- config.h.in | 13 + configure | 4571 ++++------------------------- configure.ac | 80 +- debian/changelog | 44 + debian/control | 4 +- history.txt | 17 +- html/Makefile.in | 9 +- html/httrack.man.html | 4 +- lang/Makefile.in | 9 +- libtest/Makefile.am | 4 +- libtest/Makefile.in | 42 +- m4/Makefile.in | 9 +- man/Makefile.in | 9 +- man/httrack.1 | 4 +- src/Makefile.am | 18 +- src/Makefile.in | 324 +- src/htsalias.c | 14 +- src/htsalias.h | 2 +- src/htsarrays.h | 149 + src/htsback.c | 68 +- src/htsback.h | 28 +- src/htsbasenet.h | 11 +- src/htsbauth.c | 66 +- src/htsbauth.h | 24 +- src/htscache.c | 12 +- src/htscatchurl.c | 53 +- src/htscharset.c | 98 +- src/htsconcat.c | 2 +- src/htscore.c | 776 ++--- src/htscore.h | 134 +- src/htscoremain.c | 41 +- src/htsdefines.h | 9 +- src/htsentities.h | 504 ++-- src/htsentities.sh | 2 +- src/htsfilters.c | 10 +- src/htsfilters.h | 6 +- src/htsftp.c | 84 +- src/htsftp.h | 2 +- src/htsglobal.h | 31 +- src/htshash.c | 57 +- src/htshash.h | 2 +- src/htshelp.c | 16 +- src/htshelp.h | 8 +- src/htsindex.c | 6 +- src/htsinthash.c | 78 +- src/htsinthash.h | 27 + src/htsjava.c | 9 +- src/htslib.c | 540 ++-- src/htslib.h | 140 +- src/htsmd5.c | 26 +- src/htsmd5.h | 1 + src/htsmodules.c | 14 +- src/htsmodules.h | 13 +- src/htsname.c | 347 ++- src/htsname.h | 23 +- src/htsnet.h | 313 +- src/htsopt.h | 175 +- src/htsparse.c | 1496 +++++----- src/htsparse.h | 29 +- src/htsrobots.c | 6 +- src/htsrobots.h | 4 +- src/htssafe.h | 59 +- src/htsserver.c | 220 +- src/htsserver.h | 20 +- src/htstools.c | 198 +- src/htstools.h | 18 +- src/htsweb.c | 11 +- src/htswizard.c | 118 +- src/htswizard.h | 11 +- src/htswrap.h | 8 + src/htszlib.c | 3 +- src/httrack-library.h | 29 +- src/httrack.c | 10 + src/httrack.vcproj | 12 +- src/md5.c | 29 +- src/md5.h | 5 +- src/minizip/ChangeLogUnzip | 55 - src/minizip/MiniZip64_Changes.txt | 6 + src/minizip/MiniZip64_info.txt | 74 + src/minizip/crypt.h | 27 +- src/minizip/ioapi.c | 262 +- src/minizip/ioapi.c.diff | 48 + src/minizip/ioapi.c.orig | 177 -- src/minizip/ioapi.h | 199 +- src/minizip/ioapi.h.diff | 34 + src/minizip/ioapi.h.orig | 75 - src/minizip/iowin32.c | 392 ++- src/minizip/iowin32.h | 15 +- src/minizip/mztools.c | 574 ++-- src/minizip/mztools.h | 14 +- src/minizip/unzip.c | 1364 ++++++--- src/minizip/unzip.c.orig | 1585 ---------- src/minizip/unzip.h | 133 +- src/minizip/unzip.h.orig | 352 --- src/minizip/zip.c | 1899 ++++++++---- src/minizip/zip.c.diff | 85 + src/minizip/zip.c.orig | 1180 -------- src/minizip/zip.h | 185 +- src/minizip/zip.h.diff | 26 + src/minizip/zip.h.orig | 235 -- src/proxy/main.c | 1 + src/proxy/proxytrack.c | 58 +- src/proxy/proxytrack.h | 6 +- src/proxy/store.c | 2 +- templates/Makefile.in | 9 +- templates/topindex-header.html | 2 +- tests/11_crawl-idna.test | 6 + tests/Makefile.in | 9 +- 110 files changed, 8327 insertions(+), 12380 deletions(-) create mode 100644 src/htsarrays.h delete mode 100755 src/minizip/ChangeLogUnzip create mode 100644 src/minizip/MiniZip64_Changes.txt create mode 100644 src/minizip/MiniZip64_info.txt create mode 100644 src/minizip/ioapi.c.diff delete mode 100644 src/minizip/ioapi.c.orig create mode 100644 src/minizip/ioapi.h.diff delete mode 100644 src/minizip/ioapi.h.orig delete mode 100644 src/minizip/unzip.c.orig delete mode 100644 src/minizip/unzip.h.orig create mode 100644 src/minizip/zip.c.diff delete mode 100644 src/minizip/zip.c.orig create mode 100644 src/minizip/zip.h.diff delete mode 100644 src/minizip/zip.h.orig diff --git a/Makefile.in b/Makefile.in index cc6fa50..64b0789 100644 --- a/Makefile.in +++ b/Makefile.in @@ -134,6 +134,7 @@ am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -142,14 +143,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -163,6 +162,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -218,7 +218,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/compile b/compile index 1b1d232..862a14e 100755 --- a/compile +++ b/compile @@ -1,9 +1,10 @@ #! /bin/sh -# Wrapper for compilers which do not understand `-c -o'. +# Wrapper for compilers which do not understand '-c -o'. -scriptversion=2005-05-14.22 +scriptversion=2012-03-05.13; # UTC -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free +# Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -17,8 +18,7 @@ scriptversion=2005-05-14.22 # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -29,21 +29,219 @@ scriptversion=2005-05-14.22 # bugs to or send patches to # . +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + case $1 in '') - echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] -Wrapper for compilers which do not understand `-c -o'. -Remove `-o dest.o' from ARGS, run PROGRAM with the remaining +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the -right script to run: please start by reading the file `INSTALL'. +right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF @@ -53,11 +251,13 @@ EOF echo "compile $scriptversion" exit $? ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; esac ofile= cfile= -eat= for arg do @@ -66,8 +266,8 @@ do else case $1 in -o) - # configure might choose to run compile as `compile cc -o foo foo.c'. - # So we strip `-o arg' only if arg is an object. + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) @@ -94,22 +294,22 @@ do done if test -z "$ofile" || test -z "$cfile"; then - # If no `-o' option was seen then we might have been invoked from a + # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no - # `.c' file was seen then we are probably linking. That is also + # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. -# Note: use `[/.-]' here to ensure that we don't use the same name +# Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. -lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break @@ -124,9 +324,9 @@ trap "rmdir '$lockdir'; exit 1" 1 2 15 ret=$? if test -f "$cofile"; then - mv "$cofile" "$ofile" + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then - mv "${cofile}bj" "$ofile" + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" @@ -138,5 +338,6 @@ exit $ret # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" # End: diff --git a/config.h.in b/config.h.in index 246c8e9..c146b78 100644 --- a/config.h.in +++ b/config.h.in @@ -42,6 +42,10 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 or 0, depending whether the compiler supports simple visibility + declarations. */ +#undef HAVE_VISIBILITY + /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF @@ -67,6 +71,9 @@ */ #undef LT_OBJDIR +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + /* Name of package */ #undef PACKAGE @@ -108,3 +115,9 @@ /* Version number of package */ #undef VERSION + +/* in_port_t */ +#undef in_port_t + +/* sa_family_t */ +#undef sa_family_t diff --git a/configure b/configure index 292b2ef..dad4cf1 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for httrack 3.48.6. +# Generated by GNU Autoconf 2.69 for httrack 3.48.13. # # Report bugs to . # @@ -10,6 +10,32 @@ # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. +# +# +# HTTrack Website Copier, Offline Browser for Windows and Unix +# Copyright (C) 1998-2014 Xavier Roche and other contributors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Important notes: +# +# - We hereby ask people using this source NOT to use it in purpose of grabbing +# emails addresses, or collecting any other private information on persons. +# This would disgrace our work, and spoil the many hours we spent on it. +# +# Please visit our Website: http://www.httrack.com +# ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## @@ -590,8 +616,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='httrack' PACKAGE_TARNAME='httrack' -PACKAGE_VERSION='3.48.6' -PACKAGE_STRING='httrack 3.48.6' +PACKAGE_VERSION='3.48.13' +PACKAGE_STRING='httrack 3.48.13' PACKAGE_BUGREPORT='roche+packaging@httrack.com' PACKAGE_URL='http://www.httrack.com/' @@ -646,11 +672,14 @@ LFS_FLAG V6_FLAG OPENSSL_LIBS HTTPS_SUPPORT -VERSION_INFO +AM_CFLAGS +HAVE_VISIBILITY +CFLAG_VISIBILITY +DEFAULT_LDFLAGS DEFAULT_CFLAGS +VERSION_INFO LT_CV_OBJDIR SHLIBPATH_VAR -CXXCPP OTOOL64 OTOOL LIPO @@ -681,12 +710,6 @@ LIBTOOL EGREP GREP CPP -am__fastdepCXX_FALSE -am__fastdepCXX_TRUE -CXXDEPMODE -ac_ct_CXX -CXXFLAGS -CXX am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE @@ -792,11 +815,7 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CXX -CXXFLAGS -CCC -CPP -CXXCPP' +CPP' # Initialize some variables set by options. @@ -1337,7 +1356,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures httrack 3.48.6 to adapt to many kinds of systems. +\`configure' configures httrack 3.48.13 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1407,7 +1426,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of httrack 3.48.6:";; + short | recursive ) echo "Configuration of httrack 3.48.13:";; esac cat <<\_ACEOF @@ -1449,10 +1468,7 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory - CXX C++ compiler command - CXXFLAGS C++ compiler flags CPP C preprocessor - CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1521,12 +1537,38 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -httrack configure 3.48.6 +httrack configure 3.48.13 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. + + +HTTrack Website Copier, Offline Browser for Windows and Unix +Copyright (C) 1998-2014 Xavier Roche and other contributors + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Important notes: + +- We hereby ask people using this source NOT to use it in purpose of grabbing +emails addresses, or collecting any other private information on persons. +This would disgrace our work, and spoil the many hours we spent on it. + +Please visit our Website: http://www.httrack.com + _ACEOF exit fi @@ -1573,44 +1615,6 @@ fi } # ac_fn_c_try_compile -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_compile - # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -1834,89 +1838,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_func -# ac_fn_cxx_try_cpp LINENO -# ------------------------ -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_cpp - -# ac_fn_cxx_try_link LINENO -# ------------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_link - # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes @@ -2248,7 +2169,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by httrack $as_me 3.48.6, which was +It was created by httrack $as_me 3.48.13, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2598,6 +2519,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ac_config_headers="$ac_config_headers config.h" am__api_version='1.11' @@ -3067,7 +2990,7 @@ fi # Define the identity of the package. PACKAGE='httrack' - VERSION='3.48.6' + VERSION='3.48.13' cat >>confdefs.h <<_ACEOF @@ -3132,8 +3055,6 @@ fi - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4114,145 +4035,16 @@ else fi -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : - $as_echo_n "(cached) " >&6 +if test "x$CC" != xcc; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 +$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 +$as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : +set dummy $CC; ac_cc=`$as_echo "$2" | + sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` +if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4261,241 +4053,111 @@ else int main () { -#ifndef __GNUC__ - choke me -#endif ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -depcc="$CXX" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CXX_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue +# Make sure it works both with $CC and with simple cc. +# We do the test twice because some compilers refuse to overwrite an +# existing .o file with -o, though they will create one. +ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' +rm -f conftest2.* +if { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && + test -f conftest2.$ac_objext && { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; +then + eval ac_cv_prog_cc_${ac_cc}_c_o=yes + if test "x$CC" != xcc; then + # Test first that cc exists at all. + if { ac_try='cc -c conftest.$ac_ext >&5' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' + rm -f conftest2.* + if { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && + test -f conftest2.$ac_objext && { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; + then + # cc works too. + : else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break + # cc exists but doesn't like -o. + eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi - done - - cd .. - rm -rf conftest.dir + fi else - am_cv_CXX_dependencies_compiler_type=none + eval ac_cv_prog_cc_${ac_cc}_c_o=no fi +rm -f core conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' +if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h + +fi + +# FIXME: we rely on the cache variable name because +# there is no other way. +set dummy $CC +am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` +eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o +if test "$am_t" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" fi @@ -8080,17 +7742,6 @@ done -func_stripname_cnf () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname_cnf - - - - # Set options @@ -12079,3195 +11730,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -$as_echo_n "checking how to run the C++ preprocessor... " >&6; } -if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -$as_echo "$CXXCPP" >&6; } -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -else - _lt_caught_CXX_error=yes -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -archive_cmds_need_lc_CXX=no -allow_undefined_flag_CXX= -always_export_symbols_CXX=no -archive_expsym_cmds_CXX= -compiler_needs_object_CXX=no -export_dynamic_flag_spec_CXX= -hardcode_direct_CXX=no -hardcode_direct_absolute_CXX=no -hardcode_libdir_flag_spec_CXX= -hardcode_libdir_separator_CXX= -hardcode_minus_L_CXX=no -hardcode_shlibpath_var_CXX=unsupported -hardcode_automatic_CXX=no -inherit_rpath_CXX=no -module_cmds_CXX= -module_expsym_cmds_CXX= -link_all_deplibs_CXX=unknown -old_archive_cmds_CXX=$old_archive_cmds -reload_flag_CXX=$reload_flag -reload_cmds_CXX=$reload_cmds -no_undefined_flag_CXX= -whole_archive_flag_spec_CXX= -enable_shared_with_static_runtimes_CXX=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -objext_CXX=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - - - - - - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC - - - # save warnings/boilerplate of simple test code - ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* - - ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* - - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_CFLAGS=$CFLAGS - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - CFLAGS=$CXXFLAGS - compiler=$CC - compiler_CXX=$CC - for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` - - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' - else - lt_prog_compiler_no_builtin_flag_CXX= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$lt_cv_prog_gnu_ld - - - - - - - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - whole_archive_flag_spec_CXX= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - ld_shlibs_CXX=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aix[4-9]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - archive_cmds_CXX='' - hardcode_direct_CXX=yes - hardcode_direct_absolute_CXX=yes - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - file_list_spec_CXX='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[012]|aix4.[012].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - hardcode_direct_CXX=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L_CXX=yes - hardcode_libdir_flag_spec_CXX='-L$libdir' - hardcode_libdir_separator_CXX= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - export_dynamic_flag_spec_CXX='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - always_export_symbols_CXX=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - allow_undefined_flag_CXX='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath__CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath__CXX -fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - - archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag_CXX="-z nodefs" - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath__CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - - lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }' - lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - # Check for a 64-bit object if we didn't find anything. - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath__CXX -fi - - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - no_undefined_flag_CXX=' ${wl}-bernotok' - allow_undefined_flag_CXX=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec_CXX='$convenience' - fi - archive_cmds_need_lc_CXX=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - allow_undefined_flag_CXX=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - ld_shlibs_CXX=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - hardcode_libdir_flag_spec_CXX=' ' - allow_undefined_flag_CXX=unsupported - always_export_symbols_CXX=yes - file_list_spec_CXX='@' - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' - enable_shared_with_static_runtimes_CXX=yes - # Don't use ranlib - old_postinstall_cmds_CXX='chmod 644 $oldlib' - postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, - # as there is no search path for DLLs. - hardcode_libdir_flag_spec_CXX='-L$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' - allow_undefined_flag_CXX=unsupported - always_export_symbols_CXX=no - enable_shared_with_static_runtimes_CXX=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - ld_shlibs_CXX=no - fi - ;; - esac - ;; - darwin* | rhapsody*) - - - archive_cmds_need_lc_CXX=no - hardcode_direct_CXX=no - hardcode_automatic_CXX=yes - hardcode_shlibpath_var_CXX=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - - else - whole_archive_flag_spec_CXX='' - fi - link_all_deplibs_CXX=yes - allow_undefined_flag_CXX="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=func_echo_all - archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - if test "$lt_cv_apple_cc_single_mod" != "yes"; then - archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi - - else - ld_shlibs_CXX=no - fi - - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - freebsd2.*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - ld_shlibs_CXX=no - ;; - - freebsd-elf*) - archive_cmds_need_lc_CXX=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - ld_shlibs_CXX=yes - ;; - - haiku*) - archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - link_all_deplibs_CXX=yes - ;; - - hpux9*) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - export_dynamic_flag_spec_CXX='${wl}-E' - hardcode_direct_CXX=yes - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aCC*) - archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - export_dynamic_flag_spec_CXX='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - ;; - *) - hardcode_direct_CXX=yes - hardcode_direct_absolute_CXX=yes - hardcode_minus_L_CXX=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - - interix[3-9]*) - hardcode_direct_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' - fi - fi - link_all_deplibs_CXX=yes - ;; - esac - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - inherit_rpath_CXX=yes - ;; - - linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - archive_cmds_need_lc_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [1-5].* | *pgcpp\ [1-5].*) - prelink_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' - old_archive_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' - archive_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - archive_expsym_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 and above use weak symbols - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' - ;; - xl* | mpixl* | bgxl*) - # IBM XL 8.0 on PPC, with GNU ld - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - hardcode_libdir_flag_spec_CXX='-R$libdir' - whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object_CXX=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - ld_shlibs_CXX=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - ld_shlibs_CXX=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - hardcode_direct_CXX=yes - hardcode_shlibpath_var_CXX=no - hardcode_direct_absolute_CXX=yes - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - export_dynamic_flag_spec_CXX='${wl}-E' - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=func_echo_all - else - ld_shlibs_CXX=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - hardcode_libdir_separator_CXX=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - cxx*) - case $host in - osf3*) - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - ;; - *) - allow_undefined_flag_CXX=' -expect_unresolved \*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - hardcode_libdir_flag_spec_CXX='-rpath $libdir' - ;; - esac - - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - hardcode_libdir_separator_CXX=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - archive_cmds_need_lc_CXX=yes - no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - hardcode_libdir_flag_spec_CXX='-R$libdir' - hardcode_shlibpath_var_CXX=no - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' - ;; - esac - link_all_deplibs_CXX=yes - - output_verbose_link_cmd='func_echo_all' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - no_undefined_flag_CXX=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' - fi - - hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' - case $host_os in - solaris2.[0-5] | solaris2.[0-5].*) ;; - *) - whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag_CXX='${wl}-z,text' - archive_cmds_need_lc_CXX=no - hardcode_shlibpath_var_CXX=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - no_undefined_flag_CXX='${wl}-z,text' - allow_undefined_flag_CXX='${wl}-z,nodefs' - archive_cmds_need_lc_CXX=no - hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' - hardcode_libdir_separator_CXX=':' - link_all_deplibs_CXX=yes - export_dynamic_flag_spec_CXX='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ - '"$old_archive_cmds_CXX" - reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ - '"$reload_cmds_CXX" - ;; - *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - - *) - # FIXME: insert proper C++ library support - ld_shlibs_CXX=no - ;; - esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -$as_echo "$ld_shlibs_CXX" >&6; } - test "$ld_shlibs_CXX" = no && can_build_shared=no - - GCC_CXX="$GXX" - LD_CXX="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - # Dependencies to place before and after the object being linked: -predep_objects_CXX= -postdep_objects_CXX= -predeps_CXX= -postdeps_CXX= -compiler_lib_search_path_CXX= - -cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF - - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - -if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - fi - - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} in - -L | -R) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$compiler_lib_search_path_CXX"; then - compiler_lib_search_path_CXX="${prev}${p}" - else - compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$postdeps_CXX"; then - postdeps_CXX="${prev}${p}" - else - postdeps_CXX="${postdeps_CXX} ${prev}${p}" - fi - fi - prev= - ;; - - *.lto.$objext) ;; # Ignore GCC LTO objects - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$predep_objects_CXX"; then - predep_objects_CXX="$p" - else - predep_objects_CXX="$predep_objects_CXX $p" - fi - else - if test -z "$postdep_objects_CXX"; then - postdep_objects_CXX="$p" - else - postdep_objects_CXX="$postdep_objects_CXX $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling CXX test program" -fi - -$RM -f confest.$objext -CFLAGS=$_lt_libdeps_save_CFLAGS - -# PORTME: override above test on systems where it is broken -case $host_os in -interix[3-9]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - predep_objects_CXX= - postdep_objects_CXX= - postdeps_CXX= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - postdeps_CXX='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC* | sunCC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - postdeps_CXX='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac - - -case " $postdeps_CXX " in -*" -lc "*) archive_cmds_need_lc_CXX=no ;; -esac - compiler_lib_search_dirs_CXX= -if test -n "${compiler_lib_search_path_CXX}"; then - compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - lt_prog_compiler_wl_CXX= -lt_prog_compiler_pic_CXX= -lt_prog_compiler_static_CXX= - - - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - lt_prog_compiler_pic_CXX='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - lt_prog_compiler_pic_CXX='-DDLL_EXPORT' - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - lt_prog_compiler_pic_CXX='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - lt_prog_compiler_pic_CXX= - ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - lt_prog_compiler_static_CXX= - ;; - interix[3-9]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - lt_prog_compiler_pic_CXX=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic_CXX='-fPIC -shared' - ;; - *) - lt_prog_compiler_pic_CXX='-fPIC' - ;; - esac - else - case $host_os in - aix[4-9]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_prog_compiler_static_CXX='-Bstatic' - else - lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - lt_prog_compiler_pic_CXX='-DDLL_EXPORT' - ;; - dgux*) - case $cc_basename in - ec++*) - lt_prog_compiler_pic_CXX='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - lt_prog_compiler_pic_CXX='+Z' - fi - ;; - aCC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - lt_prog_compiler_pic_CXX='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - case $cc_basename in - KCC*) - # KAI C++ Compiler - lt_prog_compiler_wl_CXX='--backend -Wl,' - lt_prog_compiler_pic_CXX='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-fPIC' - lt_prog_compiler_static_CXX='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-fpic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-qpic' - lt_prog_compiler_static_CXX='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - lt_prog_compiler_wl_CXX='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - lt_prog_compiler_pic_CXX='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd* | netbsdelf*-gnu) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - lt_prog_compiler_pic_CXX='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - lt_prog_compiler_wl_CXX='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - lt_prog_compiler_pic_CXX='-pic' - ;; - cxx*) - # Digital/Compaq C++ - lt_prog_compiler_wl_CXX='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - lt_prog_compiler_pic_CXX= - lt_prog_compiler_static_CXX='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC* | sunCC*) - # Sun C++ 4.2, 5.x and Centerline C++ - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - lt_prog_compiler_wl_CXX='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - lt_prog_compiler_pic_CXX='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - lt_prog_compiler_pic_CXX='-pic' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - lcc*) - # Lucid - lt_prog_compiler_pic_CXX='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_pic_CXX='-KPIC' - lt_prog_compiler_static_CXX='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - lt_prog_compiler_pic_CXX='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - lt_prog_compiler_can_build_shared_CXX=no - ;; - esac - fi - -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - lt_prog_compiler_pic_CXX= - ;; - *) - lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" - ;; -esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } -lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$lt_prog_compiler_pic_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } -if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic_works_CXX=no - ac_outfile=conftest.$ac_objext - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_pic_works_CXX=yes - fi - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } - -if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then - case $lt_prog_compiler_pic_CXX in - "" | " "*) ;; - *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; - esac -else - lt_prog_compiler_pic_CXX= - lt_prog_compiler_can_build_shared_CXX=no -fi - -fi - - - - - -# -# Check to make sure the static flag actually works. -# -wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_static_works_CXX=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $lt_tmp_static_flag" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&5 - $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler_static_works_CXX=yes - fi - else - lt_cv_prog_compiler_static_works_CXX=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } - -if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then - : -else - lt_prog_compiler_static_CXX= -fi - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o_CXX=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_CXX=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_c_o_CXX=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - lt_cv_prog_compiler_c_o_CXX=yes - fi - fi - chmod u+w . 2>&5 - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } - - - - -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} - need_locks=warn - fi -else - need_locks=no -fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } - - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' - case $host_os in - aix[4-9]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - export_symbols_cmds_CXX="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - case $cc_basename in - cl*) - exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' - ;; - esac - ;; - linux* | k*bsd*-gnu | gnu*) - link_all_deplibs_CXX=no - ;; - *) - export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -$as_echo "$ld_shlibs_CXX" >&6; } -test "$ld_shlibs_CXX" = no && can_build_shared=no - -with_gnu_ld_CXX=$with_gnu_ld - - - - - - -# -# Do we need to explicitly link libc? -# -case "x$archive_cmds_need_lc_CXX" in -x|xyes) - # Assume -lc should be added - archive_cmds_need_lc_CXX=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $archive_cmds_CXX in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl_CXX - pic_flag=$lt_prog_compiler_pic_CXX - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag_CXX - allow_undefined_flag_CXX= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 - (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - then - lt_cv_archive_cmds_need_lc_CXX=no - else - lt_cv_archive_cmds_need_lc_CXX=yes - fi - allow_undefined_flag_CXX=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } - archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX - ;; - esac - fi - ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } - -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[4-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[01] | aix4.[01].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[45]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$cc_basename in - yes,*) - # gcc - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[23].*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2.*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ - freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555, ... - postinstall_cmds='chmod 555 $lib' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[3-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux # correct to gnu/linux during the next big refactor - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - - # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_shlibpath_overrides_runpath=no - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - lt_cv_shlibpath_overrides_runpath=yes -fi -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - -fi - - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsdelf*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } -hardcode_action_CXX= -if test -n "$hardcode_libdir_flag_spec_CXX" || - test -n "$runpath_var_CXX" || - test "X$hardcode_automatic_CXX" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$hardcode_direct_CXX" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && - test "$hardcode_minus_L_CXX" != no; then - # Linking always hardcodes the temporary library directory. - hardcode_action_CXX=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - hardcode_action_CXX=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - hardcode_action_CXX=unsupported -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 -$as_echo "$hardcode_action_CXX" >&6; } - -if test "$hardcode_action_CXX" = relink || - test "$inherit_rpath_CXX" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi - - - - - - - - fi # test -n "$compiler" - - CC=$lt_save_CC - CFLAGS=$lt_save_CFLAGS - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - @@ -15302,6 +11764,7 @@ $as_echo "no, using $LN_S" >&6; } fi + # Export LD_LIBRARY_PATH name or equivalent. SHLIBPATH_VAR=$shlibpath_var @@ -15310,12 +11773,391 @@ SHLIBPATH_VAR=$shlibpath_var LT_CV_OBJDIR=$lt_cv_objdir -### Default CFLAGS -DEFAULT_CFLAGS="-Wall -Wcast-align -Wstrict-prototypes \ --Wmissing-prototypes -Wmissing-declarations -Wpointer-arith \ --Wnested-externs -D_REENTRANT" +# Export version info +### Default CFLAGS +DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \ +-Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \ +-Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement \ +-Wpointer-arith -Wsequence-point -Wnested-externs \ +-D_REENTRANT" + +DEFAULT_LDFLAGS="" + + +### Additional flags (if supported) +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wparentheses" >&5 +$as_echo_n "checking whether C compiler accepts -Wparentheses... " >&6; } +if ${ax_cv_check_cflags___Wparentheses+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Wparentheses" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Wparentheses=yes +else + ax_cv_check_cflags___Wparentheses=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wparentheses" >&5 +$as_echo "$ax_cv_check_cflags___Wparentheses" >&6; } +if test x"$ax_cv_check_cflags___Wparentheses" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wparentheses" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Winit-self" >&5 +$as_echo_n "checking whether C compiler accepts -Winit-self... " >&6; } +if ${ax_cv_check_cflags___Winit_self+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Winit-self" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Winit_self=yes +else + ax_cv_check_cflags___Winit_self=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Winit_self" >&5 +$as_echo "$ax_cv_check_cflags___Winit_self" >&6; } +if test x"$ax_cv_check_cflags___Winit_self" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Winit-self" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wuninitialized" >&5 +$as_echo_n "checking whether C compiler accepts -Wuninitialized... " >&6; } +if ${ax_cv_check_cflags___Wuninitialized+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Wuninitialized" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Wuninitialized=yes +else + ax_cv_check_cflags___Wuninitialized=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wuninitialized" >&5 +$as_echo "$ax_cv_check_cflags___Wuninitialized" >&6; } +if test x"$ax_cv_check_cflags___Wuninitialized" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wuninitialized" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wformat=2" >&5 +$as_echo_n "checking whether C compiler accepts -Wformat=2... " >&6; } +if ${ax_cv_check_cflags___Wformat_2+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Wformat=2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Wformat_2=yes +else + ax_cv_check_cflags___Wformat_2=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wformat_2" >&5 +$as_echo "$ax_cv_check_cflags___Wformat_2" >&6; } +if test x"$ax_cv_check_cflags___Wformat_2" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat=2" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wformat-nonliteral" >&5 +$as_echo_n "checking whether C compiler accepts -Wformat-nonliteral... " >&6; } +if ${ax_cv_check_cflags___Wformat_nonliteral+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Wformat-nonliteral" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___Wformat_nonliteral=yes +else + ax_cv_check_cflags___Wformat_nonliteral=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wformat_nonliteral" >&5 +$as_echo "$ax_cv_check_cflags___Wformat_nonliteral" >&6; } +if test x"$ax_cv_check_cflags___Wformat_nonliteral" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat-nonliteral" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing=2" >&5 +$as_echo_n "checking whether C compiler accepts -fstrict-aliasing -Wstrict-aliasing=2... " >&6; } +if ${ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -fstrict-aliasing -Wstrict-aliasing=2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2=yes +else + ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2" >&5 +$as_echo "$ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2" >&6; } +if test x"$ax_cv_check_cflags___fstrict_aliasing__Wstrict_aliasing_2" = xyes; then : + DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing=2" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--discard-all" >&5 +$as_echo_n "checking whether the linker accepts -Wl,--discard-all... " >&6; } +if ${ax_cv_check_ldflags___Wl___discard_all+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--discard-all" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ax_cv_check_ldflags___Wl___discard_all=yes +else + ax_cv_check_ldflags___Wl___discard_all=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___discard_all" >&5 +$as_echo "$ax_cv_check_ldflags___Wl___discard_all" >&6; } +if test x"$ax_cv_check_ldflags___Wl___discard_all" = xyes; then : + DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--discard-all" +else + : +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker accepts -Wl,--no-undefined" >&5 +$as_echo_n "checking whether the linker accepts -Wl,--no-undefined... " >&6; } +if ${ax_cv_check_ldflags___Wl___no_undefined+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--no-undefined" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ax_cv_check_ldflags___Wl___no_undefined=yes +else + ax_cv_check_ldflags___Wl___no_undefined=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_ldflags___Wl___no_undefined" >&5 +$as_echo "$ax_cv_check_ldflags___Wl___no_undefined" >&6; } +if test x"$ax_cv_check_ldflags___Wl___no_undefined" = xyes; then : + DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--no-undefined" +else + : +fi + + +### Check for -fvisibility=hidden support + + + CFLAG_VISIBILITY= + HAVE_VISIBILITY=0 + if test -n "$GCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the -Werror option is usable" >&5 +$as_echo_n "checking whether the -Werror option is usable... " >&6; } + if ${gl_cv_cc_vis_werror+:} false; then : + $as_echo_n "(cached) " >&6 +else + + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_cc_vis_werror=yes +else + gl_cv_cc_vis_werror=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$gl_save_CFLAGS" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_vis_werror" >&5 +$as_echo "$gl_cv_cc_vis_werror" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5 +$as_echo_n "checking for simple visibility declarations... " >&6; } + if ${gl_cv_cc_visibility+:} false; then : + $as_echo_n "(cached) " >&6 +else + + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + if test $gl_cv_cc_vis_werror = yes; then + CFLAGS="$CFLAGS -Werror" + fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void) {} +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_cc_visibility=yes +else + gl_cv_cc_visibility=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$gl_save_CFLAGS" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5 +$as_echo "$gl_cv_cc_visibility" >&6; } + if test $gl_cv_cc_visibility = yes; then + CFLAG_VISIBILITY="-fvisibility=hidden" + HAVE_VISIBILITY=1 + fi + fi + + + +cat >>confdefs.h <<_ACEOF +#define HAVE_VISIBILITY $HAVE_VISIBILITY +_ACEOF + + +AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY" + ### Check for platform #case $host in @@ -15408,6 +12250,36 @@ $as_echo "$as_me: WARNING: *** in_addr_t not found" >&2;} fi +# check for in_port_ +ac_fn_c_check_type "$LINENO" "in_port_t" "ac_cv_type_in_port_t" " +#include +#include + +" +if test "x$ac_cv_type_in_port_t" = xyes; then : + +else + +$as_echo "#define in_port_t uint16_t" >>confdefs.h + +fi + + +# check for sa_family_t +ac_fn_c_check_type "$LINENO" "sa_family_t" "ac_cv_type_sa_family_t" " +#include +#include + +" +if test "x$ac_cv_type_sa_family_t" = xyes; then : + +else + +$as_echo "#define sa_family_t uint16_t" >>confdefs.h + +fi + + ### zlib # # Handle user hints @@ -16491,10 +13363,6 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -16892,7 +13760,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by httrack $as_me 3.48.6, which was +This file was extended by httrack $as_me 3.48.13, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16959,7 +13827,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -httrack config.status 3.48.6 +httrack config.status 3.48.13 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -17218,60 +14086,6 @@ enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_sub enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' -predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' -postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' -predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' -postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' -LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' -reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' -reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' -old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' -compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' -GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' -archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' -export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' -whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' -compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' -old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' -archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' -archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' -module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' -module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' -with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' -allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' -no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' -inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' -link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' -always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' -export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' -exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' -include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' -prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' -postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' -file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' -hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' -predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' -postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' -predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' -postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' -compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' @@ -17350,38 +14164,7 @@ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ -striplib \ -compiler_lib_search_dirs \ -predep_objects \ -postdep_objects \ -predeps \ -postdeps \ -compiler_lib_search_path \ -LD_CXX \ -reload_flag_CXX \ -compiler_CXX \ -lt_prog_compiler_no_builtin_flag_CXX \ -lt_prog_compiler_pic_CXX \ -lt_prog_compiler_wl_CXX \ -lt_prog_compiler_static_CXX \ -lt_cv_prog_compiler_c_o_CXX \ -export_dynamic_flag_spec_CXX \ -whole_archive_flag_spec_CXX \ -compiler_needs_object_CXX \ -with_gnu_ld_CXX \ -allow_undefined_flag_CXX \ -no_undefined_flag_CXX \ -hardcode_libdir_flag_spec_CXX \ -hardcode_libdir_separator_CXX \ -exclude_expsyms_CXX \ -include_expsyms_CXX \ -file_list_spec_CXX \ -compiler_lib_search_dirs_CXX \ -predep_objects_CXX \ -postdep_objects_CXX \ -predeps_CXX \ -postdeps_CXX \ -compiler_lib_search_path_CXX; do +striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" @@ -17411,18 +14194,7 @@ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec \ -reload_cmds_CXX \ -old_archive_cmds_CXX \ -old_archive_from_new_cmds_CXX \ -old_archive_from_expsyms_cmds_CXX \ -archive_cmds_CXX \ -archive_expsym_cmds_CXX \ -module_cmds_CXX \ -module_expsym_cmds_CXX \ -export_symbols_cmds_CXX \ -prelink_cmds_CXX \ -postlink_cmds_CXX; do +sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" @@ -17453,8 +14225,6 @@ fi - - _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 @@ -18215,7 +14985,7 @@ $as_echo X"$file" | # The names of the tagged configurations supported by this script. -available_tags="CXX " +available_tags="" # ### BEGIN LIBTOOL CONFIG @@ -18602,20 +15372,6 @@ file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action -# The directories searched by this compiler when creating a shared library. -compiler_lib_search_dirs=$lt_compiler_lib_search_dirs - -# Dependencies to place before and after the objects being linked to -# create a shared library. -predep_objects=$lt_predep_objects -postdep_objects=$lt_postdep_objects -predeps=$lt_predeps -postdeps=$lt_postdeps - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path - # ### END LIBTOOL CONFIG _LT_EOF @@ -18808,159 +15564,6 @@ fi (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" - - cat <<_LT_EOF >> "$ofile" - -# ### BEGIN LIBTOOL TAG CONFIG: CXX - -# The linker used to build libraries. -LD=$lt_LD_CXX - -# How to create reloadable object files. -reload_flag=$lt_reload_flag_CXX -reload_cmds=$lt_reload_cmds_CXX - -# Commands used to build an old-style archive. -old_archive_cmds=$lt_old_archive_cmds_CXX - -# A language specific compiler. -CC=$lt_compiler_CXX - -# Is the compiler the GNU compiler? -with_gcc=$GCC_CXX - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic_CXX - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl_CXX - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_lt_prog_compiler_static_CXX - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$archive_cmds_need_lc_CXX - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object=$lt_compiler_needs_object_CXX - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX - -# Commands used to build a shared archive. -archive_cmds=$lt_archive_cmds_CXX -archive_expsym_cmds=$lt_archive_expsym_cmds_CXX - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds=$lt_module_cmds_CXX -module_expsym_cmds=$lt_module_expsym_cmds_CXX - -# Whether we are building with GNU ld or not. -with_gnu_ld=$lt_with_gnu_ld_CXX - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_allow_undefined_flag_CXX - -# Flag that enforces no undefined symbols. -no_undefined_flag=$lt_no_undefined_flag_CXX - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist -hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=$hardcode_direct_CXX - -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes -# DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the -# library is relocated. -hardcode_direct_absolute=$hardcode_direct_absolute_CXX - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=$hardcode_minus_L_CXX - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX - -# Set to "yes" if building a shared library automatically hardcodes DIR -# into the library and all subsequent libraries and executables linked -# against it. -hardcode_automatic=$hardcode_automatic_CXX - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=$inherit_rpath_CXX - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$link_all_deplibs_CXX - -# Set to "yes" if exported symbols are required. -always_export_symbols=$always_export_symbols_CXX - -# The commands to list exported symbols. -export_symbols_cmds=$lt_export_symbols_cmds_CXX - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_exclude_expsyms_CXX - -# Symbols that must always be exported. -include_expsyms=$lt_include_expsyms_CXX - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds=$lt_prelink_cmds_CXX - -# Commands necessary for finishing linking programs. -postlink_cmds=$lt_postlink_cmds_CXX - -# Specify filename containing input files. -file_list_spec=$lt_file_list_spec_CXX - -# How to hardcode a shared library path into an executable. -hardcode_action=$hardcode_action_CXX - -# The directories searched by this compiler when creating a shared library. -compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX - -# Dependencies to place before and after the objects being linked to -# create a shared library. -predep_objects=$lt_predep_objects_CXX -postdep_objects=$lt_postdep_objects_CXX -predeps=$lt_predeps_CXX -postdeps=$lt_postdeps_CXX - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_compiler_lib_search_path_CXX - -# ### END LIBTOOL TAG CONFIG: CXX -_LT_EOF - ;; esac diff --git a/configure.ac b/configure.ac index d9a5807..cf28234 100644 --- a/configure.ac +++ b/configure.ac @@ -1,18 +1,45 @@ -AC_INIT([httrack], [3.48.6], [roche+packaging@httrack.com], [httrack], [http://www.httrack.com/]) +AC_PREREQ(2.59) + +AC_INIT([httrack], [3.48.13], [roche+packaging@httrack.com], [httrack], [http://www.httrack.com/]) +AC_COPYRIGHT([ +HTTrack Website Copier, Offline Browser for Windows and Unix +Copyright (C) 1998-2014 Xavier Roche and other contributors + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Important notes: + +- We hereby ask people using this source NOT to use it in purpose of grabbing +emails addresses, or collecting any other private information on persons. +This would disgrace our work, and spoil the many hours we spent on it. + +Please visit our Website: http://www.httrack.com +]) + AC_CONFIG_SRCDIR(src/httrack.c) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS(config.h) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([subdir-objects]) VERSION_INFO="2:48:0" AM_MAINTAINER_MODE -AC_PREREQ(2.50) - AC_PROG_CC -AC_PROG_CXX +AM_PROG_CC_C_O AC_STDC_HEADERS LT_INIT AC_PROG_LN_S +AM_PROG_LIBTOOL # Export LD_LIBRARY_PATH name or equivalent. AC_SUBST(SHLIBPATH_VAR,$shlibpath_var) @@ -20,13 +47,34 @@ AC_SUBST(SHLIBPATH_VAR,$shlibpath_var) # Export .libs or equivalent. AC_SUBST(LT_CV_OBJDIR,$lt_cv_objdir) -### Default CFLAGS -DEFAULT_CFLAGS="-Wall -Wcast-align -Wstrict-prototypes \ --Wmissing-prototypes -Wmissing-declarations -Wpointer-arith \ --Wnested-externs -D_REENTRANT" -AC_SUBST(DEFAULT_CFLAGS) +# Export version info AC_SUBST(VERSION_INFO) +### Default CFLAGS +DEFAULT_CFLAGS="-Wall -Wformat -Wformat-security \ +-Wmultichar -Wwrite-strings -Wcast-align -Wstrict-prototypes \ +-Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement \ +-Wpointer-arith -Wsequence-point -Wnested-externs \ +-D_REENTRANT" +AC_SUBST(DEFAULT_CFLAGS) +DEFAULT_LDFLAGS="" +AC_SUBST(DEFAULT_LDFLAGS) + +### Additional flags (if supported) +AX_CHECK_COMPILE_FLAG([-Wparentheses], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wparentheses"]) +AX_CHECK_COMPILE_FLAG([-Winit-self], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Winit-self"]) +AX_CHECK_COMPILE_FLAG([-Wuninitialized], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wuninitialized"]) +AX_CHECK_COMPILE_FLAG([-Wformat=2], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat=2"]) +AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -Wformat-nonliteral"]) +AX_CHECK_COMPILE_FLAG([-fstrict-aliasing -Wstrict-aliasing=2], [DEFAULT_CFLAGS="$DEFAULT_CFLAGS -fstrict-aliasing -Wstrict-aliasing=2"]) +AX_CHECK_LINK_FLAG([-Wl,--discard-all], [DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--discard-all"]) +AX_CHECK_LINK_FLAG([-Wl,--no-undefined], [DEFAULT_LDLAGS="$DEFAULT_LDLAGS -Wl,--no-undefined"]) + +### Check for -fvisibility=hidden support +gl_VISIBILITY +AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY" +AC_SUBST([AM_CFLAGS]) + ### Check for platform #case $host in #AIX) AC_DEFINE(HTS_PLATFORM, 1, [Defined to build under AIX]);; @@ -47,6 +95,18 @@ AC_MSG_WARN([*** in_addr_t not found]), #include #include ]) +# check for in_port_ +AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [ +#include +#include +]) + +# check for sa_family_t +AC_CHECK_TYPE(sa_family_t, [], [AC_DEFINE([sa_family_t], [uint16_t], [sa_family_t])], [ +#include +#include +]) + ### zlib CHECK_ZLIB() diff --git a/debian/changelog b/debian/changelog index dd4b63c..74f5641 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,47 @@ +httrack (3.48.13-1) unstable; urgency=low + + * Updated to 3.48.13 (3.48-13) + closes:#750931 + + -- Xavier Roche Sun, 08 Jun 2014 16:22:13 +0200 + +httrack (3.48.12-1) unstable; urgency=low + + * Updated to 3.48.12 (3.48-12) + Should fix missing/broken .h for libhttrack-dev + + -- Xavier Roche Sun, 08 Jun 2014 13:19:49 +0200 + +httrack (3.48.11-1) unstable; urgency=low + + * Updated to 3.48.11 (3.48-11) + + -- Xavier Roche Fri, 06 Jun 2014 17:58:12 +0200 + +httrack (3.48.10-1) unstable; urgency=low + + * Updated to 3.48.10 (3.48-10) + + -- Xavier Roche Wed, 04 Jun 2014 19:00:07 +0200 + +httrack (3.48.9-1) unstable; urgency=low + + * Updated to 3.48.9 (3.48-9) + + -- Xavier Roche Wed, 21 May 2014 19:22:04 +0200 + +httrack (3.48.8-1) unstable; urgency=low + + * Updated to 3.48.8 (3.48-8) + + -- Xavier Roche Thu, 15 May 2014 19:21:21 +0200 + +httrack (3.48.7-1) unstable; urgency=low + + * Updated to 3.48.7 (3.48-7) + + -- Xavier Roche Wed, 14 May 2014 19:51:57 +0200 + httrack (3.48.6-1) unstable; urgency=low * Updated to 3.48.6 (3.48-6) diff --git a/debian/control b/debian/control index cec8f58..5464bee 100644 --- a/debian/control +++ b/debian/control @@ -3,8 +3,10 @@ Section: web Priority: optional Maintainer: Xavier Roche Standards-Version: 3.9.5 -Build-Depends: debhelper (>= 8.0.0), dh-autoreconf, autotools-dev, autoconf, automake, libtool, zlib1g-dev, libssl-dev +Build-Depends: debhelper (>= 8.0.0), dh-autoreconf, autotools-dev, autoconf, autoconf-archive, automake, libtool, zlib1g-dev, libssl-dev Homepage: http://www.httrack.com +Vcs-Svn: http://httrack.googlecode.com/svn/trunk +Vcs-Browser: https://code.google.com/p/httrack/source/browse/trunk/src Package: httrack Architecture: any diff --git a/history.txt b/history.txt index 005a3bd..5588130 100644 --- a/history.txt +++ b/history.txt @@ -4,8 +4,21 @@ HTTrack Website Copier release history: This file lists all changes and fixes that have been made for HTTrack. -3.48-6 -+ Fixed: mitigate the "hashtable internal error: cuckoo/stash collision" errors +3.48-12 ++ Fixed: --advanced-maxlinks broken (Localhost) ++ Fixed: -devel package should now be standalone ++ Fixed: assertion failure at htscore.c:244 (len + liensbuf->string_buffer_size < liensbuf->string_buffer_capa) ++ Fixed: injection-proof templates ++ Fixed: htshash.c:330 assertion failure ("error invalidating hash entry") (Sergey) ++ Fixed: Windows 2000 regression (fantozzi.usenet) ++ Fixed: code cleanup (aliasing issues, const correctness, safe strings) ++ New: handle --advanced-maxlinks=0 to disable maximum link limits ++ New: updated ZIP routines (zlib 1.2.8) ++ Fixed: broken 32-bit version ++ Fixed: assertion "segOutputSize < segSize assertion fails at htscharset.c:993" ++ Fixed: new zlib version fixing CVE-2004-0797 and CVE-2005-2096 ++ Fixed: more reliable crash reporting ++ Fixed: fixed infamous "hashtable internal error: cuckoo/stash collision" errors + Fixed: safety cleanup in many strings operations + Fixed: buggy option pannels + New: Enforce check against CVE-2014-0160 diff --git a/html/Makefile.in b/html/Makefile.in index 5a28392..5b8baf9 100644 --- a/html/Makefile.in +++ b/html/Makefile.in @@ -115,6 +115,7 @@ DATA = $(HelpHtml_DATA) $(HelpHtmlTxt_DATA) $(HelpHtmldiv_DATA) \ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -123,14 +124,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -144,6 +143,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -199,7 +199,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/html/httrack.man.html b/html/httrack.man.html index 4705d42..216e1b5 100644 --- a/html/httrack.man.html +++ b/html/httrack.man.html @@ -1032,8 +1032,8 @@ HTTP headers (−F "user−agent name") -

accepted formats (−%l -"text/html,image/png,image/jpeg,image/gif;q=0.9,*/*;q=0.1" +

accepted formats (−%a +"text/html,image/png;q=0.9,*/*;q=0.1" (−−accept <param>)

diff --git a/lang/Makefile.in b/lang/Makefile.in index 52df9f4..c273388 100644 --- a/lang/Makefile.in +++ b/lang/Makefile.in @@ -104,6 +104,7 @@ DATA = $(lang_DATA) $(langroot_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -112,14 +113,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -133,6 +132,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -188,7 +188,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/libtest/Makefile.am b/libtest/Makefile.am index 4be2158..8e52eaa 100644 --- a/libtest/Makefile.am +++ b/libtest/Makefile.am @@ -3,7 +3,7 @@ exemplesdir = $(datadir)/httrack/libtest exemples_DATA = *.c *.h *.txt EXTRA_DIST = $(exemples_DATA) -INCLUDES = \ +AM_CPPFLAGS = \ @DEFAULT_CFLAGS@ \ @THREADS_CFLAGS@ \ @V6_FLAG@ \ @@ -13,7 +13,7 @@ INCLUDES = \ -DDATADIR=\""$(datadir)"\" \ -DLIBDIR=\""$(libdir)"\" -AM_CPPFLAGS = -I../src +AM_CPPFLAGS += -I../src AM_LDFLAGS = -L../src # Examples diff --git a/libtest/Makefile.in b/libtest/Makefile.in index a1b8338..7b4cf80 100644 --- a/libtest/Makefile.in +++ b/libtest/Makefile.in @@ -201,6 +201,7 @@ CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -209,14 +210,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -230,6 +229,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -285,7 +285,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -335,17 +334,9 @@ top_srcdir = @top_srcdir@ exemplesdir = $(datadir)/httrack/libtest exemples_DATA = *.c *.h *.txt EXTRA_DIST = $(exemples_DATA) -INCLUDES = \ - @DEFAULT_CFLAGS@ \ - @THREADS_CFLAGS@ \ - @V6_FLAG@ \ - @LFS_FLAG@ \ - -DPREFIX=\""$(prefix)"\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DLIBDIR=\""$(libdir)"\" - -AM_CPPFLAGS = -I../src +AM_CPPFLAGS = @DEFAULT_CFLAGS@ @THREADS_CFLAGS@ @V6_FLAG@ @LFS_FLAG@ \ + -DPREFIX=\""$(prefix)"\" -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DDATADIR=\""$(datadir)"\" -DLIBDIR=\""$(libdir)"\" -I../src AM_LDFLAGS = -L../src # Examples @@ -485,22 +476,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/callbacks-example-simple.Plo@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $< .c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< diff --git a/m4/Makefile.in b/m4/Makefile.in index cbacb0e..14ccbd2 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -74,6 +74,7 @@ am__can_run_installinfo = \ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -82,14 +83,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -103,6 +102,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -158,7 +158,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/man/Makefile.in b/man/Makefile.in index 69b6f44..948863b 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -105,6 +105,7 @@ MANS = $(man_MANS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -113,14 +114,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -134,6 +133,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -189,7 +189,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/man/httrack.1 b/man/httrack.1 index 8580f13..66fcad1 100644 --- a/man/httrack.1 +++ b/man/httrack.1 @@ -1,7 +1,7 @@ .\" Process this file with .\" groff -man -Tascii httrack.1 .\" -.TH httrack 1 "12 May 2014" "httrack website copier" +.TH httrack 1 "08 June 2014" "httrack website copier" .SH NAME httrack \- offline browser : copy websites to a local directory .SH SYNOPSIS @@ -347,7 +347,7 @@ footer string in Html code (\-%F "Mirrored [from host %s [file %s [at %s]]]" (\- .IP \-%l preffered language (\-%l "fr, en, jp, *" (\-\-language ) .IP \-%a -accepted formats (\-%l "text/html,image/png,image/jpeg,image/gif;q=0.9,*/*;q=0.1" (\-\-accept ) +accepted formats (\-%a "text/html,image/png;q=0.9,*/*;q=0.1" (\-\-accept ) .IP \-%X additional HTTP header line (\-%X "X\-Magic: 42" (\-\-headers ) diff --git a/src/Makefile.am b/src/Makefile.am index 1d585a1..e2dd799 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,10 +8,14 @@ DevIncludes_DATA = \ ../config.h \ htsmodules.h \ htsbasenet.h \ + htsnet.h \ htsbauth.h \ - htsdefines.h + htsdefines.h \ + htsstrings.h \ + htsarrays.h \ + htssafe.h -INCLUDES = \ +AM_CPPFLAGS = \ @DEFAULT_CFLAGS@ \ @THREADS_CFLAGS@ \ @V6_FLAG@ \ @@ -56,7 +60,8 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \ htsmodules.h htsname.h htsnet.h \ htsopt.h htsrobots.h htsthread.h \ htstools.h htswizard.h htswrap.h htszlib.h \ - htsstrings.h httrack-library.h htscharset.h punycode.h htsencoding.h \ + htsstrings.h htsarrays.h httrack-library.h \ + htscharset.h punycode.h htsencoding.h \ htsentities.h htsentities.sh htsbasiccharsets.sh htscodepages.h \ md5.h murmurhash3.h \ minizip/crypt.h minizip/ioapi.h minizip/mztools.h minizip/unzip.h minizip/zip.h @@ -69,9 +74,14 @@ libhtsjava_la_LIBADD = $(THREADS_LIBS) $(DL_LIBS) libhttrack.la libhtsjava_la_LDFLAGS = -version-info $(VERSION_INFO) EXTRA_DIST = httrack.h webhttrack \ - minizip/ChangeLogUnzip \ minizip/iowin32.c \ minizip/iowin32.h \ + minizip/ioapi.c.diff \ + minizip/ioapi.h.diff \ + minizip/zip.c.diff \ + minizip/zip.h.diff \ + minizip/MiniZip64_Changes.txt \ + minizip/MiniZip64_info.txt \ proxy/AUTHORS \ proxy/COPYING \ proxy/changelog.txt \ diff --git a/src/Makefile.in b/src/Makefile.in index ab200b7..9cd00c0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -110,6 +110,7 @@ libhtsjava_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ libhttrack_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am__dirstamp = $(am__leading_dot)dirstamp am_libhttrack_la_OBJECTS = libhttrack_la-htscore.lo \ libhttrack_la-htsparse.lo libhttrack_la-htsback.lo \ libhttrack_la-htscache.lo libhttrack_la-htscatchurl.lo \ @@ -125,8 +126,9 @@ am_libhttrack_la_OBJECTS = libhttrack_la-htscore.lo \ libhttrack_la-htsconcat.lo libhttrack_la-htsmodules.lo \ libhttrack_la-htscharset.lo libhttrack_la-punycode.lo \ libhttrack_la-htsencoding.lo libhttrack_la-md5.lo \ - libhttrack_la-ioapi.lo libhttrack_la-mztools.lo \ - libhttrack_la-unzip.lo libhttrack_la-zip.lo + minizip/libhttrack_la-ioapi.lo \ + minizip/libhttrack_la-mztools.lo \ + minizip/libhttrack_la-unzip.lo minizip/libhttrack_la-zip.lo libhttrack_la_OBJECTS = $(am_libhttrack_la_OBJECTS) libhttrack_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libhttrack_la_CFLAGS) \ @@ -139,12 +141,14 @@ htsserver_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ httrack_SOURCES = httrack.c httrack_OBJECTS = httrack.$(OBJEXT) httrack_DEPENDENCIES = $(am__DEPENDENCIES_1) libhttrack.la -am_proxytrack_OBJECTS = proxytrack-main.$(OBJEXT) \ - proxytrack-proxytrack.$(OBJEXT) proxytrack-store.$(OBJEXT) \ +am_proxytrack_OBJECTS = proxy/proxytrack-main.$(OBJEXT) \ + proxy/proxytrack-proxytrack.$(OBJEXT) \ + proxy/proxytrack-store.$(OBJEXT) \ proxytrack-htsinthash.$(OBJEXT) proxytrack-htsmd5.$(OBJEXT) \ - proxytrack-md5.$(OBJEXT) proxytrack-ioapi.$(OBJEXT) \ - proxytrack-mztools.$(OBJEXT) proxytrack-unzip.$(OBJEXT) \ - proxytrack-zip.$(OBJEXT) + proxytrack-md5.$(OBJEXT) minizip/proxytrack-ioapi.$(OBJEXT) \ + minizip/proxytrack-mztools.$(OBJEXT) \ + minizip/proxytrack-unzip.$(OBJEXT) \ + minizip/proxytrack-zip.$(OBJEXT) proxytrack_OBJECTS = $(am_proxytrack_OBJECTS) proxytrack_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) proxytrack_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -179,6 +183,7 @@ CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -187,14 +192,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -208,6 +211,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -263,7 +267,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ @@ -320,10 +323,14 @@ DevIncludes_DATA = \ ../config.h \ htsmodules.h \ htsbasenet.h \ + htsnet.h \ htsbauth.h \ - htsdefines.h + htsdefines.h \ + htsstrings.h \ + htsarrays.h \ + htssafe.h -INCLUDES = \ +AM_CPPFLAGS = \ @DEFAULT_CFLAGS@ \ @THREADS_CFLAGS@ \ @V6_FLAG@ \ @@ -363,7 +370,8 @@ libhttrack_la_SOURCES = htscore.c htsparse.c htsback.c htscache.c \ htsmodules.h htsname.h htsnet.h \ htsopt.h htsrobots.h htsthread.h \ htstools.h htswizard.h htswrap.h htszlib.h \ - htsstrings.h httrack-library.h htscharset.h punycode.h htsencoding.h \ + htsstrings.h htsarrays.h httrack-library.h \ + htscharset.h punycode.h htsencoding.h \ htsentities.h htsentities.sh htsbasiccharsets.sh htscodepages.h \ md5.h murmurhash3.h \ minizip/crypt.h minizip/ioapi.h minizip/mztools.h minizip/unzip.h minizip/zip.h @@ -375,9 +383,14 @@ libhtsjava_la_SOURCES = htsjava.c htsjava.h libhtsjava_la_LIBADD = $(THREADS_LIBS) $(DL_LIBS) libhttrack.la libhtsjava_la_LDFLAGS = -version-info $(VERSION_INFO) EXTRA_DIST = httrack.h webhttrack \ - minizip/ChangeLogUnzip \ minizip/iowin32.c \ minizip/iowin32.h \ + minizip/ioapi.c.diff \ + minizip/ioapi.h.diff \ + minizip/zip.c.diff \ + minizip/zip.h.diff \ + minizip/MiniZip64_Changes.txt \ + minizip/MiniZip64_info.txt \ proxy/AUTHORS \ proxy/COPYING \ proxy/changelog.txt \ @@ -454,6 +467,20 @@ clean-libLTLIBRARIES: done libhtsjava.la: $(libhtsjava_la_OBJECTS) $(libhtsjava_la_DEPENDENCIES) $(EXTRA_libhtsjava_la_DEPENDENCIES) $(libhtsjava_la_LINK) -rpath $(libdir) $(libhtsjava_la_OBJECTS) $(libhtsjava_la_LIBADD) $(LIBS) +minizip/$(am__dirstamp): + @$(MKDIR_P) minizip + @: > minizip/$(am__dirstamp) +minizip/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) minizip/$(DEPDIR) + @: > minizip/$(DEPDIR)/$(am__dirstamp) +minizip/libhttrack_la-ioapi.lo: minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) +minizip/libhttrack_la-mztools.lo: minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) +minizip/libhttrack_la-unzip.lo: minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) +minizip/libhttrack_la-zip.lo: minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) libhttrack.la: $(libhttrack_la_OBJECTS) $(libhttrack_la_DEPENDENCIES) $(EXTRA_libhttrack_la_DEPENDENCIES) $(libhttrack_la_LINK) -rpath $(libdir) $(libhttrack_la_OBJECTS) $(libhttrack_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @@ -508,6 +535,26 @@ htsserver$(EXEEXT): $(htsserver_OBJECTS) $(htsserver_DEPENDENCIES) $(EXTRA_htsse httrack$(EXEEXT): $(httrack_OBJECTS) $(httrack_DEPENDENCIES) $(EXTRA_httrack_DEPENDENCIES) @rm -f httrack$(EXEEXT) $(LINK) $(httrack_OBJECTS) $(httrack_LDADD) $(LIBS) +proxy/$(am__dirstamp): + @$(MKDIR_P) proxy + @: > proxy/$(am__dirstamp) +proxy/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) proxy/$(DEPDIR) + @: > proxy/$(DEPDIR)/$(am__dirstamp) +proxy/proxytrack-main.$(OBJEXT): proxy/$(am__dirstamp) \ + proxy/$(DEPDIR)/$(am__dirstamp) +proxy/proxytrack-proxytrack.$(OBJEXT): proxy/$(am__dirstamp) \ + proxy/$(DEPDIR)/$(am__dirstamp) +proxy/proxytrack-store.$(OBJEXT): proxy/$(am__dirstamp) \ + proxy/$(DEPDIR)/$(am__dirstamp) +minizip/proxytrack-ioapi.$(OBJEXT): minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) +minizip/proxytrack-mztools.$(OBJEXT): minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) +minizip/proxytrack-unzip.$(OBJEXT): minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) +minizip/proxytrack-zip.$(OBJEXT): minizip/$(am__dirstamp) \ + minizip/$(DEPDIR)/$(am__dirstamp) proxytrack$(EXEEXT): $(proxytrack_OBJECTS) $(proxytrack_DEPENDENCIES) $(EXTRA_proxytrack_DEPENDENCIES) @rm -f proxytrack$(EXEEXT) $(proxytrack_LINK) $(proxytrack_OBJECTS) $(proxytrack_LDADD) $(LIBS) @@ -549,6 +596,21 @@ uninstall-whttrackrunSCRIPTS: mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f minizip/libhttrack_la-ioapi.$(OBJEXT) + -rm -f minizip/libhttrack_la-ioapi.lo + -rm -f minizip/libhttrack_la-mztools.$(OBJEXT) + -rm -f minizip/libhttrack_la-mztools.lo + -rm -f minizip/libhttrack_la-unzip.$(OBJEXT) + -rm -f minizip/libhttrack_la-unzip.lo + -rm -f minizip/libhttrack_la-zip.$(OBJEXT) + -rm -f minizip/libhttrack_la-zip.lo + -rm -f minizip/proxytrack-ioapi.$(OBJEXT) + -rm -f minizip/proxytrack-mztools.$(OBJEXT) + -rm -f minizip/proxytrack-unzip.$(OBJEXT) + -rm -f minizip/proxytrack-zip.$(OBJEXT) + -rm -f proxy/proxytrack-main.$(OBJEXT) + -rm -f proxy/proxytrack-proxytrack.$(OBJEXT) + -rm -f proxy/proxytrack-store.$(OBJEXT) distclean-compile: -rm -f *.tab.c @@ -584,40 +646,43 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htswizard.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htswrap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-htszlib.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-ioapi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-md5.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-mztools.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-punycode.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-unzip.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhttrack_la-zip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-htsinthash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-htsmd5.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-ioapi.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-md5.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-mztools.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-proxytrack.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-store.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-unzip.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxytrack-zip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/libhttrack_la-ioapi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/libhttrack_la-mztools.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/libhttrack_la-unzip.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/libhttrack_la-zip.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/proxytrack-ioapi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/proxytrack-mztools.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/proxytrack-unzip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@minizip/$(DEPDIR)/proxytrack-zip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@proxy/$(DEPDIR)/proxytrack-main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@proxy/$(DEPDIR)/proxytrack-proxytrack.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@proxy/$(DEPDIR)/proxytrack-store.Po@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $< .c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< @@ -825,75 +890,75 @@ libhttrack_la-md5.lo: md5.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c -libhttrack_la-ioapi.lo: minizip/ioapi.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-ioapi.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-ioapi.Tpo -c -o libhttrack_la-ioapi.lo `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libhttrack_la-ioapi.Tpo $(DEPDIR)/libhttrack_la-ioapi.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/ioapi.c' object='libhttrack_la-ioapi.lo' libtool=yes @AMDEPBACKSLASH@ +minizip/libhttrack_la-ioapi.lo: minizip/ioapi.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT minizip/libhttrack_la-ioapi.lo -MD -MP -MF minizip/$(DEPDIR)/libhttrack_la-ioapi.Tpo -c -o minizip/libhttrack_la-ioapi.lo `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/libhttrack_la-ioapi.Tpo minizip/$(DEPDIR)/libhttrack_la-ioapi.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/ioapi.c' object='minizip/libhttrack_la-ioapi.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-ioapi.lo `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o minizip/libhttrack_la-ioapi.lo `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c -libhttrack_la-mztools.lo: minizip/mztools.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-mztools.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-mztools.Tpo -c -o libhttrack_la-mztools.lo `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libhttrack_la-mztools.Tpo $(DEPDIR)/libhttrack_la-mztools.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/mztools.c' object='libhttrack_la-mztools.lo' libtool=yes @AMDEPBACKSLASH@ +minizip/libhttrack_la-mztools.lo: minizip/mztools.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT minizip/libhttrack_la-mztools.lo -MD -MP -MF minizip/$(DEPDIR)/libhttrack_la-mztools.Tpo -c -o minizip/libhttrack_la-mztools.lo `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/libhttrack_la-mztools.Tpo minizip/$(DEPDIR)/libhttrack_la-mztools.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/mztools.c' object='minizip/libhttrack_la-mztools.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-mztools.lo `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o minizip/libhttrack_la-mztools.lo `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c -libhttrack_la-unzip.lo: minizip/unzip.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-unzip.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-unzip.Tpo -c -o libhttrack_la-unzip.lo `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libhttrack_la-unzip.Tpo $(DEPDIR)/libhttrack_la-unzip.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/unzip.c' object='libhttrack_la-unzip.lo' libtool=yes @AMDEPBACKSLASH@ +minizip/libhttrack_la-unzip.lo: minizip/unzip.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT minizip/libhttrack_la-unzip.lo -MD -MP -MF minizip/$(DEPDIR)/libhttrack_la-unzip.Tpo -c -o minizip/libhttrack_la-unzip.lo `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/libhttrack_la-unzip.Tpo minizip/$(DEPDIR)/libhttrack_la-unzip.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/unzip.c' object='minizip/libhttrack_la-unzip.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-unzip.lo `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o minizip/libhttrack_la-unzip.lo `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c -libhttrack_la-zip.lo: minizip/zip.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT libhttrack_la-zip.lo -MD -MP -MF $(DEPDIR)/libhttrack_la-zip.Tpo -c -o libhttrack_la-zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libhttrack_la-zip.Tpo $(DEPDIR)/libhttrack_la-zip.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/zip.c' object='libhttrack_la-zip.lo' libtool=yes @AMDEPBACKSLASH@ +minizip/libhttrack_la-zip.lo: minizip/zip.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -MT minizip/libhttrack_la-zip.lo -MD -MP -MF minizip/$(DEPDIR)/libhttrack_la-zip.Tpo -c -o minizip/libhttrack_la-zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/libhttrack_la-zip.Tpo minizip/$(DEPDIR)/libhttrack_la-zip.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/zip.c' object='minizip/libhttrack_la-zip.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o libhttrack_la-zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libhttrack_la_CFLAGS) $(CFLAGS) -c -o minizip/libhttrack_la-zip.lo `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c -proxytrack-main.o: proxy/main.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-main.o -MD -MP -MF $(DEPDIR)/proxytrack-main.Tpo -c -o proxytrack-main.o `test -f 'proxy/main.c' || echo '$(srcdir)/'`proxy/main.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-main.Tpo $(DEPDIR)/proxytrack-main.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/main.c' object='proxytrack-main.o' libtool=no @AMDEPBACKSLASH@ +proxy/proxytrack-main.o: proxy/main.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-main.o -MD -MP -MF proxy/$(DEPDIR)/proxytrack-main.Tpo -c -o proxy/proxytrack-main.o `test -f 'proxy/main.c' || echo '$(srcdir)/'`proxy/main.c +@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-main.Tpo proxy/$(DEPDIR)/proxytrack-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/main.c' object='proxy/proxytrack-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-main.o `test -f 'proxy/main.c' || echo '$(srcdir)/'`proxy/main.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-main.o `test -f 'proxy/main.c' || echo '$(srcdir)/'`proxy/main.c -proxytrack-main.obj: proxy/main.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-main.obj -MD -MP -MF $(DEPDIR)/proxytrack-main.Tpo -c -o proxytrack-main.obj `if test -f 'proxy/main.c'; then $(CYGPATH_W) 'proxy/main.c'; else $(CYGPATH_W) '$(srcdir)/proxy/main.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-main.Tpo $(DEPDIR)/proxytrack-main.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/main.c' object='proxytrack-main.obj' libtool=no @AMDEPBACKSLASH@ +proxy/proxytrack-main.obj: proxy/main.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-main.obj -MD -MP -MF proxy/$(DEPDIR)/proxytrack-main.Tpo -c -o proxy/proxytrack-main.obj `if test -f 'proxy/main.c'; then $(CYGPATH_W) 'proxy/main.c'; else $(CYGPATH_W) '$(srcdir)/proxy/main.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-main.Tpo proxy/$(DEPDIR)/proxytrack-main.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/main.c' object='proxy/proxytrack-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-main.obj `if test -f 'proxy/main.c'; then $(CYGPATH_W) 'proxy/main.c'; else $(CYGPATH_W) '$(srcdir)/proxy/main.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-main.obj `if test -f 'proxy/main.c'; then $(CYGPATH_W) 'proxy/main.c'; else $(CYGPATH_W) '$(srcdir)/proxy/main.c'; fi` -proxytrack-proxytrack.o: proxy/proxytrack.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-proxytrack.o -MD -MP -MF $(DEPDIR)/proxytrack-proxytrack.Tpo -c -o proxytrack-proxytrack.o `test -f 'proxy/proxytrack.c' || echo '$(srcdir)/'`proxy/proxytrack.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-proxytrack.Tpo $(DEPDIR)/proxytrack-proxytrack.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/proxytrack.c' object='proxytrack-proxytrack.o' libtool=no @AMDEPBACKSLASH@ +proxy/proxytrack-proxytrack.o: proxy/proxytrack.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-proxytrack.o -MD -MP -MF proxy/$(DEPDIR)/proxytrack-proxytrack.Tpo -c -o proxy/proxytrack-proxytrack.o `test -f 'proxy/proxytrack.c' || echo '$(srcdir)/'`proxy/proxytrack.c +@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-proxytrack.Tpo proxy/$(DEPDIR)/proxytrack-proxytrack.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/proxytrack.c' object='proxy/proxytrack-proxytrack.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-proxytrack.o `test -f 'proxy/proxytrack.c' || echo '$(srcdir)/'`proxy/proxytrack.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-proxytrack.o `test -f 'proxy/proxytrack.c' || echo '$(srcdir)/'`proxy/proxytrack.c -proxytrack-proxytrack.obj: proxy/proxytrack.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-proxytrack.obj -MD -MP -MF $(DEPDIR)/proxytrack-proxytrack.Tpo -c -o proxytrack-proxytrack.obj `if test -f 'proxy/proxytrack.c'; then $(CYGPATH_W) 'proxy/proxytrack.c'; else $(CYGPATH_W) '$(srcdir)/proxy/proxytrack.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-proxytrack.Tpo $(DEPDIR)/proxytrack-proxytrack.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/proxytrack.c' object='proxytrack-proxytrack.obj' libtool=no @AMDEPBACKSLASH@ +proxy/proxytrack-proxytrack.obj: proxy/proxytrack.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-proxytrack.obj -MD -MP -MF proxy/$(DEPDIR)/proxytrack-proxytrack.Tpo -c -o proxy/proxytrack-proxytrack.obj `if test -f 'proxy/proxytrack.c'; then $(CYGPATH_W) 'proxy/proxytrack.c'; else $(CYGPATH_W) '$(srcdir)/proxy/proxytrack.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-proxytrack.Tpo proxy/$(DEPDIR)/proxytrack-proxytrack.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/proxytrack.c' object='proxy/proxytrack-proxytrack.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-proxytrack.obj `if test -f 'proxy/proxytrack.c'; then $(CYGPATH_W) 'proxy/proxytrack.c'; else $(CYGPATH_W) '$(srcdir)/proxy/proxytrack.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-proxytrack.obj `if test -f 'proxy/proxytrack.c'; then $(CYGPATH_W) 'proxy/proxytrack.c'; else $(CYGPATH_W) '$(srcdir)/proxy/proxytrack.c'; fi` -proxytrack-store.o: proxy/store.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-store.o -MD -MP -MF $(DEPDIR)/proxytrack-store.Tpo -c -o proxytrack-store.o `test -f 'proxy/store.c' || echo '$(srcdir)/'`proxy/store.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-store.Tpo $(DEPDIR)/proxytrack-store.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/store.c' object='proxytrack-store.o' libtool=no @AMDEPBACKSLASH@ +proxy/proxytrack-store.o: proxy/store.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-store.o -MD -MP -MF proxy/$(DEPDIR)/proxytrack-store.Tpo -c -o proxy/proxytrack-store.o `test -f 'proxy/store.c' || echo '$(srcdir)/'`proxy/store.c +@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-store.Tpo proxy/$(DEPDIR)/proxytrack-store.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/store.c' object='proxy/proxytrack-store.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-store.o `test -f 'proxy/store.c' || echo '$(srcdir)/'`proxy/store.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-store.o `test -f 'proxy/store.c' || echo '$(srcdir)/'`proxy/store.c -proxytrack-store.obj: proxy/store.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-store.obj -MD -MP -MF $(DEPDIR)/proxytrack-store.Tpo -c -o proxytrack-store.obj `if test -f 'proxy/store.c'; then $(CYGPATH_W) 'proxy/store.c'; else $(CYGPATH_W) '$(srcdir)/proxy/store.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-store.Tpo $(DEPDIR)/proxytrack-store.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/store.c' object='proxytrack-store.obj' libtool=no @AMDEPBACKSLASH@ +proxy/proxytrack-store.obj: proxy/store.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxy/proxytrack-store.obj -MD -MP -MF proxy/$(DEPDIR)/proxytrack-store.Tpo -c -o proxy/proxytrack-store.obj `if test -f 'proxy/store.c'; then $(CYGPATH_W) 'proxy/store.c'; else $(CYGPATH_W) '$(srcdir)/proxy/store.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) proxy/$(DEPDIR)/proxytrack-store.Tpo proxy/$(DEPDIR)/proxytrack-store.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='proxy/store.c' object='proxy/proxytrack-store.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-store.obj `if test -f 'proxy/store.c'; then $(CYGPATH_W) 'proxy/store.c'; else $(CYGPATH_W) '$(srcdir)/proxy/store.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxy/proxytrack-store.obj `if test -f 'proxy/store.c'; then $(CYGPATH_W) 'proxy/store.c'; else $(CYGPATH_W) '$(srcdir)/proxy/store.c'; fi` proxytrack-htsinthash.o: htsinthash.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-htsinthash.o -MD -MP -MF $(DEPDIR)/proxytrack-htsinthash.Tpo -c -o proxytrack-htsinthash.o `test -f 'htsinthash.c' || echo '$(srcdir)/'`htsinthash.c @@ -937,67 +1002,68 @@ proxytrack-md5.obj: md5.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-md5.obj `if test -f 'md5.c'; then $(CYGPATH_W) 'md5.c'; else $(CYGPATH_W) '$(srcdir)/md5.c'; fi` -proxytrack-ioapi.o: minizip/ioapi.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-ioapi.o -MD -MP -MF $(DEPDIR)/proxytrack-ioapi.Tpo -c -o proxytrack-ioapi.o `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-ioapi.Tpo $(DEPDIR)/proxytrack-ioapi.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/ioapi.c' object='proxytrack-ioapi.o' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-ioapi.o: minizip/ioapi.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-ioapi.o -MD -MP -MF minizip/$(DEPDIR)/proxytrack-ioapi.Tpo -c -o minizip/proxytrack-ioapi.o `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-ioapi.Tpo minizip/$(DEPDIR)/proxytrack-ioapi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/ioapi.c' object='minizip/proxytrack-ioapi.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-ioapi.o `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-ioapi.o `test -f 'minizip/ioapi.c' || echo '$(srcdir)/'`minizip/ioapi.c -proxytrack-ioapi.obj: minizip/ioapi.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-ioapi.obj -MD -MP -MF $(DEPDIR)/proxytrack-ioapi.Tpo -c -o proxytrack-ioapi.obj `if test -f 'minizip/ioapi.c'; then $(CYGPATH_W) 'minizip/ioapi.c'; else $(CYGPATH_W) '$(srcdir)/minizip/ioapi.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-ioapi.Tpo $(DEPDIR)/proxytrack-ioapi.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/ioapi.c' object='proxytrack-ioapi.obj' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-ioapi.obj: minizip/ioapi.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-ioapi.obj -MD -MP -MF minizip/$(DEPDIR)/proxytrack-ioapi.Tpo -c -o minizip/proxytrack-ioapi.obj `if test -f 'minizip/ioapi.c'; then $(CYGPATH_W) 'minizip/ioapi.c'; else $(CYGPATH_W) '$(srcdir)/minizip/ioapi.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-ioapi.Tpo minizip/$(DEPDIR)/proxytrack-ioapi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/ioapi.c' object='minizip/proxytrack-ioapi.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-ioapi.obj `if test -f 'minizip/ioapi.c'; then $(CYGPATH_W) 'minizip/ioapi.c'; else $(CYGPATH_W) '$(srcdir)/minizip/ioapi.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-ioapi.obj `if test -f 'minizip/ioapi.c'; then $(CYGPATH_W) 'minizip/ioapi.c'; else $(CYGPATH_W) '$(srcdir)/minizip/ioapi.c'; fi` -proxytrack-mztools.o: minizip/mztools.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-mztools.o -MD -MP -MF $(DEPDIR)/proxytrack-mztools.Tpo -c -o proxytrack-mztools.o `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-mztools.Tpo $(DEPDIR)/proxytrack-mztools.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/mztools.c' object='proxytrack-mztools.o' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-mztools.o: minizip/mztools.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-mztools.o -MD -MP -MF minizip/$(DEPDIR)/proxytrack-mztools.Tpo -c -o minizip/proxytrack-mztools.o `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-mztools.Tpo minizip/$(DEPDIR)/proxytrack-mztools.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/mztools.c' object='minizip/proxytrack-mztools.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-mztools.o `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-mztools.o `test -f 'minizip/mztools.c' || echo '$(srcdir)/'`minizip/mztools.c -proxytrack-mztools.obj: minizip/mztools.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-mztools.obj -MD -MP -MF $(DEPDIR)/proxytrack-mztools.Tpo -c -o proxytrack-mztools.obj `if test -f 'minizip/mztools.c'; then $(CYGPATH_W) 'minizip/mztools.c'; else $(CYGPATH_W) '$(srcdir)/minizip/mztools.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-mztools.Tpo $(DEPDIR)/proxytrack-mztools.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/mztools.c' object='proxytrack-mztools.obj' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-mztools.obj: minizip/mztools.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-mztools.obj -MD -MP -MF minizip/$(DEPDIR)/proxytrack-mztools.Tpo -c -o minizip/proxytrack-mztools.obj `if test -f 'minizip/mztools.c'; then $(CYGPATH_W) 'minizip/mztools.c'; else $(CYGPATH_W) '$(srcdir)/minizip/mztools.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-mztools.Tpo minizip/$(DEPDIR)/proxytrack-mztools.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/mztools.c' object='minizip/proxytrack-mztools.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-mztools.obj `if test -f 'minizip/mztools.c'; then $(CYGPATH_W) 'minizip/mztools.c'; else $(CYGPATH_W) '$(srcdir)/minizip/mztools.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-mztools.obj `if test -f 'minizip/mztools.c'; then $(CYGPATH_W) 'minizip/mztools.c'; else $(CYGPATH_W) '$(srcdir)/minizip/mztools.c'; fi` -proxytrack-unzip.o: minizip/unzip.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-unzip.o -MD -MP -MF $(DEPDIR)/proxytrack-unzip.Tpo -c -o proxytrack-unzip.o `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-unzip.Tpo $(DEPDIR)/proxytrack-unzip.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/unzip.c' object='proxytrack-unzip.o' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-unzip.o: minizip/unzip.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-unzip.o -MD -MP -MF minizip/$(DEPDIR)/proxytrack-unzip.Tpo -c -o minizip/proxytrack-unzip.o `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-unzip.Tpo minizip/$(DEPDIR)/proxytrack-unzip.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/unzip.c' object='minizip/proxytrack-unzip.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-unzip.o `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-unzip.o `test -f 'minizip/unzip.c' || echo '$(srcdir)/'`minizip/unzip.c -proxytrack-unzip.obj: minizip/unzip.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-unzip.obj -MD -MP -MF $(DEPDIR)/proxytrack-unzip.Tpo -c -o proxytrack-unzip.obj `if test -f 'minizip/unzip.c'; then $(CYGPATH_W) 'minizip/unzip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/unzip.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-unzip.Tpo $(DEPDIR)/proxytrack-unzip.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/unzip.c' object='proxytrack-unzip.obj' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-unzip.obj: minizip/unzip.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-unzip.obj -MD -MP -MF minizip/$(DEPDIR)/proxytrack-unzip.Tpo -c -o minizip/proxytrack-unzip.obj `if test -f 'minizip/unzip.c'; then $(CYGPATH_W) 'minizip/unzip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/unzip.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-unzip.Tpo minizip/$(DEPDIR)/proxytrack-unzip.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/unzip.c' object='minizip/proxytrack-unzip.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-unzip.obj `if test -f 'minizip/unzip.c'; then $(CYGPATH_W) 'minizip/unzip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/unzip.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-unzip.obj `if test -f 'minizip/unzip.c'; then $(CYGPATH_W) 'minizip/unzip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/unzip.c'; fi` -proxytrack-zip.o: minizip/zip.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-zip.o -MD -MP -MF $(DEPDIR)/proxytrack-zip.Tpo -c -o proxytrack-zip.o `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-zip.Tpo $(DEPDIR)/proxytrack-zip.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/zip.c' object='proxytrack-zip.o' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-zip.o: minizip/zip.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-zip.o -MD -MP -MF minizip/$(DEPDIR)/proxytrack-zip.Tpo -c -o minizip/proxytrack-zip.o `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-zip.Tpo minizip/$(DEPDIR)/proxytrack-zip.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/zip.c' object='minizip/proxytrack-zip.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-zip.o `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-zip.o `test -f 'minizip/zip.c' || echo '$(srcdir)/'`minizip/zip.c -proxytrack-zip.obj: minizip/zip.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT proxytrack-zip.obj -MD -MP -MF $(DEPDIR)/proxytrack-zip.Tpo -c -o proxytrack-zip.obj `if test -f 'minizip/zip.c'; then $(CYGPATH_W) 'minizip/zip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/zip.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proxytrack-zip.Tpo $(DEPDIR)/proxytrack-zip.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/zip.c' object='proxytrack-zip.obj' libtool=no @AMDEPBACKSLASH@ +minizip/proxytrack-zip.obj: minizip/zip.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -MT minizip/proxytrack-zip.obj -MD -MP -MF minizip/$(DEPDIR)/proxytrack-zip.Tpo -c -o minizip/proxytrack-zip.obj `if test -f 'minizip/zip.c'; then $(CYGPATH_W) 'minizip/zip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/zip.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) minizip/$(DEPDIR)/proxytrack-zip.Tpo minizip/$(DEPDIR)/proxytrack-zip.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='minizip/zip.c' object='minizip/proxytrack-zip.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o proxytrack-zip.obj `if test -f 'minizip/zip.c'; then $(CYGPATH_W) 'minizip/zip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/zip.c'; fi` +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(proxytrack_CFLAGS) $(CFLAGS) -c -o minizip/proxytrack-zip.obj `if test -f 'minizip/zip.c'; then $(CYGPATH_W) 'minizip/zip.c'; else $(CYGPATH_W) '$(srcdir)/minizip/zip.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs + -rm -rf minizip/.libs minizip/_libs install-DevIncludesDATA: $(DevIncludes_DATA) @$(NORMAL_INSTALL) @list='$(DevIncludes_DATA)'; test -n "$(DevIncludesdir)" || list=; \ @@ -1137,6 +1203,10 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f minizip/$(DEPDIR)/$(am__dirstamp) + -rm -f minizip/$(am__dirstamp) + -rm -f proxy/$(DEPDIR)/$(am__dirstamp) + -rm -f proxy/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -1147,7 +1217,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -rf ./$(DEPDIR) minizip/$(DEPDIR) proxy/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1193,7 +1263,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -rf ./$(DEPDIR) minizip/$(DEPDIR) proxy/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/src/htsalias.c b/src/htsalias.c index 0f8a41e..df608fc 100644 --- a/src/htsalias.c +++ b/src/htsalias.c @@ -189,10 +189,10 @@ const char *hts_optalias[][4] = { /* Badly documented */ {"debug-testfilters", "-#0", "param1", "debug: test filters"}, {"advanced-flushlogs", "-#f", "single", ""}, - {"advanced-maxfilters", "-#F", "param", ""}, + {"advanced-maxfilters", "-#F", "param", "maximum number of scan rules"}, {"version", "-#h", "single", ""}, {"debug-scanstdin", "-#K", "single", ""}, - {"advanced-maxlinks", "-#L", "single", ""}, + {"advanced-maxlinks", "-#L", "param", "maximum number of links (0 to disable limit)"}, {"advanced-progressinfo", "-#p", "single", "deprecated"}, {"catch-url", "-#P", "single", "catch complex URL through proxy"}, /*{"debug-oldftp","-#R","single",""}, */ @@ -517,9 +517,9 @@ int optinclude_file(const char *name, int *argc, char **argv, char *x_argvblk, tmp_argv[1] = _tmp_argv[1]; tmp_argv[2] = _tmp_argv[2]; tmp_argv[3] = _tmp_argv[3]; - strcpybuff(tmp_argv[0], "--"); - strcatbuff(tmp_argv[0], a); - strcpybuff(tmp_argv[1], b); + strcpybuff(_tmp_argv[0], "--"); + strcatbuff(_tmp_argv[0], a); + strcpybuff(_tmp_argv[1], b); result = optalias_check(2, (const char *const *) tmp_argv, 0, &return_argc, @@ -560,8 +560,8 @@ int optinclude_file(const char *name, int *argc, char **argv, char *x_argvblk, /* Get home directory, '.' if failed */ /* example: /home/smith */ -char *hts_gethome(void) { - char *home = getenv("HOME"); +const char *hts_gethome(void) { + const char *home = getenv("HOME"); if (home) return home; diff --git a/src/htsalias.h b/src/htsalias.h index b77885d..b09d18f 100644 --- a/src/htsalias.h +++ b/src/htsalias.h @@ -48,7 +48,7 @@ const char *optreal_value(int p); const char *optalias_value(int p); const char *opttype_value(int p); const char *opthelp_value(int p); -char *hts_gethome(void); +const char *hts_gethome(void); void expand_home(String * str); #endif diff --git a/src/htsarrays.h b/src/htsarrays.h new file mode 100644 index 0000000..c89222e --- /dev/null +++ b/src/htsarrays.h @@ -0,0 +1,149 @@ +/* ------------------------------------------------------------ */ +/* +HTTrack Website Copier, Offline Browser for Windows and Unix +Copyright (C) 1998-2014 Xavier Roche and other contributors + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +Important notes: + +- We hereby ask people using this source NOT to use it in purpose of grabbing +emails addresses, or collecting any other private information on persons. +This would disgrace our work, and spoil the many hours we spent on it. + +Please visit our Website: http://www.httrack.com +*/ + +/* ------------------------------------------------------------ */ +/* File: Arrays */ +/* Author: Xavier Roche */ +/* ------------------------------------------------------------ */ + +#ifndef HTS_ARRAYS_DEFSTATIC +#define HTS_ARRAYS_DEFSTATIC + +/* System definitions. */ +#include +#include + +#include "htssafe.h" + +/* Memory allocation assertion failure */ +static void hts_record_assert_memory_failed(const size_t size) { + fprintf(stderr, "memory allocation failed (%lu bytes)", \ + (long int) size); \ + assertf(! "memory allocation failed"); \ +} + +/** Dynamic array of T elements. **/ +#define TypedArray(T) \ + struct { \ + /** Elements. **/ \ + union { \ + /** Typed. **/ \ + T* elts; \ + /** Opaque. **/ \ + void* ptr; \ + } data; \ + /** Count. **/ \ + size_t size; \ + /** Capacity. **/ \ + size_t capa; \ + } +#define EMPTY_TYPED_ARRAY { { NULL }, 0, 0 } + +/** Array size, in elements. **/ +#define TypedArraySize(A) ((A).size) + +/** Array capacity, in elements. **/ +#define TypedArrayCapa(A) ((A).capa) + +/** + * Remaining free space, in elements. + * Macro, first element evaluated multiple times. + **/ +#define TypedArrayRoom(A) ( TypedArrayCapa(A) - TypedArraySize(A) ) + +/** Array elements, of type T*. **/ +#define TypedArrayElts(A) ((A).data.elts) + +/** Array pointer, of type void*. **/ +#define TypedArrayPtr(A) ((A).data.ptr) + +/** Size of T. **/ +#define TypedArrayWidth(A) (sizeof(*TypedArrayElts(A))) + +/** Nth element of the array. **/ +#define TypedArrayNth(A, N) (TypedArrayElts(A)[N]) + +/** + * Tail of the array (outside the array). + * The returned pointer points to the beginning of TypedArrayRoom(A) + * free elements. + **/ +#define TypedArrayTail(A) (TypedArrayNth(A, TypedArraySize(A))) + +/** + * Ensure at least 'ROOM' elements can be put in the remaining space. + * After a call to this macro, TypedArrayRoom(A) is guaranteed to be at + * least equal to 'ROOM'. + **/ +#define TypedArrayEnsureRoom(A, ROOM) do { \ + const size_t room_ = (ROOM); \ + while (TypedArrayRoom(A) < room_) { \ + TypedArrayCapa(A) = TypedArrayCapa(A) < 16 ? 16 : TypedArrayCapa(A) * 2; \ + } \ + TypedArrayPtr(A) = realloc(TypedArrayPtr(A), \ + TypedArrayCapa(A)*TypedArrayWidth(A)); \ + if (TypedArrayPtr(A) == NULL) { \ + hts_record_assert_memory_failed(TypedArrayCapa(A)*TypedArrayWidth(A)); \ + } \ +} while(0) + +/** Add an element. Macro, first element evaluated multiple times. **/ +#define TypedArrayAdd(A, E) do { \ + TypedArrayEnsureRoom(A, 1); \ + assertf(TypedArraySize(A) < TypedArrayCapa(A)); \ + TypedArrayTail(A) = (E); \ + TypedArraySize(A)++; \ +} while(0) + +/** + * Add 'COUNT' elements from 'PTR'. + * Macro, first element evaluated multiple times. + **/ +#define TypedArrayAppend(A, PTR, COUNT) do { \ + const size_t count_ = (COUNT); \ + /* This 1-case is to benefit from type safety. */ \ + if (count_ == 1) { \ + TypedArrayAdd(A, *(PTR)); \ + } else { \ + const void *const source_ = (PTR); \ + TypedArrayEnsureRoom(A, count_); \ + assertf(count_ <= TypedArrayRoom(A)); \ + memcpy(&TypedArrayTail(A), source_, count_ * TypedArrayWidth(A)); \ + TypedArraySize(A) += count_; \ + } \ +} while(0) + +/** Clear an array, freeing memory and clearing size and capacity. **/ +#define TypedArrayFree(A) do { \ + if (TypedArrayPtr(A) != NULL) { \ + TypedArrayCapa(A) = TypedArraySize(A) = 0; \ + free(TypedArrayPtr(A)); \ + TypedArrayPtr(A) = NULL; \ + } \ +} while(0) + +#endif diff --git a/src/htsback.c b/src/htsback.c index d5d7c10..ecfa4e3 100644 --- a/src/htsback.c +++ b/src/htsback.c @@ -117,7 +117,7 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) { while((item = inthash_enum_next(&e))) { #ifndef HTS_NO_BACK_ON_DISK - char *filename = (char *) item->value.ptr; + const char *filename = (char *) item->value.ptr; if (filename != NULL) { (void) UNLINK(filename); @@ -139,19 +139,19 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) { // --- // routines de backing -static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex); -static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex); +static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex); +static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex); // retourne l'index d'un lien dans un tableau de backing -int back_index(httrackp * opt, struct_back * sback, char *adr, char *fil, - char *sav) { +int back_index(httrackp * opt, struct_back * sback, const char *adr, const char *fil, + const char *sav) { return back_index_fetch(opt, sback, adr, fil, sav, 1); } -static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex) { +static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex) { lien_back *const back = sback->lnk; const int back_max = sback->count; int index = -1; @@ -177,8 +177,8 @@ static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr, } /* resurrect stored entry */ -static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, - char *fil, char *sav, int getIndex) { +static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr, + const char *fil, const char *sav, int getIndex) { lien_back *const back = sback->lnk; void *ptr = NULL; @@ -194,7 +194,7 @@ static int back_index_ready(httrackp * opt, struct_back * sback, char *adr, #ifndef HTS_NO_BACK_ON_DISK FILE *fp; - char *fileback = (char *) ptr; + const char *fileback = (char *) ptr; char catbuff[CATBUFF_SIZE]; if ((fp = FOPEN(fconv(catbuff, sizeof(catbuff), fileback), "rb")) != NULL) { @@ -349,8 +349,8 @@ int back_cleanup_background(httrackp * opt, cache_back * cache, } // nombre d'entrées libres dans le backing -int back_available(struct_back * sback) { - lien_back *const back = sback->lnk; +int back_available(const struct_back * sback) { + const lien_back *const back = sback->lnk; const int back_max = sback->count; int i; int nb = 0; @@ -362,8 +362,8 @@ int back_available(struct_back * sback) { } // retourne estimation de la taille des html et fichiers stockés en mémoire -LLint back_incache(struct_back * sback) { - lien_back *const back = sback->lnk; +LLint back_incache(const struct_back * sback) { + const lien_back *const back = sback->lnk; const int back_max = sback->count; int i; LLint sum = 0; @@ -391,8 +391,8 @@ LLint back_incache(struct_back * sback) { } // retourne estimation de la taille des html et fichiers stockés en mémoire -int back_done_incache(struct_back * sback) { - lien_back *const back = sback->lnk; +int back_done_incache(const struct_back * sback) { + const lien_back *const back = sback->lnk; const int back_max = sback->count; int i; int n = 0; @@ -420,14 +420,14 @@ int back_done_incache(struct_back * sback) { } // le lien a-t-il été mis en backing? -HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, char *adr, - char *fil, char *sav) { +HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, const char *adr, + const char *fil, const char *sav) { return (back_index_fetch(opt, sback, adr, fil, sav, /*don't fetch */ 0) >= 0); } // nombre de sockets en tâche de fond -int back_nsoc(struct_back * sback) { - lien_back *const back = sback->lnk; +int back_nsoc(const struct_back * sback) { + const lien_back *const back = sback->lnk; const int back_max = sback->count; int n = 0; int i; @@ -438,8 +438,8 @@ int back_nsoc(struct_back * sback) { return n; } -int back_nsoc_overall(struct_back * sback) { - lien_back *const back = sback->lnk; +int back_nsoc_overall(const struct_back * sback) { + const lien_back *const back = sback->lnk; const int back_max = sback->count; int n = 0; int i; @@ -515,7 +515,7 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback, && (back[p].r.statuscode > 0) // not internal error ) { if (!back[p].testmode) { // not test mode - char *state = "unknown"; + const char *state = "unknown"; /* décompression */ #if HTS_USEZLIB @@ -626,7 +626,7 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback, FILE *fp = FOPEN(back[p].url_sav, "rb"); if (fp) { - back[p].r.adr = malloct((int) sz + 2); + back[p].r.adr = malloct((size_t) sz + 1); if (back[p].r.adr) { if (fread(back[p].r.adr, 1, sz, fp) == sz) { back[p].r.size = sz; @@ -980,7 +980,7 @@ int back_unserialize(FILE * fp, lien_back ** dst) { /* serialize a reference ; used to store references of files being downloaded in case of broken download */ /* Note: NOT utf-8 */ int back_serialize_ref(httrackp * opt, const lien_back * src) { - char *filename = + const char *filename = url_savename_refname_fullpath(opt, src->url_adr, src->url_fil); FILE *fp = fopen(filename, "wb"); @@ -1012,7 +1012,7 @@ int back_serialize_ref(httrackp * opt, const lien_back * src) { /* unserialize a reference ; used to store references of files being downloaded in case of broken download */ int back_unserialize_ref(httrackp * opt, const char *adr, const char *fil, lien_back ** dst) { - char *filename = url_savename_refname_fullpath(opt, adr, fil); + const char *filename = url_savename_refname_fullpath(opt, adr, fil); FILE *fp = FOPEN(filename, "rb"); if (fp != NULL) { @@ -1148,7 +1148,7 @@ int back_trylive(httrackp * opt, cache_back * cache, struct_back * sback, } /* search for a live position, or, if not possible, try to return a new one */ -int back_searchlive(httrackp * opt, struct_back * sback, char *search_addr) { +int back_searchlive(httrackp * opt, struct_back * sback, const char *search_addr) { lien_back *const back = sback->lnk; const int back_max = sback->count; int i; @@ -1400,8 +1400,8 @@ int back_stack_available(struct_back * sback) { // ajouter un lien en backing int back_add_if_not_exists(struct_back * sback, httrackp * opt, - cache_back * cache, char *adr, char *fil, char *save, - char *referer_adr, char *referer_fil, int test) { + cache_back * cache, const char *adr, const char *fil, const char *save, + const char *referer_adr, const char *referer_fil, int test) { back_clean(opt, cache, sback); /* first cleanup the backlog to ensure that we have some entry left */ if (!back_exist(sback, opt, adr, fil, save)) { return back_add(sback, opt, cache, adr, fil, save, referer_adr, referer_fil, @@ -1410,8 +1410,8 @@ int back_add_if_not_exists(struct_back * sback, httrackp * opt, return 0; } -int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr, - char *fil, char *save, char *referer_adr, char *referer_fil, +int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char *adr, + const char *fil, const char *save, const char *referer_adr, const char *referer_fil, int test) { lien_back *const back = sback->lnk; const int back_max = sback->count; @@ -1974,7 +1974,7 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr, printf("ok, dns cache ready..\n"); #endif soc = - http_xfopen(opt, 0, 0, 0, back[p].send_too, adr, fil, &(back[p].r)); + http_xfopen(opt, 0, 0, 0, back[p].send_too, adr, fil, &back[p].r); if (soc == INVALID_SOCKET) { back[p].status = STATUS_READY; // fini, erreur back_set_finished(sback, p); diff --git a/src/htsback.h b/src/htsback.h index 1da5450..5c1aac8 100644 --- a/src/htsback.h +++ b/src/htsback.h @@ -74,21 +74,21 @@ void back_free(struct_back ** sback); // backing #define BACK_ADD_TEST "(dummy)" #define BACK_ADD_TEST2 "(dummy2)" -int back_index(httrackp * opt, struct_back * sback, char *adr, char *fil, - char *sav); -int back_available(struct_back * sback); -LLint back_incache(struct_back * sback); -int back_done_incache(struct_back * sback); -HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, char *adr, - char *fil, char *sav); -int back_nsoc(struct_back * sback); -int back_nsoc_overall(struct_back * sback); -int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr, - char *fil, char *save, char *referer_adr, char *referer_fil, +int back_index(httrackp * opt, struct_back * sback, const char *adr, const char *fil, + const char *sav); +int back_available(const struct_back * sback); +LLint back_incache(const struct_back * sback); +int back_done_incache(const struct_back * sback); +HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, const char *adr, + const char *fil, const char *sav); +int back_nsoc(const struct_back * sback); +int back_nsoc_overall(const struct_back * sback); +int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char *adr, + const char *fil, const char *save, const char *referer_adr, const char *referer_fil, int test); int back_add_if_not_exists(struct_back * sback, httrackp * opt, - cache_back * cache, char *adr, char *fil, char *save, - char *referer_adr, char *referer_fil, int test); + cache_back * cache, const char *adr, const char *fil, const char *save, + const char *referer_adr, const char *referer_fil, int test); int back_stack_available(struct_back * sback); int back_search(httrackp * opt, struct_back * sback); int back_search_quick(struct_back * sback); @@ -99,7 +99,7 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache, TStamp stat_timestart); int back_letlive(httrackp * opt, cache_back * cache, struct_back * sback, const int p); -int back_searchlive(httrackp * opt, struct_back * sback, char *search_addr); +int back_searchlive(httrackp * opt, struct_back * sback, const char *search_addr); void back_connxfr(htsblk * src, htsblk * dst); void back_move(lien_back * src, lien_back * dst); void back_copy_static(const lien_back * src, lien_back * dst); diff --git a/src/htsbasenet.h b/src/htsbasenet.h index a9578c4..23901d0 100644 --- a/src/htsbasenet.h +++ b/src/htsbasenet.h @@ -54,12 +54,13 @@ Please visit our Website: http://www.httrack.com #endif -typedef struct hostent FAR t_hostent; - #else #define HTS_USESCOPEID #define INVALID_SOCKET -1 -typedef struct hostent t_hostent; +#endif + +#ifdef __cplusplus +extern "C" { #endif #if HTS_USEOPENSSL @@ -157,4 +158,8 @@ typedef enum HTTrackStatus { STATUS_FTP_READY = 1001 } HTTrackStatus; +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/htsbauth.c b/src/htsbauth.c index da0ef1d..12af086 100644 --- a/src/htsbauth.c +++ b/src/htsbauth.c @@ -38,14 +38,15 @@ Please visit our Website: http://www.httrack.com /* specific definitions */ #include "htsglobal.h" #include "htslib.h" +#include "htscore.h" /* END specific definitions */ // gestion des cookie // ajoute, dans l'ordre // !=0 : erreur -int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, - char *domain, char *path) { +int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value, + const char *domain, const char *path) { char buffer[8192]; char *a = cookie->data; char *insert; @@ -53,20 +54,20 @@ int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, // effacer éventuel cookie en double cookie_del(cookie, cook_name, domain, path); - if ((int) strlen(cook_value) > 1024) + if (strlen(cook_value) > 1024) return -1; // trop long - if ((int) strlen(cook_name) > 256) + if (strlen(cook_name) > 256) return -1; // trop long - if ((int) strlen(domain) > 256) + if (strlen(domain) > 256) return -1; // trop long - if ((int) strlen(path) > 256) + if (strlen(path) > 256) return -1; // trop long - if ((int) (strlen(cookie->data) + if (strlen(cookie->data) + strlen(cook_value) + strlen(cook_name) + strlen(domain) + strlen(path) - + 256) > cookie->max_len) + + 256 > cookie->max_len) return -1; // impossible d'ajouter insert = a; // insérer ici @@ -99,7 +100,7 @@ int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, strcatbuff(cook, "\t"); strcatbuff(cook, cook_value); strcatbuff(cook, "\n"); - if (!(((int) strlen(cookie->data) + (int) strlen(cook)) < cookie->max_len)) + if (!((strlen(cookie->data) + strlen(cook)) < cookie->max_len)) return -1; // impossible d'ajouter cookie_insert(insert, cook); #if DEBUG_COOK @@ -111,13 +112,13 @@ int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, } // effacer cookie si existe -int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path) { +int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, const char *path) { char *a, *b; b = cookie_find(cookie->data, cook_name, domain, path); if (b) { a = cookie_nextfield(b); - cookie_delete(b, (int) (a - b)); + cookie_delete(b, a - b); #if DEBUG_COOK printf("deleted old cookie: %s %s %s\n", cook_name, domain, path); #endif @@ -128,7 +129,7 @@ int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path) { // Matches wildcard cookie domains that start with a dot // chk_dom: the domain stored in the cookie (potentially wildcard). // domain: query domain -static int cookie_cmp_wildcard_domain(char *chk_dom, char *domain) { +static int cookie_cmp_wildcard_domain(const char *chk_dom, const char *domain) { const size_t n = strlen(chk_dom); const size_t m = strlen(domain); const size_t l = n < m ? n : m; @@ -152,7 +153,7 @@ static int cookie_cmp_wildcard_domain(char *chk_dom, char *domain) { // renvoie pointeur sur ligne, ou NULL si introuvable // path est aligné à droite et cook_name peut être vide (chercher alors tout cookie) // .doubleclick.net TRUE / FALSE 1999999999 id A -char *cookie_find(char *s, char *cook_name, char *domain, char *path) { +char *cookie_find(char *s, const char *cook_name, const char *domain, const char *path) { char buffer[8192]; char *a = s; @@ -165,15 +166,15 @@ char *cookie_find(char *s, char *cook_name, char *domain, char *path) { t = (strcmp(cookie_get(buffer, a, 5), cook_name) == 0); // tester si même nom if (t) { // même nom ou nom qualconque // - char *chk_dom = cookie_get(buffer, a, 0); // domaine concerné par le cookie + const char *chk_dom = cookie_get(buffer, a, 0); // domaine concerné par le cookie - if (((int) strlen(chk_dom) <= (int) strlen(domain) && + if ((strlen(chk_dom) <= strlen(domain) && strcmp(chk_dom, domain + strlen(domain) - strlen(chk_dom)) == 0) || !cookie_cmp_wildcard_domain(chk_dom, domain)) { // même domaine // - char *chk_path = cookie_get(buffer, a, 2); // chemin concerné par le cookie + const char *chk_path = cookie_get(buffer, a, 2); // chemin concerné par le cookie - if ((int) strlen(chk_path) <= (int) strlen(path)) { + if (strlen(chk_path) <= strlen(path)) { if (strncmp(path, chk_path, strlen(chk_path)) == 0) { // même chemin return a; } @@ -231,15 +232,14 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) { char dummy[512]; // - char domain[256]; // domaine cookie (.netscape.com) - char path[256]; // chemin (/) + lien_adrfil af; // chemin (/) int cookie_merged = 0; // // Read all cookies while(!feof(fp)) { cook_name[0] = cook_value[0] = domainpathpath[0] - = dummy[0] = domain[0] = path[0] = '\0'; + = dummy[0] = af.adr[0] = af.fil[0] = '\0'; linput(fp, cook_name, 250); if (!feof(fp)) { linput(fp, cook_value, 250); @@ -254,8 +254,8 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) { if (strnotempty(cook_name) && strnotempty(cook_value) && strnotempty(domainpathpath)) { - if (ident_url_absolute(domainpathpath, domain, path) >= 0) { - cookie_add(cookie, cook_name, cook_value, domain, path); + if (ident_url_absolute(domainpathpath, &af) >= 0) { + cookie_add(cookie, cook_name, cook_value, af.adr, af.fil); cookie_merged = 1; } } @@ -311,7 +311,7 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) { // écrire cookies.txt // !=0 : erreur -int cookie_save(t_cookie * cookie, char *name) { +int cookie_save(t_cookie * cookie, const char *name) { char catbuff[CATBUFF_SIZE]; if (strnotempty(cookie->data)) { @@ -337,13 +337,13 @@ int cookie_save(t_cookie * cookie, char *name) { } // insertion chaine ins avant s -void cookie_insert(char *s, char *ins) { +void cookie_insert(char *s, const char *ins) { char *buff; if (strnotempty(s) == 0) { // rien à faire, juste concat strcatbuff(s, ins); } else { - buff = (char *) malloct(strlen(s) + 2); + buff = (char *) malloct(strlen(s) + 1); if (buff) { strcpybuff(buff, s); // copie temporaire strcpybuff(s, ins); // insérer @@ -354,13 +354,13 @@ void cookie_insert(char *s, char *ins) { } // destruction chaine dans s position pos -void cookie_delete(char *s, int pos) { +void cookie_delete(char *s, size_t pos) { char *buff; if (strnotempty(s + pos) == 0) { // rien à faire, effacer s[0] = '\0'; } else { - buff = (char *) malloct(strlen(s + pos) + 2); + buff = (char *) malloct(strlen(s + pos) + 1); if (buff) { strcpybuff(buff, s + pos); // copie temporaire strcpybuff(s, buff); // copier @@ -371,8 +371,8 @@ void cookie_delete(char *s, int pos) { // renvoie champ param de la chaine cookie_base // ex: cookie_get("ceci estunexemple",1) renvoi "un" -char *cookie_get(char *buffer, char *cookie_base, int param) { - char *limit; +const char *cookie_get(char *buffer, const char *cookie_base, int param) { + const char *limit; while(*cookie_base == '\n') cookie_base++; @@ -393,7 +393,7 @@ char *cookie_get(char *buffer, char *cookie_base, int param) { } if (cookie_base) { if (cookie_base < limit) { - char *a = cookie_base; + const char *a = cookie_base; while((*a) && (*a != '\t') && (*a != '\n')) a++; @@ -413,7 +413,7 @@ char *cookie_get(char *buffer, char *cookie_base, int param) { // -- basic auth -- /* déclarer un répertoire comme possédant une authentification propre */ -int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth) { +int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *auth) { char buffer[HTS_URLMAXSIZE * 2]; if (cookie) { @@ -439,7 +439,7 @@ int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth) { /* tester adr et fil, et retourner authentification si nécessaire */ /* sinon, retourne NULL */ -char *bauth_check(t_cookie * cookie, char *adr, char *fil) { +char *bauth_check(t_cookie * cookie, const char *adr, const char *fil) { char buffer[HTS_URLMAXSIZE * 2]; if (cookie) { @@ -458,7 +458,7 @@ char *bauth_check(t_cookie * cookie, char *adr, char *fil) { return NULL; } -char *bauth_prefix(char *prefix, char *adr, char *fil) { +char *bauth_prefix(char *prefix, const char *adr, const char *fil) { char *a; strcpybuff(prefix, jump_identification(adr)); diff --git a/src/htsbauth.h b/src/htsbauth.h index 248097e..dd57070 100644 --- a/src/htsbauth.h +++ b/src/htsbauth.h @@ -34,6 +34,8 @@ Please visit our Website: http://www.httrack.com #ifndef HTSBAUTH_DEFH #define HTSBAUTH_DEFH +#include + // robots wizard #ifndef HTS_DEF_FWSTRUCT_bauth_chain #define HTS_DEF_FWSTRUCT_bauth_chain @@ -60,21 +62,21 @@ struct t_cookie { #ifdef HTS_INTERNAL_BYTECODE // cookies -int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value, - char *domain, char *path); -int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path); +int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value, + const char *domain, const char *path); +int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, const char *path); int cookie_load(t_cookie * cookie, const char *path, const char *name); -int cookie_save(t_cookie * cookie, char *name); -void cookie_insert(char *s, char *ins); -void cookie_delete(char *s, int pos); -char *cookie_get(char *buffer, char *cookie_base, int param); -char *cookie_find(char *s, char *cook_name, char *domain, char *path); +int cookie_save(t_cookie * cookie, const char *name); +void cookie_insert(char *s, const char *ins); +void cookie_delete(char *s, size_t pos); +const char *cookie_get(char *buffer, const char *cookie_base, int param); +char *cookie_find(char *s, const char *cook_name, const char *domain, const char *path); char *cookie_nextfield(char *a); // basic auth -int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth); -char *bauth_check(t_cookie * cookie, char *adr, char *fil); -char *bauth_prefix(char *buffer, char *adr, char *fil); +int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *auth); +char *bauth_check(t_cookie * cookie, const char *adr, const char *fil); +char *bauth_prefix(char *buffer, const char *adr, const char *fil); #endif diff --git a/src/htscache.c b/src/htscache.c index 5cdcc3f..783251a 100644 --- a/src/htscache.c +++ b/src/htscache.c @@ -2016,12 +2016,12 @@ void cache_init(cache_back * cache, httrackp * opt) { // lire un fichier.. (compatible \0) /* Note: NOT utf-8 */ -char *readfile(char *fil) { +char *readfile(const char *fil) { return readfile2(fil, NULL); } /* Note: NOT utf-8 */ -char *readfile2(char *fil, LLint * size) { +char *readfile2(const char *fil, LLint * size) { char *adr = NULL; char catbuff[CATBUFF_SIZE]; INTsys len = 0; @@ -2049,7 +2049,7 @@ char *readfile2(char *fil, LLint * size) { } /* Note: utf-8 */ -char *readfile_utf8(char *fil) { +char *readfile_utf8(const char *fil) { char *adr = NULL; char catbuff[CATBUFF_SIZE]; const off_t len = fsize_utf8(fil); @@ -2074,8 +2074,8 @@ char *readfile_utf8(char *fil) { } /* Note: NOT utf-8 */ -char *readfile_or(char *fil, char *defaultdata) { - char *realfile = fil; +char *readfile_or(const char *fil, const char *defaultdata) { + const char *realfile = fil; char *ret; char catbuff[CATBUFF_SIZE]; @@ -2085,7 +2085,7 @@ char *readfile_or(char *fil, char *defaultdata) { if (ret) return ret; else { - char *adr = malloct(strlen(defaultdata) + 2); + char *adr = malloct(strlen(defaultdata) + 1); if (adr) { strcpybuff(adr, defaultdata); diff --git a/src/htscatchurl.c b/src/htscatchurl.c index 088594f..e14eee6 100644 --- a/src/htscatchurl.c +++ b/src/htscatchurl.c @@ -40,6 +40,7 @@ Please visit our Website: http://www.httrack.com #include "htsbase.h" #include "htsnet.h" #include "htslib.h" +#include "htscore.h" #include #ifdef _WIN32 #else @@ -77,40 +78,25 @@ HTSEXT_API T_SOC catch_url_init_std(int *port_prox, char *adr_prox) { // 1- Init the URL catcher // catch_url_init(&port,&return_host); -HTSEXT_API T_SOC catch_url_init(int *port, char *adr) { +HTSEXT_API T_SOC catch_url_init(int *port, /* 128 bytes */ char *adr) { T_SOC soc = INVALID_SOCKET; - char h_loc[256 + 2]; + char h_loc[256]; - if (gethostname(h_loc, 256) == 0) { // host name + if (gethostname(h_loc, sizeof(h_loc)) == 0) { // host name SOCaddr server; - int server_size = sizeof(server); - t_hostent *hp_loc; - t_fullhostent buffer; - - // effacer structure - memset(&server, 0, sizeof(server)); - - if ((hp_loc = vxgethostbyname(h_loc, &buffer))) { // notre host - - // copie adresse - SOCaddr_copyaddr(server, server_size, hp_loc->h_addr_list[0], - hp_loc->h_length); - + if (hts_dns_resolve_nocache(h_loc, &server) != NULL) { // notre host if ((soc = (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, 0)) != INVALID_SOCKET) { SOCaddr_initport(server, *port); - if (bind(soc, (struct sockaddr *) &server, server_size) == 0) { + if (bind(soc, &SOCaddr_sockaddr(server), SOCaddr_size(server)) == 0) { SOCaddr server2; - SOClen len; + SOClen len = SOCaddr_capacity(server2); - len = sizeof(server2); - // effacer structure - memset(&server2, 0, sizeof(server2)); - if (getsockname(soc, (struct sockaddr *) &server2, &len) == 0) { + if (getsockname(soc, &SOCaddr_sockaddr(server2), &len) == 0) { *port = ntohs(SOCaddr_sinport(server)); // récupérer port - if (listen(soc, 10) >= 0) { // au pif le 10 - SOCaddr_inetntoa(adr, 128, server2, len); + if (listen(soc, 1) >= 0) { + SOCaddr_inetntoa(adr, 128, server2); } else { #ifdef _WIN32 closesocket(soc); @@ -168,15 +154,13 @@ HTSEXT_API int catch_url(T_SOC soc, char *url, char *method, char *data) { /* INFOS */ { SOCaddr server2; - SOClen len = sizeof(server2); + SOClen len = SOCaddr_capacity(server2); - // effacer structure - memset(&server2, 0, sizeof(server2)); - if (getpeername(soc, (struct sockaddr *) &server2, &len) == 0) { + if (getpeername(soc, &SOCaddr_sockaddr(server2), &len) == 0) { char dot[256 + 2]; - SOCaddr_inetntoa(dot, 256, server2, sizeof(server2)); - sprintf(url, "%s:%d", dot, htons(SOCaddr_sinport(server2))); + SOCaddr_inetntoa(dot, sizeof(dot), server2); + sprintf(url, "%s:%d", dot, ntohs(SOCaddr_sinport(server2))); } } /* INFOS */ @@ -191,21 +175,20 @@ HTSEXT_API int catch_url(T_SOC soc, char *url, char *method, char *data) { socinput(soc, line, 1000); if (strnotempty(line)) { if (sscanf(line, "%s %s %s", method, url, protocol) == 3) { - char BIGSTK url_adr[HTS_URLMAXSIZE * 2]; - char BIGSTK url_fil[HTS_URLMAXSIZE * 2]; + lien_adrfil af; // méthode en majuscule size_t i; int r = 0; - url_adr[0] = url_fil[0] = '\0'; + af.adr[0] = af.fil[0] = '\0'; // for(i = 0; method[i] != '\0'; i++) { if ((method[i] >= 'a') && (method[i] <= 'z')) method[i] -= ('a' - 'A'); } // adresse du lien - if (ident_url_absolute(url, url_adr, url_fil) >= 0) { + if (ident_url_absolute(url, &af) >= 0) { // Traitement des en-têtes char BIGSTK loc[HTS_URLMAXSIZE * 2]; htsblk blkretour; @@ -214,7 +197,7 @@ HTSEXT_API int catch_url(T_SOC soc, char *url, char *method, char *data) { //memset(&blkretour, 0, sizeof(htsblk)); // effacer blkretour.location = loc; // si non nul, contiendra l'adresse véritable en cas de moved xx // Lire en têtes restants - sprintf(data, "%s %s %s\r\n", method, url_fil, protocol); + sprintf(data, "%s %s %s\r\n", method, af.fil, protocol); while(strnotempty(line)) { socinput(soc, line, 1000); treathead(NULL, NULL, NULL, &blkretour, line); // traiter diff --git a/src/htscharset.c b/src/htscharset.c index 0184382..50be2d2 100644 --- a/src/htscharset.c +++ b/src/htscharset.c @@ -723,43 +723,21 @@ static unsigned int nlz8(unsigned char x) { 26 U+200000 U+3FFFFFF 5 111110xx 31 U+4000000 U+7FFFFFFF 6 1111110x */ -#define ADD_SEQ(UC, BITS, EMITTER) do { \ - /* number of data bits in first octet */ \ - const unsigned int bits = BITS % 6; \ - /* shift for first octet */ \ - const unsigned int shift0 = BITS - bits; \ - /* first octet */ \ - const unsigned char lead = \ - /* leading bits */ \ - ( 0xff ^ ( ( 1 << ( bits + 1 ) ) - 1 ) ) \ - /* encoded bits */ \ - | ( ( (UC) >> shift0 ) & ( ( 1 << ( bits + 1 ) ) - 1 ) ) \ - ; \ - /* further bytes are encoding 6 bits */ \ - const unsigned char second = \ - 0x80 | ( ( (UC) >> ( shift0 - 6 ) ) & 0x3f ); \ - EMITTER(lead); \ - EMITTER(second); \ - if (BITS > 6*2) { \ - const unsigned char next = \ - 0x80 | ( ( (UC) >> ( shift0 - 6*2 ) ) & 0x3f ); \ - EMITTER(next); \ - if (BITS > 6*3) { \ - const unsigned char next = \ - 0x80 | ( ( (UC) >> ( shift0 - 6*3 ) ) & 0x3f ); \ - EMITTER(next); \ - if (BITS > 6*4) { \ - const unsigned char next = \ - 0x80 | ( ( (UC) >> ( shift0 - 6*4 ) ) & 0x3f ); \ - EMITTER(next); \ - if (BITS > 6*5) { \ - const unsigned char next = \ - 0x80 | ( ( (UC) >> ( shift0 - 6*5 ) ) & 0x3f ); \ - EMITTER(next); \ - } \ - } \ - } \ - } \ +#define ADD_FIRST_SEQ(UC, LEN, EMITTER) do { \ + /* first octet */ \ + const unsigned char lead = \ + /* leading bits: LEN "1" bits */ \ + ~ ( ( 1 << (unsigned) ( 8 - LEN ) ) - 1 ) \ + /* encoded bits */ \ + | ( (UC) >> (unsigned) ( ( LEN - 1 ) * 6 ) ); \ + EMITTER(lead); \ + } while(0) + +#define ADD_NEXT_SEQ(UC, SHIFT, EMITTER) do { \ + /* further bytes are encoding 6 bits */ \ + const unsigned char next = \ + 0x80 | ( ( (UC) >> SHIFT ) & 0x3f ); \ + EMITTER(next); \ } while(0) /* UC is a constant. EMITTER is a macro function taking an unsigned int. */ @@ -767,15 +745,30 @@ static unsigned int nlz8(unsigned char x) { if ((UC) < 0x80) { \ EMITTER(((unsigned char) (UC))); \ } else if ((UC) < 0x0800) { \ - ADD_SEQ(UC, 11, EMITTER); \ + ADD_FIRST_SEQ(UC, 2, EMITTER); \ + ADD_NEXT_SEQ(UC, 0, EMITTER); \ } else if ((UC) < 0x10000) { \ - ADD_SEQ(UC, 16, EMITTER); \ + ADD_FIRST_SEQ(UC, 3, EMITTER); \ + ADD_NEXT_SEQ(UC, 6, EMITTER); \ + ADD_NEXT_SEQ(UC, 0, EMITTER); \ } else if ((UC) < 0x200000) { \ - ADD_SEQ(UC, 21, EMITTER); \ + ADD_FIRST_SEQ(UC, 4, EMITTER); \ + ADD_NEXT_SEQ(UC, 12, EMITTER); \ + ADD_NEXT_SEQ(UC, 6, EMITTER); \ + ADD_NEXT_SEQ(UC, 0, EMITTER); \ } else if ((UC) < 0x4000000) { \ - ADD_SEQ(UC, 26, EMITTER); \ + ADD_FIRST_SEQ(UC, 5, EMITTER); \ + ADD_NEXT_SEQ(UC, 18, EMITTER); \ + ADD_NEXT_SEQ(UC, 12, EMITTER); \ + ADD_NEXT_SEQ(UC, 6, EMITTER); \ + ADD_NEXT_SEQ(UC, 0, EMITTER); \ } else { \ - ADD_SEQ(UC, 31, EMITTER); \ + ADD_FIRST_SEQ(UC, 6, EMITTER); \ + ADD_NEXT_SEQ(UC, 24, EMITTER); \ + ADD_NEXT_SEQ(UC, 18, EMITTER); \ + ADD_NEXT_SEQ(UC, 12, EMITTER); \ + ADD_NEXT_SEQ(UC, 6, EMITTER); \ + ADD_NEXT_SEQ(UC, 0, EMITTER); \ } \ } while(0) @@ -966,24 +959,29 @@ char *hts_convertStringUTF8ToIDNA(const char *s, size_t size) { if (HTS_IS_LEADING_UTF8(c)) { /* commit sequence ? */ if (utfSeq != (size_t) -1) { - /* unicode character */ - punycode_uint uc = 0; /* Reader: can read bytes up to j */ #define RD ( utfSeq < j ? segData[utfSeq++] : -1 ) /* Writer: upon error, return FFFD (replacement character) */ -#define WR(C) uc = C != -1 ? (punycode_uint) C : (punycode_uint) 0xfffd +#define WR(C) do { \ + if ((C) != -1) { \ + /* copy character */ \ + assertf(segOutputSize < segSize); \ + segInt[segOutputSize++] = (C); \ + } \ + /* In case of error, abort. */ \ + else { \ + FREE_BUFFER(); \ + return NULL; \ + } \ +} while(0) - /* Read Unicode character. */ + /* Read/Write Unicode character. */ READ_UNICODE(RD, WR); #undef RD #undef WR - /* copy character */ - assertf(segOutputSize < segSize); - segInt[segOutputSize++] = uc; - /* not anymore in sequence */ utfSeq = (size_t) -1; } diff --git a/src/htsconcat.c b/src/htsconcat.c index c78513f..3553207 100644 --- a/src/htsconcat.c +++ b/src/htsconcat.c @@ -105,7 +105,7 @@ char *fslash(char *catbuff, size_t size, const char *a) { } // extension : html,gif.. -HTSEXT_API char *get_ext(char *catbuff, size_t size, const char *fil) { +HTSEXT_API const char *get_ext(char *catbuff, size_t size, const char *fil) { size_t i, last; RUNTIME_TIME_CHECK_SIZE(size); diff --git a/src/htscore.c b/src/htscore.c index 94ed251..80f7772 100644 --- a/src/htscore.c +++ b/src/htscore.c @@ -61,6 +61,9 @@ Please visit our Website: http://www.httrack.com /* Charset handling */ #include "htscharset.h" +/* Dynamic typed arrays */ +#include "htsarrays.h" + /* END specific definitions */ /* external modules */ @@ -107,12 +110,6 @@ int longest_hash[3] = { 0, 0, 0 }, hashnumber = 0; // Début de httpmirror, routines annexes -// pour alléger la syntaxe, des raccourcis sont créés -#define urladr (liens[ptr]->adr) -#define urlfil (liens[ptr]->fil) -#define savename (liens[ptr]->sav) -//#define level (liens[ptr]->depth) - // au cas où nous devons quitter rapidement xhttpmirror (plus de mémoire, etc) // note: partir de liens_max.. vers 0.. sinon erreur de violation de mémoire: les liens suivants // ne sont plus à nous.. agh! [dur celui-là] @@ -122,20 +119,8 @@ RUN_CALLBACK0(opt, end); \ } #define XH_extuninit do { \ - int i; \ HTMLCHECK_UNINIT \ - if (liens!=NULL) { \ - for(i=lien_max-1;i>=0;i--) { \ - if (liens[i]) { \ - if (liens[i]->firstblock==1) { \ - freet(liens[i]); \ - liens[i]=NULL; \ - } \ - } \ - } \ - freet(liens); \ - liens=NULL; \ - } \ + hts_record_free(opt); \ if (filters && filters[0]) { \ freet(filters[0]); filters[0]=NULL; \ } \ @@ -175,61 +160,252 @@ RUN_CALLBACK0(opt, end); \ } while(0) #define XH_uninit do { XH_extuninit; if (r.adr) { freet(r.adr); r.adr=NULL; } } while(0) -// Enregistrement d'un lien: -// on calcule la taille nécessaire: taille des 3 chaînes à stocker (taille forcée paire, plus 2 octets de sécurité) -// puis on vérifie qu'on a assez de marge dans le buffer - sinon on en réalloue un autre -// enfin on écrit à l'adresse courante du buffer, qu'on incrémente. on décrémente la taille dispo d'autant ensuite -// codebase: si non nul et si .class stockee on le note pour chemin primaire pour classes -// FA,FS: former_adr et former_fil, lien original -#define liens_record_sav_len(A) +struct lien_buffers { + /* Main array of pointers. + This is the real "lien_url **liens" pointer base. */ + TypedArray(lien_url*) ptr; + /* String pool, chunked. */ + char *string_buffer; + size_t string_buffer_size; + size_t string_buffer_capa; + TypedArray(char*) string_buffers; + /* Structure list, chunked. */ + lien_url *lien_buffer; + size_t lien_buffer_size; + size_t lien_buffer_capa; + TypedArray(lien_url*) lien_buffers; +}; -#define liens_record(A,F,S,FA,FF,NORM) { \ -int notecode=0; \ -size_t lienurl_len=((sizeof(lien_url)+HTS_ALIGN-1)/HTS_ALIGN)*HTS_ALIGN,\ - adr_len=strlen(A),\ - fil_len=strlen(F),\ - sav_len=strlen(S),\ - cod_len=0,\ - former_adr_len=strlen(FA),\ - former_fil_len=strlen(FF); \ -if (former_adr_len>0) {\ - former_adr_len=(former_adr_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - former_fil_len=(former_fil_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ -} else former_adr_len=former_fil_len=0;\ -if (strlen(F)>6) if (strnotempty(codebase)) if (strfield(F+strlen(F)-6,".class")) { notecode=1; \ -cod_len=strlen(codebase); cod_len=(cod_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; } \ -adr_len=(adr_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; fil_len=(fil_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; sav_len=(sav_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ -if ((int) lien_size < (int) (adr_len+fil_len+sav_len+cod_len+former_adr_len+former_fil_len+lienurl_len)) { \ -lien_buffer=(char*) ((void*) calloct(add_tab_alloc,1)); \ -lien_size=add_tab_alloc; \ -if (lien_buffer!=NULL) { \ -liens[lien_tot]=(lien_url*) (void*) lien_buffer; lien_buffer+=lienurl_len; lien_size-=lienurl_len; \ -liens[lien_tot]->firstblock=1; \ -} \ -} else { \ -liens[lien_tot]=(lien_url*) (void*) lien_buffer; lien_buffer+=lienurl_len; lien_size-=lienurl_len; \ -liens[lien_tot]->firstblock=0; \ -} \ -if (liens[lien_tot]!=NULL) { \ -liens[lien_tot]->adr=lien_buffer; lien_buffer+=adr_len; lien_size-=adr_len; \ -liens[lien_tot]->fil=lien_buffer; lien_buffer+=fil_len; lien_size-=fil_len; \ -liens[lien_tot]->sav=lien_buffer; lien_buffer+=sav_len; lien_size-=sav_len; \ -liens[lien_tot]->cod=NULL; \ -if (notecode) { liens[lien_tot]->cod=lien_buffer; lien_buffer+=cod_len; lien_size-=cod_len; strcpybuff(liens[lien_tot]->cod,codebase); } \ -if (former_adr_len>0) {\ -liens[lien_tot]->former_adr=lien_buffer; lien_buffer+=former_adr_len; lien_size-=former_adr_len; \ -liens[lien_tot]->former_fil=lien_buffer; lien_buffer+=former_fil_len; lien_size-=former_fil_len; \ -strcpybuff(liens[lien_tot]->former_adr,FA); \ -strcpybuff(liens[lien_tot]->former_fil,FF); \ -}\ -strcpybuff(liens[lien_tot]->adr,A); \ -strcpybuff(liens[lien_tot]->fil,F); \ -strcpybuff(liens[lien_tot]->sav,S); \ -liens_record_sav_len(liens[lien_tot]); \ -hash_write(hashptr,lien_tot); \ -} \ +// duplicate a string, or return NULL upon error (out-of-memory) +static char* hts_record_link_strdup_(httrackp *opt, const char *s) { + static const size_t block_capa = 32768; + lien_buffers *const liensbuf = opt->liensbuf; + const size_t len = strlen(s) + 1; /* including terminating \0 */ + char *s_dup; + + assertf(liensbuf != NULL); + assertf(len < block_capa); + + // not enough capacity ? then create a new chunk + if (len + liensbuf->string_buffer_size > liensbuf->string_buffer_capa) { + // backup current block pointer for later free + if (liensbuf->string_buffer != NULL) { + TypedArrayAdd(liensbuf->string_buffers, liensbuf->string_buffer); + liensbuf->string_buffer = NULL; + liensbuf->string_buffer_size = 0; + } + + // Double capacity for each new chained block + liensbuf->string_buffer_capa = + liensbuf->string_buffer_capa < block_capa + ? block_capa : liensbuf->string_buffer_capa * 2; + + liensbuf->string_buffer = malloct(liensbuf->string_buffer_capa); + if (liensbuf->string_buffer == NULL) { + hts_record_assert_memory_failed(liensbuf->string_buffer_capa); + } + liensbuf->string_buffer_size = 0; + + hts_log_print(opt, LOG_DEBUG, + "reallocated %d new bytes of strings room", + (int) liensbuf->string_buffer_capa); + } + + assertf(len + liensbuf->string_buffer_size <= liensbuf->string_buffer_capa); + s_dup = &liensbuf->string_buffer[liensbuf->string_buffer_size]; + memcpy(s_dup, s, len); + liensbuf->string_buffer_size += len; + + return s_dup; } +static char* hts_record_link_strdup(httrackp *opt, const char *s) { + assertf(opt != NULL); + assertf(s != NULL); + return hts_record_link_strdup_(opt, s); +} + +size_t hts_record_link_latest(httrackp *opt) { + lien_buffers *const liensbuf = opt->liensbuf; + + assertf(TypedArraySize(liensbuf->ptr) != 0); + return TypedArraySize(liensbuf->ptr) - 1; +} + +// returns a new zeroed lien_url entry, +// or (size_t) -1 upon error (out-of-memory) +// the returned index is the osset within opt->liens[] +static size_t hts_record_link_alloc(httrackp *opt) { + static const size_t block_capa = 256; + lien_buffers *const liensbuf = opt->liensbuf; + lien_url *link; + + assertf(opt != NULL); + assertf(liensbuf != NULL); + + // Limit the number of links + if (opt->maxlink > 0 && TypedArraySize(liensbuf->ptr) >= opt->maxlink) { + return (size_t) -1; + } + + // Create a new chunk of lien_url[] + // There are references to item pointers, so we can not just realloc() + if (liensbuf->lien_buffer_size == liensbuf->lien_buffer_capa) { + size_t capa_bytes; + + if (liensbuf->lien_buffer != NULL) { + TypedArrayAdd(liensbuf->lien_buffers, liensbuf->lien_buffer); + liensbuf->lien_buffer_size = 0; + } + + // Double capacity for each new chained block + liensbuf->lien_buffer_capa = + liensbuf->lien_buffer_capa < block_capa + ? block_capa : liensbuf->lien_buffer_capa * 2; + + capa_bytes = liensbuf->lien_buffer_capa*sizeof(*liensbuf->lien_buffer); + liensbuf->lien_buffer = (lien_url*) malloct(capa_bytes); + if (liensbuf->lien_buffer == NULL) { + hts_record_assert_memory_failed(capa_bytes); + } + liensbuf->lien_buffer_size = 0; + + hts_log_print(opt, LOG_DEBUG, "reallocated %d new link placeholders", + (int) liensbuf->lien_buffer_capa); + } + + // Take next lien_url item + assertf(liensbuf->lien_buffer_size < liensbuf->lien_buffer_capa); + link = &liensbuf->lien_buffer[liensbuf->lien_buffer_size++]; + memset(link, 0, sizeof(*link)); + + // Add new lien_url pointer to the array of links + TypedArrayAdd(liensbuf->ptr, link); + + // Ensure we have a guard NULL + TypedArrayAdd(liensbuf->ptr, NULL); + TypedArraySize(liensbuf->ptr)--; + + // Update pointer as it may have changed, + // and update heap top index + opt->liens = TypedArrayElts(liensbuf->ptr); + assertf(TypedArraySize(liensbuf->ptr) != 0); + assertf(TypedArraySize(liensbuf->ptr) < ( (unsigned int) -1 ) / 2); + opt->lien_tot = (int) TypedArraySize(liensbuf->ptr); + + // return tail + return hts_record_link_latest(opt); +} + +void hts_record_init(httrackp *opt) { + if (opt->liensbuf == NULL) { + opt->liensbuf = calloct(sizeof(*opt->liensbuf), 1); + if (opt->liensbuf == NULL) { + hts_record_assert_memory_failed(sizeof(*opt->liensbuf)); + } + } +} + +// wipe records +void hts_record_free(httrackp *opt) { + lien_buffers *const liensbuf = opt->liensbuf; + + if (liensbuf != NULL) { + size_t i; + + TypedArrayFree(liensbuf->ptr); + + if (liensbuf->string_buffer != NULL) { + freet(liensbuf->string_buffer); + liensbuf->string_buffer = NULL; + liensbuf->string_buffer_size = 0; + liensbuf->string_buffer_capa = 0; + } + + for(i = 0 ; i < TypedArraySize(liensbuf->string_buffers) ; i++) { + freet(TypedArrayNth(liensbuf->string_buffers, i)); + TypedArrayNth(liensbuf->string_buffers, i) = NULL; + } + TypedArrayFree(liensbuf->string_buffers); + + if (liensbuf->lien_buffer != NULL) { + freet(liensbuf->lien_buffer); + liensbuf->lien_buffer = NULL; + } + + for(i = 0 ; i < TypedArraySize(liensbuf->lien_buffers) ; i++) { + freet(TypedArrayNth(liensbuf->lien_buffers, i)); + TypedArrayNth(liensbuf->lien_buffers, i) = NULL; + } + TypedArrayFree(liensbuf->lien_buffers); + + freet(opt->liensbuf); + opt->liensbuf = NULL; + } + + opt->liens = NULL; // no longer defined +} + +// adds a new link and returns a non-zero value upon success +static int hts_record_link_(httrackp * opt, + const char *address, const char *file, const char *save, + const char *ref_address, const char *ref_file, + const char *codebase) { + // create a new entry + const size_t lien_tot = hts_record_link_alloc(opt); + lien_url*const link = lien_tot != (size_t) -1 ? opt->liens[lien_tot] : NULL; + if (link == NULL) { + return 0; + } + + // record string fields + if ( (link->adr = hts_record_link_strdup(opt, address)) == NULL + || (link->fil = hts_record_link_strdup(opt, file)) == NULL + || (link->sav = hts_record_link_strdup(opt, save)) == NULL + || (link->former_adr = hts_record_link_strdup(opt, ref_address)) == NULL + || (link->former_fil = hts_record_link_strdup(opt, ref_file)) == NULL + ) { + return 0; + } + + // record codebase for java classes + if (codebase != NULL) { + const size_t len = strlen(file); + if (len > 6 && strncmp(&file[len - 6], ".class", 6) == 0) { + if ((link->cod = hts_record_link_strdup(opt, codebase)) == NULL) { + return 0; + } + } + } + + // add entry in the hashtables + hash_write(opt->hash, lien_tot); + + // success + return 1; +} + +int hts_record_link(httrackp * opt, + const char *address, const char *file, const char *save, + const char *ref_address, const char *ref_file, + const char *codebase) { + const int success = + hts_record_link_(opt, address, file, save, ref_address, ref_file, codebase); + if (!success) { + hts_log_print(opt, LOG_PANIC, "Too many links (links=%ld, limit=%ld)", + (long int) heap_top_index(), (long int) opt->maxlink); + hts_log_print(opt, LOG_INFO, + "To avoid that: use #L option for more links (example: -#L1000000, or -#L0 to disable)"); + } + return success; +} + +void hts_invalidate_link(httrackp * opt, int lpos) { + /* devalidate entry */ + opt->liens[lpos]->pass2 = -1; +} + + #define HT_INDEX_END do { \ if (!makeindex_done) { \ if (makeindex_fp) { \ @@ -240,9 +416,9 @@ if (makeindex_fp) { \ sprintf(tempo,""CRLF, link_escaped); \ } else \ tempo[0]='\0'; \ - fprintf(makeindex_fp,template_footer, \ + hts_template_format(makeindex_fp,template_footer, \ "", \ - tempo \ + tempo, /* EOF */ NULL \ ); \ fflush(makeindex_fp); \ fclose(makeindex_fp); /* à ne pas oublier sinon on passe une nuit blanche */ \ @@ -257,15 +433,9 @@ makeindex_done=1; /* ok c'est fait */ \ // url1 peut être multiple int httpmirror(char *url1, httrackp * opt) { char *primary = NULL; // première page, contenant les liens à scanner - int lien_tot = 0; // nombre de liens pour le moment - lien_url **liens = NULL; // les pointeurs sur les liens hash_struct hash; // système de hachage, accélère la recherche dans les liens hash_struct *const hashptr = &hash; t_cookie BIGSTK cookie; // gestion des cookies - int lien_max = 0; - size_t lien_size = 0; // octets restants dans buffer liens dispo - char *lien_buffer = NULL; // buffer liens actuel - int add_tab_alloc = 256000; // +256K de liens à chaque fois //char* tab_alloc=NULL; int ptr; // pointeur actuel sur les liens @@ -430,31 +600,16 @@ int httpmirror(char *url1, httrackp * opt) { // hash table opt->hash = &hash; - // tableau de pointeurs sur les liens - lien_max = maximum(opt->maxlink, 32); - liens = (lien_url **) malloct(lien_max * sizeof(lien_url *)); // tableau de pointeurs sur les liens - if (liens == NULL) { - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - //XH_uninit; - return 0; - } else { - int i; + // initialize link heap + hts_record_init(opt); - for(i = 0; i < lien_max; i++) { - liens[i] = NULL; - } - } // initialiser ptr et lien_tot ptr = 0; - lien_tot = 0; // initialiser hachage hash_init(opt, &hash, opt->urlhack); // note: we need a cast because of the const - hash.liens = (const lien_url **) liens; - - // we need it - opt->liens = liens; + hash.liens = (const lien_url ***) &opt->liens; // copier adresse(s) dans liste des adresses { @@ -576,13 +731,13 @@ int httpmirror(char *url1, httrackp * opt) { /* OPTIMIZED for fast load */ if (StringNotEmpty(opt->filelist)) { char *filelist_buff = NULL; - off_t filelist_sz = fsize(StringBuff(opt->filelist)); + const size_t filelist_sz = off_t_to_size_t(fsize(StringBuff(opt->filelist))); - if (filelist_sz > 0) { + if (filelist_sz != (size_t) -1) { FILE *fp = fopen(StringBuff(opt->filelist), "rb"); if (fp) { - filelist_buff = malloct(filelist_sz + 2); + filelist_buff = malloct(filelist_sz + 1); if (filelist_buff) { if (fread(filelist_buff, 1, filelist_sz, fp) != filelist_sz) { freet(filelist_buff); @@ -630,32 +785,26 @@ int httpmirror(char *url1, httrackp * opt) { } // lien primaire - liens_record("primary", "/primary", - fslash(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), + if (!hts_record_link(opt, "primary", "/primary", + fslash(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), fconcat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), - StringBuff(opt->path_html_utf8), "index.html")), - "", "", opt->urlhack); - if (liens[lien_tot] == NULL) { // erreur, pas de place réservée - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + 1) * sizeof(lien_url))); + StringBuff(opt->path_html_utf8), "index.html")), + "", "", NULL)) { XH_extuninit; // désallocation mémoire & buffers return 0; } - liens[lien_tot]->testmode = 0; // pas mode test - liens[lien_tot]->link_import = 0; // pas mode import - liens[lien_tot]->depth = opt->depth + 1; // lien de priorité maximale - liens[lien_tot]->pass2 = 0; // 1ère passe - liens[lien_tot]->retry = opt->retry; // lien de priorité maximale - liens[lien_tot]->premier = lien_tot; // premier lien, objet-père=objet - liens[lien_tot]->precedent = lien_tot; // lien précédent - lien_tot++; + heap_top()->testmode = 0; // pas mode test + heap_top()->link_import = 0; // pas mode import + heap_top()->depth = opt->depth + 1; // lien de priorité maximale + heap_top()->pass2 = 0; // 1ère passe + heap_top()->retry = opt->retry; // lien de priorité maximale + heap_top()->premier = heap_top_index(); // premier lien, objet-père=objet + heap_top()->precedent = heap_top_index(); // lien précédent // Initialiser cache { opt->state._hts_in_html_parsing = 4; - if (!RUN_CALLBACK7(opt, loop, NULL, 0, 0, 0, lien_tot, 0, NULL)) { + if (!RUN_CALLBACK7(opt, loop, NULL, 0, 0, 0, opt->lien_tot, 0, NULL)) { opt->state.exit_xh = 1; // exit requested } cache_init(&cache, opt); @@ -669,7 +818,7 @@ int httpmirror(char *url1, httrackp * opt) { int i; for(i = 0; i < lien_tot; i++) { - printf("%d>%s%s as %s\n", i, liens[i]->adr, liens[i]->fil, liens[i]->sav); + printf("%d>%s%s as %s\n", i, heap(i)->adr, heap(i)->fil, heap(i)->sav); } for(i = 0; i < filptr; i++) { printf("%d>filters=%s\n", i, filters[i]); @@ -718,7 +867,7 @@ int httpmirror(char *url1, httrackp * opt) { } } // on n'a pas de liens!! (exemple: httrack www.* impossible sans départ..) - if (lien_tot <= 0) { + if (opt->lien_tot <= 0) { hts_log_print(opt, LOG_ERROR, "You MUST specify at least one complete URL, and not only wildcards!"); } @@ -771,11 +920,11 @@ int httpmirror(char *url1, httrackp * opt) { if (rollover) r = - RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, 0, 0, lien_tot, + RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, 0, 0, opt->lien_tot, (int) (opt->waittime - tl + 24 * 3600), NULL); else r = - RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, 0, 0, lien_tot, + RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, 0, 0, opt->lien_tot, (int) (opt->waittime - tl), NULL); if (!r) { opt->state.exit_xh = 1; // exit requested @@ -843,35 +992,40 @@ int httpmirror(char *url1, httrackp * opt) { if (!error) { // Skip empty/invalid/done in background - if (liens[ptr]) { - while((liens[ptr]) - && ((((urladr != NULL) ? (urladr) : (" "))[0] == '!') - || (((urlfil != NULL) ? (urlfil) : (" "))[0] == '\0') - || ((liens[ptr]->pass2 == -1)) + if (heap(ptr)) { + while(ptr < opt->lien_tot + && (heap(ptr)) + && ((((urladr() != NULL) ? (urladr()) : (" "))[0] == '!') + || (((urlfil() != NULL) ? (urlfil()) : (" "))[0] == '\0') + || ((heap(ptr)->pass2 == -1)) ) ) { // sauter si lien annulé (ou fil vide) - if (liens[ptr] != NULL && liens[ptr]->pass2 == -1) { + if (heap(ptr) != NULL && heap(ptr)->pass2 == -1) { hts_log_print(opt, LOG_DEBUG, "link #%d is ready, skipping: %s%s..", - ptr, ((urladr != NULL) ? (urladr) : (" ")), - ((urlfil != NULL) ? (urlfil) : (" "))); + ptr, ((urladr() != NULL) ? (urladr()) : (" ")), + ((urlfil() != NULL) ? (urlfil()) : (" "))); } else { hts_log_print(opt, LOG_DEBUG, "link #%d seems ready, skipping: %s%s..", ptr, - ((urladr != NULL) ? (urladr) : (" ")), - ((urlfil != NULL) ? (urlfil) : (" "))); + ((urladr() != NULL) ? (urladr()) : (" ")), + ((urlfil() != NULL) ? (urlfil()) : (" "))); } // remove from stats - if (liens[ptr]->pass2 == -1) { + if (heap(ptr)->pass2 == -1) { HTS_STAT.stat_background--; } ptr++; } + // We're done! + if (ptr == opt->lien_tot) { + goto jump_if_done; + } } - if (liens[ptr] != NULL) { // on a qq chose à récupérer? + if (heap(ptr) != NULL) { // on a qq chose à récupérer? - hts_log_print(opt, LOG_DEBUG, "Wait get: %s%s", urladr, urlfil); + hts_log_print(opt, LOG_DEBUG, "Wait get: %s%s", urladr(), urlfil()); #if DEBUG_ROBOTS - if (strcmp(urlfil, "/robots.txt") == 0) { + if (strcmp(urlfil(), "/robots.txt") == 0) { printf("robots.txt detected\n"); } #endif @@ -886,7 +1040,7 @@ int httpmirror(char *url1, httrackp * opt) { strcpybuff(r.contenttype, "text/html"); /*} else if (opt->maxsoc<=0) { // fichiers 1 à 1 en attente (pas de backing) // charger le fichier en mémoire tout bêtement - r=xhttpget(urladr,urlfil); + r=xhttpget(urladr(),urlfil()); // */ } else { // backing, multiples sockets @@ -904,26 +1058,21 @@ int httpmirror(char *url1, httrackp * opt) { memset(&stre, 0, sizeof(stre)); /* */ str.err_msg = buff_err_msg; - str.filename = savename; + str.filename = savename(); str.mime = r.contenttype; - str.url_host = urladr; - str.url_file = urlfil; + str.url_host = urladr(); + str.url_file = urlfil(); str.size = (const int) r.size; /* */ str.addLink = htsAddLink; /* */ - str.liens = liens; str.opt = opt; str.sback = sback; str.cache = &cache; str.hashptr = hashptr; str.numero_passe = numero_passe; - str.add_tab_alloc = add_tab_alloc; /* */ - str.lien_tot_ = &lien_tot; str.ptr_ = &ptr; - str.lien_size_ = &lien_size; - str.lien_buffer_ = &lien_buffer; /* */ str.page_charset_ = NULL; /* */ @@ -941,7 +1090,6 @@ int httpmirror(char *url1, httrackp * opt) { stre.filptr_ = &filptr; stre.robots_ = &robots; stre.hash_ = &hash; - stre.lien_max_ = &lien_max; /* */ stre.makeindex_done_ = &makeindex_done; stre.makeindex_fp_ = &makeindex_fp; @@ -1014,7 +1162,7 @@ int httpmirror(char *url1, httrackp * opt) { error = 0; hts_log_print(opt, LOG_WARNING, "Big file cancelled according to user's preferences: %s%s", - urladr, urlfil); + urladr(), urlfil()); } // // // error=1; // ne pas traiter la suite -- euhh si finalement.. } @@ -1032,15 +1180,15 @@ int httpmirror(char *url1, httrackp * opt) { if (!error) { if (r.statuscode == HTTP_OK) { // OK (ou 304 en backing) if (r.adr) { // Written file - if ((is_hypertext_mime(opt, r.contenttype, urlfil)) + if ((is_hypertext_mime(opt, r.contenttype, urlfil())) /* Is HTML or Js, .. */ /* NO - real media is real media, not HTML */ - /*|| (may_be_hypertext_mime(r.contenttype, urlfil) && (r.adr) ) */ + /*|| (may_be_hypertext_mime(r.contenttype, urlfil()) && (r.adr) ) */ /* Is real media, .. */ ) { if (strnotempty(r.cdispo)) { // Content-disposition set! - if (ishtml(opt, savename) == 0) { // Non HTML!! + if (ishtml(opt, savename()) == 0) { // Non HTML!! // patch it! strcpybuff(r.contenttype, "application/octet-stream"); } @@ -1052,19 +1200,19 @@ int httpmirror(char *url1, httrackp * opt) { /* Load file if necessary and decode. */ #define LOAD_IN_MEMORY_IF_NECESSARY() do { \ if ( \ - may_be_hypertext_mime(opt,r.contenttype, urlfil) /* Is HTML or Js, .. */ \ - && (liens[ptr]->depth>0) /* Depth > 0 (recurse depth) */ \ + may_be_hypertext_mime(opt,r.contenttype, urlfil()) /* Is HTML or Js, .. */ \ + && (heap(ptr)->depth>0) /* Depth > 0 (recurse depth) */ \ && (r.adr==NULL) /* HTML Data exists */ \ && (!store_errpage) /* Not an html error page */ \ - && (savename[0]!='\0') /* Output filename exists */ \ + && (savename()[0]!='\0') /* Output filename exists */ \ ) \ { \ is_loaded_from_file = 1; \ - r.adr = readfile2(savename, &r.size); \ + r.adr = readfile2(savename(), &r.size); \ if (r.adr != NULL) { \ - hts_log_print(opt, LOG_INFO, "File successfully loaded for parsing: %s%s (%d bytes)",urladr,urlfil,(int)r.size); \ + hts_log_print(opt, LOG_INFO, "File successfully loaded for parsing: %s%s (%d bytes)",urladr(),urlfil(),(int)r.size); \ } else { \ - hts_log_print(opt, LOG_ERROR, "File could not be loaded for parsing: %s%s",urladr,urlfil); \ + hts_log_print(opt, LOG_ERROR, "File could not be loaded for parsing: %s%s",urladr(),urlfil()); \ } \ } \ } while(0) @@ -1074,8 +1222,8 @@ int httpmirror(char *url1, httrackp * opt) { // ------------------------------------ // BOGUS MIME TYPE HACK II (the revenge) // Check if we have a bogus MIME type - if (HTTP_IS_OK(r.statuscode) && (is_hypertext_mime(opt, r.contenttype, urlfil) /* Is HTML or Js, .. */ - ||may_be_hypertext_mime(opt, r.contenttype, urlfil)) /* Is real media, .. */ + if (HTTP_IS_OK(r.statuscode) && (is_hypertext_mime(opt, r.contenttype, urlfil()) /* Is HTML or Js, .. */ + ||may_be_hypertext_mime(opt, r.contenttype, urlfil())) /* Is real media, .. */ ) { /* Convert charset to UTF-8 - NOT! (what about links ? remote server side will have troubles with converted names) */ @@ -1212,7 +1360,7 @@ int httpmirror(char *url1, httrackp * opt) { } hts_log_print(opt, LOG_WARNING, "File %s%s converted from UCS2 to UTF-8 (old size: %d bytes, new size: %d bytes)", - urladr, urlfil, (int) r.size, new_offs); + urladr(), urlfil(), (int) r.size, new_offs); freet(r.adr); r.adr = NULL; r.size = new_offs; @@ -1226,8 +1374,8 @@ int httpmirror(char *url1, httrackp * opt) { is_binary = 1; strcpybuff(r.contenttype, "application/octet-stream"); hts_log_print(opt, LOG_WARNING, - "File not parsed, looks like binary: %s%s", urladr, - urlfil); + "File not parsed, looks like binary: %s%s", urladr(), + urlfil()); } /* This hack allows you to avoid problems with parsing '\0' characters */ @@ -1251,14 +1399,14 @@ int httpmirror(char *url1, httrackp * opt) { //if (!error) { // if (r.statuscode == HTTP_OK) { // OK (ou 304 en backing) // if (r.adr==NULL) { // Written file - // if (may_be_hypertext_mime(r.contenttype, urlfil)) { // to parse! + // if (may_be_hypertext_mime(r.contenttype, urlfil())) { // to parse! // LLint sz; - // sz=fsize_utf8(savename); + // sz=fsize_utf8(savename()); // if (sz>0) { // ok, exists! // if (sz < 8192) { // ok, small file --> to parse! - // FILE* fp=FOPEN(savename,"rb"); + // FILE* fp=FOPEN(savename(),"rb"); // if (fp) { - // r.adr=malloct((int)sz + 2); + // r.adr=malloct(sz + 1); // if (r.adr) { // if (fread(r.adr,1,sz,fp) == sz) { // r.size=sz; @@ -1274,7 +1422,7 @@ int httpmirror(char *url1, httrackp * opt) { // fclose(fp); // fp=NULL; // // remove (temporary) file! - // remove(savename); + // remove(savename()); // } // if (fp) // fclose(fp); @@ -1292,8 +1440,8 @@ int httpmirror(char *url1, httrackp * opt) { /* if (!error) { if (ptr>0) { - if (liens[ptr]) { - xxcache_mayadd(opt,&cache,&r,urladr,urlfil,savename); + if (heap(ptr)) { + xxcache_mayadd(opt,&cache,&r,urladr(),urlfil(),savename()); } else error=1; } @@ -1316,26 +1464,21 @@ int httpmirror(char *url1, httrackp * opt) { memset(&stre, 0, sizeof(stre)); /* */ str.err_msg = buff_err_msg; - str.filename = savename; + str.filename = savename(); str.mime = r.contenttype; - str.url_host = urladr; - str.url_file = urlfil; + str.url_host = urladr(); + str.url_file = urlfil(); str.size = (int) r.size; /* */ str.addLink = htsAddLink; /* */ - str.liens = liens; str.opt = opt; str.sback = sback; str.cache = &cache; str.hashptr = hashptr; str.numero_passe = numero_passe; - str.add_tab_alloc = add_tab_alloc; /* */ - str.lien_tot_ = &lien_tot; str.ptr_ = &ptr; - str.lien_size_ = &lien_size; - str.lien_buffer_ = &lien_buffer; /* */ str.page_charset_ = NULL; /* */ @@ -1353,7 +1496,6 @@ int httpmirror(char *url1, httrackp * opt) { stre.filptr_ = &filptr; stre.robots_ = &robots; stre.hash_ = &hash; - stre.lien_max_ = &lien_max; /* */ stre.makeindex_done_ = &makeindex_done; stre.makeindex_fp_ = &makeindex_fp; @@ -1417,14 +1559,14 @@ int httpmirror(char *url1, httrackp * opt) { if (ptr>0) { // "mis à jour" if ((!r.notmodified) && (opt->is_update) && (!store_errpage)) { // page modifiée - if (strnotempty(savename)) { + if (strnotempty(savename())) { HTS_STAT.stat_updated_files++; //if ((opt->debug>0) && (opt->log!=NULL)) { - hts_log_print(opt, LOG_INFO, "File updated: %s%s",urladr,urlfil); + hts_log_print(opt, LOG_INFO, "File updated: %s%s",urladr(),urlfil()); } } else { if (!store_errpage) { - hts_log_print(opt, LOG_INFO, "File recorded: %s%s",urladr,urlfil); + hts_log_print(opt, LOG_INFO, "File recorded: %s%s",urladr(),urlfil()); } } } @@ -1435,14 +1577,14 @@ int httpmirror(char *url1, httrackp * opt) { // ------------------------------------------------------ // traiter - if (!is_binary && ((is_hypertext_mime(opt, r.contenttype, urlfil)) /* Is HTML or Js, .. */ - ||(may_be_hypertext_mime(opt, r.contenttype, urlfil) && r.adr != NULL) /* Is real media, .. */ + if (!is_binary && ((is_hypertext_mime(opt, r.contenttype, urlfil())) /* Is HTML or Js, .. */ + ||(may_be_hypertext_mime(opt, r.contenttype, urlfil()) && r.adr != NULL) /* Is real media, .. */ ) - && (liens[ptr]->depth > 0) /* Depth > 0 (recurse depth) */ + && (heap(ptr)->depth > 0) /* Depth > 0 (recurse depth) */ &&(r.adr != NULL) /* HTML Data exists */ &&(r.size > 0) /* And not empty */ &&(!store_errpage) /* Not an html error page */ - &&(savename[0] != '\0') /* Output filename exists */ + &&(savename()[0] != '\0') /* Output filename exists */ ) { // ne traiter que le html si autorisé // -- -- -- -- // Parsing HTML @@ -1451,7 +1593,7 @@ int httpmirror(char *url1, httrackp * opt) { /* Remove file if being processed */ if (is_loaded_from_file) { - (void) unlink(fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), savename)); + (void) unlink(fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), savename())); is_loaded_from_file = 0; } @@ -1486,15 +1628,15 @@ int httpmirror(char *url1, httrackp * opt) { if (page_charset[0] == '\0') { hts_log_print(opt, LOG_INFO, "Warning: could not detect encoding for: %s%s", - urladr, urlfil); + urladr(), urlfil()); /* Fallback to ISO-8859-1 (~== identity) ; accents will look weird */ strcpy(page_charset, "iso-8859-1"); } } /* Info for wrappers */ - hts_log_print(opt, LOG_INFO, "engine: check-html: %s%s", urladr, - urlfil); + hts_log_print(opt, LOG_INFO, "engine: check-html: %s%s", urladr(), + urlfil()); { char BIGSTK buff_err_msg[1024]; htsmoduleStruct BIGSTK str; @@ -1505,26 +1647,21 @@ int httpmirror(char *url1, httrackp * opt) { memset(&stre, 0, sizeof(stre)); /* */ str.err_msg = buff_err_msg; - str.filename = savename; + str.filename = savename(); str.mime = r.contenttype; - str.url_host = urladr; - str.url_file = urlfil; + str.url_host = urladr(); + str.url_file = urlfil(); str.size = (int) r.size; /* */ str.addLink = htsAddLink; /* */ - str.liens = liens; str.opt = opt; str.sback = sback; str.cache = &cache; str.hashptr = hashptr; str.numero_passe = numero_passe; - str.add_tab_alloc = add_tab_alloc; /* */ - str.lien_tot_ = &lien_tot; str.ptr_ = &ptr; - str.lien_size_ = &lien_size; - str.lien_buffer_ = &lien_buffer; /* */ str.page_charset_ = page_charset[0] != '\0' ? page_charset : NULL; /* */ @@ -1542,7 +1679,6 @@ int httpmirror(char *url1, httrackp * opt) { stre.filptr_ = &filptr; stre.robots_ = &robots; stre.hash_ = &hash; - stre.lien_max_ = &lien_max; /* */ stre.makeindex_done_ = &makeindex_done; stre.makeindex_fp_ = &makeindex_fp; @@ -1581,18 +1717,18 @@ int httpmirror(char *url1, httrackp * opt) { // sauver fichier /* En cas d'erreur, vérifier que fichier d'erreur existe */ - if (strnotempty(savename) == 0) { // chemin de sauvegarde existant - if (strcmp(urlfil, "/robots.txt") == 0) { // pas robots.txt + if (strnotempty(savename()) == 0) { // chemin de sauvegarde existant + if (strcmp(urlfil(), "/robots.txt") == 0) { // pas robots.txt if (store_errpage) { // c'est une page d'erreur int create_html_warning = 0; int create_gif_warning = 0; - switch (ishtml(opt, urlfil)) { /* pas fichier html */ + switch (ishtml(opt, urlfil())) { /* pas fichier html */ case 0: /* non html */ { char buff[256]; - guess_httptype(opt, buff, urlfil); + guess_httptype(opt, buff, urlfil()); if (strcmp(buff, "image/gif") == 0) create_gif_warning = 1; } @@ -1634,8 +1770,8 @@ int httpmirror(char *url1, httrackp * opt) { } } - if (strnotempty(savename) == 0) { // pas de chemin de sauvegarde - if (strcmp(urlfil, "/robots.txt") == 0) { // robots.txt + if (strnotempty(savename()) == 0) { // pas de chemin de sauvegarde + if (strcmp(urlfil(), "/robots.txt") == 0) { // robots.txt if (r.adr) { int bptr = 0; char BIGSTK line[1024]; @@ -1711,7 +1847,7 @@ int httpmirror(char *url1, httrackp * opt) { else { hts_log_print(opt, LOG_NOTICE, "Note: %s robots.txt rules are too restrictive, ignoring /", - urladr); + urladr()); } #endif } @@ -1719,13 +1855,13 @@ int httpmirror(char *url1, httrackp * opt) { } } while((bptr < r.size) && (strlen(buff) < (sizeof(buff) - 32))); if (strnotempty(buff)) { - checkrobots_set(&robots, urladr, buff); + checkrobots_set(&robots, urladr(), buff); hts_log_print(opt, LOG_INFO, "Note: robots.txt forbidden links for %s are: %s", - urladr, infobuff); + urladr(), infobuff); hts_log_print(opt, LOG_NOTICE, "Note: due to %s remote robots.txt rules, links beginning with these path will be forbidden: %s (see in the options to disable this)", - urladr, infobuff); + urladr(), infobuff); } } } @@ -1743,12 +1879,12 @@ int httpmirror(char *url1, httrackp * opt) { // Si par la suite on doit retraiter ce fichier avec un niveau de récursion plus // fort, on supprimera le readme, et on scannera le fichier html! // note: sauté si store_errpage (càd si page d'erreur, non à scanner!) - if ((is_hypertext_mime(opt, r.contenttype, urlfil)) && (!store_errpage) && (r.size > 0)) { // c'est du html!! + if ((is_hypertext_mime(opt, r.contenttype, urlfil())) && (!store_errpage) && (r.size > 0)) { // c'est du html!! char BIGSTK tempo[HTS_URLMAXSIZE * 2]; FILE *fp; tempo[0] = '\0'; - strcpybuff(tempo, savename); + strcpybuff(tempo, savename()); strcatbuff(tempo, ".readme"); #if HTS_DOSNAME @@ -1771,7 +1907,7 @@ int httpmirror(char *url1, httrackp * opt) { HTTRACK_VERSION "%s" CRLF "" CRLF, hts_get_version_info(opt)); fprintf(fp, "The file %s has not been scanned by HTS" CRLF, - savename); + savename()); fprintf(fp, "Some links contained in it may be unreachable locally." CRLF); @@ -1788,15 +1924,15 @@ int httpmirror(char *url1, httrackp * opt) { hts_log_print(opt, LOG_WARNING, "Warning: store %s without scan: %s", r.contenttype, - savename); + savename()); } else { if ((opt->getmode & 2) != 0) { // ok autorisé hts_log_print(opt, LOG_DEBUG, "Store %s: %s", r.contenttype, - savename); + savename()); } else { // lien non autorisé! (ex: cgi-bin en html) hts_log_print(opt, LOG_DEBUG, "non-html file ignored after upload at %s : %s", - urladr, urlfil); + urladr(), urlfil()); if (r.adr) { freet(r.adr); r.adr = NULL; @@ -1808,8 +1944,8 @@ int httpmirror(char *url1, httrackp * opt) { // ATTENTION C'EST ICI QU'ON SAUVE LE FICHIER!! if (r.adr != NULL || r.size == 0) { - file_notify(opt, urladr, urlfil, savename, 1, 1, r.notmodified); - if (filesave(opt, r.adr, (int) r.size, savename, urladr, urlfil) != + file_notify(opt, urladr(), urlfil(), savename(), 1, 1, r.notmodified); + if (filesave(opt, r.adr, (int) r.size, savename(), urladr(), urlfil()) != 0) { int fcheck; @@ -1819,7 +1955,7 @@ int httpmirror(char *url1, httrackp * opt) { opt->state.exit_xh = -1; /* fatal error */ } hts_log_print(opt, LOG_ERROR | LOG_ERRNO, - "Unable to save file %s", savename); + "Unable to save file %s", savename()); } else { /* if (!ishttperror(r.statuscode)) @@ -1834,9 +1970,9 @@ int httpmirror(char *url1, httrackp * opt) { /* Parsing of other media types (java, ram..) */ /* if (strfield2(r.contenttype,"audio/x-pn-realaudio")) { - hts_log_print(opt, LOG_DEBUG, "(Real Media): parsing %s",savename); - if (fexist(savename)) { // ok, existe bien! - FILE* fp=FOPEN(savename,"r+b"); + hts_log_print(opt, LOG_DEBUG, "(Real Media): parsing %s",savename()); + if (fexist(savename())) { // ok, existe bien! + FILE* fp=FOPEN(savename(),"r+b"); if (fp) { if (!fseek(fp,0,SEEK_SET)) { char BIGSTK line[HTS_URLMAXSIZE*2]; @@ -1852,7 +1988,7 @@ int httpmirror(char *url1, httrackp * opt) { /* External modules */ if (opt->parsejava && (opt->parsejava & HTSPARSE_NO_CLASS) == 0 - && fexist(savename)) { + && fexist(savename())) { char BIGSTK buff_err_msg[1024]; htsmoduleStruct BIGSTK str; @@ -1860,37 +1996,32 @@ int httpmirror(char *url1, httrackp * opt) { memset(&str, 0, sizeof(str)); /* */ str.err_msg = buff_err_msg; - str.filename = savename; + str.filename = savename(); str.mime = r.contenttype; - str.url_host = urladr; - str.url_file = urlfil; + str.url_host = urladr(); + str.url_file = urlfil(); str.size = (int) r.size; /* */ str.addLink = htsAddLink; /* */ - str.liens = liens; str.opt = opt; str.sback = sback; str.cache = &cache; str.hashptr = hashptr; str.numero_passe = numero_passe; - str.add_tab_alloc = add_tab_alloc; - /* */ - str.lien_tot_ = &lien_tot; str.ptr_ = &ptr; - str.lien_size_ = &lien_size; - str.lien_buffer_ = &lien_buffer; + /* Parse if recognized */ switch (hts_parse_externals(&str)) { case 1: hts_log_print(opt, LOG_DEBUG, "(External module): parsed successfully %s", - savename); + savename()); break; case 0: hts_log_print(opt, LOG_DEBUG, "(External module): couldn't parse successfully %s : %s", - savename, str.err_msg); + savename(), str.err_msg); break; } } @@ -1898,8 +2029,8 @@ int httpmirror(char *url1, httrackp * opt) { } // text/html ou autre /* Post-processing */ - if (fexist(savename)) { - usercommand(opt, 0, NULL, savename, urladr, urlfil); + if (fexist(savename())) { + usercommand(opt, 0, NULL, savename(), urladr(), urlfil()); } } // if !error @@ -1918,19 +2049,19 @@ int httpmirror(char *url1, httrackp * opt) { if (opt->getmode & 4) { // sauver les non html après // sauter les fichiers selon la passe if (!numero_passe) { - while((ptr < lien_tot) ? (liens[ptr]->pass2) : 0) + while((ptr < opt->lien_tot) ? (heap(ptr)->pass2) : 0) ptr++; } else { - while((ptr < lien_tot) ? (!liens[ptr]->pass2) : 0) + while((ptr < opt->lien_tot) ? (!heap(ptr)->pass2) : 0) ptr++; } - if (ptr >= lien_tot) { // fin de boucle + if (ptr >= opt->lien_tot) { // fin de boucle if (!numero_passe) { // première boucle hts_log_print(opt, LOG_DEBUG, "Now getting non-html files..."); numero_passe = 1; // seconde boucle ptr = 0; // prochain pass2 - while((ptr < lien_tot) ? (!liens[ptr]->pass2) : 0) + while((ptr < opt->lien_tot) ? (!heap(ptr)->pass2) : 0) ptr++; //printf("first link==%d\n"); @@ -1944,16 +2075,16 @@ int httpmirror(char *url1, httrackp * opt) { //} // a-t-on dépassé le quota? if (!back_checkmirror(opt)) { - ptr = lien_tot; + ptr = opt->lien_tot; } else if (opt->state.exit_xh) { // sortir if (opt->state.exit_xh == 1) { hts_log_print(opt, LOG_ERROR, "Exit requested by shell or user"); } else { hts_log_print(opt, LOG_ERROR, "Exit requested by engine"); } - ptr = lien_tot; + ptr = opt->lien_tot; } - } while(ptr < lien_tot); + } while(ptr < opt->lien_tot); // // // @@ -2040,15 +2171,15 @@ int httpmirror(char *url1, httrackp * opt) { (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/old.lst"), "rb"); if (old_lst) { - off_t sz = - fsize(fconcat + const size_t sz = + off_t_to_size_t(fsize(fconcat (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), - "hts-cache/new.lst")); + "hts-cache/new.lst"))); new_lst = fopen(fconcat (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_log), "hts-cache/new.lst"), "rb"); - if ((new_lst) && (sz > 0)) { + if (new_lst != NULL && sz != (size_t) -1) { char *adr = (char *) malloct(sz); if (adr) { @@ -2155,7 +2286,7 @@ int httpmirror(char *url1, httrackp * opt) { "HTTrack Website Copier/" HTTRACK_VERSION " mirror complete in %s : " "%d links scanned, %d files written (" LLintP " bytes overall)%s " "[" LLintP " bytes received at " LLintP - " bytes/sec]", htstime, (int) lien_tot - 1, + " bytes/sec]", htstime, (int) opt->lien_tot - 1, (int) HTS_STAT.stat_files, (LLint) HTS_STAT.stat_bytes, infoupdated, (LLint) HTS_STAT.HTS_TOTAL_RECV, (LLint) n); @@ -2280,8 +2411,8 @@ int engine_stats(void) { #define _ROBOTS ((robots_wizard*)opt->robotsptr) // bannir host (trop lent etc) -void host_ban(httrackp * opt, lien_url ** liens, int ptr, int lien_tot, - struct_back * sback, char *host) { +void host_ban(httrackp * opt, int ptr, + struct_back * sback, const char *host) { lien_back *const back = sback->lnk; const int back_max = sback->count; @@ -2342,20 +2473,20 @@ void host_ban(httrackp * opt, lien_url ** liens, int ptr, int lien_tot, // effacer liens //l=strlen(host); - for(i = 0; i < lien_tot; i++) { - //if (liens[i]->adr_len==l) { // même taille de chaîne + for(i = 0; i < opt->lien_tot; i++) { + //if (heap(i)->adr_len==l) { // même taille de chaîne // Calcul de taille sécurisée - if (liens[i]) { - if (liens[i]->adr) { + if (heap(i)) { + if (heap(i)->adr) { int l = 0; - while((liens[i]->adr[l]) && (l < 1020)) + while((heap(i)->adr[l]) && (l < 1020)) l++; if ((l > 0) && (l < 1020)) { // sécurité - if (strfield2(jump_identification(liens[i]->adr), host)) { // host - hts_log_print(opt, LOG_DEBUG, "Cancel: %s%s", liens[i]->adr, - liens[i]->fil); - strcpybuff(liens[i]->adr, "!"); // cancel (invalide hash) + if (strfield2(jump_identification(heap(i)->adr), host)) { // host + hts_log_print(opt, LOG_DEBUG, "Cancel: %s%s", heap(i)->adr, + heap(i)->fil); + hts_invalidate_link(opt, i); // invalidate hashtable entry // on efface pas le hash, because si on rencontre le lien, reverif sav.. } } else { @@ -2363,13 +2494,13 @@ void host_ban(httrackp * opt, lien_url ** liens, int ptr, int lien_tot, char dmp[1040]; dmp[0] = '\0'; - strncatbuff(dmp, liens[i]->adr, 1024); + strncatbuff(dmp, heap(i)->adr, 1024); hts_log_print(opt, LOG_WARNING, "WARNING! HostCancel detected memory leaks [len %d at %d]", l, i); hts_log_print(opt, LOG_WARNING, "dump 1024 bytes (address %p): " LF "%s", - liens[i]->adr, dmp); + heap(i)->adr, dmp); } } } else { @@ -3120,7 +3251,8 @@ void check_rate(TStamp stat_timestart, int maxrate) { // sous routines liées au moteur et au backing // supplemental links ready (done) after ptr or ready in background -int backlinks_done(struct_back * sback, lien_url ** liens, int lien_tot, +int backlinks_done(const struct_back * sback, + lien_url ** liens, int lien_tot, int ptr) { int n = 0; @@ -3129,8 +3261,8 @@ int backlinks_done(struct_back * sback, lien_url ** liens, int lien_tot, //Links done and stored in cache for(i = ptr + 1; i < lien_tot; i++) { - if (liens[i]) { - if (liens[i]->pass2 == -1) { + if (heap(i)) { + if (heap(i)->pass2 == -1) { n++; } } @@ -3145,11 +3277,11 @@ int backlinks_done(struct_back * sback, lien_url ** liens, int lien_tot, // remplir backing si moins de max_bytes en mémoire HTS_INLINE int back_fillmax(struct_back * sback, httrackp * opt, - cache_back * cache, lien_url ** liens, int ptr, - int numero_passe, int lien_tot) { + cache_back * cache, int ptr, + int numero_passe) { if (!opt->state.stop) { if (back_incache(sback) < opt->maxcache) { // pas trop en mémoire? - return back_fill(sback, opt, cache, liens, ptr, numero_passe, lien_tot); + return back_fill(sback, opt, cache, ptr, numero_passe); } } return -1; /* plus de place */ @@ -3196,7 +3328,7 @@ int back_pluggable_sockets(struct_back * sback, httrackp * opt) { // remplir backing int back_fill(struct_back * sback, httrackp * opt, cache_back * cache, - lien_url ** liens, int ptr, int numero_passe, int lien_tot) { + int ptr, int numero_passe) { int n = back_pluggable_sockets(sback, opt); if (opt->savename_delayed == 2 && !opt->delayed_cached) /* cancel (always delayed) */ @@ -3212,12 +3344,12 @@ int back_fill(struct_back * sback, httrackp * opt, cache_back * cache, /* on a déja parcouru */ if (p < cache->ptr_ant) p = cache->ptr_ant; - while((p < lien_tot) && (n > 0) && back_checkmirror(opt)) { + while(p < opt->lien_tot && n > 0 && back_checkmirror(opt)) { //while((p0) && (p < ptr+opt->maxcache_anticipate)) { int ok = 1; // on ne met pas le fichier en backing si il doit être traité après ou s'il a déja été traité - if (liens[p]->pass2) { // 2è passe + if (heap(p)->pass2) { // 2è passe if (numero_passe != 1) ok = 0; } else { @@ -3226,24 +3358,24 @@ int back_fill(struct_back * sback, httrackp * opt, cache_back * cache, } // Why in hell did I do that ? - //if (ok && liens[p]->sav != NULL && liens[p]->sav[0] != '\0' - // && hash_read(opt->hash,liens[p]->sav,NULL,HASH_STRUCT_FILENAME ) >= 0) // lookup in liens_record + //if (ok && heap(p)->sav != NULL && heap(p)->sav[0] != '\0' + // && hash_read(opt->hash,heap(p)->sav,NULL,HASH_STRUCT_FILENAME ) >= 0) // lookup in liens_record //{ // ok = 0; //} - if (liens[p]->sav == NULL || liens[p]->sav[0] == '\0' - || hash_read(opt->hash, liens[p]->sav, NULL, HASH_STRUCT_FILENAME ) < 0) { + if (heap(p)->sav == NULL || heap(p)->sav[0] == '\0' + || hash_read(opt->hash, heap(p)->sav, NULL, HASH_STRUCT_FILENAME ) < 0) { ok = 0; } // note: si un backing est fini, il reste en mémoire jusqu'à ce que // le ptr l'atteigne if (ok) { if (!back_exist - (sback, opt, liens[p]->adr, liens[p]->fil, liens[p]->sav)) { + (sback, opt, heap(p)->adr, heap(p)->fil, heap(p)->sav)) { if (back_add - (sback, opt, cache, liens[p]->adr, liens[p]->fil, liens[p]->sav, - liens[liens[p]->precedent]->adr, liens[liens[p]->precedent]->fil, - liens[p]->testmode) == -1) { + (sback, opt, cache, heap(p)->adr, heap(p)->fil, heap(p)->sav, + heap(heap(p)->precedent)->adr, heap(heap(p)->precedent)->fil, + heap(p)->testmode) == -1) { hts_log_print(opt, LOG_DEBUG, "error: unable to add more links through back_add for back_fill"); #if BDEBUG==1 @@ -3253,7 +3385,7 @@ int back_fill(struct_back * sback, httrackp * opt, cache_back * cache, } else { n--; #if BDEBUG==1 - printf("backing: %s%s\n", liens[p]->adr, liens[p]->fil); + printf("backing: %s%s\n", heap(p)->adr, heap(p)->fil); #endif } } @@ -3606,8 +3738,7 @@ int htsAddLink(htsmoduleStruct * str, char *link) { if (link != NULL && str != NULL && link[0] != '\0') { ENGINE_LOAD_CONTEXT_BASE(); /* */ - char BIGSTK adr[HTS_URLMAXSIZE * 2], fil[HTS_URLMAXSIZE * 2], - save[HTS_URLMAXSIZE * 2]; + lien_adrfilsave afs; char BIGSTK codebase[HTS_URLMAXSIZE * 2]; /* */ @@ -3634,17 +3765,17 @@ int htsAddLink(htsmoduleStruct * str, char *link) { } // adr = c'est la même // fil et save: save2 et fil2 - prio_fix = maximum(liens[ptr]->depth - 1, 0); - pass_fix = max(liens[ptr]->pass2, numero_passe); - if (liens[ptr]->cod) - strcpybuff(codebase, liens[ptr]->cod); // codebase valable pour tt les classes descendantes + prio_fix = maximum(heap(ptr)->depth - 1, 0); + pass_fix = max(heap(ptr)->pass2, numero_passe); + if (heap(ptr)->cod) + strcpybuff(codebase, heap(ptr)->cod); // codebase valable pour tt les classes descendantes if (strnotempty(codebase) == 0) { // pas de codebase, construire char *a; if (str->relativeToHtmlLink == 0) - strcpybuff(codebase, liens[ptr]->fil); + strcpybuff(codebase, heap(ptr)->fil); else - strcpybuff(codebase, liens[liens[ptr]->precedent]->fil); + strcpybuff(codebase, heap(heap(ptr)->precedent)->fil); a = codebase + strlen(codebase) - 1; while((*a) && (*a != '/') && (a > codebase)) a--; @@ -3678,14 +3809,13 @@ int htsAddLink(htsmoduleStruct * str, char *link) { if (strnotempty(lien) && strlen(lien) < HTS_URLMAXSIZE) { // calculer les chemins et noms de sauvegarde - if (ident_url_relatif(lien, urladr, codebase, adr, fil) >= 0) { // reformage selon chemin + if (ident_url_relatif(lien, urladr(), codebase, &afs.af) >= 0) { // reformage selon chemin int r; int set_prio_to = 0; int just_test_it = 0; forbidden_url = - hts_acceptlink(opt, ptr, lien_tot, liens, adr, fil, NULL, NULL, - &set_prio_to, &just_test_it); + hts_acceptlink(opt, ptr, afs.af.adr, afs.af.fil, NULL, NULL, &set_prio_to, &just_test_it); hts_log_print(opt, LOG_DEBUG, "result for wizard external module link: %d", forbidden_url); @@ -3702,29 +3832,26 @@ int htsAddLink(htsmoduleStruct * str, char *link) { opt->savename_83 = 0; // note: adr,fil peuvent être patchés r = - url_savename(adr, fil, save, NULL, NULL, NULL, NULL, opt, liens, - lien_tot, sback, cache, hashptr, ptr, numero_passe, + url_savename(&afs, NULL, NULL, NULL, opt, sback, cache, hashptr, ptr, numero_passe, NULL); // resolve unresolved type - if (r != -1 && forbidden_url == 0 && IS_DELAYED_EXT(save) + if (r != -1 && forbidden_url == 0 && IS_DELAYED_EXT(afs.save) ) { // pas d'erreur, on continue - char BIGSTK former_adr[HTS_URLMAXSIZE * 2]; - char BIGSTK former_fil[HTS_URLMAXSIZE * 2]; + lien_adrfil former; - former_adr[0] = former_fil[0] = '\0'; + former.adr[0] = former.fil[0] = '\0'; r = - hts_wait_delayed(str, adr, fil, save, NULL, NULL, former_adr, - former_fil, &forbidden_url); + hts_wait_delayed(str, &afs, NULL, NULL, &former, &forbidden_url); } // end resolve unresolved type opt->savename_type = a; opt->savename_83 = b; if (r != -1 && !forbidden_url) { - if (savename) { - if (lienrelatif(tempo, save, savename) == 0) { + if (savename()) { + if (lienrelatif(tempo, afs.save, savename()) == 0) { hts_log_print(opt, LOG_DEBUG, "(module): relative link at %s build with %s and %s: %s", - adr, save, savename, tempo); + afs.af.adr, afs.save, savename(), tempo); if (str->localLink && str->localLinkSize > (int) strlen(tempo) + 1) { strcpybuff(str->localLink, tempo); @@ -3738,19 +3865,19 @@ int htsAddLink(htsmoduleStruct * str, char *link) { hts_log_print(opt, LOG_DEBUG, "(module): file not caught: %s", lien); if (str->localLink - && str->localLinkSize > (int) (strlen(adr) + strlen(fil) + 8)) { + && str->localLinkSize > (int) (strlen(afs.af.adr) + strlen(afs.af.fil) + 8)) { str->localLink[0] = '\0'; - if (!link_has_authority(adr)) + if (!link_has_authority(afs.af.adr)) strcpybuff(str->localLink, "http://"); - strcatbuff(str->localLink, adr); - strcatbuff(str->localLink, fil); + strcatbuff(str->localLink, afs.af.adr); + strcatbuff(str->localLink, afs.af.fil); } r = -1; } // if (r != -1) { - hts_log_print(opt, LOG_DEBUG, "(module): %s%s -> %s (base %s)", adr, - fil, save, codebase); + hts_log_print(opt, LOG_DEBUG, "(module): %s%s -> %s (base %s)", afs.af.adr, + afs.af.fil, afs.save, codebase); // modifié par rapport à l'autre version (cf prio_fix notamment et save2) @@ -3760,10 +3887,10 @@ int htsAddLink(htsmoduleStruct * str, char *link) { // // On part de la fin et on essaye de se presser (économise temps machine) { - int i = hash_read(hashptr, save, NULL, HASH_STRUCT_FILENAME ); // lecture type 0 (sav) + int i = hash_read(hashptr, afs.save, NULL, HASH_STRUCT_FILENAME ); // lecture type 0 (sav) if (i >= 0) { - liens[i]->depth = maximum(liens[i]->depth, prio_fix); + heap(i)->depth = maximum(heap(i)->depth, prio_fix); dejafait = 1; } } @@ -3773,43 +3900,36 @@ int htsAddLink(htsmoduleStruct * str, char *link) { // >>>> CREER LE LIEN JAVA <<<< // enregistrer fichier (MACRO) - liens_record(adr, fil, save, "", "", opt->urlhack); - if (liens[lien_tot] == NULL) { // erreur, pas de place réservée - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + 1) * sizeof(lien_url))); + if (!hts_record_link(opt, afs.af.adr, afs.af.fil, afs.save, "", "", "")) { // erreur, pas de place réservée opt->state.exit_xh = -1; /* fatal error -> exit */ return 0; } // mode test? - liens[lien_tot]->testmode = 0; // pas mode test - - liens[lien_tot]->link_import = 0; // pas mode import + heap_top()->testmode = 0; // pas mode test + heap_top()->link_import = 0; // pas mode import // écrire autres paramètres de la structure-lien //if (meme_adresse) - liens[lien_tot]->premier = liens[ptr]->premier; + heap_top()->premier = heap(ptr)->premier; //else // sinon l'objet père est le précédent lui même - // liens[lien_tot]->premier=ptr; + // heap_top()->premier=ptr; - liens[lien_tot]->precedent = ptr; + heap_top()->precedent = ptr; // noter la priorité if (!set_prio_to) - liens[lien_tot]->depth = prio_fix; + heap_top()->depth = prio_fix; else - liens[lien_tot]->depth = max(0, min(liens[ptr]->depth - 1, set_prio_to - 1)); // PRIORITE NULLE (catch page) - liens[lien_tot]->pass2 = max(pass_fix, numero_passe); - liens[lien_tot]->retry = opt->retry; + heap_top()->depth = max(0, min(heap(ptr)->depth - 1, set_prio_to - 1)); // PRIORITE NULLE (catch page) + heap_top()->pass2 = max(pass_fix, numero_passe); + heap_top()->retry = opt->retry; - //strcpybuff(liens[lien_tot]->adr,adr); - //strcpybuff(liens[lien_tot]->fil,fil); - //strcpybuff(liens[lien_tot]->sav,save); + //strcpybuff(heap_top()->adr,adr); + //strcpybuff(heap_top()->fil,fil); + //strcpybuff(heap_top()->sav,save); hts_log_print(opt, LOG_DEBUG, "(module): OK, NOTE: %s%s -> %s", - liens[lien_tot]->adr, liens[lien_tot]->fil, - liens[lien_tot]->sav); + heap_top()->adr, heap_top()->fil, + heap_top()->sav); - lien_tot++; // UN LIEN DE PLUS } } } diff --git a/src/htscore.h b/src/htscore.h index f082d11..48785f7 100644 --- a/src/htscore.h +++ b/src/htscore.h @@ -129,78 +129,24 @@ typedef struct filecreate_params filecreate_params; #include "hts-indextmpl.h" -// structure d'un lien -#ifndef HTS_DEF_FWSTRUCT_lien_url -#define HTS_DEF_FWSTRUCT_lien_url -typedef struct lien_url lien_url; +// adr, fil +#ifndef HTS_DEF_FWSTRUCT_lien_adrfil +#define HTS_DEF_FWSTRUCT_lien_adrfil +typedef struct lien_adrfil lien_adrfil; #endif -struct lien_url { - char firstblock; // flag 1=premier malloc - char link_import; // lien importé à la suite d'un moved - ne pas appliquer les règles classiques up/down - int depth; // profondeur autorisée lien ; >0 forte 0=faible - int pass2; // traiter après les autres, seconde passe. si == -1, lien traité en background - int premier; // pointeur sur le premier lien qui a donné lieu aux autres liens du domaine - int precedent; // pointeur sur le lien qui a donné lieu à ce lien précis - //int moved; // pointeur sur moved - int retry; // nombre de retry restants - int testmode; // mode test uniquement, envoyer juste un head! - char *adr; // adresse - char *fil; // nom du fichier distant - char *sav; // nom à sauver sur disque (avec chemin éventuel) - char *cod; // chemin codebase éventuel si classe java - char *former_adr; // adresse initiale (avant éventuel moved), peut être nulle - char *former_fil; // nom du fichier distant initial (avant éventuel moved), peut être nul +struct lien_adrfil { + char adr[HTS_URLMAXSIZE * 2]; // adresse + char fil[HTS_URLMAXSIZE * 2]; // nom du fichier distant }; -// chargement de fichiers en 'arrière plan' -#ifndef HTS_DEF_FWSTRUCT_lien_back -#define HTS_DEF_FWSTRUCT_lien_back -typedef struct lien_back lien_back; -#endif -struct lien_back { -#if DEBUG_CHECKINT - char magic; -#endif - char url_adr[HTS_URLMAXSIZE * 2]; // adresse - char url_fil[HTS_URLMAXSIZE * 2]; // nom du fichier distant - char url_sav[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel) - char referer_adr[HTS_URLMAXSIZE * 2]; // adresse host page referer - char referer_fil[HTS_URLMAXSIZE * 2]; // fichier page referer - char location_buffer[HTS_URLMAXSIZE * 2]; // "location" en cas de "moved" (302,..) - char *tmpfile; // nom à sauver temporairement (compressé) - char tmpfile_buffer[HTS_URLMAXSIZE * 2]; // buffer pour le nom à sauver temporairement - char send_too[1024]; // données à envoyer en même temps que le header - int status; // status (-1=non utilisé, 0: prêt, >0: opération en cours) - int locked; // locked (to be used soon) - int testmode; // mode de test - int timeout; // gérer des timeouts? (!=0 : nombre de secondes) - TStamp timeout_refresh; // si oui, time refresh - int rateout; // timeout refresh? (!=0 : taux minimum toléré en octets/s) - TStamp rateout_time; // si oui, date de départ - LLint maxfile_nonhtml; // taille max d'un fichier non html - LLint maxfile_html; // idem pour un ficheir html - htsblk r; // structure htsblk de chaque objet en background - int is_update; // mode update - int head_request; // requète HEAD? - LLint range_req_size; // range utilisé - TStamp ka_time_start; // refresh time for KA - // - int http11; // L'en tête doit être signé HTTP/1.1 et non HTTP/1.0 - int is_chunk; // chunk? - char *chunk_adr; // adresse chunk en cours de chargement - LLint chunk_size; // taille chunk en cours de chargement - LLint chunk_blocksize; // taille data declaree par le chunk - LLint compressed_size; // taille compressés (stats uniquement) - // - //int links_index; // to access liens[links_index] - // - char info[256]; // éventuel status pour le ftp - int stop_ftp; // flag stop pour ftp - int finalized; // finalized (optim memory) - int early_add; // was added before link heap saw it -#if DEBUG_CHECKINT - char magic2; +// adr, fil, save +#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave +#define HTS_DEF_FWSTRUCT_lien_adrfilsave +typedef struct lien_adrfilsave lien_adrfilsave; #endif +struct lien_adrfilsave { + lien_adrfil af; + char save[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel) }; #ifndef HTS_DEF_FWSTRUCT_struct_back @@ -255,7 +201,7 @@ typedef struct hash_struct hash_struct; #endif struct hash_struct { /* Links big array reference */ - const lien_url **liens; + const lien_url ***liens; /* Savename (case insensitive ; lowercased) */ inthash sav; /* Address and path */ @@ -278,6 +224,20 @@ struct filecreate_params { char path[HTS_URLMAXSIZE * 2]; }; +/* Access macros. */ +#define heap(N) (opt->liens[N]) +#define heap_top_index() (opt->lien_tot - 1) +#define heap_top() (heap(heap_top_index())) +#define urladr() (heap(ptr)->adr) +#define urlfil() (heap(ptr)->fil) +#define savename() (heap(ptr)->sav) +#define parenturladr() (heap(heap(ptr)->precedent)->adr) +#define parenturlfil() (heap(heap(ptr)->precedent)->fil) +#define parentsavename() (heap(heap(ptr)->precedent)->sav) +#define relativeurladr() ((!parent_relative)?urladr():parenturladr()) +#define relativeurlfil() ((!parent_relative)?urlfil():parenturlfil()) +#define relativesavename() ((!parent_relative)?savename():parentsavename()) + /* Library internal definictions */ #ifdef HTS_INTERNAL_BYTECODE @@ -302,7 +262,21 @@ char *hts_cancel_file_pop(httrackp * opt); #endif -// +// add a link on the heap +int hts_record_link(httrackp * opt, + const char *address, const char *file, const char *save, + const char *ref_address, const char *ref_file, + const char *codebase); + +// index of the latest added link +size_t hts_record_link_latest(httrackp *opt); + +// invalidate an entry +void hts_invalidate_link(httrackp * opt, int lpos); + +// wipe all records +void hts_record_init(httrackp *opt); +void hts_record_free(httrackp *opt); //int httpmirror(char* url,int level,httrackp opt); int httpmirror(char *url1, httrackp * opt); @@ -312,8 +286,7 @@ int filesave(httrackp * opt, const char *adr, int len, const char *s, char *hts_cancel_file_pop(httrackp * opt); int check_fatal_io_errno(void); int engine_stats(void); -void host_ban(httrackp * opt, lien_url ** liens, int ptr, int lien_tot, - struct_back * sback, char *host); +void host_ban(httrackp * opt, int ptr, struct_back * sback, const char *host); FILE *filecreate(filenote_strc * strct, const char *s); FILE *fileappend(filenote_strc * strct, const char *s); int filecreateempty(filenote_strc * strct, const char *filename); @@ -329,10 +302,10 @@ int fspc(httrackp * opt, FILE * fp, const char *type); char *next_token(char *p, int flag); // -char *readfile(char *fil); -char *readfile2(char *fil, LLint * size); -char *readfile_utf8(char *fil); -char *readfile_or(char *fil, char *defaultdata); +char *readfile(const char *fil); +char *readfile2(const char *fil, LLint * size); +char *readfile_utf8(const char *fil); +char *readfile_or(const char *fil, const char *defaultdata); #if 0 void check_rate(TStamp stat_timestart, int maxrate); @@ -346,11 +319,11 @@ int liens_record(char *adr, char *fil, char *save, char *former_adr, int back_pluggable_sockets(struct_back * sback, httrackp * opt); int back_pluggable_sockets_strict(struct_back * sback, httrackp * opt); int back_fill(struct_back * sback, httrackp * opt, cache_back * cache, - lien_url ** liens, int ptr, int numero_passe, int lien_tot); -int backlinks_done(struct_back * sback, lien_url ** liens, int lien_tot, - int ptr); + int ptr, int numero_passe); +int backlinks_done(const struct_back * sback, lien_url ** liens, + int lien_tot, int ptr); int back_fillmax(struct_back * sback, httrackp * opt, cache_back * cache, - lien_url ** liens, int ptr, int numero_passe, int lien_tot); + int ptr, int numero_passe); int ask_continue(httrackp * opt); int nombre_digit(int n); @@ -374,7 +347,6 @@ int htsAddLink(htsmoduleStruct * str, char *link); // Void void voidf(void); - #define HTS_TOPINDEX "TOP_INDEX_HTTRACK" #endif diff --git a/src/htscoremain.c b/src/htscoremain.c index 77dc93a..e5af672 100644 --- a/src/htscoremain.c +++ b/src/htscoremain.c @@ -45,6 +45,7 @@ Please visit our Website: http://www.httrack.com #include "htszlib.h" #include "htscharset.h" #include "htsencoding.h" +#include "htsmd5.h" #include #if USE_BEGINTHREAD @@ -2006,8 +2007,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { cache.hashtable = (void *) cache_hashtable; /* copy backcache hash */ cache.ro = 1; /* read only */ if (cache.hashtable) { - char BIGSTK adr[HTS_URLMAXSIZE * 2]; - char BIGSTK fil[HTS_URLMAXSIZE * 2]; + lien_adrfilsave afs; char BIGSTK url[HTS_URLMAXSIZE * 2]; char linepos[256]; int pos; @@ -2030,52 +2030,50 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { /* */ a++; /* read "host/file" */ - a += binput(a, adr, HTS_URLMAXSIZE); - a += binput(a, fil, HTS_URLMAXSIZE); + a += binput(a, afs.af.adr, HTS_URLMAXSIZE); + a += binput(a, afs.af.fil, HTS_URLMAXSIZE); url[0] = '\0'; - if (!link_has_authority(adr)) + if (!link_has_authority(afs.af.adr)) strcatbuff(url, "http://"); - strcatbuff(url, adr); - strcatbuff(url, fil); + strcatbuff(url, afs.af.adr); + strcatbuff(url, afs.af.fil); /* read position */ a += binput(a, linepos, 200); sscanf(linepos, "%d", &pos); if (!hasFilter || (strjoker(url, filter, NULL, NULL) != NULL) ) { - r = cache_read_ro(opt, &cache, adr, fil, "", NULL); // lire entrée cache + data + r = cache_read_ro(opt, &cache, afs.af.adr, afs.af.fil, "", NULL); // lire entrée cache + data if (r.statuscode != -1) { // No errors found++; if (!hasFilter) { fprintf(stdout, "%s%s%s\r\n", - (link_has_authority(adr)) ? "" : - "http://", adr, fil); + (link_has_authority(afs.af.adr)) ? "" : + "http://", afs.af.adr, afs.af.fil); } else { char msg[256], cdate[256]; - char BIGSTK sav[HTS_URLMAXSIZE * 2]; infostatuscode(msg, r.statuscode); time_gmt_rfc822(cdate); fprintf(stdout, "HTTP/1.1 %d %s\r\n", r.statuscode, r.msg[0] ? r.msg : msg); - fprintf(stdout, "X-Host: %s\r\n", adr); - fprintf(stdout, "X-File: %s\r\n", fil); + fprintf(stdout, "X-Host: %s\r\n", afs.af.adr); + fprintf(stdout, "X-File: %s\r\n", afs.af.fil); fprintf(stdout, "X-URL: %s%s%s\r\n", - (link_has_authority(adr)) ? "" : - "http://", adr, fil); + (link_has_authority(afs.af.adr)) ? "" : + "http://", afs.af.adr, afs.af.fil); if (url_savename - (adr, fil, sav, /*former_adr */ NULL, - /*former_fil */ NULL, /*referer_adr */ + (&afs, /*former */ NULL, + /*referer_adr */ NULL, /*referer_fil */ NULL, - /*opt */ opt, /*liens */ NULL, - /*lien_tot */ 0, /*sback */ NULL, + /*opt */ opt, /*sback */ NULL, /*cache */ &cache, /*hash */ NULL, /*ptr */ 0, /*numero_passe */ 0, /*mime_type */ NULL) != -1) { - if (fexist(sav)) { + if (fexist(afs.save)) { fprintf(stdout, "Content-location: %s\r\n", - sav); + afs.save); } } fprintf(stdout, "Date: %s\r\n", cdate); @@ -2410,6 +2408,7 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) { return 0; break; case '7': // hashtable selftest: httrack -#7 nb_entries + md5selftest(); if (++na < argc) { char *const snum = strdup(argv[na]); unsigned long count = 0; diff --git a/src/htsdefines.h b/src/htsdefines.h index 644f85b..fe5105f 100644 --- a/src/htsdefines.h +++ b/src/htsdefines.h @@ -231,8 +231,15 @@ struct t_hts_callback_ref { size_t offset; }; +#ifdef __cplusplus +extern "C" { +#endif + extern const t_hts_htmlcheck_callbacks default_callbacks; -extern const t_hts_callback_ref default_callbacks_ref[]; + +#ifdef __cplusplus +} +#endif #define HT_PRINT(A) strcatbuff(opt->state.HTbuff,A); #define HT_REQUEST_START opt->state.HTbuff[0]='\0'; diff --git a/src/htsentities.h b/src/htsentities.h index bbb3a06..7fb8a59 100644 --- a/src/htsentities.h +++ b/src/htsentities.h @@ -18,1513 +18,1513 @@ static int decode_entity(const unsigned int hash, const size_t len) { switch(hash) { /* nbsp 160 no-break space = non-breaking space, */ - case 3948425267: + case 3948425267u: if (len == 4 /* && strncmp(ent, "nbsp") == 0 */) { return 160; } break; /* iexcl 161 inverted exclamation mark, U+00A1 ISOnum */ - case 1499591408: + case 1499591408u: if (len == 5 /* && strncmp(ent, "iexcl") == 0 */) { return 161; } break; /* cent 162 cent sign, U+00A2 ISOnum */ - case 2824786826: + case 2824786826u: if (len == 4 /* && strncmp(ent, "cent") == 0 */) { return 162; } break; /* pound 163 pound sign, U+00A3 ISOnum */ - case 805305925: + case 805305925u: if (len == 5 /* && strncmp(ent, "pound") == 0 */) { return 163; } break; /* curren 164 currency sign, U+00A4 ISOnum */ - case 1584829677: + case 1584829677u: if (len == 6 /* && strncmp(ent, "curren") == 0 */) { return 164; } break; /* yen 165 yen sign = yuan sign, U+00A5 ISOnum */ - case 3581281881: + case 3581281881u: if (len == 3 /* && strncmp(ent, "yen") == 0 */) { return 165; } break; /* brvbar 166 broken bar = broken vertical bar, */ - case 3768851825: + case 3768851825u: if (len == 6 /* && strncmp(ent, "brvbar") == 0 */) { return 166; } break; /* sect 167 section sign, U+00A7 ISOnum */ - case 2614630987: + case 2614630987u: if (len == 4 /* && strncmp(ent, "sect") == 0 */) { return 167; } break; /* uml 168 diaeresis = spacing diaeresis, */ - case 2036319259: + case 2036319259u: if (len == 3 /* && strncmp(ent, "uml") == 0 */) { return 168; } break; /* copy 169 copyright sign, U+00A9 ISOnum */ - case 2428845635: + case 2428845635u: if (len == 4 /* && strncmp(ent, "copy") == 0 */) { return 169; } break; /* ordf 170 feminine ordinal indicator, U+00AA ISOnum */ - case 212470411: + case 212470411u: if (len == 4 /* && strncmp(ent, "ordf") == 0 */) { return 170; } break; /* laquo 171 left-pointing double angle quotation mark */ - case 401220509: + case 401220509u: if (len == 5 /* && strncmp(ent, "laquo") == 0 */) { return 171; } break; /* not 172 not sign, U+00AC ISOnum */ - case 3607627678: + case 3607627678u: if (len == 3 /* && strncmp(ent, "not") == 0 */) { return 172; } break; /* shy 173 soft hyphen = discretionary hyphen, */ - case 1248857237: + case 1248857237u: if (len == 3 /* && strncmp(ent, "shy") == 0 */) { return 173; } break; /* reg 174 registered sign = registered trade mark sign, */ - case 854293939: + case 854293939u: if (len == 3 /* && strncmp(ent, "reg") == 0 */) { return 174; } break; /* macr 175 macron = spacing macron = overline */ - case 591423527: + case 591423527u: if (len == 4 /* && strncmp(ent, "macr") == 0 */) { return 175; } break; /* deg 176 degree sign, U+00B0 ISOnum */ - case 3990252661: + case 3990252661u: if (len == 3 /* && strncmp(ent, "deg") == 0 */) { return 176; } break; /* plusmn 177 plus-minus sign = plus-or-minus sign, */ - case 3641444957: + case 3641444957u: if (len == 6 /* && strncmp(ent, "plusmn") == 0 */) { return 177; } break; /* sup2 178 superscript two = superscript digit two */ - case 279450434: + case 279450434u: if (len == 4 /* && strncmp(ent, "sup2") == 0 */) { return 178; } break; /* sup3 179 superscript three = superscript digit three */ - case 279450435: + case 279450435u: if (len == 4 /* && strncmp(ent, "sup3") == 0 */) { return 179; } break; /* acute 180 acute accent = spacing acute, */ - case 1795641881: + case 1795641881u: if (len == 5 /* && strncmp(ent, "acute") == 0 */) { return 180; } break; /* micro 181 micro sign, U+00B5 ISOnum */ - case 1447763057: + case 1447763057u: if (len == 5 /* && strncmp(ent, "micro") == 0 */) { return 181; } break; /* para 182 pilcrow sign = paragraph sign, */ - case 848855704: + case 848855704u: if (len == 4 /* && strncmp(ent, "para") == 0 */) { return 182; } break; /* middot 183 middle dot = Georgian comma */ - case 3167839463: + case 3167839463u: if (len == 6 /* && strncmp(ent, "middot") == 0 */) { return 183; } break; /* cedil 184 cedilla = spacing cedilla, U+00B8 ISOdia */ - case 1354214564: + case 1354214564u: if (len == 5 /* && strncmp(ent, "cedil") == 0 */) { return 184; } break; /* sup1 185 superscript one = superscript digit one, */ - case 279450433: + case 279450433u: if (len == 4 /* && strncmp(ent, "sup1") == 0 */) { return 185; } break; /* ordm 186 masculine ordinal indicator, */ - case 212470418: + case 212470418u: if (len == 4 /* && strncmp(ent, "ordm") == 0 */) { return 186; } break; /* raquo 187 right-pointing double angle quotation mark */ - case 1355124995: + case 1355124995u: if (len == 5 /* && strncmp(ent, "raquo") == 0 */) { return 187; } break; /* frac14 188 vulgar fraction one quarter */ - case 1016175271: + case 1016175271u: if (len == 6 /* && strncmp(ent, "frac14") == 0 */) { return 188; } break; /* frac12 189 vulgar fraction one half */ - case 1016175269: + case 1016175269u: if (len == 6 /* && strncmp(ent, "frac12") == 0 */) { return 189; } break; /* frac34 190 vulgar fraction three quarters */ - case 1019504321: + case 1019504321u: if (len == 6 /* && strncmp(ent, "frac34") == 0 */) { return 190; } break; /* iquest 191 inverted question mark */ - case 430057661: + case 430057661u: if (len == 6 /* && strncmp(ent, "iquest") == 0 */) { return 191; } break; /* Agrave 192 latin capital letter A with grave */ - case 2815520320: + case 2815520320u: if (len == 6 /* && strncmp(ent, "Agrave") == 0 */) { return 192; } break; /* Aacute 193 latin capital letter A with acute, */ - case 4192391993: + case 4192391993u: if (len == 6 /* && strncmp(ent, "Aacute") == 0 */) { return 193; } break; /* Acirc 194 latin capital letter A with circumflex, */ - case 619920369: + case 619920369u: if (len == 5 /* && strncmp(ent, "Acirc") == 0 */) { return 194; } break; /* Atilde 195 latin capital letter A with tilde, */ - case 4145258425: + case 4145258425u: if (len == 6 /* && strncmp(ent, "Atilde") == 0 */) { return 195; } break; /* Auml 196 latin capital letter A with diaeresis, */ - case 3558330427: + case 3558330427u: if (len == 4 /* && strncmp(ent, "Auml") == 0 */) { return 196; } break; /* Aring 197 latin capital letter A with ring above */ - case 1775583868: + case 1775583868u: if (len == 5 /* && strncmp(ent, "Aring") == 0 */) { return 197; } break; /* AElig 198 latin capital letter AE */ - case 3743972869: + case 3743972869u: if (len == 5 /* && strncmp(ent, "AElig") == 0 */) { return 198; } break; /* Ccedil 199 latin capital letter C with cedilla, */ - case 885931646: + case 885931646u: if (len == 6 /* && strncmp(ent, "Ccedil") == 0 */) { return 199; } break; /* Egrave 200 latin capital letter E with grave, */ - case 1380421556: + case 1380421556u: if (len == 6 /* && strncmp(ent, "Egrave") == 0 */) { return 200; } break; /* Eacute 201 latin capital letter E with acute, */ - case 2757293229: + case 2757293229u: if (len == 6 /* && strncmp(ent, "Eacute") == 0 */) { return 201; } break; /* Ecirc 202 latin capital letter E with circumflex, */ - case 1255856693: + case 1255856693u: if (len == 5 /* && strncmp(ent, "Ecirc") == 0 */) { return 202; } break; /* Euml 203 latin capital letter E with diaeresis, */ - case 2436627087: + case 2436627087u: if (len == 4 /* && strncmp(ent, "Euml") == 0 */) { return 203; } break; /* Igrave 204 latin capital letter I with grave, */ - case 4240290088: + case 4240290088u: if (len == 6 /* && strncmp(ent, "Igrave") == 0 */) { return 204; } break; /* Iacute 205 latin capital letter I with acute, */ - case 1322194465: + case 1322194465u: if (len == 6 /* && strncmp(ent, "Iacute") == 0 */) { return 205; } break; /* Icirc 206 latin capital letter I with circumflex, */ - case 1891793017: + case 1891793017u: if (len == 5 /* && strncmp(ent, "Icirc") == 0 */) { return 206; } break; /* Iuml 207 latin capital letter I with diaeresis, */ - case 1314923747: + case 1314923747u: if (len == 4 /* && strncmp(ent, "Iuml") == 0 */) { return 207; } break; /* ETH 208 latin capital letter ETH, U+00D0 ISOlat1 */ - case 475229442: + case 475229442u: if (len == 3 /* && strncmp(ent, "ETH") == 0 */) { return 208; } break; /* Ntilde 209 latin capital letter N with tilde, */ - case 2702412914: + case 2702412914u: if (len == 6 /* && strncmp(ent, "Ntilde") == 0 */) { return 209; } break; /* Ograve 210 latin capital letter O with grave, */ - case 4235125590: + case 4235125590u: if (len == 6 /* && strncmp(ent, "Ograve") == 0 */) { return 210; } break; /* Oacute 211 latin capital letter O with acute, */ - case 1317029967: + case 1317029967u: if (len == 6 /* && strncmp(ent, "Oacute") == 0 */) { return 211; } break; /* Ocirc 212 latin capital letter O with circumflex, */ - case 2845697503: + case 2845697503u: if (len == 5 /* && strncmp(ent, "Ocirc") == 0 */) { return 212; } break; /* Otilde 213 latin capital letter O with tilde, */ - case 1269896399: + case 1269896399u: if (len == 6 /* && strncmp(ent, "Otilde") == 0 */) { return 213; } break; /* Ouml 214 latin capital letter O with diaeresis, */ - case 1779852385: + case 1779852385u: if (len == 4 /* && strncmp(ent, "Ouml") == 0 */) { return 214; } break; /* times 215 multiplication sign, U+00D7 ISOnum */ - case 2139742557: + case 2139742557u: if (len == 5 /* && strncmp(ent, "times") == 0 */) { return 215; } break; /* Oslash 216 latin capital letter O with stroke */ - case 1378045056: + case 1378045056u: if (len == 6 /* && strncmp(ent, "Oslash") == 0 */) { return 216; } break; /* Ugrave 217 latin capital letter U with grave, */ - case 4229961092: + case 4229961092u: if (len == 6 /* && strncmp(ent, "Ugrave") == 0 */) { return 217; } break; /* Uacute 218 latin capital letter U with acute, */ - case 1311865469: + case 1311865469u: if (len == 6 /* && strncmp(ent, "Uacute") == 0 */) { return 218; } break; /* Ucirc 219 latin capital letter U with circumflex, */ - case 3799601989: + case 3799601989u: if (len == 5 /* && strncmp(ent, "Ucirc") == 0 */) { return 219; } break; /* Uuml 220 latin capital letter U with diaeresis, */ - case 2244781023: + case 2244781023u: if (len == 4 /* && strncmp(ent, "Uuml") == 0 */) { return 220; } break; /* Yacute 221 latin capital letter Y with acute, */ - case 4171734001: + case 4171734001u: if (len == 6 /* && strncmp(ent, "Yacute") == 0 */) { return 221; } break; /* THORN 222 latin capital letter THORN, */ - case 4251263774: + case 4251263774u: if (len == 5 /* && strncmp(ent, "THORN") == 0 */) { return 222; } break; /* szlig 223 latin small letter sharp s = ess-zed, */ - case 51833136: + case 51833136u: if (len == 5 /* && strncmp(ent, "szlig") == 0 */) { return 223; } break; /* agrave 224 latin small letter a with grave */ - case 4219632096: + case 4219632096u: if (len == 6 /* && strncmp(ent, "agrave") == 0 */) { return 224; } break; /* aacute 225 latin small letter a with acute, */ - case 1301536473: + case 1301536473u: if (len == 6 /* && strncmp(ent, "aacute") == 0 */) { return 225; } break; /* acirc 226 latin small letter a with circumflex, */ - case 1412443665: + case 1412443665u: if (len == 5 /* && strncmp(ent, "acirc") == 0 */) { return 226; } break; /* atilde 227 latin small letter a with tilde, */ - case 1254402905: + case 1254402905u: if (len == 6 /* && strncmp(ent, "atilde") == 0 */) { return 227; } break; /* auml 228 latin small letter a with diaeresis, */ - case 3174638299: + case 3174638299u: if (len == 4 /* && strncmp(ent, "auml") == 0 */) { return 228; } break; /* aring 229 latin small letter a with ring above */ - case 2568107164: + case 2568107164u: if (len == 5 /* && strncmp(ent, "aring") == 0 */) { return 229; } break; /* aelig 230 latin small letter ae */ - case 4152804037: + case 4152804037u: if (len == 5 /* && strncmp(ent, "aelig") == 0 */) { return 230; } break; /* ccedil 231 latin small letter c with cedilla, */ - case 2290043422: + case 2290043422u: if (len == 6 /* && strncmp(ent, "ccedil") == 0 */) { return 231; } break; /* egrave 232 latin small letter e with grave, */ - case 2784533332: + case 2784533332u: if (len == 6 /* && strncmp(ent, "egrave") == 0 */) { return 232; } break; /* eacute 233 latin small letter e with acute, */ - case 4161405005: + case 4161405005u: if (len == 6 /* && strncmp(ent, "eacute") == 0 */) { return 233; } break; /* ecirc 234 latin small letter e with circumflex, */ - case 2048379989: + case 2048379989u: if (len == 5 /* && strncmp(ent, "ecirc") == 0 */) { return 234; } break; /* euml 235 latin small letter e with diaeresis, */ - case 2052934959: + case 2052934959u: if (len == 4 /* && strncmp(ent, "euml") == 0 */) { return 235; } break; /* igrave 236 latin small letter i with grave, */ - case 1349434568: + case 1349434568u: if (len == 6 /* && strncmp(ent, "igrave") == 0 */) { return 236; } break; /* iacute 237 latin small letter i with acute, */ - case 2726306241: + case 2726306241u: if (len == 6 /* && strncmp(ent, "iacute") == 0 */) { return 237; } break; /* icirc 238 latin small letter i with circumflex, */ - case 2684316313: + case 2684316313u: if (len == 5 /* && strncmp(ent, "icirc") == 0 */) { return 238; } break; /* iuml 239 latin small letter i with diaeresis, */ - case 931231619: + case 931231619u: if (len == 4 /* && strncmp(ent, "iuml") == 0 */) { return 239; } break; /* eth 240 latin small letter eth, U+00F0 ISOlat1 */ - case 109822946: + case 109822946u: if (len == 3 /* && strncmp(ent, "eth") == 0 */) { return 240; } break; /* ntilde 241 latin small letter n with tilde, */ - case 4106524690: + case 4106524690u: if (len == 6 /* && strncmp(ent, "ntilde") == 0 */) { return 241; } break; /* ograve 242 latin small letter o with grave, */ - case 1344270070: + case 1344270070u: if (len == 6 /* && strncmp(ent, "ograve") == 0 */) { return 242; } break; /* oacute 243 latin small letter o with acute, */ - case 2721141743: + case 2721141743u: if (len == 6 /* && strncmp(ent, "oacute") == 0 */) { return 243; } break; /* ocirc 244 latin small letter o with circumflex, */ - case 3638220799: + case 3638220799u: if (len == 5 /* && strncmp(ent, "ocirc") == 0 */) { return 244; } break; /* otilde 245 latin small letter o with tilde, */ - case 2674008175: + case 2674008175u: if (len == 6 /* && strncmp(ent, "otilde") == 0 */) { return 245; } break; /* ouml 246 latin small letter o with diaeresis, */ - case 1396160257: + case 1396160257u: if (len == 4 /* && strncmp(ent, "ouml") == 0 */) { return 246; } break; /* divide 247 division sign, U+00F7 ISOnum */ - case 2204943563: + case 2204943563u: if (len == 6 /* && strncmp(ent, "divide") == 0 */) { return 247; } break; /* oslash 248 latin small letter o with stroke, */ - case 2782156832: + case 2782156832u: if (len == 6 /* && strncmp(ent, "oslash") == 0 */) { return 248; } break; /* ugrave 249 latin small letter u with grave, */ - case 1339105572: + case 1339105572u: if (len == 6 /* && strncmp(ent, "ugrave") == 0 */) { return 249; } break; /* uacute 250 latin small letter u with acute, */ - case 2715977245: + case 2715977245u: if (len == 6 /* && strncmp(ent, "uacute") == 0 */) { return 250; } break; /* ucirc 251 latin small letter u with circumflex, */ - case 297157989: + case 297157989u: if (len == 5 /* && strncmp(ent, "ucirc") == 0 */) { return 251; } break; /* uuml 252 latin small letter u with diaeresis, */ - case 1861088895: + case 1861088895u: if (len == 4 /* && strncmp(ent, "uuml") == 0 */) { return 252; } break; /* yacute 253 latin small letter y with acute, */ - case 1280878481: + case 1280878481u: if (len == 6 /* && strncmp(ent, "yacute") == 0 */) { return 253; } break; /* thorn 254 latin small letter thorn with, */ - case 4294688446: + case 4294688446u: if (len == 5 /* && strncmp(ent, "thorn") == 0 */) { return 254; } break; /* yuml 255 latin small letter y with diaeresis, */ - case 739385555: + case 739385555u: if (len == 4 /* && strncmp(ent, "yuml") == 0 */) { return 255; } break; /* fnof 402 latin small f with hook = function */ - case 2270075705: + case 2270075705u: if (len == 4 /* && strncmp(ent, "fnof") == 0 */) { return 402; } break; /* Alpha 913 greek capital letter alpha, U+0391 */ - case 4027656009: + case 4027656009u: if (len == 5 /* && strncmp(ent, "Alpha") == 0 */) { return 913; } break; /* Beta 914 greek capital letter beta, U+0392 */ - case 277666448: + case 277666448u: if (len == 4 /* && strncmp(ent, "Beta") == 0 */) { return 914; } break; /* Gamma 915 greek capital letter gamma, */ - case 1537149070: + case 1537149070u: if (len == 5 /* && strncmp(ent, "Gamma") == 0 */) { return 915; } break; /* Delta 916 greek capital letter delta, */ - case 3855542753: + case 3855542753u: if (len == 5 /* && strncmp(ent, "Delta") == 0 */) { return 916; } break; /* Epsilon 917 greek capital letter epsilon, U+0395 */ - case 2449300823: + case 2449300823u: if (len == 7 /* && strncmp(ent, "Epsilon") == 0 */) { return 917; } break; /* Zeta 918 greek capital letter zeta, U+0396 */ - case 2137381000: + case 2137381000u: if (len == 4 /* && strncmp(ent, "Zeta") == 0 */) { return 918; } break; /* Eta 919 greek capital letter eta, U+0397 */ - case 528494267: + case 528494267u: if (len == 3 /* && strncmp(ent, "Eta") == 0 */) { return 919; } break; /* Theta 920 greek capital letter theta, */ - case 3904764433: + case 3904764433u: if (len == 5 /* && strncmp(ent, "Theta") == 0 */) { return 920; } break; /* Iota 921 greek capital letter iota, U+0399 */ - case 3284124477: + case 3284124477u: if (len == 4 /* && strncmp(ent, "Iota") == 0 */) { return 921; } break; /* Kappa 922 greek capital letter kappa, U+039A */ - case 3346788084: + case 3346788084u: if (len == 5 /* && strncmp(ent, "Kappa") == 0 */) { return 922; } break; /* Lambda 923 greek capital letter lambda, */ - case 1824315307: + case 1824315307u: if (len == 6 /* && strncmp(ent, "Lambda") == 0 */) { return 923; } break; /* Mu 924 greek capital letter mu, U+039C */ - case 1324604304: + case 1324604304u: if (len == 2 /* && strncmp(ent, "Mu") == 0 */) { return 924; } break; /* Nu 925 greek capital letter nu, U+039D */ - case 1326268829: + case 1326268829u: if (len == 2 /* && strncmp(ent, "Nu") == 0 */) { return 925; } break; /* Xi 926 greek capital letter xi, U+039E ISOgrk3 */ - case 1342914067: + case 1342914067u: if (len == 2 /* && strncmp(ent, "Xi") == 0 */) { return 926; } break; /* Omicron 927 greek capital letter omicron, U+039F */ - case 488730696: + case 488730696u: if (len == 7 /* && strncmp(ent, "Omicron") == 0 */) { return 927; } break; /* Pi 928 greek capital letter pi, U+03A0 ISOgrk3 */ - case 1329597867: + case 1329597867u: if (len == 2 /* && strncmp(ent, "Pi") == 0 */) { return 928; } break; /* Rho 929 greek capital letter rho, U+03A1 */ - case 1277958850: + case 1277958850u: if (len == 3 /* && strncmp(ent, "Rho") == 0 */) { return 929; } break; /* Sigma 931 greek capital letter sigma, */ - case 3159100428: + case 3159100428u: if (len == 5 /* && strncmp(ent, "Sigma") == 0 */) { return 931; } break; /* Tau 932 greek capital letter tau, U+03A4 */ - case 2045446591: + case 2045446591u: if (len == 3 /* && strncmp(ent, "Tau") == 0 */) { return 932; } break; /* Upsilon 933 greek capital letter upsilon, */ - case 2291992807: + case 2291992807u: if (len == 7 /* && strncmp(ent, "Upsilon") == 0 */) { return 933; } break; /* Phi 934 greek capital letter phi, */ - case 498819434: + case 498819434u: if (len == 3 /* && strncmp(ent, "Phi") == 0 */) { return 934; } break; /* Chi 935 greek capital letter chi, U+03A7 */ - case 4024347861: + case 4024347861u: if (len == 3 /* && strncmp(ent, "Chi") == 0 */) { return 935; } break; /* Psi 936 greek capital letter psi, */ - case 517129209: + case 517129209u: if (len == 3 /* && strncmp(ent, "Psi") == 0 */) { return 936; } break; /* Omega 937 greek capital letter omega, */ - case 612334204: + case 612334204u: if (len == 5 /* && strncmp(ent, "Omega") == 0 */) { return 937; } break; /* alpha 945 greek small letter alpha, */ - case 525212009: + case 525212009u: if (len == 5 /* && strncmp(ent, "alpha") == 0 */) { return 945; } break; /* beta 946 greek small letter beta, U+03B2 ISOgrk3 */ - case 4188941616: + case 4188941616u: if (len == 4 /* && strncmp(ent, "beta") == 0 */) { return 946; } break; /* gamma 947 greek small letter gamma, */ - case 2329672366: + case 2329672366u: if (len == 5 /* && strncmp(ent, "gamma") == 0 */) { return 947; } break; /* delta 948 greek small letter delta, */ - case 353098753: + case 353098753u: if (len == 5 /* && strncmp(ent, "delta") == 0 */) { return 948; } break; /* epsilon 949 greek small letter epsilon, */ - case 2134684791: + case 2134684791u: if (len == 7 /* && strncmp(ent, "epsilon") == 0 */) { return 949; } break; /* zeta 950 greek small letter zeta, U+03B6 ISOgrk3 */ - case 1753688872: + case 1753688872u: if (len == 4 /* && strncmp(ent, "zeta") == 0 */) { return 950; } break; /* eta 951 greek small letter eta, U+03B7 ISOgrk3 */ - case 109822939: + case 109822939u: if (len == 3 /* && strncmp(ent, "eta") == 0 */) { return 951; } break; /* theta 952 greek small letter theta, */ - case 402320433: + case 402320433u: if (len == 5 /* && strncmp(ent, "theta") == 0 */) { return 952; } break; /* iota 953 greek small letter iota, U+03B9 ISOgrk3 */ - case 2900432349: + case 2900432349u: if (len == 4 /* && strncmp(ent, "iota") == 0 */) { return 953; } break; /* kappa 954 greek small letter kappa, */ - case 4139311380: + case 4139311380u: if (len == 5 /* && strncmp(ent, "kappa") == 0 */) { return 954; } break; /* lambda 955 greek small letter lambda, */ - case 3228427083: + case 3228427083u: if (len == 6 /* && strncmp(ent, "lambda") == 0 */) { return 955; } break; /* mu 956 greek small letter mu, U+03BC ISOgrk3 */ - case 1377869104: + case 1377869104u: if (len == 2 /* && strncmp(ent, "mu") == 0 */) { return 956; } break; /* nu 957 greek small letter nu, U+03BD ISOgrk3 */ - case 1379533629: + case 1379533629u: if (len == 2 /* && strncmp(ent, "nu") == 0 */) { return 957; } break; /* xi 958 greek small letter xi, U+03BE ISOgrk3 */ - case 1396178867: + case 1396178867u: if (len == 2 /* && strncmp(ent, "xi") == 0 */) { return 958; } break; /* omicron 959 greek small letter omicron, U+03BF NEW */ - case 174114664: + case 174114664u: if (len == 7 /* && strncmp(ent, "omicron") == 0 */) { return 959; } break; /* pi 960 greek small letter pi, U+03C0 ISOgrk3 */ - case 1382862667: + case 1382862667u: if (len == 2 /* && strncmp(ent, "pi") == 0 */) { return 960; } break; /* rho 961 greek small letter rho, U+03C1 ISOgrk3 */ - case 859287522: + case 859287522u: if (len == 3 /* && strncmp(ent, "rho") == 0 */) { return 961; } break; /* sigmaf 962 greek small letter final sigma, */ - case 2582995969: + case 2582995969u: if (len == 6 /* && strncmp(ent, "sigmaf") == 0 */) { return 962; } break; /* sigma 963 greek small letter sigma, */ - case 3951623724: + case 3951623724u: if (len == 5 /* && strncmp(ent, "sigma") == 0 */) { return 963; } break; /* tau 964 greek small letter tau, U+03C4 ISOgrk3 */ - case 1626775263: + case 1626775263u: if (len == 3 /* && strncmp(ent, "tau") == 0 */) { return 964; } break; /* upsilon 965 greek small letter upsilon, */ - case 1977376775: + case 1977376775u: if (len == 7 /* && strncmp(ent, "upsilon") == 0 */) { return 965; } break; /* phi 966 greek small letter phi, U+03C6 ISOgrk3 */ - case 80148106: + case 80148106u: if (len == 3 /* && strncmp(ent, "phi") == 0 */) { return 966; } break; /* chi 967 greek small letter chi, U+03C7 ISOgrk3 */ - case 3605676533: + case 3605676533u: if (len == 3 /* && strncmp(ent, "chi") == 0 */) { return 967; } break; /* psi 968 greek small letter psi, U+03C8 ISOgrk3 */ - case 98457881: + case 98457881u: if (len == 3 /* && strncmp(ent, "psi") == 0 */) { return 968; } break; /* omega 969 greek small letter omega, */ - case 1404857500: + case 1404857500u: if (len == 5 /* && strncmp(ent, "omega") == 0 */) { return 969; } break; /* thetasym 977 greek small letter theta symbol, */ - case 3881711083: + case 3881711083u: if (len == 8 /* && strncmp(ent, "thetasym") == 0 */) { return 977; } break; /* upsih 978 greek upsilon with hook symbol, */ - case 3753563936: + case 3753563936u: if (len == 5 /* && strncmp(ent, "upsih") == 0 */) { return 978; } break; /* piv 982 greek pi symbol, U+03D6 ISOgrk3 */ - case 81812644: + case 81812644u: if (len == 3 /* && strncmp(ent, "piv") == 0 */) { return 982; } break; /* bull 8226 bullet = black small circle, */ - case 1818806115: + case 1818806115u: if (len == 4 /* && strncmp(ent, "bull") == 0 */) { return 8226; } break; /* hellip 8230 horizontal ellipsis = three dot leader, */ - case 1967714928: + case 1967714928u: if (len == 6 /* && strncmp(ent, "hellip") == 0 */) { return 8230; } break; /* prime 8242 prime = minutes = feet, U+2032 ISOtech */ - case 656236556: + case 656236556u: if (len == 5 /* && strncmp(ent, "prime") == 0 */) { return 8242; } break; /* Prime 8243 double prime = seconds = inches, */ - case 4158680556: + case 4158680556u: if (len == 5 /* && strncmp(ent, "Prime") == 0 */) { return 8243; } break; /* oline 8254 overline = spacing overscore, */ - case 33988362: + case 33988362u: if (len == 5 /* && strncmp(ent, "oline") == 0 */) { return 8254; } break; /* frasl 8260 fraction slash, U+2044 NEW */ - case 254792559: + case 254792559u: if (len == 5 /* && strncmp(ent, "frasl") == 0 */) { return 8260; } break; /* weierp 8472 script capital P = power set */ - case 3305299450: + case 3305299450u: if (len == 6 /* && strncmp(ent, "weierp") == 0 */) { return 8472; } break; /* image 8465 blackletter capital I = imaginary part, */ - case 3187641494: + case 3187641494u: if (len == 5 /* && strncmp(ent, "image") == 0 */) { return 8465; } break; /* real 8476 blackletter capital R = real part symbol, */ - case 3965469588: + case 3965469588u: if (len == 4 /* && strncmp(ent, "real") == 0 */) { return 8476; } break; /* trade 8482 trade mark sign, U+2122 ISOnum */ - case 2455601811: + case 2455601811u: if (len == 5 /* && strncmp(ent, "trade") == 0 */) { return 8482; } break; /* alefsym 8501 alef symbol = first transfinite cardinal, */ - case 3894502290: + case 3894502290u: if (len == 7 /* && strncmp(ent, "alefsym") == 0 */) { return 8501; } break; /* larr 8592 leftwards arrow, U+2190 ISOnum */ - case 1970559061: + case 1970559061u: if (len == 4 /* && strncmp(ent, "larr") == 0 */) { return 8592; } break; /* uarr 8593 upwards arrow, U+2191 ISOnum */ - case 2667952018: + case 2667952018u: if (len == 4 /* && strncmp(ent, "uarr") == 0 */) { return 8593; } break; /* rarr 8594 rightwards arrow, U+2192 ISOnum */ - case 2435487699: + case 2435487699u: if (len == 4 /* && strncmp(ent, "rarr") == 0 */) { return 8594; } break; /* darr 8595 downwards arrow, U+2193 ISOnum */ - case 4213965741: + case 4213965741u: if (len == 4 /* && strncmp(ent, "darr") == 0 */) { return 8595; } break; /* harr 8596 left right arrow, U+2194 ISOamsa */ - case 3092262401: + case 3092262401u: if (len == 4 /* && strncmp(ent, "harr") == 0 */) { return 8596; } break; /* crarr 8629 downwards arrow with corner leftwards */ - case 4071143093: + case 4071143093u: if (len == 5 /* && strncmp(ent, "crarr") == 0 */) { return 8629; } break; /* lArr 8656 leftwards double arrow, U+21D0 ISOtech */ - case 2389230389: + case 2389230389u: if (len == 4 /* && strncmp(ent, "lArr") == 0 */) { return 8656; } break; /* uArr 8657 upwards double arrow, U+21D1 ISOamsa */ - case 3086623346: + case 3086623346u: if (len == 4 /* && strncmp(ent, "uArr") == 0 */) { return 8657; } break; /* rArr 8658 rightwards double arrow, */ - case 2854159027: + case 2854159027u: if (len == 4 /* && strncmp(ent, "rArr") == 0 */) { return 8658; } break; /* dArr 8659 downwards double arrow, U+21D3 ISOamsa */ - case 337669773: + case 337669773u: if (len == 4 /* && strncmp(ent, "dArr") == 0 */) { return 8659; } break; /* hArr 8660 left right double arrow, */ - case 3510933729: + case 3510933729u: if (len == 4 /* && strncmp(ent, "hArr") == 0 */) { return 8660; } break; /* forall 8704 for all, U+2200 ISOtech */ - case 2607244222: + case 2607244222u: if (len == 6 /* && strncmp(ent, "forall") == 0 */) { return 8704; } break; /* part 8706 partial differential, U+2202 ISOtech */ - case 848855723: + case 848855723u: if (len == 4 /* && strncmp(ent, "part") == 0 */) { return 8706; } break; /* exist 8707 there exists, U+2203 ISOtech */ - case 3677294764: + case 3677294764u: if (len == 5 /* && strncmp(ent, "exist") == 0 */) { return 8707; } break; /* empty 8709 empty set = null set = diameter, */ - case 4121922294: + case 4121922294u: if (len == 5 /* && strncmp(ent, "empty") == 0 */) { return 8709; } break; /* nabla 8711 nabla = backward difference, */ - case 3450596949: + case 3450596949u: if (len == 5 /* && strncmp(ent, "nabla") == 0 */) { return 8711; } break; /* isin 8712 element of, U+2208 ISOtech */ - case 145434111: + case 145434111u: if (len == 4 /* && strncmp(ent, "isin") == 0 */) { return 8712; } break; /* notin 8713 not an element of, U+2209 ISOtech */ - case 89445443: + case 89445443u: if (len == 5 /* && strncmp(ent, "notin") == 0 */) { return 8713; } break; /* ni 8715 contains as member, U+220B ISOtech */ - case 1379533617: + case 1379533617u: if (len == 2 /* && strncmp(ent, "ni") == 0 */) { return 8715; } break; /* prod 8719 n-ary product = product sign, */ - case 3171579821: + case 3171579821u: if (len == 4 /* && strncmp(ent, "prod") == 0 */) { return 8719; } break; /* sum 8721 n-ary sumation, U+2211 ISOamsb */ - case 1270496050: + case 1270496050u: if (len == 3 /* && strncmp(ent, "sum") == 0 */) { return 8721; } break; /* minus 8722 minus sign, U+2212 ISOtech */ - case 1443056095: + case 1443056095u: if (len == 5 /* && strncmp(ent, "minus") == 0 */) { return 8722; } break; /* lowast 8727 asterisk operator, U+2217 ISOtech */ - case 137860408: + case 137860408u: if (len == 6 /* && strncmp(ent, "lowast") == 0 */) { return 8727; } break; /* radic 8730 square root = radical sign, */ - case 565711814: + case 565711814u: if (len == 5 /* && strncmp(ent, "radic") == 0 */) { return 8730; } break; /* prop 8733 proportional to, U+221D ISOtech */ - case 3171579833: + case 3171579833u: if (len == 4 /* && strncmp(ent, "prop") == 0 */) { return 8733; } break; /* infin 8734 infinity, U+221E ISOtech */ - case 3784651419: + case 3784651419u: if (len == 5 /* && strncmp(ent, "infin") == 0 */) { return 8734; } break; /* ang 8736 angle, U+2220 ISOamso */ - case 2836524271: + case 2836524271u: if (len == 3 /* && strncmp(ent, "ang") == 0 */) { return 8736; } break; /* and 8743 logical and = wedge, U+2227 ISOtech */ - case 2836524268: + case 2836524268u: if (len == 3 /* && strncmp(ent, "and") == 0 */) { return 8743; } break; /* or 8744 logical or = vee, U+2228 ISOtech */ - case 1381198151: + case 1381198151u: if (len == 2 /* && strncmp(ent, "or") == 0 */) { return 8744; } break; /* cap 8745 intersection = cap, U+2229 ISOtech */ - case 3594024865: + case 3594024865u: if (len == 3 /* && strncmp(ent, "cap") == 0 */) { return 8745; } break; /* cup 8746 union = cup, U+222A ISOtech */ - case 3627315365: + case 3627315365u: if (len == 3 /* && strncmp(ent, "cup") == 0 */) { return 8746; } break; /* int 8747 integral, U+222B ISOtech */ - case 1658114628: + case 1658114628u: if (len == 3 /* && strncmp(ent, "int") == 0 */) { return 8747; } break; /* there4 8756 therefore, U+2234 ISOtech */ - case 1359369970: + case 1359369970u: if (len == 6 /* && strncmp(ent, "there4") == 0 */) { return 8756; } break; /* sim 8764 tilde operator = varies with = similar to, */ - case 1250521750: + case 1250521750u: if (len == 3 /* && strncmp(ent, "sim") == 0 */) { return 8764; } break; /* cong 8773 approximately equal to, U+2245 ISOtech */ - case 2425516567: + case 2425516567u: if (len == 4 /* && strncmp(ent, "cong") == 0 */) { return 8773; } break; /* asymp 8776 almost equal to = asymptotic to, */ - case 3150422973: + case 3150422973u: if (len == 5 /* && strncmp(ent, "asymp") == 0 */) { return 8776; } break; /* ne 8800 not equal to, U+2260 ISOtech */ - case 1379533613: + case 1379533613u: if (len == 2 /* && strncmp(ent, "ne") == 0 */) { return 8800; } break; /* equiv 8801 identical to, U+2261 ISOtech */ - case 634790405: + case 634790405u: if (len == 5 /* && strncmp(ent, "equiv") == 0 */) { return 8801; } break; /* le 8804 less-than or equal to, U+2264 ISOtech */ - case 1376204563: + case 1376204563u: if (len == 2 /* && strncmp(ent, "le") == 0 */) { return 8804; } break; /* ge 8805 greater-than or equal to, */ - case 1367881938: + case 1367881938u: if (len == 2 /* && strncmp(ent, "ge") == 0 */) { return 8805; } break; /* sub 8834 subset of, U+2282 ISOtech */ - case 1270496039: + case 1270496039u: if (len == 3 /* && strncmp(ent, "sub") == 0 */) { return 8834; } break; /* sup 8835 superset of, U+2283 ISOtech */ - case 1270496053: + case 1270496053u: if (len == 3 /* && strncmp(ent, "sup") == 0 */) { return 8835; } break; /* nsub 8836 not a subset of, U+2284 ISOamsn */ - case 1984504696: + case 1984504696u: if (len == 4 /* && strncmp(ent, "nsub") == 0 */) { return 8836; } break; /* sube 8838 subset of or equal to, U+2286 ISOtech */ - case 256147135: + case 256147135u: if (len == 4 /* && strncmp(ent, "sube") == 0 */) { return 8838; } break; /* supe 8839 superset of or equal to, */ - case 279450485: + case 279450485u: if (len == 4 /* && strncmp(ent, "supe") == 0 */) { return 8839; } break; /* oplus 8853 circled plus = direct sum, */ - case 92645826: + case 92645826u: if (len == 5 /* && strncmp(ent, "oplus") == 0 */) { return 8853; } break; /* otimes 8855 circled times = vector product, */ - case 3065242419: + case 3065242419u: if (len == 6 /* && strncmp(ent, "otimes") == 0 */) { return 8855; } break; /* perp 8869 up tack = orthogonal to = perpendicular, */ - case 2407134539: + case 2407134539u: if (len == 4 /* && strncmp(ent, "perp") == 0 */) { return 8869; } break; /* sdot 8901 dot operator, U+22C5 ISOamsb */ - case 2245035582: + case 2245035582u: if (len == 4 /* && strncmp(ent, "sdot") == 0 */) { return 8901; } break; /* lceil 8968 left ceiling = apl upstile, */ - case 1588009020: + case 1588009020u: if (len == 5 /* && strncmp(ent, "lceil") == 0 */) { return 8968; } break; /* rceil 8969 right ceiling, U+2309 ISOamsc */ - case 2541913506: + case 2541913506u: if (len == 5 /* && strncmp(ent, "rceil") == 0 */) { return 8969; } break; /* lfloor 8970 left floor = apl downstile, */ - case 1870296512: + case 1870296512u: if (len == 6 /* && strncmp(ent, "lfloor") == 0 */) { return 8970; } break; /* rfloor 8971 right floor, U+230B ISOamsc */ - case 1865132014: + case 1865132014u: if (len == 6 /* && strncmp(ent, "rfloor") == 0 */) { return 8971; } break; /* lang 9001 left-pointing angle bracket = bra, */ - case 1963900950: + case 1963900950u: if (len == 4 /* && strncmp(ent, "lang") == 0 */) { return 9001; } break; /* rang 9002 right-pointing angle bracket = ket, */ - case 2428829588: + case 2428829588u: if (len == 4 /* && strncmp(ent, "rang") == 0 */) { return 9002; } break; /* loz 9674 lozenge, U+25CA ISOpub */ - case 2828488274: + case 2828488274u: if (len == 3 /* && strncmp(ent, "loz") == 0 */) { return 9674; } break; /* spades 9824 black spade suit, U+2660 ISOpub */ - case 4026453962: + case 4026453962u: if (len == 6 /* && strncmp(ent, "spades") == 0 */) { return 9824; } break; /* clubs 9827 black club suit = shamrock, */ - case 2781041564: + case 2781041564u: if (len == 5 /* && strncmp(ent, "clubs") == 0 */) { return 9827; } break; /* hearts 9829 black heart suit = valentine, */ - case 2039418001: + case 2039418001u: if (len == 6 /* && strncmp(ent, "hearts") == 0 */) { return 9829; } break; /* diams 9830 black diamond suit, U+2666 ISOpub */ - case 3524411593: + case 3524411593u: if (len == 5 /* && strncmp(ent, "diams") == 0 */) { return 9830; } break; /* quot 34 quotation mark = APL quote, */ - case 2986121293: + case 2986121293u: if (len == 4 /* && strncmp(ent, "quot") == 0 */) { return 34; } break; /* amp 38 ampersand, U+0026 ISOnum */ - case 2834859755: + case 2834859755u: if (len == 3 /* && strncmp(ent, "amp") == 0 */) { return 38; } break; /* lt 60 less-than sign, U+003C ISOnum */ - case 1376204578: + case 1376204578u: if (len == 2 /* && strncmp(ent, "lt") == 0 */) { return 60; } break; /* gt 62 greater-than sign, U+003E ISOnum */ - case 1367881953: + case 1367881953u: if (len == 2 /* && strncmp(ent, "gt") == 0 */) { return 62; } break; /* OElig 338 latin capital ligature OE, */ - case 1674782707: + case 1674782707u: if (len == 5 /* && strncmp(ent, "OElig") == 0 */) { return 338; } break; /* oelig 339 latin small ligature oe, U+0153 ISOlat2 */ - case 2083613875: + case 2083613875u: if (len == 5 /* && strncmp(ent, "oelig") == 0 */) { return 339; } break; /* Scaron 352 latin capital letter S with caron, */ - case 1731202952: + case 1731202952u: if (len == 6 /* && strncmp(ent, "Scaron") == 0 */) { return 352; } break; /* scaron 353 latin small letter s with caron, */ - case 3135314728: + case 3135314728u: if (len == 6 /* && strncmp(ent, "scaron") == 0 */) { return 353; } break; /* Yuml 376 latin capital letter Y with diaeresis, */ - case 1123077683: + case 1123077683u: if (len == 4 /* && strncmp(ent, "Yuml") == 0 */) { return 376; } break; /* circ 710 modifier letter circumflex accent, */ - case 94756433: + case 94756433u: if (len == 4 /* && strncmp(ent, "circ") == 0 */) { return 710; } break; /* tilde 732 small tilde, U+02DC ISOdia */ - case 1748508313: + case 1748508313u: if (len == 5 /* && strncmp(ent, "tilde") == 0 */) { return 732; } break; /* ensp 8194 en space, U+2002 ISOpub */ - case 3630901474: + case 3630901474u: if (len == 4 /* && strncmp(ent, "ensp") == 0 */) { return 8194; } break; /* emsp 8195 em space, U+2003 ISOpub */ - case 3241331769: + case 3241331769u: if (len == 4 /* && strncmp(ent, "emsp") == 0 */) { return 8195; } break; /* thinsp 8201 thin space, U+2009 ISOpub */ - case 2997658516: + case 2997658516u: if (len == 6 /* && strncmp(ent, "thinsp") == 0 */) { return 8201; } break; /* zwnj 8204 zero width non-joiner, */ - case 166021829: + case 166021829u: if (len == 4 /* && strncmp(ent, "zwnj") == 0 */) { return 8204; } break; /* zwj 8205 zero width joiner, U+200D NEW RFC 2070 */ - case 4000813032: + case 4000813032u: if (len == 3 /* && strncmp(ent, "zwj") == 0 */) { return 8205; } break; /* lrm 8206 left-to-right mark, U+200E NEW RFC 2070 */ - case 2833481836: + case 2833481836u: if (len == 3 /* && strncmp(ent, "lrm") == 0 */) { return 8206; } break; /* rlm 8207 right-to-left mark, U+200F NEW RFC 2070 */ - case 865945620: + case 865945620u: if (len == 3 /* && strncmp(ent, "rlm") == 0 */) { return 8207; } break; /* ndash 8211 en dash, U+2013 ISOpub */ - case 3305143245: + case 3305143245u: if (len == 5 /* && strncmp(ent, "ndash") == 0 */) { return 8211; } break; /* mdash 8212 em dash, U+2014 ISOpub */ - case 3146159164: + case 3146159164u: if (len == 5 /* && strncmp(ent, "mdash") == 0 */) { return 8212; } break; /* lsquo 8216 left single quotation mark, */ - case 1796006423: + case 1796006423u: if (len == 5 /* && strncmp(ent, "lsquo") == 0 */) { return 8216; } break; /* rsquo 8217 right single quotation mark, */ - case 2749910909: + case 2749910909u: if (len == 5 /* && strncmp(ent, "rsquo") == 0 */) { return 8217; } break; /* sbquo 8218 single low-9 quotation mark, U+201A NEW */ - case 159941417: + case 159941417u: if (len == 5 /* && strncmp(ent, "sbquo") == 0 */) { return 8218; } break; /* ldquo 8220 left double quotation mark, */ - case 633684828: + case 633684828u: if (len == 5 /* && strncmp(ent, "ldquo") == 0 */) { return 8220; } break; /* rdquo 8221 right double quotation mark, */ - case 1587589314: + case 1587589314u: if (len == 5 /* && strncmp(ent, "rdquo") == 0 */) { return 8221; } break; /* bdquo 8222 double low-9 quotation mark, U+201E NEW */ - case 3338811314: + case 3338811314u: if (len == 5 /* && strncmp(ent, "bdquo") == 0 */) { return 8222; } break; /* dagger 8224 dagger, U+2020 ISOpub */ - case 3288241744: + case 3288241744u: if (len == 6 /* && strncmp(ent, "dagger") == 0 */) { return 8224; } break; /* Dagger 8225 double dagger, U+2021 ISOpub */ - case 1884129968: + case 1884129968u: if (len == 6 /* && strncmp(ent, "Dagger") == 0 */) { return 8225; } break; /* permil 8240 per mille sign, U+2030 ISOtech */ - case 4246983035: + case 4246983035u: if (len == 6 /* && strncmp(ent, "permil") == 0 */) { return 8240; } break; /* lsaquo 8249 single left-pointing angle quotation mark, */ - case 2442191187: + case 2442191187u: if (len == 6 /* && strncmp(ent, "lsaquo") == 0 */) { return 8249; } break; /* rsaquo 8250 single right-pointing angle quotation mark, */ - case 2437026689: + case 2437026689u: if (len == 6 /* && strncmp(ent, "rsaquo") == 0 */) { return 8250; } break; /* euro 8364 euro sign, U+20AC NEW */ - case 2061257587: + case 2061257587u: if (len == 4 /* && strncmp(ent, "euro") == 0 */) { return 8364; } diff --git a/src/htsentities.sh b/src/htsentities.sh index 5039aee..50745cd 100755 --- a/src/htsentities.sh +++ b/src/htsentities.sh @@ -56,7 +56,7 @@ EOF i=$[${i}+1] done echo -e " /* $A */" - echo -e " case ${hash}:" + echo -e " case ${hash}u:" echo -e " if (len == ${#ent} /* && strncmp(ent, \"${ent}\") == 0 */) {" echo -e " return ${code};" echo -e " }" diff --git a/src/htsfilters.c b/src/htsfilters.c index 855cc59..ad879f4 100644 --- a/src/htsfilters.c +++ b/src/htsfilters.c @@ -54,7 +54,7 @@ Please visit our Website: http://www.httrack.com // optionnel: taille à contrôller (ou numéro, etc) en pointeur // (en de détection de *size, la taille limite est écrite par dessus *size) // exemple: +-*.gif*[<5] == supprimer GIF si <5KB -int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size, +int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * size, int *size_flag, int *depth) { int verdict = 0; // on sait pas int i; @@ -101,7 +101,7 @@ int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size, // cet algo est 'un peu' récursif mais ne consomme pas trop de tm // * = toute lettre // --?-- : spécifique à HTTrack et aux ? -HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, +HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * size, int *size_flag) { //int err=0; if (strnotempty(joker) == 0) { // fin de chaine joker @@ -262,7 +262,7 @@ HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, { int i, max; - char *adr; + const char *adr; // la chaine doit se terminer exactement if (cut) { @@ -335,8 +335,8 @@ HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, // exemple: find dans un texte de strcpybuff(*[A-Z,a-z],"*[0-9]"); va rechercher la première occurence // d'un strcpy sur une variable ayant un nom en lettres et copiant une chaine de chiffres // ATTENTION!! Eviter les jokers en début, où gare au temps machine! -char *strjokerfind(char *chaine, char *joker) { - char *adr; +const char *strjokerfind(const char *chaine, const char *joker) { + const char *adr; while(*chaine) { if ((adr = strjoker(chaine, joker, NULL, NULL))) { // ok trouvé diff --git a/src/htsfilters.h b/src/htsfilters.h index 5ed2e19..c08bd06 100644 --- a/src/htsfilters.h +++ b/src/htsfilters.h @@ -39,11 +39,11 @@ Please visit our Website: http://www.httrack.com #include "htsbase.h" -int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size, +int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * size, int *size_flag, int *depth); -HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size, +HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * size, int *size_flag); -char *strjokerfind(char *chaine, char *joker); +const char *strjokerfind(const char *chaine, const char *joker); #endif #endif diff --git a/src/htsftp.c b/src/htsftp.c index 5ea7f82..ccba1bd 100644 --- a/src/htsftp.c +++ b/src/htsftp.c @@ -142,21 +142,17 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { #endif char BIGSTK adr_ip[1024]; char *adr, *real_adr; - char *ftp_filename = ""; + const char *ftp_filename = ""; int timeout = 300; // timeout int timeout_onfly = 8; // attente réponse supplémentaire int transfer_list = 0; // directory int rest_understood = 0; // rest command understood - t_fullhostent fullhostent_buffer; // buffer pour resolver // T_SOC soc_ctl = INVALID_SOCKET; T_SOC soc_servdat = INVALID_SOCKET; T_SOC soc_dat = INVALID_SOCKET; - - // SOCaddr server_data; - int server_data_size = sizeof(server_data); // line_retr[0] = adr_ip[0] = '\0'; @@ -249,8 +245,6 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { // connexion { SOCaddr server; - int server_size = sizeof(server); - t_hostent *hp; char *a; char _adr[256]; const char *error = "unknown error"; @@ -270,8 +264,7 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { // récupérer adresse résolue strcpybuff(back->info, "host name"); - hp = hts_gethostbyname2(opt, _adr, &fullhostent_buffer, &error); - if (hp == NULL) { + if (hts_dns_resolve2(opt, _adr, &server, &error) == NULL) { snprintf(back->r.msg, sizeof(back->r.msg), "Unable to get server's address: %s", error); // back->status=STATUS_FTP_READY; // fini @@ -280,12 +273,8 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { } _CHECK_HALT_FTP; - // copie adresse - SOCaddr_copyaddr(server, server_size, hp->h_addr_list[0], hp->h_length); // copie adresse pour cnx data - SOCaddr_copyaddr(server_data, server_data_size, hp->h_addr_list[0], - hp->h_length); - // memcpy(&server.sin_addr, hp->h_addr, hp->h_length); + SOCaddr_copy_SOCaddr(server_data, server); // créer ("attachement") une socket (point d'accès) internet,en flot soc_ctl = (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, 0); @@ -302,12 +291,7 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { // connexion (bloquante, on est en thread) strcpybuff(back->info, "connect"); -#ifdef _WIN32 - if (connect(soc_ctl, (const struct sockaddr FAR *) &server, server_size) != - 0) { -#else - if (connect(soc_ctl, (struct sockaddr *) &server, server_size) == -1) { -#endif + if (connect(soc_ctl, &SOCaddr_sockaddr(server), SOCaddr_size(server)) != 0) { strcpybuff(back->r.msg, "Unable to connect to the server"); // back->status=STATUS_FTP_READY; // fini back->r.statuscode = STATUSCODE_INVALID; @@ -419,7 +403,7 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { // Pré-REST // #if FTP_PASV - if (SOCaddr_getproto(server, server_size) == '1') { + if (SOCaddr_getproto(server) == '1') { strcpybuff(back->info, "pasv"); snprintf(line, sizeof(line), "PASV"); send_line(soc_ctl, line); @@ -581,7 +565,6 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { if (port_pasv) { SOCaddr server; int server_size = sizeof(server); - t_hostent *hp; const char *error = "unknown error"; // effacer structure @@ -592,16 +575,9 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { // résoudre if (adr_ip[0]) { - hp = hts_gethostbyname2(opt, adr_ip, &fullhostent_buffer, &error); - if (hp) { - SOCaddr_copyaddr(server, server_size, hp->h_addr_list[0], - hp->h_length); - } else { - server_size = 0; - } + hts_dns_resolve2(opt, adr_ip, &server, &error); } else { - memcpy(&server, &server_data, sizeof(server_data)); - server_size = server_data_size; + SOCaddr_copy_SOCaddr(server, server_data); } // infos @@ -615,15 +591,7 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) { if (soc_dat != INVALID_SOCKET) { // structure: connexion au domaine internet, port 80 (ou autre) SOCaddr_initport(server, port_pasv); - // server.sin_port = htons((unsigned short int) port_pasv); -#ifdef _WIN32 - if (connect - (soc_dat, (const struct sockaddr FAR *) &server, - server_size) == 0) { -#else - if (connect(soc_dat, (struct sockaddr *) &server, server_size) != - -1) { -#endif + if (connect(soc_dat, &SOCaddr_sockaddr(server), SOCaddr_size(server)) == 0) { strcpybuff(back->info, "retr"); strcpybuff(line, line_retr); send_line(soc_ctl, line); @@ -856,33 +824,19 @@ T_SOC get_datasocket(char *to_send, size_t to_send_size) { to_send[0] = '\0'; if (gethostname(h_loc, 256) == 0) { // host name SOCaddr server; - int server_size = sizeof(server); - t_hostent *hp_loc; - t_fullhostent buffer; - - // effacer structure - memset(&server, 0, sizeof(server)); - - if ((hp_loc = vxgethostbyname(h_loc, &buffer))) { // notre host - - // copie adresse - SOCaddr_copyaddr(server, server_size, hp_loc->h_addr_list[0], - hp_loc->h_length); + if (hts_dns_resolve_nocache(h_loc, &server) != NULL) { // notre host if ((soc = (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, 0)) != INVALID_SOCKET) { - if (bind(soc, (struct sockaddr *) &server, server_size) == 0) { + if (bind(soc, &SOCaddr_sockaddr(server), SOCaddr_size(server)) == 0) { SOCaddr server2; - SOClen len; + SOClen len = SOCaddr_capacity(server2); - len = sizeof(server2); - // effacer structure - memset(&server2, 0, sizeof(server2)); - if (getsockname(soc, (struct sockaddr *) &server2, &len) == 0) { + if (getsockname(soc, &SOCaddr_sockaddr(server2), &len) == 0) { // *port=ntohs(server.sin_port); // récupérer port - if (listen(soc, 10) >= 0) { // au pif le 10 + if (listen(soc, 1) >= 0) { #if HTS_INET6==0 unsigned short int a, n1, n2; @@ -895,7 +849,7 @@ T_SOC get_datasocket(char *to_send, size_t to_send_size) { char dot[256 + 2]; char *a; - SOCaddr_inetntoa(dot, 256, server2, sizeof(server2)); + SOCaddr_inetntoa(dot, 256, server2); // dots[0] = '\0'; strncatbuff(dots, dot, 128); @@ -913,9 +867,9 @@ T_SOC get_datasocket(char *to_send, size_t to_send_size) { { char dot[256 + 2]; - SOCaddr_inetntoa(dot, 256, server2, len); + SOCaddr_inetntoa(dot, 256, server2); snprintf(to_send, to_send_size, "EPRT |%c|%s|%d|", - SOCaddr_getproto(server2, len), dot, + SOCaddr_getproto(server2), dot, SOCaddr_sinport(server2)); } #endif @@ -959,7 +913,7 @@ FILE *dd = NULL; // routines de réception/émission // 0 = ERROR -int send_line(T_SOC soc, char *data) { +int send_line(T_SOC soc, const char *data) { char BIGSTK line[1024]; if (_DEBUG_HEAD) { @@ -1093,7 +1047,7 @@ int check_socket(T_SOC soc) { tv.tv_sec = 0; tv.tv_usec = 0; // poll! - select(soc + 1, &fds, NULL, &fds_e, &tv); + select((int) soc + 1, &fds, NULL, &fds_e, &tv); if (FD_ISSET(soc, &fds_e)) { // error detected return -1; } else if (FD_ISSET(soc, &fds)) { @@ -1116,7 +1070,7 @@ int check_socket_connect(T_SOC soc) { tv.tv_sec = 0; tv.tv_usec = 0; // poll! - select(soc + 1, NULL, &fds, &fds_e, &tv); + select((int) soc + 1, NULL, &fds, &fds_e, &tv); if (FD_ISSET(soc, &fds_e)) { // error detected return -1; } else if (FD_ISSET(soc, &fds)) { diff --git a/src/htsftp.h b/src/htsftp.h index de2a9c5..ef6fca7 100644 --- a/src/htsftp.h +++ b/src/htsftp.h @@ -68,7 +68,7 @@ int back_launch_ftp(FTPDownloadStruct * params); #endif int run_launch_ftp(FTPDownloadStruct * params); -int send_line(T_SOC soc, char *data); +int send_line(T_SOC soc, const char *data); int get_ftp_line(T_SOC soc, char *line, size_t line_size, int timeout); T_SOC get_datasocket(char *to_send, size_t to_send_size); int stop_ftp(lien_back * back); diff --git a/src/htsglobal.h b/src/htsglobal.h index 0546017..cfefb09 100644 --- a/src/htsglobal.h +++ b/src/htsglobal.h @@ -36,8 +36,8 @@ Please visit our Website: http://www.httrack.com #define HTTRACK_GLOBAL_DEFH // Version (also check external version information) -#define HTTRACK_VERSION "3.48-6" -#define HTTRACK_VERSIONID "3.48.6" +#define HTTRACK_VERSION "3.48-13" +#define HTTRACK_VERSIONID "3.48.13" #define HTTRACK_AFF_VERSION "3.x" #define HTTRACK_LIB_VERSION "2.0" @@ -132,11 +132,6 @@ Please visit our Website: http://www.httrack.com #endif -// don't spare memory usage by default -#ifndef HTS_SPARE_MEMORY -#define HTS_SPARE_MEMORY 0 -#endif - #ifndef BIGSTK #define BIGSTK #endif @@ -206,17 +201,10 @@ Please visit our Website: http://www.httrack.com #endif -#if HTS_SPARE_MEMORY==0 /* Taille max d'une URL */ #define HTS_URLMAXSIZE 1024 /* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */ #define HTS_CDLMAXSIZE 1024 -#else -/* Taille max d'une URL */ -#define HTS_URLMAXSIZE 256 -/* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */ -#define HTS_CDLMAXSIZE 1024 -#endif /* Copyright (C) 1998-2014 Xavier Roche and other contributors */ #define HTTRACK_AFF_AUTHORS "[XR&CO'2014]" @@ -257,8 +245,14 @@ Please visit our Website: http://www.httrack.com #define HTSEXT_API __declspec(dllimport) #endif #else +/* See */ +#if ( ( defined(__GNUC__) && ( __GNUC__ >= 4 ) ) \ + || ( defined(HAVE_VISIBILITY) && HAVE_VISIBILITY ) ) +#define HTSEXT_API __attribute__ ((visibility ("default"))) +#else #define HTSEXT_API #endif +#endif #ifndef HTS_LONGLONG #ifdef HTS_NO_64_BIT @@ -329,11 +323,6 @@ typedef unsigned __int32 T_SOC; typedef int T_SOC; #endif -/* Default alignement */ -#ifndef HTS_ALIGN -#define HTS_ALIGN (sizeof(void*)) -#endif - /* IPV4, IPV6 and various unified structures */ #define HTS_MAXADDRLEN 64 @@ -378,11 +367,7 @@ typedef int T_SOC; #define LOCAL_SOCKET_ID -2 // taille de chaque buffer (10 sockets 650 ko) -#if HTS_SPARE_MEMORY==0 #define TAILLE_BUFFER 65536 -#else -#define TAILLE_BUFFER 8192 -#endif #ifdef HTS_DO_NOT_USE_PTHREAD #error needs threads support diff --git a/src/htshash.c b/src/htshash.c index 7bdf782..8cc2f1f 100644 --- a/src/htshash.c +++ b/src/htshash.c @@ -85,6 +85,14 @@ static int key_sav_equals(void *arg, const char *a, const char *b) { return strcasecmp(a, b) == 0; } +static const char* key_sav_debug_print(void *arg, const char *a) { + return a; +} + +static const char* value_sav_debug_print(void *arg, void *a) { + return (char*) a; +} + /* Pseudo-key (lien_url structure) hash function */ static inthash_keys key_adrfil_hashes_generic(void *arg, const char *value_, const int former) { @@ -151,6 +159,31 @@ static int key_adrfil_equals_generic(void *arg, const char *a_, const char *b_, } } +static const char* key_adrfil_debug_print_(void *arg, const char *a_, const int former) { + hash_struct *const hash = (hash_struct*) arg; + const lien_url*const a = (lien_url*) a_; + const char *const a_adr = !former ? a->adr : a->former_adr; + const char *const a_fil = !former ? a->fil : a->former_fil; + snprintf(hash->normfil, sizeof(hash->normfil), "%s%s", a_adr, a_fil); + return hash->normfil; +} + +static const char* key_adrfil_debug_print(void *arg, const char *a_) { + return key_adrfil_debug_print_(arg, a_, 0); +} + +static const char* key_former_adrfil_debug_print(void *arg, const char *a_) { + return key_adrfil_debug_print_(arg, a_, 1); +} + +static const char* value_adrfil_debug_print(void *arg, void *value) { + hash_struct *const hash = (hash_struct*) arg; + inthash_value v; + v.ptr = value; + snprintf(hash->normfil2, sizeof(hash->normfil2), "%d", (int) v.intg); + return hash->normfil2; +} + /* "adr"/"fil" lien_url structure members hashing function */ static inthash_keys key_adrfil_hashes(void *arg, const char *value_) { return key_adrfil_hashes_generic(arg, value_, 0); @@ -207,6 +240,20 @@ void hash_init(httrackp *opt, hash_struct * hash, int normalized) { key_former_adrfil_hashes, key_former_adrfil_equals, hash); + + /* pretty-printing */ + inthash_set_print_handler(hash->sav, + key_sav_debug_print, + value_sav_debug_print, + NULL); + inthash_set_print_handler(hash->adrfil, + key_adrfil_debug_print, + value_adrfil_debug_print, + hash); + inthash_set_print_handler(hash->former_adrfil, + key_former_adrfil_debug_print, + value_adrfil_debug_print, + hash); } void hash_free(hash_struct *hash) { @@ -260,15 +307,15 @@ int hash_read(const hash_struct * hash, const char *nom1, const char *nom2, } // enregistrement lien lpos dans les 3 tables hash1..3 -void hash_write(hash_struct * hash, int lpos) { +void hash_write(hash_struct * hash, size_t lpos) { /* first entry: destination filename (lowercased) */ - inthash_write(hash->sav, hash->liens[lpos]->sav, lpos); + inthash_write(hash->sav, (*hash->liens)[lpos]->sav, lpos); /* second entry: URL address and path */ - inthash_write(hash->adrfil, (char*) hash->liens[lpos], lpos); + inthash_write(hash->adrfil, (char*) (*hash->liens)[lpos], lpos); /* third entry: URL address and path before redirect */ - if (hash->liens[lpos]->former_adr) { // former_adr existe? - inthash_write(hash->former_adrfil, (char*) hash->liens[lpos], lpos); + if ((*hash->liens)[lpos]->former_adr) { // former_adr existe? + inthash_write(hash->former_adrfil, (char*) (*hash->liens)[lpos], lpos); } } diff --git a/src/htshash.h b/src/htshash.h index 4810513..484eb76 100644 --- a/src/htshash.h +++ b/src/htshash.h @@ -55,7 +55,7 @@ void hash_init(httrackp *opt, hash_struct *hash, int normalized); void hash_free(hash_struct *hash); int hash_read(const hash_struct * hash, const char *nom1, const char *nom2, hash_struct_type type); -void hash_write(hash_struct * hash, int lpos); +void hash_write(hash_struct * hash, size_t lpos); int *hash_calc_chaine(hash_struct * hash, hash_struct_type type, int pos); unsigned long int hash_cle(const char *nom1, const char *nom2); #endif diff --git a/src/htshelp.c b/src/htshelp.c index 239e857..2416030 100644 --- a/src/htshelp.c +++ b/src/htshelp.c @@ -52,7 +52,7 @@ Please visit our Website: http://www.httrack.com /* END specific definitions */ #define waitkey if (more) { char s[4]; printf("\nMORE.. q to quit\n"); linput(stdin,s,4); if (strcmp(s,"q")==0) quit=1; else printf("Page %d\n\n",++m); } -void infomsg(char *msg) { +void infomsg(const char *msg) { int l = 0; int m = 0; int more = 0; @@ -332,7 +332,7 @@ void help_wizard(httrackp * opt) { printf("\n"); // couper en morceaux - argv[0] = "winhttrack"; + argv[0] = strdup("winhttrack"); argv[1] = cmd; argc++; while(cmd[i]) { @@ -364,15 +364,15 @@ void help_wizard(httrackp * opt) { #undef str #undef argv } -int help_query(char *list, int def) { +int help_query(const char *list, int def) { char s[256]; - char *a; + const char *a; int opt; int n = 1; a = list; while(strnotempty(a)) { - char *b = strchr(a, '|'); + const char *b = strchr(a, '|'); if (b) { char str[256]; @@ -455,7 +455,7 @@ void help_catchurl(const char *dest_path) { } // Créer un index.html vide -void make_empty_index(char *str) { +void make_empty_index(const char *str) { #if 0 if (!fexist(fconcat(str, "index.html"))) { FILE *fp = fopen(fconcat(str, "index.html"), "wb"); @@ -473,7 +473,7 @@ void make_empty_index(char *str) { // mini-aide (h: help) // y -void help(char *app, int more) { +void help(const char *app, int more) { char info[2048]; infomsg(""); @@ -605,7 +605,7 @@ void help(char *app, int more) { infomsg (" %F footer string in Html code (-%F \"Mirrored [from host %s [file %s [at %s]]]\""); infomsg(" %l preffered language (-%l \"fr, en, jp, *\""); - infomsg(" %a accepted formats (-%l \"text/html,image/png,image/jpeg,image/gif;q=0.9,*/*;q=0.1\""); + infomsg(" %a accepted formats (-%a \"text/html,image/png;q=0.9,*/*;q=0.1\""); infomsg(" %X additional HTTP header line (-%X \"X-Magic: 42\""); infomsg(""); infomsg("Log, index, cache"); diff --git a/src/htshelp.h b/src/htshelp.h index 5f1b75b..7add77e 100644 --- a/src/htshelp.h +++ b/src/htshelp.h @@ -43,11 +43,11 @@ Please visit our Website: http://www.httrack.com typedef struct httrackp httrackp; #endif -void infomsg(char *msg); -void help(char *app, int more); -void make_empty_index(char *str); +void infomsg(const char *msg); +void help(const char *app, int more); +void make_empty_index(const char *str); void help_wizard(httrackp * opt); -int help_query(char *list, int def); +int help_query(const char *list, int def); void help_catchurl(const char *dest_path); #endif diff --git a/src/htsindex.c b/src/htsindex.c index 1d08012..1dca05c 100644 --- a/src/htsindex.c +++ b/src/htsindex.c @@ -103,7 +103,7 @@ Please visit our Website: http://www.httrack.com /* End of Keyword Indexer Parameters */ -int strcpos(char *adr, char c); +int strcpos(const char *adr, char c); int mystrcmp(const void *_e1, const void *_e2); // Global variables @@ -468,8 +468,8 @@ void index_finish(const char *indexpath, int mode) { /* Subroutines */ #if HTS_MAKE_KEYWORD_INDEX -int strcpos(char *adr, char c) { - char *apos = strchr(adr, c); +int strcpos(const char *adr, char c) { + const char *apos = strchr(adr, c); if (apos) return (int) (apos - adr); diff --git a/src/htsinthash.c b/src/htsinthash.c index 6e32aee..b842651 100644 --- a/src/htsinthash.c +++ b/src/htsinthash.c @@ -187,6 +187,16 @@ struct struct_inthash { /** hashtable name for logging **/ const char *name; } error; + + /** How to handle pretty-print (debug) (might be NULL). **/ + struct { + /** key print() **/ + t_inthash_printkeyhandler key; + /** value print() **/ + t_inthash_printvaluehandler value; + /** opaque argument **/ + void *arg; + } print; } custom; }; @@ -889,10 +899,62 @@ static int inthash_add_item_(inthash hashtable, inthash_item item) { (int) hashtable->stash.size); return 1; /* added */ } else { + /* debugging */ + if (hashtable->custom.print.key != NULL + && hashtable->custom.print.value != NULL) { + size_t i; + for(i = 0 ; i < hashtable->stash.size ; i++) { + inthash_item *const item = &hashtable->stash.items[i]; + const size_t pos1 = inthash_hash_to_pos(hashtable, item->hashes.hash1); + const size_t pos2 = inthash_hash_to_pos(hashtable, item->hashes.hash2); + inthash_crit(hashtable, + "stash[%u]: key='%s' value='%s' pos1=%d pos2=%d hash1=%04x hash2=%04x", + (int) i, + hashtable->custom.print.key(hashtable->custom.print.arg, item->name), + hashtable->custom.print.value(hashtable->custom.print.arg, item->value.ptr), + (int) pos1, (int) pos2, + item->hashes.hash1, item->hashes.hash2); + if (!inthash_is_free(hashtable, pos1)) { + inthash_item *const item = &hashtable->items[pos1]; + const size_t pos1 = inthash_hash_to_pos(hashtable, item->hashes.hash1); + const size_t pos2 = inthash_hash_to_pos(hashtable, item->hashes.hash2); + inthash_crit(hashtable, + "\t.. collisionning with key='%s' value='%s' pos1=%d pos2=%d hash1=%04x hash2=%04x", + hashtable->custom.print.key(hashtable->custom.print.arg, item->name), + hashtable->custom.print.value(hashtable->custom.print.arg, item->value.ptr), + (int) pos1, (int) pos2, + item->hashes.hash1, item->hashes.hash2); + } else { + inthash_crit(hashtable, "\t.. collisionning with a free slot (%d)!", (int) pos1); + } + if (!inthash_is_free(hashtable, pos2)) { + inthash_item *const item = &hashtable->items[pos2]; + const size_t pos1 = inthash_hash_to_pos(hashtable, item->hashes.hash1); + const size_t pos2 = inthash_hash_to_pos(hashtable, item->hashes.hash2); + inthash_crit(hashtable, + "\t.. collisionning with key='%s' value='%s' pos1=%d pos2=%d hash1=%04x hash2=%04x", + hashtable->custom.print.key(hashtable->custom.print.arg, item->name), + hashtable->custom.print.value(hashtable->custom.print.arg, item->value.ptr), + (int) pos1, (int) pos2, + item->hashes.hash1, item->hashes.hash2); + } else { + inthash_crit(hashtable, "\t.. collisionning with a free slot (%d)!", (int) pos2); + } + } + //struct_inthash_enum e = inthash_enum_new(hashtable); + //while((item = inthash_enum_next(&e)) != NULL) { + // inthash_crit(hashtable, "element key='%s' value='%s' hash1=%04x hash2=%04x", + // hashtable->custom.print.key(hashtable->custom.print.arg, item->name), + // hashtable->custom.print.value(hashtable->custom.print.arg, item->value.ptr), + // item->hashes.hash1, item->hashes.hash2); + //} + } + /* we are doomed. hopefully the probability is lower than being killed by a wandering radioactive monkey */ inthash_log_stats(hashtable); inthash_assert(hashtable, ! "hashtable internal error: cuckoo/stash collision"); + /* not reachable code */ return -1; } @@ -934,7 +996,7 @@ int inthash_write_value(inthash hashtable, const char *name, inthash_warning(hashtable, "stash size still full despite %"UINT_64_FORMAT " elements used out of %"UINT_64_FORMAT, - hashtable->used, half_size*2); + (uint64_t) hashtable->used, (uint64_t) half_size*2); } /* statistics */ @@ -1235,9 +1297,13 @@ inthash inthash_new(size_t initial_size) { hashtable->custom.key.hash = NULL; hashtable->custom.key.equals = NULL; hashtable->custom.key.arg = NULL; + hashtable->custom.error.log = NULL; hashtable->custom.error.fatal = NULL; hashtable->custom.error.name = NULL; hashtable->custom.error.arg = NULL; + hashtable->custom.print.key = NULL; + hashtable->custom.print.value = NULL; + hashtable->custom.print.arg = NULL; } return hashtable; } @@ -1288,12 +1354,20 @@ void inthash_set_assert_handler(inthash hashtable, t_inthash_loghandler log, t_inthash_asserthandler fatal, void *arg) { - inthash_assert(hashtable, fatal != NULL); hashtable->custom.error.log = log; hashtable->custom.error.fatal = fatal; hashtable->custom.error.arg = arg; } +void inthash_set_print_handler(inthash hashtable, + t_inthash_printkeyhandler key, + t_inthash_printvaluehandler value, + void *arg) { + hashtable->custom.print.key = key; + hashtable->custom.print.value = value; + hashtable->custom.print.arg = arg; +} + size_t inthash_nitems(inthash hashtable) { if (hashtable != NULL) return hashtable->used; diff --git a/src/htsinthash.h b/src/htsinthash.h index 037e25d..a2689b6 100644 --- a/src/htsinthash.h +++ b/src/htsinthash.h @@ -67,6 +67,7 @@ typedef unsigned __int64 uint64_t; #else #include #endif +#include /** Value. **/ typedef union inthash_value { @@ -140,6 +141,12 @@ typedef void (*t_inthash_loghandler)(void *arg, inthash_loglevel level, /** Hashtable fatal assertion failure. **/ typedef void (*t_inthash_asserthandler)(void *arg, const char* exp, const char* file, int line); +/** Key printer (debug) **/ +typedef const char* (*t_inthash_printkeyhandler)(void *arg, const char *name); + +/** Value printer (debug) **/ +typedef const char* (*t_inthash_printvaluehandler)(void *arg, void *value); + /** * Value comparison handler (returns non-zero value if strings are equal). **/ @@ -166,6 +173,10 @@ struct struct_inthash_enum { /* Library internal definictions */ #ifdef HTS_INTERNAL_BYTECODE +#ifdef __cplusplus +extern "C" { +#endif + /** * Create a new hashtable, with initial bucket size of 'size'. * If size is 0, use the default minimal bucket size. @@ -240,6 +251,18 @@ void inthash_set_assert_handler(inthash hashtable, t_inthash_asserthandler fatal, void *arg); +/** + * Set pretty print loggers (debug). Both handlers must return a string + * pointer which shall be valid until the next call. Both key and value + * pointers shall be valid at the same time. + * name: handler called to print the string representation of the name + * value: handler called to print the string representation of the value + **/ +void inthash_set_print_handler(inthash hashtable, + t_inthash_printkeyhandler key, + t_inthash_printvaluehandler value, + void *arg); + /** * Set the hashtable name, for degugging purpose. * name: the hashtable name (ASCII or UTF-8) @@ -358,6 +381,10 @@ inthash_keys inthash_hash_value(const char *value); void inthash_set_global_assert_handler(t_inthash_loghandler log, t_inthash_asserthandler fatal); +#ifdef __cplusplus +} +#endif + #endif #endif diff --git a/src/htsjava.c b/src/htsjava.c index 0098994..44ecbc4 100644 --- a/src/htsjava.c +++ b/src/htsjava.c @@ -493,8 +493,9 @@ static char *printname(char rname[1024], char name[1024]) { p = &name[0]; - if (*p != '[') - return ""; + if (*p != '[') { + return rname; // "" + } p += 2; //rname=(char*)calloct(strlen(name)+8,sizeof(char)); p1 = rname; @@ -504,13 +505,13 @@ static char *printname(char rname[1024], char name[1024]) { if (*p == ';') { *p1 = '\0'; strcat(rname, ".class"); - return (rname); + return rname; } else *p1 = *p; p1++; } p1 -= 3; *p1 = '\0'; - return (rname); + return rname; } diff --git a/src/htslib.c b/src/htslib.c index d1936cc..1b29f3a 100644 --- a/src/htslib.c +++ b/src/htslib.c @@ -62,6 +62,7 @@ Please visit our Website: http://www.httrack.com #include #endif #endif /* _WIN32 */ +#include #include #include @@ -83,6 +84,13 @@ static long int timezone = 0; #include /* END specific definitions */ +/* Windows might be missing va_copy */ +#ifdef _WIN32 +#ifndef va_copy +#define va_copy(dst, src) ((dst) = (src)) +#endif +#endif + // Debugging #if _HTS_WIDE FILE *DEBUG_fp = NULL; @@ -601,7 +609,7 @@ void hts_init_htsblk(htsblk * r) { // ouvre une liaison http, envoie une requète GET et réceptionne le header // retour: socket -T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour) { +T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * retour) { // / GET, traiter en-tête return http_xfopen(opt, 0, 1, 1, NULL, adr, fil, retour); } @@ -612,10 +620,11 @@ T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour) { // waitconnect: attendre le connect() // note: dans retour, on met les params du proxy T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, - char *xsend, char *adr, char *fil, htsblk * retour) { + const char *xsend, const char *adr, const char *fil, htsblk * retour) { //htsblk retour; //int bufl=TAILLE_BUFFER; // 8Ko de buffer T_SOC soc = INVALID_SOCKET; + char BIGSTK tempo_fil[HTS_URLMAXSIZE * 2]; //char *p,*q; @@ -691,10 +700,8 @@ T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, (fconv (OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), unescape_http(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), fil + 1)))) { - char BIGSTK tempo[HTS_URLMAXSIZE * 2]; - - strcpybuff(tempo, fil + 1); - strcpybuff(fil, tempo); + strcpybuff(tempo_fil, fil + 1); + fil = tempo_fil; } // Ouvrir retour->totalsize = fsize(fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), @@ -837,15 +844,16 @@ static void print_buffer(buff_struct*const str, const char *format, ...) { } // envoi d'une requète -int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, - char *adr, char *fil, char *referer_adr, char *referer_fil, +int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, + const char *xsend, const char *adr, const char *fil, + const char *referer_adr, const char *referer_fil, htsblk * retour) { char BIGSTK buffer_head_request[8192]; buff_struct bstr = { buffer_head_request, sizeof(buffer_head_request), 0 }; //int use_11=0; // HTTP 1.1 utilisé int direct_url = 0; // ne pas analyser l'url (exemple: ftp://) - char *search_tag = NULL; + const char *search_tag = NULL; // Initialize buffer buffer_head_request[0] = '\0'; @@ -1046,7 +1054,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, } { - char *real_adr = jump_identification(adr); + const char *real_adr = jump_identification(adr); // Mandatory per RFC2616 if (!direct_url) { // pas ftp:// par exemple @@ -1091,12 +1099,12 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, /* Authentification */ { char autorisation[1100]; - char *a; + const char *a; autorisation[0] = '\0'; if (link_has_authorization(adr)) { // ohh une authentification! - char *a = jump_identification(adr); - char *astart = jump_protocol(adr); + const char *a = jump_identification(adr); + const char *astart = jump_protocol(adr); if (!direct_url) { // pas ftp:// par exemple char user_pass[256]; @@ -1176,8 +1184,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, } // traiter 1ere ligne d'en tête -void treatfirstline(htsblk * retour, char *rcvd) { - char *a = rcvd; +void treatfirstline(htsblk * retour, const char *rcvd) { + const char *a = rcvd; // exemple: // HTTP/1.0 200 OK @@ -1247,7 +1255,7 @@ void treatfirstline(htsblk * retour, char *rcvd) { // traiter ligne par ligne l'en tête // gestion des cookies -void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, +void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * retour, char *rcvd) { int p; @@ -1380,7 +1388,7 @@ void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, } } else if ((p = strfield(rcvd, "Content-Range:")) != 0) { // Content-Range: bytes 0-70870/70871 - char *a; + const char *a; for(a = rcvd + p; is_space(*a); a++) ; if (strncasecmp(a, "bytes ", 6) == 0) { @@ -1976,42 +1984,12 @@ LLint http_xfread1(htsblk * r, int bufl) { } } -// teste une adresse, et suit l'éventuel chemin "moved" -// retourne 200 ou le code d'erreur (404=NOT FOUND, etc) -// copie dans loc la véritable adresse si celle-ci est différente -htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc) { - htsblk retour; - int retry = 0; - int tryagain; - - // note: "RFC says" - // 5 boucles au plus, on en teste au plus 8 ici - // sinon abandon.. - do { - tryagain = 0; - switch ((retour = http_test(opt, adr, fil, loc)).statuscode) { - case HTTP_OK: - break; // ok! - case HTTP_MOVED_PERMANENTLY: - case HTTP_FOUND: - case HTTP_SEE_OTHER: - case HTTP_TEMPORARY_REDIRECT: // moved! - // recalculer adr et fil! - if (ident_url_absolute(loc, adr, fil) != -1) { - tryagain = 1; // retenter - retry++; // ..encore une fois - } - } - } while((tryagain) && (retry < 5 + 3)); - return retour; -} - // teste si une URL (validité, header, taille) // retourne 200 ou le code d'erreur (404=NOT FOUND, etc) // en cas de moved xx, dans location // abandonne désormais au bout de 30 secondes (aurevoir les sites // qui nous font poireauter 5 heures..) -> -2=timeout -htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc) { +htsblk http_test(httrackp * opt, const char *adr, const char *fil, char *loc) { T_SOC soc; htsblk retour; @@ -2118,27 +2096,16 @@ htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc) { // peut ouvrir avec des connect() non bloquants: waitconnect=0/1 T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, int waitconnect) { - t_fullhostent fullhostent_buffer; // buffer pour resolver T_SOC soc; // descipteur de la socket - char *iadr; - // unsigned short int port; - - // si iadr="#" alors c'est une fausse URL, mais un vrai fichier - // local. - // utile pour les tests! - //## if (iadr[0]!=lOCAL_CHAR) { if (strcmp(_iadr, "file://") != 0) { /* non fichier */ SOCaddr server; - int server_size = sizeof(server); - t_hostent *hp; const char *error = "unknown error"; - // effacer structure - memset(&server, 0, sizeof(server)); - // tester un éventuel id:pass et virer id:pass@ si détecté - iadr = jump_identification(_iadr); + const char *const iadr = jump_identification(_iadr); + + SOCaddr_clear(server); #if HDEBUG printf("gethostbyname\n"); @@ -2156,7 +2123,8 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, #else port = 80; // port par défaut #endif - if (a) { + + if (a != NULL) { char BIGSTK iadr2[HTS_URLMAXSIZE * 2]; int i = -1; @@ -2165,25 +2133,24 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, if (i != -1) { port = (unsigned short int) i; } + // adresse véritable (sans :xx) strncatbuff(iadr2, iadr, (int) (a - iadr)); // adresse sans le :xx - hp = hts_gethostbyname2(opt, iadr2, &fullhostent_buffer, &error); + hts_dns_resolve2(opt, iadr2, &server, &error); } else { // adresse normale (port par défaut par la suite) - hp = hts_gethostbyname2(opt, iadr, &fullhostent_buffer, &error); + hts_dns_resolve2(opt, iadr, &server, &error); } - } else // port défini - hp = hts_gethostbyname2(opt, iadr, &fullhostent_buffer, &error); + } else { // port défini + hts_dns_resolve2(opt, iadr, &server, &error); + } - // Conversion iadr -> adresse - // structure recevant le nom de l'hôte, etc - //struct hostent *hp; - if (hp == NULL) { + if (!SOCaddr_is_valid(server)) { #if DEBUG printf("erreur gethostbyname\n"); #endif @@ -2198,13 +2165,10 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, } return INVALID_SOCKET; } - // copie adresse - SOCaddr_copyaddr(server, server_size, hp->h_addr_list[0], hp->h_length); + // make a copy for external clients - retour->address_size = sizeof(retour->address); - SOCaddr_copyaddr(retour->address, retour->address_size, hp->h_addr_list[0], - hp->h_length); - // memcpy(&SOCaddr_sinaddr(server), hp->h_addr_list[0], hp->h_length); + SOCaddr_copy_SOCaddr(retour->address, server); + retour->address_size = SOCaddr_size(retour->address); // créer ("attachement") une socket (point d'accès) internet,en flot #if HDEBUG @@ -2238,14 +2202,13 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, } // bind this address if (retour != NULL && strnotempty(retour->req.proxy.bindhost)) { - t_fullhostent bind_buffer; const char *error = "unknown error"; + SOCaddr bind_addr; - hp = hts_gethostbyname2(opt, retour->req.proxy.bindhost, &bind_buffer, - &error); - if (hp == NULL - || bind(soc, (struct sockaddr *) hp->h_addr_list[0], - hp->h_length) != 0) { + if (hts_dns_resolve2(opt, retour->req.proxy.bindhost, + &bind_addr, &error) == NULL + || bind(soc, &SOCaddr_sockaddr(bind_addr), + SOCaddr_size(bind_addr)) != 0) { if (retour && retour->msg) { #ifdef _WIN32 snprintf(retour->msg, sizeof(retour->msg), @@ -2297,25 +2260,20 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, #if HTS_WIDE_DEBUG DEBUG_W("connect\n"); #endif -#ifdef _WIN32 - if (connect(soc, (const struct sockaddr FAR *) &server, server_size) != 0) { -#else - if (connect(soc, (struct sockaddr *) &server, server_size) == -1) { -#endif - + if (connect(soc, &SOCaddr_sockaddr(server), SOCaddr_size(server)) != 0) { // bloquant if (waitconnect) { #if HDEBUG printf("unable to connect!\n"); #endif - if (retour && retour->msg) { + if (retour != NULL && retour->msg) { #ifdef _WIN32 - int last_errno = WSAGetLastError(); + const int last_errno = WSAGetLastError(); sprintf(retour->msg, "Unable to connect to the server: %s", strerror(last_errno)); #else - int last_errno = errno; + const int last_errno = errno; sprintf(retour->msg, "Unable to connect to the server: %s", strerror(last_errno)); @@ -2352,12 +2310,12 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port, // couper http://www.truc.fr/pub/index.html -> www.truc.fr /pub/index.html // retour=-1 si erreur. // si file://... alors adresse=file:// (et coupe le ?query dans ce cas) -int ident_url_absolute(const char *url, char *adr, char *fil) { +int ident_url_absolute(const char *url, lien_adrfil *adrfil) { int pos = 0; int scheme = 0; - // effacer adr et fil - adr[0] = fil[0] = '\0'; + // effacer adrfil->adr et adrfil->fil + adrfil->adr[0] = adrfil->fil[0] = '\0'; #if HDEBUG printf("protocol: %s\n", url); @@ -2376,15 +2334,15 @@ int ident_url_absolute(const char *url, char *adr, char *fil) { // 1. optional scheme ":" if ((pos = strfield(url, "file:"))) { // fichier local!! (pour les tests) //!!p+=3; - strcpybuff(adr, "file://"); + strcpybuff(adrfil->adr, "file://"); } else if ((pos = strfield(url, "http:"))) { // HTTP //!!p+=3; } else if ((pos = strfield(url, "ftp:"))) { // FTP - strcpybuff(adr, "ftp://"); // FTP!! + strcpybuff(adrfil->adr, "ftp://"); // FTP!! //!!p+=3; #if HTS_USEOPENSSL } else if ((pos = strfield(url, "https:"))) { // HTTPS - strcpybuff(adr, "https://"); + strcpybuff(adrfil->adr, "https://"); #endif } else if (scheme) { return -1; // erreur non reconnu @@ -2397,13 +2355,13 @@ int ident_url_absolute(const char *url, char *adr, char *fil) { // (url+pos) now points to the path (not net path) - //## if (adr[0]!=lOCAL_CHAR) { // adresse normale http - if (!strfield(adr, "file:")) { // PAS file:// + //## if (adrfil->adr[0]!=lOCAL_CHAR) { // adrfil->adresse normale http + if (!strfield(adrfil->adr, "file:")) { // PAS adrfil->file:// const char *p, *q; p = url + pos; - // p pointe sur le début de l'adresse, ex: www.truc.fr/sommaire/index.html + // p pointe sur le début de l'adrfil->adresse, ex: www.truc.fr/sommaire/index.html q = strchr(jump_identification(p), '/'); if (q == 0) q = strchr(jump_identification(p), '?'); // http://www.foo.com?bar=1 @@ -2416,53 +2374,53 @@ int ident_url_absolute(const char *url, char *adr, char *fil) { //strcpybuff(retour.msg,"Path too long"); return -1; // erreur } - // recopier adresse www.. - strncatbuff(adr, p, ((int) (q - p))); - // *( adr+( ((int) q) - ((int) p) ) )=0; // faut arrêter la fumette! + // recopier adrfil->adresse www.. + strncatbuff(adrfil->adr, p, ((int) (q - p))); + // *( adrfil->adr+( ((int) q) - ((int) p) ) )=0; // faut arrêter la fumette! // recopier chemin /pub/.. if (q[0] != '/') // page par défaut (/) - strcatbuff(fil, "/"); - strcatbuff(fil, q); + strcatbuff(adrfil->fil, "/"); + strcatbuff(adrfil->fil, q); // SECURITE: // simplifier url pour les ../ - fil_simplifie(fil); - } else { // localhost file:// + fil_simplifie(adrfil->fil); + } else { // localhost adrfil->file:// const char *p; size_t i; char *a; p = url + pos; - if (*p == '/' || *p == '\\') { /* file:///.. */ - strcatbuff(fil, p); // fichier local ; adr="#" + if (*p == '/' || *p == '\\') { /* adrfil->file:///.. */ + strcatbuff(adrfil->fil, p); // fichier local ; adrfil->adr="#" } else { if (p[1] != ':') { - strcatbuff(fil, "//"); /* file://server/foo */ - strcatbuff(fil, p); + strcatbuff(adrfil->fil, "//"); /* adrfil->file://server/foo */ + strcatbuff(adrfil->fil, p); } else { - strcatbuff(fil, p); // file://C:\.. + strcatbuff(adrfil->fil, p); // adrfil->file://C:\.. } } - a = strchr(fil, '?'); + a = strchr(adrfil->fil, '?'); if (a) - *a = '\0'; /* couper query (inutile pour file:// lors de la requête) */ - // filtrer les \\ -> / pour les fichiers DOS - for(i = 0; fil[i] != '\0'; i++) - if (fil[i] == '\\') - fil[i] = '/'; + *a = '\0'; /* couper query (inutile pour adrfil->file:// lors de la requête) */ + // adrfil->filtrer les \\ -> / pour les fichiers DOS + for(i = 0; adrfil->fil[i] != '\0'; i++) + if (adrfil->fil[i] == '\\') + adrfil->fil[i] = '/'; } // no hostname - if (!strnotempty(adr)) + if (!strnotempty(adrfil->adr)) return -1; // erreur non reconnu // nommer au besoin.. (non utilisé normalement) - if (!strnotempty(fil)) - strcpybuff(fil, "default-index.html"); + if (!strnotempty(adrfil->fil)) + strcpybuff(adrfil->fil, "default-index.html"); - // case insensitive pour adresse + // case insensitive pour adrfil->adresse { - char *a = jump_identification(adr); + char *a = jump_identification(adrfil->adr); while(*a) { if ((*a >= 'A') && (*a <= 'Z')) @@ -2983,13 +2941,13 @@ int sendc(htsblk * r, const char *s) { } // Remplace read -int finput(int fd, char *s, int max) { +int finput(T_SOC fd, char *s, int max) { char c; int j = 0; do { //c=fgetc(fp); - if (read(fd, &c, 1) <= 0) { + if (read((int) fd, &c, 1) <= 0) { c = 0; } if (c != 0) { @@ -3093,7 +3051,7 @@ int linputsoc_t(T_SOC soc, char *s, int max, int timeout) { } int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; - char *ls = (char *) malloct(max + 2); + char *ls = (char *) malloct(max + 1); s[0] = '\0'; if (ls) { @@ -3165,8 +3123,8 @@ void rawlinput(FILE * fp, char *s, int max) { } //cherche chaine, case insensitive -char *strstrcase(char *s, char *o) { - while((*s) && (strfield(s, o) == 0)) +char *strstrcase(char *s, const char *o) { + while(*s && strfield(s, o) == 0) s++; if (*s == '\0') return NULL; @@ -4289,7 +4247,7 @@ int may_unknown2(httrackp * opt, const char *mime, const char *filename) { // -- Utils fichiers // pretty print for i/o -void fprintfio(FILE * fp, char *buff, char *prefix) { +void fprintfio(FILE * fp, const char *buff, const char *prefix) { char nl = 1; while(*buff) { @@ -4404,15 +4362,17 @@ typedef struct { char path[1024 + 4]; int init; } hts_rootdir_strc; -HTSEXT_API char *hts_rootdir(char *file) { +HTSEXT_API const char *hts_rootdir(char *file) { static hts_rootdir_strc strc = { "", 0 }; if (file) { if (!strc.init) { strc.path[0] = '\0'; strc.init = 1; if (strnotempty(file)) { + const size_t file_len = strlen(file); char *a; + assertf(file_len < sizeof(strc.path)); strcpybuff(strc.path, file); while((a = strrchr(strc.path, '\\'))) *a = '/'; @@ -4422,7 +4382,7 @@ HTSEXT_API char *hts_rootdir(char *file) { strc.path[0] = '\0'; } if (!strnotempty(strc.path)) { - if (getcwd(strc.path, 1024) == NULL) + if (getcwd(strc.path, sizeof(strc.path)) == NULL) strc.path[0] = '\0'; else strcatbuff(strc.path, "/"); @@ -4558,7 +4518,6 @@ int hts_read(htsblk * r, char *buff, int size) { // -- Gestion cache DNS -- // 'RX98 -#if HTS_DNSCACHE // 'capsule' contenant uniquement le cache t_dnscache *_hts_cache(httrackp * opt) { @@ -4592,63 +4551,47 @@ void hts_cache_free(t_dnscache *const root) { // routine pour le cache - retour optionnel à donner à chaque fois // NULL: nom non encore testé dans le cache // si h_length==0 alors le nom n'existe pas dans le dns -static t_hostent *hts_ghbn(const t_dnscache *cache, const char *const iadr, t_hostent *retour) { +static SOCaddr* hts_ghbn(const t_dnscache *cache, const char *const iadr, SOCaddr *const addr) { + assertf(addr != NULL); for(; cache != NULL; cache = cache->n) { assertf(cache != NULL); assertf(iadr != NULL); if (cache->iadr != NULL && strcmp(cache->iadr, iadr) == 0) { // ok trouvé if (cache->host_length > 0) { // entrée valide - if (retour->h_addr_list[0]) - memcpy(retour->h_addr_list[0], cache->host_addr, cache->host_length); - retour->h_length = cache->host_length; + SOCaddr_copyaddr2(*addr, cache->host_addr, cache->host_length); + return addr; } else if (cache->host_length == 0) { // en cours return NULL; } else { // erreur dans le dns, déja vérifié - if (retour->h_addr_list[0]) - retour->h_addr_list[0][0] = '\0'; - retour->h_length = 0; // erreur, n'existe pas + SOCaddr_clear(*addr); + return addr; } - return retour; } } return NULL; } -static t_hostent *vxgethostbyname2_(const char *const hostname, - void *const v_buffer, const char **error) { - t_fullhostent *buffer = (t_fullhostent *) v_buffer; - - /* Clear */ - fullhostent_init(buffer); - +static SOCaddr* hts_dns_resolve_nocache2_(const char *const hostname, + SOCaddr *const addr, + const char **error) { { #if HTS_INET6==0 - /* - ipV4 resolver - */ - t_hostent *hp = gethostbyname(hostname); + /* IPv4 resolver */ + struct hostent *const hp = gethostbyname(hostname); if (hp != NULL) { - if ((hp->h_length) - && (((unsigned int) hp->h_length) <= buffer->addr_maxlen)) { - memcpy(buffer->hp.h_addr_list[0], hp->h_addr_list[0], hp->h_length); - buffer->hp.h_length = hp->h_length; - return &(buffer->hp); - } + SOCaddr_copyaddr2(addr, hp->h_addr_list[0], hp->h_length); + return SOCaddr_is_valid(addr) ? &addr : NULL; + } else { + SOCaddr_clear(*addr); } #else - /* - ipV6 resolver - */ - /* - int error_num=0; - t_hostent* hp=getipnodebyname(hostname, AF_INET6, AI_DEFAULT, &error_num); - oops, deprecated :( - */ + /* IPv6 resolver */ struct addrinfo *res = NULL; struct addrinfo hints; int gerr; + SOCaddr_clear(*addr); memset(&hints, 0, sizeof(hints)); if (IPV6_resolver == 1) // V4 only (for bogus V6 entries) hints.ai_family = PF_INET; @@ -4659,13 +4602,9 @@ static t_hostent *vxgethostbyname2_(const char *const hostname, hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if ( ( gerr = getaddrinfo(hostname, NULL, &hints, &res) ) == 0) { - if (res) { - if ((res->ai_addr) && (res->ai_addrlen) - && (res->ai_addrlen <= buffer->addr_maxlen)) { - memcpy(buffer->hp.h_addr_list[0], res->ai_addr, res->ai_addrlen); - buffer->hp.h_length = (short) res->ai_addrlen; - freeaddrinfo(res); - return &(buffer->hp); + if (res != NULL) { + if (res->ai_addr != NULL && res->ai_addrlen != 0) { + SOCaddr_copyaddr2(*addr, res->ai_addr, res->ai_addrlen); } } } else { @@ -4678,11 +4617,12 @@ static t_hostent *vxgethostbyname2_(const char *const hostname, } #endif } - return NULL; + + return SOCaddr_is_valid(*addr) ? addr : NULL; } -HTSEXT_API t_hostent *vxgethostbyname2(const char *const hostname, - void *const v_buffer, const char **error) { +HTSEXT_API SOCaddr* hts_dns_resolve_nocache2(const char *const hostname, + SOCaddr *const addr, const char **error) { /* Protection */ if (!strnotempty(hostname)) { return NULL; @@ -4693,43 +4633,40 @@ HTSEXT_API t_hostent *vxgethostbyname2(const char *const hostname, The resolver doesn't seem to handle IP6 addresses in brackets */ if ((hostname[0] == '[') && (hostname[strlen(hostname) - 1] == ']')) { - t_hostent *ret; + SOCaddr *ret; size_t size = strlen(hostname); char *copy = malloct(size + 1); assertf(copy != NULL); copy[0] = '\0'; strncat(copy, hostname + 1, size - 2); - ret = vxgethostbyname2_(copy, v_buffer, error); + ret = hts_dns_resolve_nocache2_(copy, addr, error); freet(copy); return ret; } else { - return vxgethostbyname2_(hostname, v_buffer, error); + return hts_dns_resolve_nocache2_(hostname, addr, error); } } -HTSEXT_API t_hostent *vxgethostbyname(const char *const hostname, void *v_buffer) { - return vxgethostbyname2(hostname, v_buffer, NULL); +HTSEXT_API SOCaddr* hts_dns_resolve_nocache(const char *const hostname, SOCaddr *const addr) { + return hts_dns_resolve_nocache2(hostname, addr, NULL); } HTSEXT_API int check_hostname_dns(const char *const hostname) { - t_fullhostent buffer; - return vxgethostbyname(hostname, &buffer) != NULL; + SOCaddr buffer; + return hts_dns_resolve_nocache(hostname, &buffer) != NULL; } // Needs locking // cache dns interne à HTS // ** FREE A FAIRE sur la chaine -static t_hostent *hts_gethostbyname_(httrackp * opt, const char *_iadr, void *v_buffer, const char **error) { +static SOCaddr* hts_dns_resolve_(httrackp * opt, const char *_iadr, + SOCaddr *const addr, const char **error) { char BIGSTK iadr[HTS_URLMAXSIZE * 2]; - t_fullhostent *buffer = (t_fullhostent *) v_buffer; t_dnscache *cache = _hts_cache(opt); // adresse du cache - t_hostent *hp; + SOCaddr *sa; assertf(opt != NULL); assertf(_iadr != NULL); - assertf(v_buffer != NULL); - - /* Clear */ - fullhostent_init(buffer); + assertf(addr != NULL); strcpybuff(iadr, jump_identification(_iadr)); // couper éventuel : @@ -4741,92 +4678,56 @@ static t_hostent *hts_gethostbyname_(httrackp * opt, const char *_iadr, void *v_ } /* get IP from the dns cache */ - hp = hts_ghbn(cache, iadr, &buffer->hp); - if (hp) { - if (hp->h_length > 0) - return hp; - else - return NULL; // entrée erronée (erreur DNS) dans le DNS + sa = hts_ghbn(cache, iadr, addr); + if (sa != NULL) { + return SOCaddr_is_valid(*sa) ? sa : NULL; } else { // non présent dans le cache dns, tester // find queue for(; cache->n != NULL; cache = cache->n) ; -#if HTS_WIDE_DEBUG - DEBUG_W("gethostbyname\n"); -#endif -#if HDEBUG - printf("gethostbyname (not in cache)\n"); -#endif - { - unsigned long inetaddr; - -#ifdef _WIN32 - if ((inetaddr = inet_addr(iadr)) == INADDR_NONE) { -#else - if ((inetaddr = inet_addr(iadr)) == (in_addr_t) - 1) { -#endif #if DEBUGDNS - printf("resolving (not cached) %s\n", iadr); + printf("resolving (not cached) %s\n", iadr); #endif - hp = vxgethostbyname2(iadr, buffer, error); // calculer IP host - } else { // numérique, convertir sans passer par le dns - buffer->hp.h_addr_list[0] = (char *) &inetaddr; - buffer->hp.h_length = 4; - hp = &buffer->hp; - } - } + + sa = hts_dns_resolve_nocache2(iadr, addr, error); // calculer IP host + #if HTS_WIDE_DEBUG DEBUG_W("gethostbyname done\n"); #endif + + /* attempt to store new entry */ cache->n = (t_dnscache *) calloct(1, sizeof(t_dnscache)); if (cache->n != NULL) { strcpybuff(cache->n->iadr, iadr); - if (hp != NULL) { - memcpy(cache->n->host_addr, hp->h_addr_list[0], hp->h_length); - cache->n->host_length = hp->h_length; + if (sa != NULL) { + cache->n->host_length = SOCaddr_size(*sa); + assertf(cache->n->host_length < sizeof(cache->n->host_addr)); + memcpy(cache->n->host_addr, &SOCaddr_sockaddr(*sa), cache->n->host_length); } else { cache->n->host_addr[0] = '\0'; cache->n->host_length = 0; // non existant dans le dns } cache->n->n = NULL; - return hp; - } else { // on peut pas noter, mais on peut renvoyer le résultat - return hp; + return sa; } + + /* return result if any */ + return sa; } // retour hp du cache } -t_hostent *hts_gethostbyname2(httrackp * opt, const char *_iadr, void *v_buffer, const char **error) { - t_hostent *ret; +SOCaddr* hts_dns_resolve2(httrackp * opt, const char *_iadr, SOCaddr *const addr, const char **error) { + SOCaddr *ret; hts_mutexlock(&opt->state.lock); - ret = hts_gethostbyname_(opt, _iadr, v_buffer, error); + ret = hts_dns_resolve_(opt, _iadr, addr, error); hts_mutexrelease(&opt->state.lock); return ret; } -t_hostent *hts_gethostbyname(httrackp * opt, const char *_iadr, void *v_buffer) { - return hts_gethostbyname2(opt ,_iadr, v_buffer, NULL); +SOCaddr* hts_dns_resolve(httrackp * opt, const char *_iadr, SOCaddr *const addr) { + return hts_dns_resolve2(opt, _iadr, addr, NULL); } -#else -static HTS_INLINE t_hostent *hts_gethostbyname(httrackp * opt, char *iadr, - t_fullhostent * buffer) { - t_hostent *retour; - -#if HTS_WIDE_DEBUG - DEBUG_W("gethostbyname (2)\n"); -#endif -#if DEBUGDNS - printf("blocking method gethostbyname() in progress for %s\n", iadr); -#endif - retour = vxgethostbyname(jump_identification(iadr),); -#if HTS_WIDE_DEBUG - DEBUG_W("gethostbyname (2) done\n"); -#endif - return retour; -} -#endif - // --- Tracage des mallocs() --- #ifdef HTS_TRACE_MALLOC //#define htsLocker(A, N) htsLocker(A, N) @@ -5112,6 +5013,17 @@ static int ssl_vulnerable(const char *version) { return 0; } +/* user abort callback */ +htsErrorCallback htsCallbackErr = NULL; + +HTSEXT_API void hts_set_error_callback(htsErrorCallback handler) { + htsCallbackErr = handler; +} + +HTSEXT_API htsErrorCallback hts_get_error_callback() { + return htsCallbackErr; +} + static void default_inthash_asserthandler(void *arg, const char* exp, const char* file, int line) { abortf_(exp, file, line); } @@ -5278,8 +5190,21 @@ HTSEXT_API int hts_log(httrackp * opt, const char *prefix, const char *msg) { return 1; /* Error */ } +static void (*hts_log_print_callback)(httrackp * opt, int type, const char *format, va_list args) = NULL; + +HTSEXT_API void hts_set_log_vprint_callback(void (*callback)(httrackp * opt, + int type, const char *format, va_list args)) { + hts_log_print_callback = callback; +} + HTSEXT_API void hts_log_vprint(httrackp * opt, int type, const char *format, va_list args) { assertf(format != NULL); + if (hts_log_print_callback != NULL) { + va_list args_copy; + va_copy(args_copy, args); + hts_log_print_callback(opt, type, format, args); + va_end(args_copy); + } if (opt != NULL && opt->log != NULL) { const int save_errno = errno; const char *s_type = "unknown"; @@ -5325,13 +5250,11 @@ HTSEXT_API void hts_log_vprint(httrackp * opt, int type, const char *format, va_ } HTSEXT_API void hts_log_print(httrackp * opt, int type, const char *format, ...) { + va_list args; assertf(format != NULL); - if (opt != NULL && opt->log != NULL) { - va_list args; - va_start(args, format); - hts_log_vprint(opt, type, format, args); - va_end(args); - } + va_start(args, format); + hts_log_vprint(opt, type, format, args); + va_end(args); } HTSEXT_API void set_wrappers(httrackp * opt) { // LEGACY @@ -5538,13 +5461,8 @@ HTSEXT_API httrackp *hts_create_opt(void) { StringCopy(opt->path_log, ""); StringCopy(opt->path_bin, ""); // -#if HTS_SPARE_MEMORY==0 - opt->maxlink = 100000; // 100,000 liens max par défaut (400Kb) + opt->maxlink = 100000; // 100,000 liens max par défaut opt->maxfilter = 200; // 200 filtres max par défaut -#else - opt->maxlink = 10000; // 10,000 liens max par défaut (40Kb) - opt->maxfilter = 50; // 50 filtres max par défaut -#endif opt->maxcache = 1048576 * 32; // a peu près 32Mo en cache max -- OPTION NON PARAMETRABLE POUR L'INSTANT -- //opt->maxcache_anticipate=256; // maximum de liens à anticiper opt->maxtime = -1; // temps max en secondes @@ -5583,6 +5501,10 @@ HTSEXT_API httrackp *hts_create_opt(void) { return opt; } +HTSEXT_API size_t hts_sizeof_opt(void) { + return sizeof(httrackp); +} + HTSEXT_API void hts_free_opt(httrackp * opt) { if (opt != NULL) { @@ -5835,68 +5757,56 @@ const t_hts_htmlcheck_callbacks default_callbacks = { {htsdefault_parse, NULL} }; -#define CHARCAST(A) ( (char*) (A) ) -#define OFFSET_OF(TYPE, MEMBER) ( (size_t) ( CHARCAST(&(((TYPE*) NULL)->MEMBER)) - CHARCAST((TYPE*) NULL) ) ) -#define CALLBACK_REF(name, fun) \ - { name, OFFSET_OF(t_hts_htmlcheck_callbacks, fun) } -#define MEMBER_OF(STRUCT, OFFSET, TYPE) ( * ((TYPE*)((char*)(STRUCT) + (OFFSET))) ) +#define CALLBACK_OP(CB, NAME, OPERATION, S, FUN) do { \ + if (strcmp(NAME, S) == 0) { \ + OPERATION(t_hts_htmlcheck_ ##FUN, (CB)->FUN.fun); \ + } \ +} while(0) -const t_hts_callback_ref default_callbacks_ref[] = { - CALLBACK_REF("init", init), - CALLBACK_REF("free", uninit), - CALLBACK_REF("start", start), - CALLBACK_REF("end", end), - CALLBACK_REF("change-options", chopt), - CALLBACK_REF("preprocess-html", preprocess), - CALLBACK_REF("postprocess-html", postprocess), - CALLBACK_REF("check-html", check_html), - CALLBACK_REF("query", query), - CALLBACK_REF("query2", query2), - CALLBACK_REF("query3", query3), - CALLBACK_REF("loop", loop), - CALLBACK_REF("check-link", check_link), - CALLBACK_REF("check-mime", check_mime), - CALLBACK_REF("pause", pause), - CALLBACK_REF("save-file", filesave), - CALLBACK_REF("save-file2", filesave2), - CALLBACK_REF("link-detected", linkdetected), - CALLBACK_REF("link-detected2", linkdetected2), - CALLBACK_REF("transfer-status", xfrstatus), - CALLBACK_REF("save-name", savename), - CALLBACK_REF("send-header", sendhead), - CALLBACK_REF("receive-header", receivehead), - {NULL, 0} -}; - -size_t hts_get_callback_offs(const char *name) { - const t_hts_callback_ref *ref; - - for(ref = &default_callbacks_ref[0]; ref->name != NULL; ref++) { - if (strcmp(name, ref->name) == 0) { - return ref->offset; - } - } - return (size_t) (-1); -} +#define DISPATCH_CALLBACK(CB, NAME, OPERATION) do { \ + CALLBACK_OP(CB, NAME, OPERATION, "init", init); \ + CALLBACK_OP(CB, NAME, OPERATION, "free", uninit); \ + CALLBACK_OP(CB, NAME, OPERATION, "start", start); \ + CALLBACK_OP(CB, NAME, OPERATION, "end", end); \ + CALLBACK_OP(CB, NAME, OPERATION, "change-options", chopt); \ + CALLBACK_OP(CB, NAME, OPERATION, "preprocess-html", preprocess); \ + CALLBACK_OP(CB, NAME, OPERATION, "postprocess-html", postprocess); \ + CALLBACK_OP(CB, NAME, OPERATION, "check-html", check_html); \ + CALLBACK_OP(CB, NAME, OPERATION, "query", query); \ + CALLBACK_OP(CB, NAME, OPERATION, "query2", query2); \ + CALLBACK_OP(CB, NAME, OPERATION, "query3", query3); \ + CALLBACK_OP(CB, NAME, OPERATION, "loop", loop); \ + CALLBACK_OP(CB, NAME, OPERATION, "check-link", check_link); \ + CALLBACK_OP(CB, NAME, OPERATION, "check-mime", check_mime); \ + CALLBACK_OP(CB, NAME, OPERATION, "pause", pause); \ + CALLBACK_OP(CB, NAME, OPERATION, "save-file", filesave); \ + CALLBACK_OP(CB, NAME, OPERATION, "save-file2", filesave2); \ + CALLBACK_OP(CB, NAME, OPERATION, "link-detected", linkdetected); \ + CALLBACK_OP(CB, NAME, OPERATION, "link-detected2", linkdetected2); \ + CALLBACK_OP(CB, NAME, OPERATION, "transfer-status", xfrstatus); \ + CALLBACK_OP(CB, NAME, OPERATION, "save-name", savename); \ + CALLBACK_OP(CB, NAME, OPERATION, "send-header", sendhead); \ + CALLBACK_OP(CB, NAME, OPERATION, "receive-header", receivehead); \ +} while(0) int hts_set_callback(t_hts_htmlcheck_callbacks * callbacks, const char *name, void *function) { - size_t offs = hts_get_callback_offs(name); - - if (offs != (size_t) - 1) { - MEMBER_OF(callbacks, offs, void *) = function; - - return 0; - } - return 1; + int error = 1; +#define CALLBACK_OPERATION(TYPE, FUNCTION) do { \ + FUNCTION = (TYPE) function; \ + error = 0; \ + } while(0) + DISPATCH_CALLBACK(callbacks, name, CALLBACK_OPERATION); +#undef CALLBACK_OPERATION + return error; } void *hts_get_callback(t_hts_htmlcheck_callbacks * callbacks, const char *name) { - size_t offs = hts_get_callback_offs(name); - - if (offs != (size_t) - 1) { - return MEMBER_OF(callbacks, offs, void *); - } +#define CALLBACK_OPERATION(TYPE, FUNCTION) do { \ + return (void*) FUNCTION; \ + } while(0) + DISPATCH_CALLBACK(callbacks, name, CALLBACK_OPERATION); +#undef CALLBACK_OPERATION return NULL; } diff --git a/src/htslib.h b/src/htslib.h index 2b75dc4..2212a0b 100644 --- a/src/htslib.h +++ b/src/htslib.h @@ -50,6 +50,14 @@ typedef struct htsblk htsblk; #define HTS_DEF_FWSTRUCT_t_dnscache typedef struct t_dnscache t_dnscache; #endif +#ifndef HTS_DEF_FWSTRUCT_lien_adrfil +#define HTS_DEF_FWSTRUCT_lien_adrfil +typedef struct lien_adrfil lien_adrfil; +#endif +#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave +#define HTS_DEF_FWSTRUCT_lien_adrfilsave +typedef struct lien_adrfilsave lien_adrfilsave; +#endif /* définitions globales */ #include "htsglobal.h" @@ -97,86 +105,6 @@ MSVC2003INLINEBUG HTS_STATIC char *getHtsOptBuff_(httrackp * opt) { #define OPT_GET_BUFF(OPT) ( getHtsOptBuff_(OPT) ) #define OPT_GET_BUFF_SIZE(OPT) ( sizeof(opt->state.concat.buff[0]) ) -// structure pour paramètres supplémentaires lors de la requête -#ifndef HTS_DEF_FWSTRUCT_htsrequest_proxy -#define HTS_DEF_FWSTRUCT_htsrequest_proxy -typedef struct htsrequest_proxy htsrequest_proxy; -#endif -struct htsrequest_proxy { - int active; - const char* name; - int port; - const char* bindhost; // bind this host -}; - -#ifndef HTS_DEF_FWSTRUCT_htsrequest -#define HTS_DEF_FWSTRUCT_htsrequest -typedef struct htsrequest htsrequest; -#endif -struct htsrequest { - short int user_agent_send; // user agent (ex: httrack/1.0 [sun]) - short int http11; // l'en tête peut (doit) être signé HTTP/1.1 et non HTTP/1.0 - short int nokeepalive; // pas de keep-alive - short int range_used; // Range utilisé - short int nocompression; // Pas de compression - short int flush_garbage; // recycled - const char* user_agent; - const char* referer; - const char* from; - const char* lang_iso; - const char* accept; - const char* headers; - htsrequest_proxy proxy; // proxy -}; - -// structure pour retour d'une connexion/prise d'en tête -#ifndef HTS_DEF_FWSTRUCT_htsblk -#define HTS_DEF_FWSTRUCT_htsblk -typedef struct htsblk htsblk; -#endif -struct htsblk { - int statuscode; // status-code, -1=erreur, 200=OK,201=..etc (cf RFC1945) - short int notmodified; // page ou fichier NON modifié (transféré) - short int is_write; // sortie sur disque (out) ou en mémoire (adr) - short int is_chunk; // mode chunk - short int compressed; // compressé? - short int empty; // vide? - short int keep_alive; // Keep-Alive? - short int keep_alive_trailers; // ..with trailers extension - int keep_alive_t; // KA timeout - int keep_alive_max; // KA number of requests - char *adr; // adresse du bloc de mémoire, NULL=vide - char *headers; // adresse des en têtes si présents - FILE *out; // écriture directe sur disque (si is_write=1) - LLint size; // taille fichier - char msg[80]; // message éventuel si échec ("\0"=non précisé) - char contenttype[64]; // content-type ("text/html" par exemple) - char charset[64]; // charset ("iso-8859-1" par exemple) - char contentencoding[64]; // content-encoding ("gzip" par exemple) - char *location; // on copie dedans éventuellement la véritable 'location' - LLint totalsize; // taille totale à télécharger (-1=inconnue) - short int is_file; // ce n'est pas une socket mais un descripteur de fichier si 1 - T_SOC soc; // ID socket - SOCaddr address; // IP address - int address_size; // IP address structure length - FILE *fp; // fichier pour file:// -#if HTS_USEOPENSSL - short int ssl; // is this connection a SSL one? (https) - // BIO* ssl_soc; // SSL structure - SSL *ssl_con; // connection structure -#endif - char lastmodified[64]; // Last-Modified - char etag[256]; // Etag - char cdispo[256]; // Content-Disposition coupé - LLint crange; // Content-Range - LLint crange_start; // Content-Range - LLint crange_end; // Content-Range - int debugid; // debug connection - /* */ - htsrequest req; // paramètres pour la requête - /*char digest[32+2]; // digest md5 généré par le moteur ("" si non généré) */ -}; - /* ANCIENNE STURCTURE pour cache 1.0 */ #ifndef HTS_DEF_FWSTRUCT_OLD_t_proxy #define HTS_DEF_FWSTRUCT_OLD_t_proxy @@ -249,11 +177,12 @@ LLint check_downloadable_bytes(int rate); HTSEXT_API int hts_uninit_module(void); // fonctions principales -T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour); +T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * retour); T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect, - char *xsend, char *adr, char *fil, htsblk * retour); -int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend, - char *adr, char *fil, char *referer_adr, char *referer_fil, + const char *xsend, const char *adr, const char *fil, htsblk * retour); +int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, const char *xsend, + const char *adr, const char *fil, + const char *referer_adr, const char *referer_fil, htsblk * retour); //int newhttp(char* iadr,char* err=NULL); @@ -263,22 +192,25 @@ HTS_INLINE void deletehttp(htsblk * r); HTS_INLINE int deleteaddr(htsblk * r); HTS_INLINE void deletesoc(T_SOC soc); HTS_INLINE void deletesoc_r(htsblk * r); -htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc); -htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc); +htsblk http_test(httrackp * opt, const char *adr, const char *fil, char *loc); int check_readinput(htsblk * r); int check_readinput_t(T_SOC soc, int timeout); -void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour, +void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * retour, char *rcvd); -void treatfirstline(htsblk * retour, char *rcvd); +void treatfirstline(htsblk * retour, const char *rcvd); // sous-fonctions LLint http_xfread1(htsblk * r, int bufl); -HTS_INLINE t_hostent *hts_gethostbyname2(httrackp * opt, const char *iadr, - void *v_buffer, const char **error); -HTS_INLINE t_hostent *hts_gethostbyname(httrackp * opt, const char *iadr, - void *v_buffer); -HTSEXT_API t_hostent *vxgethostbyname2(const char *const hostname, void *v_buffer, const char **error); -HTSEXT_API t_hostent *vxgethostbyname(const char *const hostname, void *v_buffer); +HTS_INLINE SOCaddr* hts_dns_resolve2(httrackp * opt, const char *iadr, + SOCaddr *const addr, + const char **error); +HTS_INLINE SOCaddr* hts_dns_resolve(httrackp * opt, const char *iadr, + SOCaddr *const addr); +HTSEXT_API SOCaddr* hts_dns_resolve_nocache2(const char *const hostname, + SOCaddr *const addr, + const char **error); +HTSEXT_API SOCaddr* hts_dns_resolve_nocache(const char *const hostname, + SOCaddr *const addr); HTSEXT_API int check_hostname_dns(const char *const hostname); int ftp_available(void); @@ -303,7 +235,7 @@ HTS_INLINE void time_rfc822(char *s, struct tm *A); HTS_INLINE void time_rfc822_local(char *s, struct tm *A); HTS_INLINE int sendc(htsblk * r, const char *s); -int finput(int fd, char *s, int max); +int finput(T_SOC fd, char *s, int max); int binput(char *buff, char *s, int max); int linput(FILE * fp, char *s, int max); int linputsoc(T_SOC soc, char *s, int max); @@ -311,8 +243,8 @@ int linputsoc_t(T_SOC soc, char *s, int max, int timeout); int linput_trim(FILE * fp, char *s, int max); int linput_cpp(FILE * fp, char *s, int max); void rawlinput(FILE * fp, char *s, int max); -char *strstrcase(char *s, char *o); -int ident_url_absolute(const char *url, char *adr, char *fil); +char *strstrcase(char *s, const char *o); +int ident_url_absolute(const char *url, lien_adrfil *adrfil); void fil_simplifie(char *f); int is_unicode_utf8(const char *buffer, const size_t size); void map_characters(unsigned char *buffer, unsigned int size, @@ -320,12 +252,10 @@ void map_characters(unsigned char *buffer, unsigned int size, int ishtml(httrackp * opt, const char *urlfil); int ishtml_ext(const char *a); int ishttperror(int err); -void guess_httptype(httrackp * opt, char *s, const char *fil); int get_userhttptype(httrackp * opt, char *s, const char *fil); void give_mimext(char *s, const char *st); -int may_unknown(httrackp * opt, const char *st); int may_bogus_multiple(httrackp * opt, const char *mime, const char *filename); int may_unknown2(httrackp * opt, const char *mime, const char *filename); @@ -341,7 +271,7 @@ void hts_lowcase(char *s); void hts_replace(char *s, char from, char to); int multipleStringMatch(const char *s, const char *match); -void fprintfio(FILE * fp, char *buff, char *prefix); +void fprintfio(FILE * fp, const char *buff, const char *prefix); #ifdef _WIN32 #else @@ -384,7 +314,6 @@ extern void *getFunctionPtr(void *handle, const char *fncname); extern void closeFunctionLib(void *handle); extern void clearCallbacks(htscallbacks * chain); -extern size_t hts_get_callback_offs(const char *name); int hts_set_callback(t_hts_htmlcheck_callbacks * callbacks, const char *name, void *function); void *hts_get_callback(t_hts_htmlcheck_callbacks * callbacks, @@ -610,6 +539,15 @@ HTS_STATIC int compare_mime(httrackp * opt, const char *mime, const char *file, #endif +// returns (size_t) -1 upon error +static HTS_UNUSED size_t off_t_to_size_t(off_t o) { + if (o >= 0 && o < ( (size_t) -1 ) / 2) { + return (size_t) o; + } else { + return (size_t) -1; + } +} + /* dirent() compatibility */ #ifdef _WIN32 #define HTS_DIRENT_SIZE 256 diff --git a/src/htsmd5.c b/src/htsmd5.c index def901d..2843738 100644 --- a/src/htsmd5.c +++ b/src/htsmd5.c @@ -1,4 +1,4 @@ -/* ------------------------------------------------------------ */ + /* HTTrack Website Copier, Offline Browser for Windows and Unix Copyright (C) 1998-2014 Xavier Roche and other contributors @@ -41,8 +41,10 @@ Please visit our Website: http://www.httrack.com #include #include #include +#include #include "htsmd5.h" #include "md5.h" +#include "htssafe.h" int domd5mem(const char *buf, size_t len, char *digest, int asAscii) { int endian = 1; @@ -77,3 +79,25 @@ unsigned long int md5sum32(const char *buff) { domd5mem(buff, strlen(buff), u.md5digest, 0); return u.hash; } + +void md5selftest() { + static const char str1[] = "The quick brown fox jumps over the lazy dog\n"; + static const char str1m[] = "37c4b87edffc5d198ff5a185cee7ee09"; + static const char str2[] = "Hello"; + static const char str2m[] = "8b1a9953c4611296a827abf8c47804d7"; + char digest[64]; +#define MDCHECK(VAR, VARMD) do { \ + memset(digest, 0xCC, sizeof(digest)); \ + domd5mem(VAR, sizeof(VAR) - 1, digest, 1); \ + if (strcmp(digest, VARMD) != 0) { \ + fprintf(stderr, \ + "error: md5 selftest failed: '%s' => '%s' (!= '%s')\n", \ + VAR, digest, VARMD); \ + assert(! "md5 selftest failed"); \ + } \ +} while(0) +MDCHECK(str1, str1m); +MDCHECK(str2, str2m); +#undef MDCHECK + fprintf(stderr, "md5 selftest succeeded\n"); +} diff --git a/src/htsmd5.h b/src/htsmd5.h index 194d8c8..091a454 100644 --- a/src/htsmd5.h +++ b/src/htsmd5.h @@ -42,6 +42,7 @@ Please visit our Website: http://www.httrack.com #ifdef HTS_INTERNAL_BYTECODE int domd5mem(const char *buf, size_t len, char *digest, int asAscii); unsigned long int md5sum32(const char *buff); +void md5selftest(void); #endif #endif diff --git a/src/htsmodules.c b/src/htsmodules.c index 656cd6a..e49bd7c 100644 --- a/src/htsmodules.c +++ b/src/htsmodules.c @@ -218,17 +218,17 @@ void htspe_init(void) { /* See CVE-2010-5252 */ #if (defined(_WIN32) && (!defined(_DEBUG))) { - /* >= Windows Server 2003 (Andy Hewitt) */ - const DWORD dwVersion = GetVersion(); - const DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); - const DWORD dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); - const int hasSetDllDirectory = - dwMajorVersion >= 6 || ( dwMajorVersion == 5 && dwMinorVersion >= 2 ); /* See KB 2389418 "If this parameter is an empty string (""), the call removes the current directory from the default DLL search order" */ - if (hasSetDllDirectory && !SetDllDirectory("")) { + BOOL (WINAPI*const k32_SetDllDirectoryA)(LPCSTR) = + (BOOL (WINAPI *)(LPCSTR)) + GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA"); + if (k32_SetDllDirectoryA != NULL && !k32_SetDllDirectoryA("")) { /* Do no choke on NT or 98SE with KernelEx NT API (James Blough) */ + const DWORD dwVersion = GetVersion(); + const DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); + const DWORD dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); if (dwMajorVersion >= 5) { assertf(!"SetDllDirectory failed"); } diff --git a/src/htsmodules.h b/src/htsmodules.h index 077a720..18eef8e 100644 --- a/src/htsmodules.h +++ b/src/htsmodules.h @@ -104,22 +104,21 @@ struct htsmoduleStruct { httrackp *opt; /* Internal use - please don't touch */ - lien_url **liens; struct_back *sback; cache_back *cache; hash_struct *hashptr; int numero_passe; - int add_tab_alloc; /* */ - int *lien_tot_; int *ptr_; - size_t *lien_size_; - char **lien_buffer_; const char *page_charset_; /* Internal use - please don't touch */ }; +#ifdef __cplusplus +extern "C" { +#endif + /* Used to wrap module initialization */ /* return 1 if init was ok */ typedef int (*t_htsWrapperInit) (char *fn, char *args); @@ -138,4 +137,8 @@ extern int hts_parse_externals(htsmoduleStruct * str); extern int V6_is_available; #endif +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/htsname.c b/src/htsname.c index 1a3ee47..ec6a839 100644 --- a/src/htsname.c +++ b/src/htsname.c @@ -47,15 +47,15 @@ Please visit our Website: http://www.httrack.com { /* ajout nom */\ char BIGSTK buff[HTS_URLMAXSIZE*2];\ buff[0]='\0';\ - strncatbuff(buff,start_pos,(int) (nom_pos - start_pos));\ - url_savename_addstr(save,buff);\ + strncatbuff(buff,start_pos,nom_pos - start_pos);\ + url_savename_addstr(afs->save, buff);\ } #define ADD_STANDARD_NAME(shortname) \ { /* ajout nom */\ char BIGSTK buff[HTS_URLMAXSIZE*2];\ standard_name(buff,dot_pos,nom_pos,fil_complete,(shortname));\ - url_savename_addstr(save,buff);\ + url_savename_addstr(afs->save, buff);\ } /* Avoid stupid DOS system folders/file such as 'nul' */ @@ -82,11 +82,11 @@ static const char *hts_tbdev[] = { HTS_STAT.stat_errors=fspc(opt,NULL,"error"); \ HTS_STAT.stat_warnings=fspc(opt,NULL,"warning"); \ HTS_STAT.stat_infos=fspc(opt,NULL,"info"); \ - HTS_STAT.nbk=backlinks_done(sback,liens,lien_tot,ptr); \ + HTS_STAT.nbk=backlinks_done(sback,opt->liens,opt->lien_tot,ptr); \ HTS_STAT.nb=back_transferred(HTS_STAT.stat_bytes,sback); \ /* Check */ \ { \ - if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count,-1,ptr,lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \ + if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count,-1,ptr,opt->lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \ return -1; \ } \ } \ @@ -139,10 +139,10 @@ static void cleanEndingSpaceOrDot(char *s) { // forme le nom du fichier à sauver (save) à partir de fil et adr // système intelligent, qui renomme en cas de besoin (exemple: deux INDEX.HTML et index.html) -int url_savename(char *adr_complete, char *fil_complete, char *save, - char *former_adr, char *former_fil, char *referer_adr, - char *referer_fil, httrackp * opt, lien_url ** liens, - int lien_tot, struct_back * sback, cache_back * cache, +int url_savename(lien_adrfilsave *const afs, + lien_adrfil *const former, + const char *referer_adr, const char *referer_fil, + httrackp * opt, struct_back * sback, cache_back * cache, hash_struct * hash, int ptr, int numero_passe, const lien_back * headers) { char catbuff[CATBUFF_SIZE]; @@ -152,7 +152,10 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, lien_back *const back = sback->lnk; /* */ - char BIGSTK newfil[HTS_URLMAXSIZE * 2]; /* ="" */ + char BIGSTK fil[HTS_URLMAXSIZE * 2]; /* ="" */ + + const char *const adr_complete = afs->af.adr; + const char *const fil_complete = afs->af.fil; /*char BIGSTK normadr_[HTS_URLMAXSIZE*2]; */ char BIGSTK normadr_[HTS_URLMAXSIZE * 2], normfil_[HTS_URLMAXSIZE * 2]; @@ -162,12 +165,11 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, { "http", "https", "ftp", "file", "unknown" }; int protocol = PROTOCOL_HTTP; const char *const adr = jump_identification(adr_complete); - char *fil = fil_complete; // copy of fil, used for lookups (see urlhack) const char *normadr = adr; - const char *normfil = fil; + const char *normfil = fil_complete; const char *const print_adr = jump_protocol(adr); - char *start_pos = NULL, *nom_pos = NULL, *dot_pos = NULL; // Position nom et point + const char *start_pos = NULL, *nom_pos = NULL, *dot_pos = NULL; // Position nom et point // pour changement d'extension ou de nom (content-disposition) int ext_chg = 0, ext_chg_delayed = 0; @@ -176,8 +178,8 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, int max_char = 0; //CLEAR - newfil[0] = ext[0] = '\0'; - save[0] = '\0'; + fil[0] = ext[0] = '\0'; + afs->save[0] = '\0'; /* 8-3 ? */ switch (opt->savename_83) { @@ -199,7 +201,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, if (opt->urlhack) { // copy of adr (without protocol), used for lookups (see urlhack) normadr = adr_normalized(adr, normadr_); - normfil = fil_normalized(fil, normfil_); + normfil = fil_normalized(fil_complete, normfil_); } else { if (link_has_authority(adr_complete)) { // https or other protocols : in "http/" subfolder char *pos = strchr(adr_complete, ':'); @@ -227,8 +229,8 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // court-circuit pour lien primaire if (strnotempty(adr) == 0) { - if (strcmp(fil, "primary") == 0) { - strcatbuff(save, "primary.html"); + if (strcmp(fil_complete, "primary") == 0) { + strcatbuff(afs->save, "primary.html"); return 0; } } @@ -259,21 +261,21 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // vérifier que le nom n'a pas déja été calculé (si oui le renvoyer tel que) // vérifier que le nom n'est pas déja pris... // NOTE: si on cherche /toto/ et que /toto est trouvé on le prend (et réciproquqment) ** // ** - if (liens != NULL) { + if (opt->liens != NULL) { int i; i = hash_read(hash, normadr, normfil, HASH_STRUCT_ADR_PATH); // recherche table 1 (adr+fil) if (i >= 0) { // ok, trouvé - strcpybuff(save, liens[i]->sav); + strcpybuff(afs->save, heap(i)->sav); return 0; } - i = hash_read(hash, normadr, normfil, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former_adr+former_fil) + i = hash_read(hash, normadr, normfil, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former->adr+former->fil) if (i >= 0) { // ok, trouvé // copier location moved! - strcpybuff(adr_complete, liens[i]->adr); - strcpybuff(fil_complete, liens[i]->fil); + strcpybuff(afs->af.adr, heap(i)->adr); + strcpybuff(afs->af.fil, heap(i)->fil); // et save - strcpybuff(save, liens[i]->sav); // copier (formé à partir du nouveau lien!) + strcpybuff(afs->save, heap(i)->sav); // copier (formé à partir du nouveau lien!) return 0; } // chercher sans / ou avec / dans former @@ -286,13 +288,13 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, fil_complete_patche[strlen(fil_complete_patche) - 1] = '\0'; else strcatbuff(fil_complete_patche, "/"); - i = hash_read(hash, normadr, fil_complete_patche, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former_adr+former_fil) + i = hash_read(hash, normadr, fil_complete_patche, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former->adr+former->fil) if (i >= 0) { - // écraser fil et adr (pas former_fil?????) - strcpybuff(adr_complete, liens[i]->adr); - strcpybuff(fil_complete, liens[i]->fil); + // écraser fil et adr (pas former->fil?????) + strcpybuff(afs->af.adr, heap(i)->adr); + strcpybuff(afs->af.fil, heap(i)->fil); // écrire save - strcpybuff(save, liens[i]->sav); + strcpybuff(afs->save, heap(i)->sav); return 0; } } @@ -303,13 +305,12 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, { char *a; - a = strchr(fil, '?'); + a = strchr(fil_complete, '?'); if (a != NULL) { - strncatbuff(newfil, fil, (int) (a - fil)); + strncatbuff(fil, fil_complete, a - fil_complete); } else { - strcpybuff(newfil, fil); + strcpybuff(fil, fil_complete); } - fil = newfil; } // decode remaining % (normally not necessary; already done in htsparse.c) @@ -465,8 +466,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // int hihp = opt->state._hts_in_html_parsing; int has_been_moved = 0; - char BIGSTK curr_adr[HTS_URLMAXSIZE * 2], - curr_fil[HTS_URLMAXSIZE * 2]; + lien_adrfil current; /* Ensure we don't use too many sockets by using a "testing" one If we have only 1 simultaneous connection authorized, wait for pending download @@ -475,20 +475,20 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, URLSAVENAME_WAIT_FOR_AVAILABLE_SOCKET(); /* Rock'in */ - curr_adr[0] = curr_fil[0] = '\0'; + current.adr[0] = current.fil[0] = '\0'; opt->state._hts_in_html_parsing = 2; // test hts_log_print(opt, LOG_DEBUG, "Testing link type %s%s", adr_complete, fil_complete); - strcpybuff(curr_adr, adr_complete); - strcpybuff(curr_fil, fil_complete); + strcpybuff(current.adr, adr_complete); + strcpybuff(current.fil, fil_complete); // ajouter dans le backing le fichier en mode test // savename: rien car en mode test if (back_add - (sback, opt, cache, curr_adr, curr_fil, BACK_ADD_TEST, + (sback, opt, cache, current.adr, current.fil, BACK_ADD_TEST, referer_adr, referer_fil, 1) != -1) { int b; - b = back_index(opt, sback, curr_adr, curr_fil, BACK_ADD_TEST); + b = back_index(opt, sback, current.adr, current.fil, BACK_ADD_TEST); if (b >= 0) { int stop_looping = 0; int petits_tours = 0; @@ -500,8 +500,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, back_wait(sback, opt, cache, 0); } if (ptr >= 0) { - back_fillmax(sback, opt, cache, liens, ptr, numero_passe, - lien_tot); + back_fillmax(sback, opt, cache, ptr, numero_passe); } // on est obligé d'appeler le shell pour le refresh.. // Transfer rate @@ -512,11 +511,11 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, HTS_STAT.stat_errors = fspc(opt, NULL, "error"); HTS_STAT.stat_warnings = fspc(opt, NULL, "warning"); HTS_STAT.stat_infos = fspc(opt, NULL, "info"); - HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr); + HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr); HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback); if (!RUN_CALLBACK7 - (opt, loop, sback->lnk, sback->count, b, ptr, lien_tot, + (opt, loop, sback->lnk, sback->count, b, ptr, opt->lien_tot, (int) (time_local() - HTS_STAT.stat_timestart), &HTS_STAT)) { return -1; @@ -527,42 +526,40 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // traitement des 304,303.. if (back[b].status <= 0) { if (HTTP_IS_REDIRECT(back[b].r.statuscode)) { // agh moved.. un tit tour de plus - if ((petits_tours < 5) && (former_adr) && (former_fil)) { // on va pas tourner en rond non plus! - if ((int) strnotempty(back[b].r.location)) { // location existe! - char BIGSTK mov_url[HTS_URLMAXSIZE * 2], - mov_adr[HTS_URLMAXSIZE * 2], - mov_fil[HTS_URLMAXSIZE * 2]; - mov_url[0] = mov_adr[0] = mov_fil[0] = '\0'; + if ((petits_tours < 5) && former != NULL) { // on va pas tourner en rond non plus! + if (strnotempty(back[b].r.location)) { // location existe! + char BIGSTK mov_url[HTS_URLMAXSIZE * 2]; + lien_adrfil moved; + mov_url[0] = moved.adr[0] = moved.fil[0] = '\0'; // strcpybuff(mov_url, back[b].r.location); // copier URL if (ident_url_relatif - (mov_url, curr_adr, curr_fil, mov_adr, - mov_fil) >= 0) { + (mov_url, current.adr, current.fil, &moved) >= 0) { // si non bouclage sur soi même, ou si test avec GET non testé - if ((strcmp(mov_adr, curr_adr)) - || (strcmp(mov_fil, curr_fil)) + if ((strcmp(moved.adr, current.adr)) + || (strcmp(moved.fil, current.fil)) || (get_test_request == 0)) { // bouclage? - if ((!strcmp(mov_adr, curr_adr)) - && (!strcmp(mov_fil, curr_fil))) + if ((!strcmp(moved.adr, current.adr)) + && (!strcmp(moved.fil, current.fil))) get_test_request = 1; // faire requète avec GET - // recopier former_adr/fil? - if ((former_adr) && (former_fil)) { - if (strnotempty(former_adr) == 0) { // Pas déja noté - strcpybuff(former_adr, curr_adr); - strcpybuff(former_fil, curr_fil); + // recopier former->adr/fil? + if (former != NULL) { + if (strnotempty(former->adr) == 0) { // Pas déja noté + strcpybuff(former->adr, current.adr); + strcpybuff(former->fil, current.fil); } } // check explicit forbidden - don't follow 3xx in this case { int set_prio_to = 0; - if (hts_acceptlink(opt, ptr, lien_tot, liens, mov_adr, mov_fil, NULL, NULL, &set_prio_to, NULL) == 1) { /* forbidden */ + if (hts_acceptlink(opt, ptr, moved.adr, moved.fil, NULL, NULL, &set_prio_to, NULL) == 1) { /* forbidden */ has_been_moved = 1; back_maydelete(opt, cache, sback, b); // ok - strcpybuff(curr_adr, mov_adr); - strcpybuff(curr_fil, mov_fil); + strcpybuff(current.adr, moved.adr); + strcpybuff(current.fil, moved.fil); mov_url[0] = '\0'; stop_looping = 1; } @@ -573,11 +570,11 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, ) { // ftp, ok on arrête has_been_moved = 1; back_maydelete(opt, cache, sback, b); // ok - strcpybuff(curr_adr, mov_adr); - strcpybuff(curr_fil, mov_fil); + strcpybuff(current.adr, moved.adr); + strcpybuff(current.fil, moved.fil); stop_looping = 1; } else if (*mov_url) { - char *methode; + const char *methode; if (!get_test_request) methode = BACK_ADD_TEST; // tester avec HEAD @@ -585,24 +582,24 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, methode = BACK_ADD_TEST2; // tester avec GET hts_log_print(opt, LOG_WARNING, "Loop with HEAD request (during prefetch) at %s%s", - curr_adr, curr_fil); + current.adr, current.fil); } // Ajouter URLSAVENAME_WAIT_FOR_AVAILABLE_SOCKET(); - if (back_add(sback, opt, cache, mov_adr, mov_fil, methode, referer_adr, referer_fil, 1) != -1) { // OK + if (back_add(sback, opt, cache, moved.adr, moved.fil, methode, referer_adr, referer_fil, 1) != -1) { // OK hts_log_print(opt, LOG_DEBUG, "(during prefetch) %s (%d) to link %s at %s%s", back[b].r.msg, back[b].r.statuscode, - back[b].r.location, curr_adr, - curr_fil); + back[b].r.location, current.adr, + current.fil); // libérer emplacement backing actuel et attendre le prochain back_maydelete(opt, cache, sback, b); - strcpybuff(curr_adr, mov_adr); - strcpybuff(curr_fil, mov_fil); + strcpybuff(current.adr, moved.adr); + strcpybuff(current.fil, moved.fil); b = - back_index(opt, sback, curr_adr, curr_fil, + back_index(opt, sback, current.adr, current.fil, methode); if (!get_test_request) has_been_moved = 1; // sinon ne pas forcer has_been_moved car non déplacé @@ -611,7 +608,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } else { // sinon on fait rien et on s'en va.. (ftp etc) hts_log_print(opt, LOG_DEBUG, "Warning: Savename redirect backing error at %s%s", - mov_adr, mov_fil); + moved.adr, moved.fil); } } } else { @@ -673,13 +670,13 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // oops, a été déplacé.. on recalcule en récursif (osons!) if (has_been_moved) { // copier adr, fil (optionnel, mais sinon marche pas pour le rip) - strcpybuff(adr_complete, curr_adr); - strcpybuff(fil_complete, curr_fil); + strcpybuff(afs->af.adr, current.adr); + strcpybuff(afs->af.fil, current.fil); // copier adr, fil - return url_savename(curr_adr, curr_fil, save, NULL, NULL, - referer_adr, referer_fil, opt, liens, - lien_tot, sback, cache, hash, ptr, + return url_savename(afs, NULL, + referer_adr, referer_fil, opt, + sback, cache, hash, ptr, numero_passe, NULL); } // --- --- --- @@ -749,7 +746,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } // Rechercher premier / et dernier . { - char *a = fil + strlen(fil) - 1; + const char *a = fil + strlen(fil) - 1; // passer structures start_pos = fil; @@ -770,7 +767,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // ajouter nom du site éventuellement en premier if (opt->savename_type == -1) { // utiliser savename_userdef! (%h%p/%n%q.%t) const char *a = StringBuff(opt->savename_userdef); - char *b = save; + char *b = afs->save; /*char *nom_pos=NULL,*dot_pos=NULL; // Position nom et point */ char tok; @@ -791,7 +788,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, */ // Construire nom - while((*a) && (((int) (b - save)) < HTS_URLMAXSIZE)) { // parser, et pas trop long.. + while((*a) && (((int) (b - afs->save)) < HTS_URLMAXSIZE)) { // parser, et pas trop long.. if (*a == '%') { int short_ver = 0; @@ -812,7 +809,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, name[pos][0] = '\0'; } pos = 0; - while(*a != ']') { + while(*a != '\0' && *a != ']') { if (pos < 5) { if (*a == ':') { // next token c = name[++pos]; @@ -823,7 +820,9 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } } } - a++; + if (*a == ']') { + a++; + } strcatbuff(name[0], "="); /* param=.. */ c = strchr(fil_complete, '?'); /* parameters exists */ @@ -1046,26 +1045,26 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // adresse url if (!opt->savename_83) { // noms longs (et pas de .) - strcatbuff(save, final_adr); + strcatbuff(afs->save, final_adr); } else { // noms 8-3 if (strlen(final_adr) > 4) { if (strfield(final_adr, "www.")) - hts_appendStringUTF8(save, final_adr + 4, max_char); + hts_appendStringUTF8(afs->save, final_adr + 4, max_char); else - hts_appendStringUTF8(save, final_adr, max_char); + hts_appendStringUTF8(afs->save, final_adr, max_char); } else - hts_appendStringUTF8(save, final_adr, max_char); + hts_appendStringUTF8(afs->save, final_adr, max_char); } /* release */ RELEASE_ADR(); if (*fil != '/') - strcatbuff(save, "/"); + strcatbuff(afs->save, "/"); } } - hts_lowcase(save); + hts_lowcase(afs->save); /* // ne sert à rien car a déja été filtré normalement @@ -1091,42 +1090,42 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, DECLARE_ADR(final_adr); if (!opt->savename_83) { // noms longs - strcatbuff(save, final_adr); - strcatbuff(save, "/"); + strcatbuff(afs->save, final_adr); + strcatbuff(afs->save, "/"); } else { // noms 8-3 if (strlen(final_adr) > 4) { if (strfield(final_adr, "www.")) - hts_appendStringUTF8(save, final_adr + 4, max_char); + hts_appendStringUTF8(afs->save, final_adr + 4, max_char); else - hts_appendStringUTF8(save, final_adr, max_char); - strcatbuff(save, "/"); + hts_appendStringUTF8(afs->save, final_adr, max_char); + strcatbuff(afs->save, "/"); } else { - hts_appendStringUTF8(save, final_adr, max_char); - strcatbuff(save, "/"); + hts_appendStringUTF8(afs->save, final_adr, max_char); + strcatbuff(afs->save, "/"); } } /* release */ RELEASE_ADR(); } else { - strcatbuff(save, "web/"); // répertoire général + strcatbuff(afs->save, "web/"); // répertoire général } } // si un html à coup sûr if ((ext_chg != 0) ? (ishtml_ext(ext) == 1) : (ishtml(opt, fil) == 1)) { if (opt->savename_type % 100 == 2) { // html/ - strcatbuff(save, "html/"); + strcatbuff(afs->save, "html/"); } } else { if ((opt->savename_type % 100 == 1) || (opt->savename_type % 100 == 2)) { // html & images - strcatbuff(save, "images/"); + strcatbuff(afs->save, "images/"); } } switch (opt->savename_type % 100) { case 4: case 5:{ // séparer par types - char *a = fil + strlen(fil) - 1; + const char *a = fil + strlen(fil) - 1; // passer structures while((a > fil) && (*a != '/') && (*a != '\\')) @@ -1137,17 +1136,17 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // html? if ((ext_chg != 0) ? (ishtml_ext(ext) == 1) : (ishtml(opt, fil) == 1)) { if (opt->savename_type % 100 == 5) - strcatbuff(save, "html/"); + strcatbuff(afs->save, "html/"); } else { - char *a = fil + strlen(fil) - 1; + const char *a = fil + strlen(fil) - 1; while((a > fil) && (*a != '/') && (*a != '.')) a--; if (*a != '.') - strcatbuff(save, "other"); + strcatbuff(afs->save, "other"); else - strcatbuff(save, a + 1); - strcatbuff(save, "/"); + strcatbuff(afs->save, a + 1); + strcatbuff(afs->save, "/"); } /*strcatbuff(save,a); */ /* add name */ @@ -1156,8 +1155,8 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, break; case 99:{ // 'codé' .. c'est un gadget size_t i; - int j; - char *a; + size_t j; + const char *a; char C[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"; int L; @@ -1173,19 +1172,19 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } srand(s); - j = (int) strlen(save); + j = strlen(afs->save); for(i = 0; i < 8; i++) { char c = C[(rand() % L)]; - save[i + j] = c; + afs->save[i + j] = c; } - save[i + j] = '\0'; + afs->save[i + j] = '\0'; // ajouter extension a = fil + strlen(fil) - 1; while((a > fil) && (*a != '/') && (*a != '.')) a--; if (*a == '.') { - strcatbuff(save, a); // ajouter + strcatbuff(afs->save, a); // ajouter } } break; @@ -1204,10 +1203,10 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, break; } - hts_lowcase(save); + hts_lowcase(afs->save); - if (save[strlen(save) - 1] == '/') - strcatbuff(save, DEFAULT_HTML); // nommer page par défaut!! + if (afs->save[strlen(afs->save) - 1] == '/') + strcatbuff(afs->save, DEFAULT_HTML); // nommer page par défaut!! } // vérifier qu'on ne doit pas forcer l'extension @@ -1225,23 +1224,23 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // de même en cas de manque d'extension on en place une de manière forcée.. // cela évite les /chez/toto et les /chez/toto/index.html incompatibles if (opt->savename_type != -1 && opt->savename_delayed != 2) { - char *a = save + strlen(save) - 1; + char *a = afs->save + strlen(afs->save) - 1; - while((a > save) && (*a != '.') && (*a != '/')) + while((a > afs->save) && (*a != '.') && (*a != '/')) a--; if (*a != '.') { // agh pas de point //strcatbuff(save,".none"); // a éviter - strcatbuff(save, ".html"); // préférable! + strcatbuff(afs->save, ".html"); // préférable! hts_log_print(opt, LOG_DEBUG, "Default HTML type set for %s%s => %s", - adr_complete, fil_complete, save); + adr_complete, fil_complete, afs->save); } } // effacer pass au besoin pour les autentifications // (plus la peine : masqué au début) /* { - char* a=jump_identification(save); - if (a!=save) { + char* a=jump_identification(afs->save); + if (a!=afs->save) { char BIGSTK tempo[HTS_URLMAXSIZE*2]; char *b; tempo[0]='\0'; @@ -1258,18 +1257,18 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, */ // éviter les / au début (cause: N100) - if (save[0] == '/') { + if (afs->save[0] == '/') { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; - strcpybuff(tempo, save + 1); - strcpybuff(save, tempo); + strcpybuff(tempo, afs->save + 1); + strcpybuff(afs->save, tempo); } /* Cleanup reserved or forbidden characters. */ { size_t i; - for(i = 0 ; save[i] != '\0' ; i++) { - unsigned char c = (unsigned char) save[i]; + for(i = 0 ; afs->save[i] != '\0' ; i++) { + unsigned char c = (unsigned char) afs->save[i]; if (c < 32 // control || c == 127 // unwise || c == '~' // unix unwise @@ -1294,13 +1293,13 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, ) ) { - save[i] = '_'; + afs->save[i] = '_'; } } } // éliminer les // (comme ftp://) - cleanDoubleSlash(save); + cleanDoubleSlash(afs->save); #if HTS_OVERRIDE_DOS_FOLDERS /* Replace /foo/nul/bar by /foo/nul_/bar */ @@ -1308,7 +1307,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, int i = 0; while(hts_tbdev[i][0]) { - char *a = save; + char *a = afs->save; while((a = strstrcase(a, (char *) hts_tbdev[i]))) { switch ((int) a[strlen(hts_tbdev[i])]) { @@ -1319,10 +1318,10 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, char BIGSTK tempo[HTS_URLMAXSIZE * 2]; tempo[0] = '\0'; - strncatbuff(tempo, save, (int) (a - save) + strlen(hts_tbdev[i])); + strncatbuff(tempo, afs->save, (int) (a - afs->save) + strlen(hts_tbdev[i])); strcatbuff(tempo, "_"); strcatbuff(tempo, a + strlen(hts_tbdev[i])); - strcpybuff(save, tempo); + strcpybuff(afs->save, tempo); } break; } @@ -1333,7 +1332,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } /* Strip ending . or ' ' forbidden on windoz */ - cleanEndingSpaceOrDot(save); + cleanEndingSpaceOrDot(afs->save); #endif @@ -1341,8 +1340,8 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, if (opt->savename_83) { char BIGSTK n83[HTS_URLMAXSIZE * 2]; - long_to_83(opt->savename_83, n83, save); - strcpybuff(save, n83); + long_to_83(opt->savename_83, n83, afs->save); + strcpybuff(afs->save, n83); } // enforce stricter ISO9660 compliance (bug reported by Steffo Carlsson) // Level 1 File names are restricted to 8 characters with a 3 character extension, @@ -1353,12 +1352,12 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, if (opt->savename_83 > 0) { char *a, *last; - for(last = save + strlen(save) - 1; - last != save && *last != '/' && *last != '\\' && *last != '.'; last--) ; + for(last = afs->save + strlen(afs->save) - 1; + last != afs->save && *last != '/' && *last != '\\' && *last != '.'; last--) ; if (*last != '.') { last = NULL; } - for(a = save; *a != '\0'; a++) { + for(a = afs->save; *a != '\0'; a++) { if (*a >= 'a' && *a <= 'z') { *a -= 'a' - 'A'; } else if (*a == '.') { @@ -1375,7 +1374,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } /* ensure that there is no ../ (potential vulnerability) */ - fil_simplifie(save); + fil_simplifie(afs->save); /* convert name to UTF-8 ? Note: already done while parsing. */ //if (charset != NULL && charset[0] != '\0') { @@ -1392,17 +1391,17 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, /* callback */ RUN_CALLBACK5(opt, savename, adr_complete, fil_complete, referer_adr, - referer_fil, save); + referer_fil, afs->save); hts_log_print(opt, LOG_DEBUG, "engine: save-name: local name: %s%s -> %s", - adr, fil, save); + adr, fil, afs->save); /* Ensure that the MANDATORY "temporary" extension is set */ if (ext_chg_delayed) { char *ptr; char *lastDot = NULL; - for(ptr = save; *ptr != 0; ptr++) { + for(ptr = afs->save; *ptr != 0; ptr++) { if (*ptr == '.') { lastDot = ptr; } else if (*ptr == '/' || *ptr == '\\') { @@ -1410,8 +1409,8 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } } if (lastDot == NULL) { - strcatbuff(save, "." DELAYED_EXT); - } else if (!IS_DELAYED_EXT(save)) { + strcatbuff(afs->save, "." DELAYED_EXT); + } else if (!IS_DELAYED_EXT(afs->save)) { strcatbuff(lastDot, "." DELAYED_EXT); } } @@ -1424,12 +1423,12 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, #define MIN_LAST_SEG_RESERVE 12 #define MAX_LAST_SEG_RESERVE 24 #define MAX_SEG_LEN 48 - if (hts_stringLengthUTF8(save) + + if (hts_stringLengthUTF8(afs->save) + hts_stringLengthUTF8(StringBuff(opt->path_html_utf8)) >= HTS_MAX_PATH_LEN) { // convert to Unicode (much simpler) size_t wsaveLen; - hts_UCS4 *const wsave = hts_convertUTF8StringToUCS4(save, strlen(save), &wsaveLen); + hts_UCS4 *const wsave = hts_convertUTF8StringToUCS4(afs->save, strlen(afs->save), &wsaveLen); if (wsave != NULL) { const size_t parentLen = hts_stringLengthUTF8(StringBuff(opt->path_html_utf8)); @@ -1484,7 +1483,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // copy final name and cleanup saveFinal = hts_convertUCS4StringToUTF8(wsave, j); if (saveFinal != NULL) { - strcpybuff(save, saveFinal); + strcpybuff(afs->save, saveFinal); free(saveFinal); } else { hts_log_print(opt, LOG_ERROR, "Could not revert to UTF-8: %s%s", @@ -1494,13 +1493,13 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, // log in debug hts_log_print(opt, LOG_DEBUG, "Too long filename shortened: %s%s => %s", - adr_complete, fil_complete, save); + adr_complete, fil_complete, afs->save); } else { - hts_log_print(opt, LOG_ERROR, "Could not read UTF-8: %s", save); + hts_log_print(opt, LOG_ERROR, "Could not read UTF-8: %s", afs->save); } // Re-check again ending space or dot after cut (see bug #5) - cleanEndingSpaceOrDot(save); + cleanEndingSpaceOrDot(afs->save); } #undef MAX_UTF8_SEQ_CHARS #undef MIN_LAST_SEG_RESERVE @@ -1511,11 +1510,11 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, char BIGSTK tempo[HTS_URLMAXSIZE * 2]; strcpybuff(tempo, StringBuff(opt->path_html_utf8)); - strcatbuff(tempo, save); - strcpybuff(save, tempo); + strcatbuff(tempo, afs->save); + strcpybuff(afs->save, tempo); } // vérifier que le nom n'est pas déja pris... - if (liens != NULL) { + if (opt->liens != NULL) { int nom_ok; do { @@ -1529,20 +1528,20 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, printf("\nStart search\n"); #endif - i = hash_read(hash, save, NULL, HASH_STRUCT_FILENAME); // lecture type 0 (sav) + i = hash_read(hash, afs->save, NULL, HASH_STRUCT_FILENAME); // lecture type 0 (sav) if (i >= 0) { - int sameAdr = (strfield2(liens[i]->adr, normadr) != 0); + int sameAdr = (strfield2(heap(i)->adr, normadr) != 0); int sameFil; // NO - URL hack is only for stripping // and www. //if (opt->urlhack != 0) - // sameFil = ( strfield2(liens[i]->fil, normfil) != 0); + // sameFil = ( strfield2(heap(i)->fil, normfil) != 0); //else - sameFil = (strcmp(liens[i]->fil, normfil) == 0); + sameFil = (strcmp(heap(i)->fil, normfil) == 0); if (sameAdr && sameFil) { // ok c'est le même lien, adresse déja définie /* Take the existing name not to screw up with cAsE sEnSiTiViTy of Linux/Unix */ - if (strcmp(liens[i]->sav, save) != 0) { - strcpybuff(save, liens[i]->sav); + if (strcmp(heap(i)->sav, afs->save) != 0) { + strcpybuff(afs->save, heap(i)->sav); } i = 0; #if DEBUG_SAVENAME @@ -1550,7 +1549,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, #endif } else { // utilisé par un AUTRE, changer de nom char BIGSTK tempo[HTS_URLMAXSIZE * 2]; - char *a = save + strlen(save) - 1; + char *a = afs->save + strlen(afs->save) - 1; char *b; int n = 2; char collisionSeparator = ((opt->savename_83 != 2) ? '-' : '_'); @@ -1558,18 +1557,18 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, tempo[0] = '\0'; #if DEBUG_SAVENAME - printf("\nWRONG CASE UNMATCH : \n%s\n%s, REDEFINE\n", liens[i]->fil, + printf("\nWRONG CASE UNMATCH : \n%s\n%s, REDEFINE\n", heap(i)->fil, fil_complete); #endif nom_ok = 0; i = 0; - while((a > save) && (*a != '.') && (*a != '\\') && (*a != '/')) + while((a > afs->save) && (*a != '.') && (*a != '\\') && (*a != '/')) a--; if (*a == '.') - strncatbuff(tempo, save, (int) (a - save)); + strncatbuff(tempo, afs->save, a - afs->save); else - strcatbuff(tempo, save); + strcatbuff(tempo, afs->save); // tester la présence d'un -xx (ex: index-2.html -> index-3.html) b = tempo + strlen(tempo) - 1; @@ -1600,7 +1599,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, if (*a == '.') strcatbuff(tempo, a); - strcpybuff(save, tempo); + strcpybuff(afs->save, tempo); //printf("switched: %s\n",save); @@ -1618,7 +1617,7 @@ int url_savename(char *adr_complete, char *fil_complete, char *save, } /* nom avec md5 urilisé partout */ -void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete, +void standard_name(char *b, const char *dot_pos, const char *nom_pos, const char *fil, int short_ver) { char md5[32 + 2]; @@ -1626,9 +1625,9 @@ void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete, /* Nom */ if (dot_pos) { if (!short_ver) // Noms longs - strncatbuff(b, nom_pos, (int) (dot_pos - nom_pos)); + strncatbuff(b, nom_pos, (dot_pos - nom_pos)); else - strncatbuff(b, nom_pos, min((int) (dot_pos - nom_pos), 8)); + strncatbuff(b, nom_pos, min(dot_pos - nom_pos, 8)); } else { if (!short_ver) // Noms longs strcatbuff(b, nom_pos); @@ -1636,7 +1635,7 @@ void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete, strncatbuff(b, nom_pos, 8); } /* MD5 - 16 bits */ - strncatbuff(b, url_md5(md5, fil_complete), 4); + strncatbuff(b, url_md5(md5, fil), 4); /* Ext */ if (dot_pos) { strcatbuff(b, "."); @@ -1657,11 +1656,11 @@ void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete, } /* Petit md5 */ -char *url_md5(char *digest, char *fil_complete) { +char *url_md5(char *digest, const char *fil) { char *a; digest[0] = '\0'; - a = strchr(fil_complete, '?'); + a = strchr(fil, '?'); if (a) { if (strlen(a)) { char BIGSTK buff[HTS_URLMAXSIZE * 2]; @@ -1676,7 +1675,7 @@ char *url_md5(char *digest, char *fil_complete) { } // interne à url_savename: ajoute une chaîne à une autre avec \ -> / -void url_savename_addstr(char *d, char *s) { +void url_savename_addstr(char *d, const char *s) { int i = (int) strlen(d); while(*s) { @@ -1695,9 +1694,9 @@ void url_savename_refname(const char *adr, const char *fil, char *filename) { MD5_CTX ctx; MD5Init(&ctx, 0); - MD5Update(&ctx, (const unsigned char *) adr, strlen(adr)); + MD5Update(&ctx, (const unsigned char *) adr, (int) strlen(adr)); MD5Update(&ctx, (const unsigned char *) ",", 1); - MD5Update(&ctx, (const unsigned char *) fil, strlen(fil)); + MD5Update(&ctx, (const unsigned char *) fil, (int) strlen(fil)); MD5Final(bindigest, &ctx); sprintf(filename, CACHE_REFNAME "/" "%02x%02x%02x%02x%02x%02x%02x%02x" diff --git a/src/htsname.h b/src/htsname.h index 245cc26..675b0cb 100644 --- a/src/htsname.h +++ b/src/htsname.h @@ -80,18 +80,27 @@ typedef struct hash_struct hash_struct; #define HTS_DEF_FWSTRUCT_lien_back typedef struct lien_back lien_back; #endif +#ifndef HTS_DEF_FWSTRUCT_lien_adrfil +#define HTS_DEF_FWSTRUCT_lien_adrfil +typedef struct lien_adrfil lien_adrfil; +#endif +#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave +#define HTS_DEF_FWSTRUCT_lien_adrfilsave +typedef struct lien_adrfilsave lien_adrfilsave; +#endif // note: 'headers' can either be null, or incomplete (only r member filled) -int url_savename(char *adr_complete, char *fil_complete, char *save, - char *former_adr, char *former_fil, char *referer_adr, - char *referer_fil, httrackp * opt, lien_url ** liens, - int lien_tot, struct_back * sback, cache_back * cache, +int url_savename(lien_adrfilsave *const afs, + lien_adrfil *const former, + const char *referer_adr, const char *referer_fil, + httrackp * opt, struct_back * sback, cache_back * cache, hash_struct * hash, int ptr, int numero_passe, const lien_back * headers); -void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete, +void standard_name(char *b, const char *dot_pos, const char *nom_pos, + const char *fil_complete, int short_ver); -void url_savename_addstr(char *d, char *s); -char *url_md5(char *digest_buffer, char *fil_complete); +void url_savename_addstr(char *d, const char *s); +char *url_md5(char *digest_buffer, const char *fil_complete); void url_savename_refname(const char *adr, const char *fil, char *filename); char *url_savename_refname_fullpath(httrackp * opt, const char *adr, const char *fil); diff --git a/src/htsnet.h b/src/htsnet.h index f0d8496..a393129 100644 --- a/src/htsnet.h +++ b/src/htsnet.h @@ -38,13 +38,17 @@ Please visit our Website: http://www.httrack.com /* basic net definitions */ #include "htsglobal.h" #include "htsbasenet.h" +#include "htssafe.h" +#include #include #ifdef _WIN32 // pour read #include // pour FindFirstFile #include +typedef USHORT in_port_t; +typedef ADDRESS_FAMILY sa_family_t; #else //typedef int T_SOC; #define INVALID_SOCKET -1 @@ -70,87 +74,16 @@ typedef unsigned long in_addr_t; #endif #endif -/* - ** ipV4 ** -*/ -#if HTS_INET6==0 - -/* Ipv4 structures */ -typedef struct in_addr INaddr; - -/* This should handle all cases */ -#ifndef HTS_DEF_FWSTRUCT_SOCaddr -#define HTS_DEF_FWSTRUCT_SOCaddr -typedef struct SOCaddr SOCaddr; +#ifdef __cplusplus +extern "C" { #endif -struct SOCaddr { - union { - struct sockaddr_in in; - struct sockaddr sa; - unsigned char v4data[4]; - unsigned char v6data[16]; - unsigned char pad[128]; - } m_addr; -}; - -/* Ipv4 structure members */ -#define SOCaddr_sinaddr(server) ((server).m_addr.in.sin_addr) -#define SOCaddr_sinfamily(server) ((server).m_addr.in.sin_family) -#define SOCaddr_sinport(server) ((server).m_addr.in.sin_port) - -/* AF_xx */ -#define AFinet AF_INET - -/* Set port to sockaddr structure */ -#define SOCaddr_initport(server, port) do { \ - SOCaddr_sinport(server) = htons((unsigned short int) (port)); \ -} while(0) - -#define SOCaddr_initany(server, server_len) do { \ - SOCaddr_sinfamily(server) = AF_INET; \ - memset(&SOCaddr_sinaddr(server), 0, sizeof(struct sockaddr_in)); \ - server_len=sizeof(struct sockaddr_in); \ -} while(0) - -/* Copy sockaddr to another one */ -#define SOCaddr_copyaddr(server, server_len, hpaddr, hpsize) do { \ -if (hpsize == sizeof(struct sockaddr_in)) { \ - server_len=sizeof(struct sockaddr_in); \ - SOCaddr_sinfamily(server) = (*(struct sockaddr_in*)(hpaddr)).sin_family; \ - SOCaddr_sinport(server) = (*(struct sockaddr_in*)(hpaddr)).sin_port; \ - memcpy(&SOCaddr_sinaddr(server), &(*(struct sockaddr_in*)(hpaddr)).sin_addr, sizeof(SOCaddr_sinaddr(server))); \ -} else if (hpsize == 4) {\ - server_len=sizeof(struct sockaddr_in); \ - SOCaddr_sinfamily(server) = AF_INET; \ - SOCaddr_sinport(server) = 0; \ - memcpy(&SOCaddr_sinaddr(server), (hpaddr), sizeof(SOCaddr_sinaddr(server))); \ -} else if ((hpsize > 0) && (hpsize <= sizeof(server))) { \ - server_len=hpsize; \ - memcpy(&(server), hpaddr, hpsize); \ -} else { \ - server_len=0; \ -} \ -} while(0) - -/* Get dotted address */ -#define SOCaddr_inetntoa(namebuf, namebuflen, ss, sslen) do { \ -char* dot = (char*) inet_ntoa(SOCaddr_sinaddr(ss)); \ -(namebuf)[0]='\0'; \ -if (dot) { \ -strcpy(namebuf, dot); \ -} \ -} while(0) - -/* Get protocol ID */ -#define SOCaddr_getproto(ss, sslen) ('1') - -/* - ** ipV6 ** -*/ -#else /* Ipv4 structures */ +#if HTS_INET6 != 0 typedef struct in6_addr INaddr; +#else +typedef struct in_addr INaddr; +#endif /* This should handle all cases */ #ifndef HTS_DEF_FWSTRUCT_SOCaddr @@ -159,117 +92,173 @@ typedef struct SOCaddr SOCaddr; #endif struct SOCaddr { union { - struct sockaddr_in6 in6; - struct sockaddr_in in; + /* Generic version, for network functions such as getnameinfo() */ struct sockaddr sa; - unsigned char v4data[4]; - unsigned char v6data[16]; - unsigned char pad[128]; + /* IPv4 */ + struct sockaddr_in in; +#if HTS_INET6 != 0 + /* IPv6 */ + struct sockaddr_in6 in6; +#endif } m_addr; }; -/* Ipv4 structure members */ -#define SOCaddr_sinaddr(server) ((server).m_addr.in6.sin6_addr) -#define SOCaddr_sinfamily(server) ((server).m_addr.in6.sin6_family) -#define SOCaddr_sinport(server) ((server).m_addr.in6.sin6_port) -#define SOCaddr_sinflowinfo(server) ((server).m_addr.in6.sin6_flowinfo) -/* #define SOCaddr_sinscopeid(a) ((a).m_addr.in6.sin6_scope_id) */ +static HTS_INLINE HTS_UNUSED in_port_t* SOCaddr_sinport_(SOCaddr *const addr, + const char *file, const int line) { + assertf_(addr != NULL, file, line); + switch(addr->m_addr.sa.sa_family) { + case AF_INET: + return &addr->m_addr.in.sin_port; + break; +#if HTS_INET6 != 0 + case AF_INET6: + return &addr->m_addr.in6.sin6_port; + break; +#endif + default: + assertf_(! "invalid structure", file, line); + return 0; + break; + } +} + +static HTS_INLINE HTS_UNUSED socklen_t SOCaddr_size_(const SOCaddr*const addr, + const char *file, const int line) { + assertf_(addr != NULL, file, line); + switch(addr->m_addr.sa.sa_family) { + case AF_INET: + return sizeof(addr->m_addr.in); + break; +#if HTS_INET6 != 0 + case AF_INET6: + return sizeof(addr->m_addr.in6); + break; +#endif + default: + return 0; + break; + } +} + +static HTS_INLINE HTS_UNUSED void SOCaddr_clear_(SOCaddr*const addr, + const char *file, const int line) { + assertf_(addr != NULL, file, line); + addr->m_addr.sa.sa_family = AF_UNSPEC; +} + +/* Ipv4/6 structure members */ +#define SOCaddr_sinfamily(server) ((server).m_addr.sa.sa_family) +#define SOCaddr_sinport(server) (*SOCaddr_sinport_(&(server), __FILE__, __LINE__)) +#define SOCaddr_size(server) (SOCaddr_size_(&(server), __FILE__, __LINE__)) +#define SOCaddr_is_valid(server) (SOCaddr_size_(&(server), __FILE__, __LINE__) != 0 ) +#define SOCaddr_clear(server) SOCaddr_clear_(&(server), __FILE__, __LINE__) +#define SOCaddr_sockaddr(server) ((server).m_addr.sa) +#define SOCaddr_capacity(server) sizeof((server).m_addr) /* AF_xx */ +#if HTS_INET6 != 0 #define AFinet AF_INET6 +#else +#define AFinet AF_INET +#endif /* Set port to sockaddr structure */ #define SOCaddr_initport(server, port) do { \ - SOCaddr_sinport(server) = htons((unsigned short int) (port)); \ + SOCaddr_sinport(server) = htons((in_port_t) (port)); \ } while(0) -#define SOCaddr_initany(server, server_len) do { \ - SOCaddr_sinfamily(server) = AF_INET; \ - memset(&SOCaddr_sinaddr(server), 0, sizeof(struct sockaddr_in)); \ - server_len=sizeof(struct sockaddr_in); \ +static HTS_INLINE HTS_UNUSED socklen_t SOCaddr_initany_(SOCaddr*const addr, + const char *file, const int line) { + assertf_(addr != NULL, file, line); + memset(&addr->m_addr.in, 0, sizeof(addr->m_addr.in)); + addr->m_addr.in.sin_family = AF_INET; + return SOCaddr_size_(addr, file, line); +} + +#define SOCaddr_initany(server) do { \ + SOCaddr_initany_(&(server), __FILE__, __LINE__); \ } while(0) /* - Copy sockaddr to SOCaddr - - Note; - The '> sizeof(struct sockaddr_in6)' hack if for the VC6 structure which - lacks the scope id + Copy sockaddr_in/sockaddr_in6/raw IPv4/raw IPv6 to our opaque SOCaddr */ +static HTS_UNUSED socklen_t SOCaddr_copyaddr_(SOCaddr*const server, + const void *data, const size_t data_size, + const char *file, const int line) { + assertf_(server != NULL, file, line); + assertf_(data != NULL, file, line); + + if (data_size == sizeof(struct sockaddr_in)) { + memcpy(&server->m_addr.in, data, sizeof(struct sockaddr_in)); + assertf_(server->m_addr.sa.sa_family == AF_INET, file, line); +#if HTS_INET6 != 0 + } else if (data_size == sizeof(struct sockaddr_in6)) { + memcpy(&server->m_addr.in6, data, sizeof(struct sockaddr_in6)); + assertf_(server->m_addr.sa.sa_family == AF_INET6, file, line); +#endif + } else if (data_size == 4) { + memset(&server->m_addr.in, 0, sizeof(server->m_addr.in)); + server->m_addr.in.sin_family = AF_INET; + server->m_addr.in.sin_port = 0; + memcpy(&server->m_addr.in.sin_addr, data, 4); +#if HTS_INET6 != 0 + } else if (data_size == 16) { + memset(&server->m_addr.in6, 0, sizeof(server->m_addr.in6)); + server->m_addr.in6.sin6_family = AF_INET6; + server->m_addr.in6.sin6_port = 0; + memcpy(&server->m_addr.in6.sin6_addr, data, 16); +#endif + } else { + server->m_addr.in.sin_family = AF_INET; + } + return SOCaddr_size_(server, file, line); +} + #define SOCaddr_copyaddr(server, server_len, hpaddr, hpsize) do { \ -if (hpsize == sizeof(struct sockaddr_in6)) { \ - server_len=sizeof(struct sockaddr_in6); \ - SOCaddr_sinfamily(server) = (*(struct sockaddr_in6*)(hpaddr)).sin6_family; \ - SOCaddr_sinport(server) = (*(struct sockaddr_in6*)(hpaddr)).sin6_port; \ - SOCaddr_sinflowinfo(server) = (*(struct sockaddr_in6*)(hpaddr)).sin6_flowinfo; \ - memcpy(&SOCaddr_sinaddr(server), &(*(struct sockaddr_in6*)(hpaddr)).sin6_addr, sizeof(SOCaddr_sinaddr(server))); \ -} else if (hpsize > sizeof(struct sockaddr_in6)) { \ - server_len=hpsize; \ - SOCaddr_sinport(server) = 0; \ - memcpy(&(server), hpaddr, hpsize); \ -} else if (hpsize == sizeof(struct sockaddr_in)) { \ - server_len=sizeof(struct sockaddr_in); \ - (*(struct sockaddr_in*)(&server)).sin_family = AF_INET; \ - SOCaddr_sinport(server) = (*(struct sockaddr_in*)(hpaddr)).sin_port; \ - memcpy(&(*(struct sockaddr_in*)&(server)).sin_addr, &(*(struct sockaddr_in*)(hpaddr)).sin_addr, sizeof((*(struct sockaddr_in*)(hpaddr)).sin_addr)); \ -} else if (hpsize == 4) {\ - server_len=sizeof(struct sockaddr_in); \ - (*(struct sockaddr_in*)(&server)).sin_family = AF_INET; \ - SOCaddr_sinport(server) = 0; \ - memcpy(&(*(struct sockaddr_in*)&(server)).sin_addr, hpaddr, 4); \ -} else if (hpsize == 16) {\ - server_len=sizeof(struct sockaddr_in6); \ - SOCaddr_sinfamily(server) = AF_INET6; \ - SOCaddr_sinport(server) = 0; \ - memcpy(&SOCaddr_sinaddr(server), (hpaddr), 16); \ -} else if ((hpsize > 0) && (hpsize <= sizeof(server))) { \ - server_len=hpsize; \ - memcpy(&(server), hpaddr, hpsize); \ -} else { \ - server_len=0; \ -} \ + server_len = (int) SOCaddr_copyaddr_(&(server), hpaddr, hpsize, __FILE__, __LINE__); \ +} while(0) + +#define SOCaddr_copyaddr2(server, hpaddr, hpsize) do { \ + (void) SOCaddr_copyaddr_(&(server), hpaddr, hpsize, __FILE__, __LINE__); \ +} while(0) + +#define SOCaddr_copy_SOCaddr(dest, src) do { \ + SOCaddr_copyaddr_(&(dest), &(src).m_addr.sa, SOCaddr_size(src), __FILE__, __LINE__); \ } while(0) /* Get dotted address */ -#define SOCaddr_inetntoa(namebuf, namebuflen, ss, sslen) do { \ - char *pos_; \ - (namebuf)[0]='\0'; \ - getnameinfo((struct sockaddr *)&(ss), sslen, \ - (namebuf), namebuflen, NULL, 0, NI_NUMERICHOST); \ - /* remove scope id */ \ - pos_ = strrchr(namebuf, '%'); \ - if (pos_ != NULL) { \ - *pos_ = '\0'; \ - } \ -} while(0) + +static HTS_UNUSED void SOCaddr_inetntoa_(char *namebuf, size_t namebuflen, + SOCaddr *const ss, + const char *file, const int line) { + assertf_(namebuf != NULL, file, line); + assertf_(ss != NULL, file, line); + + if (getnameinfo(&ss->m_addr.sa, sizeof(ss->m_addr), + namebuf, namebuflen, + NULL, 0, + NI_NUMERICHOST) == 0) { + /* remove scope id(s) */ + char *const pos = strchr(namebuf, '%'); + if (pos != NULL) { + *pos = '\0'; + } + } else { + namebuf[0] = '\0'; + } +} + +#define SOCaddr_inetntoa(namebuf, namebuflen, ss) \ + SOCaddr_inetntoa_(namebuf, namebuflen, &(ss), __FILE__, __LINE__) /* Get protocol ID */ -#define SOCaddr_getproto(ss, sslen) ((sslen == sizeof(struct sockaddr_in6))?('2'):('1')) - -#endif +#define SOCaddr_getproto(ss) ( SOCaddr_size(ss) == sizeof(struct sockaddr_in) ? '1' : '2') /* Socket length type */ typedef socklen_t SOClen; -/* Buffer structure to copy various hostent structures */ -#ifndef HTS_DEF_FWSTRUCT_t_fullhostent -#define HTS_DEF_FWSTRUCT_t_fullhostent -typedef struct t_fullhostent t_fullhostent; +#ifdef __cplusplus +} #endif -struct t_fullhostent { - t_hostent hp; - char *list[2]; - char addr[HTS_MAXADDRLEN]; /* various struct sockaddr structures */ - unsigned int addr_maxlen; -}; - -/* Initialize a t_fullhostent structure */ -#define fullhostent_init(h) do { \ -memset((h), 0, sizeof(t_fullhostent)); \ -(h)->hp.h_addr_list = (char **) & ((h)->list); \ -(h)->list[0] = (char *) & ((h)->addr); \ -(h)->list[1] = NULL; \ -(h)->addr_maxlen = HTS_MAXADDRLEN; \ -} while(0) #endif diff --git a/src/htsopt.h b/src/htsopt.h index 3b589f8..5c2e35e 100644 --- a/src/htsopt.h +++ b/src/htsopt.h @@ -35,7 +35,13 @@ Please visit our Website: http://www.httrack.com #define HTTRACK_DEFOPT #include + #include "htsglobal.h" +#include "htsnet.h" + +#ifdef __cplusplus +extern "C" { +#endif /* Forward definitions */ #ifndef HTS_DEF_FWSTRUCT_t_hts_htmlcheck_callbacks @@ -274,6 +280,11 @@ typedef enum htsparsejava_flags { HTSPARSE_NO_AGGRESSIVE = 8 // don't aggressively parse .js or .java } htsparsejava_flags; +#ifndef HTS_DEF_FWSTRUCT_lien_buffers +#define HTS_DEF_FWSTRUCT_lien_buffers +typedef struct lien_buffers lien_buffers; +#endif + // paramètres httrack (options) #ifndef HTS_DEF_FWSTRUCT_httrackp #define HTS_DEF_FWSTRUCT_httrackp @@ -362,7 +373,9 @@ struct httrackp { String urllist; // fichier liste de filtres à inclure htsfilters filters; // contient les pointeurs pour les filtres hash_struct *hash; // hash structure - lien_url **liens; // liens + lien_url **liens; // links + int lien_tot; // top index of "links" heap (always out-of-range) + lien_buffers *liensbuf; // links buffers robots_wizard *robotsptr; // robots ptr String lang_iso; // en, fr .. String accept; // Accept: @@ -374,7 +387,7 @@ struct httrackp { int maxlink; // nombre max de liens int maxfilter; // nombre max de filtres // - char *exec; // adresse du nom de l'éxecutable + const char *exec; // adresse du nom de l'éxecutable // int quiet; // poser des questions autres que wizard? int keyboard; // vérifier stdin @@ -432,4 +445,162 @@ struct hts_stat_struct { TStamp last_request; // last request issued }; +// structure pour paramètres supplémentaires lors de la requête +#ifndef HTS_DEF_FWSTRUCT_htsrequest_proxy +#define HTS_DEF_FWSTRUCT_htsrequest_proxy +typedef struct htsrequest_proxy htsrequest_proxy; +#endif +struct htsrequest_proxy { + int active; + const char* name; + int port; + const char* bindhost; // bind this host +}; + +#ifndef HTS_DEF_FWSTRUCT_htsrequest +#define HTS_DEF_FWSTRUCT_htsrequest +typedef struct htsrequest htsrequest; +#endif +struct htsrequest { + short int user_agent_send; // user agent (ex: httrack/1.0 [sun]) + short int http11; // l'en tête peut (doit) être signé HTTP/1.1 et non HTTP/1.0 + short int nokeepalive; // pas de keep-alive + short int range_used; // Range utilisé + short int nocompression; // Pas de compression + short int flush_garbage; // recycled + const char* user_agent; + const char* referer; + const char* from; + const char* lang_iso; + const char* accept; + const char* headers; + htsrequest_proxy proxy; // proxy +}; + +// structure pour retour d'une connexion/prise d'en tête +#ifndef HTS_DEF_FWSTRUCT_htsblk +#define HTS_DEF_FWSTRUCT_htsblk +typedef struct htsblk htsblk; +#endif +struct htsblk { + int statuscode; // status-code, -1=erreur, 200=OK,201=..etc (cf RFC1945) + short int notmodified; // page ou fichier NON modifié (transféré) + short int is_write; // sortie sur disque (out) ou en mémoire (adr) + short int is_chunk; // mode chunk + short int compressed; // compressé? + short int empty; // vide? + short int keep_alive; // Keep-Alive? + short int keep_alive_trailers; // ..with trailers extension + int keep_alive_t; // KA timeout + int keep_alive_max; // KA number of requests + char *adr; // adresse du bloc de mémoire, NULL=vide + char *headers; // adresse des en têtes si présents + FILE *out; // écriture directe sur disque (si is_write=1) + LLint size; // taille fichier + char msg[80]; // message éventuel si échec ("\0"=non précisé) + char contenttype[64]; // content-type ("text/html" par exemple) + char charset[64]; // charset ("iso-8859-1" par exemple) + char contentencoding[64]; // content-encoding ("gzip" par exemple) + char *location; // on copie dedans éventuellement la véritable 'location' + LLint totalsize; // taille totale à télécharger (-1=inconnue) + short int is_file; // ce n'est pas une socket mais un descripteur de fichier si 1 + T_SOC soc; // ID socket + SOCaddr address; // IP address + int address_size; // IP address structure length (unused internally) + FILE *fp; // fichier pour file:// +#if HTS_USEOPENSSL + short int ssl; // is this connection a SSL one? (https) + // BIO* ssl_soc; // SSL structure + SSL *ssl_con; // connection structure +#endif + char lastmodified[64]; // Last-Modified + char etag[256]; // Etag + char cdispo[256]; // Content-Disposition coupé + LLint crange; // Content-Range + LLint crange_start; // Content-Range + LLint crange_end; // Content-Range + int debugid; // debug connection + /* */ + htsrequest req; // paramètres pour la requête + /*char digest[32+2]; // digest md5 généré par le moteur ("" si non généré) */ +}; + +// structure d'un lien +#ifndef HTS_DEF_FWSTRUCT_lien_url +#define HTS_DEF_FWSTRUCT_lien_url +typedef struct lien_url lien_url; +#endif +struct lien_url { + char *adr; // adresse + char *fil; // nom du fichier distant + char *sav; // nom à sauver sur disque (avec chemin éventuel) + char *cod; // chemin codebase éventuel si classe java + char *former_adr; // adresse initiale (avant éventuel moved), peut être nulle + char *former_fil; // nom du fichier distant initial (avant éventuel moved), peut être nul + + int premier; // pointeur sur le premier lien qui a donné lieu aux autres liens du domaine + int precedent; // pointeur sur le lien qui a donné lieu à ce lien précis + int depth; // profondeur autorisée lien ; >0 forte 0=faible + int pass2; // traiter après les autres, seconde passe. si == -1, lien traité en background + char link_import; // lien importé à la suite d'un moved - ne pas appliquer les règles classiques up/down + //int moved; // pointeur sur moved + int retry; // nombre de retry restants + int testmode; // mode test uniquement, envoyer juste un head! +}; + +// chargement de fichiers en 'arrière plan' +#ifndef HTS_DEF_FWSTRUCT_lien_back +#define HTS_DEF_FWSTRUCT_lien_back +typedef struct lien_back lien_back; +#endif +struct lien_back { +#if DEBUG_CHECKINT + char magic; +#endif + char url_adr[HTS_URLMAXSIZE * 2]; // adresse + char url_fil[HTS_URLMAXSIZE * 2]; // nom du fichier distant + char url_sav[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel) + char referer_adr[HTS_URLMAXSIZE * 2]; // adresse host page referer + char referer_fil[HTS_URLMAXSIZE * 2]; // fichier page referer + char location_buffer[HTS_URLMAXSIZE * 2]; // "location" en cas de "moved" (302,..) + char *tmpfile; // nom à sauver temporairement (compressé) + char tmpfile_buffer[HTS_URLMAXSIZE * 2]; // buffer pour le nom à sauver temporairement + char send_too[1024]; // données à envoyer en même temps que le header + int status; // status (-1=non utilisé, 0: prêt, >0: opération en cours) + int locked; // locked (to be used soon) + int testmode; // mode de test + int timeout; // gérer des timeouts? (!=0 : nombre de secondes) + TStamp timeout_refresh; // si oui, time refresh + int rateout; // timeout refresh? (!=0 : taux minimum toléré en octets/s) + TStamp rateout_time; // si oui, date de départ + LLint maxfile_nonhtml; // taille max d'un fichier non html + LLint maxfile_html; // idem pour un ficheir html + htsblk r; // structure htsblk de chaque objet en background + int is_update; // mode update + int head_request; // requète HEAD? + LLint range_req_size; // range utilisé + TStamp ka_time_start; // refresh time for KA + // + int http11; // L'en tête doit être signé HTTP/1.1 et non HTTP/1.0 + int is_chunk; // chunk? + char *chunk_adr; // adresse chunk en cours de chargement + LLint chunk_size; // taille chunk en cours de chargement + LLint chunk_blocksize; // taille data declaree par le chunk + LLint compressed_size; // taille compressés (stats uniquement) + // + //int links_index; // to access liens[links_index] + // + char info[256]; // éventuel status pour le ftp + int stop_ftp; // flag stop pour ftp + int finalized; // finalized (optim memory) + int early_add; // was added before link heap saw it +#if DEBUG_CHECKINT + char magic2; +#endif +}; + +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/htsparse.c b/src/htsparse.c index e12e94c..811e077 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -60,113 +60,73 @@ Please visit our Website: http://www.httrack.com #include "htsparse.h" #include "htsback.h" -// specific defines -#define urladr (liens[ptr]->adr) -#define urlfil (liens[ptr]->fil) -#define savename (liens[ptr]->sav) -#define parenturladr (liens[liens[ptr]->precedent]->adr) -#define parenturlfil (liens[liens[ptr]->precedent]->fil) -#define parentsavename (liens[liens[ptr]->precedent]->sav) -#define relativeurladr ((!parent_relative)?urladr:parenturladr) -#define relativeurlfil ((!parent_relative)?urlfil:parenturlfil) -#define relativesavename ((!parent_relative)?savename:parentsavename) +// arrays +#include "htsarrays.h" + +/** Append bytes to the output buffer up to the pointer 'html'. **/ +#define HT_add_adr do { \ + if ( (opt->getmode & 1) != 0 && ptr > 0 ) { \ + const size_t sz_ = html - lastsaved; \ + if (sz_ != 0) { \ + TypedArrayAppend(output_buffer, lastsaved, sz_); \ + lastsaved = html; \ + } \ + } \ +} while(0) + +/** Append to the output buffer the string 'A'. **/ +#define HT_ADD(A) TypedArrayAppend(output_buffer, A, strlen(A)) + +/** Append to the output buffer the string 'A', html-escaped. **/ +#define HT_ADD_HTMLESCAPED_ANY(A, FUNCTION) do { \ + if ((opt->getmode & 1) != 0 && ptr>0) { \ + const char *const str_ = (A); \ + size_t size_; \ + /* & is the maximum expansion */ \ + TypedArrayEnsureRoom(output_buffer, strlen(str_) * 5 + 1024); \ + size_ = FUNCTION(str_, &TypedArrayTail(output_buffer), \ + TypedArrayRoom(output_buffer)); \ + TypedArraySize(output_buffer) += size_; \ + } \ +} while(0) + +/** Append to the output buffer the string 'A', html-escaped for &. **/ +#define HT_ADD_HTMLESCAPED(A) HT_ADD_HTMLESCAPED_ANY(A, escape_for_html_print) + +/** + * Append to the output buffer the string 'A', html-escaped for & and + * high chars. + **/ +#define HT_ADD_HTMLESCAPED_FULL(A) HT_ADD_HTMLESCAPED_ANY(A, escape_for_html_print_full) // does nothing #define XH_uninit do {} while(0) -// version optimisée, qui permet de ne pas toucher aux html non modifiés (update) -#define REALLOC_SIZE 8192 -#define HT_ADD_CHK(A) if (((int) (A)+ht_len+1) >= ht_size) { \ - char message[256]; \ - ht_size=(A)+ht_len+REALLOC_SIZE; \ - ht_buff=(char*) realloct(ht_buff,ht_size); \ - if (ht_buff==NULL) { \ - printf("PANIC! : Not enough memory [%d]\n", __LINE__); \ - XH_uninit; \ - snprintf(message, sizeof(message), "not enough memory for current html document in HT_ADD_CHK : realloct("LLintP") failed", (LLint) ht_size); \ - abortLog(message); \ - abort(); \ - } \ -} \ - ht_len+=A; -#define HT_ADD_ADR \ - if ((opt->getmode & 1) && (ptr>0)) { \ - size_t i = ((size_t) (adr - lastsaved)),j=ht_len; HT_ADD_CHK(i) \ - memcpy(ht_buff+j, lastsaved, i); \ - ht_buff[j+i]='\0'; \ - lastsaved=adr; \ - } -#define HT_ADD(A) \ - if ((opt->getmode & 1) && (ptr>0)) { \ - size_t i_ = strlen(A), j_ = ht_len; \ - if (i_) { \ - HT_ADD_CHK(i_) \ - memcpy(ht_buff+j_, A, i_); \ - ht_buff[j_+i_]='\0'; \ - } } -#define HT_ADD_HTMLESCAPED(A) \ - if ((opt->getmode & 1) && (ptr>0)) { \ - size_t i_, j_; \ - char BIGSTK tempo_[HTS_URLMAXSIZE*2]; \ - escape_for_html_print(A, tempo_, sizeof(tempo_)); \ - i_=strlen(tempo_); \ - j_=ht_len; \ - if (i_) { \ - HT_ADD_CHK(i_) \ - memcpy(ht_buff+j_, tempo_, i_); \ - ht_buff[j_+i_]='\0'; \ - } } -#define HT_ADD_HTMLESCAPED_FULL(A) \ - if ((opt->getmode & 1) && (ptr>0)) { \ - size_t i_, j_; \ - char BIGSTK tempo_[HTS_URLMAXSIZE*2]; \ - escape_for_html_print_full(A, tempo_, sizeof(tempo_)); \ - i_=strlen(tempo_); \ - j_=ht_len; \ - if (i_) { \ - HT_ADD_CHK(i_) \ - memcpy(ht_buff+j_, tempo_, i_); \ - ht_buff[j_+i_]='\0'; \ - } } -#define HT_ADD_START \ - char message[256]; \ - size_t ht_size=(size_t)(r->size*5)/4+REALLOC_SIZE; \ - size_t ht_len=0; \ - char* ht_buff=NULL; \ - if ((opt->getmode & 1) && (ptr>0)) { \ - ht_buff=(char*) malloct(ht_size); \ - if (ht_buff==NULL) { \ - printf("PANIC! : Not enough memory [%d]\n",__LINE__); \ - XH_uninit; \ - snprintf(message, sizeof(message), "not enough memory for current html document in HT_ADD_START : malloct("LLintP") failed", (LLint) ht_size); \ - abortLog(message); \ - abort(); \ - } \ - ht_buff[0]='\0'; \ - } #define HT_ADD_END { \ int ok=0;\ - if (ht_buff) { \ + if (TypedArraySize(output_buffer) != 0) { \ + const size_t ht_len = TypedArraySize(output_buffer); \ + const char *const ht_buff = TypedArrayElts(output_buffer); \ char digest[32+2];\ - off_t fsize_old = fsize(fconv(OPT_GET_BUFF(opt),OPT_GET_BUFF_SIZE(opt),savename));\ - digest[0]='\0';\ - domd5mem(ht_buff,ht_len,digest,1);\ - if (fsize_old==ht_len) { \ + off_t fsize_old = fsize(fconv(OPT_GET_BUFF(opt),OPT_GET_BUFF_SIZE(opt),savename()));\ + digest[0] = '\0';\ + domd5mem(TypedArrayElts(output_buffer), ht_len, digest, 1);\ + if (fsize_old == (off_t) ht_len) { \ int mlen = 0;\ char* mbuff;\ - cache_readdata(cache,"//[HTML-MD5]//",savename,&mbuff,&mlen);\ + cache_readdata(cache,"//[HTML-MD5]//",savename(),&mbuff,&mlen);\ if (mlen) \ mbuff[mlen]='\0';\ if ((mlen == 32) && (strcmp(((mbuff!=NULL)?mbuff:""),digest)==0)) {\ ok=1;\ - hts_log_print(opt, LOG_DEBUG, "File not re-written (md5): %s",savename);\ + hts_log_print(opt, LOG_DEBUG, "File not re-written (md5): %s",savename());\ } else {\ ok=0;\ } \ }\ if (!ok) { \ - file_notify(opt,urladr, urlfil, savename, 1, 1, r->notmodified); \ - fp=filecreate(&opt->state.strc, savename); \ + file_notify(opt,urladr(), urlfil(), savename(), 1, 1, r->notmodified); \ + fp=filecreate(&opt->state.strc, savename()); \ if (fp) { \ if (ht_len>0) {\ if (fwrite(ht_buff,1,ht_len,fp) != ht_len) { \ @@ -175,7 +135,7 @@ Please visit our Website: http://www.httrack.com opt->state.exit_xh=-1;\ }\ if (opt->log) { \ - hts_log_print(opt, LOG_ERROR | LOG_ERRNO, "Unable to write HTML file %s", savename);\ + hts_log_print(opt, LOG_ERROR | LOG_ERRNO, "Unable to write HTML file %s", savename());\ if (fcheck) {\ hts_log_print(opt, LOG_ERROR, "* * Fatal write error, giving up");\ }\ @@ -184,26 +144,26 @@ Please visit our Website: http://www.httrack.com }\ fclose(fp); fp=NULL; \ if (strnotempty(r->lastmodified)) \ - set_filetime_rfc822(savename,r->lastmodified); \ + set_filetime_rfc822(savename(),r->lastmodified); \ } else {\ int fcheck;\ if ((fcheck=check_fatal_io_errno())) {\ hts_log_print(opt, LOG_ERROR, "Mirror aborted: disk full or filesystem problems"); \ opt->state.exit_xh=-1;\ }\ - hts_log_print(opt, LOG_ERROR | LOG_ERRNO, "Unable to save file %s", savename);\ + hts_log_print(opt, LOG_ERROR | LOG_ERRNO, "Unable to save file %s", savename());\ if (fcheck) {\ hts_log_print(opt, LOG_ERROR, "* * Fatal write error, giving up");\ }\ }\ } else {\ - file_notify(opt,urladr, urlfil, savename, 0, 0, r->notmodified); \ - filenote(&opt->state.strc, savename,NULL); \ + file_notify(opt,urladr(), urlfil(), savename(), 0, 0, r->notmodified); \ + filenote(&opt->state.strc, savename(),NULL); \ }\ if (cache->ndx)\ - cache_writedata(cache->ndx,cache->dat,"//[HTML-MD5]//",savename,digest,(int)strlen(digest));\ + cache_writedata(cache->ndx,cache->dat,"//[HTML-MD5]//",savename(),digest,(int)strlen(digest));\ } \ - freet(ht_buff); ht_buff=NULL; \ + TypedArrayFree(output_buffer); \ } #define HT_ADD_FOP @@ -218,9 +178,9 @@ Please visit our Website: http://www.httrack.com sprintf(tempo,""CRLF,link_escaped); \ } else \ tempo[0]='\0'; \ - fprintf(makeindex_fp,template_footer, \ + hts_template_format(makeindex_fp,template_footer, \ "", \ - tempo \ + tempo, /* EOF */ NULL \ ); \ fflush(makeindex_fp); \ fclose(makeindex_fp); /* à ne pas oublier sinon on passe une nuit blanche */ \ @@ -231,74 +191,6 @@ Please visit our Website: http://www.httrack.com makeindex_done=1; /* ok c'est fait */ \ } while(0) -// Enregistrement d'un lien: -// on calcule la taille nécessaire: taille des 3 chaînes à stocker (taille forcée paire, plus 2 octets de sécurité) -// puis on vérifie qu'on a assez de marge dans le buffer - sinon on en réalloue un autre -// enfin on écrit à l'adresse courante du buffer, qu'on incrémente. on décrémente la taille dispo d'autant ensuite -// codebase: si non nul et si .class stockee on le note pour chemin primaire pour classes -// FA,FS: former_adr et former_fil, lien original -#define liens_record_sav_len(A) - -// COPIE DE HTSCORE.C - -#define liens_record(A,F,S,FA,FF) { \ - int notecode=0; \ - size_t lienurl_len=((sizeof(lien_url)+HTS_ALIGN-1)/HTS_ALIGN)*HTS_ALIGN,\ - adr_len=strlen(A),\ - fil_len=strlen(F),\ - sav_len=strlen(S),\ - cod_len=0,\ - former_adr_len=strlen(FA),\ - former_fil_len=strlen(FF); \ - if (former_adr_len>0) {\ - former_adr_len=(former_adr_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - former_fil_len=(former_fil_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - } else \ - former_adr_len=former_fil_len=0;\ - if (strlen(F)>6) if (strnotempty(codebase)) if (strfield(F+strlen(F)-6,".class")) {\ - notecode=1; \ - cod_len=strlen(codebase); \ - cod_len=(cod_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - } \ - adr_len=(adr_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - fil_len=(fil_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - sav_len=(sav_len/HTS_ALIGN)*HTS_ALIGN+HTS_ALIGN*2; \ - if ((int) lien_size < (int) (adr_len+fil_len+sav_len+cod_len+former_adr_len+former_fil_len+lienurl_len)) { \ - lien_buffer=(char*) ((void*) calloct(add_tab_alloc,1)); \ - lien_size=add_tab_alloc; \ - if (lien_buffer!=NULL) { \ - liens[lien_tot]=(lien_url*) (void*) lien_buffer; lien_buffer+=lienurl_len; lien_size-=lienurl_len; \ - liens[lien_tot]->firstblock=1; \ - } \ - } else { \ - liens[lien_tot]=(lien_url*) (void*) lien_buffer; lien_buffer+=lienurl_len; lien_size-=lienurl_len; \ - liens[lien_tot]->firstblock=0; \ - } \ - if (liens[lien_tot]!=NULL) { \ - liens[lien_tot]->adr=lien_buffer; lien_buffer+=adr_len; lien_size-=adr_len; \ - liens[lien_tot]->fil=lien_buffer; lien_buffer+=fil_len; lien_size-=fil_len; \ - liens[lien_tot]->sav=lien_buffer; lien_buffer+=sav_len; lien_size-=sav_len; \ - liens[lien_tot]->cod=NULL; \ - if (notecode) { \ - liens[lien_tot]->cod=lien_buffer; \ - lien_buffer+=cod_len; \ - lien_size-=cod_len; \ - strcpybuff(liens[lien_tot]->cod,codebase); \ - } \ - if (former_adr_len>0) {\ - liens[lien_tot]->former_adr=lien_buffer; lien_buffer+=former_adr_len; lien_size-=former_adr_len; \ - liens[lien_tot]->former_fil=lien_buffer; lien_buffer+=former_fil_len; lien_size-=former_fil_len; \ - strcpybuff(liens[lien_tot]->former_adr,FA); \ - strcpybuff(liens[lien_tot]->former_fil,FF); \ - }\ - strcpybuff(liens[lien_tot]->adr,A); \ - strcpybuff(liens[lien_tot]->fil,F); \ - strcpybuff(liens[lien_tot]->sav,S); \ - liens_record_sav_len(liens[lien_tot]); \ - hash_write(hashptr,lien_tot); \ - } \ -} - #define ENGINE_DEFINE_CONTEXT() \ ENGINE_DEFINE_CONTEXT_BASE(); \ /* */ \ @@ -316,7 +208,6 @@ Please visit our Website: http://www.httrack.com /* */ \ int error = * stre->error_; \ int store_errpage = * stre->store_errpage_; \ - int lien_max = *stre->lien_max_; \ /* */ \ int makeindex_done = *stre->makeindex_done_; \ FILE* makeindex_fp = *stre->makeindex_fp_; \ @@ -331,7 +222,6 @@ Please visit our Website: http://www.httrack.com /* */ \ error = * stre->error_; \ store_errpage = * stre->store_errpage_; \ - lien_max = *stre->lien_max_; \ /* */ \ makeindex_done = *stre->makeindex_done_; \ makeindex_fp = *stre->makeindex_fp_; \ @@ -349,7 +239,6 @@ Please visit our Website: http://www.httrack.com /* */ \ * stre->error_ = error; \ * stre->store_errpage_ = store_errpage; \ - * stre->lien_max_ = lien_max; \ /* */ \ *stre->makeindex_done_ = makeindex_done; \ *stre->makeindex_fp_ = makeindex_fp; \ @@ -365,7 +254,7 @@ Please visit our Website: http://www.httrack.com #define AUTOMATE_LOOKUP_CURRENT_ADR() do { \ if (inscript) { \ int new_state_pos; \ - new_state_pos=inscript_state[inscript_state_pos][(unsigned char)*adr]; \ + new_state_pos=inscript_state[inscript_state_pos][(unsigned char)*html]; \ if (new_state_pos < 0) { \ new_state_pos=inscript_state[inscript_state_pos][INSCRIPT_DEFAULT]; \ } \ @@ -379,7 +268,7 @@ Please visit our Website: http://www.httrack.com #define INCREMENT_CURRENT_ADR(steps) do { \ int steps__ = (int) ( steps ); \ while(steps__ > 0) { \ - adr++; \ + html++; \ AUTOMATE_LOOKUP_CURRENT_ADR(); \ steps__ --; \ } \ @@ -396,26 +285,39 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char *cAddr = r->adr; int cSize = (int) r->size; - hts_log_print(opt, LOG_DEBUG, "engine: preprocess-html: %s%s", urladr, - urlfil); - if (RUN_CALLBACK4(opt, preprocess, &cAddr, &cSize, urladr, urlfil) == 1) { + hts_log_print(opt, LOG_DEBUG, "engine: preprocess-html: %s%s", urladr(), + urlfil()); + if (RUN_CALLBACK4(opt, preprocess, &cAddr, &cSize, urladr(), urlfil()) == 1) { r->adr = cAddr; r->size = cSize; } } - if (RUN_CALLBACK4(opt, check_html, r->adr, (int) r->size, urladr, urlfil)) { - FILE *fp = NULL; // fichier écrit localement - char *adr = r->adr; // pointeur (on parcourt) - char *lastsaved; // adresse du dernier octet sauvé + 1 + if (RUN_CALLBACK4(opt, check_html, r->adr, (int) r->size, urladr(), urlfil())) { + FILE *fp = NULL; // fichier écrit localement + const char *html = r->adr; // pointeur (on parcours) + const char *lastsaved; // adresse du dernier octet sauvé + 1 - hts_log_print(opt, LOG_DEBUG, "scanning file %s%s (%s)..", urladr, urlfil, - savename); + hts_log_print(opt, LOG_DEBUG, "scanning file %s%s (%s)..", urladr(), urlfil(), + savename()); + + /* Hack to avoid NULL char problems with C syntax */ + /* Yes, some bogus HTML pages can embed null chars + and therefore can not be properly handled if this hack is not done + */ + if (r->adr != NULL) { + size_t i; + for(i = 0 ; i < (size_t) r->size ; i++) { + if (r->adr[i] == '\0') { + r->adr[i] = ' '; + } + } + } // Indexing! #if HTS_MAKE_KEYWORD_INDEX if (opt->kindex) { if (index_keyword - (r->adr, r->size, r->contenttype, savename, + (r->adr, r->size, r->contenttype, savename(), StringBuff(opt->path_html_utf8))) { hts_log_print(opt, LOG_DEBUG, "indexing file..done"); } else { @@ -431,12 +333,14 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } if (!error) { + // output HTML + TypedArray(char) output_buffer = EMPTY_TYPED_ARRAY; + time_t user_interact_timestamp = 0; int detect_title = 0; // détection du title int back_add_stats = opt->state.back_add_stats; - // - char *in_media = NULL; // in other media type (real media and so..) + const char *in_media = NULL; // in other media type (real media and so..) int intag = 0; // on est dans un tag int incomment = 0; // dans un "); + HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->", /* EOF */ NULL); } else makeindex_done = -1; // fait, erreur @@ -685,7 +579,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { s[0] = '\0'; if (p > 0) { - a = strchr(adr, '>'); + a = strchr(html, '>'); if (a != NULL) { a++; while(is_space(*a)) @@ -694,7 +588,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } } if (lienrelatif - (tempo, liens[ptr]->sav, + (tempo, heap(ptr)->sav, concat(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), StringBuff(opt->path_html_utf8), "index.html")) == 0) { @@ -733,14 +627,14 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // Body inplace_escape_uri_utf(tempo, sizeof(tempo)); - fprintf(makeindex_fp, template_body, tempo, s); + hts_template_format(makeindex_fp, template_body, tempo, s, /* EOF */ NULL); } } } } } - } else if (liens[ptr]->depth < opt->depth) { // on a sauté level1+1 et level1 + } else if (heap(ptr)->depth < opt->depth) { // on a sauté level1+1 et level1 HT_INDEX_END; } } // if (opt->makeindex) @@ -751,7 +645,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { */ /* Parse */ - if ((*adr == '<') /* No starting tag */ + if ((*html == '<') /* No starting tag */ &&(!inscript) /* Not in (java)script */ &&(!incomment) /* Not in comment ( is used somewhere else.. darn those browsers are dirty */ - if (!strstr(adr, "-->")) { + if (!strstr(html, "-->")) { intag = 0; incomment = 0; intag_start_valid = 0; @@ -931,18 +826,18 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { int p_searchMETAURL = 0; // chercher ..URL= int add_class = 0; // ajouter .class int add_class_dots_to_patch = 0; // number of '.' in code="x.y.z" - char *p_flush = NULL; + const char *p_flush = NULL; // ------------------------------------------------------------ // parsing évolé // ------------------------------------------------------------ - if (((isalpha((unsigned char) *adr)) || (*adr == '/') || (inscript) || (in_media) || (inscriptgen))) { // sinon pas la peine de tester.. + if (((isalpha((unsigned char) *html)) || (*html == '/') || (inscript) || (in_media) || (inscriptgen))) { // sinon pas la peine de tester.. /* caractère de terminaison pour "miniparsing" javascript=.. ? (ex: ) */ if (inscript_tag) { if (inscript_tag_lastc) { - if (*adr == inscript_tag_lastc) { + if (*html == inscript_tag_lastc) { /* sortir */ inscript_tag = inscript = 0; incomment = 0; @@ -969,9 +864,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { p = 0; valid_p = 1; } else if (strcmp(in_media, "AAM") == 0) { // AAM - if (is_space((unsigned char) adr[0]) - && !is_space((unsigned char) adr[1])) { - char *a = adr + 1; + if (is_space((unsigned char) html[0]) + && !is_space((unsigned char) html[1])) { + const char *a = html + 1; int n = 0; int ok = 0; int dot = 0; @@ -990,7 +885,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { tmp[0] = '\0'; strncat(tmp, a + dot + 1, n - dot - 1); if (is_knowntype(opt, tmp) || ishtml_ext(tmp) != -1) { - adr++; + html++; p = 0; valid_p = 1; unquoted_script = 1; @@ -1007,21 +902,21 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // note: inscript==1 donc on sautera après les \" if (inscript) { if (inscriptgen) { // on est déja dans un objet générant.. - if (*adr == scriptgen_q) { // fermeture des " ou ' - if (*(adr - 1) != '\\') { // non + if (*html == scriptgen_q) { // fermeture des " ou ' + if (*(html - 1) != '\\') { // non inscriptgen = 0; // ok parsing terminé } } } else { - char *a = NULL; + const char *a = NULL; char check_this_fking_line = 0; // parsing code javascript.. char must_be_terminated = 0; // caractère obligatoire de terminaison! int token_size; - if (!(token_size = strfield(adr, ".writeln"))) // détection ...objet.write[ln]("code html")... - token_size = strfield(adr, ".write"); + if (!(token_size = strfield(html, ".writeln"))) // détection ...objet.write[ln]("code html")... + token_size = strfield(html, ".write"); if (token_size) { - a = adr + token_size; + a = html + token_size; while(is_realspace(*a)) a++; // sauter espaces if (*a == '(') { // début parenthèse @@ -1047,7 +942,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { while(is_realspace(*a)) a++; if ((*a == '\'') || (*a == '"')) { // départ de '' ou "" - char *b; + const char *b; scriptgen_q = *a; // quote b = a + 1; // départ de la chaîne @@ -1078,10 +973,10 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // NOTE: le code javascript autogénéré n'est pas pris en compte!! // (et ne marche pas dans 50% des cas de toute facon!) if (check_this_fking_line == 1) { - p = (int) (b - adr); // calculer saut! + p = (int) (b - html); // calculer saut! } else { inscriptgen = 1; // SCRIPTGEN actif - adr = b; // jump + html = b; // jump } if ((opt->debug > 1) && (opt->log != NULL)) { @@ -1110,9 +1005,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!p) { // si dans un tag, et pas dans un script - sauf si on analyse un obj.write(".. if ((intag && (!inscript)) || inscriptgen) { - if ((*(adr - 1) == '<') || (is_space(*(adr - 1)))) { // 0 && len < sizeof(temp) - 2) { char *chpos; @@ -1194,7 +1089,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { int i = 0; while((p == 0) && (strnotempty(hts_detectandleave[i]))) { - p = rech_tageq(adr, hts_detectandleave[i]); + p = rech_tageq(html, hts_detectandleave[i]); i++; } if (p) @@ -1208,20 +1103,20 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { /* détection onLoad etc */ while((p == 0) && (strnotempty(hts_detect_js[i]))) { - p = rech_tageq(adr, hts_detect_js[i]); + p = rech_tageq(html, hts_detect_js[i]); i++; } /* non détecté - détecter également les onXxxxx= */ if (p == 0) { - if ((*adr == 'o') && (*(adr + 1) == 'n') - && isUpperLetter(*(adr + 2))) { + if ((*html == 'o') && (*(html + 1) == 'n') + && isUpperLetter(*(html + 2))) { p = 0; - while(isalpha((unsigned char) adr[p]) && (p < 64)) + while(isalpha((unsigned char) html[p]) && (p < 64)) p++; if (p < 64) { - while(is_space(adr[p])) + while(is_space(html[p])) p++; - if (adr[p] == '=') + if (html[p] == '=') p++; else p = 0; @@ -1231,8 +1126,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } /* OK, événement repéré */ if (p) { - inscript_tag_lastc = *(adr + p); /* à attendre à la fin */ - adr += p /*+ 1*/; /* saut */ + inscript_tag_lastc = *(html + p); /* à attendre à la fin */ + html += p /*+ 1*/; /* saut */ /* On est désormais dans du code javascript */ @@ -1247,7 +1142,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // '); - if (b) { - if (((int) (b - adr)) < 1000) { // au total < 1Ko + if (b != NULL) { + if (b - html < 1000) { // au total < 1Ko char BIGSTK tempo[HTS_URLMAXSIZE * 2]; + const size_t offset = html - r->adr; + char *const modify = &r->adr[offset]; + assertf(modify == html); tempo[0] = '\0'; - strncatbuff(tempo, a, (int) (b - a)); + strncatbuff(tempo, a, b - a); strcatbuff(tempo, " "); - strncatbuff(tempo, adr, (int) (a - adr - 1)); + strncatbuff(tempo, html, a - html - 1); // éventuellement remplire par des espaces pour avoir juste la taille - while((int) strlen(tempo) < ((int) (b - adr))) + while(strlen(tempo) < (size_t) (b - html)) strcatbuff(tempo, " "); // pas d'erreur? - if ((int) strlen(tempo) == ((int) (b - adr))) { - strncpy(adr, tempo, strlen(tempo)); // PAS d'octet nul à la fin! + if (strlen(tempo) == b - html) { + strncpy(modify, tempo, strlen(tempo)); // PAS d'octet nul à la fin! p = 0; // DEVALIDER!! p_type = 0; add_class = 0; @@ -1296,7 +1194,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // liens à patcher mais pas à charger (ex: codebase) if (p == 0) { // note: si non chargé (ex: ignorer .class) patché tout de même - p = rech_tageq(adr, "codebase"); + p = rech_tageq(html, "codebase"); if (p) { if ((intag_start_valid) && check_tag(intag_start, "applet")) { // dans un robots) { if ((intag_start_valid) && check_tag(intag_start, "meta")) { - if (rech_tageq(adr, "name")) { // name=robots.txt + if (rech_tageq(html, "name")) { // name=robots.txt char tempo[1100]; char *a; tempo[0] = '\0'; - a = strchr(adr, '>'); + a = strchr(html, '>'); #if DEBUG_ROBOTS printf("robots.txt meta tag detected\n"); #endif if (a) { - if (((int) (a - adr)) < 999) { - strncatbuff(tempo, adr, (int) (a - adr)); + if (((int) (a - html)) < 999) { + strncatbuff(tempo, html, (int) (a - html)); if (strstrcase(tempo, "content")) { if (strstrcase(tempo, "robots")) { if (strstrcase(tempo, "nofollow")) { #if DEBUG_ROBOTS printf ("robots.txt meta tag: nofollow in %s%s\n", - urladr, urlfil); + urladr(), urlfil()); #endif nofollow = 1; // NE PLUS suivre liens dans cette page hts_log_print(opt, LOG_WARNING, "Link %s%s not scanned (follow robots meta tag)", - urladr, urlfil); + urladr(), urlfil()); } } } @@ -1346,7 +1244,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // entrée dans une applet javascript /*if (!inscript) { // sinon on est dans un obj.write(".. if (p==0) - if (rech_sampletag(adr,"script")) + if (rech_sampletag(html,"script")) if (check_tag(intag_start,"script")) { inscript=1; } @@ -1361,13 +1259,13 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { #if 0 /* Check // javascript comments */ - if (*adr == 10 || *adr == 13) { + if (*html == 10 || *html == 13) { inscript_check_comments = 1; inscript_in_comments = 0; } else if (inscript_check_comments) { - if (!is_realspace(*adr)) { + if (!is_realspace(*html)) { inscript_check_comments = 0; - if (adr[0] == '/' && adr[1] == '/') { + if (html[0] == '/' && html[1] == '/') { inscript_in_comments = 1; } } @@ -1376,15 +1274,15 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { /* Parse */ assertf(inscript_name != NULL); - if (*adr == '/' + if (*html == '/' && - ((strfield(adr, "/script") + ((strfield(html, "/script") && strfield(inscript_name, "script")) - || (strfield(adr, "/style") + || (strfield(html, "/style") && strfield(inscript_name, "style")) ) && inscript_locked == 0) { - char *a = adr; + const char *a = html; //while(is_realspace(*(--a))); while(is_realspace(*a)) @@ -1405,7 +1303,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { foo "url" */ char expected = '='; // caractère attendu après - char *expected_end = ";"; + const char *expected_end = ";"; int can_avoid_quotes = 0; char quotes_replacement = '\0'; int ensure_not_mime = 0; @@ -1417,54 +1315,54 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if ((opt->parsejava & HTSPARSE_NO_JAVASCRIPT) == 0) { int nc; - nc = strfield(adr, ".src"); // nom.src="image"; - if (!nc && inscript_tag && inscript_tag_lastc == *(adr - 1)) - nc = strfield(adr, "src"); // onXXX='src="image";' + nc = strfield(html, ".src"); // nom.src="image"; + if (!nc && inscript_tag && inscript_tag_lastc == *(html - 1)) + nc = strfield(html, "src"); // onXXX='src="image";' if (!nc) - nc = strfield(adr, ".location"); // document.location="doc" + nc = strfield(html, ".location"); // document.location="doc" if (!nc) - nc = strfield(adr, ":location"); // javascript:location="doc" + nc = strfield(html, ":location"); // javascript:location="doc" if (!nc) { // location="doc" - if ((nc = strfield(adr, "location")) - && !isspace(*(adr - 1)) + if ((nc = strfield(html, "location")) + && !isspace(*(html - 1)) ) nc = 0; } if (!nc) - nc = strfield(adr, ".href"); // document.location="doc" + nc = strfield(html, ".href"); // document.location="doc" if (!nc) - if ((nc = strfield(adr, ".open"))) { // window.open("doc",.. + if ((nc = strfield(html, ".open"))) { // window.open("doc",.. expected = '('; // parenthèse expected_end = "),"; // fin: virgule ou parenthèse ensure_not_mime = 1; //* ensure the url is not a mime type */ } if (!nc) - if ((nc = strfield(adr, ".replace"))) { // window.replace("url") + if ((nc = strfield(html, ".replace"))) { // window.replace("url") expected = '('; // parenthèse expected_end = ")"; // fin: parenthèse } if (!nc) - if ((nc = strfield(adr, ".link"))) { // window.link("url") + if ((nc = strfield(html, ".link"))) { // window.link("url") expected = '('; // parenthèse expected_end = ")"; // fin: parenthèse } - if (!nc && (nc = strfield(adr, "url")) && (!isalnum(*(adr - 1))) && *(adr - 1) != '_') { // url(url) + if (!nc && (nc = strfield(html, "url")) && (!isalnum(*(html - 1))) && *(html - 1) != '_') { // url(url) expected = '('; // parenthèse expected_end = ")"; // fin: parenthèse can_avoid_quotes = 1; quotes_replacement = ')'; } if (!nc) - if ((nc = strfield(adr, "import"))) { // import "url" - if (is_space(*(adr + nc))) { + if ((nc = strfield(html, "import"))) { // import "url" + if (is_space(*(html + nc))) { expected = 0; // no char expected } else nc = 0; } if (nc) { - char *a; + const char *a; - a = adr + nc; + a = html + nc; while(is_realspace(*a)) a++; if ((*a == expected) || (!expected)) { @@ -1473,7 +1371,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { while(is_realspace(*a)) a++; if ((*a == 34) || (*a == '\'') || (can_avoid_quotes)) { - char *b, *c; + const char *b, *c; int ndelim = 1; if ((*a == 34) || (*a == '\'')) @@ -1546,7 +1444,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { "link detected in javascript: %s", str); } - p = (int) (a - adr); // p non nul: TRAITER CHAINE COMME FICHIER + p = (int) (a - html); // p non nul: TRAITER CHAINE COMME FICHIER if (can_avoid_quotes) { ending_p = quotes_replacement; } @@ -1568,14 +1466,14 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { //p=rech_tageq(adr,"primary"); // lien primaire, yeah p = 0; // No stupid tag anymore, raw link valid_p = 1; // Valid even if p==0 - while((adr[p] == '\r') || (adr[p] == '\n')) + while((html[p] == '\r') || (html[p] == '\n')) p++; //can_avoid_quotes=1; ending_p = '\r'; } - } else if (isspace((unsigned char) *adr)) { - intag_startattr = adr + 1; // attribute in tag (for dirty parsing) + } else if (isspace((unsigned char) *html)) { + intag_startattr = html + 1; // attribute in tag (for dirty parsing) } // ------------------------------------------------------------ @@ -1585,18 +1483,18 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // ------------------------------------------------------------ if (opt->parseall && (opt->parsejava & HTSPARSE_NO_AGGRESSIVE) == 0 && (ptr > 0) && (!in_media) /* && (!inscript_in_comments) */ ) { // option parsing "brut" //int incomment_justquit=0; - if (!is_realspace(*adr)) { + if (!is_realspace(*html)) { int noparse = 0; // Gestion des /* */ #if 0 if (inscript) { if (parseall_incomment) { - if ((*adr == '/') && (*(adr - 1) == '*')) + if ((*html == '/') && (*(html - 1) == '*')) parseall_incomment = 0; incomment_justquit = 1; // ne pas noter dernier caractère } else { - if ((*adr == '/') && (*(adr + 1) == '*')) + if ((*html == '/') && (*(html + 1) == '*')) parseall_incomment = 1; } } else @@ -1617,12 +1515,12 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!noparse) { //if ((!parseall_incomment) && (!noparse)) { if (!p) { // non déja trouvé - if (adr != r->adr) { // >1 caractère + if (html != r->adr) { // >1 caractère // scanner les chaines - if ((*adr == '\"') || (*adr == '\'')) { // "xx.gif" 'xx.gif' + if ((*html == '\"') || (*html == '\'')) { // "xx.gif" 'xx.gif' if (strchr("=(,", parseall_lastc)) { // exemple: a="img.gif.. (handles comments) - char *a = adr; - char stop = *adr; // " ou ' + const char *a = html; + char stop = *html; // " ou ' int count = 0; // sauter caractères @@ -1655,7 +1553,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { tempo[0] = '\0'; type[0] = '\0'; // - strncatbuff(tempo, adr + 1, count); + strncatbuff(tempo, html + 1, count); // if ((!strchr(tempo, ' ')) || inscript) { // espace dedans: méfiance! (sauf dans code javascript) int invalid_url = 0; @@ -1783,7 +1681,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // plus dans un commentaire if (inscript_state_pos == INSCRIPT_START && inscript_state_pos_prev == INSCRIPT_START) { - parseall_lastc = *adr; // caractère avant le prochain + parseall_lastc = *html; // caractère avant le prochain } } // if realspace @@ -1795,14 +1693,14 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // if ((p > 0) || (valid_p)) { // on a repéré un lien //int lien_valide=0; - char *eadr = NULL; /* fin de l'URL */ + const char *eadr = NULL; /* fin de l'URL */ //char* quote_adr=NULL; /* adresse du ? dans l'adresse */ int ok = 1; char quote = '\0'; int quoteinscript = 0; int noquote = 0; - char *tag_attr_start = adr; + const char *tag_attr_start = html; // si nofollow ou un stop a été déclenché, réécrire tous les liens en externe if ((nofollow) @@ -1815,27 +1713,27 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // écrire codebase avant, flusher avant code if ((p_type == -1) || (p_type == -2)) { if ((opt->getmode & 1) && (ptr > 0)) { - HT_ADD_ADR; // refresh + HT_add_adr; // refresh } - lastsaved = adr; // dernier écrit+1 + lastsaved = html; // dernier écrit+1 } // sauter espaces // adr+=p; INCREMENT_CURRENT_ADR(p); - while((is_space(*adr) - || (inscriptgen && adr[0] == '\\' && is_space(adr[1]) + while((is_space(*html) + || (inscriptgen && html[0] == '\\' && is_space(html[1]) ) ) && quote == '\0') { if (!quote) - if ((*adr == '\"') || (*adr == '\'')) { - quote = *adr; // on doit attendre cela à la fin - if (inscriptgen && *(adr - 1) == '\\') { + if ((*html == '\"') || (*html == '\'')) { + quote = *html; // on doit attendre cela à la fin + if (inscriptgen && *(html - 1) == '\\') { quoteinscript = 1; /* will wait for \" */ } } // puis quitter - // adr++; // sauter les espaces, "" et cie + // html++; // sauter les espaces, "" et cie INCREMENT_CURRENT_ADR(1); } @@ -1848,9 +1746,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // sauter éventuel \" ou \' javascript if (inscript) { // on est dans un obj.write(".. - if (*adr == '\\') { - if ((*(adr + 1) == '\'') || (*(adr + 1) == '"')) { // \" ou \' - // adr+=2; // sauter + if (*html == '\\') { + if ((*(html + 1) == '\'') || (*(html + 1) == '"')) { // \" ou \' + // html+=2; // sauter INCREMENT_CURRENT_ADR(2); } } @@ -1859,19 +1757,19 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (p_searchMETAURL) { int l = 0; - while((adr + l + 4 < r->adr + r->size) - && (!strfield(adr + l, "URL=")) + while((html + l + 4 < r->adr + r->size) + && (!strfield(html + l, "URL=")) && (l < 128)) l++; - if (!strfield(adr + l, "URL=")) + if (!strfield(html + l, "URL=")) ok = -1; else - adr += (l + 4); + html += (l + 4); } /* éviter les javascript:document.location=.. : les parser, plutôt */ if (ok != -1) { - if (strfield(adr, "javascript:") + if (strfield(html, "javascript:") && !inscript /* we don't want to parse 'javascript:' inside document.write inside scripts */ ) { ok = -1; @@ -1889,22 +1787,22 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } if (p_type == 1) { - if (*adr == '#') { - adr++; // sauter # pour usemap etc + if (*html == '#') { + html++; // sauter # pour usemap etc } } - eadr = adr; + eadr = html; // ne pas flusher après code si on doit écrire le codebase avant! if ((p_type != -1) && (p_type != 2) && (p_type != -2)) { if ((opt->getmode & 1) && (ptr > 0)) { - HT_ADD_ADR; // refresh + HT_add_adr; // refresh } - lastsaved = adr; // dernier écrit+1 + lastsaved = html; // dernier écrit+1 // après on écrira soit les données initiales, // soir une URL/lien modifié! } else if (p_type == -1) - p_flush = adr; // flusher jusqu'à adr ensuite + p_flush = html; // flusher jusqu'à adr ensuite if (ok != -1) { // continuer // découper le lien @@ -1913,7 +1811,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (!is_space(*eadr)) ok = 0; } - if ((((int) (eadr - adr))) > HTS_URLMAXSIZE) // ** trop long, >HTS_URLMAXSIZE caractères (on prévoit HTS_URLMAXSIZE autres pour path) + if ((((int) (eadr - html))) > HTS_URLMAXSIZE) // ** trop long, >HTS_URLMAXSIZE caractères (on prévoit HTS_URLMAXSIZE autres pour path) ok = -1; // ne pas traiter ce lien if (ok > 0) { @@ -1958,10 +1856,10 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } while(ok == 1); // Empty link detected - if ((((int) (eadr - adr))) <= 1) { // link empty + if ((((int) (eadr - html))) <= 1) { // link empty ok = -1; // No - if (*adr != '#') { // Not empty+unique # - if ((((int) (eadr - adr)) == 1)) { // 1=link empty with delim (end_adr-start_adr) + if (*html != '#') { // Not empty+unique # + if ((((int) (eadr - html)) == 1)) { // 1=link empty with delim (end_adr-start_adr) if (quote) { if ((opt->getmode & 1) && (ptr > 0)) { HT_ADD("#"); // We add this for a @@ -1971,7 +1869,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } } // This is a dirty and horrible hack to avoid parsing an Adobe GoLive bogus tag - if (strfield(adr, "(Empty Reference!)")) { + if (strfield(html, "(Empty Reference!)")) { ok = -1; // No } @@ -1981,13 +1879,13 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char BIGSTK lien[HTS_URLMAXSIZE * 2]; int meme_adresse = 0; // 0 par défaut pour primary - //char *copie_de_adr=adr; + //char *copie_de_adr=html; //char* p; // construire lien (découpage) - if ((((int) (eadr - adr)) - 1) < HTS_URLMAXSIZE) { // pas trop long? - strncpy(lien, adr, ((int) (eadr - adr)) - 1); - *(lien + (((int) (eadr - adr))) - 1) = '\0'; + if ((((int) (eadr - html)) - 1) < HTS_URLMAXSIZE) { // pas trop long? + strncpy(lien, html, ((int) (eadr - html)) - 1); + *(lien + (((int) (eadr - html))) - 1) = '\0'; //printf("link: %s\n",lien); // supprimer les espaces while((lien[strlen(lien) - 1] == ' ') && (strnotempty(lien))) @@ -1999,15 +1897,16 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // ------------------------------------------------------ // Lien repéré et extrait if (strnotempty(lien) > 0) { // construction du lien - char BIGSTK adr[HTS_URLMAXSIZE * 2], fil[HTS_URLMAXSIZE * 2]; // ATTENTION adr cache le "vrai" adr + lien_adrfilsave afs; int forbidden_url = -1; // lien non interdit (mais non autorisé..) int just_test_it = 0; // mode de test des liens int set_prio_to = 0; // pour capture de page isolée int import_done = 0; // lien importé (ne pas scanner ensuite *à priori*) // - adr[0] = '\0'; - fil[0] = '\0'; + afs.af.adr[0] = '\0'; + afs.af.fil[0] = '\0'; + afs.save[0] = '\0'; // // 0: autorisé // 1: interdit (patcher tout de même adresse) @@ -2179,7 +2078,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { while((lien[0] == '.') && (lien[1] == '/')) { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; - strcpybuff(tempo, lien + 2); + strcpybuff(tempo, lien + /* ./ */ 2); strcpybuff(lien, tempo); } if (strnotempty(lien) == 0) // sauf si plus de nom de fichier @@ -2288,7 +2187,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // Vérifier les codebase=applet (au lieu de applet/) if (p_type == -2) { // codebase if (strnotempty(lien)) { - if (fil[strlen(lien) - 1] != '/') { // pas répertoire + if (lien[strlen(lien) - 1] != '/') { // pas répertoire strcatbuff(lien, "/"); } } @@ -2312,17 +2211,16 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // copier nom host si besoin est if (!link_has_authority(lien)) { // pas de http:// - char BIGSTK adr2[HTS_URLMAXSIZE * 2], fil2[HTS_URLMAXSIZE * 2]; // ** euh ident_url_relatif?? + lien_adrfil af2; // ** euh ident_url_relatif?? - if (ident_url_relatif(lien, urladr, urlfil, adr2, fil2) < - 0) { + if (ident_url_relatif(lien, urladr(), urlfil(), &af2) < 0) { error = 1; } else { strcpybuff(lien, "http://"); - strcatbuff(lien, adr2); - if (*fil2 != '/') + strcatbuff(lien, af2.adr); + if (*af2.fil != '/') strcatbuff(lien, "/"); - strcatbuff(lien, fil2); + strcatbuff(lien, af2.fil); { char *a; @@ -2335,7 +2233,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } //char BIGSTK tempo[HTS_URLMAXSIZE*2]; //strcpybuff(tempo,"http://"); - //strcatbuff(tempo,urladr); // host + //strcatbuff(tempo,urladr()); // host //if (*lien!='/') // strcatbuff(tempo,"/"); //strcatbuff(tempo,lien); @@ -2402,7 +2300,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { HTS_URLMAXSIZE) { // mailto: and co: do NOT add base if (ident_url_relatif - (lien, urladr, urlfil, adr, fil) >= 0) { + (lien, urladr(), urlfil(), &afs.af) >= 0) { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; // base est absolue @@ -2423,19 +2321,18 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { lien); } } else { - char BIGSTK badr[HTS_URLMAXSIZE * 2], - bfil[HTS_URLMAXSIZE * 2]; - if (ident_url_absolute(_base, badr, bfil) >= 0) { - if (((int) strlen(badr) + (int) strlen(lien)) < + lien_adrfil baseaf; + if (ident_url_absolute(_base, &baseaf) >= 0) { + if (((int) strlen(baseaf.adr) + (int) strlen(lien)) < HTS_URLMAXSIZE) { char BIGSTK tempo[HTS_URLMAXSIZE * 2]; // base est absolue tempo[0] = '\0'; - if (!link_has_authority(badr)) { + if (!link_has_authority(baseaf.adr)) { strcatbuff(tempo, "http://"); } - strcatbuff(tempo, badr); + strcatbuff(tempo, baseaf.adr); strcatbuff(tempo, lien); strcpybuff(lien, tempo); // patcher en considérant base @@ -2462,11 +2359,11 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { hts_log_print(opt, LOG_DEBUG, "build relative link %s with %s%s", lien, - relativeurladr, relativeurlfil); + relativeurladr(), relativeurlfil()); if ((reponse = - ident_url_relatif(lien, relativeurladr, relativeurlfil, - adr, fil)) < 0) { - adr[0] = '\0'; // erreur + ident_url_relatif(lien, relativeurladr(), relativeurlfil(), + &afs.af)) < 0) { + afs.af.adr[0] = '\0'; // erreur if (reponse == -2) { hts_log_print(opt, LOG_WARNING, "Link %s not caught (unknown protocol)", @@ -2474,19 +2371,19 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } else { hts_log_print(opt, LOG_DEBUG, "ident_url_relatif failed for %s with %s%s", - lien, relativeurladr, relativeurlfil); + lien, relativeurladr(), relativeurlfil()); } } else { hts_log_print(opt, LOG_DEBUG, "built relative link %s with %s%s -> %s%s", - lien, relativeurladr, relativeurlfil, adr, - fil); + lien, relativeurladr(), relativeurlfil(), afs.af.adr, + afs.af.fil); } } else { hts_log_print(opt, LOG_DEBUG, "link %s not build, error detected before", lien); - adr[0] = '\0'; + afs.af.adr[0] = '\0'; } // Le lien doit juste être réécrit, mais ne doit pas générer un lien @@ -2494,7 +2391,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (p_nocatch) { forbidden_url = 1; // interdire récupération du lien hts_log_print(opt, LOG_DEBUG, "link forced external at %s%s", - adr, fil); + afs.af.adr, afs.af.fil); } // Tester si un lien doit être accepté ou refusé (wizard) // forbidden_url=1 : lien refusé @@ -2502,11 +2399,11 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { //if ((ptr>0) && (p_type!=2) && (p_type!=-2)) { // tester autorisations? if ((p_type != 2) && (p_type != -2)) { // tester autorisations? if (!p_nocatch) { - if (adr[0] != '\0') { + if (afs.af.adr[0] != '\0') { hts_log_print(opt, LOG_DEBUG, - "wizard link test at %s%s..", adr, fil); + "wizard link test at %s%s..", afs.af.adr, afs.af.fil); forbidden_url = - hts_acceptlink(opt, ptr, lien_tot, liens, adr, fil, + hts_acceptlink(opt, ptr, afs.af.adr, afs.af.fil, intag_name ? intag_name : NULL, intag_name ? tag_attr_start : NULL, &set_prio_to, &just_test_it); @@ -2518,25 +2415,23 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // calculer meme_adresse meme_adresse = - strfield2(jump_identification(adr), - jump_identification(urladr)); + strfield2(jump_identification(afs.af.adr), + jump_identification(urladr())); // Début partie sauvegarde // ici on forme le nom du fichier à sauver, et on patche l'URL - if (adr[0] != '\0') { - // savename: simplifier les ../ et autres joyeusetés - char BIGSTK save[HTS_URLMAXSIZE * 2]; + if (afs.af.adr[0] != '\0') { + // savename(): simplifier les ../ et autres joyeusetés int r_sv = 0; // En cas de moved, adresse première - char BIGSTK former_adr[HTS_URLMAXSIZE * 2]; - char BIGSTK former_fil[HTS_URLMAXSIZE * 2]; + lien_adrfil former; // - save[0] = '\0'; - former_adr[0] = '\0'; - former_fil[0] = '\0'; + afs.save[0] = '\0'; + former.adr[0] = '\0'; + former.fil[0] = '\0'; // // nom du chemin à sauver si on doit le calculer @@ -2552,14 +2447,14 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { /* Calc */ last_adr[0] = '\0'; //char last_fil[HTS_URLMAXSIZE*2]=""; - strcpybuff(last_adr, adr); // ancienne adresse + strcpybuff(last_adr, afs.af.adr); // ancienne adresse //strcpybuff(last_fil,fil); // ancien chemin r_sv = - url_savename(adr, fil, save, former_adr, former_fil, - liens[ptr]->adr, liens[ptr]->fil, opt, - liens, lien_tot, sback, cache, hash, ptr, + url_savename(&afs, &former, heap(ptr)->adr, heap(ptr)->fil, opt, + sback, cache, hash, ptr, numero_passe, NULL); - if (strcmp(jump_identification(last_adr), jump_identification(adr)) != 0) { // a changé + if (strcmp(jump_identification(last_adr), + jump_identification(afs.af.adr)) != 0) { // a changé // 2e test si moved @@ -2568,13 +2463,12 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // forbidden_url=0 : lien accepté if ((ptr > 0) && (p_type != 2) && (p_type != -2)) { // tester autorisations? if (!p_nocatch) { - if (adr[0] != '\0') { + if (afs.af.adr[0] != '\0') { hts_log_print(opt, LOG_DEBUG, "wizard moved link retest at %s%s..", - adr, fil); + afs.af.adr, afs.af.fil); forbidden_url = - hts_acceptlink(opt, ptr, lien_tot, liens, adr, - fil, + hts_acceptlink(opt, ptr, afs.af.adr, afs.af.fil, intag_name ? intag_name : NULL, intag_name ? tag_attr_start : NULL, &set_prio_to, @@ -2589,19 +2483,19 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { meme_adresse = 0; // on a changé } } else { - strcpybuff(save, ""); // dummy + strcpybuff(afs.save, ""); // dummy } } // resolve unresolved type if (r_sv != -1 && p_type != 2 && p_type != -2 - && forbidden_url == 0 && IS_DELAYED_EXT(save) + && forbidden_url == 0 && IS_DELAYED_EXT(afs.save) ) { time_t t; // pas d'erreur, on continue r_sv = - hts_wait_delayed(str, adr, fil, save, liens[ptr]->adr, - liens[ptr]->fil, former_adr, former_fil, + hts_wait_delayed(str, &afs, heap(ptr)->adr, + heap(ptr)->fil, &former, &forbidden_url); /* User interaction, because hts_wait_delayed can be slow.. (3.43) */ @@ -2623,22 +2517,22 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (forbidden_url != 1) { // le lien va être chargé if ((p_type == 2) || (p_type == -2)) { // base href ou codebase, pas un lien hts_log_print(opt, LOG_DEBUG, "Code/Codebase: %s%s", - adr, fil); + afs.af.adr, afs.af.fil); } else if ((opt->getmode & 4) == 0) { hts_log_print(opt, LOG_DEBUG, "Record: %s%s -> %s", - adr, fil, save); + afs.af.adr, afs.af.fil, afs.save); } else { - if (!ishtml(opt, fil)) + if (!ishtml(opt, afs.af.fil)) hts_log_print(opt, LOG_DEBUG, - "Record after: %s%s -> %s", adr, fil, - save); + "Record after: %s%s -> %s", afs.af.adr, afs.af.fil, + afs.save); else hts_log_print(opt, LOG_DEBUG, "Record: %s%s -> %s", - adr, fil, save); + afs.af.adr, afs.af.fil, afs.save); } } else - hts_log_print(opt, LOG_DEBUG, "External: %s%s", adr, - fil); + hts_log_print(opt, LOG_DEBUG, "External: %s%s", afs.af.adr, + afs.af.fil); } /* FIN log */ @@ -2649,29 +2543,29 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { /* */ else if (opt->urlmode == 0) { // URL absolue dans tous les cas if ((opt->getmode & 1) && (ptr > 0)) { // ecrire les html - if (!link_has_authority(adr)) { + if (!link_has_authority(afs.af.adr)) { HT_ADD("http://"); } else { - char *aut = strstr(adr, "//"); + char *aut = strstr(afs.af.adr, "//"); if (aut) { char tmp[256]; tmp[0] = '\0'; - strncatbuff(tmp, adr, (int) (aut - adr)); // scheme + strncatbuff(tmp, afs.af.adr, aut - afs.af.adr); // scheme HT_ADD(tmp); // Protocol HT_ADD("//"); } } if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(jump_protocol(adr)); // Password + HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } - if (*fil != '/') + if (afs.af.fil[0] != '/') HT_ADD("/"); - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } lastsaved = eadr - 1; // dernier écrit+1 (enfin euh apres on fait un ++ alors hein) /* */ @@ -2683,34 +2577,34 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if ((opt->getmode & 1) && (ptr > 0)) { if (p_type != -1) { // pas que le nom de fichier (pas classe java) if (!opt->external) { - if (!link_has_authority(adr)) { + if (!link_has_authority(afs.af.adr)) { HT_ADD("http://"); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(adr); // Password + HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } - if (*fil != '/') + if (afs.af.fil[0] != '/') HT_ADD("/"); - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } else { - char *aut = strstr(adr, "//"); + char *aut = strstr(afs.af.adr, "//"); if (aut) { char tmp[256]; tmp[0] = '\0'; - strncatbuff(tmp, adr, (int) (aut - adr)); // scheme + strncatbuff(tmp, afs.af.adr, (aut - afs.af.adr)); // scheme HT_ADD(tmp); // Protocol HT_ADD("//"); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(jump_protocol(adr)); // Password + HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } - if (*fil != '/') + if (afs.af.fil[0] != '/') HT_ADD("/"); - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } } // @@ -2718,15 +2612,15 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // int patch_it = 0; int add_url = 0; - char *cat_name = NULL; - char *cat_data = NULL; + const char *cat_name = NULL; + const char *cat_data = NULL; int cat_nb = 0; int cat_data_len = 0; // ajouter lien external - switch ((link_has_authority(adr)) ? 1 - : ((fil[strlen(fil) - 1] == - '/') ? 1 : (ishtml(opt, fil)))) { + switch ((link_has_authority(afs.af.adr)) ? 1 + : ((afs.af.fil[strlen(afs.af.fil) - 1] == + '/') ? 1 : (ishtml(opt, afs.af.fil)))) { case 1: case -2: // html ou répertoire if (opt->getmode & 1) { // sauver html @@ -2741,15 +2635,15 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { default: // inconnu // asp, cgi.. if ((strfield2 - (fil + max(0, (int) strlen(fil) - 4), + (afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4), ".gif")) || (strfield2 - (fil + max(0, (int) strlen(fil) - 4), + (afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4), ".jpg")) || (strfield2 - (fil + max(0, (int) strlen(fil) - 4), + (afs.af.fil + max(0, (int) strlen(afs.af.fil) - 4), ".xbm")) /*|| (ishtml(opt,fil)!=0) */ ) { @@ -2777,8 +2671,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { strcpybuff(save, StringBuff(opt->path_html_utf8)); strcatbuff(save, cat_name); - if (lienrelatif(tempo, save, relativesavename) == - 0) { + if (lienrelatif(tempo, save, relativesavename()) == 0) { /* Never escape high-chars (we don't know the encoding!!) */ inplace_escape_uri_utf(tempo, sizeof(tempo)); // escape with %xx //if (!no_esc_utf) @@ -2790,33 +2683,33 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { HT_ADD("?link="); // page externe // same as above - if (!link_has_authority(adr)) { + if (!link_has_authority(afs.af.adr)) { HT_ADD("http://"); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(adr); // Password + HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } - if (*fil != '/') + if (afs.af.fil[0] != '/') HT_ADD("/"); - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } else { - char *aut = strstr(adr, "//"); + char *aut = strstr(afs.af.adr, "//"); if (aut) { char tmp[256]; tmp[0] = '\0'; - strncatbuff(tmp, adr, (int) (aut - adr) + 2); // scheme + strncatbuff(tmp, afs.af.adr, (aut - afs.af.adr) + 2); // scheme HT_ADD(tmp); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(jump_protocol(adr)); // Password + HT_ADD_HTMLESCAPED(jump_protocol(afs.af.adr)); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } - if (*fil != '/') + if (afs.af.fil[0] != '/') HT_ADD("/"); - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } } // @@ -2855,13 +2748,13 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } else { // écrire normalement le nom de fichier HT_ADD("http://"); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(adr); // Password + HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } - if (*fil != '/') + if (afs.af.fil[0] != '/') HT_ADD("/"); - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } // patcher? } // external } else { // que le nom de fichier (classe java) @@ -2872,7 +2765,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // Calculer chemin tempo_pat[0] = '\0'; - strcpybuff(tempo, fil); // <-- ajouté + strcpybuff(tempo, afs.af.fil); // <-- ajouté { char *a = strrchr(tempo, '/'); @@ -2896,7 +2789,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char BIGSTK tempo2[HTS_URLMAXSIZE * 2]; strcpybuff(tempo2, a + 1); // FICHIER - strncatbuff(tempo_pat, tempo, (int) (a - tempo) + 1); // chemin + strncatbuff(tempo_pat, tempo, (a - tempo) + 1); // chemin strcpybuff(tempo, tempo2); // fichier } } @@ -2910,9 +2803,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if (strnotempty(tempo_pat)) { HT_ADD("codebase=\"http://"); if (!opt->passprivacy) { - HT_ADD_HTMLESCAPED(adr); // Password + HT_ADD_HTMLESCAPED(afs.af.adr); // Password } else { - HT_ADD_HTMLESCAPED(jump_identification(adr)); // No Password + HT_ADD_HTMLESCAPED(jump_identification(afs.af.adr)); // No Password } if (*tempo_pat != '/') HT_ADD("/"); @@ -2948,12 +2841,12 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char BIGSTK cid[HTS_URLMAXSIZE * 3]; HT_ADD("cid:"); - make_content_id(adr, fil, cid, sizeof(cid)); + make_content_id(afs.af.adr, afs.af.fil, cid, sizeof(cid)); HT_ADD_HTMLESCAPED(cid); lastsaved = eadr - 1; // dernier écrit+1 (enfin euh apres on fait un ++ alors hein) } else if (opt->urlmode == 3) { // URI absolue / if ((opt->getmode & 1) && (ptr > 0)) { // ecrire les html - HT_ADD_HTMLESCAPED(fil); + HT_ADD_HTMLESCAPED(afs.af.fil); } lastsaved = eadr - 1; // dernier écrit+1 (enfin euh apres on fait un ++ alors hein) } else if (opt->urlmode == 5) { // transparent proxy URL @@ -2963,23 +2856,23 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { char *pos; if ((opt->getmode & 1) && (ptr > 0)) { // ecrire les html - if (!link_has_authority(adr)) { + if (!link_has_authority(afs.af.adr)) { HT_ADD("http://"); } else { - char *aut = strstr(adr, "//"); + char *aut = strstr(afs.af.adr, "//"); if (aut) { char tmp[256]; tmp[0] = '\0'; - strncatbuff(tmp, adr, (int) (aut - adr)); // scheme + strncatbuff(tmp, afs.af.adr, (aut - afs.af.adr)); // scheme HT_ADD(tmp); // Protocol HT_ADD("//"); } } // filename is taken as URI (ex: "C:\My Website\www.example.com\foo4242.html) - uri = save; + uri = afs.save; // .. after stripping the path prefix (ex: "www.example.com\foo4242.html) if (strnotempty(StringBuff(opt->path_html_utf8))) { @@ -2995,7 +2888,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // put original query string if any (ex: "www.example.com/foo4242.html?q=45) - pos = strchr(fil, '?'); + pos = strchr(afs.af.fil, '?'); if (pos != NULL) { strcatbuff(tempo, pos); } @@ -3009,7 +2902,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { tempo[0] = '\0'; // calculer le lien relatif - if (lienrelatif(tempo, save, relativesavename) == 0) { + if (lienrelatif(tempo, afs.save, relativesavename()) == 0) { if (!in_media) { // In media (such as real audio): don't patch /* Never escape high-chars (we don't know the encoding!!) */ inplace_escape_uri_utf(tempo, sizeof(tempo)); @@ -3026,7 +2919,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } hts_log_print(opt, LOG_DEBUG, "relative link at %s build with %s and %s: %s", - adr, save, relativesavename, tempo); + afs.af.adr, afs.save, relativesavename(), tempo); // lien applet (code) - il faut placer un codebase avant if (p_type == -1) { // que le nom de fichier @@ -3115,7 +3008,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } else { hts_log_print(opt, LOG_WARNING, "Error building relative link %s and %s", - save, relativesavename); + afs.save, relativesavename()); } } // sinon le lien sera écrit normalement @@ -3130,20 +3023,19 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { #endif /* Security check */ - if (strlen(save) >= HTS_URLMAXSIZE) { - adr[0] = '\0'; + if (strlen(afs.save) >= HTS_URLMAXSIZE) { + afs.af.adr[0] = '\0'; hts_log_print(opt, LOG_WARNING, "Link is too long: %s", - save); + afs.save); } - if ((adr[0] != '\0') && (p_type != 2) && (p_type != -2) && (forbidden_url != 1)) { // si le fichier n'existe pas, ajouter à la liste + if ((afs.af.adr[0] != '\0') && (p_type != 2) && (p_type != -2) && (forbidden_url != 1)) { // si le fichier n'existe pas, ajouter à la liste // n'y a-t-il pas trop de liens? - if (lien_tot + 1 >= lien_max - 4) { // trop de liens! - printf("PANIC! : Too many URLs : >%d [%d]\n", lien_tot, + if (opt->maxlink > 0 && opt->lien_tot + 1 >= opt->maxlink) { // trop de liens! + printf("PANIC! : Too many URLs : >%d [%d]\n", opt->lien_tot, __LINE__); - hts_log_print(opt, LOG_PANIC, - "Too many URLs, giving up..(>%d)", - lien_max); + hts_log_print(opt, LOG_PANIC, "Too many URLs, giving up..(>%d)", + opt->maxlink); hts_log_print(opt, LOG_INFO, "To avoid that: use #L option for more links (example: -#L1000000)"); if ((opt->getmode & 1) && (ptr > 0)) { @@ -3154,7 +3046,6 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } XH_uninit; // désallocation mémoire & buffers return -1; - } else { // noter le lien sur la listes des liens à charger int pass_fix, dejafait = 0; @@ -3162,7 +3053,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { if ((opt->getmode & 4) == 0) { // traiter html après pass_fix = 0; } else { // vérifier que ce n'est pas un !html - if (!ishtml(opt, fil)) + if (!ishtml(opt, afs.af.fil)) pass_fix = 1; // priorité inférieure (traiter après) else pass_fix = max(0, numero_passe); // priorité normale @@ -3185,20 +3076,20 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // // On part de la fin et on essaye de se presser (économise temps machine) { - int i = hash_read(hash, save, NULL, 0); // lecture type 0 (sav) + int i = hash_read(hash, afs.save, NULL, 0); // lecture type 0 (sav) if (i >= 0) { if ((opt->debug > 1) && (opt->log != NULL)) { - if (strcmp(adr, liens[i]->adr) != 0 - || strcmp(fil, liens[i]->fil) != 0) { + if (strcmp(afs.af.adr, heap(i)->adr) != 0 + || strcmp(afs.af.fil, heap(i)->fil) != 0) { hts_log_print(opt, LOG_DEBUG, "merging similar links %s%s and %s%s", - adr, fil, liens[i]->adr, - liens[i]->fil); + afs.af.adr, afs.af.fil, heap(i)->adr, + heap(i)->fil); } } - liens[i]->depth = - maximum(liens[i]->depth, liens[ptr]->depth - 1); + heap(i)->depth = + maximum(heap(i)->depth, heap(ptr)->depth - 1); dejafait = 1; } } @@ -3210,31 +3101,21 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // >>>> CREER LE LIEN <<<< // // enregistrer lien à charger - //liens[lien_tot]->adr[0]=liens[lien_tot]->fil[0]=liens[lien_tot]->sav[0]='\0'; + //heap_top()->adr[0]=heap_top()->fil[0]=heap_top()->sav[0]='\0'; // même adresse: l'objet père est l'objet père de l'actuel // DEBUT ROBOTS.TXT AJOUT if (!just_test_it) { - if ((!strfield(adr, "ftp://")) // non ftp - && (!strfield(adr, "file://")) + if ((!strfield(afs.af.adr, "ftp://")) // non ftp + && (!strfield(afs.af.adr, "file://")) ) { // non file if (opt->robots) { // récupérer robots - if (ishtml(opt, fil) != 0) { // pas la peine pour des fichiers isolés - if (checkrobots(_ROBOTS, adr, "") != -1) { // robots.txt ? - checkrobots_set(_ROBOTS, adr, ""); // ajouter entrée vide - if (checkrobots(_ROBOTS, adr, "") == -1) { // robots.txt ? + if (ishtml(opt, afs.af.fil) != 0) { // pas la peine pour des fichiers isolés + if (checkrobots(_ROBOTS, afs.af.adr, "") != -1) { // robots.txt ? + checkrobots_set(_ROBOTS, afs.af.adr, ""); // ajouter entrée vide + if (checkrobots(_ROBOTS, afs.af.adr, "") == -1) { // robots.txt ? // enregistrer robots.txt (MACRO) - liens_record(adr, "/robots.txt", "", "", - ""); - if (liens[lien_tot] == NULL) { // erreur, pas de place réservée - printf - ("PANIC! : Not enough memory [%d]\n", - __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + - 1) * - sizeof(lien_url))); + if (!hts_record_link(opt, afs.af.adr, "/robots.txt", "", "", "", NULL)) { if ((opt->getmode & 1) && (ptr > 0)) { if (fp) { fclose(fp); @@ -3244,15 +3125,13 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { XH_uninit; // désallocation mémoire & buffers return -1; } - liens[lien_tot]->testmode = 0; // pas mode test - liens[lien_tot]->link_import = 0; // pas mode import - liens[lien_tot]->premier = lien_tot; - liens[lien_tot]->precedent = ptr; - liens[lien_tot]->depth = 0; - liens[lien_tot]->pass2 = - max(0, numero_passe); - liens[lien_tot]->retry = 0; - lien_tot++; // UN LIEN DE PLUS + heap_top()->testmode = 0; // pas mode test + heap_top()->link_import = 0; // pas mode import + heap_top()->premier = heap_top_index(); + heap_top()->precedent = ptr; + heap_top()->depth = 0; + heap_top()->pass2 = max(0, numero_passe); + heap_top()->retry = 0; #if DEBUG_ROBOTS printf ("robots.txt: added file robots.txt for %s\n", @@ -3260,7 +3139,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { #endif hts_log_print(opt, LOG_DEBUG, "robots.txt added at %s", - adr); + afs.af.adr); } else { hts_log_print(opt, LOG_ERROR, "Unexpected robots.txt error at %d", @@ -3273,15 +3152,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // FIN ROBOTS.TXT AJOUT - // enregistrer (MACRO) - liens_record(adr, fil, save, former_adr, former_fil); - if (liens[lien_tot] == NULL) { // erreur, pas de place réservée - printf("PANIC! : Not enough memory [%d]\n", - __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + - 1) * sizeof(lien_url))); + // enregistrer + if (!hts_record_link(opt, afs.af.adr, afs.af.fil, afs.save, + former.adr, former.fil, codebase)) { if ((opt->getmode & 1) && (ptr > 0)) { if (fp) { fclose(fp); @@ -3293,51 +3166,50 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // mode test? if (!just_test_it) - liens[lien_tot]->testmode = 0; // pas mode test + heap_top()->testmode = 0; // pas mode test else - liens[lien_tot]->testmode = 1; // mode test + heap_top()->testmode = 1; // mode test if (!import_done) - liens[lien_tot]->link_import = 0; // pas mode import + heap_top()->link_import = 0; // pas mode import else - liens[lien_tot]->link_import = 1; // mode import + heap_top()->link_import = 1; // mode import // écrire autres paramètres de la structure-lien if ((meme_adresse) && (!import_done) - && (liens[ptr]->premier != 0)) - liens[lien_tot]->premier = liens[ptr]->premier; + && (heap(ptr)->premier != 0)) + heap_top()->premier = heap(ptr)->premier; else // sinon l'objet père est le précédent lui même - liens[lien_tot]->premier = lien_tot; - // liens[lien_tot]->premier=ptr; + heap_top()->premier = heap_top_index(); + // heap_top()->premier=ptr; - liens[lien_tot]->precedent = ptr; + heap_top()->precedent = ptr; // noter la priorité if (!set_prio_to) - liens[lien_tot]->depth = liens[ptr]->depth - 1; + heap_top()->depth = heap(ptr)->depth - 1; else - liens[lien_tot]->depth = max(0, min(liens[ptr]->depth - 1, set_prio_to - 1)); // PRIORITE NULLE (catch page) + heap_top()->depth = max(0, min(heap(ptr)->depth - 1, set_prio_to - 1)); // PRIORITE NULLE (catch page) // noter pass - liens[lien_tot]->pass2 = pass_fix; - liens[lien_tot]->retry = opt->retry; + heap_top()->pass2 = pass_fix; + heap_top()->retry = opt->retry; - //strcpybuff(liens[lien_tot]->adr,adr); - //strcpybuff(liens[lien_tot]->fil,fil); - //strcpybuff(liens[lien_tot]->sav,save); + //strcpybuff(heap_top()->adr,adr); + //strcpybuff(heap_top()->fil,fil); + //strcpybuff(heap_top()->sav,save); if (!just_test_it) { hts_log_print(opt, LOG_DEBUG, "OK, NOTE: %s%s -> %s", - liens[lien_tot]->adr, - liens[lien_tot]->fil, - liens[lien_tot]->sav); + heap_top()->adr, + heap_top()->fil, + heap_top()->sav); } else { hts_log_print(opt, LOG_DEBUG, "OK, TEST: %s%s", - liens[lien_tot]->adr, - liens[lien_tot]->fil); + heap_top()->adr, + heap_top()->fil); } - lien_tot++; // UN LIEN DE PLUS } else { // if !dejafait hts_log_print(opt, LOG_DEBUG, "link has already been recorded, cancelled: %s", - save); + afs.save); } @@ -3352,9 +3224,9 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // if ok==0 - assertf(eadr - adr >= 0); // Should not go back - if (eadr > adr) { - INCREMENT_CURRENT_ADR(eadr - 1 - adr); + assertf(eadr - html >= 0); // Should not go back + if (eadr > html) { + INCREMENT_CURRENT_ADR(eadr - 1 - html); } // adr=eadr-1; // ** sauter @@ -3368,7 +3240,7 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } // si '<' ou '>' // plus loin - adr++; // automate will be checked next loop + html++; // automate will be checked next loop /* Otimization: if we are scanning in HTML data (not in tag or script), then jump to the next starting tag */ @@ -3380,25 +3252,25 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { &&(!inscript_tag) /* Not in tag with script inside */ ) { /* Not at the end */ - if ((((int) (adr - r->adr))) < r->size) { + if ((((int) (html - r->adr))) < r->size) { /* Not on a starting tag yet */ - if (*adr != '<') { + if (*html != '<') { /* strchr does not well behave with null chrs.. */ /* char* adr_next = strchr(adr,'<'); */ - char *adr_next = adr; + const char *adr_next = html; while(*adr_next != '<' && (adr_next - r->adr) < r->size) { adr_next++; } /* Jump to near end (index hack) */ if (!adr_next || *adr_next != '<') { - if (((int) (adr - r->adr) < (r->size - 4)) + if (((int) (html - r->adr) < (r->size - 4)) && (r->size > 4) ) { - adr = r->adr + r->size - 2; + html = r->adr + r->size - 2; } } else { - adr = adr_next; + html = adr_next; } } } @@ -3407,8 +3279,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // ---------- // écrire peu à peu if ((opt->getmode & 1) && (ptr > 0)) - HT_ADD_ADR; - lastsaved = adr; // dernier écrit+1 + HT_add_adr; + lastsaved = html; // dernier écrit+1 // ---------- // Checks @@ -3417,18 +3289,18 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // Check max time if (!back_checkmirror(opt)) { - adr = r->adr + r->size; + html = r->adr + r->size; } } // pour les stats du shell si parsing trop long if (r->size) opt->state._hts_in_html_done = - (100 * ((int) (adr - r->adr))) / (int) (r->size); + (100 * ((int) (html - r->adr))) / (int) (r->size); if (opt->state._hts_in_html_poll) { opt->state._hts_in_html_poll = 0; // temps à attendre, et remplir autant que l'on peut le cache (backing) back_wait(sback, opt, cache, HTS_STAT.stat_timestart); - back_fillmax(sback, opt, cache, liens, ptr, numero_passe, lien_tot); + back_fillmax(sback, opt, cache, ptr, numero_passe); // Transfer rate engine_stats(); @@ -3438,11 +3310,11 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { HTS_STAT.stat_errors = fspc(opt, NULL, "error"); HTS_STAT.stat_warnings = fspc(opt, NULL, "warning"); HTS_STAT.stat_infos = fspc(opt, NULL, "info"); - HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr); + HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr); HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback); if (!RUN_CALLBACK7 - (opt, loop, sback->lnk, sback->count, 0, ptr, lien_tot, + (opt, loop, sback->lnk, sback->count, 0, ptr, opt->lien_tot, (int) (time_local() - HTS_STAT.stat_timestart), &HTS_STAT)) { hts_log_print(opt, LOG_ERROR, "Exit requested by shell or user"); *stre->exit_xh_ = 1; // exit requested @@ -3459,24 +3331,27 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { // refresh the backing system each 2 seconds if (engine_stats()) { back_wait(sback, opt, cache, HTS_STAT.stat_timestart); - back_fillmax(sback, opt, cache, liens, ptr, numero_passe, lien_tot); + back_fillmax(sback, opt, cache, ptr, numero_passe); } - } while((((int) (adr - r->adr))) < r->size); + } while(html - r->adr < r->size); opt->state._hts_in_html_parsing = 0; // flag opt->state._hts_cancel = 0; // pas de cancel if ((opt->getmode & 1) && (ptr > 0)) { { - char *cAddr = ht_buff; - int cSize = (int) ht_len; + char *cAddr = TypedArrayElts(output_buffer); + int cSize = (int) TypedArraySize(output_buffer); hts_log_print(opt, LOG_DEBUG, "engine: postprocess-html: %s%s", - urladr, urlfil); - if (RUN_CALLBACK4(opt, postprocess, &cAddr, &cSize, urladr, urlfil) == - 1) { - ht_buff = cAddr; - ht_len = cSize; + urladr(), urlfil()); + if (RUN_CALLBACK4(opt, postprocess, &cAddr, &cSize, urladr(), urlfil()) == 1) { + if (cAddr != TypedArrayElts(output_buffer)) { + hts_log_print(opt, LOG_DEBUG, + "engine: postprocess-html: callback modified data, applying %d bytes", cSize); + TypedArraySize(output_buffer) = 0; + TypedArrayAppend(output_buffer, cAddr, cSize); + } } } @@ -3495,8 +3370,8 @@ int htsparse(htsmoduleStruct * str, htsmoduleStructExtended * stre) { } } // sauver fichier - //structcheck(savename); - //filesave(opt,r->adr,r->size,savename); + //structcheck(savename()); + //filesave(opt,r->adr,r->size,savename()); } // analyse OK @@ -3529,25 +3404,26 @@ int hts_mirror_check_moved(htsmoduleStruct * str, //int i=0; // char* p; - hts_log_print(opt, LOG_WARNING, "%s for %s%s", r->msg, urladr, urlfil); + hts_log_print(opt, LOG_WARNING, "%s for %s%s", r->msg, urladr(), urlfil()); { - char BIGSTK mov_url[HTS_URLMAXSIZE * 2], mov_adr[HTS_URLMAXSIZE * 2], - mov_fil[HTS_URLMAXSIZE * 2]; + char BIGSTK mov_url[HTS_URLMAXSIZE * 2]; + lien_adrfilsave savedmoved; + lien_adrfil *const moved = &savedmoved.af; int get_it = 0; // ne pas prendre le fichier à la même adresse par défaut int reponse = 0; mov_url[0] = '\0'; - mov_adr[0] = '\0'; - mov_fil[0] = '\0'; + moved->adr[0] = '\0'; + moved->fil[0] = '\0'; + savedmoved.save[0] = '\0'; // strcpybuff(mov_url, r->location); // url qque -> adresse+fichier if ((reponse = - ident_url_relatif(mov_url, urladr, urlfil, mov_adr, - mov_fil)) >= 0) { + ident_url_relatif(mov_url, urladr(), urlfil(), moved)) >= 0) { int set_prio_to = 0; // pas de priotité fixéd par wizard // check whether URLHack is harmless or not @@ -3556,29 +3432,29 @@ int hts_mirror_check_moved(htsmoduleStruct * str, char BIGSTK pn_adr[HTS_URLMAXSIZE * 2], pn_fil[HTS_URLMAXSIZE * 2]; n_adr[0] = n_fil[0] = '\0'; - (void) adr_normalized(mov_adr, n_adr); - (void) fil_normalized(mov_fil, n_fil); - (void) adr_normalized(urladr, pn_adr); - (void) fil_normalized(urlfil, pn_fil); + (void) adr_normalized(moved->adr, n_adr); + (void) fil_normalized(moved->fil, n_fil); + (void) adr_normalized(urladr(), pn_adr); + (void) fil_normalized(urlfil(), pn_fil); if (strcasecmp(n_adr, pn_adr) == 0 && strcasecmp(n_fil, pn_fil) == 0) { hts_log_print(opt, LOG_WARNING, "Redirected link is identical because of 'URL Hack' option: %s%s and %s%s", - urladr, urlfil, mov_adr, mov_fil); + urladr(), urlfil(), moved->adr, moved->fil); } } - //if (ident_url_absolute(mov_url,mov_adr,mov_fil)!=-1) { // ok URL reconnue + //if (ident_url_absolute(mov_url,moved->adr,moved->fil)!=-1) { // ok URL reconnue // c'est (en gros) la même URL.. // si c'est un problème de casse dans le host c'est que le serveur est buggé // ("RFC says.." : host name IS case insensitive) - if ((strfield2(mov_adr, urladr) != 0) && (strfield2(mov_fil, urlfil) != 0)) { // identique à casse près + if ((strfield2(moved->adr, urladr()) != 0) && (strfield2(moved->fil, urlfil()) != 0)) { // identique à casse près // on tourne en rond - if (strcmp(mov_fil, urlfil) == 0) { + if (strcmp(moved->fil, urlfil()) == 0) { error = 1; get_it = -1; // ne rien faire hts_log_print(opt, LOG_WARNING, "Can not bear crazy server (%s) for %s%s", r->msg, - urladr, urlfil); + urladr(), urlfil()); } else { // mauvaise casse, effacer entrée dans la pile et rejouer une fois get_it = 1; } @@ -3587,71 +3463,59 @@ int hts_mirror_check_moved(htsmoduleStruct * str, // -> on prend à cette adresse, le lien sera enregistré avec lien_record() (hash) hts_log_print(opt, LOG_DEBUG, "wizard link test for moved file at %s%s..", - mov_adr, mov_fil); + moved->adr, moved->fil); // accepté? - if (hts_acceptlink(opt, ptr, lien_tot, liens, mov_adr, mov_fil, NULL, NULL, &set_prio_to, NULL) != 1) { /* nouvelle adresse non refusée ? */ + if (hts_acceptlink(opt, ptr, moved->adr, moved->fil, NULL, NULL, &set_prio_to, NULL) != 1) { /* nouvelle adresse non refusée ? */ get_it = 1; hts_log_print(opt, LOG_DEBUG, "moved link accepted: %s%s", - mov_adr, mov_fil); + moved->adr, moved->fil); } } /* sinon traité normalement */ } - //if ((strfield2(mov_adr,urladr)!=0) && (strfield2(mov_fil,urlfil)!=0)) { // identique à casse près + //if ((strfield2(moved->adr,urladr())!=0) && (strfield2(moved->fil,urlfil())!=0)) { // identique à casse près if (get_it == 1) { // court-circuiter le reste du traitement // et reculer pour mieux sauter hts_log_print(opt, LOG_WARNING, "Warning moved treated for %s%s (real one is %s%s)", - urladr, urlfil, mov_adr, mov_fil); + urladr(), urlfil(), moved->adr, moved->fil); // canceller lien actuel error = 1; - strcpybuff(liens[ptr]->adr, "!"); // caractère bidon (invalide hash) + hts_invalidate_link(opt, ptr); // invalidate hashtable entry // noter NOUVEAU lien //xxc xxc // set_prio_to=0+1; // protection if the moved URL is an html page!! //xxc xxc { - char BIGSTK mov_sav[HTS_URLMAXSIZE * 2]; - // calculer lien et éventuellement modifier addresse/fichier - if (url_savename - (mov_adr, mov_fil, mov_sav, NULL, NULL, - liens[liens[ptr]->precedent]->adr, - liens[liens[ptr]->precedent]->fil, opt, liens, lien_tot, + if (url_savename(&savedmoved, NULL, + heap(heap(ptr)->precedent)->adr, + heap(heap(ptr)->precedent)->fil, opt, sback, cache, hash, ptr, numero_passe, NULL) != -1) { - if (hash_read(hash, mov_sav, NULL, HASH_STRUCT_FILENAME) < 0) { // n'existe pas déja - // enregistrer lien (MACRO) avec SAV IDENTIQUE - liens_record(mov_adr, mov_fil, liens[ptr]->sav, "", ""); - //liens_record(mov_adr,mov_fil,mov_sav,"",""); - if (liens[lien_tot] != NULL) { // OK, pas d'erreur + if (hash_read(hash, savedmoved.save, NULL, HASH_STRUCT_FILENAME) < 0) { // n'existe pas déja + // enregistrer lien avec SAV IDENTIQUE + if (hts_record_link(opt, moved->adr, moved->fil, heap(ptr)->sav, "", "", NULL)) { // mode test? - liens[lien_tot]->testmode = liens[ptr]->testmode; - liens[lien_tot]->link_import = 0; // mode normal + heap_top()->testmode = heap(ptr)->testmode; + heap_top()->link_import = 0; // mode normal if (!set_prio_to) - liens[lien_tot]->depth = liens[ptr]->depth; + heap_top()->depth = heap(ptr)->depth; else - liens[lien_tot]->depth = max(0, min(set_prio_to - 1, liens[ptr]->depth)); // PRIORITE NULLE (catch page) - liens[lien_tot]->pass2 = - max(liens[ptr]->pass2, numero_passe); - liens[lien_tot]->retry = liens[ptr]->retry; - liens[lien_tot]->premier = liens[ptr]->premier; - liens[lien_tot]->precedent = liens[ptr]->precedent; - lien_tot++; + heap_top()->depth = max(0, min(set_prio_to - 1, heap(ptr)->depth)); // PRIORITE NULLE (catch page) + heap_top()->pass2 = + max(heap(ptr)->pass2, numero_passe); + heap_top()->retry = heap(ptr)->retry; + heap_top()->premier = heap(ptr)->premier; + heap_top()->precedent = heap(ptr)->precedent; } else { // oups erreur, plus de mémoire!! - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + - 1) * sizeof(lien_url))); - //if (opt->getmode & 1) { if (fp) { fclose(fp); fp=NULL; } } XH_uninit; // désallocation mémoire & buffers return 0; } } else { hts_log_print(opt, LOG_INFO, "moving %s to an existing file %s", - liens[ptr]->fil, urlfil); + heap(ptr)->fil, urlfil()); } } @@ -3670,12 +3534,12 @@ int hts_mirror_check_moved(htsmoduleStruct * str, char *const rn = (char *) malloct(rn_size); if (rn != NULL) { hts_log_print(opt, LOG_WARNING, "File has moved from %s%s to %s", - urladr, urlfil, mov_url); + urladr(), urlfil(), mov_url); if (!opt->mimehtml) { inplace_escape_uri(mov_url, sizeof(mov_url)); } else { char BIGSTK cid[HTS_URLMAXSIZE * 3]; - make_content_id(mov_adr, mov_fil, cid, sizeof(cid)); + make_content_id(moved->adr, moved->fil, cid, sizeof(cid)); strcpybuff(mov_url, "cid:"); strcatbuff(mov_url, cid); } @@ -3712,49 +3576,41 @@ int hts_mirror_check_moved(htsmoduleStruct * str, } else if ((r->statuscode == HTTP_PRECONDITION_FAILED) || (r->statuscode == HTTP_REQUESTED_RANGE_NOT_SATISFIABLE) ) { // Precondition Failed, c'est à dire pour nous redemander TOUT le fichier - if (fexist_utf8(liens[ptr]->sav)) { - remove(liens[ptr]->sav); // Eliminer + if (fexist_utf8(heap(ptr)->sav)) { + remove(heap(ptr)->sav); // Eliminer } else { hts_log_print(opt, LOG_WARNING, "Unexpected 412/416 error (%s) for %s%s, '%s' could not be found on disk", - r->msg, urladr, urlfil, - liens[ptr]->sav != NULL ? liens[ptr]->sav : ""); + r->msg, urladr(), urlfil(), + heap(ptr)->sav != NULL ? heap(ptr)->sav : ""); } - if (!fexist_utf8(liens[ptr]->sav)) { // Bien éliminé? (sinon on boucle..) + if (!fexist_utf8(heap(ptr)->sav)) { // Bien éliminé? (sinon on boucle..) #if HDEBUG printf("Partial content NOT up-to-date, reget all file for %s\n", - liens[ptr]->sav); + heap(ptr)->sav); #endif hts_log_print(opt, LOG_DEBUG, "Partial file reget (%s) for %s%s", - r->msg, urladr, urlfil); - // enregistrer le MEME lien (MACRO) - liens_record(liens[ptr]->adr, liens[ptr]->fil, liens[ptr]->sav, "", - ""); - if (liens[lien_tot] != NULL) { // OK, pas d'erreur - liens[lien_tot]->testmode = liens[ptr]->testmode; // mode test? - liens[lien_tot]->link_import = 0; // pas mode import - liens[lien_tot]->depth = liens[ptr]->depth; - liens[lien_tot]->pass2 = max(liens[ptr]->pass2, numero_passe); - liens[lien_tot]->retry = liens[ptr]->retry; - liens[lien_tot]->premier = liens[ptr]->premier; - liens[lien_tot]->precedent = ptr; - lien_tot++; + r->msg, urladr(), urlfil()); + // enregistrer le MEME lien + if (hts_record_link(opt, heap(ptr)->adr, heap(ptr)->fil, heap(ptr)->sav, "", "", NULL)) { + heap_top()->testmode = heap(ptr)->testmode; // mode test? + heap_top()->link_import = 0; // pas mode import + heap_top()->depth = heap(ptr)->depth; + heap_top()->pass2 = max(heap(ptr)->pass2, numero_passe); + heap_top()->retry = heap(ptr)->retry; + heap_top()->premier = heap(ptr)->premier; + heap_top()->precedent = ptr; // // canceller lien actuel error = 1; - strcpybuff(liens[ptr]->adr, "!"); // caractère bidon (invalide hash) + hts_invalidate_link(opt, ptr); // invalidate hashtable entry // } else { // oups erreur, plus de mémoire!! - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + 1) * sizeof(lien_url))); - //if (opt->getmode & 1) { if (fp) { fclose(fp); fp=NULL; } } XH_uninit; // désallocation mémoire & buffers return 0; } } else { - hts_log_print(opt, LOG_ERROR, "Can not remove old file %s", urlfil); + hts_log_print(opt, LOG_ERROR, "Can not remove old file %s", urlfil()); error = 1; } @@ -3775,27 +3631,25 @@ int hts_mirror_check_moved(htsmoduleStruct * str, //case -1: can_retry=1; break; case STATUSCODE_TIMEOUT: if (opt->hostcontrol) { // timeout et retry épuisés - if ((opt->hostcontrol & 1) && (liens[ptr]->retry <= 0)) { - hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr, urlfil); - host_ban(opt, liens, ptr, lien_tot, sback, - jump_identification(urladr)); + if ((opt->hostcontrol & 1) && (heap(ptr)->retry <= 0)) { + hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr(), urlfil()); + host_ban(opt, ptr, sback, jump_identification(urladr())); hts_log_print(opt, LOG_DEBUG, - "Info: previous log - link banned: %s%s", urladr, - urlfil); + "Info: previous log - link banned: %s%s", urladr(), + urlfil()); } else can_retry = 1; } else can_retry = 1; break; case STATUSCODE_SLOW: - if ((opt->hostcontrol) && (liens[ptr]->retry <= 0)) { // too slow + if ((opt->hostcontrol) && (heap(ptr)->retry <= 0)) { // too slow if (opt->hostcontrol & 2) { - hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr, urlfil); - host_ban(opt, liens, ptr, lien_tot, sback, - jump_identification(urladr)); + hts_log_print(opt, LOG_DEBUG, "Link banned: %s%s", urladr(), urlfil()); + host_ban(opt, ptr, sback, jump_identification(urladr())); hts_log_print(opt, LOG_DEBUG, - "Info: previous log - link banned: %s%s", urladr, - urlfil); + "Info: previous log - link banned: %s%s", urladr(), + urlfil()); } else can_retry = 1; } else @@ -3819,29 +3673,29 @@ int hts_mirror_check_moved(htsmoduleStruct * str, break; } - if (strcmp(liens[ptr]->fil, "/primary") != 0) { // no primary (internal page 0) - if ((liens[ptr]->retry <= 0) || (!can_retry)) { // retry épuisés (ou retry impossible) + if (strcmp(heap(ptr)->fil, "/primary") != 0) { // no primary (internal page 0) + if ((heap(ptr)->retry <= 0) || (!can_retry)) { // retry épuisés (ou retry impossible) if ((opt->retry > 0) && (can_retry)) { hts_log_print(opt, LOG_ERROR, "\"%s\" (%d) after %d retries at link %s%s (from %s%s)", - r->msg, r->statuscode, opt->retry, urladr, urlfil, - liens[liens[ptr]->precedent]->adr, - liens[liens[ptr]->precedent]->fil); + r->msg, r->statuscode, opt->retry, urladr(), urlfil(), + heap(heap(ptr)->precedent)->adr, + heap(heap(ptr)->precedent)->fil); } else { if (r->statuscode == STATUSCODE_TEST_OK) { // test OK hts_log_print(opt, LOG_INFO, "Test OK at link %s%s (from %s%s)", - urladr, urlfil, liens[liens[ptr]->precedent]->adr, - liens[liens[ptr]->precedent]->fil); + urladr(), urlfil(), heap(heap(ptr)->precedent)->adr, + heap(heap(ptr)->precedent)->fil); } else { - if (strcmp(urlfil, "/robots.txt")) { // ne pas afficher d'infos sur robots.txt par défaut + if (strcmp(urlfil(), "/robots.txt")) { // ne pas afficher d'infos sur robots.txt par défaut hts_log_print(opt, LOG_ERROR, "\"%s\" (%d) at link %s%s (from %s%s)", r->msg, - r->statuscode, urladr, urlfil, - liens[liens[ptr]->precedent]->adr, - liens[liens[ptr]->precedent]->fil); + r->statuscode, urladr(), urlfil(), + heap(heap(ptr)->precedent)->adr, + heap(heap(ptr)->precedent)->fil); } else { hts_log_print(opt, LOG_DEBUG, "No robots.txt rules at %s", - urladr); + urladr()); } } } @@ -3850,13 +3704,13 @@ int hts_mirror_check_moved(htsmoduleStruct * str, // due to the "no connection -> previous restored" hack // This prevent the engine from wiping all data if the website has been deleted (or moved) // since last time (which is quite annoying) - if (liens[ptr]->precedent != 0) { + if (heap(ptr)->precedent != 0) { // ici on teste si on doit enregistrer la page tout de même if (opt->errpage) { store_errpage = 1; } } else { - if (strcmp(urlfil, "/robots.txt") != 0) { + if (strcmp(urlfil(), "/robots.txt") != 0) { /* This is an error caused by a link entered by the user That is, link(s) entered by user are invalid (404, 500, connect error, proxy error->.) @@ -3873,33 +3727,25 @@ int hts_mirror_check_moved(htsmoduleStruct * str, } else { // retry!! hts_log_print(opt, LOG_NOTICE, "Retry after error %d (%s) at link %s%s (from %s%s)", - r->statuscode, r->msg, urladr, urlfil, - liens[liens[ptr]->precedent]->adr, - liens[liens[ptr]->precedent]->fil); + r->statuscode, r->msg, urladr(), urlfil(), + heap(heap(ptr)->precedent)->adr, + heap(heap(ptr)->precedent)->fil); // redemander fichier - liens_record(urladr, urlfil, savename, "", ""); - if (liens[lien_tot] != NULL) { // OK, pas d'erreur - liens[lien_tot]->testmode = liens[ptr]->testmode; // mode test? - liens[lien_tot]->link_import = 0; // pas mode import - liens[lien_tot]->depth = liens[ptr]->depth; - liens[lien_tot]->pass2 = max(liens[ptr]->pass2, numero_passe); - liens[lien_tot]->retry = liens[ptr]->retry - 1; // moins 1 retry! - liens[lien_tot]->premier = liens[ptr]->premier; - liens[lien_tot]->precedent = liens[ptr]->precedent; - lien_tot++; + if (hts_record_link(opt, urladr(), urlfil(), savename(), "", "", codebase)) { + heap_top()->testmode = heap(ptr)->testmode; // mode test? + heap_top()->link_import = 0; // pas mode import + heap_top()->depth = heap(ptr)->depth; + heap_top()->pass2 = max(heap(ptr)->pass2, numero_passe); + heap_top()->retry = heap(ptr)->retry - 1; // moins 1 retry! + heap_top()->premier = heap(ptr)->premier; + heap_top()->precedent = heap(ptr)->precedent; } else { // oups erreur, plus de mémoire!! - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + 1) * sizeof(lien_url))); - //if (opt->getmode & 1) { if (fp) { fclose(fp); fp=NULL; } } - XH_uninit; // désallocation mémoire & buffers return 0; } } } else { - hts_log_print(opt, LOG_DEBUG, "Info: no robots.txt at %s%s", urladr, - urlfil); + hts_log_print(opt, LOG_DEBUG, "Info: no robots.txt at %s%s", urladr(), + urlfil()); } if (!store_errpage) { if (r->adr) { // désalloc @@ -3979,12 +3825,12 @@ void hts_mirror_process_user_interaction(htsmoduleStruct * str, HTS_STAT.stat_errors = fspc(opt, NULL, "error"); HTS_STAT.stat_warnings = fspc(opt, NULL, "warning"); HTS_STAT.stat_infos = fspc(opt, NULL, "info"); - HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr); + HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr); HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback); b = 0; if (!RUN_CALLBACK7 - (opt, loop, sback->lnk, sback->count, b, ptr, lien_tot, + (opt, loop, sback->lnk, sback->count, b, ptr, opt->lien_tot, (int) (time_local() - HTS_STAT.stat_timestart), &HTS_STAT) || !back_checkmirror(opt)) { hts_log_print(opt, LOG_ERROR, "Exit requested by shell or user"); @@ -4027,54 +3873,43 @@ void hts_mirror_process_user_interaction(htsmoduleStruct * str, // changement dans les préférences if (opt->state._hts_addurl) { - char BIGSTK add_adr[HTS_URLMAXSIZE * 2]; - char BIGSTK add_fil[HTS_URLMAXSIZE * 2]; + lien_adrfilsave add; while(*opt->state._hts_addurl) { char BIGSTK add_url[HTS_URLMAXSIZE * 2]; - add_adr[0] = add_fil[0] = add_url[0] = '\0'; + add.af.adr[0] = add.af.fil[0] = add_url[0] = '\0'; if (!link_has_authority(*opt->state._hts_addurl)) strcpybuff(add_url, "http://"); // ajouter http:// strcatbuff(add_url, *opt->state._hts_addurl); - if (ident_url_absolute(add_url, add_adr, add_fil) >= 0) { + if (ident_url_absolute(add_url, &add.af) >= 0) { // ----Ajout---- - // noter NOUVEAU lien - char BIGSTK add_sav[HTS_URLMAXSIZE * 2]; // calculer lien et éventuellement modifier addresse/fichier if (url_savename - (add_adr, add_fil, add_sav, NULL, NULL, NULL, NULL, opt, liens, - lien_tot, sback, cache, hash, ptr, numero_passe, NULL) != -1) { - if (hash_read(hash, add_sav, NULL, HASH_STRUCT_FILENAME) < 0) { // n'existe pas déja - // enregistrer lien (MACRO) - liens_record(add_adr, add_fil, add_sav, "", ""); - if (liens[lien_tot] != NULL) { // OK, pas d'erreur - liens[lien_tot]->testmode = 0; // mode test? - liens[lien_tot]->link_import = 0; // mode normal - liens[lien_tot]->depth = opt->depth; - liens[lien_tot]->pass2 = max(0, numero_passe); - liens[lien_tot]->retry = opt->retry; - liens[lien_tot]->premier = lien_tot; - liens[lien_tot]->precedent = lien_tot; - lien_tot++; + (&add, NULL, NULL, NULL, opt, sback, cache, hash, ptr, numero_passe, NULL) != -1) { + if (hash_read(hash, add.save, NULL, HASH_STRUCT_FILENAME) < 0) { // n'existe pas déja + // enregistrer lien + if (hts_record_link(opt, add.af.adr, add.af.fil, add.save, "", "", NULL)) { + heap_top()->testmode = 0; // mode test? + heap_top()->link_import = 0; // mode normal + heap_top()->depth = opt->depth; + heap_top()->pass2 = max(0, numero_passe); + heap_top()->retry = opt->retry; + heap_top()->premier = heap_top_index(); + heap_top()->precedent = heap_top_index(); // - hts_log_print(opt, LOG_INFO, "Link added by user: %s%s", add_adr, - add_fil); + hts_log_print(opt, LOG_INFO, "Link added by user: %s%s", add.af.adr, + add.af.fil); // } else { // oups erreur, plus de mémoire!! - printf("PANIC! : Not enough memory [%d]\n", __LINE__); - hts_log_print(opt, LOG_PANIC, - "Not enough memory, can not re-allocate %d bytes", - (int) ((add_tab_alloc + 1) * sizeof(lien_url))); - //if (opt->getmode & 1) { if (fp) { fclose(fp); fp=NULL; } } XH_uninit; // désallocation mémoire & buffers return; } } else { hts_log_print(opt, LOG_NOTICE, "Existing link %s%s not added after user request", - add_adr, add_fil); + add.af.adr, add.af.fil); } } @@ -4091,7 +3926,7 @@ void hts_mirror_process_user_interaction(htsmoduleStruct * str, if (opt->state._hts_setpause || back_pluggable_sockets_strict(sback, opt) <= 0) { // index du lien actuel - int b = back_index(opt, sback, urladr, urlfil, savename); + int b = back_index(opt, sback, urladr(), urlfil(), savename()); int prev = opt->state._hts_in_html_parsing; if (b < 0) @@ -4108,11 +3943,11 @@ void hts_mirror_process_user_interaction(htsmoduleStruct * str, HTS_STAT.stat_errors = fspc(opt, NULL, "error"); HTS_STAT.stat_warnings = fspc(opt, NULL, "warning"); HTS_STAT.stat_infos = fspc(opt, NULL, "info"); - HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr); + HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr); HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback); if (!RUN_CALLBACK7 - (opt, loop, sback->lnk, sback->count, b, ptr, lien_tot, + (opt, loop, sback->lnk, sback->count, b, ptr, opt->lien_tot, (int) (time_local() - HTS_STAT.stat_timestart), &HTS_STAT)) { hts_log_print(opt, LOG_ERROR, "Exit requested by shell or user"); *stre->exit_xh_ = 1; // exit requested @@ -4139,9 +3974,9 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, int n; /* This is not supposed to hapen. */ - if (liens[ptr]->pass2 == -1) { - hts_log_print(opt, LOG_WARNING, "Link is already ready %s%s", urladr, - urlfil); + if (heap(ptr)->pass2 == -1) { + hts_log_print(opt, LOG_WARNING, "Link is already ready %s%s", urladr(), + urlfil()); } /* User interaction */ @@ -4152,27 +3987,27 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, ENGINE_SET_CONTEXT(); /* Done while processing user interactions ? */ - if (liens[ptr]->pass2 == -1) { - hts_log_print(opt, LOG_DEBUG, "Link is now ready %s%s", urladr, urlfil); + if (heap(ptr)->pass2 == -1) { + hts_log_print(opt, LOG_DEBUG, "Link is now ready %s%s", urladr(), urlfil()); // We are ready return 2; // goto jump_if_done; } // si le fichier n'est pas en backing, le mettre.. - if (!back_exist(str->sback, str->opt, urladr, urlfil, savename)) { + if (!back_exist(str->sback, str->opt, urladr(), urlfil(), savename())) { #if BDEBUG==1 - printf("crash backing: %s%s\n", liens[ptr]->adr, liens[ptr]->fil); + printf("crash backing: %s%s\n", heap(ptr)->adr, heap(ptr)->fil); #endif if (back_add - (sback, opt, cache, urladr, urlfil, savename, - liens[liens[ptr]->precedent]->adr, liens[liens[ptr]->precedent]->fil, - liens[ptr]->testmode) == -1) { + (sback, opt, cache, urladr(), urlfil(), savename(), + heap(heap(ptr)->precedent)->adr, heap(heap(ptr)->precedent)->fil, + heap(ptr)->testmode) == -1) { printf("PANIC! : Crash adding error, unexpected error found.. [%d]\n", __LINE__); #if BDEBUG==1 printf("error while crash adding\n"); #endif - hts_log_print(opt, LOG_ERROR, "Unexpected backing error for %s%s", urladr, - urlfil); + hts_log_print(opt, LOG_ERROR, "Unexpected backing error for %s%s", urladr(), + urlfil()); } } @@ -4188,7 +4023,7 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, if ((n > 0) && (!opt->state._hts_setpause)) { // si sockets libre et pas en pause, ajouter // remplir autant que l'on peut le cache (backing) - back_fillmax(sback, opt, cache, liens, ptr, numero_passe, lien_tot); + back_fillmax(sback, opt, cache, ptr, numero_passe); } // index du lien actuel { @@ -4203,7 +4038,7 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, ENGINE_SET_CONTEXT(); // index du lien actuel - b = back_index(opt, sback, urladr, urlfil, savename); + b = back_index(opt, sback, urladr(), urlfil(), savename()); #if BDEBUG==1 printf("back index %d, waiting\n", b); #endif @@ -4216,7 +4051,7 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, back_wait(sback, opt, cache, HTS_STAT.stat_timestart); // Continue to the loop if link still present - b = back_index(opt, sback, urladr, urlfil, savename); + b = back_index(opt, sback, urladr(), urlfil(), savename()); if (b < 0) break; @@ -4229,10 +4064,10 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, } // And fill the backing stack if (back[b].status > 0) - back_fillmax(sback, opt, cache, liens, ptr, numero_passe, lien_tot); + back_fillmax(sback, opt, cache, ptr, numero_passe); // Continue to the loop if link still present - b = back_index(opt, sback, urladr, urlfil, savename); + b = back_index(opt, sback, urladr(), urlfil(), savename()); if (b < 0) break; @@ -4248,10 +4083,10 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, (int) ((HTS_STAT.HTS_TOTAL_RECV - *stre->makestat_total_) / (l - makestat_time)), (LLint) HTS_STAT.HTS_TOTAL_RECV, - (int) lien_tot - *stre->makestat_lnk_, (int) lien_tot); + (int) opt->lien_tot - *stre->makestat_lnk_, (int) opt->lien_tot); fflush(makestat_fp); *stre->makestat_total_ = HTS_STAT.HTS_TOTAL_RECV; - *stre->makestat_lnk_ = lien_tot; + *stre->makestat_lnk_ = heap_top_index(); } if (stre->maketrack_fp != NULL) { int i; @@ -4308,11 +4143,11 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, HTS_STAT.stat_errors = fspc(opt, NULL, "error"); HTS_STAT.stat_warnings = fspc(opt, NULL, "warning"); HTS_STAT.stat_infos = fspc(opt, NULL, "info"); - HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr); + HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr); HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback); if (!RUN_CALLBACK7 - (opt, loop, sback->lnk, sback->count, b, ptr, lien_tot, + (opt, loop, sback->lnk, sback->count, b, ptr, opt->lien_tot, (int) (time_local() - HTS_STAT.stat_timestart), &HTS_STAT)) { hts_log_print(opt, LOG_ERROR, "Exit requested by shell or user"); *stre->exit_xh_ = 1; // exit requested @@ -4377,7 +4212,7 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, (int) (HTS_STAT.HTS_TOTAL_RECV / (tl - HTS_STAT.stat_timestart))); fprintf(fp, "SOCKET %d" LF, back_nsoc(sback)); - fprintf(fp, "LINK %d" LF, lien_tot); + fprintf(fp, "LINK %d" LF, opt->lien_tot); { LLint mem = 0; @@ -4410,7 +4245,7 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, if (b < 0) { hts_log_print(opt, LOG_DEBUG, "link #%d is ready, no more on the stack, skipping: %s%s..", - ptr, urladr, urlfil); + ptr, urladr(), urlfil()); // prochain lien // ptr++; @@ -4451,10 +4286,10 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, } else if (opt->verbosedisplay == 1) { if (b >= 0) { if (back[b].r.statuscode == HTTP_OK) - printf("%d/%d: %s%s (" LLintP " bytes) - OK\33[K\r", ptr, lien_tot, + printf("%d/%d: %s%s (" LLintP " bytes) - OK\33[K\r", ptr, opt->lien_tot, back[b].url_adr, back[b].url_fil, (LLint) back[b].r.size); else - printf("%d/%d: %s%s (" LLintP " bytes) - %d\33[K\r", ptr, lien_tot, + printf("%d/%d: %s%s (" LLintP " bytes) - %d\33[K\r", ptr, opt->lien_tot, back[b].url_adr, back[b].url_fil, (LLint) back[b].r.size, back[b].r.statuscode); } else { @@ -4528,9 +4363,9 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, } /* Wait for delayed types */ -int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, - char *parent_adr, char *parent_fil, char *former_adr, - char *former_fil, int *forbidden_url) { +int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs, + char *parent_adr, char *parent_fil, lien_adrfil *former, + int *forbidden_url) { ENGINE_LOAD_CONTEXT_BASE(); hash_struct *const hash = hashptr; @@ -4539,17 +4374,17 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, char in_error_msg[32]; // resolve unresolved type - if (opt->savename_delayed != 0 && *forbidden_url == 0 && IS_DELAYED_EXT(save) + if (opt->savename_delayed != 0 && *forbidden_url == 0 && IS_DELAYED_EXT(afs->save) && !opt->state.stop) { int loops; int continue_loop; - hts_log_print(opt, LOG_DEBUG, "Waiting for type to be known: %s%s", adr, - fil); + hts_log_print(opt, LOG_DEBUG, "Waiting for type to be known: %s%s", afs->af.adr, + afs->af.fil); /* Follow while type is unknown and redirects occurs */ for(loops = 0, continue_loop = 1; - IS_DELAYED_EXT(save) && continue_loop && loops < 7; loops++) { + IS_DELAYED_EXT(afs->save) && continue_loop && loops < 7; loops++) { continue_loop = 0; /* @@ -4562,23 +4397,22 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, lien_back back; memset(&back, 0, sizeof(back)); - back.r = cache_read(opt, cache, adr, fil, NULL, NULL); // test uniquement + back.r = cache_read(opt, cache, afs->af.adr, afs->af.fil, NULL, NULL); // test uniquement if (back.r.statuscode == HTTP_OK && strnotempty(back.r.contenttype)) { // cache found, and aswer is 'OK' hts_log_print(opt, LOG_DEBUG, "Direct type lookup in cache (-%%D1): %s", back.r.contenttype); /* Recompute filename with MIME type */ - save[0] = '\0'; - url_savename(adr, fil, save, former_adr, former_fil, liens[ptr]->adr, - liens[ptr]->fil, opt, liens, lien_tot, sback, cache, + afs->save[0] = '\0'; + url_savename(afs, former, heap(ptr)->adr, + heap(ptr)->fil, opt, sback, cache, hash, ptr, numero_passe, &back); /* Recompute authorization with MIME type */ { int new_forbidden_url = - hts_acceptmime(opt, ptr, lien_tot, liens, adr, fil, - back.r.contenttype); + hts_acceptmime(opt, ptr, afs->af.adr, afs->af.fil, back.r.contenttype); if (new_forbidden_url != -1) { hts_log_print(opt, LOG_DEBUG, "result for wizard mime test: %d", new_forbidden_url); @@ -4586,7 +4420,7 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, *forbidden_url = new_forbidden_url; hts_log_print(opt, LOG_DEBUG, "link forbidden because of MIME types restrictions: %s%s", - adr, fil); + afs->af.adr, afs->af.fil); break; // exit loop } } @@ -4598,11 +4432,11 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, } /* Check if the file was recorded already (necessary for redirects) */ - if (hash_read(hash, save, NULL, HASH_STRUCT_FILENAME) >= 0) { + if (hash_read(hash, afs->save, NULL, HASH_STRUCT_FILENAME) >= 0) { if (loops == 0) { /* Should not happend */ hts_log_print(opt, LOG_ERROR, "Duplicate entry in hts_wait_delayed() cancelled: %s%s -> %s", - adr, fil, save); + afs->af.adr, afs->af.fil, afs->save); } /* Exit loop (we're done) */ continue_loop = 0; @@ -4611,11 +4445,11 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, /* Add in backing (back_index() will respond correctly) */ if (back_add_if_not_exists - (sback, opt, cache, adr, fil, save, parent_adr, parent_fil, + (sback, opt, cache, afs->af.adr, afs->af.fil, afs->save, parent_adr, parent_fil, 0) != -1) { int b; - b = back_index(opt, sback, adr, fil, save); + b = back_index(opt, sback, afs->af.adr, afs->af.fil, afs->save); if (b < 0) { printf("PANIC! : Crash adding error, unexpected error found.. [%d]\n", __LINE__); @@ -4643,16 +4477,15 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, b = -1; /* Recompute filename with MIME type */ - save[0] = '\0'; - url_savename(adr, fil, save, former_adr, former_fil, liens[ptr]->adr, - liens[ptr]->fil, opt, liens, lien_tot, sback, cache, + afs->save[0] = '\0'; + url_savename(afs, former, heap(ptr)->adr, + heap(ptr)->fil, opt, sback, cache, hash, ptr, numero_passe, &delayed_back); /* Recompute authorization with MIME type */ { int new_forbidden_url = - hts_acceptmime(opt, ptr, lien_tot, liens, adr, fil, - delayed_back.r.contenttype); + hts_acceptmime(opt, ptr, afs->af.adr, afs->af.fil, delayed_back.r.contenttype); if (new_forbidden_url != -1) { hts_log_print(opt, LOG_DEBUG, "result for wizard mime test: %d", *forbidden_url); @@ -4660,7 +4493,7 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, *forbidden_url = new_forbidden_url; hts_log_print(opt, LOG_DEBUG, "link forbidden because of MIME types restrictions: %s%s", - adr, fil); + afs->af.adr, afs->af.fil); break; // exit loop } } @@ -4668,9 +4501,9 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, /* Re-Add wiht correct type */ if (back_add_if_not_exists - (sback, opt, cache, adr, fil, save, parent_adr, parent_fil, + (sback, opt, cache, afs->af.adr, afs->af.fil, afs->save, parent_adr, parent_fil, 0) != -1) { - b = back_index(opt, sback, adr, fil, save); + b = back_index(opt, sback, afs->af.adr, afs->af.fil, afs->save); } if (b < 0) { printf @@ -4701,7 +4534,7 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, back_wait(sback, opt, cache, 0); } if (ptr >= 0) { - back_fillmax(sback, opt, cache, liens, ptr, numero_passe, lien_tot); + back_fillmax(sback, opt, cache, ptr, numero_passe); } // on est obligé d'appeler le shell pour le refresh.. { @@ -4714,11 +4547,11 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, HTS_STAT.stat_errors = fspc(opt, NULL, "error"); HTS_STAT.stat_warnings = fspc(opt, NULL, "warning"); HTS_STAT.stat_infos = fspc(opt, NULL, "info"); - HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr); + HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr); HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback); if (!RUN_CALLBACK7 - (opt, loop, sback->lnk, sback->count, b, ptr, lien_tot, + (opt, loop, sback->lnk, sback->count, b, ptr, opt->lien_tot, (int) (time_local() - HTS_STAT.stat_timestart), &HTS_STAT)) { return -1; } else if (opt->state._hts_cancel || !back_checkmirror(opt)) { // cancel 2 ou 1 (cancel parsing) @@ -4779,36 +4612,35 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, /* Handle redirect */ if ((int) strnotempty(mov_url)) { // location existe! - char BIGSTK mov_adr[HTS_URLMAXSIZE * 2], - mov_fil[HTS_URLMAXSIZE * 2]; - mov_adr[0] = mov_fil[0] = '\0'; + lien_adrfil moved; + moved.adr[0] = moved.fil[0] = '\0'; // - if (ident_url_relatif(mov_url, adr, fil, mov_adr, mov_fil) >= 0) { + if (ident_url_relatif(mov_url, afs->af.adr, afs->af.fil, &moved) >= 0) { hts_log_print(opt, LOG_DEBUG, "Redirect while resolving type: %s%s -> %s%s", - adr, fil, mov_adr, mov_fil); + afs->af.adr, afs->af.fil, moved.adr, moved.fil); // si non bouclage sur soi même, ou si test avec GET non testé - if (strcmp(mov_adr, adr) != 0 || strcmp(mov_fil, fil) != 0) { + if (strcmp(moved.adr, afs->af.adr) != 0 || strcmp(moved.fil, afs->af.fil) != 0) { - // recopier former_adr/fil? - if ((former_adr) && (former_fil)) { - if (strnotempty(former_adr) == 0) { // Pas déja noté - strcpybuff(former_adr, adr); - strcpybuff(former_fil, fil); + // recopier former->adr/fil? + if (former != NULL) { + if (strnotempty(former->adr) == 0) { // Pas déja noté + strcpybuff(former->adr, afs->af.adr); + strcpybuff(former->fil, afs->af.fil); } } // check explicit forbidden - don't follow 3xx in this case { int set_prio_to = 0; - if (hts_acceptlink(opt, ptr, lien_tot, liens, mov_adr, mov_fil, NULL, NULL, &set_prio_to, NULL) == 1) { /* forbidden */ + if (hts_acceptlink(opt, ptr, moved.adr, moved.fil, NULL, NULL, &set_prio_to, NULL) == 1) { /* forbidden */ /* Note: the cache 'cached_tests' system will remember this error, and we'll only issue ONE request */ *forbidden_url = 1; /* Forbidden! */ hts_log_print(opt, LOG_DEBUG, "link forbidden because of redirect beyond the mirror scope at %s%s -> %s%s", - adr, fil, mov_adr, mov_fil); - strcpybuff(adr, mov_adr); - strcpybuff(fil, mov_fil); + afs->af.adr, afs->af.fil, moved.adr, moved.fil); + strcpybuff(afs->af.adr, moved.adr); + strcpybuff(afs->af.fil, moved.fil); mov_url[0] = '\0'; break; } @@ -4816,46 +4648,44 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, // ftp: stop! if (strfield(mov_url, "ftp://")) { - strcpybuff(adr, mov_adr); - strcpybuff(fil, mov_fil); + strcpybuff(afs->af.adr, moved.adr); + strcpybuff(afs->af.fil, moved.fil); break; } /* ok, continue */ - strcpybuff(adr, mov_adr); - strcpybuff(fil, mov_fil); + strcpybuff(afs->af.adr, moved.adr); + strcpybuff(afs->af.fil, moved.fil); continue_loop = 1; /* Recompute filename for hash lookup */ - save[0] = '\0'; - url_savename(adr, fil, save, former_adr, former_fil, - liens[ptr]->adr, liens[ptr]->fil, opt, liens, - lien_tot, sback, cache, hash, ptr, numero_passe, + afs->save[0] = '\0'; + url_savename(afs, former, heap(ptr)->adr, heap(ptr)->fil, + opt, sback, cache, hash, ptr, numero_passe, &delayed_back); } else { hts_log_print(opt, LOG_WARNING, "Unable to test %s%s (loop to same filename)", - adr, fil); + afs->af.adr, afs->af.fil); } // loop to same location } // ident_url_relatif() } // location } // redirect - hts_log_print(opt, LOG_DEBUG, "Final type for %s%s: '%s'", adr, fil, + hts_log_print(opt, LOG_DEBUG, "Final type for %s%s: '%s'", afs->af.adr, afs->af.fil, delayed_back.r.contenttype); /* If we are done, do additional checks with final type and authorizations */ if (!continue_loop) { /* Recompute filename with MIME type */ - save[0] = '\0'; - url_savename(adr, fil, save, former_adr, former_fil, - liens[ptr]->adr, liens[ptr]->fil, opt, liens, lien_tot, + afs->save[0] = '\0'; + url_savename(afs, former, + heap(ptr)->adr, heap(ptr)->fil, opt, sback, cache, hash, ptr, numero_passe, &delayed_back); /* Recompute authorization with MIME type */ { int new_forbidden_url = - hts_acceptmime(opt, ptr, lien_tot, liens, adr, fil, - delayed_back.r.contenttype); + hts_acceptmime(opt, ptr, afs->af.adr, afs->af.fil, delayed_back.r.contenttype); if (new_forbidden_url != -1) { hts_log_print(opt, LOG_DEBUG, "result for wizard mime test: %d", *forbidden_url); @@ -4863,7 +4693,7 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, *forbidden_url = new_forbidden_url; hts_log_print(opt, LOG_DEBUG, "link forbidden because of MIME types restrictions: %s%s", - adr, fil); + afs->af.adr, afs->af.fil); break; // exit loop } } @@ -4880,7 +4710,7 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, } } /* Patch destination filename for direct-to-disk mode */ - strcpybuff(back[b].url_sav, save); + strcpybuff(back[b].url_sav, afs->save); } } // b >= 0 @@ -4907,25 +4737,25 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, if (in_error == STATUSCODE_TOO_BIG) { hts_log_print(opt, LOG_INFO, "link not taken because of its size (%d bytes) at %s%s", - (int) in_error_size, adr, fil); + (int) in_error_size, afs->af.adr, afs->af.fil); } else { hts_log_print(opt, LOG_INFO, "link not taken because of error (%d '%s') at %s%s", - in_error, in_error_msg, adr, fil); + in_error, in_error_msg, afs->af.adr, afs->af.fil); } } } // error - if (*forbidden_url != 1 && IS_DELAYED_EXT(save)) { + if (*forbidden_url != 1 && IS_DELAYED_EXT(afs->save)) { *forbidden_url = 1; if (in_error) { hts_log_print(opt, LOG_WARNING, "link in error (%d '%s'), type unknown, aborting: %s%s", - in_error, in_error_msg, adr, fil); + in_error, in_error_msg, afs->af.adr, afs->af.fil); } else { hts_log_print(opt, LOG_WARNING, "link is probably looping, type unknown, aborting: %s%s", - adr, fil); + afs->af.adr, afs->af.fil); } } diff --git a/src/htsparse.h b/src/htsparse.h index 9a8e649..01eb953 100644 --- a/src/htsparse.h +++ b/src/htsparse.h @@ -66,7 +66,7 @@ struct htsmoduleStructExtended { char ***filters_; robots_wizard *robots_; hash_struct *hash_; - int *lien_max_; + //int *lien_max_; /* Base & codebase */ char *base; @@ -135,14 +135,13 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str, to be ready for naming, having its header MIME type If the final URL is to be forbidden, sets 'forbidden_url' to the corresponding value */ -int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, - char *parent_adr, char *parent_fil, char *former_adr, - char *former_fil, int *forbidden_url); +int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs, + char *parent_adr, char *parent_fil, lien_adrfil *former, + int *forbidden_url); /* Context state */ #define ENGINE_DEFINE_CONTEXT_BASE() \ - lien_url** const liens HTS_UNUSED = (lien_url**) str->liens; \ httrackp* const opt HTS_UNUSED = (httrackp*) str->opt; \ struct_back* const sback HTS_UNUSED = (struct_back*) str->sback; \ lien_back* const back HTS_UNUSED = sback->lnk; \ @@ -150,28 +149,18 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, cache_back* const cache HTS_UNUSED = (cache_back*) str->cache; \ hash_struct* const hashptr HTS_UNUSED = (hash_struct*) str->hashptr; \ const int numero_passe HTS_UNUSED = str->numero_passe; \ - const int add_tab_alloc HTS_UNUSED = str->add_tab_alloc; \ /* variable */ \ - int lien_tot = *str->lien_tot_; \ - int ptr = *str->ptr_; \ - size_t lien_size = *str->lien_size_; \ - char* lien_buffer = *str->lien_buffer_ + int ptr = *str->ptr_ #define ENGINE_SET_CONTEXT_BASE() \ - lien_tot = *str->lien_tot_; \ - ptr = *str->ptr_; \ - lien_size = *str->lien_size_; \ - lien_buffer = *str->lien_buffer_ + ptr = *str->ptr_ #define ENGINE_LOAD_CONTEXT_BASE() \ ENGINE_DEFINE_CONTEXT_BASE() #define ENGINE_SAVE_CONTEXT_BASE() \ /* Apply changes */ \ - * str->lien_tot_ = lien_tot; \ - * str->ptr_ = ptr; \ - * str->lien_size_ = lien_size; \ - * str->lien_buffer_ = lien_buffer + * str->ptr_ = ptr #define WAIT_FOR_AVAILABLE_SOCKET() do { \ int prev = opt->state._hts_in_html_parsing; \ @@ -186,10 +175,10 @@ int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save, HTS_STAT.stat_errors=fspc(opt,NULL,"error"); \ HTS_STAT.stat_warnings=fspc(opt,NULL,"warning"); \ HTS_STAT.stat_infos=fspc(opt,NULL,"info"); \ - HTS_STAT.nbk=backlinks_done(sback,liens,lien_tot,ptr); \ + HTS_STAT.nbk=backlinks_done(sback,opt->liens,opt->lien_tot,ptr); \ HTS_STAT.nb=back_transferred(HTS_STAT.stat_bytes,sback); \ /* Check */ \ - if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, -1,ptr,lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \ + if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, -1,ptr,opt->lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \ return -1; \ } \ } \ diff --git a/src/htsrobots.c b/src/htsrobots.c index 0b70257..e7656b3 100644 --- a/src/htsrobots.c +++ b/src/htsrobots.c @@ -45,7 +45,7 @@ Please visit our Website: http://www.httrack.com // -- robots -- // fil="" : vérifier si règle déja enregistrée -int checkrobots(robots_wizard * robots, char *adr, char *fil) { +int checkrobots(robots_wizard * robots, const char *adr, const char *fil) { while(robots) { if (strfield2(robots->adr, adr)) { if (fil[0]) { @@ -60,7 +60,7 @@ int checkrobots(robots_wizard * robots, char *adr, char *fil) { return -1; // interdit } } else { // relatif - if (strstrcase(fil, line)) { + if (strstrcase((char*) fil, line)) { return -1; } } @@ -74,7 +74,7 @@ int checkrobots(robots_wizard * robots, char *adr, char *fil) { } return 0; } -int checkrobots_set(robots_wizard * robots, char *adr, char *data) { +int checkrobots_set(robots_wizard * robots, const char *adr, const char *data) { if (((int) strlen(adr)) >= sizeof(robots->adr) - 2) return 0; if (((int) strlen(data)) >= sizeof(robots->token) - 2) diff --git a/src/htsrobots.h b/src/htsrobots.h index 8fcc1c6..9160372 100644 --- a/src/htsrobots.h +++ b/src/htsrobots.h @@ -47,9 +47,9 @@ struct robots_wizard { /* Library internal definictions */ #ifdef HTS_INTERNAL_BYTECODE -int checkrobots(robots_wizard * robots, char *adr, char *fil); +int checkrobots(robots_wizard * robots, const char *adr, const char *fil); void checkrobots_free(robots_wizard * robots); -int checkrobots_set(robots_wizard * robots, char *adr, char *data); +int checkrobots_set(robots_wizard * robots, const char *adr, const char *data); #endif #endif diff --git a/src/htssafe.h b/src/htssafe.h index 004b068..cde0ad1 100644 --- a/src/htssafe.h +++ b/src/htssafe.h @@ -33,19 +33,38 @@ Please visit our Website: http://www.httrack.com #ifndef HTSSAFE_DEFH #define HTSSAFE_DEFH +#include +#include +#include + #include "htsglobal.h" -/** - * Optional user-defined callback upon fatal error. - */ -typedef void (*htsErrorCallback) (const char *msg, const char *file, int line); - /** * Emergency logging. + * Default is to use libhttrack one. */ #ifndef HTSSAFE_ABORT_FUNCTION -HTSEXT_API htsErrorCallback htsCallbackErr; -#define HTSSAFE_ABORT_FUNCTION(A,B,C) do { if (htsCallbackErr != NULL) { htsCallbackErr(A,B,C); } } while(0) + +/** Assert error callback. **/ +#ifndef HTS_DEF_FWSTRUCT_htsErrorCallback +#define HTS_DEF_FWSTRUCT_htsErrorCallback +typedef void (*htsErrorCallback) (const char *msg, const char *file, int line); +#ifdef __cplusplus +extern "C" { +#endif +HTSEXT_API htsErrorCallback hts_get_error_callback(void); +#ifdef __cplusplus +} +#endif +#endif + +#define HTSSAFE_ABORT_FUNCTION(A,B,C) do { \ + htsErrorCallback callback = hts_get_error_callback(); \ + if (callback != NULL) { \ + callback(A,B,C); \ + } \ +} while(0) + #endif /** @@ -61,7 +80,7 @@ HTSEXT_API htsErrorCallback htsCallbackErr; /** * Fatal assertion check. */ -#define assertf_(exp, file, line) assertf__(exp, #exp, __FILE__, __LINE__) +#define assertf_(exp, file, line) assertf__(exp, #exp, file, line) /** * Fatal assertion check. @@ -82,7 +101,7 @@ static HTS_UNUSED void abortf_(const char *exp, const char *file, int line) { /** * Check wether 'VAR' is of type char[]. */ -#ifdef __GNUC__ +#if (defined(__GNUC__) && !defined(__cplusplus)) /* Note: char[] and const char[] are compatible */ #define HTS_IS_CHAR_BUFFER(VAR) ( __builtin_types_compatible_p ( typeof (VAR), char[] ) ) #else @@ -91,6 +110,17 @@ static HTS_UNUSED void abortf_(const char *exp, const char *file, int line) { #endif #define HTS_IS_NOT_CHAR_BUFFER(VAR) ( ! HTS_IS_CHAR_BUFFER(VAR) ) +/* Compile-time checks. */ +static HTS_UNUSED void htssafe_compile_time_check_(void) { + char array[32]; + char *pointer = array; + char check_array[HTS_IS_CHAR_BUFFER(array) ? 1 : -1]; + char check_pointer[HTS_IS_CHAR_BUFFER(pointer) ? -1 : 1]; + (void) pointer; + (void) check_array; + (void) check_pointer; +} + /** * Append at most N characters from "B" to "A". * If "A" is a char[] variable whose size is not sizeof(char*), then the size @@ -130,13 +160,22 @@ static HTS_UNUSED void abortf_(const char *exp, const char *file, int line) { #define strlcatbuff(A, B, S) \ strncat_safe_(A, S, B, \ HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(B), (size_t) -1, \ + "overflow while appending '" #B "' to '"#A"'", __FILE__, __LINE__) + +/** + * Copy characters of "B" to "A", "A" having a maximum capacity of "S". + */ +#define strlcpybuff(A, B, S) \ + strcpy_safe_(A, S, B, \ + HTS_IS_NOT_CHAR_BUFFER(B) ? (size_t) -1 : sizeof(B), \ "overflow while copying '" #B "' to '"#A"'", __FILE__, __LINE__) static HTS_INLINE HTS_UNUSED size_t strlen_safe_(const char *source, const size_t sizeof_source, const char *file, int line) { size_t size; assertf_( source != NULL, file, line ); - size = strnlen(source, sizeof_source); + size = sizeof_source != (size_t) -1 + ? strnlen(source, sizeof_source) : strlen(source); assertf_( size < sizeof_source, file, line ); return size; } diff --git a/src/htsserver.c b/src/htsserver.c index 65329f3..401f131 100644 --- a/src/htsserver.c +++ b/src/htsserver.c @@ -81,7 +81,7 @@ inthash NewLangList = NULL; #include "htsserver.h" -char *gethomedir(void); +const char *gethomedir(void); int commandRunning = 0; int commandEndRequested = 0; int commandEnd = 0; @@ -97,13 +97,13 @@ extern void webhttrack_main(char *cmd); extern void webhttrack_lock(void); extern void webhttrack_release(void); -static int is_image(char *file) { +static int is_image(const char *file) { return ((strstr(file, ".gif") != NULL)); } -static int is_text(char *file) { +static int is_text(const char *file) { return ((strstr(file, ".txt") != NULL)); } -static int is_html(char *file) { +static int is_html(const char *file) { return ((strstr(file, ".htm") != NULL)); } @@ -119,16 +119,16 @@ HTS_UNUSED static int linputsoc_t(T_SOC soc, char *s, int max, int timeout); HTS_UNUSED static int linput(FILE * fp, char *s, int max); /* Language files */ -HTS_UNUSED static int htslang_load(char *limit_to, char *apppath); -HTS_UNUSED static void conv_printf(char *from, char *to); +HTS_UNUSED static int htslang_load(char *limit_to, const char *apppath); +HTS_UNUSED static void conv_printf(const char *from, char *to); HTS_UNUSED static void LANG_DELETE(void); -HTS_UNUSED static void LANG_INIT(char *path); -HTS_UNUSED static int LANG_T(char *path, int l); +HTS_UNUSED static void LANG_INIT(const char *path); +HTS_UNUSED static int LANG_T(const char *path, int l); HTS_UNUSED static int QLANG_T(int l); -HTS_UNUSED static char *LANGSEL(char *name); -HTS_UNUSED static char *LANGINTKEY(char *name); -HTS_UNUSED static int LANG_SEARCH(char *path, char *iso); -HTS_UNUSED static int LANG_LIST(char *path, char *buffer); +HTS_UNUSED static const char *LANGSEL(const char *name); +HTS_UNUSED static const char *LANGINTKEY(const char *name); +HTS_UNUSED static int LANG_SEARCH(const char *path, const char *iso); +HTS_UNUSED static int LANG_LIST(const char *path, char *buffer, size_t size); // URL Link catcher @@ -162,16 +162,15 @@ T_SOC smallserver_init_std(int *port_prox, char *adr_prox, int defaultPort) { // 1- Init the URL catcher // get hostname. return 1 upon success. -static int gethost(const char *hostname, SOCaddr * server, size_t server_size) { +static int gethost(const char *hostname, SOCaddr * server) { if (hostname != NULL && *hostname != '\0') { #if HTS_INET6==0 /* ipV4 resolver */ - t_hostent *hp = gethostbyname(hostname); + struct hostent *hp = gethostbyname(hostname); if (hp != NULL) { if (hp->h_length) { - SOCaddr_copyaddr(*server, server_size, hp->h_addr_list[0], - hp->h_length); + SOCaddr_copyaddr2(*server, hp->h_addr_list[0], hp->h_length); return 1; } } @@ -187,7 +186,7 @@ static int gethost(const char *hostname, SOCaddr * server, size_t server_size) { if (getaddrinfo(hostname, NULL, &hints, &res) == 0) { if (res) { if ((res->ai_addr) && (res->ai_addrlen)) { - SOCaddr_copyaddr(*server, server_size, res->ai_addr, res->ai_addrlen); + SOCaddr_copyaddr2(*server, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); return 1; } @@ -204,7 +203,7 @@ static int gethost(const char *hostname, SOCaddr * server, size_t server_size) { static int my_getlocalhost(char *h_loc, size_t size) { SOCaddr addr; strcpy(h_loc, "localhost"); - if (gethost(h_loc, &addr, sizeof(addr)) == 1) { + if (gethost(h_loc, &addr) == 1) { return 0; } // come on ... @@ -220,7 +219,7 @@ static int my_gethostname(char *h_loc, size_t size) { h_loc[0] = '\0'; if (gethostname(h_loc, (int) size) == 0) { // host name SOCaddr addr; - if (gethost(h_loc, &addr, sizeof(addr)) == 1) { + if (gethost(h_loc, &addr) == 1) { return 0; } else { return my_getlocalhost(h_loc, size); @@ -247,54 +246,16 @@ T_SOC smallserver_init(int *port, char *adr) { if (my_gethostname(h_loc, 256) == 0) { // host name SOCaddr server; - int server_size = sizeof(server); - - /*t_hostent* hp_loc; - t_fullhostent buffer; */ - - // effacer structure - memset(&server, 0, sizeof(server)); - - /*if ( (hp_loc=vxgethostbyname(h_loc, &buffer)) ) */ - { - // copie adresse - // NO (bind all) - // SOCaddr_copyaddr(server, server_size, hp_loc->h_addr_list[0], hp_loc->h_length); - - SOCaddr_initany(server, server_size); - if ((soc = - (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, - 0)) != INVALID_SOCKET) { - SOCaddr_initport(server, *port); - if (bind(soc, (struct sockaddr *) &server, server_size) == 0) { - /*SOClen len; - SOCaddr server2; - len=sizeof(server2); */ - // effacer structure - /*memset(&server2, 0, sizeof(server2)); - if (getsockname(soc,(struct sockaddr*) &server2,&len) == 0) { - *port=ntohs(SOCaddr_sinport(server)); // récupérer port */ - if (listen(soc, 10) >= 0) { // au pif le 10 - // SOCaddr_inetntoa(adr, 128, server2, len); - strcpy(adr, h_loc); - } else { -#ifdef _WIN32 - closesocket(soc); -#else - close(soc); -#endif - soc = INVALID_SOCKET; - } - - /*} else { - #ifdef _WIN32 - closesocket(soc); - #else - close(soc); - #endif - soc=INVALID_SOCKET; - } */ + SOCaddr_initany(server); + if ((soc = + (T_SOC) socket(SOCaddr_sinfamily(server), SOCK_STREAM, + 0)) != INVALID_SOCKET) { + SOCaddr_initport(server, *port); + if (bind(soc, &SOCaddr_sockaddr(server), SOCaddr_size(server)) == 0) { + if (listen(soc, 10) >= 0) { + // SOCaddr_inetntoa(adr, 128, server2); + strcpy(adr, h_loc); } else { #ifdef _WIN32 closesocket(soc); @@ -303,6 +264,13 @@ T_SOC smallserver_init(int *port, char *adr) { #endif soc = INVALID_SOCKET; } + } else { +#ifdef _WIN32 + closesocket(soc); +#else + close(soc); +#endif + soc = INVALID_SOCKET; } } } @@ -319,12 +287,12 @@ T_SOC smallserver_init(int *port, char *adr) { // data: 32Kb typedef struct { - char *name; + const char *name; int value; } initIntElt; typedef struct { - char *name; - char *value; + const char *name; + const char *value; } initStrElt; #define SET_ERROR(err) do { \ @@ -358,10 +326,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { { char pth[1024]; - char *initOn[] = { "parseall", "Cache", "ka", + const char *initOn[] = { "parseall", "Cache", "ka", "cookies", "parsejava", "testall", "updhack", "urlhack", "index", NULL }; - initIntElt initInt[] = { + const initIntElt initInt[] = { {"filter", 4}, {"travel", 2}, {"travel2", 1}, @@ -415,7 +383,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { char line2[1024]; T_SOC soc_c; LLint length = 0; - char *error_redirect = NULL; + const char *error_redirect = NULL; line[0] = '\0'; buffer[0] = '\0'; @@ -530,7 +498,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { strcatbuff(buffer, "&"); while(s && (e = strchr(s, '=')) && (f = strchr(s, '&'))) { - char *ua; + const char *ua; String sua = STRING_EMPTY; *e = *f = '\0'; @@ -818,7 +786,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { if (url && *++url == '/' && (pos = strchr(url, ' ')) && !(*pos = '\0')) { char fsfile[1024]; - char *file; + const char *file; FILE *fp; char *qpos; @@ -893,10 +861,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { "HTTP/1.0 302 Redirect\r\n" "Connection: close\r\n" "Server: httrack-small-server\r\n"; intptr_t adr = 0; - char *newfile = file; + const char *newfile = file; if (inthash_readptr(NewLangList, "redirect", &adr) && adr != 0) { - char *newadr = (char *) adr; + const char *newadr = (char *) adr; if (*newadr) { newfile = newadr; @@ -936,7 +904,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { && (n = (pos - str)) && n < 1024) { char name_[1024 + 2]; char *name = name_; - char *langstr = NULL; + const char *langstr = NULL; int p; int format = 0; int listDefault = 0; @@ -971,6 +939,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { } } else if ((p = strfield(name, "do:"))) { char *pos2; + char empty[2] = ""; name += p; format = 1; @@ -980,7 +949,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { *pos2 = '\0'; pos2++; } else { - pos2 = ""; + pos2 = empty; } if (strcmp(name, "output-mode") == 0) { if (strcmp(pos2, "html") == 0) { @@ -1095,7 +1064,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { if (pos2 != NULL) { *pos2 = '\0'; if (inthash_readptr(NewLangList, name, &adr) || ztest) { - char *newadr = (char *) adr; + const char *newadr = (char *) adr; if (!newadr) newadr = ""; @@ -1171,8 +1140,8 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { if (langstr == NULL) { if (strfield2(name, "#iso")) { langstr = line2; - langstr[0] = '\0'; - LANG_LIST(path, langstr); + line2[0] = '\0'; + LANG_LIST(path, line2, sizeof(line2)); assertf(strlen(langstr) < sizeof(line2) - 2); } else { langstr = LANGSEL(name); @@ -1191,7 +1160,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { switch (format) { case 0: { - char *a = langstr; + const char *a = langstr; while(*a) { if (a[0] == '\\' && isxdigit(a[1]) @@ -1237,7 +1206,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) { default: if (*langstr) { int id = 1; - char *fstr = langstr; + const char *fstr = langstr; StringClear(tmpbuff); if (format == 2) { @@ -1460,24 +1429,25 @@ int htslang_uninit(void) { return 1; } -int smallserver_setkey(char *key, char *value) { +int smallserver_setkey(const char *key, const char *value) { return inthash_write(NewLangList, key, (intptr_t) strdup(value)); } -int smallserver_setkeyint(char *key, LLint value) { + +int smallserver_setkeyint(const char *key, LLint value) { char tmp[256]; - sprintf(tmp, LLintP, value); + snprintf(tmp, sizeof(tmp), LLintP, value); return inthash_write(NewLangList, key, (intptr_t) strdup(tmp)); } -int smallserver_setkeyarr(char *key, int id, char *key2, char *value) { +int smallserver_setkeyarr(const char *key, int id, const char *key2, const char *value) { char tmp[256]; - sprintf(tmp, "%s%d%s", key, id, key2); + snprintf(tmp, sizeof(tmp), "%s%d%s", key, id, key2); return inthash_write(NewLangList, tmp, (intptr_t) strdup(value)); } -static int htslang_load(char *limit_to, char *path) { - char *hashname; +static int htslang_load(char *limit_to, const char *path) { + const char *hashname; char catbuff[CATBUFF_SIZE]; // @@ -1500,7 +1470,7 @@ static int htslang_load(char *limit_to, char *path) { /* Load master file (list of keys and internal keys) */ if (!limit_to) { - char *mname = "lang.def"; + const char *mname = "lang.def"; FILE *fp = fopen(fconcat(catbuff, sizeof(catbuff), path, mname), "rb"); if (fp) { @@ -1511,7 +1481,7 @@ static int htslang_load(char *limit_to, char *path) { linput_cpp(fp, intkey, 8000); linput_cpp(fp, key, 8000); if (strnotempty(intkey) && strnotempty(key)) { - char *test = LANGINTKEY(key); + const char *test = LANGINTKEY(key); /* Increment for multiple definitions */ if (strnotempty(test)) { @@ -1527,11 +1497,9 @@ static int htslang_load(char *limit_to, char *path) { if (!strnotempty(test)) { // éviter doublons // conv_printf(key,key); - int len; - char *buff; + const size_t len = strlen(intkey); + char *const buff = (char *) malloc(len + 1); - len = (int) strlen(intkey); - buff = (char *) malloc(len + 2); if (buff) { strcpybuff(buff, intkey); inthash_add(NewLangStrKeys, key, (intptr_t) buff); @@ -1591,9 +1559,7 @@ static int htslang_load(char *limit_to, char *path) { linput_cpp(fp, extkey, 8000); linput_cpp(fp, value, 8000); if (strnotempty(extkey) && strnotempty(value)) { - int len; - char *buff; - char *intkey; + const char *intkey; intkey = LANGINTKEY(extkey); @@ -1601,7 +1567,7 @@ static int htslang_load(char *limit_to, char *path) { /* Increment for multiple definitions */ { - char *test = LANGSEL(intkey); + const char *test = LANGSEL(intkey); if (strnotempty(test)) { if (loops == 0) { @@ -1629,8 +1595,8 @@ static int htslang_load(char *limit_to, char *path) { /* Add key */ if (strnotempty(intkey)) { - len = (int) strlen(value); - buff = (char *) malloc(len + 2); + const size_t len = strlen(value); + char *const buff = (char *) malloc(len + 1); if (buff) { conv_printf(value, buff); inthash_add(NewLangStr, intkey, (intptr_t) buff); @@ -1655,7 +1621,7 @@ static int htslang_load(char *limit_to, char *path) { } /* NOTE : also contains the "webhttrack" hack */ -static void conv_printf(char *from, char *to) { +static void conv_printf(const char *from, char *to) { int i = 0, j = 0, len; len = (int) strlen(from); @@ -1729,7 +1695,7 @@ static void LANG_DELETE(void) { } // sélection de la langue -static void LANG_INIT(char *path) { +static void LANG_INIT(const char *path) { //CWinApp* pApp = AfxGetApp(); //if (pApp) { /* pApp->GetProfileInt("Language","IntId",0); */ @@ -1737,7 +1703,7 @@ static void LANG_INIT(char *path) { //} } -static int LANG_T(char *path, int l) { +static int LANG_T(const char *path, int l) { if (l >= 0) { QLANG_T(l); htslang_load(NULL, path); @@ -1745,7 +1711,7 @@ static int LANG_T(char *path, int l) { return QLANG_T(-1); // 0=default (english) } -static int LANG_SEARCH(char *path, char *iso) { +static int LANG_SEARCH(const char *path, const char *iso) { char lang_str[1024]; int i = 0; int curr_lng = LANG_T(path, -1); @@ -1764,7 +1730,7 @@ static int LANG_SEARCH(char *path, char *iso) { return found; } -static int LANG_LIST(char *path, char *buffer) { +static int LANG_LIST(const char *path, char *buffer, size_t buffer_size) { char lang_str[1024]; int i = 0; int curr_lng = LANG_T(path, -1); @@ -1772,12 +1738,12 @@ static int LANG_LIST(char *path, char *buffer) { buffer[0] = '\0'; do { QLANG_T(i); - strcpybuff(lang_str, "LANGUAGE_NAME"); + strlcpybuff(lang_str, "LANGUAGE_NAME", buffer_size); htslang_load(lang_str, path); if (strlen(lang_str) > 0) { if (buffer[0]) strcatbuff(buffer, "\n"); - strcatbuff(buffer, lang_str); + strlcatbuff(buffer, lang_str, buffer_size); } i++; } while(strlen(lang_str) > 0); @@ -1794,28 +1760,26 @@ static int QLANG_T(int l) { return lng; // 0=default (english) } -static char *LANGSEL(char *name) { - intptr_t adr = 0; - - if (NewLangStr) - if (!inthash_read(NewLangStr, name, &adr)) - adr = 0; - if (adr) { - return (char *) adr; +const char* LANGSEL(const char* name) { + inthash_value value; + if (NewLangStr != NULL + && inthash_read_value(NewLangStr, name, &value) != 0 + && value.ptr != NULL) { + return (char*) value.ptr; + } else { + return ""; } - return ""; } -static char *LANGINTKEY(char *name) { - intptr_t adr = 0; - - if (NewLangStrKeys) - if (!inthash_read(NewLangStrKeys, name, &adr)) - adr = 0; - if (adr) { - return (char *) adr; +const char* LANGINTKEY(const char* name) { + inthash_value value; + if (NewLangStrKeys != NULL + && inthash_read_value(NewLangStrKeys, name, &value) != 0 + && value.ptr != NULL) { + return (char*) value.ptr; + } else { + return ""; } - return ""; } /* *** Various functions *** */ @@ -1848,7 +1812,7 @@ static int check_readinput(htsblk * r) { FD_SET(r->soc, &fds); tv.tv_sec = 0; tv.tv_usec = 0; - select(r->soc + 1, &fds, NULL, NULL, &tv); + select((int) r->soc + 1, &fds, NULL, NULL, &tv); if (FD_ISSET(r->soc, &fds)) return 1; else diff --git a/src/htsserver.h b/src/htsserver.h index c5db213..0db7e1c 100644 --- a/src/htsserver.h +++ b/src/htsserver.h @@ -91,16 +91,16 @@ extern httrackp *global_opt; #define min(a,b) ((a)>(b)?(b):(a)) #define max(a,b) ((a)>(b)?(a):(b)) -extern int smallserver_setkey(char *key, char *value); -extern int smallserver_setkeyint(char *key, LLint value); -extern int smallserver_setkeyarr(char *key, int id, char *key2, char *value); +extern int smallserver_setkey(const char *key, const char *value); +extern int smallserver_setkeyint(const char *key, LLint value); +extern int smallserver_setkeyarr(const char *key, int id, const char *key2, const char *value); int htslang_init(void); int htslang_uninit(void); /* Static definitions */ -HTS_UNUSED static char *gethomedir(void); +HTS_UNUSED static const char *gethomedir(void); HTS_UNUSED static int linput_cpp(FILE * fp, char *s, int max); HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max); HTS_UNUSED static int fexist(const char *s); @@ -147,7 +147,7 @@ HTS_UNUSED static int check_readinput_t(T_SOC soc, int timeout) { FD_SET(soc, &fds); tv.tv_sec = timeout; tv.tv_usec = 0; - select(soc + 1, &fds, NULL, NULL, &tv); + select((int) soc + 1, &fds, NULL, NULL, &tv); if (FD_ISSET(soc, &fds)) return 1; else @@ -163,8 +163,8 @@ HTS_UNUSED static int linputsoc_t(T_SOC soc, char *s, int max, int timeout) { return -1; } -static char *gethomedir(void) { - char *home = getenv("HOME"); +static const char *gethomedir(void) { + const char *home = getenv("HOME"); if (home) return home; @@ -228,7 +228,7 @@ static int linput(FILE * fp, char *s, int max) { } static int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; - char *ls = (char *) malloc(max + 2); + char *ls = (char *) malloc(max + 1); s[0] = '\0'; if (ls) { @@ -267,11 +267,11 @@ static int ehexh(char c) { return 0; } -static int ehex(char *s) { +static int ehex(const char *s) { return 16 * ehexh(*s) + ehexh(*(s + 1)); } -HTS_UNUSED static void unescapehttp(char *s, String * tempo) { +HTS_UNUSED static void unescapehttp(const char *s, String * tempo) { size_t i; for(i = 0; s[i] != '\0'; i++) { diff --git a/src/htstools.c b/src/htstools.c index de81d57..e3c587b 100644 --- a/src/htstools.c +++ b/src/htstools.c @@ -91,11 +91,11 @@ static int ehexh(char c) { return 0; } -static int ehex(char *s) { +static int ehex(const char *s) { return 16 * ehexh(*s) + ehexh(*(s + 1)); } -static void unescapehttp(char *s, String * tempo) { +static void unescapehttp(const char *s, String * tempo) { size_t i; for(i = 0; s[i] != '\0'; i++) { @@ -122,12 +122,15 @@ static void unescapehttp(char *s, String * tempo) { // -1 : erreur // -2 : protocole non supporté (ftp) int ident_url_relatif(const char *lien, const char *origin_adr, - const char *origin_fil, char *adr, char *fil) { + const char *origin_fil, + lien_adrfil* const adrfil) { int ok = 0; int scheme = 0; - adr[0] = '\0'; - fil[0] = '\0'; //effacer buffers + assertf(adrfil != NULL); + + adrfil->adr[0] = '\0'; + adrfil->fil[0] = '\0'; //effacer buffers // lien non vide! if (strnotempty(lien) == 0) @@ -149,13 +152,13 @@ int ident_url_relatif(const char *lien, const char *origin_adr, || (strfield(lien, "file://")) // scheme+// || (strncmp(lien, "//", 2) == 0) // // sans scheme (-> default) ) { - if (ident_url_absolute(lien, adr, fil) == -1) { + if (ident_url_absolute(lien, adrfil) == -1) { ok = -1; // erreur URL } } else if (strfield(lien, "ftp://")) { // Note: ftp:foobar.gif is not valid if (ftp_available()) { // ftp supporté - if (ident_url_absolute(lien, adr, fil) == -1) { + if (ident_url_absolute(lien, adrfil) == -1) { ok = -1; // erreur URL } } else { @@ -164,7 +167,7 @@ int ident_url_relatif(const char *lien, const char *origin_adr, #if HTS_USEOPENSSL } else if (strfield(lien, "https://")) { // Note: ftp:foobar.gif is not valid - if (ident_url_absolute(lien, adr, fil) == -1) { + if (ident_url_absolute(lien, adrfil) == -1) { ok = -1; // erreur URL } #endif @@ -191,30 +194,30 @@ int ident_url_relatif(const char *lien, const char *origin_adr, /* patch scheme if necessary */ if (strfield(lien, "http:")) { lien += 5; - strcpybuff(adr, jump_protocol(origin_adr)); // même adresse ; protocole vide (http) + strcpybuff(adrfil->adr, jump_protocol(origin_adr)); // même adresse ; protocole vide (http) } else if (strfield(lien, "https:")) { lien += 6; - strcpybuff(adr, "https://"); // même adresse forcée en https - strcatbuff(adr, jump_protocol(origin_adr)); + strcpybuff(adrfil->adr, "https://"); // même adresse forcée en https + strcatbuff(adrfil->adr, jump_protocol(origin_adr)); } else if (strfield(lien, "ftp:")) { lien += 4; - strcpybuff(adr, "ftp://"); // même adresse forcée en ftp - strcatbuff(adr, jump_protocol(origin_adr)); + strcpybuff(adrfil->adr, "ftp://"); // même adresse forcée en ftp + strcatbuff(adrfil->adr, jump_protocol(origin_adr)); } else { - strcpybuff(adr, origin_adr); // même adresse ; et même éventuel protocole + strcpybuff(adrfil->adr, origin_adr); // même adresse ; et même éventuel protocole } if (*lien != '/') { // sinon c'est un lien absolu if (*lien == '\0') { - strcpybuff(fil, origin_fil); + strcpybuff(adrfil->fil, origin_fil); } else if (*lien == '?') { // example: a href="?page=2" char *a; - strcpybuff(fil, origin_fil); - a = strchr(fil, '?'); + strcpybuff(adrfil->fil, origin_fil); + a = strchr(adrfil->fil, '?'); if (a) *a = '\0'; - strcatbuff(fil, lien); + strcatbuff(adrfil->fil, lien); } else { const char *a = strchr(origin_fil, '?'); @@ -225,14 +228,14 @@ int ident_url_relatif(const char *lien, const char *origin_adr, if (*a == '/') { // ok on a un '/' if ((((int) (a - origin_fil)) + 1 + strlen(lien)) < HTS_URLMAXSIZE) { // copier chemin - strncpy(fil, origin_fil, ((int) (a - origin_fil)) + 1); - *(fil + ((int) (a - origin_fil)) + 1) = '\0'; + strncpy(adrfil->fil, origin_fil, ((int) (a - origin_fil)) + 1); + *(adrfil->fil + ((int) (a - origin_fil)) + 1) = '\0'; // copier chemin relatif - if (((int) strlen(fil) + (int) strlen(lien)) < HTS_URLMAXSIZE) { - strcatbuff(fil, lien + ((*lien == '/') ? 1 : 0)); + if (((int) strlen(adrfil->fil) + (int) strlen(lien)) < HTS_URLMAXSIZE) { + strcatbuff(adrfil->fil, lien + ((*lien == '/') ? 1 : 0)); // simplifier url pour les ../ - fil_simplifie(fil); + fil_simplifie(adrfil->fil); } else ok = -1; // erreur } else { // erreur @@ -244,8 +247,8 @@ int ident_url_relatif(const char *lien, const char *origin_adr, } } else { // chemin absolu // copier chemin directement - strcatbuff(fil, lien); - fil_simplifie(fil); + strcatbuff(adrfil->fil, lien); + fil_simplifie(adrfil->fil); } // *lien!='/' } else ok = -1; @@ -254,7 +257,7 @@ int ident_url_relatif(const char *lien, const char *origin_adr, // case insensitive pour adresse { - char *a = jump_identification(adr); + char *a = jump_identification(adrfil->adr); while(*a) { if ((*a >= 'A') && (*a <= 'Z')) @@ -264,8 +267,8 @@ int ident_url_relatif(const char *lien, const char *origin_adr, } // IDNA / RFC 3492 (Punycode) handling for HTTP(s) - if (!link_has_authority(adr) || strfield(adr, "https:")) { - char *const a = jump_identification(adr); + if (!link_has_authority(adrfil->adr) || strfield(adrfil->adr, "https:")) { + char *const a = jump_identification(adrfil->adr); // Non-ASCII characters (theorically forbidden, but browsers are lenient) if (!hts_isStringAscii(a, strlen(a))) { char *const idna = hts_convertStringUTF8ToIDNA(a, strlen(a)); @@ -708,19 +711,18 @@ HTS_INLINE int rech_sampletag(const char *adr, const char *s) { } // teste si le tag contenu dans from est égal à "tag" -HTS_INLINE int check_tag(char *from, const char *tag) { - char *a = from + 1; +HTS_INLINE int check_tag(const char *from, const char *tag) { + const char *a = from + 1; int i = 0; char s[256]; while(is_space(*a)) a++; - while((isalnum((unsigned char) *a) || (*a == '/')) && (i < 250)) { - s[i++] = *a; - a++; + for( ; (isalnum((unsigned char) *a) || (*a == '/')) && i + 1 < sizeof(s) ; i++, a++) { + s[i] = *a; } - s[i++] = '\0'; - return (strfield2(s, tag)); // comparer + s[i] = '\0'; + return strfield2(s, tag); // comparer } // teste si un fichier dépasse le quota @@ -758,7 +760,117 @@ static int sortTopIndexFnc(const void *a_, const void *b_) { return cmp; } -//HTSEXT_API char *hts_getcategory(const char *filename); +typedef struct hts_template_format_buf { + FILE *fp; + char *buffer; + size_t size; + size_t offset; +} hts_template_format_buf; + +// note: upstream arg list MUST be NULL-terminated for safety +// returns a negative value upon error +static int hts_template_formatv(hts_template_format_buf *buf, + const char *format, va_list args) { +#undef FPUTC +#undef FPUTS +#define FPUTC(C) do { \ + if (buf->fp != NULL) { \ + assertf(buf->buffer == NULL); \ + if (fputc(C, buf->fp) < 0) { \ + return -1; \ + } \ + } else { \ + assertf(buf->buffer != NULL); \ + if (buf->offset + 1 < buf->size) { \ + buf->buffer[buf->offset++] = (C); \ + } else { \ + return -1; \ + } \ + } \ +} while(0) +#define FPUTS(S) do { \ + size_t i; \ + const char *const str_ = (S); \ + assertf(str_ != NULL); \ + for(i = 0 ; str_[i] != '\0' ; i++) { \ + FPUTC(str_[i]); \ + } \ +} while(0) + + if (buf != NULL && format != NULL) { + const char *arg_expanded[32]; + size_t i, nbArgs, posArgs; + /* Expand internal code args. */ + const char *str; + for(nbArgs = 0 ; ( str = va_arg(args, const char*) ) != NULL ; nbArgs++) { + assertf(nbArgs < sizeof(arg_expanded)/sizeof(arg_expanded[0])); + arg_expanded[nbArgs] = str; + } + /* Expand user-injected format string. */ + for(posArgs = 0, i = 0 ; format[i] != '\0' ; i++) { + const unsigned char c = format[i]; + if (c == '%') { + const unsigned char cFormat = format[++i]; + switch(cFormat) { + case '%': + FPUTC('%'); + break; + case 's': + if (posArgs < nbArgs) { + assertf(arg_expanded[posArgs] != NULL); + FPUTS(arg_expanded[posArgs]); + posArgs++; + } else { + FPUTS("???"); /* error (args overflow) */ + } + break; + default: /* ignored */ + FPUTC('%'); + FPUTC(cFormat); + break; + } + } else { + FPUTC(c); + } + } + /* Terminating NULL. */ + if (buf->buffer != NULL) { + buf->buffer[buf->offset] = 0; + } + return 1; + } else { + return -1; + } +#undef FPUTC +#undef FPUTS +} + +// note: upstream arg list MUST be NULL-terminated for safety +// returns a negative value upon error +int hts_template_format(FILE *const out, const char *format, ...) { + int success; + hts_template_format_buf buf = { NULL, NULL, 0, 0 }; + va_list args; + buf.fp = out; + va_start(args, format); + success = hts_template_formatv(&buf, format, args); + va_end(args); + return success; +} + +// note: upstream arg list MUST be NULL-terminated for safety +// returns a negative value upon error +int hts_template_format_str(char *buffer, size_t size, const char *format, ...) { + int success; + hts_template_format_buf buf = { NULL, NULL, 0, 0 }; + va_list args; + buf.buffer = buffer; + buf.size = size; + va_start(args, format); + success = hts_template_formatv(&buf, format, args); + va_end(args); + return success; +} /* Note: NOT utf-8 */ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path, @@ -799,9 +911,9 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path, verif_backblue(opt, concat(catbuff, sizeof(catbuff), rpath, "/")); // générer gif // Header - fprintf(fpo, toptemplate_header, + hts_template_format(fpo, toptemplate_header, ""); + HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->", /* EOF */ NULL); /* Find valid project names */ h = hts_findfirst(rpath); @@ -870,7 +982,7 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path, assertf(sortedElts != NULL); if (sortedElts != NULL) { int i; - char *category = ""; + const char *category = ""; /* Build array */ struct topindex_chain *chain = startchain; @@ -892,9 +1004,9 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path, /* Changed category */ if (strcmp(category, sortedElts[i]->category) != 0) { category = sortedElts[i]->category; - fprintf(fpo, toptemplate_bodycat, category); + hts_template_format(fpo, toptemplate_bodycat, category, /* EOF */ NULL); } - fprintf(fpo, toptemplate_body, hname, sortedElts[i]->name); + hts_template_format(fpo, toptemplate_body, hname, sortedElts[i]->name, /* EOF */ NULL); } /* Wipe elements */ @@ -912,9 +1024,9 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path, } // Footer - fprintf(fpo, toptemplate_footer, + hts_template_format(fpo, toptemplate_footer, ""); + HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->", /* EOF */ NULL); fclose(fpo); diff --git a/src/htstools.h b/src/htstools.h index 953a691..1289849 100644 --- a/src/htstools.h +++ b/src/htstools.h @@ -47,11 +47,20 @@ typedef struct httrackp httrackp; typedef struct find_handle_struct find_handle_struct; typedef find_handle_struct *find_handle; #endif +#ifndef HTS_DEF_FWSTRUCT_lien_adrfil +#define HTS_DEF_FWSTRUCT_lien_adrfil +typedef struct lien_adrfil lien_adrfil; +#endif +#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave +#define HTS_DEF_FWSTRUCT_lien_adrfilsave +typedef struct lien_adrfilsave lien_adrfilsave; +#endif /* Library internal definictions */ #ifdef HTS_INTERNAL_BYTECODE -int ident_url_relatif(const char *lien, const char *urladr, const char *urlfil, - char *adr, char *fil); +int ident_url_relatif(const char *lien, const char *origin_adr, + const char *origin_fil, + lien_adrfil* const adrfil); int lienrelatif(char *s, const char *link, const char *curr); int link_has_authority(const char *lien); int link_has_authorization(const char *lien); @@ -61,6 +70,9 @@ HTS_INLINE int __rech_tageq(const char *adr, const char *s); HTS_INLINE int __rech_tageqbegdigits(const char *adr, const char *s); HTS_INLINE int rech_tageq_all(const char *adr, const char *s); +int hts_template_format(FILE *const out, const char *format, ...); +int hts_template_format_str(char *buffer, size_t size, const char *format, ...); + #define rech_tageq(adr,s) \ ( \ ( (*((adr)-1)=='<') || (is_space(*((adr)-1))) ) ? \ @@ -84,7 +96,7 @@ HTS_INLINE int rech_tageq_all(const char *adr, const char *s); //HTS_INLINE int rech_tageq(const char* adr,const char* s); HTS_INLINE int rech_sampletag(const char *adr, const char *s); HTS_INLINE int rech_endtoken(const char *adr, const char **start); -HTS_INLINE int check_tag(char *from, const char *tag); +HTS_INLINE int check_tag(const char *from, const char *tag); int verif_backblue(httrackp * opt, const char *base); int verif_external(httrackp * opt, int nb, int test); diff --git a/src/htsweb.c b/src/htsweb.c index d428c5d..6e3f4a5 100644 --- a/src/htsweb.c +++ b/src/htsweb.c @@ -178,6 +178,14 @@ int main(int argc, char *argv[]) { } smallserver_setkey("HTTRACK_WEB", HTTRACK_WEB); + /* Check version compatibility */ + if (hts_sizeof_opt() != sizeof(httrackp)) { + fprintf(stderr, + "** CRITICAL: incompatible current httrack library version %s, expected version %s", + hts_version(), HTTRACK_VERSIONID); + smallserver_setkey("HTTRACK_INCOMPATIBLE_VERSIONID", hts_version()); + } + /* protected session-id */ { char buff[1024]; @@ -238,7 +246,7 @@ static void back_launch_cmd(void *pP) { commandReturnCmdl = strdup(cmd); /* split */ - argv[0] = "webhttrack"; + argv[0] = strdup("webhttrack"); argv[1] = cmd; argc++; i = 0; @@ -264,6 +272,7 @@ static void back_launch_cmd(void *pP) { /* init */ hts_init(); global_opt = opt = hts_create_opt(); + assert(opt->size_httrackp == sizeof(httrackp)); /* run */ commandReturn = webhttrack_runmain(opt, argc, argv); diff --git a/src/htswizard.c b/src/htswizard.c index 15ca5c0..af364db 100644 --- a/src/htswizard.c +++ b/src/htswizard.c @@ -42,10 +42,6 @@ Please visit our Website: http://www.httrack.com #include /* END specific definitions */ -// pour alléger la syntaxe, des raccourcis sont créés -#define urladr (liens[ptr]->adr) -#define urlfil (liens[ptr]->fil) - // libérer filters[0] pour insérer un élément dans filters[0] #define HT_INSERT_FILTERS0 do {\ int i;\ @@ -60,8 +56,8 @@ Please visit our Website: http://www.httrack.com } while(0) typedef struct htspair_t { - char *tag; - char *attr; + const char *tag; + const char *attr; } htspair_t; /* "embedded" */ @@ -79,9 +75,9 @@ htspair_t hts_detect_embed[] = { }; /* Internal */ -static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, - lien_url ** liens, char *adr, char *fil, char *tag, - char *attribute, int *set_prio_to, +static int hts_acceptlink_(httrackp * opt, int ptr, const char *adr, + const char *fil, const char *tag, + const char *attribute, int *set_prio_to, int *just_test_it); /* @@ -104,10 +100,11 @@ retour: -1 pas d'avis */ -int hts_acceptlink(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *tag, char *attribute, +int hts_acceptlink(httrackp * opt, int ptr, + const char *adr, const char *fil, + const char *tag, const char *attribute, int *set_prio_to, int *just_test_it) { - int forbidden_url = hts_acceptlink_(opt, ptr, lien_tot, liens, + int forbidden_url = hts_acceptlink_(opt, ptr, adr, fil, tag, attribute, set_prio_to, just_test_it); int prev_prio = set_prio_to ? *set_prio_to : 0; @@ -133,9 +130,9 @@ static int cmp_token(const char *tag, const char *cmp) { && !isalnum((unsigned char) tag[p])); } -static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, - lien_url ** liens, char *adr, char *fil, char *tag, - char *attribute, int *set_prio_to, +static int hts_acceptlink_(httrackp * opt, int ptr, + const char *adr, const char *fil, const char *tag, + const char *attribute, int *set_prio_to, int *just_test_it) { int forbidden_url = -1; int meme_adresse; @@ -187,8 +184,8 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, /* Niveau 1: ne pas parser suivant! */ if (ptr > 0) { - if ((liens[ptr]->depth <= 0) - || (liens[ptr]->depth <= 1 && !embedded_triggered)) { + if ((heap(ptr)->depth <= 0) + || (heap(ptr)->depth <= 1 && !embedded_triggered)) { forbidden_url = 1; // interdire récupération du lien hts_log_print(opt, LOG_DEBUG, "file from too far level ignored at %s : %s", adr, fil); @@ -203,11 +200,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, // ------------------------------------------------------ // doit-on traiter ce lien?.. vérifier droits de déplacement - meme_adresse = strfield2(adr, urladr); + meme_adresse = strfield2(adr, urladr()); if (meme_adresse) - hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s=%s", adr, urladr); + hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s=%s", adr, urladr()); else - hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s!=%s", adr, urladr); + hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s!=%s", adr, urladr()); if (meme_adresse) { // même adresse { // tester interdiction de descendre // MODIFIE : en cas de remontée puis de redescente, il se pouvait qu'on ne puisse pas atteindre certains fichiers @@ -220,15 +217,15 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, // note (up/down): on calcule à partir du lien primaire, ET du lien précédent. // ex: si on descend 2 fois on peut remonter 1 fois - if (lienrelatif(tempo, fil, liens[liens[ptr]->premier]->fil) == 0) { - if (lienrelatif(tempo2, fil, liens[ptr]->fil) == 0) { + if (lienrelatif(tempo, fil, heap(heap(ptr)->premier)->fil) == 0) { + if (lienrelatif(tempo2, fil, heap(ptr)->fil) == 0) { hts_log_print(opt, LOG_DEBUG, "build relative links to test: %s %s (with %s and %s)", - tempo, tempo2, liens[liens[ptr]->premier]->fil, - liens[ptr]->fil); + tempo, tempo2, heap(heap(ptr)->premier)->fil, + heap(ptr)->fil); // si vient de primary, ne pas tester lienrelatif avec (car host "différent") - /*if (liens[liens[ptr]->premier] == 0) { // vient de primary + /*if (heap(heap(ptr)->premier) == 0) { // vient de primary } */ @@ -242,7 +239,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, || (tempo2[0] != '\0' && tempo2[1] != '\0' && strchr(tempo2 + 1, '/') == 0) ) { - if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved' + if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved' forbidden_url = 0; hts_log_print(opt, LOG_DEBUG, "same level link authorized: %s%s", adr, fil); @@ -267,7 +264,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, hts_log_print(opt, LOG_DEBUG, "lower link canceled: %s%s", adr, fil); } else { // autorisé à priori - NEW - if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved' + if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved' forbidden_url = 0; hts_log_print(opt, LOG_DEBUG, "lower link authorized: %s%s", adr, fil); @@ -275,7 +272,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, } } else if ((test1) || (test2)) { // on peut descendre pour accéder au lien if ((opt->seeker & 1) != 0) { // on peut descendre - NEW - if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved' + if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved' forbidden_url = 0; hts_log_print(opt, LOG_DEBUG, "lower link authorized: %s%s", adr, fil); @@ -291,7 +288,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, hts_log_print(opt, LOG_DEBUG, "upper link canceled: %s%s", adr, fil); } else { // autorisé à monter - NEW - if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved' + if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved' forbidden_url = 0; hts_log_print(opt, LOG_DEBUG, "upper link authorized: %s%s", adr, fil); @@ -299,7 +296,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, } } else if ((!strncmp(tempo, "../", 3)) || (!strncmp(tempo2, "../", 3))) { // Possible en montant if ((opt->seeker & 2) != 0) { // autorisé à monter - NEW - if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved' + if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved' forbidden_url = 0; hts_log_print(opt, LOG_DEBUG, "upper link authorized: %s%s", adr, fil); @@ -310,11 +307,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, } else { hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s", fil, - liens[ptr]->fil); + heap(ptr)->fil); } } else { hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s", - fil, liens[liens[ptr]->premier]->fil); + fil, heap(heap(ptr)->premier)->fil); } } // tester interdiction de descendre? @@ -323,16 +320,16 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, char BIGSTK tempo[HTS_URLMAXSIZE * 2]; char BIGSTK tempo2[HTS_URLMAXSIZE * 2]; - if (lienrelatif(tempo, fil, liens[liens[ptr]->premier]->fil) == 0) { - if (lienrelatif(tempo2, fil, liens[ptr]->fil) == 0) { + if (lienrelatif(tempo, fil, heap(heap(ptr)->premier)->fil) == 0) { + if (lienrelatif(tempo2, fil, heap(ptr)->fil) == 0) { } else { hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s", fil, - liens[ptr]->fil); + heap(ptr)->fil); } } else { hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s", - fil, liens[liens[ptr]->premier]->fil); + fil, heap(heap(ptr)->premier)->fil); } } // fin tester interdiction de monter @@ -348,24 +345,24 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, break; // interdicton de sortir au dela de l'adresse case 1:{ // sortie sur le même dom.xxx size_t i = strlen(adr) - 1; - size_t j = strlen(urladr) - 1; + size_t j = strlen(urladr()) - 1; if ((i > 0) && (j > 0)) { while((i > 0) && (adr[i] != '.')) i--; - while((j > 0) && (urladr[j] != '.')) + while((j > 0) && (urladr()[j] != '.')) j--; if ((i > 0) && (j > 0)) { i--; j--; while((i > 0) && (adr[i] != '.')) i--; - while((j > 0) && (urladr[j] != '.')) + while((j > 0) && (urladr()[j] != '.')) j--; } } if ((i > 0) && (j > 0)) { - if (!strfield2(adr + i, urladr + j)) { // != + if (!strfield2(adr + i, urladr() + j)) { // != if (!opt->wizard) { // mode non wizard //printf("refused: %s\n",adr); forbidden_url = 1; // pas même domaine @@ -387,14 +384,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, break; case 2:{ // sortie sur le même .xxx size_t i = strlen(adr) - 1; - size_t j = strlen(urladr) - 1; + size_t j = strlen(urladr()) - 1; while((i > 0) && (adr[i] != '.')) i--; - while((j > 0) && (urladr[j] != '.')) + while((j > 0) && (urladr()[j] != '.')) j--; if ((i > 0) && (j > 0)) { - if (!strfield2(adr + i, urladr + j)) { // !- + if (!strfield2(adr + i, urladr() + j)) { // !- if (!opt->wizard) { // mode non wizard //printf("refused: %s\n",adr); forbidden_url = 1; // pas même .xx @@ -493,7 +490,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, // there is no way yet to tag "external" links, and therefore links that are // "weak" (authorized depth < external depth) are just not considered for external // hack - if (liens[ptr]->depth > opt->extdepth) { + if (heap(ptr)->depth > opt->extdepth) { // *set_prio_to = opt->extdepth + 1; *set_prio_to = 1 + (opt->extdepth); may_set_prio_to = 0; // clear may-set flag @@ -502,11 +499,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, if (question) { hts_log_print(opt, LOG_DEBUG, "(wizard) ambiguous link accepted (external depth): link %s at %s%s", - l, urladr, urlfil); + l, urladr(), urlfil()); } else { hts_log_print(opt, LOG_DEBUG, "(wizard) forced to accept link (external depth): link %s at %s%s", - l, urladr, urlfil); + l, urladr(), urlfil()); } } @@ -515,7 +512,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, // filters { int jok; - char *mdepth = ""; + const char *mdepth = ""; // filters, 0=sait pas 1=ok -1=interdit { @@ -550,14 +547,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, may_set_prio_to = 0; // clear may-set flag hts_log_print(opt, LOG_DEBUG, "(wizard) explicit authorized (%s) link: link %s at %s%s", - mdepth, l, urladr, urlfil); + mdepth, l, urladr(), urlfil()); } else if (jok == -1) { // forbidden filters_answer = 1; // décision prise par les filtres question = 0; // ne pas poser de question: forbidden_url = 1; // URL interdite hts_log_print(opt, LOG_DEBUG, "(wizard) explicit forbidden (%s) link: link %s at %s%s", - mdepth, l, urladr, urlfil); + mdepth, l, urladr(), urlfil()); } // sinon on touche à rien } } @@ -565,14 +562,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, // vérifier mode mirror links if (question) { if (opt->mirror_first_page) { // mode mirror links - if (liens[ptr]->precedent == 0) { // parent=primary! + if (heap(ptr)->precedent == 0) { // parent=primary! forbidden_url = 0; // autorisé may_set_prio_to = 0; // clear may-set flag question = 1; // résolution auto force_mirror = 5; // mirror (5) hts_log_print(opt, LOG_DEBUG, "(wizard) explicit mirror link: link %s at %s%s", l, - urladr, urlfil); + urladr(), urlfil()); } } } @@ -584,7 +581,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, forbidden_url = 1; hts_log_print(opt, LOG_DEBUG, "(wizard) ambiguous forbidden link: link %s at %s%s", l, - urladr, urlfil); + urladr(), urlfil()); } } // vérifier robots.txt @@ -619,14 +616,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, if (!forbidden_url) { hts_log_print(opt, LOG_DEBUG, "(wizard) shared foreign domain link: link %s at %s%s", l, - urladr, urlfil); + urladr(), urlfil()); } else { hts_log_print(opt, LOG_DEBUG, "(wizard) cancelled foreign domain link: link %s at %s%s", - l, urladr, urlfil); + l, urladr(), urlfil()); } #if BDEBUG==3 - printf("at %s in %s, wizard says: url %s ", urladr, urlfil, l); + printf("at %s in %s, wizard says: url %s ", urladr(), urlfil(), l); if (forbidden_url) printf("cancelled"); else @@ -863,13 +860,13 @@ static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot, #undef _ROBOTS } -int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *mime) { +int hts_acceptmime(httrackp * opt, int ptr, + const char *adr, const char *fil, const char *mime) { #define _FILTERS (*opt->filters.filters) #define _FILTERS_PTR (opt->filters.filptr) #define _ROBOTS ((robots_wizard*)opt->robotsptr) int forbidden_url = -1; - char *mdepth = ""; + const char *mdepth = ""; int jokDepth = 0; int jok = 0; @@ -906,7 +903,7 @@ int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, } // tester taille -int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size) { +int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint size) { int jok = 0; if (size >= 0) { @@ -984,7 +981,4 @@ int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size) { return jok; } -#undef urladr -#undef urlfil - #undef HT_INSERT_FILTERS0 diff --git a/src/htswizard.h b/src/htswizard.h index 3c78884..42a3e43 100644 --- a/src/htswizard.h +++ b/src/htswizard.h @@ -49,12 +49,13 @@ typedef struct httrackp httrackp; typedef struct lien_url lien_url; #endif -int hts_acceptlink(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *tag, char *attribute, +int hts_acceptlink(httrackp * opt, int ptr, + const char *adr, const char *fil, + const char *tag, const char *attribute, int *set_prio_to_0, int *just_test_it); -int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size); -int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens, - char *adr, char *fil, char *mime); +int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint size); +int hts_acceptmime(httrackp * opt, int ptr, + const char *adr, const char *fil, const char *mime); #endif #endif diff --git a/src/htswrap.h b/src/htswrap.h index e87ddf6..eb010d3 100644 --- a/src/htswrap.h +++ b/src/htswrap.h @@ -46,9 +46,17 @@ Please visit our Website: http://www.httrack.com typedef struct httrackp httrackp; #endif +#ifdef __cplusplus +extern "C" { +#endif + HTSEXT_API int htswrap_init(void); // LEGACY HTSEXT_API int htswrap_free(void); // LEGACY +#ifdef __cplusplus +} +#endif + //HTSEXT_API int htswrap_add(httrackp * opt, const char *name, void *fct); //HTSEXT_API uintptr_t htswrap_read(httrackp * opt, const char *name); diff --git a/src/htszlib.c b/src/htszlib.c index 5042910..05cc457 100644 --- a/src/htszlib.c +++ b/src/htszlib.c @@ -59,8 +59,9 @@ int hts_zunpack(char *filename, char *newfile) { char catbuff[CATBUFF_SIZE]; FILE *const in = FOPEN(fconv(catbuff, sizeof(catbuff), filename), "rb"); const int fd = in != NULL ? fileno(in) : -1; + const int dup_fd = fd != -1 ? dup(fd) : -1; // Note: we must dup to be able to flose cleanly. - gzFile gz = fd != -1 ? gzdopen(dup(fd), "rb") : NULL; + const gzFile gz = dup_fd != -1 ? gzdopen(dup_fd, "rb") : NULL; if (gz) { FILE *const fpout = FOPEN(fconv(catbuff, sizeof(catbuff), newfile), "wb"); diff --git a/src/httrack-library.h b/src/httrack-library.h index 8c63fb4..9873bef 100644 --- a/src/httrack-library.h +++ b/src/httrack-library.h @@ -5,7 +5,7 @@ Copyright (C) 1998-2014 Xavier Roche and other contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -as published by the Free Software Foundation; either version 2 +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -33,11 +33,16 @@ Please visit our Website: http://www.httrack.com #ifndef HTTRACK_DEFLIB #define HTTRACK_DEFLIB +#ifdef __cplusplus +extern "C" { +#endif + #include "htsglobal.h" #ifndef _WIN32 #include #endif +#include #ifndef HTS_DEF_FWSTRUCT_httrackp #define HTS_DEF_FWSTRUCT_httrackp @@ -65,6 +70,12 @@ typedef enum hts_log_type { typedef struct hts_stat_struct hts_stat_struct; #endif +/** Assert error callback. **/ +#ifndef HTS_DEF_FWSTRUCT_htsErrorCallback +#define HTS_DEF_FWSTRUCT_htsErrorCallback +typedef void (*htsErrorCallback) (const char *msg, const char *file, int line); +#endif + /* Helpers for plugging callbacks requires: htsdefines.h */ @@ -107,10 +118,13 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt); /* Options handling */ HTSEXT_API httrackp *hts_create_opt(void); HTSEXT_API void hts_free_opt(httrackp * opt); +HTSEXT_API size_t hts_sizeof_opt(void); HTSEXT_API const hts_stat_struct* hts_get_stats(httrackp * opt); HTSEXT_API void set_wrappers(httrackp * opt); /* LEGACY */ HTSEXT_API int plug_wrapper(httrackp * opt, const char *moduleName, const char *argv); +HTSEXT_API void hts_set_error_callback(htsErrorCallback handler); +HTSEXT_API htsErrorCallback hts_get_error_callback(void); /* Logging */ HTSEXT_API int hts_log(httrackp * opt, const char *prefix, const char *msg); @@ -118,6 +132,9 @@ HTSEXT_API void hts_log_print(httrackp * opt, int type, const char *format, ...) HTS_PRINTF_FUN(3, 4); HTSEXT_API void hts_log_vprint(httrackp * opt, int type, const char *format, va_list args); +HTSEXT_API void hts_set_log_vprint_callback(void (*callback)(httrackp * opt, + int type, + const char *format, va_list args)); /* Infos */ HTSEXT_API const char *hts_get_version_info(httrackp * opt); @@ -186,7 +203,7 @@ HTSEXT_API char *jump_normalized(const char *); HTSEXT_API char *jump_toport(const char *); HTSEXT_API char *fil_normalized(const char *source, char *dest); HTSEXT_API char *adr_normalized(const char *source, char *dest); -HTSEXT_API char *hts_rootdir(char *file); +HTSEXT_API const char *hts_rootdir(char *file); /* Escaping URLs */ HTSEXT_API void unescape_amp(char *s); @@ -227,7 +244,9 @@ HTSEXT_API void get_httptype(httrackp * opt, char *s, const char *fil, HTSEXT_API int is_knowntype(httrackp * opt, const char *fil); HTSEXT_API int is_userknowntype(httrackp * opt, const char *fil); HTSEXT_API int is_dyntype(const char *fil); -HTSEXT_API char *get_ext(char *catbuff, size_t size, const char *fil); +HTSEXT_API const char *get_ext(char *catbuff, size_t size, const char *fil); +HTSEXT_API int may_unknown(httrackp * opt, const char *st); +HTSEXT_API void guess_httptype(httrackp * opt, char *s, const char *fil); /* Ugly string tools */ HTSEXT_API char *concat(char *catbuff, size_t size, const char *a, const char *b); @@ -318,4 +337,8 @@ typedef struct utimbuf STRUCT_UTIMBUF; #define fconcat(A,B,C,D) (COMPILE_TIME_CHECK_SIZE(B), fconcat(A,B,C,D)) #define fslash(A,B,C) (COMPILE_TIME_CHECK_SIZE(B), fslash(A,B,C)) +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/httrack.c b/src/httrack.c index 7c1ea5e..e8e5cd3 100644 --- a/src/httrack.c +++ b/src/httrack.c @@ -223,7 +223,17 @@ int main(int argc, char **argv) { signal_handlers(); hts_init(); + + // Check version compatibility + if (hts_sizeof_opt() != sizeof(httrackp)) { + fprintf(stderr, + "incompatible current httrack library version %s, expected version %s", + hts_version(), HTTRACK_VERSIONID); + abortLog("incompatible httrack library version, please update both httrack and its library"); + } + opt = global_opt = hts_create_opt(); + assert(opt->size_httrackp == sizeof(httrackp)); CHAIN_FUNCTION(opt, init, htsshow_init, NULL); CHAIN_FUNCTION(opt, uninit, htsshow_uninit, NULL); diff --git a/src/httrack.vcproj b/src/httrack.vcproj index b523502..f82cff7 100755 --- a/src/httrack.vcproj +++ b/src/httrack.vcproj @@ -53,7 +53,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" OmitFramePointers="true" - AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.8\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" PreprocessorDefinitions="WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" RuntimeLibrary="2" UsePrecompiledHeader="0" @@ -152,7 +152,7 @@ EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" OmitFramePointers="true" - AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.8\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" PreprocessorDefinitions="WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE" RuntimeLibrary="2" UsePrecompiledHeader="0" @@ -246,7 +246,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/Zm200 " Optimization="0" - AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.8\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" RuntimeLibrary="3" BufferSecurityCheck="true" @@ -343,7 +343,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/Zm200 " Optimization="0" - AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.8\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" RuntimeLibrary="3" BufferSecurityCheck="true" @@ -440,7 +440,7 @@ AdditionalOptions="/Zm200 " Optimization="3" InlineFunctionExpansion="2" - AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.8\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" StringPooling="true" RuntimeLibrary="2" @@ -535,7 +535,7 @@ AdditionalOptions="/Zm200 " Optimization="3" InlineFunctionExpansion="2" - AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.3\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" + AdditionalIncludeDirectories=""C:\Dev\zlib-1.2.8\";"C:\Dev\openssl-1.0.1e\include";C:\Dev\Winhttrack" PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;HTS_ANALYSTE_CONSOLE;_CRT_SECURE_NO_WARNINGS" StringPooling="true" RuntimeLibrary="2" diff --git a/src/md5.c b/src/md5.c index d5b8945..7c9d9de 100644 --- a/src/md5.c +++ b/src/md5.c @@ -88,7 +88,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) { /* Handle any leading odd-sized chunks */ if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; + unsigned char *p = ctx->in.ui8 + t; t = 64 - t; if (len < t) { @@ -97,25 +97,25 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) { } memcpy(p, buf, t); if (ctx->doByteReverse) - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); + byteReverse(ctx->in.ui8, 16); + MD5Transform(ctx->buf, ctx->in.ui32); buf += t; len -= t; } /* Process data in 64-byte chunks */ while(len >= 64) { - memcpy(ctx->in, buf, 64); + memcpy(ctx->in.ui8, buf, 64); if (ctx->doByteReverse) - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); + byteReverse(ctx->in.ui8, 16); + MD5Transform(ctx->buf, ctx->in.ui32); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + memcpy(ctx->in.ui8, buf, len); } /* @@ -131,7 +131,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) { /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ - p = ctx->in + count; + p = ctx->in.ui8 + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ @@ -142,26 +142,27 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); if (ctx->doByteReverse) - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); + byteReverse(ctx->in.ui8, 16); + MD5Transform(ctx->buf, ctx->in.ui32); /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); + memset(ctx->in.ui8, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } if (ctx->doByteReverse) - byteReverse(ctx->in, 14); + byteReverse(ctx->in.ui8, 14); /* Append length in bits and transform */ /* Note: see patch for PAM from Tomas Mraz */ - memcpy((uint32 *) ctx->in + 14, ctx->bits, 2 * sizeof(uint32)); + ctx->in.ui32[14] = ctx->bits[0]; + ctx->in.ui32[15] = ctx->bits[1]; /*((uint32 *) ctx->in)[14] = ctx->bits[0]; ((uint32 *) ctx->in)[15] = ctx->bits[1]; */ - MD5Transform(ctx->buf, (uint32 *) ctx->in); + MD5Transform(ctx->buf, ctx->in.ui32); if (ctx->doByteReverse) byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); diff --git a/src/md5.h b/src/md5.h index a7b9f17..9dc72c7 100644 --- a/src/md5.h +++ b/src/md5.h @@ -18,7 +18,10 @@ typedef unsigned long uint32; #endif struct MD5Context { - unsigned char in[64]; + union { + unsigned char ui8[64]; + uint32 ui32[16]; + } in; uint32 buf[4]; uint32 bits[2]; int doByteReverse; diff --git a/src/minizip/ChangeLogUnzip b/src/minizip/ChangeLogUnzip deleted file mode 100755 index 3508eb4..0000000 --- a/src/minizip/ChangeLogUnzip +++ /dev/null @@ -1,55 +0,0 @@ -Change in 1.00: (10 sept 03) -- rename to 1.00 -- cosmetic code change - -Change in 0.22: (19 May 03) -- crypting support (unless you define NOCRYPT) -- append file in existing zipfile - -Change in 0.21: (10 Mar 03) -- bug fixes - -Change in 0.17: (27 Jan 02) -- bug fixes - -Change in 0.16: (19 Jan 02) -- Support of ioapi for virtualize zip file access - -Change in 0.15: (19 Mar 98) -- fix memory leak in minizip.c - -Change in 0.14: (10 Mar 98) -- fix bugs in minizip.c sample for zipping big file -- fix problem in month in date handling -- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for - comment handling - -Change in 0.13: (6 Mar 98) -- fix bugs in zip.c -- add real minizip sample - -Change in 0.12: (4 Mar 98) -- add zip.c and zip.h for creates .zip file -- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) -- fix miniunz.c for file without specific record for directory - -Change in 0.11: (3 Mar 98) -- fix bug in unzGetCurrentFileInfo for get extra field and comment -- enhance miniunz sample, remove the bad unztst.c sample - -Change in 0.10: (2 Mar 98) -- fix bug in unzReadCurrentFile -- rename unzip* to unz* function and structure -- remove Windows-like hungary notation variable name -- modify some structure in unzip.h -- add somes comment in source -- remove unzipGetcCurrentFile function -- replace ZUNZEXPORT by ZEXPORT -- add unzGetLocalExtrafield for get the local extrafield info -- add a new sample, miniunz.c - -Change in 0.4: (25 Feb 98) -- suppress the type unzipFileInZip. - Only on file in the zipfile can be open at the same time -- fix somes typo in code -- added tm_unz structure in unzip_file_info (date/time in readable format) diff --git a/src/minizip/MiniZip64_Changes.txt b/src/minizip/MiniZip64_Changes.txt new file mode 100644 index 0000000..13a1bd9 --- /dev/null +++ b/src/minizip/MiniZip64_Changes.txt @@ -0,0 +1,6 @@ + +MiniZip 1.1 was derrived from MiniZip at version 1.01f + +Change in 1.0 (Okt 2009) + - **TODO - Add history** + diff --git a/src/minizip/MiniZip64_info.txt b/src/minizip/MiniZip64_info.txt new file mode 100644 index 0000000..57d7152 --- /dev/null +++ b/src/minizip/MiniZip64_info.txt @@ -0,0 +1,74 @@ +MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson + +Introduction +--------------------- +MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html ) + +When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0. +All possible work was done for compatibility. + + +Background +--------------------- +When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 +support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ ) + +That was used as a starting point. And after that ZIP64 support was added to zip.c +some refactoring and code cleanup was also done. + + +Changed from MiniZip 1.0 to MiniZip 1.1 +--------------------------------------- +* Added ZIP64 support for unzip ( by Even Rouault ) +* Added ZIP64 support for zip ( by Mathias Svensson ) +* Reverted some changed that Even Rouault did. +* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users. +* Added unzip patch for BZIP Compression method (patch create by Daniel Borca) +* Added BZIP Compress method for zip +* Did some refactoring and code cleanup + + +Credits + + Gilles Vollant - Original MiniZip author + Even Rouault - ZIP64 unzip Support + Daniel Borca - BZip Compression method support in unzip + Mathias Svensson - ZIP64 zip support + Mathias Svensson - BZip Compression method support in zip + + Resources + + ZipLayout http://result42.com/projects/ZipFileLayout + Command line tool for Windows that shows the layout and information of the headers in a zip archive. + Used when debugging and validating the creation of zip files using MiniZip64 + + + ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT + Zip File specification + + +Notes. + * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined. + +License +---------------------------------------------------------- + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +---------------------------------------------------------- + diff --git a/src/minizip/crypt.h b/src/minizip/crypt.h index 9c7a89c..1e9e820 100644 --- a/src/minizip/crypt.h +++ b/src/minizip/crypt.h @@ -1,9 +1,9 @@ /* crypt.h -- base code for crypt/uncrypt ZIPfile - Version 1.00, September 10th, 2003 + Version 1.01e, February 12th, 2005 - Copyright (C) 1998-2003 Gilles Vollant + Copyright (C) 1998-2005 Gilles Vollant This code is a modified version of crypting code in Infozip distribution @@ -32,7 +32,7 @@ /*********************************************************************** * Return the next byte in the pseudo-random sequence */ -static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) +static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an * unpredictable manner on 16-bit systems; not a problem @@ -45,7 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) /*********************************************************************** * Update the encryption keys with the next byte of plain text */ -static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) +static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) { (*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+1)) += (*(pkeys+0)) & 0xff; @@ -62,7 +62,7 @@ static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int * Initialize the encryption keys and the random header according to * the given password. */ -static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) +static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) { *(pkeys+0) = 305419896L; *(pkeys+1) = 591751049L; @@ -87,13 +87,12 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned lon # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ # endif -static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) - const char *passwd; /* password string */ - unsigned char *buf; /* where to write header */ - int bufSize; - unsigned long* pkeys; - const unsigned long* pcrc_32_tab; - unsigned long crcForCrypting; +static int crypthead(const char* passwd, /* password string */ + unsigned char* buf, /* where to write header */ + int bufSize, + unsigned long* pkeys, + const z_crc_t* pcrc_32_tab, + unsigned long crcForCrypting) { int n; /* index in random header */ int t; /* temporary */ @@ -124,8 +123,8 @@ static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) { buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); } - buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); - buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); + buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); + buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); return n; } diff --git a/src/minizip/ioapi.c b/src/minizip/ioapi.c index 53583ed..bbf3dd1 100644 --- a/src/minizip/ioapi.c +++ b/src/minizip/ioapi.c @@ -1,83 +1,101 @@ -/* ioapi.c -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API +/* ioapi.h -- IO base function header for compress/uncompress .zip + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Version 1.00, September 10th, 2003 + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt - Copyright (C) 1998-2003 Gilles Vollant */ -#ifndef _WIN32_WCE -#include -#include -#else -#include -//#include "celib.h" +#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS))) + #define _CRT_SECURE_NO_WARNINGS #endif -#include -#include "zlib.h" +#if defined(__APPLE__) || defined(IOAPI_NO_64) +// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions +#define FOPEN_FUNC(filename, mode) fopen(filename, mode) +#define FTELLO_FUNC(stream) ftello(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) +#else +#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) +#define FTELLO_FUNC(stream) ftello64(stream) +#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) +#endif + + #include "ioapi.h" +voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) +{ + if (pfilefunc->zfile_func64.zopen64_file != NULL) + return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); + else + { + return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); + } +} + +long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) +{ + if (pfilefunc->zfile_func64.zseek64_file != NULL) + return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); + else + { + uLong offsetTruncated = (uLong)offset; + if (offsetTruncated != offset) + return -1; + else + return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); + } +} + +ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) +{ + if (pfilefunc->zfile_func64.zseek64_file != NULL) + return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); + else + { + uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); + if ((tell_uLong) == MAXU32) + return (ZPOS64_T)-1; + else + return tell_uLong; + } +} + +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) +{ + p_filefunc64_32->zfile_func64.zopen64_file = NULL; + p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; + p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; + p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; + p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; + p_filefunc64_32->zfile_func64.zflush_file = p_filefunc32->zflush_file; + p_filefunc64_32->zfile_func64.ztell64_file = NULL; + p_filefunc64_32->zfile_func64.zseek64_file = NULL; + p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; + p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; + p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; + p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; + p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; +} -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif +static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); +static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); +static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); +static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); +static int ZCALLBACK fflush_file_func OF((voidpf opaque, voidpf stream)); -#ifndef SEEK_END -#define SEEK_END 2 -#endif +static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); +static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -voidpf ZCALLBACK fopen_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); - -uLong ZCALLBACK fread_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); - -uLong ZCALLBACK fwrite_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); - -long ZCALLBACK ftell_file_func OF(( - voidpf opaque, - voidpf stream)); - -long ZCALLBACK fseek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); - -int ZCALLBACK fflush_file_func OF(( - voidpf opaque, - voidpf stream)); - -int ZCALLBACK fclose_file_func OF(( - voidpf opaque, - voidpf stream)); - -int ZCALLBACK ferror_file_func OF(( - voidpf opaque, - voidpf stream)); - - -voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) - voidpf opaque; - const char* filename; - int mode; +static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) { FILE* file = NULL; const char* mode_fopen = NULL; @@ -95,44 +113,55 @@ voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) return file; } - -uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - void* buf; - uLong size; +static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) { - uLong ret; - ret = fread(buf, 1, (size_t)size, (FILE *)stream); - return ret; + FILE* file = NULL; + const char* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = "rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = "r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = "wb"; + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = FOPEN_FUNC((const char*)filename, mode_fopen); + return file; } -uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - const void* buf; - uLong size; +static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) { uLong ret; - ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); return ret; } -long ZCALLBACK ftell_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) +{ + uLong ret; + ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); + return ret; +} + +static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) { long ret; ret = ftell((FILE *)stream); return ret; } -long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) - voidpf opaque; - voidpf stream; - uLong offset; - int origin; + +static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) +{ + ZPOS64_T ret; + ret = FTELLO_FUNC((FILE *)stream); + return ret; +} + +static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) { int fseek_origin=0; long ret; @@ -150,31 +179,51 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) default: return -1; } ret = 0; - fseek((FILE *)stream, offset, fseek_origin); + if (fseek((FILE *)stream, offset, fseek_origin) != 0) + ret = -1; return ret; } -int ZCALLBACK fflush_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) +{ + int fseek_origin=0; + long ret; + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + fseek_origin = SEEK_CUR; + break; + case ZLIB_FILEFUNC_SEEK_END : + fseek_origin = SEEK_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + fseek_origin = SEEK_SET; + break; + default: return -1; + } + ret = 0; + + if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0) + ret = -1; + + return ret; +} + +static int ZCALLBACK fflush_file_func (voidpf opaque, voidpf stream) { int ret; ret = fflush((FILE *)stream); return ret; } -int ZCALLBACK fclose_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) { int ret; ret = fclose((FILE *)stream); return ret; } -int ZCALLBACK ferror_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) { int ret; ret = ferror((FILE *)stream); @@ -194,3 +243,16 @@ void fill_fopen_filefunc (pzlib_filefunc_def) pzlib_filefunc_def->zerror_file = ferror_file_func; pzlib_filefunc_def->opaque = NULL; } + +void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = fopen64_file_func; + pzlib_filefunc_def->zread_file = fread_file_func; + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell64_file = ftell64_file_func; + pzlib_filefunc_def->zseek64_file = fseek64_file_func; + pzlib_filefunc_def->zflush_file = fflush_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +} diff --git a/src/minizip/ioapi.c.diff b/src/minizip/ioapi.c.diff new file mode 100644 index 0000000..05d3e4a --- /dev/null +++ b/src/minizip/ioapi.c.diff @@ -0,0 +1,48 @@ +--- ioapi.c.orig 2012-01-21 20:58:45.000000000 +0100 ++++ ioapi.c 2014-05-24 13:27:22.516230485 +0200 +@@ -73,6 +73,7 @@ + p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; + p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; + p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; ++ p_filefunc64_32->zfile_func64.zflush_file = p_filefunc32->zflush_file; + p_filefunc64_32->zfile_func64.ztell64_file = NULL; + p_filefunc64_32->zfile_func64.zseek64_file = NULL; + p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; +@@ -89,6 +90,8 @@ + static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); + static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); + static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); ++static int ZCALLBACK fflush_file_func OF((voidpf opaque, voidpf stream)); ++ + static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); + static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); + +@@ -206,6 +209,12 @@ + return ret; + } + ++static int ZCALLBACK fflush_file_func (voidpf opaque, voidpf stream) ++{ ++ int ret; ++ ret = fflush((FILE *)stream); ++ return ret; ++} + + static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) + { +@@ -229,6 +238,7 @@ + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell_file = ftell_file_func; + pzlib_filefunc_def->zseek_file = fseek_file_func; ++ pzlib_filefunc_def->zflush_file = fflush_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; +@@ -241,6 +251,7 @@ + pzlib_filefunc_def->zwrite_file = fwrite_file_func; + pzlib_filefunc_def->ztell64_file = ftell64_file_func; + pzlib_filefunc_def->zseek64_file = fseek64_file_func; ++ pzlib_filefunc_def->zflush_file = fflush_file_func; + pzlib_filefunc_def->zclose_file = fclose_file_func; + pzlib_filefunc_def->zerror_file = ferror_file_func; + pzlib_filefunc_def->opaque = NULL; diff --git a/src/minizip/ioapi.c.orig b/src/minizip/ioapi.c.orig deleted file mode 100644 index 894fc83..0000000 --- a/src/minizip/ioapi.c.orig +++ /dev/null @@ -1,177 +0,0 @@ -/* ioapi.c -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant -*/ - -#include -#include -#include - -#include "zlib.h" -#include "ioapi.h" - - - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -voidpf ZCALLBACK fopen_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); - -uLong ZCALLBACK fread_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); - -uLong ZCALLBACK fwrite_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); - -long ZCALLBACK ftell_file_func OF(( - voidpf opaque, - voidpf stream)); - -long ZCALLBACK fseek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); - -int ZCALLBACK fclose_file_func OF(( - voidpf opaque, - voidpf stream)); - -int ZCALLBACK ferror_file_func OF(( - voidpf opaque, - voidpf stream)); - - -voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) - voidpf opaque; - const char* filename; - int mode; -{ - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen(filename, mode_fopen); - return file; -} - - -uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - void* buf; - uLong size; -{ - uLong ret; - ret = fread(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - - -uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - const void* buf; - uLong size; -{ - uLong ret; - ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - -long ZCALLBACK ftell_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - long ret; - ret = ftell((FILE *)stream); - return ret; -} - -long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) - voidpf opaque; - voidpf stream; - uLong offset; - int origin; -{ - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - fseek((FILE *)stream, offset, fseek_origin); - return ret; -} - -int ZCALLBACK fclose_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - int ret; - ret = fclose((FILE *)stream); - return ret; -} - -int ZCALLBACK ferror_file_func (opaque, stream) - voidpf opaque; - voidpf stream; -{ - int ret; - ret = ferror((FILE *)stream); - return ret; -} - -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; -{ - pzlib_filefunc_def->zopen_file = fopen_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell_file = ftell_file_func; - pzlib_filefunc_def->zseek_file = fseek_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; -} diff --git a/src/minizip/ioapi.h b/src/minizip/ioapi.h index 4dfb4a0..e4462b8 100644 --- a/src/minizip/ioapi.h +++ b/src/minizip/ioapi.h @@ -1,13 +1,112 @@ /* ioapi.h -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Version 1.00, September 10th, 2003 + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + Changes + + Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) + Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. + More if/def section may be needed to support other platforms + Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. + (but you should use iowin32.c for windows instead) - Copyright (C) 1998-2003 Gilles Vollant */ -#ifndef _ZLIBIOAPI_H -#define _ZLIBIOAPI_H +#ifndef _ZLIBIOAPI64_H +#define _ZLIBIOAPI64_H + +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) + + // Linux needs this to support file operation on files larger then 4+GB + // But might need better if/def to select just the platforms that needs them. + + #ifndef __USE_FILE_OFFSET64 + #define __USE_FILE_OFFSET64 + #endif + #ifndef __USE_LARGEFILE64 + #define __USE_LARGEFILE64 + #endif + #ifndef _LARGEFILE64_SOURCE + #define _LARGEFILE64_SOURCE + #endif + #ifndef _FILE_OFFSET_BIT + #define _FILE_OFFSET_BIT 64 + #endif + +#endif + +#include +#include +#include "zlib.h" + +#if defined(USE_FILE32API) +#define fopen64 fopen +#define ftello64 ftell +#define fseeko64 fseek +#else +#ifdef __FreeBSD__ +#define fopen64 fopen +#define ftello64 ftello +#define fseeko64 fseeko +#endif +#ifdef _MSC_VER + #define fopen64 fopen + #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) + #define ftello64 _ftelli64 + #define fseeko64 _fseeki64 + #else // old MSC + #define ftello64 ftell + #define fseeko64 fseek + #endif +#endif +#endif + +/* +#ifndef ZPOS64_T + #ifdef _WIN32 + #define ZPOS64_T fpos_t + #else + #include + #define ZPOS64_T uint64_t + #endif +#endif +*/ + +#ifdef HAVE_MINIZIP64_CONF_H +#include "mz64conf.h" +#endif + +/* a type choosen by DEFINE */ +#ifdef HAVE_64BIT_INT_CUSTOM +typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; +#else +#ifdef HAS_STDINT_H +#include "stdint.h" +typedef uint64_t ZPOS64_T; +#else + +/* Maximum unsigned 32-bit value used as placeholder for zip64 */ +#define MAXU32 0xffffffff + +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef unsigned __int64 ZPOS64_T; +#else +typedef unsigned long long int ZPOS64_T; +#endif +#endif +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif #define ZLIB_FILEFUNC_SEEK_CUR (1) @@ -23,61 +122,91 @@ #ifndef ZCALLBACK - -#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) -#define ZCALLBACK CALLBACK -#else -#define ZCALLBACK -#endif + #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) + #define ZCALLBACK CALLBACK + #else + #define ZCALLBACK + #endif #endif -#ifdef __cplusplus -extern "C" { -#endif -/* fixed missing define on some zlib (Lars Wendler) */ -#ifndef OF -#define OF(args) args -#endif -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); -typedef int (ZCALLBACK *flush_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +typedef int (ZCALLBACK *flush_file_func) OF((voidpf opaque, voidpf stream)); +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); + + +/* here is the "old" 32 bits structure structure */ typedef struct zlib_filefunc_def_s { open_file_func zopen_file; read_file_func zread_file; write_file_func zwrite_file; + flush_file_func zflush_file; tell_file_func ztell_file; seek_file_func zseek_file; - flush_file_func zflush_file; close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; } zlib_filefunc_def; +typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); +typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); +typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); +typedef struct zlib_filefunc64_def_s +{ + open64_file_func zopen64_file; + read_file_func zread_file; + write_file_func zwrite_file; + flush_file_func zflush_file; + tell64_file_func ztell64_file; + seek64_file_func zseek64_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + voidpf opaque; +} zlib_filefunc64_def; +void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); -#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) -#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) -#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) -#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) -#define ZFLUSH(filefunc,filestream) ((*((filefunc).zflush_file))((filefunc).opaque,filestream)) -#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) -#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) +/* now internal definition, only for zip.c and unzip.h */ +typedef struct zlib_filefunc64_32_def_s +{ + zlib_filefunc64_def zfile_func64; + open_file_func zopen32_file; + tell_file_func ztell32_file; + seek_file_func zseek32_file; +} zlib_filefunc64_32_def; +#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) +#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) +#define ZFLUSH64(filefunc,filestream) ((*((filefunc).zfile_func64.zflush_file)) ((filefunc).zfile_func64.opaque,filestream)) +//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) +//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) +#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) +#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) + +voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); +long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); +ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); + +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); + +#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) +#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) +#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) + #ifdef __cplusplus } #endif #endif - diff --git a/src/minizip/ioapi.h.diff b/src/minizip/ioapi.h.diff new file mode 100644 index 0000000..ddcec6c --- /dev/null +++ b/src/minizip/ioapi.h.diff @@ -0,0 +1,34 @@ +--- ioapi.h.orig 2012-01-17 03:51:31.000000000 +0100 ++++ ioapi.h 2014-05-24 13:27:22.516230485 +0200 +@@ -135,6 +135,7 @@ + typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); + typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); + typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); ++typedef int (ZCALLBACK *flush_file_func) OF((voidpf opaque, voidpf stream)); + typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); + typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); + +@@ -148,6 +149,7 @@ + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; ++ flush_file_func zflush_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; +@@ -164,6 +166,7 @@ + open64_file_func zopen64_file; + read_file_func zread_file; + write_file_func zwrite_file; ++ flush_file_func zflush_file; + tell64_file_func ztell64_file; + seek64_file_func zseek64_file; + close_file_func zclose_file; +@@ -186,6 +189,7 @@ + + #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) + #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) ++#define ZFLUSH64(filefunc,filestream) ((*((filefunc).zfile_func64.zflush_file)) ((filefunc).zfile_func64.opaque,filestream)) + //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) + //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) + #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) diff --git a/src/minizip/ioapi.h.orig b/src/minizip/ioapi.h.orig deleted file mode 100644 index bd29cb7..0000000 --- a/src/minizip/ioapi.h.orig +++ /dev/null @@ -1,75 +0,0 @@ -/* ioapi.h -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant -*/ - -#ifndef _ZLIBIOAPI_H -#define _ZLIBIOAPI_H - - -#define ZLIB_FILEFUNC_SEEK_CUR (1) -#define ZLIB_FILEFUNC_SEEK_END (2) -#define ZLIB_FILEFUNC_SEEK_SET (0) - -#define ZLIB_FILEFUNC_MODE_READ (1) -#define ZLIB_FILEFUNC_MODE_WRITE (2) -#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) - -#define ZLIB_FILEFUNC_MODE_EXISTING (4) -#define ZLIB_FILEFUNC_MODE_CREATE (8) - - -#ifndef ZCALLBACK - -#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) -#define ZCALLBACK CALLBACK -#else -#define ZCALLBACK -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); - -typedef struct zlib_filefunc_def_s -{ - open_file_func zopen_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell_file_func ztell_file; - seek_file_func zseek_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc_def; - - - -void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); - -#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) -#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) -#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) -#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) -#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) -#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/minizip/iowin32.c b/src/minizip/iowin32.c index 1afddaa..a46d96c 100644 --- a/src/minizip/iowin32.c +++ b/src/minizip/iowin32.c @@ -1,18 +1,17 @@ /* iowin32.c -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - This IO API version uses the Win32 API (for Microsoft Windows) + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Version 1.00, September 10th, 2003 + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt - Copyright (C) 1998-2003 Gilles Vollant */ #include -#ifndef _WIN32_WCE -#include -#else -//#include "celib.h" -#endif #include "zlib.h" #include "ioapi.h" @@ -26,40 +25,20 @@ #define INVALID_SET_FILE_POINTER ((DWORD)-1) #endif -voidpf ZCALLBACK win32_open_file_func OF(( - voidpf opaque, - const char* filename, - int mode)); -uLong ZCALLBACK win32_read_file_func OF(( - voidpf opaque, - voidpf stream, - void* buf, - uLong size)); +#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#define IOWIN32_USING_WINRT_API 1 +#endif +#endif -uLong ZCALLBACK win32_write_file_func OF(( - voidpf opaque, - voidpf stream, - const void* buf, - uLong size)); - -long ZCALLBACK win32_tell_file_func OF(( - voidpf opaque, - voidpf stream)); - -long ZCALLBACK win32_seek_file_func OF(( - voidpf opaque, - voidpf stream, - uLong offset, - int origin)); - -int ZCALLBACK win32_close_file_func OF(( - voidpf opaque, - voidpf stream)); - -int ZCALLBACK win32_error_file_func OF(( - voidpf opaque, - voidpf stream)); +voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); +uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); +uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); +ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream)); +long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); +int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream)); +int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream)); typedef struct { @@ -67,69 +46,163 @@ typedef struct int error; } WIN32FILE_IOWIN; -voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) - voidpf opaque; - const char* filename; - int mode; -{ - const char* mode_fopen = NULL; - DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; - HANDLE hFile = 0; - voidpf ret=NULL; - dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; +static void win32_translate_open_mode(int mode, + DWORD* lpdwDesiredAccess, + DWORD* lpdwCreationDisposition, + DWORD* lpdwShareMode, + DWORD* lpdwFlagsAndAttributes) +{ + *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) { - dwDesiredAccess = GENERIC_READ; - dwCreationDisposition = OPEN_EXISTING; - dwShareMode = FILE_SHARE_READ; + *lpdwDesiredAccess = GENERIC_READ; + *lpdwCreationDisposition = OPEN_EXISTING; + *lpdwShareMode = FILE_SHARE_READ; } - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) { - dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; - dwCreationDisposition = OPEN_EXISTING; + *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + *lpdwCreationDisposition = OPEN_EXISTING; } - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) + else if (mode & ZLIB_FILEFUNC_MODE_CREATE) { - dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; - dwCreationDisposition = CREATE_ALWAYS; + *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; + *lpdwCreationDisposition = CREATE_ALWAYS; } +} - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, - dwCreationDisposition, dwFlagsAndAttributes, NULL); +static voidpf win32_build_iowin(HANDLE hFile) +{ + voidpf ret=NULL; - if (hFile == INVALID_HANDLE_VALUE) - hFile = NULL; - - if (hFile != NULL) + if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) { WIN32FILE_IOWIN w32fiow; w32fiow.hf = hFile; w32fiow.error = 0; ret = malloc(sizeof(WIN32FILE_IOWIN)); + if (ret==NULL) CloseHandle(hFile); - else *((WIN32FILE_IOWIN*)ret) = w32fiow; + else + *((WIN32FILE_IOWIN*)ret) = w32fiow; } return ret; } +voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; -uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - void* buf; - uLong size; + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API +#ifdef UNICODE + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + { + WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; + MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); + hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } +#endif +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API + if ((filename!=NULL) && (dwDesiredAccess != 0)) + { + WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; + MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); + hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL); +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) +{ + const char* mode_fopen = NULL; + DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; + HANDLE hFile = NULL; + + win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); + +#ifdef IOWIN32_USING_WINRT_API +#ifdef UNICODE + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + { + WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; + MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); + hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); + } +#endif +#else + if ((filename!=NULL) && (dwDesiredAccess != 0)) + hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); +#endif + + return win32_build_iowin(hFile); +} + + +uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) { uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; + if (hFile != NULL) + { if (!ReadFile(hFile, buf, size, &ret, NULL)) { DWORD dwErr = GetLastError(); @@ -137,23 +210,21 @@ uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) dwErr = 0; ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; } + } return ret; } -uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) - voidpf opaque; - voidpf stream; - const void* buf; - uLong size; +uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) { uLong ret=0; HANDLE hFile = NULL; if (stream!=NULL) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - if (hFile !=NULL) + if (hFile != NULL) + { if (!WriteFile(hFile, buf, size, &ret, NULL)) { DWORD dwErr = GetLastError(); @@ -161,13 +232,32 @@ uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) dwErr = 0; ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; } + } return ret; } -long ZCALLBACK win32_tell_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) +{ +#ifdef IOWIN32_USING_WINRT_API + return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); +#else + LONG lHigh = pos.HighPart; + DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT); + BOOL fOk = TRUE; + if (dwNewPos == 0xFFFFFFFF) + if (GetLastError() != NO_ERROR) + fOk = FALSE; + if ((newPos != NULL) && (fOk)) + { + newPos->LowPart = dwNewPos; + newPos->HighPart = lHigh; + } + return fOk; +#endif +} + +long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) { long ret=-1; HANDLE hFile = NULL; @@ -175,24 +265,47 @@ long ZCALLBACK win32_tell_file_func (opaque, stream) hFile = ((WIN32FILE_IOWIN*)stream) -> hf; if (hFile != NULL) { - DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); - if (dwSet == INVALID_SET_FILE_POINTER) + LARGE_INTEGER pos; + pos.QuadPart = 0; + + if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) { DWORD dwErr = GetLastError(); ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; ret = -1; } else - ret=(long)dwSet; + ret=(long)pos.LowPart; } return ret; } -long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) - voidpf opaque; - voidpf stream; - uLong offset; - int origin; +ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) +{ + ZPOS64_T ret= (ZPOS64_T)-1; + HANDLE hFile = NULL; + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream)->hf; + + if (hFile) + { + LARGE_INTEGER pos; + pos.QuadPart = 0; + + if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = (ZPOS64_T)-1; + } + else + ret=pos.QuadPart; + } + return ret; +} + + +long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin) { DWORD dwMoveMethod=0xFFFFFFFF; HANDLE hFile = NULL; @@ -216,8 +329,9 @@ long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) if (hFile != NULL) { - DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); - if (dwSet == INVALID_SET_FILE_POINTER) + LARGE_INTEGER pos; + pos.QuadPart = offset; + if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) { DWORD dwErr = GetLastError(); ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; @@ -229,9 +343,46 @@ long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) return ret; } -int ZCALLBACK win32_close_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) +{ + DWORD dwMoveMethod=0xFFFFFFFF; + HANDLE hFile = NULL; + long ret=-1; + + if (stream!=NULL) + hFile = ((WIN32FILE_IOWIN*)stream)->hf; + + switch (origin) + { + case ZLIB_FILEFUNC_SEEK_CUR : + dwMoveMethod = FILE_CURRENT; + break; + case ZLIB_FILEFUNC_SEEK_END : + dwMoveMethod = FILE_END; + break; + case ZLIB_FILEFUNC_SEEK_SET : + dwMoveMethod = FILE_BEGIN; + break; + default: return -1; + } + + if (hFile) + { + LARGE_INTEGER pos; + pos.QuadPart = offset; + if (!MySetFilePointerEx(hFile, pos, NULL, FILE_CURRENT)) + { + DWORD dwErr = GetLastError(); + ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; + ret = -1; + } + else + ret=0; + } + return ret; +} + +int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) { int ret=-1; @@ -249,9 +400,7 @@ int ZCALLBACK win32_close_file_func (opaque, stream) return ret; } -int ZCALLBACK win32_error_file_func (opaque, stream) - voidpf opaque; - voidpf stream; +int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) { int ret=-1; if (stream!=NULL) @@ -261,8 +410,7 @@ int ZCALLBACK win32_error_file_func (opaque, stream) return ret; } -void fill_win32_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; +void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = win32_open_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func; @@ -271,5 +419,43 @@ void fill_win32_filefunc (pzlib_filefunc_def) pzlib_filefunc_def->zseek_file = win32_seek_file_func; pzlib_filefunc_def->zclose_file = win32_close_file_func; pzlib_filefunc_def->zerror_file = win32_error_file_func; - pzlib_filefunc_def->opaque=NULL; + pzlib_filefunc_def->opaque = NULL; +} + +void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = win32_open64_file_func; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; + pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; +} + + +void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; + pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; +} + + +void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) +{ + pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; + pzlib_filefunc_def->zread_file = win32_read_file_func; + pzlib_filefunc_def->zwrite_file = win32_write_file_func; + pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; + pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; + pzlib_filefunc_def->zclose_file = win32_close_file_func; + pzlib_filefunc_def->zerror_file = win32_error_file_func; + pzlib_filefunc_def->opaque = NULL; } diff --git a/src/minizip/iowin32.h b/src/minizip/iowin32.h index c0ebd50..0ca0969 100644 --- a/src/minizip/iowin32.h +++ b/src/minizip/iowin32.h @@ -1,10 +1,14 @@ /* iowin32.h -- IO base function header for compress/uncompress .zip - files using zlib + zip or unzip API - This IO API version uses the Win32 API (for Microsoft Windows) + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Version 1.00, September 10th, 2003 + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt - Copyright (C) 1998-2003 Gilles Vollant */ #include @@ -15,6 +19,9 @@ extern "C" { #endif void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); +void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); +void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); +void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); #ifdef __cplusplus } diff --git a/src/minizip/mztools.c b/src/minizip/mztools.c index a09bfb7..078c190 100644 --- a/src/minizip/mztools.c +++ b/src/minizip/mztools.c @@ -1,287 +1,289 @@ -/* - Additional tools for Minizip - Code: Xavier Roche '2004 - License: Same as ZLIB (www.gzip.org) -*/ - -/* Code */ -#include -#ifndef _WIN32_WCE -#include -#include -#else +/* + Additional tools for Minizip + Code: Xavier Roche '2004 + License: Same as ZLIB (www.gzip.org) +*/ + +/* Code */ #include -#include -#include "celib.h" -#endif -#include "zlib.h" -#include "unzip.h" - -#define READ_8(adr) ((unsigned char)*(adr)) -#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) -#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) - -#define WRITE_8(buff, n) do { \ - *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ -} while(0) -#define WRITE_16(buff, n) do { \ - WRITE_8((unsigned char*)(buff), n); \ - WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ -} while(0) -#define WRITE_32(buff, n) do { \ - WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ - WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ -} while(0) - -extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) -const char* file; -const char* fileOut; -const char* fileOutTmp; -uLong* nRecovered; -uLong* bytesRecovered; -{ - int err = Z_OK; - FILE* fpZip = fopen(file, "rb"); - FILE* fpOut = fopen(fileOut, "wb"); - FILE* fpOutCD = fopen(fileOutTmp, "wb"); - if (fpZip != NULL && fpOut != NULL) { - int entries = 0; - uLong totalBytes = 0; - char header[30]; - char filename[1024]; - char extra[1024]; - int offset = 0; - int offsetCD = 0; - while ( fread(header, 1, 30, fpZip) == 30 ) { - int currentOffset = offset; - - /* File entry */ - if (READ_32(header) == 0x04034b50) { - unsigned int version = READ_16(header + 4); - unsigned int gpflag = READ_16(header + 6); - unsigned int method = READ_16(header + 8); - unsigned int filetime = READ_16(header + 10); - unsigned int filedate = READ_16(header + 12); - unsigned int crc = READ_32(header + 14); /* crc */ - unsigned int cpsize = READ_32(header + 18); /* compressed size */ - unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ - unsigned int fnsize = READ_16(header + 26); /* file name length */ - unsigned int extsize = READ_16(header + 28); /* extra field length */ - filename[0] = extra[0] = '\0'; - - /* Header */ - if (fwrite(header, 1, 30, fpOut) == 30) { - offset += 30; - } else { - err = Z_ERRNO; - break; - } - - /* Filename */ - if (fnsize > 0) { - if (fnsize < sizeof(filename) && fread(filename, 1, fnsize, fpZip) == fnsize) { - if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { - offset += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (extsize < sizeof(extra) && fread(extra, 1, extsize, fpZip) == extsize) { - if (fwrite(extra, 1, extsize, fpOut) == extsize) { - offset += extsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } - - /* Data */ - { - int dataSize = cpsize; - if (dataSize == 0) { - dataSize = uncpsize; - } - if (dataSize > 0) { - char* data = malloc(dataSize); - if (data != NULL) { - if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { - if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { - offset += dataSize; - totalBytes += dataSize; - } else { - err = Z_ERRNO; - } - } else { - err = Z_ERRNO; - } - free(data); - if (err != Z_OK) { - break; - } - } else { - err = Z_MEM_ERROR; - break; - } - } - } - - /* Central directory entry */ - { - char header[46]; - char* comment = ""; - int comsize = (int) strlen(comment); - WRITE_32(header, 0x02014b50); - WRITE_16(header + 4, version); - WRITE_16(header + 6, version); - WRITE_16(header + 8, gpflag); - WRITE_16(header + 10, method); - WRITE_16(header + 12, filetime); - WRITE_16(header + 14, filedate); - WRITE_32(header + 16, crc); - WRITE_32(header + 20, cpsize); - WRITE_32(header + 24, uncpsize); - WRITE_16(header + 28, fnsize); - WRITE_16(header + 30, extsize); - WRITE_16(header + 32, comsize); - WRITE_16(header + 34, 0); /* disk # */ - WRITE_16(header + 36, 0); /* int attrb */ - WRITE_32(header + 38, 0); /* ext attrb */ - WRITE_32(header + 42, currentOffset); - /* Header */ - if (fwrite(header, 1, 46, fpOutCD) == 46) { - offsetCD += 46; - - /* Filename */ - if (fnsize > 0) { - if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { - offsetCD += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { - offsetCD += extsize; - } else { - err = Z_ERRNO; - break; - } - } - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { - offsetCD += comsize; - } else { - err = Z_ERRNO; - break; - } - } - - - } else { - err = Z_ERRNO; - break; - } - } - - /* Success */ - entries++; - - } else { - break; - } - } - - /* Final central directory */ - { - int entriesZip = entries; - char header[22]; - char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; - int comsize = (int) strlen(comment); - if (entriesZip > 0xffff) { - entriesZip = 0xffff; - } - WRITE_32(header, 0x06054b50); - WRITE_16(header + 4, 0); /* disk # */ - WRITE_16(header + 6, 0); /* disk # */ - WRITE_16(header + 8, entriesZip); /* hack */ - WRITE_16(header + 10, entriesZip); /* hack */ - WRITE_32(header + 12, offsetCD); /* size of CD */ - WRITE_32(header + 16, offset); /* offset to CD */ - WRITE_16(header + 20, comsize); /* comment */ - - /* Header */ - if (fwrite(header, 1, 22, fpOutCD) == 22) { - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { - err = Z_ERRNO; - } - } - - } else { - err = Z_ERRNO; - } - } - - /* Final merge (file + central directory) */ - fclose(fpOutCD); - if (err == Z_OK) { - fpOutCD = fopen(fileOutTmp, "rb"); - if (fpOutCD != NULL) { - int nRead; - char buffer[8192]; - while ( (nRead = fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { - if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { - err = Z_ERRNO; - break; - } - } - fclose(fpOutCD); - } - } - - /* Close */ - fclose(fpZip); - fclose(fpOut); - - /* Wipe temporary file */ - (void)remove(fileOutTmp); - - /* Number of recovered entries */ - if (err == Z_OK) { - if (nRecovered != NULL) { - *nRecovered = entries; - } - if (bytesRecovered != NULL) { - *bytesRecovered = totalBytes; - } - } - } else { - err = Z_STREAM_ERROR; - } - return err; -} +#include +#include +#include "zlib.h" +#include "unzip.h" +#include "mztools.h" + +#define READ_8(adr) ((unsigned char)*(adr)) +#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) +#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) + +#define WRITE_8(buff, n) do { \ + *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ +} while(0) +#define WRITE_16(buff, n) do { \ + WRITE_8((unsigned char*)(buff), n); \ + WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ +} while(0) +#define WRITE_32(buff, n) do { \ + WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ + WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ +} while(0) + +int ZEXPORT unzRepair(const char* file, const char* fileOut, + const char* fileOutTmp, uLong* nRecovered, + uLong* bytesRecovered) +{ + int err = Z_OK; + FILE* fpZip = fopen(file, "rb"); + FILE* fpOut = fopen(fileOut, "wb"); + FILE* fpOutCD = fopen(fileOutTmp, "wb"); + if (fpZip != NULL && fpOut != NULL) { + int entries = 0; + uLong totalBytes = 0; + char header[30]; + char filename[1024]; + char extra[1024]; + int offset = 0; + int offsetCD = 0; + while ( fread(header, 1, 30, fpZip) == 30 ) { + int currentOffset = offset; + + /* File entry */ + if (READ_32(header) == 0x04034b50) { + unsigned int version = READ_16(header + 4); + unsigned int gpflag = READ_16(header + 6); + unsigned int method = READ_16(header + 8); + unsigned int filetime = READ_16(header + 10); + unsigned int filedate = READ_16(header + 12); + unsigned int crc = READ_32(header + 14); /* crc */ + unsigned int cpsize = READ_32(header + 18); /* compressed size */ + unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ + unsigned int fnsize = READ_16(header + 26); /* file name length */ + unsigned int extsize = READ_16(header + 28); /* extra field length */ + filename[0] = extra[0] = '\0'; + + /* Header */ + if (fwrite(header, 1, 30, fpOut) == 30) { + offset += 30; + } else { + err = Z_ERRNO; + break; + } + + /* Filename */ + if (fnsize > 0) { + if (fnsize < sizeof(filename)) { + if (fread(filename, 1, fnsize, fpZip) == fnsize) { + if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { + offset += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (extsize < sizeof(extra)) { + if (fread(extra, 1, extsize, fpZip) == extsize) { + if (fwrite(extra, 1, extsize, fpOut) == extsize) { + offset += extsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_ERRNO; + break; + } + } + + /* Data */ + { + int dataSize = cpsize; + if (dataSize == 0) { + dataSize = uncpsize; + } + if (dataSize > 0) { + char* data = malloc(dataSize); + if (data != NULL) { + if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { + if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { + offset += dataSize; + totalBytes += dataSize; + } else { + err = Z_ERRNO; + } + } else { + err = Z_ERRNO; + } + free(data); + if (err != Z_OK) { + break; + } + } else { + err = Z_MEM_ERROR; + break; + } + } + } + + /* Central directory entry */ + { + char header[46]; + const char* comment = ""; + const size_t comsize = strlen(comment); + WRITE_32(header, 0x02014b50); + WRITE_16(header + 4, version); + WRITE_16(header + 6, version); + WRITE_16(header + 8, gpflag); + WRITE_16(header + 10, method); + WRITE_16(header + 12, filetime); + WRITE_16(header + 14, filedate); + WRITE_32(header + 16, crc); + WRITE_32(header + 20, cpsize); + WRITE_32(header + 24, uncpsize); + WRITE_16(header + 28, fnsize); + WRITE_16(header + 30, extsize); + WRITE_16(header + 32, comsize); + WRITE_16(header + 34, 0); /* disk # */ + WRITE_16(header + 36, 0); /* int attrb */ + WRITE_32(header + 38, 0); /* ext attrb */ + WRITE_32(header + 42, currentOffset); + /* Header */ + if (fwrite(header, 1, 46, fpOutCD) == 46) { + offsetCD += 46; + + /* Filename */ + if (fnsize > 0) { + if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { + offsetCD += fnsize; + } else { + err = Z_ERRNO; + break; + } + } else { + err = Z_STREAM_ERROR; + break; + } + + /* Extra field */ + if (extsize > 0) { + if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { + offsetCD += extsize; + } else { + err = Z_ERRNO; + break; + } + } + + /* Comment field */ + if (comsize > 0) { + if (fwrite(comment, 1, comsize, fpOutCD) == comsize) { + offsetCD += comsize; + } else { + err = Z_ERRNO; + break; + } + } + + + } else { + err = Z_ERRNO; + break; + } + } + + /* Success */ + entries++; + + } else { + break; + } + } + + /* Final central directory */ + { + int entriesZip = entries; + char header[22]; + const char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; + const size_t comsize = strlen(comment); + if (entriesZip > 0xffff) { + entriesZip = 0xffff; + } + WRITE_32(header, 0x06054b50); + WRITE_16(header + 4, 0); /* disk # */ + WRITE_16(header + 6, 0); /* disk # */ + WRITE_16(header + 8, entriesZip); /* hack */ + WRITE_16(header + 10, entriesZip); /* hack */ + WRITE_32(header + 12, offsetCD); /* size of CD */ + WRITE_32(header + 16, offset); /* offset to CD */ + WRITE_16(header + 20, comsize); /* comment */ + + /* Header */ + if (fwrite(header, 1, 22, fpOutCD) == 22) { + + /* Comment field */ + if (comsize > 0) { + if (fwrite(comment, 1, comsize, fpOutCD) != comsize) { + err = Z_ERRNO; + } + } + + } else { + err = Z_ERRNO; + } + } + + /* Final merge (file + central directory) */ + fclose(fpOutCD); + if (err == Z_OK) { + fpOutCD = fopen(fileOutTmp, "rb"); + if (fpOutCD != NULL) { + int nRead; + char buffer[8192]; + while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { + if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { + err = Z_ERRNO; + break; + } + } + fclose(fpOutCD); + } + } + + /* Close */ + fclose(fpZip); + fclose(fpOut); + + /* Wipe temporary file */ + (void)remove(fileOutTmp); + + /* Number of recovered entries */ + if (err == Z_OK) { + if (nRecovered != NULL) { + *nRecovered = entries; + } + if (bytesRecovered != NULL) { + *bytesRecovered = totalBytes; + } + } + } else { + err = Z_STREAM_ERROR; + } + return err; +} diff --git a/src/minizip/mztools.h b/src/minizip/mztools.h index eee78dc..a49a426 100644 --- a/src/minizip/mztools.h +++ b/src/minizip/mztools.h @@ -17,15 +17,21 @@ extern "C" { #include "unzip.h" -/* Repair a ZIP file (missing central directory) +/* Repair a ZIP file (missing central directory) file: file to recover fileOut: output file after recovery fileOutTmp: temporary file name used for recovery */ -extern int ZEXPORT unzRepair(const char* file, - const char* fileOut, - const char* fileOutTmp, +extern int ZEXPORT unzRepair(const char* file, + const char* fileOut, + const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered); + +#ifdef __cplusplus +} +#endif + + #endif diff --git a/src/minizip/unzip.c b/src/minizip/unzip.c index 1452a54..9093504 100644 --- a/src/minizip/unzip.c +++ b/src/minizip/unzip.c @@ -1,49 +1,77 @@ /* unzip.c -- IO for uncompress .zip files using zlib - Version 1.00, September 10th, 2003 + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Copyright (C) 1998-2003 Gilles Vollant + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - Read unzip.h for more info -*/ + Modifications of Unzip for Zip64 + Copyright (C) 2007-2008 Even Rouault + + Modifications for Zip64 support on both zip and unzip + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + + ------------------------------------------------------------------------------------ + Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of + compatibility with older software. The following is from the original crypt.c. + Code woven in by Terry Thorsen 1/2003. -/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of -compatibility with older software. The following is from the original crypt.c. Code -woven in by Terry Thorsen 1/2003. -*/ -/* Copyright (c) 1990-2000 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in zip.h) for terms of use. If, for some reason, all these files are missing, the Info-ZIP license also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html -*/ -/* - crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] + + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] The encryption/decryption parts of this source code (as opposed to the non-echoing password parts) were originally written in Europe. The whole source package can be freely distributed, including from the USA. (Prior to January 2000, re-export from the US was a violation of US law.) - */ -/* - This encryption code is a direct transcription of the algorithm from + This encryption code is a direct transcription of the algorithm from Roger Schlafly, described by Phil Katz in the file appnote.txt. This file (appnote.txt) is distributed with the PKZIP program (even in the version without encryption capabilities). - */ + + ------------------------------------------------------------------------------------ + + Changes in unzip.c + + 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos + 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* + 2007-2008 - Even Rouault - Remove old C style function prototypes + 2007-2008 - Even Rouault - Add unzip support for ZIP64 + + Copyright (C) 2007-2008 Even Rouault + + + Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). + Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G + should only read the compressed/uncompressed size from the Zip64 format if + the size from normal header was 0xFFFFFFFF + Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant + Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) + Patch created by Daniel Borca + + Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer + + Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson + +*/ -#ifndef _WIN32_WCE #include #include -#else -#include -#include "celib.h" -#endif #include +#ifndef NOUNCRYPT + #define NOUNCRYPT +#endif + #include "zlib.h" #include "unzip.h" @@ -91,16 +119,14 @@ woven in by Terry Thorsen 1/2003. #define SIZEZIPLOCALHEADER (0x1e) - - const char unz_copyright[] = - " unzip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; + " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; /* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info_internal_s +typedef struct unz_file_info64_internal_s { - uLong offset_curfile;/* relative offset of local header 4 bytes */ -} unz_file_info_internal; + ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ +} unz_file_info64_internal; /* file_in_zip_read_info_s contain internal information about a file in zipfile, @@ -110,52 +136,61 @@ typedef struct char *read_buffer; /* internal buffer for compressed data */ z_stream stream; /* zLib stream structure for inflate */ - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ +#ifdef HAVE_BZIP2 + bz_stream bstream; /* bzLib stream structure for bziped */ +#endif + + ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ uLong stream_initialised; /* flag set if stream structure is initialised*/ - uLong offset_local_extrafield;/* offset of the local extra field */ + ZPOS64_T offset_local_extrafield;/* offset of the local extra field */ uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ + ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/ + ZPOS64_T total_out_64; uLong crc32; /* crc32 of all data uncompressed */ uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - zlib_filefunc_def z_filefunc; + ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ + ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + zlib_filefunc64_32_def z_filefunc; voidpf filestream; /* io structore of the zipfile */ uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ int raw; -} file_in_zip_read_info_s; +} file_in_zip64_read_info_s; -/* unz_s contain internal information about the zipfile +/* unz64_s contain internal information about the zipfile */ typedef struct { - zlib_filefunc_def z_filefunc; + zlib_filefunc64_32_def z_filefunc; + int is64bitOpenFunction; voidpf filestream; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ + unz_global_info64 gi; /* public global information */ + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + ZPOS64_T num_file; /* number of the current file in the zipfile*/ + ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ + ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ + ZPOS64_T central_pos; /* position of the beginning of the central dir*/ - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with + ZPOS64_T size_central_dir; /* size of the central directory */ + ZPOS64_T offset_central_dir; /* offset of start of central directory with respect to the starting disk number */ - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ - file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + unz_file_info64 cur_file_info; /* public info about the current file in zip*/ + unz_file_info64_internal cur_file_info_internal; /* private info about it*/ + file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current file if we are decompressing it */ int encrypted; + + int isZip64; + # ifndef NOUNCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const unsigned long* pcrc_32_tab; + const z_crc_t* pcrc_32_tab; # endif -} unz_s; +} unz64_s; #ifndef NOUNCRYPT @@ -169,18 +204,15 @@ typedef struct */ -local int unzlocal_getByte OF(( - const zlib_filefunc_def* pzlib_filefunc_def, +local int unz64local_getByte OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); -local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - int *pi; +local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) { unsigned char c; - int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); if (err==1) { *pi = (int)c; @@ -188,7 +220,7 @@ local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) } else { - if (ZERROR(*pzlib_filefunc_def,filestream)) + if (ZERROR64(*pzlib_filefunc_def,filestream)) return UNZ_ERRNO; else return UNZ_EOF; @@ -199,26 +231,25 @@ local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ -local int unzlocal_getShort OF(( - const zlib_filefunc_def* pzlib_filefunc_def, +local int unz64local_getShort OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); -local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; +local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX) { uLong x ; - int i; + int i = 0; int err; - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((uLong)i)<<8; if (err==UNZ_OK) *pX = x; @@ -227,33 +258,32 @@ local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) return err; } -local int unzlocal_getLong OF(( - const zlib_filefunc_def* pzlib_filefunc_def, +local int unz64local_getLong OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); -local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; +local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + uLong *pX) { uLong x ; - int i; + int i = 0; int err; - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((uLong)i)<<8; if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<16; + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((uLong)i)<<16; if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<24; if (err==UNZ_OK) @@ -263,11 +293,60 @@ local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) return err; } +local int unz64local_getLong64 OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + ZPOS64_T *pX)); + + +local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream, + ZPOS64_T *pX) +{ + ZPOS64_T x ; + int i = 0; + int err; + + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (ZPOS64_T)i; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<8; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<16; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<24; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<32; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<40; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<48; + + if (err==UNZ_OK) + err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); + x |= ((ZPOS64_T)i)<<56; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} /* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; +local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) { for (;;) { @@ -308,10 +387,10 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2) (like 1 on Unix, 2 on Windows) */ -extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; +extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, + const char* fileName2, + int iCaseSensitivity) + { if (iCaseSensitivity==0) iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; @@ -330,25 +409,20 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local uLong unzlocal_SearchCentralDir OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream)); - -local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; +local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); +local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; - if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) return 0; - uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); if (uMaxBack>uSizeFile) uMaxBack = uSizeFile; @@ -360,7 +434,8 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) uBackRead = 4; while (uBackReaduMaxBack) uBackRead = uMaxBack; @@ -369,11 +444,11 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) uReadPos = uSizeFile-uBackRead ; uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) break; - if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; for (i=(int)uReadSize-3; (i--)>0;) @@ -391,6 +466,112 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) return uPosFound; } + +/* + Locate the Central directory 64 of a zipfile (at the end, just before + the global comment) +*/ +local ZPOS64_T unz64local_SearchCentralDir64 OF(( + const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream)); + +local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, + voidpf filestream) +{ + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; + uLong uL; + ZPOS64_T relativeOffset; + + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + if (uPosFound == 0) + return 0; + + /* Zip64 end of central directory locator */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature, already checked */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + + /* number of the disk with the start of the zip64 end of central directory */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + if (uL != 0) + return 0; + + /* relative offset of the zip64 end of central directory record */ + if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) + return 0; + + /* total number of disks */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + if (uL != 1) + return 0; + + /* Goto end of central directory record */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature */ + if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) + return 0; + + if (uL != 0x06064b50) + return 0; + + return relativeOffset; +} + /* Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer @@ -400,19 +581,20 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) Else, the return value is a unzFile Handle, usable with other function of this unzip package. */ -extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) - const char *path; - zlib_filefunc_def* pzlib_filefunc_def; +local unzFile unzOpenInternal (const void *path, + zlib_filefunc64_32_def* pzlib_filefunc64_32_def, + int is64bitOpenFunction) { - unz_s us; - unz_s *s; - uLong central_pos,uL; + unz64_s us; + unz64_s *s; + ZPOS64_T central_pos; + uLong uL; uLong number_disk; /* number of the current dist, used for spaning ZIP, unsupported, always 0*/ uLong number_disk_with_CD; /* number the the disk with central dir, used for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in + ZPOS64_T number_entry_CD; /* total number of entries in the central dir (same than number_entry on nospan) */ @@ -421,63 +603,137 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) if (unz_copyright[0]!=' ') return NULL; - if (pzlib_filefunc_def==NULL) - fill_fopen_filefunc(&us.z_filefunc); + us.z_filefunc.zseek32_file = NULL; + us.z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); else - us.z_filefunc = *pzlib_filefunc_def; + us.z_filefunc = *pzlib_filefunc64_32_def; + us.is64bitOpenFunction = is64bitOpenFunction; - us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, + + + us.filestream = ZOPEN64(us.z_filefunc, path, ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING); if (us.filestream==NULL) return NULL; - central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); - if (central_pos==0) - err=UNZ_ERRNO; + central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); + if (central_pos) + { + uLong uS; + ZPOS64_T uL64; - if (ZSEEK(us.z_filefunc, us.filestream, + us.isZip64 = 1; + + if (ZSEEK64(us.z_filefunc, us.filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; - /* the signature, already checked */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; + /* the signature, already checked */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; - /* number of this disk */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; + /* size of zip64 end of central directory record */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK) + err=UNZ_ERRNO; - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; + /* version made by */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) + err=UNZ_ERRNO; - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; + /* version needed to extract */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) + err=UNZ_ERRNO; - /* total number of entries in the central dir */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; + /* number of this disk */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; + /* number of the disk with the start of the central directory */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; - /* size of the central directory */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; + /* total number of entries in the central directory on this disk */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; - /* offset of start of central directory with respect to the + /* total number of entries in the central directory */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the starting disk number */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; + if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; - /* zipfile comment length */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; + us.gi.size_comment = 0; + } + else + { + central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); + if (central_pos==0) + err=UNZ_ERRNO; + + us.isZip64 = 0; + + if (ZSEEK64(us.z_filefunc, us.filestream, + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + us.gi.number_entry = uL; + + /* total number of entries in the central dir */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + number_entry_CD = uL; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + us.size_central_dir = uL; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + us.offset_central_dir = uL; + + /* zipfile comment length */ + if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + } if ((central_pospfile_in_zip_read!=NULL) unzCloseCurrentFile(file); - ZCLOSE(s->z_filefunc, s->filestream); + ZCLOSE64(s->z_filefunc, s->filestream); TRYFREE(s); return UNZ_OK; } @@ -535,28 +825,34 @@ extern int ZEXPORT unzClose (file) Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; +extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) { - unz_s* s; + unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; *pglobal_info=s->gi; return UNZ_OK; } - +extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) +{ + unz64_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + /* to do : check if number_entry is not truncated */ + pglobal_info32->number_entry = (uLong)s->gi.number_entry; + pglobal_info32->size_comment = s->gi.size_comment; + return UNZ_OK; +} /* Translate date/time from Dos format to tm_unz (readable more easilty) */ -local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; +local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) { - uLong uDate; - uDate = (uLong)(ulDosDate>>16); + ZPOS64_T uDate; + uDate = (ZPOS64_T)(ulDosDate>>16); ptm->tm_mday = (uInt)(uDate&0x1f) ; ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; @@ -569,9 +865,9 @@ local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) /* Get Info about the current file in the zipfile, with internal only info */ -local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal +local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info64 *pfile_info, + unz_file_info64_internal *pfile_info_internal, char *szFileName, uLong fileNameBufferSize, @@ -580,33 +876,29 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, char *szComment, uLong commentBufferSize)); -local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; +local int unz64local_GetCurrentFileInfoInternal (unzFile file, + unz_file_info64 *pfile_info, + unz_file_info64_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize) { - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; + unz64_s* s; + unz_file_info64 file_info; + unz_file_info64_internal file_info_internal; int err=UNZ_OK; uLong uMagic; long lSeek=0; + uLong uL; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; - if (ZSEEK(s->z_filefunc, s->filestream, + s=(unz64_s*)file; + if (ZSEEK64(s->z_filefunc, s->filestream, s->pos_in_central_dir+s->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET)!=0) err=UNZ_ERRNO; @@ -614,57 +906,63 @@ local int unzlocal_GetCurrentFileInfoInternal (file, /* we check the magic */ if (err==UNZ_OK) - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + { + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x02014b50) err=UNZ_BADZIPFILE; + } - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) err=UNZ_ERRNO; - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + file_info.compressed_size = uL; + + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + file_info.uncompressed_size = uL; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + // relative offset of local header + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) err=UNZ_ERRNO; + file_info_internal.offset_curfile = uL; lSeek+=file_info.size_filename; if ((err==UNZ_OK) && (szFileName!=NULL)) @@ -679,34 +977,106 @@ local int unzlocal_GetCurrentFileInfoInternal (file, uSizeRead = fileNameBufferSize; if ((file_info.size_filename>0) && (fileNameBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) + if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek -= uSizeRead; } - + // Read extrafield if ((err==UNZ_OK) && (extraField!=NULL)) { - uLong uSizeRead ; + ZPOS64_T uSizeRead ; if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + { + if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; + } + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) + if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead) err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; + + lSeek += file_info.size_file_extra - (uLong)uSizeRead; } else - lSeek+=file_info.size_file_extra; + lSeek += file_info.size_file_extra; + if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) + { + uLong acc = 0; + + // since lSeek now points to after the extra field we need to move back + lSeek -= file_info.size_file_extra; + + if (lSeek!=0) + { + if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + while(acc < file_info.size_file_extra) + { + uLong headerId; + uLong dataSize; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) + err=UNZ_ERRNO; + + if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK) + err=UNZ_ERRNO; + + /* ZIP64 extra fields */ + if (headerId == 0x0001) + { + uLong uL; + + if(file_info.uncompressed_size == MAXU32) + { + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info.compressed_size == MAXU32) + { + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info_internal.offset_curfile == MAXU32) + { + /* Relative Header offset */ + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + } + + if(file_info.disk_num_start == MAXU32) + { + /* Disk Start Number */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) + err=UNZ_ERRNO; + } + + } + else + { + if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) + err=UNZ_ERRNO; + } + + acc += 2 + 2 + dataSize; + } + } + if ((err==UNZ_OK) && (szComment!=NULL)) { uLong uSizeRead ; @@ -719,18 +1089,22 @@ local int unzlocal_GetCurrentFileInfoInternal (file, uSizeRead = commentBufferSize; if (lSeek!=0) - if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) + { + if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) lSeek=0; else err=UNZ_ERRNO; + } + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) + if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; lSeek+=file_info.size_file_comment - uSizeRead; } else lSeek+=file_info.size_file_comment; + if ((err==UNZ_OK) && (pfile_info!=NULL)) *pfile_info=file_info; @@ -747,41 +1121,70 @@ local int unzlocal_GetCurrentFileInfoInternal (file, No preparation of the structure is needed return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; +extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, + unz_file_info64 * pfile_info, + char * szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char* szComment, uLong commentBufferSize) { - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, szFileName,fileNameBufferSize, extraField,extraFieldBufferSize, szComment,commentBufferSize); } +extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, + unz_file_info * pfile_info, + char * szFileName, uLong fileNameBufferSize, + void *extraField, uLong extraFieldBufferSize, + char* szComment, uLong commentBufferSize) +{ + int err; + unz_file_info64 file_info64; + err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); + if ((err==UNZ_OK) && (pfile_info != NULL)) + { + pfile_info->version = file_info64.version; + pfile_info->version_needed = file_info64.version_needed; + pfile_info->flag = file_info64.flag; + pfile_info->compression_method = file_info64.compression_method; + pfile_info->dosDate = file_info64.dosDate; + pfile_info->crc = file_info64.crc; + + pfile_info->size_filename = file_info64.size_filename; + pfile_info->size_file_extra = file_info64.size_file_extra; + pfile_info->size_file_comment = file_info64.size_file_comment; + + pfile_info->disk_num_start = file_info64.disk_num_start; + pfile_info->internal_fa = file_info64.internal_fa; + pfile_info->external_fa = file_info64.external_fa; + + pfile_info->tmu_date = file_info64.tmu_date, + + + pfile_info->compressed_size = (uLong)file_info64.compressed_size; + pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; + + } + return err; +} /* Set the current file of the zipfile to the first file. return UNZ_OK if there is no problem */ -extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; +extern int ZEXPORT unzGoToFirstFile (unzFile file) { int err=UNZ_OK; - unz_s* s; + unz64_s* s; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; s->pos_in_central_dir=s->offset_central_dir; s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); @@ -793,25 +1196,24 @@ extern int ZEXPORT unzGoToFirstFile (file) return UNZ_OK if there is no problem return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. */ -extern int ZEXPORT unzGoToNextFile (file) - unzFile file; +extern int ZEXPORT unzGoToNextFile (unzFile file) { - unz_s* s; + unz64_s* s; int err; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; - if (s->gi.number_entry != 0xffff) // 2^16 files overflow hack - if (s->num_file+1==s->gi.number_entry) + if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ + if (s->num_file+1==s->gi.number_entry) return UNZ_END_OF_LIST_OF_FILE; s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); s->current_file_ok = (err == UNZ_OK); @@ -821,27 +1223,24 @@ extern int ZEXPORT unzGoToNextFile (file) /* Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzipStringFileNameCompare + For the iCaseSensitivity signification, see unzStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */ -extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; +extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) { - unz_s* s; + unz64_s* s; int err; /* We remember the 'current' position in the file so that we can jump * back there if we fail. */ - unz_file_info cur_file_infoSaved; - unz_file_info_internal cur_file_info_internalSaved; - uLong num_fileSaved; - uLong pos_in_central_dirSaved; + unz_file_info64 cur_file_infoSaved; + unz_file_info64_internal cur_file_info_internalSaved; + ZPOS64_T num_fileSaved; + ZPOS64_T pos_in_central_dirSaved; if (file==NULL) @@ -850,7 +1249,7 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; @@ -865,7 +1264,7 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) while (err == UNZ_OK) { char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - err = unzGetCurrentFileInfo(file,NULL, + err = unzGetCurrentFileInfo64(file,NULL, szCurrentFileName,sizeof(szCurrentFileName)-1, NULL,0,NULL,0); if (err == UNZ_OK) @@ -901,20 +1300,18 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) /* typedef struct unz_file_pos_s { - uLong pos_in_zip_directory; // offset in file - uLong num_of_file; // # of file + ZPOS64_T pos_in_zip_directory; // offset in file + ZPOS64_T num_of_file; // # of file } unz_file_pos; */ -extern int ZEXPORT unzGetFilePos(file, file_pos) - unzFile file; - unz_file_pos* file_pos; +extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) { - unz_s* s; + unz64_s* s; if (file==NULL || file_pos==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_END_OF_LIST_OF_FILE; @@ -924,23 +1321,35 @@ extern int ZEXPORT unzGetFilePos(file, file_pos) return UNZ_OK; } -extern int ZEXPORT unzGoToFilePos(file, file_pos) - unzFile file; - unz_file_pos* file_pos; +extern int ZEXPORT unzGetFilePos( + unzFile file, + unz_file_pos* file_pos) { - unz_s* s; + unz64_file_pos file_pos64; + int err = unzGetFilePos64(file,&file_pos64); + if (err==UNZ_OK) + { + file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; + file_pos->num_of_file = (uLong)file_pos64.num_of_file; + } + return err; +} + +extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) +{ + unz64_s* s; int err; if (file==NULL || file_pos==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; /* jump to the right spot */ s->pos_in_central_dir = file_pos->pos_in_zip_directory; s->num_file = file_pos->num_of_file; /* set the current file */ - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, &s->cur_file_info_internal, NULL,0,NULL,0,NULL,0); /* return results */ @@ -948,6 +1357,19 @@ extern int ZEXPORT unzGoToFilePos(file, file_pos) return err; } +extern int ZEXPORT unzGoToFilePos( + unzFile file, + unz_file_pos* file_pos) +{ + unz64_file_pos file_pos64; + if (file_pos == NULL) + return UNZ_PARAMERROR; + + file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; + file_pos64.num_of_file = file_pos->num_of_file; + return unzGoToFilePos64(file,&file_pos64); +} + /* // Unzip Helper Functions - should be here? /////////////////////////////////////////// @@ -960,13 +1382,9 @@ extern int ZEXPORT unzGoToFilePos(file, file_pos) store in *piSizeVar the size of extra info in local header (filename and size of extra field data) */ -local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; +local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, + ZPOS64_T * poffset_local_extrafield, + uInt * psize_local_extrafield) { uLong uMagic,uData,uFlags; uLong size_filename; @@ -977,65 +1395,66 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, *poffset_local_extrafield = 0; *psize_local_extrafield = 0; - if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + + if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (err==UNZ_OK) - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) + { + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) err=UNZ_ERRNO; else if (uMagic!=0x04034b50) err=UNZ_BADZIPFILE; + } - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; /* else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) err=UNZ_BADZIPFILE; */ - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) err=UNZ_ERRNO; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) err=UNZ_BADZIPFILE; if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && +/* #ifdef HAVE_BZIP2 */ + (s->cur_file_info.compression_method!=Z_BZIP2ED) && +/* #endif */ (s->cur_file_info.compression_method!=Z_DEFLATED)) err=UNZ_BADZIPFILE; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ err=UNZ_ERRNO; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) + else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ + if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) + else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) err=UNZ_ERRNO; else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) err=UNZ_BADZIPFILE; *piSizeVar += (uInt)size_filename; - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) + if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) err=UNZ_ERRNO; *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + size_filename; @@ -1050,18 +1469,14 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, Open for reading data the current file in the zipfile. If there is no error and the file is opened, the return value is UNZ_OK. */ -extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) - unzFile file; - int* method; - int* level; - int raw; - const char* password; +extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, + int* level, int raw, const char* password) { int err=UNZ_OK; uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ uInt size_local_extrafield; /* size of the local extra field */ # ifndef NOUNCRYPT char source[12]; @@ -1072,19 +1487,17 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; if (!s->current_file_ok) return UNZ_PARAMERROR; if (s->pfile_in_zip_read != NULL) unzCloseCurrentFile(file); - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) return UNZ_BADZIPFILE; - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); + pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s)); if (pfile_in_zip_read_info==NULL) return UNZ_INTERNALERROR; @@ -1117,33 +1530,65 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) } if ((s->cur_file_info.compression_method!=0) && +/* #ifdef HAVE_BZIP2 */ + (s->cur_file_info.compression_method!=Z_BZIP2ED) && +/* #endif */ (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; + pfile_in_zip_read_info->total_out_64=0; + pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; pfile_in_zip_read_info->filestream=s->filestream; pfile_in_zip_read_info->z_filefunc=s->z_filefunc; pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; pfile_in_zip_read_info->stream.total_out = 0; - if ((s->cur_file_info.compression_method==Z_DEFLATED) && - (!raw)) + if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw)) { +#ifdef HAVE_BZIP2 + pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0; + pfile_in_zip_read_info->bstream.bzfree = (free_func)0; + pfile_in_zip_read_info->bstream.opaque = (voidpf)0; + pfile_in_zip_read_info->bstream.state = (voidpf)0; + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; pfile_in_zip_read_info->stream.zfree = (free_func)0; pfile_in_zip_read_info->stream.opaque = (voidpf)0; pfile_in_zip_read_info->stream.next_in = (voidpf)0; pfile_in_zip_read_info->stream.avail_in = 0; + err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; + else + { + TRYFREE(pfile_in_zip_read_info); + return err; + } +#else + pfile_in_zip_read_info->raw=1; +#endif + } + else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + pfile_in_zip_read_info->stream.next_in = 0; + pfile_in_zip_read_info->stream.avail_in = 0; + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; + pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; else + { + TRYFREE(pfile_in_zip_read_info); return err; + } /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and @@ -1165,6 +1610,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) pfile_in_zip_read_info->stream.avail_in = (uInt)0; s->pfile_in_zip_read = pfile_in_zip_read_info; + s->encrypted = 0; # ifndef NOUNCRYPT if (password != NULL) @@ -1172,12 +1618,12 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) int i; s->pcrc_32_tab = get_crc_table(); init_keys(password,s->keys,s->pcrc_32_tab); - if (ZSEEK(s->z_filefunc, s->filestream, + if (ZSEEK64(s->z_filefunc, s->filestream, s->pfile_in_zip_read->pos_in_zipfile + s->pfile_in_zip_read->byte_before_the_zipfile, SEEK_SET)!=0) return UNZ_INTERNALERROR; - if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) + if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) return UNZ_INTERNALERROR; for (i = 0; i<12; i++) @@ -1192,28 +1638,39 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) return UNZ_OK; } -extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; +extern int ZEXPORT unzOpenCurrentFile (unzFile file) { return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); } -extern int ZEXPORT unzOpenCurrentFilePassword (file, password) - unzFile file; - const char* password; +extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) { return unzOpenCurrentFile3(file, NULL, NULL, 0, password); } -extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) - unzFile file; - int* method; - int* level; - int raw; +extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) { return unzOpenCurrentFile3(file, method, level, raw, NULL); } +/** Addition for GDAL : START */ + +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) +{ + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + s=(unz64_s*)file; + if (file==NULL) + return 0; //UNZ_PARAMERROR; + pfile_in_zip_read_info=s->pfile_in_zip_read; + if (pfile_in_zip_read_info==NULL) + return 0; //UNZ_PARAMERROR; + return pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile; +} + +/** Addition for GDAL : END */ + /* Read bytes from the current file. buf contain buffer where data must be copied @@ -1224,25 +1681,22 @@ extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */ -extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; +extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) { int err=UNZ_OK; uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) return UNZ_PARAMERROR; - if ((pfile_in_zip_read_info->read_buffer == NULL)) + if (pfile_in_zip_read_info->read_buffer == NULL) return UNZ_END_OF_LIST_OF_FILE; if (len==0) return 0; @@ -1251,9 +1705,17 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) pfile_in_zip_read_info->stream.avail_out = (uInt)len; - if (len>pfile_in_zip_read_info->rest_read_uncompressed) + if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && + (!(pfile_in_zip_read_info->raw))) pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + if ((len>pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in) && + (pfile_in_zip_read_info->raw)) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_compressed+ + pfile_in_zip_read_info->stream.avail_in; while (pfile_in_zip_read_info->stream.avail_out>0) { @@ -1265,13 +1727,13 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; if (uReadThis == 0) return UNZ_EOF; - if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->pos_in_zipfile + pfile_in_zip_read_info->byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; - if (ZREAD(pfile_in_zip_read_info->z_filefunc, + if (ZREAD64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->read_buffer, uReadThis)!=uReadThis) @@ -1317,6 +1779,8 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) *(pfile_in_zip_read_info->stream.next_out+i) = *(pfile_in_zip_read_info->stream.next_in+i); + pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy; + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, pfile_in_zip_read_info->stream.next_out, uDoCopy); @@ -1328,11 +1792,54 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) pfile_in_zip_read_info->stream.total_out += uDoCopy; iRead += uDoCopy; } - else + else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { +#ifdef HAVE_BZIP2 uLong uTotalOutBefore,uTotalOutAfter; const Bytef *bufBefore; uLong uOutThis; + + pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in; + pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in; + pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in; + pfile_in_zip_read_info->bstream.total_in_hi32 = 0; + pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out; + pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out; + pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out; + pfile_in_zip_read_info->bstream.total_out_hi32 = 0; + + uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32; + bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out; + + err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream); + + uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); + pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in; + pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in; + pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32; + pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out; + pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out; + pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32; + + if (err==BZ_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=BZ_OK) + break; +#endif + } // end Z_BZIP2ED + else + { + ZPOS64_T uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + ZPOS64_T uOutThis; int flush=Z_SYNC_FLUSH; uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; @@ -1346,9 +1853,14 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) */ err=inflate(&pfile_in_zip_read_info->stream,flush); + if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) + err = Z_DATA_ERROR; + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; uOutThis = uTotalOutAfter-uTotalOutBefore; + pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); @@ -1374,14 +1886,13 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) /* Give the current position in uncompressed data */ -extern z_off_t ZEXPORT unztell (file) - unzFile file; +extern z_off_t ZEXPORT unztell (unzFile file) { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) @@ -1390,18 +1901,33 @@ extern z_off_t ZEXPORT unztell (file) return (z_off_t)pfile_in_zip_read_info->stream.total_out; } +extern ZPOS64_T ZEXPORT unztell64 (unzFile file) +{ + + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return (ZPOS64_T)-1; + s=(unz64_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return (ZPOS64_T)-1; + + return pfile_in_zip_read_info->total_out_64; +} + /* return 1 if the end of file was reached, 0 elsewhere */ -extern int ZEXPORT unzeof (file) - unzFile file; +extern int ZEXPORT unzeof (unzFile file) { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) @@ -1416,9 +1942,9 @@ extern int ZEXPORT unzeof (file) /* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) +Read extra field from the current file (opened by unzOpenCurrentFile) +This is the local-header version of the extra field (sometimes, there is +more info in the local-header version than in the central-header) if buf==NULL, it return the size of the local extra field that can be read @@ -1427,19 +1953,16 @@ extern int ZEXPORT unzeof (file) the return value is the number of bytes copied in buf, or (if <0) the error code */ -extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; +extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) { - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; uInt read_now; - uLong size_to_read; + ZPOS64_T size_to_read; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) @@ -1459,14 +1982,14 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) if (read_now==0) return 0; - if (ZSEEK(pfile_in_zip_read_info->z_filefunc, + if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, pfile_in_zip_read_info->offset_local_extrafield + pfile_in_zip_read_info->pos_local_extrafield, ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; - if (ZREAD(pfile_in_zip_read_info->z_filefunc, + if (ZREAD64(pfile_in_zip_read_info->z_filefunc, pfile_in_zip_read_info->filestream, buf,read_now)!=read_now) return UNZ_ERRNO; @@ -1475,19 +1998,18 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) } /* - Close the file in zip opened with unzipOpenCurrentFile + Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */ -extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; +extern int ZEXPORT unzCloseCurrentFile (unzFile file) { int err=UNZ_OK; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; + unz64_s* s; + file_in_zip64_read_info_s* pfile_in_zip_read_info; if (file==NULL) return UNZ_PARAMERROR; - s=(unz_s*)file; + s=(unz64_s*)file; pfile_in_zip_read_info=s->pfile_in_zip_read; if (pfile_in_zip_read_info==NULL) @@ -1504,8 +2026,13 @@ extern int ZEXPORT unzCloseCurrentFile (file) TRYFREE(pfile_in_zip_read_info->read_buffer); pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) + if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) inflateEnd(&pfile_in_zip_read_info->stream); +#ifdef HAVE_BZIP2 + else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) + BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); +#endif + pfile_in_zip_read_info->stream_initialised = 0; TRYFREE(pfile_in_zip_read_info); @@ -1521,29 +2048,25 @@ extern int ZEXPORT unzCloseCurrentFile (file) uSizeBuf is the size of the szComment buffer. return the number of byte copied or an error code <0 */ -extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; +extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) { - int err=UNZ_OK; - unz_s* s; + unz64_s* s; uLong uReadThis ; if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; + return (int)UNZ_PARAMERROR; + s=(unz64_s*)file; uReadThis = uSizeBuf; if (uReadThis>s->gi.size_comment) uReadThis = s->gi.size_comment; - if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) + if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) return UNZ_ERRNO; if (uReadThis>0) { *szComment='\0'; - if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) + if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) return UNZ_ERRNO; } @@ -1553,39 +2076,50 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) } /* Additions by RX '2004 */ -extern uLong ZEXPORT unzGetOffset (file) - unzFile file; +extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { - unz_s* s; + unz64_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return 0; - if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) - if (s->num_file==s->gi.number_entry) - return 0; - return s->pos_in_central_dir; + if (file==NULL) + return 0; //UNZ_PARAMERROR; + s=(unz64_s*)file; + if (!s->current_file_ok) + return 0; + if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) + if (s->num_file==s->gi.number_entry) + return 0; + return s->pos_in_central_dir; } -extern int ZEXPORT unzSetOffset (file, pos) - unzFile file; - uLong pos; +extern uLong ZEXPORT unzGetOffset (unzFile file) { - unz_s* s; - int err; + ZPOS64_T offset64; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - s->pos_in_central_dir = pos; - s->num_file = s->gi.number_entry; /* hack */ - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; + if (file==NULL) + return 0; //UNZ_PARAMERROR; + offset64 = unzGetOffset64(file); + return (uLong)offset64; } +extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) +{ + unz64_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz64_s*)file; + + s->pos_in_central_dir = pos; + s->num_file = s->gi.number_entry; /* hack */ + err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) +{ + return unzSetOffset64(file,pos); +} diff --git a/src/minizip/unzip.c.orig b/src/minizip/unzip.c.orig deleted file mode 100644 index 3b5eed3..0000000 --- a/src/minizip/unzip.c.orig +++ /dev/null @@ -1,1585 +0,0 @@ -/* unzip.c -- IO for uncompress .zip files using zlib - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - Read unzip.h for more info -*/ - -/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of -compatibility with older software. The following is from the original crypt.c. Code -woven in by Terry Thorsen 1/2003. -*/ -/* - Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - - See the accompanying file LICENSE, version 2000-Apr-09 or later - (the contents of which are also included in zip.h) for terms of use. - If, for some reason, all these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html -*/ -/* - crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] - - The encryption/decryption parts of this source code (as opposed to the - non-echoing password parts) were originally written in Europe. The - whole source package can be freely distributed, including from the USA. - (Prior to January 2000, re-export from the US was a violation of US law.) - */ - -/* - This encryption code is a direct transcription of the algorithm from - Roger Schlafly, described by Phil Katz in the file appnote.txt. This - file (appnote.txt) is distributed with the PKZIP program (even in the - version without encryption capabilities). - */ - - -#include -#include -#include -#include "zlib.h" -#include "unzip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - - -#ifndef CASESENSITIVITYDEFAULT_NO -# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) -# define CASESENSITIVITYDEFAULT_NO -# endif -#endif - - -#ifndef UNZ_BUFSIZE -#define UNZ_BUFSIZE (16384) -#endif - -#ifndef UNZ_MAXFILENAMEINZIP -#define UNZ_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) - - - - -const char unz_copyright[] = - " unzip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; - -/* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info_internal_s -{ - uLong offset_curfile;/* relative offset of local header 4 bytes */ -} unz_file_info_internal; - - -/* file_in_zip_read_info_s contain internal information about a file in zipfile, - when reading and decompress it */ -typedef struct -{ - char *read_buffer; /* internal buffer for compressed data */ - z_stream stream; /* zLib stream structure for inflate */ - - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ - - uLong offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ - - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - zlib_filefunc_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - int raw; -} file_in_zip_read_info_s; - - -/* unz_s contain internal information about the zipfile -*/ -typedef struct -{ - zlib_filefunc_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ - - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ - file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ - int encrypted; -# ifndef NOUNCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const unsigned long* pcrc_32_tab; -# endif -} unz_s; - - -#ifndef NOUNCRYPT -#include "crypt.h" -#endif - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ - - -local int unzlocal_getByte OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); - -local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - int *pi; -{ - unsigned char c; - int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) - { - *pi = (int)c; - return UNZ_OK; - } - else - { - if (ZERROR(*pzlib_filefunc_def,filestream)) - return UNZ_ERRNO; - else - return UNZ_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int unzlocal_getShort OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unzlocal_getLong OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - - -/* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; -{ - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1c2) - return 1; - } -} - - -#ifdef CASESENSITIVITYDEFAULT_NO -#define CASESENSITIVITYDEFAULTVALUE 2 -#else -#define CASESENSITIVITYDEFAULTVALUE 1 -#endif - -#ifndef STRCMPCASENOSENTIVEFUNCTION -#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal -#endif - -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) - -*/ -extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; -{ - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); - - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} - -#ifndef BUFREADCOMMENT -#define BUFREADCOMMENT (0x400) -#endif - -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local uLong unzlocal_SearchCentralDir OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream)); - -local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; -{ - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} - -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer - "zlib/zlib114.zip". - If the zipfile cannot be opened (file doesn't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ -extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) - const char *path; - zlib_filefunc_def* pzlib_filefunc_def; -{ - unz_s us; - unz_s *s; - uLong central_pos,uL; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - - int err=UNZ_OK; - - if (unz_copyright[0]!=' ') - return NULL; - - if (pzlib_filefunc_def==NULL) - fill_fopen_filefunc(&us.z_filefunc); - else - us.z_filefunc = *pzlib_filefunc_def; - - us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, - path, - ZLIB_FILEFUNC_MODE_READ | - ZLIB_FILEFUNC_MODE_EXISTING); - if (us.filestream==NULL) - return NULL; - - central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); - if (central_pos==0) - err=UNZ_ERRNO; - - if (ZSEEK(us.z_filefunc, us.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* zipfile comment length */ - if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((central_pospfile_in_zip_read!=NULL) - unzCloseCurrentFile(file); - - ZCLOSE(s->z_filefunc, s->filestream); - TRYFREE(s); - return UNZ_OK; -} - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; -{ - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; -} - - -/* - Translate date/time from Dos format to tm_unz (readable more easilty) -*/ -local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; -{ - uLong uDate; - uDate = (uLong)(ulDosDate>>16); - ptm->tm_mday = (uInt)(uDate&0x1f) ; - ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; - ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; - - ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); - ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; - ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; -} - -/* - Get Info about the current file in the zipfile, with internal only info -*/ -local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (ZSEEK(s->z_filefunc, s->filestream, - s->pos_in_central_dir+s->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK) - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; - - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; - - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; - - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; - - return err; -} - - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. -*/ -extern int ZEXPORT unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); -} - -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ -extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; -{ - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ -extern int ZEXPORT unzGoToNextFile (file) - unzFile file; -{ - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->gi.number_entry != 0xffff) // 2^16 files overflow hack - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; - - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - - -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzipStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ -extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; -{ - unz_s* s; - int err; - - /* We remember the 'current' position in the file so that we can jump - * back there if we fail. - */ - unz_file_info cur_file_infoSaved; - unz_file_info_internal cur_file_info_internalSaved; - uLong num_fileSaved; - uLong pos_in_central_dirSaved; - - - if (file==NULL) - return UNZ_PARAMERROR; - - if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) - return UNZ_PARAMERROR; - - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - /* Save the current state */ - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; - cur_file_infoSaved = s->cur_file_info; - cur_file_info_internalSaved = s->cur_file_info_internal; - - err = unzGoToFirstFile(file); - - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - err = unzGetCurrentFileInfo(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (err == UNZ_OK) - { - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } - } - - /* We failed, so restore the state of the 'current file' to where we - * were. - */ - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - s->cur_file_info = cur_file_infoSaved; - s->cur_file_info_internal = cur_file_info_internalSaved; - return err; -} - - -/* -/////////////////////////////////////////// -// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) -// I need random access -// -// Further optimization could be realized by adding an ability -// to cache the directory in memory. The goal being a single -// comprehensive file read to put the file I need in a memory. -*/ - -/* -typedef struct unz_file_pos_s -{ - uLong pos_in_zip_directory; // offset in file - uLong num_of_file; // # of file -} unz_file_pos; -*/ - -extern int ZEXPORT unzGetFilePos(file, file_pos) - unzFile file; - unz_file_pos* file_pos; -{ - unz_s* s; - - if (file==NULL || file_pos==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - file_pos->pos_in_zip_directory = s->pos_in_central_dir; - file_pos->num_of_file = s->num_file; - - return UNZ_OK; -} - -extern int ZEXPORT unzGoToFilePos(file, file_pos) - unzFile file; - unz_file_pos* file_pos; -{ - unz_s* s; - int err; - - if (file==NULL || file_pos==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - /* jump to the right spot */ - s->pos_in_central_dir = file_pos->pos_in_zip_directory; - s->num_file = file_pos->num_of_file; - - /* set the current file */ - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - /* return results */ - s->current_file_ok = (err == UNZ_OK); - return err; -} - -/* -// Unzip Helper Functions - should be here? -/////////////////////////////////////////// -*/ - -/* - Read the local header of the current zipfile - Check the coherency of the local header and info in the end of central - directory about this file - store in *piSizeVar the size of extra info in local header - (filename and size of extra field data) -*/ -local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; -{ - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; - - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; - - if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - - if (err==UNZ_OK) - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) - err=UNZ_ERRNO; -/* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; -*/ - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; - - if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; - - *piSizeVar += (uInt)size_filename; - - if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; - - *piSizeVar += (uInt)size_extra_field; - - return err; -} - -/* - Open for reading data the current file in the zipfile. - If there is no error and the file is opened, the return value is UNZ_OK. -*/ -extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) - unzFile file; - int* method; - int* level; - int raw; - const char* password; -{ - int err=UNZ_OK; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ -# ifndef NOUNCRYPT - char source[12]; -# else - if (password != NULL) - return UNZ_PARAMERROR; -# endif - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; - - if (s->pfile_in_zip_read != NULL) - unzCloseCurrentFile(file); - - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; - - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; - pfile_in_zip_read_info->raw=raw; - - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } - - pfile_in_zip_read_info->stream_initialised=0; - - if (method!=NULL) - *method = (int)s->cur_file_info.compression_method; - - if (level!=NULL) - { - *level = 6; - switch (s->cur_file_info.flag & 0x06) - { - case 6 : *level = 1; break; - case 4 : *level = 2; break; - case 2 : *level = 9; break; - } - } - - if ((s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; - pfile_in_zip_read_info->filestream=s->filestream; - pfile_in_zip_read_info->z_filefunc=s->z_filefunc; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; - - pfile_in_zip_read_info->stream.total_out = 0; - - if ((s->cur_file_info.compression_method==Z_DEFLATED) && - (!raw)) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - pfile_in_zip_read_info->stream.next_in = (voidpf)0; - pfile_in_zip_read_info->stream.avail_in = 0; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; - else - return err; - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the - * size of both compressed and uncompressed data - */ - } - pfile_in_zip_read_info->rest_read_compressed = - s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = - s->cur_file_info.uncompressed_size ; - - - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; - - s->pfile_in_zip_read = pfile_in_zip_read_info; - -# ifndef NOUNCRYPT - if (password != NULL) - { - int i; - s->pcrc_32_tab = get_crc_table(); - init_keys(password,s->keys,s->pcrc_32_tab); - if (ZSEEK(s->z_filefunc, s->filestream, - s->pfile_in_zip_read->pos_in_zipfile + - s->pfile_in_zip_read->byte_before_the_zipfile, - SEEK_SET)!=0) - return UNZ_INTERNALERROR; - if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) - return UNZ_INTERNALERROR; - - for (i = 0; i<12; i++) - zdecode(s->keys,s->pcrc_32_tab,source[i]); - - s->pfile_in_zip_read->pos_in_zipfile+=12; - s->encrypted=1; - } -# endif - - - return UNZ_OK; -} - -extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; -{ - return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); -} - -extern int ZEXPORT unzOpenCurrentFilePassword (file, password) - unzFile file; - const char* password; -{ - return unzOpenCurrentFile3(file, NULL, NULL, 0, password); -} - -extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) - unzFile file; - int* method; - int* level; - int raw; -{ - return unzOpenCurrentFile3(file, method, level, raw, NULL); -} - -/* - Read bytes from the current file. - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ -extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; -{ - int err=UNZ_OK; - uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if ((pfile_in_zip_read_info->read_buffer == NULL)) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; - - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - - pfile_in_zip_read_info->stream.avail_out = (uInt)len; - - if (len>pfile_in_zip_read_info->rest_read_uncompressed) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && - (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (ZSEEK(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - if (ZREAD(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->read_buffer, - uReadThis)!=uReadThis) - return UNZ_ERRNO; - - -# ifndef NOUNCRYPT - if(s->encrypted) - { - uInt i; - for(i=0;iread_buffer[i] = - zdecode(s->keys,s->pcrc_32_tab, - pfile_in_zip_read_info->read_buffer[i]); - } -# endif - - - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = - (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } - - if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) - { - uInt uDoCopy,i ; - - if ((pfile_in_zip_read_info->stream.avail_in == 0) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - return (iRead==0) ? UNZ_EOF : iRead; - - if (pfile_in_zip_read_info->stream.avail_out < - pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; - pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - int flush=Z_SYNC_FLUSH; - - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; - - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = - crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); - - pfile_in_zip_read_info->rest_read_uncompressed -= - uOutThis; - - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) - break; - } - } - - if (err==Z_OK) - return iRead; - return err; -} - - -/* - Give the current position in uncompressed data -*/ -extern z_off_t ZEXPORT unztell (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - return (z_off_t)pfile_in_zip_read_info->stream.total_out; -} - - -/* - return 1 if the end of file was reached, 0 elsewhere -*/ -extern int ZEXPORT unzeof (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - return 1; - else - return 0; -} - - - -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field that can be read - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ -extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uInt read_now; - uLong size_to_read; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); - - if (buf==NULL) - return (int)size_to_read; - - if (len>size_to_read) - read_now = (uInt)size_to_read; - else - read_now = (uInt)len ; - - if (read_now==0) - return 0; - - if (ZSEEK(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield, - ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - if (ZREAD(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - buf,size_to_read)!=size_to_read) - return UNZ_ERRNO; - - return (int)read_now; -} - -/* - Close the file in zip opened with unzipOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ -extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; -{ - int err=UNZ_OK; - - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && - (!pfile_in_zip_read_info->raw)) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } - - - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) - inflateEnd(&pfile_in_zip_read_info->stream); - - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); - - s->pfile_in_zip_read=NULL; - - return err; -} - - -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ -extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; -{ - int err=UNZ_OK; - unz_s* s; - uLong uReadThis ; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; - - if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - if (uReadThis>0) - { - *szComment='\0'; - if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) - return UNZ_ERRNO; - } - - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; -} - -/* Additions by RX '2004 */ -extern uLong ZEXPORT unzGetOffset (file) - unzFile file; -{ - unz_s* s; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return 0; - if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) - if (s->num_file==s->gi.number_entry) - return 0; - return s->pos_in_central_dir; -} - -extern int ZEXPORT unzSetOffset (file, pos) - unzFile file; - uLong pos; -{ - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - s->pos_in_central_dir = pos; - s->num_file = s->gi.number_entry; /* hack */ - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - diff --git a/src/minizip/unzip.h b/src/minizip/unzip.h index cb6cb2e..2104e39 100644 --- a/src/minizip/unzip.h +++ b/src/minizip/unzip.h @@ -1,18 +1,20 @@ /* unzip.h -- IO for uncompress .zip files using zlib - Version 1.00, September 10th, 2003 + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Copyright (C) 1998-2003 Gilles Vollant + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported + Modifications of Unzip for Zip64 + Copyright (C) 2007-2008 Even Rouault + Modifications for Zip64 support on both zip and unzip + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + For more info read MiniZip_info.txt - Condition of use and distribution are the same than zlib : + --------------------------------------------------------------------------------- + + Condition of use and distribution are the same than zlib : This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -30,18 +32,16 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. + --------------------------------------------------------------------------------- + + Changes + + See header of unzip64.c */ -/* for more info about .ZIP format, see - http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip - http://www.info-zip.org/pub/infozip/doc/ - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _unz_H -#define _unz_H +#ifndef _unz64_H +#define _unz64_H #ifdef __cplusplus extern "C" { @@ -51,10 +51,16 @@ extern "C" { #include "zlib.h" #endif -#ifndef _ZLIBIOAPI_H +#ifndef _ZLIBIOAPI_H #include "ioapi.h" #endif +#ifdef HAVE_BZIP2 +#include "bzlib.h" +#endif + +#define Z_BZIP2ED 12 + #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ @@ -87,15 +93,42 @@ typedef struct tm_unz_s /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ +typedef struct unz_global_info64_s +{ + ZPOS64_T number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info64; + typedef struct unz_global_info_s { uLong number_entry; /* total number of entries in - the central dir on this disk */ + the central dir on this disk */ uLong size_comment; /* size of the global comment of the zipfile */ } unz_global_info; - /* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info64_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + ZPOS64_T compressed_size; /* compressed size 8 bytes */ + ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info64; + typedef struct unz_file_info_s { uLong version; /* version made by 2 bytes */ @@ -131,6 +164,7 @@ extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, extern unzFile ZEXPORT unzOpen OF((const char *path)); +extern unzFile ZEXPORT unzOpen64 OF((const void *path)); /* Open a Zip file. path contain the full pathname (by example, on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer @@ -139,8 +173,14 @@ extern unzFile ZEXPORT unzOpen OF((const char *path)); return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. + the "64" function take a const void* pointer, because the path is just the + value passed to the open64_file_func callback. + Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path + is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* + does not describe the reality */ + extern unzFile ZEXPORT unzOpen2 OF((const char *path, zlib_filefunc_def* pzlib_filefunc_def)); /* @@ -148,15 +188,25 @@ extern unzFile ZEXPORT unzOpen2 OF((const char *path, for read/write the zip file (see ioapi.h) */ +extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, + zlib_filefunc64_def* pzlib_filefunc_def)); +/* + Open a Zip file, like unz64Open, but provide a set of file low level API + for read/write the zip file (see ioapi.h) +*/ + extern int ZEXPORT unzClose OF((unzFile file)); /* - Close a ZipFile opened with unzipOpen. + Close a ZipFile opened with unzOpen. If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + these files MUST be closed with unzCloseCurrentFile before call unzClose. return UNZ_OK if there is no problem. */ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, unz_global_info *pglobal_info)); + +extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, + unz_global_info64 *pglobal_info)); /* Write info about the ZipFile in the *pglobal_info structure. No preparation of the structure is needed @@ -219,8 +269,31 @@ extern int ZEXPORT unzGoToFilePos( unzFile file, unz_file_pos* file_pos); +typedef struct unz64_file_pos_s +{ + ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ + ZPOS64_T num_of_file; /* # of file */ +} unz64_file_pos; + +extern int ZEXPORT unzGetFilePos64( + unzFile file, + unz64_file_pos* file_pos); + +extern int ZEXPORT unzGoToFilePos64( + unzFile file, + const unz64_file_pos* file_pos); + /* ****************************************** */ +extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, + unz_file_info64 *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, unz_file_info *pfile_info, char *szFileName, @@ -242,6 +315,14 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, (commentBufferSize is the size of the buffer) */ + +/** Addition for GDAL : START */ + +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); + +/** Addition for GDAL : END */ + + /***************************************************************************/ /* for reading the content of the current zipfile, you can open it, read data from it, and close it (you can close it before reading all the file) @@ -310,6 +391,8 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file, */ extern z_off_t ZEXPORT unztell OF((unzFile file)); + +extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); /* Give the current position in uncompressed data */ @@ -338,9 +421,11 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, /***************************************************************************/ /* Get the current file offset */ +extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); extern uLong ZEXPORT unzGetOffset (unzFile file); /* Set the current file offset */ +extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); @@ -349,4 +434,4 @@ extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); } #endif -#endif /* _unz_H */ +#endif /* _unz64_H */ diff --git a/src/minizip/unzip.h.orig b/src/minizip/unzip.h.orig deleted file mode 100644 index 941decd..0000000 --- a/src/minizip/unzip.h.orig +++ /dev/null @@ -1,352 +0,0 @@ -/* unzip.h -- IO for uncompress .zip files using zlib - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - -*/ - -/* for more info about .ZIP format, see - http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip - http://www.info-zip.org/pub/infozip/doc/ - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _unz_H -#define _unz_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#ifndef _ZLIBIOAPI_H -#include "ioapi.h" -#endif - -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; -typedef unzFile__ *unzFile; -#else -typedef voidp unzFile; -#endif - - -#define UNZ_OK (0) -#define UNZ_END_OF_LIST_OF_FILE (-100) -#define UNZ_ERRNO (Z_ERRNO) -#define UNZ_EOF (0) -#define UNZ_PARAMERROR (-102) -#define UNZ_BADZIPFILE (-103) -#define UNZ_INTERNALERROR (-104) -#define UNZ_CRCERROR (-105) - -/* tm_unz contain date/time info */ -typedef struct tm_unz_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_unz; - -/* unz_global_info structure contain global data about the ZIPfile - These data comes from the end of central dir */ -typedef struct unz_global_info_s -{ - uLong number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info; - - -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_info_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info; - -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) -*/ - - -extern unzFile ZEXPORT unzOpen OF((const char *path)); -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer - "zlib/zlib113.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ - -extern unzFile ZEXPORT unzOpen2 OF((const char *path, - zlib_filefunc_def* pzlib_filefunc_def)); -/* - Open a Zip file, like unzOpen, but provide a set of file low level API - for read/write the zip file (see ioapi.h) -*/ - -extern int ZEXPORT unzClose OF((unzFile file)); -/* - Close a ZipFile opened with unzipOpen. - If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. - return UNZ_OK if there is no problem. */ - -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ - - -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ - - -/***************************************************************************/ -/* Unzip package allow you browse the directory of the zipfile */ - -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ - -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ - -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ - - -/* ****************************************** */ -/* Ryan supplied functions */ -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_pos_s -{ - uLong pos_in_zip_directory; /* offset in zip file directory */ - uLong num_of_file; /* # of file */ -} unz_file_pos; - -extern int ZEXPORT unzGetFilePos( - unzFile file, - unz_file_pos* file_pos); - -extern int ZEXPORT unzGoToFilePos( - unzFile file, - unz_file_pos* file_pos); - -/* ****************************************** */ - -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); -/* - Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about - the current file - if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) - if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - This is the Central-header version of the extra field - if szComment!=NULL, the comment string of the file will be copied in szComment - (commentBufferSize is the size of the buffer) -*/ - -/***************************************************************************/ -/* for reading the content of the current zipfile, you can open it, read data - from it, and close it (you can close it before reading all the file) - */ - -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); -/* - Open for reading data the current file in the zipfile. - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, - const char* password)); -/* - Open for reading data the current file in the zipfile. - password is a crypting password - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, - int* method, - int* level, - int raw)); -/* - Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) - if raw==1 - *method will receive method of compression, *level will receive level of - compression - note : you can set level parameter as NULL (if you did not want known level, - but you CANNOT set method parameter as NULL -*/ - -extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, - int* method, - int* level, - int raw, - const char* password)); -/* - Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) - if raw==1 - *method will receive method of compression, *level will receive level of - compression - note : you can set level parameter as NULL (if you did not want known level, - but you CANNOT set method parameter as NULL -*/ - - -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); -/* - Close the file in zip opened with unzOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ - -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read bytes from the current file (opened by unzOpenCurrentFile) - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ - -extern z_off_t ZEXPORT unztell OF((unzFile file)); -/* - Give the current position in uncompressed data -*/ - -extern int ZEXPORT unzeof OF((unzFile file)); -/* - return 1 if the end of file was reached, 0 elsewhere -*/ - -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ - -/***************************************************************************/ - -/* Get the current file offset */ -extern uLong ZEXPORT unzGetOffset (unzFile file); - -/* Set the current file offset */ -extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); - - - -#ifdef __cplusplus -} -#endif - -#endif /* _unz_H */ diff --git a/src/minizip/zip.c b/src/minizip/zip.c index 7dc767f..b0d83e2 100644 --- a/src/minizip/zip.c +++ b/src/minizip/zip.c @@ -1,19 +1,29 @@ /* zip.c -- IO on .zip files using zlib - Version 1.00, September 10th, 2003 + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Copyright (C) 1998-2003 Gilles Vollant + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) + + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) + + For more info read MiniZip_info.txt + + Changes + Oct-2009 - Mathias Svensson - Remove old C style function prototypes + Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives + Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. + Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data + It is used when recreting zip archive with RAW when deleting items from a zip. + ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed. + Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) + Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer - Read zip.h for more info */ -#ifndef _WIN32_WCE #include #include -#else -#include -#include "celib.h" -#endif #include #include #include "zlib.h" @@ -41,7 +51,7 @@ #endif #ifndef Z_BUFSIZE -#define Z_BUFSIZE (16384) +#define Z_BUFSIZE (64*1024) //(16384) #endif #ifndef Z_MAXFILENAMEINZIP @@ -62,6 +72,10 @@ /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +// NOT sure that this work on ALL platform +#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) + #ifndef SEEK_CUR #define SEEK_CUR 1 #endif @@ -81,8 +95,7 @@ # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif #endif -const char zip_copyright[] = - " zip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; +const char zip_copyright[] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; #define SIZEDATA_INDATABLOCK (4096-(4*4)) @@ -90,6 +103,8 @@ const char zip_copyright[] = #define LOCALHEADERMAGIC (0x04034b50) #define CENTRALHEADERMAGIC (0x02014b50) #define ENDHEADERMAGIC (0x06054b50) +#define ZIP64ENDHEADERMAGIC (0x6064b50) +#define ZIP64ENDLOCHEADERMAGIC (0x7064b50) #define FLAG_LOCALHEADER_OFFSET (0x06) #define CRC_LOCALHEADER_OFFSET (0x0e) @@ -115,13 +130,19 @@ typedef struct linkedlist_data_s typedef struct { z_stream stream; /* zLib stream structure for inflate */ +#ifdef HAVE_BZIP2 + bz_stream bstream; /* bzLib stream structure for bziped */ +#endif + int stream_initialised; /* 1 is stream is initialised */ uInt pos_in_buffered_data; /* last written byte in buffered_data */ - uLong pos_local_header; /* offset of the local header of the file + ZPOS64_T pos_local_header; /* offset of the local header of the file currenty writing */ char* central_header; /* central header data for the current file */ + uLong size_centralExtra; uLong size_centralheader; /* size of the central header for cur file */ + uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ uLong flag; /* flag of the file currently writing */ int method; /* compression method of file currenty wr.*/ @@ -130,26 +151,34 @@ typedef struct uLong dosDate; uLong crc32; int encrypt; + int zip64; /* Add ZIP64 extened information in the extra field */ + ZPOS64_T pos_zip64extrainfo; + ZPOS64_T totalCompressedData; + ZPOS64_T totalUncompressedData; #ifndef NOCRYPT unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const unsigned long* pcrc_32_tab; + const z_crc_t* pcrc_32_tab; int crypt_header_size; #endif -} curfile_info; +} curfile64_info; typedef struct { - zlib_filefunc_def z_filefunc; + zlib_filefunc64_32_def z_filefunc; voidpf filestream; /* io structore of the zipfile */ linkedlist_data central_dir;/* datablock with central dir in construction*/ int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile_info ci; /* info on the file curretly writing */ + curfile64_info ci; /* info on the file curretly writing */ - uLong begin_pos; /* position of the beginning of the zipfile */ - uLong add_position_when_writting_offset; - uLong number_entry; -} zip_internal; + ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ + ZPOS64_T add_position_when_writting_offset; + ZPOS64_T number_entry; +#ifndef NO_ADDFILEINEXISTINGZIP + char *globalcomment; +#endif + +} zip64_internal; #ifndef NOCRYPT @@ -157,7 +186,7 @@ typedef struct #include "crypt.h" #endif -local linkedlist_datablock_internal* allocate_new_datablock() +local linkedlist_datablock_internal* allocate_new_datablock(void) { linkedlist_datablock_internal* ldi; ldi = (linkedlist_datablock_internal*) @@ -171,8 +200,7 @@ local linkedlist_datablock_internal* allocate_new_datablock() return ldi; } -local void free_datablock(ldi) - linkedlist_datablock_internal* ldi; +local void free_datablock(linkedlist_datablock_internal* ldi) { while (ldi!=NULL) { @@ -182,24 +210,19 @@ local void free_datablock(ldi) } } -local void init_linkedlist(ll) - linkedlist_data* ll; +local void init_linkedlist(linkedlist_data* ll) { ll->first_block = ll->last_block = NULL; } -local void free_linkedlist(ll) - linkedlist_data* ll; +local void free_linkedlist(linkedlist_data* ll) { free_datablock(ll->first_block); ll->first_block = ll->last_block = NULL; } -local int add_data_in_datablock(ll,buf,len) - linkedlist_data* ll; - const void* buf; - uLong len; +local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) { linkedlist_datablock_internal* ldi; const unsigned char* from_copy; @@ -257,39 +280,35 @@ local int add_data_in_datablock(ll,buf,len) #ifndef NO_ADDFILEINEXISTINGZIP /* =========================================================================== Inputs a long in LSB order to the given file - nbByte == 1, 2 or 4 (byte, short or long) + nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) */ -local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, uLong x, int nbByte)); -local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong x; - int nbByte; +local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); +local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) { - unsigned char buf[4]; + unsigned char buf[8]; int n; - for (n = 0; n < nbByte; n++) { + for (n = 0; n < nbByte; n++) + { buf[n] = (unsigned char)(x & 0xff); x >>= 8; } - if (x != 0) { // data overflow - hack for ZIP64 - for (n = 0; n < nbByte; n++) { - buf[n] = 0xff; + if (x != 0) + { /* data overflow - hack for ZIP64 (X Roche) */ + for (n = 0; n < nbByte; n++) + { + buf[n] = 0xff; + } } - } - if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) + + if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) return ZIP_ERRNO; else return ZIP_OK; } -local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); -local void ziplocal_putValue_inmemory (dest, x, nbByte) - void* dest; - uLong x; - int nbByte; +local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); +local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) { unsigned char* buf=(unsigned char*)dest; int n; @@ -297,23 +316,25 @@ local void ziplocal_putValue_inmemory (dest, x, nbByte) buf[n] = (unsigned char)(x & 0xff); x >>= 8; } - if (x != 0) { // data overflow - hack for ZIP64 - for (n = 0; n < nbByte; n++) { - buf[n] = 0xff; - } + + if (x != 0) + { /* data overflow - hack for ZIP64 */ + for (n = 0; n < nbByte; n++) + { + buf[n] = 0xff; + } } } + /****************************************************************************/ -local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) - const tm_zip* ptm; - uLong dosDate; +local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) { uLong year = (uLong)ptm->tm_year; - if (year>1980) + if (year>=1980) year-=1980; - else if (year>80) + else if (year>=80) year-=80; return (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | @@ -323,18 +344,12 @@ local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) /****************************************************************************/ -local int ziplocal_getByte OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); +local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); -local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - int *pi; +local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) { unsigned char c; - int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); if (err==1) { *pi = (int)c; @@ -342,7 +357,7 @@ local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) } else { - if (ZERROR(*pzlib_filefunc_def,filestream)) + if (ZERROR64(*pzlib_filefunc_def,filestream)) return ZIP_ERRNO; else return ZIP_EOF; @@ -353,25 +368,19 @@ local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) /* =========================================================================== Reads a long in LSB order from the given gz_stream. Sets */ -local int ziplocal_getShort OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); +local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); -local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; +local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { uLong x ; - int i; + int i = 0; int err; - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<8; if (err==ZIP_OK) @@ -381,33 +390,27 @@ local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) return err; } -local int ziplocal_getLong OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); +local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); -local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; +local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { uLong x ; - int i; + int i = 0; int err; - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); x = (uLong)i; if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<8; if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<16; if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); x += ((uLong)i)<<24; if (err==ZIP_OK) @@ -417,6 +420,54 @@ local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) return err; } +local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); + + +local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) +{ + ZPOS64_T x; + int i = 0; + int err; + + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x = (ZPOS64_T)i; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<8; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<16; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<24; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<32; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<40; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<48; + + if (err==ZIP_OK) + err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); + x += ((ZPOS64_T)i)<<56; + + if (err==ZIP_OK) + *pX = x; + else + *pX = 0; + + return err; +} + #ifndef BUFREADCOMMENT #define BUFREADCOMMENT (0x400) #endif @@ -424,87 +475,391 @@ local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) Locate the Central directory of a zipfile (at the end, just before the global comment) */ -local uLong ziplocal_SearchCentralDir OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream)); +local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); -local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; +local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; - if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; - uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; - if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; } + +/* +Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before +the global comment) +*/ +local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); + +local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) +{ + unsigned char* buf; + ZPOS64_T uSizeFile; + ZPOS64_T uBackRead; + ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ + ZPOS64_T uPosFound=0; + uLong uL; + ZPOS64_T relativeOffset; + + if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) + return 0; + + uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); + if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) + break; + + if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + { + // Signature "0x07064b50" Zip64 end of central directory locater + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) + { + uPosFound = uReadPos+i; + break; + } + } + + if (uPosFound!=0) + break; + } + + TRYFREE(buf); + if (uPosFound == 0) + return 0; + + /* Zip64 end of central directory locator */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature, already checked */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + + /* number of the disk with the start of the zip64 end of central directory */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + if (uL != 0) + return 0; + + /* relative offset of the zip64 end of central directory record */ + if (zip64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=ZIP_OK) + return 0; + + /* total number of disks */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + if (uL != 1) + return 0; + + /* Goto Zip64 end of central directory record */ + if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) + return 0; + + /* the signature */ + if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) + return 0; + + if (uL != 0x06064b50) // signature of 'Zip64 end of central directory' + return 0; + + return relativeOffset; +} + +local int LoadCentralDirectoryRecord(zip64_internal* pziinit) +{ + int err=ZIP_OK; + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + + ZPOS64_T size_central_dir; /* size of the central directory */ + ZPOS64_T offset_central_dir; /* offset of start of central directory */ + ZPOS64_T central_pos; + uLong uL; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + ZPOS64_T number_entry; + ZPOS64_T number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + uLong VersionMadeBy; + uLong VersionNeeded; + uLong size_comment; + + int hasZIP64Record = 0; + + // check first if we find a ZIP64 record + central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream); + if(central_pos > 0) + { + hasZIP64Record = 1; + } + else if(central_pos == 0) + { + central_pos = zip64local_SearchCentralDir(&pziinit->z_filefunc,pziinit->filestream); + } + +/* disable to allow appending to empty ZIP archive + if (central_pos==0) + err=ZIP_ERRNO; +*/ + + if(hasZIP64Record) + { + ZPOS64_T sizeEndOfCentralDirectory; + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0) + err=ZIP_ERRNO; + + /* the signature, already checked */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) + err=ZIP_ERRNO; + + /* size of zip64 end of central directory record */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &sizeEndOfCentralDirectory)!=ZIP_OK) + err=ZIP_ERRNO; + + /* version made by */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionMadeBy)!=ZIP_OK) + err=ZIP_ERRNO; + + /* version needed to extract */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionNeeded)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of this disk */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of the disk with the start of the central directory */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central directory on this disk */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &number_entry)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central directory */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&number_entry_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) + err=ZIP_BADZIPFILE; + + /* size of the central directory */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&size_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK) + err=ZIP_ERRNO; + + // TODO.. + // read the comment from the standard central header. + size_comment = 0; + } + else + { + // Read End of central Directory info + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) + err=ZIP_ERRNO; + + /* the signature, already checked */ + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of this disk */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK) + err=ZIP_ERRNO; + + /* number of the disk with the start of the central directory */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK) + err=ZIP_ERRNO; + + /* total number of entries in the central dir on this disk */ + number_entry = 0; + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + number_entry = uL; + + /* total number of entries in the central dir */ + number_entry_CD = 0; + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + number_entry_CD = uL; + + if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) + err=ZIP_BADZIPFILE; + + /* size of the central directory */ + size_central_dir = 0; + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + size_central_dir = uL; + + /* offset of start of central directory with respect to the starting disk number */ + offset_central_dir = 0; + if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) + err=ZIP_ERRNO; + else + offset_central_dir = uL; + + + /* zipfile global comment length */ + if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &size_comment)!=ZIP_OK) + err=ZIP_ERRNO; + } + + if ((central_posz_filefunc, pziinit->filestream); + return ZIP_ERRNO; + } + + if (size_comment>0) + { + pziinit->globalcomment = (char*)ALLOC(size_comment+1); + if (pziinit->globalcomment) + { + size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit->globalcomment,size_comment); + pziinit->globalcomment[size_comment]=0; + } + } + + byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); + pziinit->add_position_when_writting_offset = byte_before_the_zipfile; + + { + ZPOS64_T size_central_dir_to_read = size_central_dir; + size_t buf_size = SIZEDATA_INDATABLOCK; + void* buf_read = (void*)ALLOC(buf_size); + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0) + err=ZIP_ERRNO; + + while ((size_central_dir_to_read>0) && (err==ZIP_OK)) + { + ZPOS64_T read_this = SIZEDATA_INDATABLOCK; + if (read_this > size_central_dir_to_read) + read_this = size_central_dir_to_read; + + if (ZREAD64(pziinit->z_filefunc, pziinit->filestream,buf_read,(uLong)read_this) != read_this) + err=ZIP_ERRNO; + + if (err==ZIP_OK) + err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this); + + size_central_dir_to_read-=read_this; + } + TRYFREE(buf_read); + } + pziinit->begin_pos = byte_before_the_zipfile; + pziinit->number_entry = number_entry_CD; + + if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0) + err=ZIP_ERRNO; + + return err; +} + + #endif /* !NO_ADDFILEINEXISTINGZIP*/ + /************************************************************/ -extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) - const char *pathname; - int append; - zipcharpc* globalcomment; - zlib_filefunc_def* pzlib_filefunc_def; +extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { - zip_internal ziinit; - zip_internal* zi; + zip64_internal ziinit; + zip64_internal* zi; int err=ZIP_OK; - - if (pzlib_filefunc_def==NULL) - fill_fopen_filefunc(&ziinit.z_filefunc); + ziinit.z_filefunc.zseek32_file = NULL; + ziinit.z_filefunc.ztell32_file = NULL; + if (pzlib_filefunc64_32_def==NULL) + fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); else - ziinit.z_filefunc = *pzlib_filefunc_def; + ziinit.z_filefunc = *pzlib_filefunc64_32_def; - ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) - (ziinit.z_filefunc.opaque, + ziinit.filestream = ZOPEN64(ziinit.z_filefunc, pathname, (append == APPEND_STATUS_CREATE) ? (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : @@ -512,7 +867,11 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc if (ziinit.filestream == NULL) return NULL; - ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); + + if (append == APPEND_STATUS_CREATEAFTER) + ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END); + + ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream); ziinit.in_opened_file_inzip = 0; ziinit.ci.stream_initialised = 0; ziinit.number_entry = 0; @@ -520,128 +879,34 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc init_linkedlist(&(ziinit.central_dir)); - zi = (zip_internal*)ALLOC(sizeof(zip_internal)); + + zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)); if (zi==NULL) { - ZCLOSE(ziinit.z_filefunc,ziinit.filestream); + ZCLOSE64(ziinit.z_filefunc,ziinit.filestream); return NULL; } /* now we add file in a zipfile */ # ifndef NO_ADDFILEINEXISTINGZIP + ziinit.globalcomment = NULL; if (append == APPEND_STATUS_ADDINZIP) { - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ + // Read and Cache Central Directory Records + err = LoadCentralDirectoryRecord(&ziinit); + } - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory */ - uLong central_pos,uL; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry; - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - uLong size_comment; - - central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); - if (central_pos==0) - err=ZIP_ERRNO; - - if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; - - /* the signature, already checked */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of this disk */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of the disk with the start of the central directory */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((number_entry_CD!=number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=ZIP_BADZIPFILE; - - /* size of the central directory */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* zipfile comment length */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((central_pos0) && (err==ZIP_OK)) - { - uLong read_this = SIZEDATA_INDATABLOCK; - if (read_this > size_central_dir_to_read) - read_this = size_central_dir_to_read; - if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) - err=ZIP_ERRNO; - - if (err==ZIP_OK) - err = add_data_in_datablock(&ziinit.central_dir,buf_read, - (uLong)read_this); - size_central_dir_to_read-=read_this; - } - TRYFREE(buf_read); - } - ziinit.begin_pos = byte_before_the_zipfile; - ziinit.number_entry = number_entry_CD; - - if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, - offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; + if (globalcomment) + { + *globalcomment = ziinit.globalcomment; } # endif /* !NO_ADDFILEINEXISTINGZIP*/ if (err != ZIP_OK) { +# ifndef NO_ADDFILEINEXISTINGZIP + TRYFREE(ziinit.globalcomment); +# endif /* !NO_ADDFILEINEXISTINGZIP*/ TRYFREE(zi); return NULL; } @@ -652,53 +917,173 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc } } -extern zipFile ZEXPORT zipOpen (pathname, append) - const char *pathname; - int append; +extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) { - return zipOpen2(pathname,append,NULL,NULL); + if (pzlib_filefunc32_def != NULL) + { + zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; + fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); + return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); + } + else + return zipOpen3(pathname, append, globalcomment, NULL); } -extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; - int raw; - int windowBits; - int memLevel; - int strategy; - const char* password; - uLong crcForCrypting; +extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) { - zip_internal* zi; + if (pzlib_filefunc_def != NULL) + { + zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; + zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; + zlib_filefunc64_32_def_fill.ztell32_file = NULL; + zlib_filefunc64_32_def_fill.zseek32_file = NULL; + return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); + } + else + return zipOpen3(pathname, append, globalcomment, NULL); +} + + + +extern zipFile ZEXPORT zipOpen (const char* pathname, int append) +{ + return zipOpen3((const void*)pathname,append,NULL,NULL); +} + +extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) +{ + return zipOpen3(pathname,append,NULL,NULL); +} + +local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) +{ + /* write the local header */ + int err; + uInt size_filename = (uInt)strlen(filename); + uInt size_extrafield = size_extrafield_local; + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4); + + if (err==ZIP_OK) + { + if(zi->ci.zip64) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ + } + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); + + // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ + if (err==ZIP_OK) + { + if(zi->ci.zip64) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */ + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ + } + if (err==ZIP_OK) + { + if(zi->ci.zip64) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */ + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ + } + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); + + if(zi->ci.zip64) + { + size_extrafield += 20; + } + + if (err==ZIP_OK) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2); + + if ((err==ZIP_OK) && (size_filename > 0)) + { + if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) + err = ZIP_ERRNO; + } + + if ((err==ZIP_OK) && (size_extrafield_local > 0)) + { + if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local) + err = ZIP_ERRNO; + } + + + if ((err==ZIP_OK) && (zi->ci.zip64)) + { + // write the Zip64 extended info + short HeaderID = 1; + short DataSize = 16; + ZPOS64_T CompressedSize = 0; + ZPOS64_T UncompressedSize = 0; + + // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) + zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); + + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2); + + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); + } + + return err; +} + +/* + NOTE. + When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped + before calling this function it can be done with zipRemoveExtraInfoBlock + + It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize + unnecessary allocations. + */ +extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase, int zip64) +{ + zip64_internal* zi; uInt size_filename; uInt size_comment; uInt i; int err = ZIP_OK; # ifdef NOCRYPT + (crcForCrypting); if (password != NULL) return ZIP_PARAMERROR; # endif if (file == NULL) return ZIP_PARAMERROR; - if ((method!=0) && (method!=Z_DEFLATED)) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; +#ifdef HAVE_BZIP2 + if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED)) + return ZIP_PARAMERROR; +#else + if ((method!=0) && (method!=Z_DEFLATED)) + return ZIP_PARAMERROR; +#endif + + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 1) { @@ -707,16 +1092,15 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, return err; } - if (filename==NULL) filename="-"; if (comment==NULL) size_comment = 0; else - size_comment = strlen(comment); + size_comment = (uInt)strlen(comment); - size_filename = strlen(filename); + size_filename = (uInt)strlen(filename); if (zipfi == NULL) zi->ci.dosDate = 0; @@ -724,15 +1108,16 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, { if (zipfi->dosDate != 0) zi->ci.dosDate = zipfi->dosDate; - else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); + else + zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date); } - zi->ci.flag = 0; + zi->ci.flag = flagBase; if ((level==8) || (level==9)) zi->ci.flag |= 2; - if ((level==2)) + if (level==2) zi->ci.flag |= 4; - if ((level==1)) + if (level==1) zi->ci.flag |= 6; if (password != NULL) zi->ci.flag |= 1; @@ -743,37 +1128,43 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, zi->ci.stream_initialised = 0; zi->ci.pos_in_buffered_data = 0; zi->ci.raw = raw; - zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + - size_extrafield_global + size_comment; - zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); + zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream); - ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); + zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; + zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data + + zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); + + zi->ci.size_centralExtra = size_extrafield_global; + zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); /* version info */ - ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); - ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); - ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); - ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); - ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); - ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); - ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); - ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ + zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2); + zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); + zip64local_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); + zip64local_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); + zip64local_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); + zip64local_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ + zip64local_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ + zip64local_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ + zip64local_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); + zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); + zip64local_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); + zip64local_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); + zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); else - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); + zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); + zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); else - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); + zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); - ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); + if(zi->ci.pos_local_header >= 0xffffffff) + zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4); + else + zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writting_offset,4); for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); @@ -788,63 +1179,66 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, if (zi->ci.central_header == NULL) return ZIP_INTERNALERROR; - /* write the local header */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); + zi->ci.zip64 = zip64; + zi->ci.totalCompressedData = 0; + zi->ci.totalUncompressedData = 0; + zi->ci.pos_zip64extrainfo = 0; - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); + err = Write_LocalFileHeader(zi, filename, size_extrafield_local, extrafield_local); - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); - - if ((err==ZIP_OK) && (size_filename>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) - err = ZIP_ERRNO; - - if ((err==ZIP_OK) && (size_extrafield_local>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) - !=size_extrafield_local) - err = ZIP_ERRNO; +#ifdef HAVE_BZIP2 + zi->ci.bstream.avail_in = (uInt)0; + zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; + zi->ci.bstream.total_in_hi32 = 0; + zi->ci.bstream.total_in_lo32 = 0; + zi->ci.bstream.total_out_hi32 = 0; + zi->ci.bstream.total_out_lo32 = 0; +#endif zi->ci.stream.avail_in = (uInt)0; zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; zi->ci.stream.next_out = zi->ci.buffered_data; zi->ci.stream.total_in = 0; zi->ci.stream.total_out = 0; + zi->ci.stream.data_type = Z_BINARY; +#ifdef HAVE_BZIP2 + if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED || zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) +#else if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) +#endif { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; - zi->ci.stream.opaque = (voidpf)0; + if(zi->ci.method == Z_DEFLATED) + { + zi->ci.stream.zalloc = (alloc_func)0; + zi->ci.stream.zfree = (free_func)0; + zi->ci.stream.opaque = (voidpf)0; - if (windowBits>0) - windowBits = -windowBits; + if (windowBits>0) + windowBits = -windowBits; - err = deflateInit2(&zi->ci.stream, level, - Z_DEFLATED, windowBits, memLevel, strategy); + err = deflateInit2(&zi->ci.stream, level, Z_DEFLATED, windowBits, memLevel, strategy); + + if (err==Z_OK) + zi->ci.stream_initialised = Z_DEFLATED; + } + else if(zi->ci.method == Z_BZIP2ED) + { +#ifdef HAVE_BZIP2 + // Init BZip stuff here + zi->ci.bstream.bzalloc = 0; + zi->ci.bstream.bzfree = 0; + zi->ci.bstream.opaque = (voidpf)0; + + err = BZ2_bzCompressInit(&zi->ci.bstream, level, 0,35); + if(err == BZ_OK) + zi->ci.stream_initialised = Z_BZIP2ED; +#endif + } - if (err==Z_OK) - zi->ci.stream_initialised = 1; } + # ifndef NOCRYPT zi->ci.crypt_header_size = 0; if ((err==Z_OK) && (password != NULL)) @@ -858,7 +1252,7 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); zi->ci.crypt_header_size = sizeHead; - if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) + if (ZWRITE64(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) err = ZIP_ERRNO; } # endif @@ -868,53 +1262,105 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, return err; } -extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; - int raw; +extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, + uLong versionMadeBy, uLong flagBase) { - return zipOpenNewFileInZip3 (file, filename, zipfi, + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, versionMadeBy, flagBase, 0); +} + +extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, 0); +} + +extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, + int windowBits,int memLevel, int strategy, + const char* password, uLong crcForCrypting, int zip64) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, raw, + windowBits, memLevel, strategy, + password, crcForCrypting, VERSIONMADEBY, 0, zip64); +} + +extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, comment, method, level, raw, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0); + NULL, 0, VERSIONMADEBY, 0, 0); } -extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; +extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void* extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int raw, int zip64) { - return zipOpenNewFileInZip2 (file, filename, zipfi, + return zipOpenNewFileInZip4_64 (file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, size_extrafield_global, - comment, method, level, 0); + comment, method, level, raw, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); } -local int zipFlushWriteBuffer(zi) - zip_internal* zi; +extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level, int zip64) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, zip64); +} + +extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, + const void* extrafield_local, uInt size_extrafield_local, + const void*extrafield_global, uInt size_extrafield_global, + const char* comment, int method, int level) +{ + return zipOpenNewFileInZip4_64 (file, filename, zipfi, + extrafield_local, size_extrafield_local, + extrafield_global, size_extrafield_global, + comment, method, level, 0, + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, + NULL, 0, VERSIONMADEBY, 0, 0); +} + +local int zip64FlushWriteBuffer(zip64_internal* zi) { int err=ZIP_OK; @@ -924,169 +1370,374 @@ local int zipFlushWriteBuffer(zi) uInt i; int t; for (i=0;ici.pos_in_buffered_data;i++) - zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, - zi->ci.buffered_data[i],t); + zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t); #endif } - if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) - !=zi->ci.pos_in_buffered_data) + + if (ZWRITE64(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) != zi->ci.pos_in_buffered_data) err = ZIP_ERRNO; + + zi->ci.totalCompressedData += zi->ci.pos_in_buffered_data; + +#ifdef HAVE_BZIP2 + if(zi->ci.method == Z_BZIP2ED) + { + zi->ci.totalUncompressedData += zi->ci.bstream.total_in_lo32; + zi->ci.bstream.total_in_lo32 = 0; + zi->ci.bstream.total_in_hi32 = 0; + } + else +#endif + { + zi->ci.totalUncompressedData += zi->ci.stream.total_in; + zi->ci.stream.total_in = 0; + } + + zi->ci.pos_in_buffered_data = 0; + return err; } -extern int ZEXPORT zipWriteInFileInZip (file, buf, len) - zipFile file; - const void* buf; - unsigned len; +extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) { - zip_internal* zi; + zip64_internal* zi; int err=ZIP_OK; if (file == NULL) return ZIP_PARAMERROR; - zi = (zip_internal*)file; + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 0) return ZIP_PARAMERROR; - zi->ci.stream.next_in = (void*)buf; - zi->ci.stream.avail_in = len; - zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); + zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len); - while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) +#ifdef HAVE_BZIP2 + if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw)) { - if (zi->ci.stream.avail_out == 0) + zi->ci.bstream.next_in = (void*)buf; + zi->ci.bstream.avail_in = len; + err = BZ_RUN_OK; + + while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0)) + { + if (zi->ci.bstream.avail_out == 0) { - if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; } - if(err != ZIP_OK) - break; + if(err != BZ_RUN_OK) + break; - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) { - uLong uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_NO_FLUSH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32; +// uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; + err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ; } - else - { - uInt copy_this,i; - if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) - copy_this = zi->ci.stream.avail_in; - else - copy_this = zi->ci.stream.avail_out; - for (i=0;ici.stream.next_out)+i) = - *(((const char*)zi->ci.stream.next_in)+i); - { - zi->ci.stream.avail_in -= copy_this; - zi->ci.stream.avail_out-= copy_this; - zi->ci.stream.next_in+= copy_this; - zi->ci.stream.next_out+= copy_this; - zi->ci.stream.total_in+= copy_this; - zi->ci.stream.total_out+= copy_this; - zi->ci.pos_in_buffered_data += copy_this; - } - } + } + + if(err == BZ_RUN_OK) + err = ZIP_OK; + } + else +#endif + { + zi->ci.stream.next_in = (Bytef*)buf; + zi->ci.stream.avail_in = len; + + while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) + { + if (zi->ci.stream.avail_out == 0) + { + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + + + if(err != ZIP_OK) + break; + + if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) + { + uLong uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_NO_FLUSH); + if(uTotalOutBefore > zi->ci.stream.total_out) + { + int bBreak = 0; + bBreak++; + } + + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + } + else + { + uInt copy_this,i; + if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) + copy_this = zi->ci.stream.avail_in; + else + copy_this = zi->ci.stream.avail_out; + + for (i = 0; i < copy_this; i++) + *(((char*)zi->ci.stream.next_out)+i) = + *(((const char*)zi->ci.stream.next_in)+i); + { + zi->ci.stream.avail_in -= copy_this; + zi->ci.stream.avail_out-= copy_this; + zi->ci.stream.next_in+= copy_this; + zi->ci.stream.next_out+= copy_this; + zi->ci.stream.total_in+= copy_this; + zi->ci.stream.total_out+= copy_this; + zi->ci.pos_in_buffered_data += copy_this; + } + } + }// while(...) } return err; } -extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) - zipFile file; - uLong uncompressed_size; - uLong crc32; +extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) { - zip_internal* zi; - uLong compressed_size; + return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); +} + +extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) +{ + zip64_internal* zi; + ZPOS64_T compressed_size; + uLong invalidValue = 0xffffffff; + short datasize = 0; int err=ZIP_OK; if (file == NULL) return ZIP_PARAMERROR; - zi = (zip_internal*)file; + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 0) return ZIP_PARAMERROR; zi->ci.stream.avail_in = 0; if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - while (err==ZIP_OK) + { + while (err==ZIP_OK) + { + uLong uTotalOutBefore; + if (zi->ci.stream.avail_out == 0) + { + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.stream.next_out = zi->ci.buffered_data; + } + uTotalOutBefore = zi->ci.stream.total_out; + err=deflate(&zi->ci.stream, Z_FINISH); + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + } + } + else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) { +#ifdef HAVE_BZIP2 + err = BZ_FINISH_OK; + while (err==BZ_FINISH_OK) + { uLong uTotalOutBefore; - if (zi->ci.stream.avail_out == 0) + if (zi->ci.bstream.avail_out == 0) { - if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; + if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) + err = ZIP_ERRNO; + zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; + zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; } - uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_FINISH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; + uTotalOutBefore = zi->ci.bstream.total_out_lo32; + err=BZ2_bzCompress(&zi->ci.bstream, BZ_FINISH); + if(err == BZ_STREAM_END) + err = Z_STREAM_END; + + zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore); + } + + if(err == BZ_FINISH_OK) + err = ZIP_OK; +#endif } if (err==Z_STREAM_END) err=ZIP_OK; /* this is normal */ if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) - if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) + { + if (zip64FlushWriteBuffer(zi)==ZIP_ERRNO) err = ZIP_ERRNO; + } if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) { - err=deflateEnd(&zi->ci.stream); + int tmp_err = deflateEnd(&zi->ci.stream); + if (err == ZIP_OK) + err = tmp_err; zi->ci.stream_initialised = 0; } +#ifdef HAVE_BZIP2 + else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) + { + int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream); + if (err==ZIP_OK) + err = tmperr; + zi->ci.stream_initialised = 0; + } +#endif if (!zi->ci.raw) { crc32 = (uLong)zi->ci.crc32; - uncompressed_size = (uLong)zi->ci.stream.total_in; + uncompressed_size = zi->ci.totalUncompressedData; } - compressed_size = (uLong)zi->ci.stream.total_out; + compressed_size = zi->ci.totalCompressedData; + # ifndef NOCRYPT compressed_size += zi->ci.crypt_header_size; # endif - ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20, - compressed_size,4); /*compr size*/ + // update Current Item crc and sizes, + if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff) + { + /*version Made by*/ + zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2); + /*version needed*/ + zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2); + + } + + zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ + + + if(compressed_size >= 0xffffffff) + zip64local_putValue_inmemory(zi->ci.central_header+20, invalidValue,4); /*compr size*/ + else + zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/ + + /// set internal file attributes field if (zi->ci.stream.data_type == Z_ASCII) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); - ziplocal_putValue_inmemory(zi->ci.central_header+24, - uncompressed_size,4); /*uncompr size*/ + zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); + + if(uncompressed_size >= 0xffffffff) + zip64local_putValue_inmemory(zi->ci.central_header+24, invalidValue,4); /*uncompr size*/ + else + zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/ + + // Add ZIP64 extra info field for uncompressed size + if(uncompressed_size >= 0xffffffff) + datasize += 8; + + // Add ZIP64 extra info field for compressed size + if(compressed_size >= 0xffffffff) + datasize += 8; + + // Add ZIP64 extra info field for relative offset to local file header of current file + if(zi->ci.pos_local_header >= 0xffffffff) + datasize += 8; + + if(datasize > 0) + { + char* p = NULL; + + if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) + { + // we can not write more data to the buffer that we have room for. + return ZIP_BADZIPFILE; + } + + p = zi->ci.central_header + zi->ci.size_centralheader; + + // Add Extra Information Header for 'ZIP64 information' + zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID + p += 2; + zip64local_putValue_inmemory(p, datasize, 2); // DataSize + p += 2; + + if(uncompressed_size >= 0xffffffff) + { + zip64local_putValue_inmemory(p, uncompressed_size, 8); + p += 8; + } + + if(compressed_size >= 0xffffffff) + { + zip64local_putValue_inmemory(p, compressed_size, 8); + p += 8; + } + + if(zi->ci.pos_local_header >= 0xffffffff) + { + zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8); + p += 8; + } + + // Update how much extra free space we got in the memory buffer + // and increase the centralheader size so the new ZIP64 fields are included + // ( 4 below is the size of HeaderID and DataSize field ) + zi->ci.size_centralExtraFree -= datasize + 4; + zi->ci.size_centralheader += datasize + 4; + + // Update the extra info size field + zi->ci.size_centralExtra += datasize + 4; + zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2); + } if (err==ZIP_OK) - err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, - (uLong)zi->ci.size_centralheader); + err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader); + free(zi->ci.central_header); if (err==ZIP_OK) { - long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); - if (ZSEEK(zi->z_filefunc,zi->filestream, - zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) + // Update the LocalFileHeader with the new values. + + ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); + + if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) err = ZIP_ERRNO; if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ - if (err==ZIP_OK) /* compressed size, unknown */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); + if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff ) + { + if(zi->ci.pos_zip64extrainfo > 0) + { + // Update the size in the ZIP64 extended field. + if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0) + err = ZIP_ERRNO; - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); + if (err==ZIP_OK) /* compressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompressed_size, 8); - if (ZSEEK(zi->z_filefunc,zi->filestream, - cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) + if (err==ZIP_OK) /* uncompressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8); + } + else + err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal + } + else + { + if (err==ZIP_OK) /* compressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); + + if (err==ZIP_OK) /* uncompressed size, unknown */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); + } + + if (ZSEEK64(zi->z_filefunc,zi->filestream, cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) err = ZIP_ERRNO; } @@ -1096,104 +1747,274 @@ extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) return err; } -extern int ZEXPORT zipCloseFileInZip (file) - zipFile file; +extern int ZEXPORT zipCloseFileInZip (zipFile file) { return zipCloseFileInZipRaw (file,0,0); } -extern int ZEXPORT zipClose (file, global_comment) - zipFile file; - const char* global_comment; +local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) { - zip_internal* zi; - int err = 0; - uLong size_centraldir = 0; - uLong centraldir_pos_inzip ; - uInt size_global_comment; + int err = ZIP_OK; + ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); + + /*num disks*/ + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); + + /*relative offset*/ + if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, pos,8); + + /*total disks*/ /* Do not support spawning of disk so always say 1 here*/ + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4); + + return err; +} + +local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) +{ + int err = ZIP_OK; + + uLong Zip64DataSize = 44; + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); + + if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ? + + if (err==ZIP_OK) /* version made by */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); + + if (err==ZIP_OK) /* version needed */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); + + if (err==ZIP_OK) /* number of this disk */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); + + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); + + if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); + + if (err==ZIP_OK) /* total number of entries in the central dir */ + err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); + + if (err==ZIP_OK) /* size of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_centraldir,8); + + if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ + { + ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); + } + return err; +} + +local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) +{ + int err = ZIP_OK; + + /*signature*/ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); + + if (err==ZIP_OK) /* number of this disk */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* number of the disk with the start of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + + if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ + { + { + if(zi->number_entry >= 0xFFFF) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + } + } + + if (err==ZIP_OK) /* total number of entries in the central dir */ + { + if(zi->number_entry >= 0xFFFF) + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + } + + if (err==ZIP_OK) /* size of the central directory */ + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); + + if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ + { + ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; + if(pos >= 0xffffffff) + { + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); + } + else + err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); + } + + return err; +} + +local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) +{ + int err = ZIP_OK; + uInt size_global_comment = 0; + + if(global_comment != NULL) + size_global_comment = (uInt)strlen(global_comment); + + err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); + + if (err == ZIP_OK && size_global_comment > 0) + { + if (ZWRITE64(zi->z_filefunc,zi->filestream, global_comment, size_global_comment) != size_global_comment) + err = ZIP_ERRNO; + } + return err; +} + +extern int ZEXPORT zipFlush (zipFile file) +{ + zip64_internal* zi; + if (file == NULL) return ZIP_PARAMERROR; - zi = (zip_internal*)file; + + zi = (zip64_internal*)file; + + return ZFLUSH64(zi->z_filefunc,zi->filestream); +} + +extern int ZEXPORT zipClose (zipFile file, const char* global_comment) +{ + zip64_internal* zi; + int err = 0; + uLong size_centraldir = 0; + ZPOS64_T centraldir_pos_inzip; + ZPOS64_T pos; + + if (file == NULL) + return ZIP_PARAMERROR; + + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 1) { err = zipCloseFileInZip (file); } +#ifndef NO_ADDFILEINEXISTINGZIP if (global_comment==NULL) - size_global_comment = 0; - else - size_global_comment = strlen(global_comment); + global_comment = zi->globalcomment; +#endif + centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); - centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); if (err==ZIP_OK) { - linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; + linkedlist_datablock_internal* ldi = zi->central_dir.first_block; while (ldi!=NULL) { if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream, - ldi->data,ldi->filled_in_this_block) - !=ldi->filled_in_this_block ) + { + if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block) err = ZIP_ERRNO; + } size_centraldir += ldi->filled_in_this_block; ldi = ldi->next_datablock; } } - free_datablock(zi->central_dir.first_block); + free_linkedlist(&(zi->central_dir)); - if (err==ZIP_OK) /* Magic End */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); + pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; + if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) + { + ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); + Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); - if (err==ZIP_OK) /* number of this disk */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); + } - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); + if (err==ZIP_OK) + err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); + if(err == ZIP_OK) + err = Write_GlobalComment(zi, global_comment); - if (err==ZIP_OK) /* total number of entries in the central dir */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* size of the central directory */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the - starting disk number */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, - (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); - - if (err==ZIP_OK) /* zipfile comment length */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); - - if ((err==ZIP_OK) && (size_global_comment>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream, - global_comment,size_global_comment) != size_global_comment) - err = ZIP_ERRNO; - - if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) + if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) if (err == ZIP_OK) err = ZIP_ERRNO; +#ifndef NO_ADDFILEINEXISTINGZIP + TRYFREE(zi->globalcomment); +#endif TRYFREE(zi); return err; } -extern int ZEXPORT zipFlush (file) - zipFile file; +extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) { - zip_internal* zi; - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; + char* p = pData; + int size = 0; + char* pNewHeader; + char* pTmp; + short header; + short dataSize; - if (zi->z_filefunc.zflush_file != NULL && zi->filestream != NULL) - return ZFLUSH(zi->z_filefunc,zi->filestream); + int retVal = ZIP_OK; + + if(pData == NULL || *dataLen < 4) + return ZIP_PARAMERROR; + + pNewHeader = (char*)ALLOC(*dataLen); + pTmp = pNewHeader; + + while(p < (pData + *dataLen)) + { + header = *(short*)p; + dataSize = *(((short*)p)+1); + + if( header == sHeader ) // Header found. + { + p += dataSize + 4; // skip it. do not copy to temp buffer + } else - return EOF; + { + // Extra Info block should not be removed, So copy it to the temp buffer. + memcpy(pTmp, p, dataSize + 4); + p += dataSize + 4; + size += dataSize + 4; + } + + } + + if(size < *dataLen) + { + // clean old extra info block. + memset(pData,0, *dataLen); + + // copy the new extra info block over the old + if(size > 0) + memcpy(pData, pNewHeader, size); + + // set the new extra info size + *dataLen = size; + + retVal = ZIP_OK; + } + else + retVal = ZIP_ERRNO; + + TRYFREE(pNewHeader); + + return retVal; } diff --git a/src/minizip/zip.c.diff b/src/minizip/zip.c.diff new file mode 100644 index 0000000..204d985 --- /dev/null +++ b/src/minizip/zip.c.diff @@ -0,0 +1,85 @@ +--- zip.c.orig 2013-02-24 08:32:30.000000000 +0100 ++++ zip.c 2014-05-24 13:52:45.570151611 +0200 +@@ -186,7 +186,7 @@ + #include "crypt.h" + #endif + +-local linkedlist_datablock_internal* allocate_new_datablock() ++local linkedlist_datablock_internal* allocate_new_datablock(void) + { + linkedlist_datablock_internal* ldi; + ldi = (linkedlist_datablock_internal*) +@@ -637,7 +637,7 @@ + return relativeOffset; + } + +-int LoadCentralDirectoryRecord(zip64_internal* pziinit) ++local int LoadCentralDirectoryRecord(zip64_internal* pziinit) + { + int err=ZIP_OK; + ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ +@@ -955,7 +955,7 @@ + return zipOpen3(pathname,append,NULL,NULL); + } + +-int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) ++local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) + { + /* write the local header */ + int err; +@@ -1752,7 +1752,7 @@ + return zipCloseFileInZipRaw (file,0,0); + } + +-int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) ++local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) + { + int err = ZIP_OK; + ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; +@@ -1774,7 +1774,7 @@ + return err; + } + +-int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) ++local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) + { + int err = ZIP_OK; + +@@ -1813,7 +1813,8 @@ + } + return err; + } +-int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) ++ ++local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) + { + int err = ZIP_OK; + +@@ -1861,7 +1862,7 @@ + return err; + } + +-int Write_GlobalComment(zip64_internal* zi, const char* global_comment) ++local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) + { + int err = ZIP_OK; + uInt size_global_comment = 0; +@@ -1879,6 +1880,18 @@ + return err; + } + ++extern int ZEXPORT zipFlush (zipFile file) ++{ ++ zip64_internal* zi; ++ ++ if (file == NULL) ++ return ZIP_PARAMERROR; ++ ++ zi = (zip64_internal*)file; ++ ++ return ZFLUSH64(zi->z_filefunc,zi->filestream); ++} ++ + extern int ZEXPORT zipClose (zipFile file, const char* global_comment) + { + zip64_internal* zi; diff --git a/src/minizip/zip.c.orig b/src/minizip/zip.c.orig deleted file mode 100644 index 0221bd4..0000000 --- a/src/minizip/zip.c.orig +++ /dev/null @@ -1,1180 +0,0 @@ -/* zip.c -- IO on .zip files using zlib - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - Read zip.h for more info -*/ - - -#include -#include -#include -#include -#include "zlib.h" -#include "zip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -#ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ -#endif - -#ifndef Z_BUFSIZE -#define Z_BUFSIZE (16384) -#endif - -#ifndef Z_MAXFILENAMEINZIP -#define Z_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -/* -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) -*/ - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifndef DEF_MEM_LEVEL -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -#endif -const char zip_copyright[] = - " zip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; - - -#define SIZEDATA_INDATABLOCK (4096-(4*4)) - -#define LOCALHEADERMAGIC (0x04034b50) -#define CENTRALHEADERMAGIC (0x02014b50) -#define ENDHEADERMAGIC (0x06054b50) - -#define FLAG_LOCALHEADER_OFFSET (0x06) -#define CRC_LOCALHEADER_OFFSET (0x0e) - -#define SIZECENTRALHEADER (0x2e) /* 46 */ - -typedef struct linkedlist_datablock_internal_s -{ - struct linkedlist_datablock_internal_s* next_datablock; - uLong avail_in_this_block; - uLong filled_in_this_block; - uLong unused; /* for future use and alignement */ - unsigned char data[SIZEDATA_INDATABLOCK]; -} linkedlist_datablock_internal; - -typedef struct linkedlist_data_s -{ - linkedlist_datablock_internal* first_block; - linkedlist_datablock_internal* last_block; -} linkedlist_data; - - -typedef struct -{ - z_stream stream; /* zLib stream structure for inflate */ - int stream_initialised; /* 1 is stream is initialised */ - uInt pos_in_buffered_data; /* last written byte in buffered_data */ - - uLong pos_local_header; /* offset of the local header of the file - currenty writing */ - char* central_header; /* central header data for the current file */ - uLong size_centralheader; /* size of the central header for cur file */ - uLong flag; /* flag of the file currently writing */ - - int method; /* compression method of file currenty wr.*/ - int raw; /* 1 for directly writing raw data */ - Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ - uLong dosDate; - uLong crc32; - int encrypt; -#ifndef NOCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const unsigned long* pcrc_32_tab; - int crypt_header_size; -#endif -} curfile_info; - -typedef struct -{ - zlib_filefunc_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - linkedlist_data central_dir;/* datablock with central dir in construction*/ - int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile_info ci; /* info on the file curretly writing */ - - uLong begin_pos; /* position of the beginning of the zipfile */ - uLong add_position_when_writting_offset; - uLong number_entry; -} zip_internal; - - - -#ifndef NOCRYPT -#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED -#include "crypt.h" -#endif - -local linkedlist_datablock_internal* allocate_new_datablock() -{ - linkedlist_datablock_internal* ldi; - ldi = (linkedlist_datablock_internal*) - ALLOC(sizeof(linkedlist_datablock_internal)); - if (ldi!=NULL) - { - ldi->next_datablock = NULL ; - ldi->filled_in_this_block = 0 ; - ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; - } - return ldi; -} - -local void free_datablock(ldi) - linkedlist_datablock_internal* ldi; -{ - while (ldi!=NULL) - { - linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); - ldi = ldinext; - } -} - -local void init_linkedlist(ll) - linkedlist_data* ll; -{ - ll->first_block = ll->last_block = NULL; -} - -local void free_linkedlist(ll) - linkedlist_data* ll; -{ - free_datablock(ll->first_block); - ll->first_block = ll->last_block = NULL; -} - - -local int add_data_in_datablock(ll,buf,len) - linkedlist_data* ll; - const void* buf; - uLong len; -{ - linkedlist_datablock_internal* ldi; - const unsigned char* from_copy; - - if (ll==NULL) - return ZIP_INTERNALERROR; - - if (ll->last_block == NULL) - { - ll->first_block = ll->last_block = allocate_new_datablock(); - if (ll->first_block == NULL) - return ZIP_INTERNALERROR; - } - - ldi = ll->last_block; - from_copy = (unsigned char*)buf; - - while (len>0) - { - uInt copy_this; - uInt i; - unsigned char* to_copy; - - if (ldi->avail_in_this_block==0) - { - ldi->next_datablock = allocate_new_datablock(); - if (ldi->next_datablock == NULL) - return ZIP_INTERNALERROR; - ldi = ldi->next_datablock ; - ll->last_block = ldi; - } - - if (ldi->avail_in_this_block < len) - copy_this = (uInt)ldi->avail_in_this_block; - else - copy_this = (uInt)len; - - to_copy = &(ldi->data[ldi->filled_in_this_block]); - - for (i=0;ifilled_in_this_block += copy_this; - ldi->avail_in_this_block -= copy_this; - from_copy += copy_this ; - len -= copy_this; - } - return ZIP_OK; -} - - - -/****************************************************************************/ - -#ifndef NO_ADDFILEINEXISTINGZIP -/* =========================================================================== - Inputs a long in LSB order to the given file - nbByte == 1, 2 or 4 (byte, short or long) -*/ - -local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, uLong x, int nbByte)); -local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong x; - int nbByte; -{ - unsigned char buf[4]; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - if (x != 0) { // data overflow - hack for ZIP64 - for (n = 0; n < nbByte; n++) { - buf[n] = 0xff; - } - } - if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) - return ZIP_ERRNO; - else - return ZIP_OK; -} - -local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); -local void ziplocal_putValue_inmemory (dest, x, nbByte) - void* dest; - uLong x; - int nbByte; -{ - unsigned char* buf=(unsigned char*)dest; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - if (x != 0) { // data overflow - hack for ZIP64 - for (n = 0; n < nbByte; n++) { - buf[n] = 0xff; - } - } -} -/****************************************************************************/ - - -local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) - const tm_zip* ptm; - uLong dosDate; -{ - uLong year = (uLong)ptm->tm_year; - if (year>1980) - year-=1980; - else if (year>80) - year-=80; - return - (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | - ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); -} - - -/****************************************************************************/ - -local int ziplocal_getByte OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); - -local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - int *pi; -{ - unsigned char c; - int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) - { - *pi = (int)c; - return ZIP_OK; - } - else - { - if (ZERROR(*pzlib_filefunc_def,filestream)) - return ZIP_ERRNO; - else - return ZIP_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int ziplocal_getShort OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int ziplocal_getLong OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<16; - - if (err==ZIP_OK) - err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - return err; -} - -#ifndef BUFREADCOMMENT -#define BUFREADCOMMENT (0x400) -#endif -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local uLong ziplocal_SearchCentralDir OF(( - const zlib_filefunc_def* pzlib_filefunc_def, - voidpf filestream)); - -local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) - const zlib_filefunc_def* pzlib_filefunc_def; - voidpf filestream; -{ - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} -#endif /* !NO_ADDFILEINEXISTINGZIP*/ - -/************************************************************/ -extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) - const char *pathname; - int append; - zipcharpc* globalcomment; - zlib_filefunc_def* pzlib_filefunc_def; -{ - zip_internal ziinit; - zip_internal* zi; - int err=ZIP_OK; - - - if (pzlib_filefunc_def==NULL) - fill_fopen_filefunc(&ziinit.z_filefunc); - else - ziinit.z_filefunc = *pzlib_filefunc_def; - - ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) - (ziinit.z_filefunc.opaque, - pathname, - (append == APPEND_STATUS_CREATE) ? - (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : - (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); - - if (ziinit.filestream == NULL) - return NULL; - ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - ziinit.add_position_when_writting_offset = 0; - init_linkedlist(&(ziinit.central_dir)); - - - zi = (zip_internal*)ALLOC(sizeof(zip_internal)); - if (zi==NULL) - { - ZCLOSE(ziinit.z_filefunc,ziinit.filestream); - return NULL; - } - - /* now we add file in a zipfile */ -# ifndef NO_ADDFILEINEXISTINGZIP - if (append == APPEND_STATUS_ADDINZIP) - { - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory */ - uLong central_pos,uL; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry; - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - uLong size_comment; - - central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); - if (central_pos==0) - err=ZIP_ERRNO; - - if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; - - /* the signature, already checked */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of this disk */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of the disk with the start of the central directory */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((number_entry_CD!=number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=ZIP_BADZIPFILE; - - /* size of the central directory */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* zipfile comment length */ - if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((central_pos0) && (err==ZIP_OK)) - { - uLong read_this = SIZEDATA_INDATABLOCK; - if (read_this > size_central_dir_to_read) - read_this = size_central_dir_to_read; - if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) - err=ZIP_ERRNO; - - if (err==ZIP_OK) - err = add_data_in_datablock(&ziinit.central_dir,buf_read, - (uLong)read_this); - size_central_dir_to_read-=read_this; - } - TRYFREE(buf_read); - } - ziinit.begin_pos = byte_before_the_zipfile; - ziinit.number_entry = number_entry_CD; - - if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, - offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; - } -# endif /* !NO_ADDFILEINEXISTINGZIP*/ - - if (err != ZIP_OK) - { - TRYFREE(zi); - return NULL; - } - else - { - *zi = ziinit; - return (zipFile)zi; - } -} - -extern zipFile ZEXPORT zipOpen (pathname, append) - const char *pathname; - int append; -{ - return zipOpen2(pathname,append,NULL,NULL); -} - -extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; - int raw; - int windowBits; - int memLevel; - int strategy; - const char* password; - uLong crcForCrypting; -{ - zip_internal* zi; - uInt size_filename; - uInt size_comment; - uInt i; - int err = ZIP_OK; - -# ifdef NOCRYPT - if (password != NULL) - return ZIP_PARAMERROR; -# endif - - if (file == NULL) - return ZIP_PARAMERROR; - if ((method!=0) && (method!=Z_DEFLATED)) - return ZIP_PARAMERROR; - - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - if (err != ZIP_OK) - return err; - } - - - if (filename==NULL) - filename="-"; - - if (comment==NULL) - size_comment = 0; - else - size_comment = strlen(comment); - - size_filename = strlen(filename); - - if (zipfi == NULL) - zi->ci.dosDate = 0; - else - { - if (zipfi->dosDate != 0) - zi->ci.dosDate = zipfi->dosDate; - else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); - } - - zi->ci.flag = 0; - if ((level==8) || (level==9)) - zi->ci.flag |= 2; - if ((level==2)) - zi->ci.flag |= 4; - if ((level==1)) - zi->ci.flag |= 6; - if (password != NULL) - zi->ci.flag |= 1; - - zi->ci.crc32 = 0; - zi->ci.method = method; - zi->ci.encrypt = 0; - zi->ci.stream_initialised = 0; - zi->ci.pos_in_buffered_data = 0; - zi->ci.raw = raw; - zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + - size_extrafield_global + size_comment; - zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); - - ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); - /* version info */ - ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); - ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); - ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); - ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); - ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); - ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); - ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); - ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); - else - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); - else - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); - - ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); - - for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = - *(((const char*)extrafield_global)+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ - size_extrafield_global+i) = *(comment+i); - if (zi->ci.central_header == NULL) - return ZIP_INTERNALERROR; - - /* write the local header */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); - - if ((err==ZIP_OK) && (size_filename>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) - err = ZIP_ERRNO; - - if ((err==ZIP_OK) && (size_extrafield_local>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) - !=size_extrafield_local) - err = ZIP_ERRNO; - - zi->ci.stream.avail_in = (uInt)0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - zi->ci.stream.total_in = 0; - zi->ci.stream.total_out = 0; - - if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; - zi->ci.stream.opaque = (voidpf)0; - - if (windowBits>0) - windowBits = -windowBits; - - err = deflateInit2(&zi->ci.stream, level, - Z_DEFLATED, windowBits, memLevel, strategy); - - if (err==Z_OK) - zi->ci.stream_initialised = 1; - } -# ifndef NOCRYPT - zi->ci.crypt_header_size = 0; - if ((err==Z_OK) && (password != NULL)) - { - unsigned char bufHead[RAND_HEAD_LEN]; - unsigned int sizeHead; - zi->ci.encrypt = 1; - zi->ci.pcrc_32_tab = get_crc_table(); - /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ - - sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); - zi->ci.crypt_header_size = sizeHead; - - if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) - err = ZIP_ERRNO; - } -# endif - - if (err==Z_OK) - zi->in_opened_file_inzip = 1; - return err; -} - -extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; - int raw; -{ - return zipOpenNewFileInZip3 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0); -} - -extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; -{ - return zipOpenNewFileInZip2 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0); -} - -local int zipFlushWriteBuffer(zi) - zip_internal* zi; -{ - int err=ZIP_OK; - - if (zi->ci.encrypt != 0) - { -#ifndef NOCRYPT - uInt i; - int t; - for (i=0;ici.pos_in_buffered_data;i++) - zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, - zi->ci.buffered_data[i],t); -#endif - } - if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) - !=zi->ci.pos_in_buffered_data) - err = ZIP_ERRNO; - zi->ci.pos_in_buffered_data = 0; - return err; -} - -extern int ZEXPORT zipWriteInFileInZip (file, buf, len) - zipFile file; - const void* buf; - unsigned len; -{ - zip_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - - zi->ci.stream.next_in = (void*)buf; - zi->ci.stream.avail_in = len; - zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); - - while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) - { - if (zi->ci.stream.avail_out == 0) - { - if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - - - if(err != ZIP_OK) - break; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - uLong uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_NO_FLUSH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - - } - else - { - uInt copy_this,i; - if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) - copy_this = zi->ci.stream.avail_in; - else - copy_this = zi->ci.stream.avail_out; - for (i=0;ici.stream.next_out)+i) = - *(((const char*)zi->ci.stream.next_in)+i); - { - zi->ci.stream.avail_in -= copy_this; - zi->ci.stream.avail_out-= copy_this; - zi->ci.stream.next_in+= copy_this; - zi->ci.stream.next_out+= copy_this; - zi->ci.stream.total_in+= copy_this; - zi->ci.stream.total_out+= copy_this; - zi->ci.pos_in_buffered_data += copy_this; - } - } - } - - return err; -} - -extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) - zipFile file; - uLong uncompressed_size; - uLong crc32; -{ - zip_internal* zi; - uLong compressed_size; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - zi->ci.stream.avail_in = 0; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - while (err==ZIP_OK) - { - uLong uTotalOutBefore; - if (zi->ci.stream.avail_out == 0) - { - if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_FINISH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - } - - if (err==Z_STREAM_END) - err=ZIP_OK; /* this is normal */ - - if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) - if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) - err = ZIP_ERRNO; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - err=deflateEnd(&zi->ci.stream); - zi->ci.stream_initialised = 0; - } - - if (!zi->ci.raw) - { - crc32 = (uLong)zi->ci.crc32; - uncompressed_size = (uLong)zi->ci.stream.total_in; - } - compressed_size = (uLong)zi->ci.stream.total_out; -# ifndef NOCRYPT - compressed_size += zi->ci.crypt_header_size; -# endif - - ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20, - compressed_size,4); /*compr size*/ - if (zi->ci.stream.data_type == Z_ASCII) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); - ziplocal_putValue_inmemory(zi->ci.central_header+24, - uncompressed_size,4); /*uncompr size*/ - - if (err==ZIP_OK) - err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, - (uLong)zi->ci.size_centralheader); - free(zi->ci.central_header); - - if (err==ZIP_OK) - { - long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); - if (ZSEEK(zi->z_filefunc,zi->filestream, - zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - - if (err==ZIP_OK) - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ - - if (err==ZIP_OK) /* compressed size, unknown */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); - - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); - - if (ZSEEK(zi->z_filefunc,zi->filestream, - cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - } - - zi->number_entry ++; - zi->in_opened_file_inzip = 0; - - return err; -} - -extern int ZEXPORT zipCloseFileInZip (file) - zipFile file; -{ - return zipCloseFileInZipRaw (file,0,0); -} - -extern int ZEXPORT zipClose (file, global_comment) - zipFile file; - const char* global_comment; -{ - zip_internal* zi; - int err = 0; - uLong size_centraldir = 0; - uLong centraldir_pos_inzip ; - uInt size_global_comment; - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - } - - if (global_comment==NULL) - size_global_comment = 0; - else - size_global_comment = strlen(global_comment); - - - centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); - if (err==ZIP_OK) - { - linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; - while (ldi!=NULL) - { - if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream, - ldi->data,ldi->filled_in_this_block) - !=ldi->filled_in_this_block ) - err = ZIP_ERRNO; - - size_centraldir += ldi->filled_in_this_block; - ldi = ldi->next_datablock; - } - } - free_datablock(zi->central_dir.first_block); - - if (err==ZIP_OK) /* Magic End */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); - - if (err==ZIP_OK) /* number of this disk */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); - - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); - - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* total number of entries in the central dir */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* size of the central directory */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the - starting disk number */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, - (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); - - if (err==ZIP_OK) /* zipfile comment length */ - err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); - - if ((err==ZIP_OK) && (size_global_comment>0)) - if (ZWRITE(zi->z_filefunc,zi->filestream, - global_comment,size_global_comment) != size_global_comment) - err = ZIP_ERRNO; - - if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) - if (err == ZIP_OK) - err = ZIP_ERRNO; - - TRYFREE(zi); - - return err; -} diff --git a/src/minizip/zip.h b/src/minizip/zip.h index d4337b7..16dea6b 100644 --- a/src/minizip/zip.h +++ b/src/minizip/zip.h @@ -1,18 +1,15 @@ -/* zip.h -- IO for compress .zip files using zlib - Version 1.00, September 10th, 2003 +/* zip.h -- IO on .zip files using zlib + Version 1.1, February 14h, 2010 + part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - Copyright (C) 1998-2003 Gilles Vollant + Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - This unzip package allow creates .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - For uncompress .zip file, look at unzip.h + For more info read MiniZip_info.txt - - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.html for evolution + --------------------------------------------------------------------------- Condition of use and distribution are the same than zlib : @@ -32,23 +29,23 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. + --------------------------------------------------------------------------- + + Changes + + See header of zip.h */ -/* for more info about .ZIP format, see - http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip - http://www.info-zip.org/pub/infozip/doc/ - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _zip_H -#define _zip_H +#ifndef _zip12_H +#define _zip12_H #ifdef __cplusplus extern "C" { #endif +//#define HAVE_BZIP2 + #ifndef _ZLIB_H #include "zlib.h" #endif @@ -57,6 +54,12 @@ extern "C" { #include "ioapi.h" #endif +#ifdef HAVE_BZIP2 +#include "bzlib.h" +#endif + +#define Z_BZIP2ED 12 + #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) /* like the STRICT of WIN32, we define a pointer that cannot be converted from (void*) without cast */ @@ -111,6 +114,7 @@ typedef const char* zipcharpc; #define APPEND_STATUS_ADDINZIP (2) extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); +extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); /* Create a zipfile. pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on @@ -135,6 +139,16 @@ extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc_def)); +extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc64_def* pzlib_filefunc_def)); + +extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, + int append, + zipcharpc* globalcomment, + zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); + extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* filename, const zip_fileinfo* zipfi, @@ -145,6 +159,19 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char* comment, int method, int level)); + +extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int zip64)); + /* Open a file in the ZIP for writing. filename : the filename in zip (if NULL, '-' without quote will be used @@ -156,6 +183,9 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, if comment != NULL, comment contain the comment string method contain the compression method (0 for store, Z_DEFLATED for deflate) level contain the level of compression (can be Z_DEFAULT_COMPRESSION) + zip64 is set to 1 if a zip64 extended information block should be added to the local file header. + this MUST be '1' if the uncompressed size is >= 0xffffffff. + */ @@ -171,6 +201,19 @@ extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, int level, int raw)); + +extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int zip64)); /* Same than zipOpenNewFileInZip, except if raw=1, we write raw file */ @@ -190,13 +233,79 @@ extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, int memLevel, int strategy, const char* password, - uLong crcForCtypting)); + uLong crcForCrypting)); + +extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + int zip64 + )); /* Same than zipOpenNewFileInZip2, except windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 password : crypting password (NULL for no crypting) - crcForCtypting : crc of file to compress (needed for crypting) + crcForCrypting : crc of file to compress (needed for crypting) + */ + +extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase + )); + + +extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, + const void* extrafield_local, + uInt size_extrafield_local, + const void* extrafield_global, + uInt size_extrafield_global, + const char* comment, + int method, + int level, + int raw, + int windowBits, + int memLevel, + int strategy, + const char* password, + uLong crcForCrypting, + uLong versionMadeBy, + uLong flagBase, + int zip64 + )); +/* + Same than zipOpenNewFileInZip4, except + versionMadeBy : value for Version made by field + flag : value for flag field (compression level info will be added) */ @@ -207,6 +316,11 @@ extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, Write data in the zipfile */ +extern int ZEXPORT zipFlush OF((zipFile file)); +/* + Flush the zipfile output +*/ + extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); /* Close the current file in the zipfile @@ -215,8 +329,13 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, uLong uncompressed_size, uLong crc32)); + +extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, + ZPOS64_T uncompressed_size, + uLong crc32)); + /* - Close the current file in the zipfile, for fiel opened with + Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2 uncompressed_size and crc32 are value for the uncompressed size */ @@ -227,13 +346,27 @@ extern int ZEXPORT zipClose OF((zipFile file, Close the zipfile */ -extern int ZEXPORT zipFlush OF((zipFile file)); + +extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); /* - Flush the zipfile output + zipRemoveExtraInfoBlock - Added by Mathias Svensson + + Remove extra information block from a extra information data for the local file header or central directory header + + It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode. + + 0x0001 is the signature header for the ZIP64 extra information blocks + + usage. + Remove ZIP64 Extra information from a central director extra field data + zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001); + + Remove ZIP64 Extra information from a Local File Header extra field data + zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001); */ #ifdef __cplusplus } #endif -#endif /* _zip_H */ +#endif /* _zip64_H */ diff --git a/src/minizip/zip.h.diff b/src/minizip/zip.h.diff new file mode 100644 index 0000000..f17bddc --- /dev/null +++ b/src/minizip/zip.h.diff @@ -0,0 +1,26 @@ +--- zip.h.orig 2010-02-15 12:58:22.000000000 +0100 ++++ zip.h 2014-05-24 13:47:52.838188589 +0200 +@@ -144,6 +144,11 @@ + zipcharpc* globalcomment, + zlib_filefunc64_def* pzlib_filefunc_def)); + ++extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, ++ int append, ++ zipcharpc* globalcomment, ++ zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); ++ + extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, + const char* filename, + const zip_fileinfo* zipfi, +@@ -311,6 +316,11 @@ + Write data in the zipfile + */ + ++extern int ZEXPORT zipFlush OF((zipFile file)); ++/* ++ Flush the zipfile output ++*/ ++ + extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); + /* + Close the current file in the zipfile diff --git a/src/minizip/zip.h.orig b/src/minizip/zip.h.orig deleted file mode 100644 index c37ea21..0000000 --- a/src/minizip/zip.h.orig +++ /dev/null @@ -1,235 +0,0 @@ -/* zip.h -- IO for compress .zip files using zlib - Version 1.00, September 10th, 2003 - - Copyright (C) 1998-2003 Gilles Vollant - - This unzip package allow creates .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - For uncompress .zip file, look at unzip.h - - - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.html for evolution - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - -*/ - -/* for more info about .ZIP format, see - http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip - http://www.info-zip.org/pub/infozip/doc/ - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _zip_H -#define _zip_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#ifndef _ZLIBIOAPI_H -#include "ioapi.h" -#endif - -#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zipFile__; -typedef zipFile__ *zipFile; -#else -typedef voidp zipFile; -#endif - -#define ZIP_OK (0) -#define ZIP_EOF (0) -#define ZIP_ERRNO (Z_ERRNO) -#define ZIP_PARAMERROR (-102) -#define ZIP_BADZIPFILE (-103) -#define ZIP_INTERNALERROR (-104) - -#ifndef DEF_MEM_LEVEL -# if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -# else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -# endif -#endif -/* default memLevel */ - -/* tm_zip contain date/time info */ -typedef struct tm_zip_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_zip; - -typedef struct -{ - tm_zip tmz_date; /* date in understandable format */ - uLong dosDate; /* if dos_date == 0, tmu_date is used */ -/* uLong flag; */ /* general purpose bit flag 2 bytes */ - - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ -} zip_fileinfo; - -typedef const char* zipcharpc; - - -#define APPEND_STATUS_CREATE (0) -#define APPEND_STATUS_CREATEAFTER (1) -#define APPEND_STATUS_ADDINZIP (2) - -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -/* - Create a zipfile. - pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on - an Unix computer "zlib/zlib113.zip". - if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip - will be created at the end of the file. - (useful if the file contain a self extractor code) - if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will - add files in existing zip (be sure you don't add file that doesn't exist) - If the zipfile cannot be opened, the return value is NULL. - Else, the return value is a zipFile Handle, usable with other function - of this zip package. -*/ - -/* Note : there is no delete function into a zipfile. - If you want delete file into a zipfile, you must open a zipfile, and create another - Of couse, you can use RAW reading and writing to copy the file you did not want delte -*/ - -extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc_def* pzlib_filefunc_def)); - -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); -/* - Open a file in the ZIP for writing. - filename : the filename in zip (if NULL, '-' without quote will be used - *zipfi contain supplemental information - if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header - if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header - if comment != NULL, comment contain the comment string - method contain the compression method (0 for store, Z_DEFLATED for deflate) - level contain the level of compression (can be Z_DEFAULT_COMPRESSION) -*/ - - -extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw)); - -/* - Same than zipOpenNewFileInZip, except if raw=1, we write raw file - */ - -extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCtypting)); - -/* - Same than zipOpenNewFileInZip2, except - windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 - password : crypting password (NULL for no crypting) - crcForCtypting : crc of file to compress (needed for crypting) - */ - - -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const void* buf, - unsigned len)); -/* - Write data in the zipfile -*/ - -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); -/* - Close the current file in the zipfile -*/ - - -extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, - uLong uncompressed_size, - uLong crc32)); -/* - Close the current file in the zipfile, for fiel opened with - parameter raw=1 in zipOpenNewFileInZip2 - uncompressed_size and crc32 are value for the uncompressed size -*/ - -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); -/* - Close the zipfile -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _zip_H */ diff --git a/src/proxy/main.c b/src/proxy/main.c index b502150..181994b 100644 --- a/src/proxy/main.c +++ b/src/proxy/main.c @@ -31,6 +31,7 @@ Please visit our Website: http://www.httrack.com #include #include +#define HTSSAFE_ABORT_FUNCTION(A,B,C) #include "htsbase.h" #include "htsnet.h" #include "htslib.h" diff --git a/src/proxy/proxytrack.c b/src/proxy/proxytrack.c index dabb761..f2fc4d0 100644 --- a/src/proxy/proxytrack.c +++ b/src/proxy/proxytrack.c @@ -226,18 +226,17 @@ static int linputsoc_t(T_SOC soc, char *s, int max, int timeout) { return -1; } -static int gethost(const char *hostname, SOCaddr * server, size_t server_size) { +static int gethost(const char *hostname, SOCaddr * server) { if (hostname != NULL && *hostname != '\0') { #if HTS_INET6==0 /* ipV4 resolver */ - t_hostent *hp = gethostbyname(hostname); + struct hostent *hp = gethostbyname(hostname); if (hp != NULL) { if (hp->h_length) { - SOCaddr_copyaddr(*server, server_size, hp->h_addr_list[0], - hp->h_length); + SOCaddr_copyaddr2(*server, hp->h_addr_list[0], hp->h_length); return 1; } } @@ -256,13 +255,13 @@ static int gethost(const char *hostname, SOCaddr * server, size_t server_size) { hints.ai_family = PF_INET6; else #endif - hints.ai_family = PF_UNSPEC; + hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if (getaddrinfo(hostname, NULL, &hints, &res) == 0) { if (res) { if ((res->ai_addr) && (res->ai_addrlen)) { - SOCaddr_copyaddr(*server, server_size, res->ai_addr, res->ai_addrlen); + SOCaddr_copyaddr2(*server, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); return 1; } @@ -276,7 +275,7 @@ static int gethost(const char *hostname, SOCaddr * server, size_t server_size) { return 0; } -static String getip(SOCaddr * server, int serverLen) { +static String getip(SOCaddr * server) { String s = STRING_EMPTY; #if HTS_INET6==0 @@ -291,7 +290,7 @@ static String getip(SOCaddr * server, int serverLen) { proxytrack_print_log(CRITICAL, "memory exhausted"); return s; } - SOCaddr_inetntoa(dotted, sizeMax, *server, serverLen); + SOCaddr_inetntoa(dotted, sizeMax, *server); sprintf(dotted + strlen(dotted), ":%d", port); StringAttach(&s, &dotted); return s; @@ -299,18 +298,15 @@ static String getip(SOCaddr * server, int serverLen) { static T_SOC smallserver_init(const char *adr, int port, int family) { SOCaddr server; - size_t server_size = sizeof(server); - - memset(&server, 0, sizeof(server)); - SOCaddr_initany(server, server_size); - if (gethost(adr, &server, server_size)) { // host name + SOCaddr_initany(server); + if (gethost(adr, &server)) { // host name T_SOC soc = INVALID_SOCKET; if ((soc = (T_SOC) socket(SOCaddr_sinfamily(server), family, 0)) != INVALID_SOCKET) { SOCaddr_initport(server, port); - if (bind(soc, (struct sockaddr *) &server, (int) server_size) == 0) { + if (bind(soc, &SOCaddr_sockaddr(server), SOCaddr_size(server)) == 0) { if (family != SOCK_STREAM || listen(soc, 10) >= 0) { return soc; } else { @@ -1320,12 +1316,12 @@ static void proxytrack_process_HTTP(PT_Indexes indexes, T_SOC soc_c) { /* */ String ip = STRING_EMPTY; SOCaddr serverClient; - SOClen lenServerClient = (int) sizeof(serverClient); + SOClen lenServerClient = SOCaddr_capacity(serverClient); memset(&serverClient, 0, sizeof(serverClient)); if (getsockname - (soc_c, (struct sockaddr *) &serverClient, &lenServerClient) == 0) { - ip = getip(&serverClient, lenServerClient); + (soc_c, &SOCaddr_sockaddr(serverClient), &lenServerClient) == 0) { + ip = getip(&serverClient); } else { StringCopy(ip, "unknown"); } @@ -1571,14 +1567,14 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { return -1; } while(soc != INVALID_SOCKET) { - struct sockaddr clientAddr; - SOClen clientAddrLen = sizeof(struct sockaddr); + SOCaddr clientAddr; + SOClen clientAddrLen = SOCaddr_capacity(clientAddr); int n; memset(&clientAddr, 0, sizeof(clientAddr)); - n = - recvfrom(soc, (char *) buffer, bufferSize, 0, &clientAddr, - &clientAddrLen); + n = recvfrom(soc, (char *) buffer, bufferSize, 0, + &SOCaddr_sockaddr(clientAddr), + &clientAddrLen); if (n != -1) { const char *LogRequest = "ERROR"; const char *LogReply = "ERROR"; @@ -1621,11 +1617,11 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { UrlRequestSize = (unsigned int) strlen((char *) UrlRequest); LogRequest = "ICP_OP_QUERY"; if (indexes == NULL) { - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_DENIED, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_DENIED, Version, 0, Request_Number, 0, 0, 0, UrlRequest); LogReply = "ICP_OP_DENIED"; } else if (PT_LookupIndex(indexes, (char*) UrlRequest)) { - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_HIT, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_HIT, Version, 0, Request_Number, 0, 0, 0, UrlRequest); LogReply = "ICP_OP_HIT"; } else { @@ -1637,7 +1633,7 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { if (UrlRedirect != NULL) { sprintf(UrlRedirect, "%s/", UrlRequest); if (PT_LookupIndex(indexes, UrlRedirect)) { /* We'll generate a redirect */ - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_HIT, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_HIT, Version, 0, Request_Number, 0, 0, 0, UrlRequest); LogReply = "ICP_OP_HIT"; @@ -1648,7 +1644,7 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { } } /* We won't retrive the cache MISS online, no way! */ - ICP_reply(&clientAddr, clientAddrLen, soc, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_MISS_NOFETCH, Version, 0, Request_Number, 0, 0, 0, UrlRequest); LogReply = "ICP_OP_MISS_NOFETCH"; @@ -1660,24 +1656,24 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { UrlRequest = &Payload[4]; LogRequest = "ICP_OP_QUERY"; LogReply = "ICP_OP_QUERY"; - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_SECHO, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_SECHO, Version, 0, Request_Number, 0, 0, 0, UrlRequest); } break; default: LogRequest = "NOTIMPLEMENTED"; LogReply = "ICP_OP_ERR"; - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_ERR, Version, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_ERR, Version, 0, Request_Number, 0, 0, 0, NULL); break; } } else { - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_ERR, 2, 0, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_ERR, 2, 0, Request_Number, 0, 0, 0, NULL); } } /* Ignored (RFC2186) */ } else { - ICP_reply(&clientAddr, clientAddrLen, soc, ICP_OP_ERR, Version, 0, + ICP_reply(&SOCaddr_sockaddr(clientAddr), clientAddrLen, soc, ICP_OP_ERR, Version, 0, Request_Number, 0, 0, 0, NULL); } } @@ -1691,7 +1687,7 @@ static int proxytrack_start_ICP(PT_Indexes indexes, T_SOC soc) { SOCaddr_copyaddr(serverClient, lenServerClient, &clientAddr, clientAddrLen); if (lenServerClient > 0) { - ip = getip(&serverClient, lenServerClient); + ip = getip(&clientAddr); } else { StringCopy(ip, "unknown"); } diff --git a/src/proxy/proxytrack.h b/src/proxy/proxytrack.h index 6936218..b42f134 100644 --- a/src/proxy/proxytrack.h +++ b/src/proxy/proxytrack.h @@ -109,8 +109,8 @@ HTS_UNUSED static void proxytrack_print_log(const char *severity, const char *fo "\r\n" \ "\r\n" -HTS_UNUSED static char *gethomedir(void) { - char *home = getenv("HOME"); +HTS_UNUSED static const char *gethomedir(void) { + const char *home = getenv("HOME"); if (home) return home; @@ -216,7 +216,7 @@ HTS_UNUSED static const char *jump_protocol_and_auth(const char *source) { #endif HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max) { int rlen = 0; - char *ls = (char *) malloc(max + 2); + char *const ls = (char *) malloc(max + 1); s[0] = '\0'; if (ls) { diff --git a/src/proxy/store.c b/src/proxy/store.c index daa9952..76f245a 100644 --- a/src/proxy/store.c +++ b/src/proxy/store.c @@ -1253,7 +1253,7 @@ static int PT_SaveCache__New_Fun(void *arg, const char *url, PT_Element element) headersSize = 0; /* */ { - char *message; + const char *message; if (strlen(element->msg) < 32) { message = element->msg; diff --git a/templates/Makefile.in b/templates/Makefile.in index 268bc04..239c660 100644 --- a/templates/Makefile.in +++ b/templates/Makefile.in @@ -104,6 +104,7 @@ DATA = $(templates_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -112,14 +113,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -133,6 +132,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -188,7 +188,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ diff --git a/templates/topindex-header.html b/templates/topindex-header.html index 4193e2d..7013ed6 100644 --- a/templates/topindex-header.html +++ b/templates/topindex-header.html @@ -98,4 +98,4 @@ h4 { margin: 0; font-weight: bold; font-size: 1.18em; }

Index of locally available projects:

- +
diff --git a/tests/11_crawl-idna.test b/tests/11_crawl-idna.test index 050fd07..6f0ee6a 100755 --- a/tests/11_crawl-idna.test +++ b/tests/11_crawl-idna.test @@ -13,3 +13,9 @@ bash crawl-test.sh \ httrack 'http://ut.httrack.com/unicode-links/idna.html' \ '+*.ut.httrack.com/*' --robots=0 +# unicode tests (bogus links) +bash crawl-test.sh \ + --errors 0 --files 1 \ + --found 'ut.httrack.com/unicode-links/idna_bogus.html' \ + httrack 'http://ut.httrack.com/unicode-links/idna_bogus.html' \ + '-*' --robots=0 diff --git a/tests/Makefile.in b/tests/Makefile.in index d153fd7..92a07dc 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -76,6 +76,7 @@ red=; grn=; lgn=; blu=; std= DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -84,14 +85,12 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ +CFLAG_VISIBILITY = @CFLAG_VISIBILITY@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFAULT_CFLAGS = @DEFAULT_CFLAGS@ +DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ @@ -105,6 +104,7 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ +HAVE_VISIBILITY = @HAVE_VISIBILITY@ HTTPS_SUPPORT = @HTTPS_SUPPORT@ ICONV_LIBS = @ICONV_LIBS@ INSTALL = @INSTALL@ @@ -160,7 +160,6 @@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@