summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2018-03-31 20:38:12 +0200
committerDidier Raboud <odyx@debian.org>2018-03-31 20:38:12 +0200
commit616faff3fb0dd69e812c3cdf941002efa28f5164 (patch)
tree1bb073456523070b9c048e71097d124ce9b0ce9f /Source
parent3fc4c1d2ad654ac291a5941670b81b48333cd9ef (diff)
Import Upstream version 2.18
Diffstat (limited to 'Source')
-rwxr-xr-xSource/Platform.h4
-rwxr-xr-xSource/build.cpp21
-rwxr-xr-xSource/build.h7
-rwxr-xr-xSource/crc32.c9
-rwxr-xr-xSource/crc32.h13
-rwxr-xr-xSource/exehead/Ui.c3
-rwxr-xr-xSource/exehead/fileform.c11
-rwxr-xr-xSource/writer.cpp2
-rwxr-xr-xSource/writer.h5
9 files changed, 42 insertions, 33 deletions
diff --git a/Source/Platform.h b/Source/Platform.h
index 9a1faf2..9a04344 100755
--- a/Source/Platform.h
+++ b/Source/Platform.h
@@ -50,9 +50,9 @@ typedef WORD LANGID;
#endif
#ifndef __BIG_ENDIAN__
-# define FIX_ENDIAN_INT32_INPLACE(x) (x)
+# define FIX_ENDIAN_INT32_INPLACE(x) ((void)(x))
# define FIX_ENDIAN_INT32(x) (x)
-# define FIX_ENDIAN_INT16_INPLACE(x) (x)
+# define FIX_ENDIAN_INT16_INPLACE(x) ((void)(x))
# define FIX_ENDIAN_INT16(x) (x)
#else
# define FIX_ENDIAN_INT32_INPLACE(x) ((x) = SWAP_ENDIAN_INT32(x))
diff --git a/Source/build.cpp b/Source/build.cpp
index 47fbcc2..7713a5e 100755
--- a/Source/build.cpp
+++ b/Source/build.cpp
@@ -8,6 +8,7 @@
#include "util.h"
#include "fileform.h"
#include "writer.h"
+#include "crc32.h"
#include <stdexcept>
@@ -2274,7 +2275,7 @@ int CEXEBuild::write_output(void)
RET_UNLESS_OK( uninstall_generate() );
- int crc=0;
+ crc32_t crc=0;
{
string full_path = get_full_path(build_output_filename);
@@ -2349,7 +2350,7 @@ int CEXEBuild::write_output(void)
}
if (!build_compress_whole)
- fh.length_of_all_following_data=ihd.getlen()+build_datablock.getlen()+(int)sizeof(firstheader)+(build_crcchk?sizeof(int):0);
+ fh.length_of_all_following_data=ihd.getlen()+build_datablock.getlen()+(int)sizeof(firstheader)+(build_crcchk?sizeof(crc32_t):0);
else
fd_start=ftell(fp);
@@ -2384,7 +2385,7 @@ int CEXEBuild::write_output(void)
return PS_ERROR;
}
#ifdef NSIS_CONFIG_CRC_SUPPORT
- crc_writer_sink crc_sink((unsigned long *) &crc);
+ crc_writer_sink crc_sink((crc32_t *) &crc);
firstheader_writer w(&crc_sink);
w.write(&fh);
@@ -2455,7 +2456,7 @@ int CEXEBuild::write_output(void)
if (db_opt_save)
{
int total_out_size_estimate=
- m_exehead_size+sizeof(fh)+build_datablock.getlen()+(build_crcchk?sizeof(int):0);
+ m_exehead_size+sizeof(fh)+build_datablock.getlen()+(build_crcchk?sizeof(crc32_t):0);
#ifdef _WIN32
int pc=MulDiv(db_opt_save,1000,db_opt_save+total_out_size_estimate);
#else
@@ -2564,7 +2565,7 @@ int CEXEBuild::write_output(void)
unsigned fend = ftell(fp);
- fh.length_of_all_following_data=ftell(fp)-fd_start+(build_crcchk?sizeof(int):0);
+ fh.length_of_all_following_data=ftell(fp)-fd_start+(build_crcchk?sizeof(crc32_t):0);
INFO_MSG(
"%10d / %d bytes\n",
ftell(fp) - fd_start,
@@ -2608,9 +2609,9 @@ int CEXEBuild::write_output(void)
{
total_usize+=sizeof(int);
int rcrc = FIX_ENDIAN_INT32(crc);
- if (fwrite(&rcrc,1,sizeof(int),fp) != sizeof(int))
+ if (fwrite(&rcrc,1,sizeof(crc32_t),fp) != sizeof(crc32_t))
{
- ERROR_MSG("Error: can't write %d bytes to output\n",sizeof(int));
+ ERROR_MSG("Error: can't write %d bytes to output\n",sizeof(crc32_t));
fclose(fp);
return PS_ERROR;
}
@@ -2693,7 +2694,7 @@ int CEXEBuild::uninstall_generate()
if (err < 0) return PS_ERROR;
}
- int crc=0;
+ crc32_t crc=0;
// Get offsets of icons to replace for uninstall
// Also makes sure that the icons are there and in the right size.
@@ -2763,7 +2764,7 @@ int CEXEBuild::uninstall_generate()
#endif
fh.siginfo=FH_SIG;
fh.length_of_all_following_data=
- uhd.getlen()+ubuild_datablock.getlen()+(int)sizeof(firstheader)+(build_crcchk?sizeof(int):0);
+ uhd.getlen()+ubuild_datablock.getlen()+(int)sizeof(firstheader)+(build_crcchk?sizeof(crc32_t):0);
MMapBuf udata;
@@ -2832,7 +2833,7 @@ int CEXEBuild::uninstall_generate()
}
firstheader *_fh=(firstheader *)udata.get(0, sizeof(firstheader));
- _fh->length_of_all_following_data=FIX_ENDIAN_INT32(udata.getlen()+(build_crcchk?sizeof(int):0));
+ _fh->length_of_all_following_data=FIX_ENDIAN_INT32(udata.getlen()+(build_crcchk?sizeof(crc32_t):0));
udata.release();
}
else
diff --git a/Source/build.h b/Source/build.h
index b8ade01..564b9ba 100755
--- a/Source/build.h
+++ b/Source/build.h
@@ -35,13 +35,6 @@
# include "Plugins.h"
#endif //NSIS_CONFIG_PLUGIN_SUPPORT
-#ifdef NSIS_CONFIG_CRC_SUPPORT
-extern "C"
-{
- unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
-};
-#endif
-
#define PS_OK 0
#define PS_EOF 1
#define PS_ERROR 50
diff --git a/Source/crc32.c b/Source/crc32.c
index 5133720..0589adf 100755
--- a/Source/crc32.c
+++ b/Source/crc32.c
@@ -1,20 +1,21 @@
#include "Platform.h"
+#include "crc32.h"
#include "exehead/config.h"
#ifdef NSIS_CONFIG_CRC_SUPPORT
// this is based on the (slow,small) CRC32 implementation from zlib.
-unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len)
+crc32_t NSISCALL CRC32(crc32_t crc, const unsigned char *buf, unsigned int len)
{
- static unsigned long crc_table[256];
+ static crc32_t crc_table[256];
if (!crc_table[1])
{
- unsigned long c;
+ crc32_t c;
int n, k;
for (n = 0; n < 256; n++)
{
- c = (unsigned long)n;
+ c = (crc32_t)n;
for (k = 0; k < 8; k++) c = (c >> 1) ^ (c & 1 ? 0xedb88320L : 0);
crc_table[n] = c;
}
diff --git a/Source/crc32.h b/Source/crc32.h
new file mode 100755
index 0000000..c55ed37
--- /dev/null
+++ b/Source/crc32.h
@@ -0,0 +1,13 @@
+#include "Platform.h"
+
+#ifndef ___CRC32__H___
+#define ___CRC32__H___
+
+typedef UINT32 crc32_t;
+
+#ifdef __cplusplus
+extern "C"
+#endif
+crc32_t NSISCALL CRC32(crc32_t crc, const unsigned char *buf, unsigned int len);
+
+#endif//!___CRC32__H___
diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c
index f6f50f8..4fdde15 100755
--- a/Source/exehead/Ui.c
+++ b/Source/exehead/Ui.c
@@ -945,13 +945,14 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
}
if (id == IDC_BROWSE)
{
+ static char bt[NSIS_MAX_STRLEN];
BROWSEINFO bi = {0,};
ITEMIDLIST *idlist;
bi.hwndOwner = hwndDlg;
bi.pszDisplayName = g_tmp;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)dir;
- bi.lpszTitle = GetNSISStringTT(browse_text);
+ bi.lpszTitle = GetNSISString(bt, browse_text);
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
idlist = SHBrowseForFolder(&bi);
if (idlist)
diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c
index fc8bcba..7967ab5 100755
--- a/Source/exehead/fileform.c
+++ b/Source/exehead/fileform.c
@@ -6,6 +6,7 @@
#include "lang.h"
#include "ui.h"
#include "exec.h"
+#include "../crc32.h"
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
#ifdef NSIS_COMPRESS_USE_ZLIB
@@ -95,8 +96,6 @@ BOOL CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
static z_stream g_inflate_stream;
#endif
-extern unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
-
const char * NSISCALL loadHeaders(int cl_flags)
{
#ifdef NSIS_CONFIG_CRC_SUPPORT
@@ -104,7 +103,7 @@ const char * NSISCALL loadHeaders(int cl_flags)
HWND hwnd = 0;
unsigned int verify_time = GetTickCount() + 1000;
#endif
- int crc = 0;
+ crc32_t crc = 0;
int do_crc = 0;
#endif//NSIS_CONFIG_CRC_SUPPORT
int left;
@@ -230,9 +229,9 @@ const char * NSISCALL loadHeaders(int cl_flags)
#ifdef NSIS_CONFIG_CRC_SUPPORT
if (do_crc)
{
- int fcrc;
+ crc32_t fcrc;
SetSelfFilePointer(m_pos);
- if (!ReadSelfFile(&fcrc, sizeof(int)) || crc != fcrc)
+ if (!ReadSelfFile(&fcrc, sizeof(crc32_t)) || crc != fcrc)
return _LANG_INVALIDCRC;
}
#endif//NSIS_CONFIG_CRC_SUPPORT
@@ -251,7 +250,7 @@ const char * NSISCALL loadHeaders(int cl_flags)
}
dbd_srcpos = SetSelfFilePointer(g_filehdrsize + sizeof(firstheader));
#ifdef NSIS_CONFIG_CRC_SUPPORT
- dbd_fulllen = dbd_srcpos - sizeof(h) + h.length_of_all_following_data - ((h.flags & FH_FLAGS_NO_CRC) ? 0 : sizeof(int));
+ dbd_fulllen = dbd_srcpos - sizeof(h) + h.length_of_all_following_data - ((h.flags & FH_FLAGS_NO_CRC) ? 0 : sizeof(crc32_t));
#else
dbd_fulllen = dbd_srcpos - sizeof(h) + h.length_of_all_following_data;
#endif//NSIS_CONFIG_CRC_SUPPORT
diff --git a/Source/writer.cpp b/Source/writer.cpp
index 5087651..a59c89a 100755
--- a/Source/writer.cpp
+++ b/Source/writer.cpp
@@ -64,7 +64,7 @@ void file_writer_sink::write_data(const void *data, const size_t size)
}
#ifdef NSIS_CONFIG_CRC_SUPPORT
-extern "C" unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len);
+#include "crc32.h"
void crc_writer_sink::write_data(const void *data, const size_t size)
{
diff --git a/Source/writer.h b/Source/writer.h
index d462929..399d53d 100755
--- a/Source/writer.h
+++ b/Source/writer.h
@@ -3,6 +3,7 @@
#include "exehead/config.h"
#include "growbuf.h"
+#include "crc32.h"
#include <stdio.h>
class writer_sink {
@@ -57,12 +58,12 @@ private:
#ifdef NSIS_CONFIG_CRC_SUPPORT
class crc_writer_sink : public writer_sink {
public:
- crc_writer_sink(unsigned long *crc) : m_crc(crc) {}
+ crc_writer_sink(crc32_t *crc) : m_crc(crc) {}
virtual void write_data(const void *data, const size_t size);
private:
- unsigned long *m_crc;
+ crc32_t *m_crc;
};
#endif