Jim Park's Unicode NSIS merging - Step 1 : switch to TCHARs where relevant.

Compiler output is identical before & after this step

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/branches/wizou@6036 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-03-24 17:22:56 +00:00
parent 4e48722b63
commit 752d7d239a
209 changed files with 9698 additions and 7658 deletions

View file

@ -1,3 +1,5 @@
// Reviewed for Unicode support by Jim Park -- 08/17/2007
#define _WIN32_IE 0x0400
#include <windows.h>

View file

@ -6,6 +6,9 @@
** License: see jnetlib.h
*/
// Reviewed for Unicode support by Jim Park -- 08/16/2007
// Note: For Unicode Support, all string functions must explicitly use
// ANSI versions if UNICODE is defined.
#include "netinc.h"
#include "util.h"
@ -57,14 +60,14 @@ int JNL_AsyncDNS::resolve(char *hostname, unsigned long *addr)
return 0;
}
if (lstrcmpi(m_hostname,hostname)) m_addr=0;
if (lstrcmpiA(m_hostname,hostname)) m_addr=0;
else if (m_addr == INADDR_NONE) return -1;
else if (m_addr)
{
*addr=m_addr;
return 0;
}
lstrcpy(m_hostname,hostname);
lstrcpyA(m_hostname,hostname);
if (m_thread_kill)
{

View file

@ -14,6 +14,9 @@
** 4. enjoy.
*/
// Reviewed for Unicode support by Jim Park -- 08/16/2007
// Note: Inet host name is strictly ANSI, no UNICODE for now.
#ifndef _ASYNCDNS_H_
#define _ASYNCDNS_H_

View file

@ -4,6 +4,8 @@
** Author: Justin Frankel
** File: connection.cpp - JNL TCP connection implementation
** License: see jnetlib.h
**
** Reviewed for Unicode support by Jim Park -- 08/17/2007
*/
#include "netinc.h"

View file

@ -50,6 +50,8 @@
** make the socket close after sending all the data sent.
**
** 8. delete ye' ol' object.
**
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
*/
#ifndef _CONNECTION_H_

View file

@ -4,6 +4,12 @@
** Author: Justin Frankel
** File: httpget.cpp - JNL HTTP GET implementation
** License: see jnetlib.h
**
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
** Note: The functions that work on char's should be explicitely set to use the
** ANSI versions. Some of the functions like wprintf() are #defined to be
** the wide-char versions when _UNICODE is defined. So these must be explictly
** set to use the ANSI versions.
*/
#include "netinc.h"
@ -181,14 +187,14 @@ void JNL_HTTPGet::connect(char *url)
if (!m_http_proxyhost || !m_http_proxyhost[0])
{
wsprintf(str,"GET %s HTTP/1.0\r\n",m_http_request);
wsprintfA(str,"GET %s HTTP/1.0\r\n",m_http_request);
}
else
{
wsprintf(str,"GET %s HTTP/1.0\r\n",m_http_url);
wsprintfA(str,"GET %s HTTP/1.0\r\n",m_http_url);
}
wsprintf(str+strlen(str),"Host: %s\r\n",m_http_host);
wsprintfA(str+strlen(str),"Host: %s\r\n",m_http_host);
if (m_http_lpinfo&&m_http_lpinfo[0])
{

View file

@ -37,6 +37,12 @@
** note that user, pass, port, and /requestwhatever are all optional :)
** note that also, http:// is really not important. if you do poo://
** or even leave out the http:// altogether, it will still work.
**
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
** Note: The functions that work on char's should be explicitely set to use the
** ANSI versions. Some of the functions like wprintf() are #defined to be
** the wide-char versions when _UNICODE is defined. So these must be explictly
** set to use the ANSI versions.
*/
#ifndef _HTTPGET_H_

View file

@ -4,6 +4,12 @@
** Author: Justin Frankel
** File: netinc.h - network includes and portability defines (used internally)
** License: see jnetlib.h
**
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
** Note: The functions that work on char's should be explicitely set to use the
** ANSI versions. Some of the functions like lstrcpy() are #defined to be
** the wide-char versions when _UNICODE is defined. So these must be explictly
** set to use the ANSI versions.
*/
#ifndef _NETINC_H_
@ -72,10 +78,10 @@ extern void mini_memset(void *,char,int);
extern void mini_memcpy(void *,void*,int);
#define memset mini_memset
#define memcpy mini_memcpy
#define strcpy lstrcpy
#define strncpy lstrcpyn
#define strcat lstrcat
#define strlen lstrlen
#define strcpy lstrcpyA
#define strncpy lstrcpynA
#define strcat lstrcatA
#define strlen lstrlenA
#define malloc(x) GlobalAlloc(GPTR,(x))
#define free(x) { if (x) GlobalFree(x); }

View file

@ -4,6 +4,12 @@
** Author: Justin Frankel
** File: util.cpp - JNL implementation of basic network utilities
** License: see jnetlib.h
**
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
** Note: The functions that work on char's should be explicitely set to use the
** ANSI versions. Some of the functions like wprintf() are #defined to be
** the wide-char versions when _UNICODE is defined. So these must be explictly
** set to use the ANSI versions.
*/
#include "netinc.h"

View file

@ -22,6 +22,11 @@
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
** gives you the dotted decimal notation of an integer ip address.
**
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
** Note: The functions that work on char's should be explicitely set to use the
** ANSI versions. Some of the functions like wprintf() are #defined to be
** the wide-char versions when _UNICODE is defined. So these must be explictly
** set to use the ANSI versions.
*/
#ifndef _UTIL_H_

View file

@ -17,6 +17,8 @@
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.
Unicode support by Jim Park -- 08/18/2007
*/
#define MAKENSISW_CPP
@ -34,7 +36,7 @@ NFINDREPLACE g_find;
extern NTOOLBAR g_toolbar;
int g_symbol_set_mode;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow) {
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, TCHAR *cmdParam, int cmdShow) {
MSG msg;
int status;
HACCEL haccel;
@ -44,19 +46,19 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
my_memset(&g_find,0,sizeof(NFINDREPLACE));
g_sdata.hInstance=GetModuleHandle(0);
g_sdata.symbols = NULL;
g_sdata.sigint_event = CreateEvent(NULL, FALSE, FALSE, "makensis win32 signint event");
g_sdata.sigint_event = CreateEvent(NULL, FALSE, FALSE, _T("makensis win32 signint event"));
RestoreSymbols();
HINSTANCE hRichEditDLL = LoadLibrary("RichEd32.dll");
HINSTANCE hRichEditDLL = LoadLibrary(_T("RichEd32.dll"));
if (!InitBranding()) {
MessageBox(0,NSISERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
MessageBox(0,NSISERROR,_T("Error"),MB_ICONEXCLAMATION|MB_OK);
return 1;
}
ResetObjects();
HWND hDialog = CreateDialog(g_sdata.hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
if (!hDialog) {
MessageBox(0,DLGERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
MessageBox(0,DLGERROR,_T("Error"),MB_ICONEXCLAMATION|MB_OK);
return 1;
}
haccel = LoadAccelerators(g_sdata.hInstance, MAKEINTRESOURCE(IDK_ACCEL));
@ -80,7 +82,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
return msg.wParam;
}
void SetScript(const char *script, bool clearArgs /*= true*/)
void SetScript(const TCHAR *script, bool clearArgs /*= true*/)
{
if (g_sdata.script)
{
@ -94,24 +96,25 @@ void SetScript(const char *script, bool clearArgs /*= true*/)
GlobalFree(g_sdata.script_cmd_args);
}
g_sdata.script_cmd_args = GlobalAlloc(GHND, 1);
// Pointing to a single char. Maybe _T('\0')
g_sdata.script_cmd_args = GlobalAlloc(GHND, sizeof(TCHAR));
}
g_sdata.script = (char *) GlobalAlloc(GPTR, lstrlen(script) + 1);
g_sdata.script = (TCHAR *) GlobalAlloc(GPTR, (lstrlen(script) + 1)*sizeof(TCHAR));
lstrcpy(g_sdata.script, script);
}
void AddScriptCmdArgs(const char *arg)
void AddScriptCmdArgs(const TCHAR *arg)
{
g_sdata.script_cmd_args = GlobalReAlloc(g_sdata.script_cmd_args,
GlobalSize(g_sdata.script_cmd_args) + lstrlen(arg) + 2 /* quotes */ + 1 /* space */,
GlobalSize(g_sdata.script_cmd_args) + (lstrlen(arg) + 2/* quotes */ + 1 /* space */)*sizeof(TCHAR),
0);
char *args = (char *) GlobalLock(g_sdata.script_cmd_args);
TCHAR *args = (TCHAR *) GlobalLock(g_sdata.script_cmd_args);
lstrcat(args, " \"");
lstrcat(args, _T(" \""));
lstrcat(args, arg);
lstrcat(args, "\"");
lstrcat(args, _T("\""));
GlobalUnlock(g_sdata.script_cmd_args);
}
@ -119,23 +122,23 @@ void AddScriptCmdArgs(const char *arg)
void ProcessCommandLine()
{
int argc;
char **argv;
TCHAR **argv;
int i, j;
int argSpaceSize;
argSpaceSize = SetArgv((char *)GetCommandLine(), &argc, &argv);
argSpaceSize = SetArgv((TCHAR *)GetCommandLine(), &argc, &argv);
if (argc > 1) {
for (i = 1; i < argc; i++)
{
if (!lstrncmpi(argv[i], "/XSetCompressor ", lstrlen("/XSetCompressor ")))
if (!lstrncmpi(argv[i], _T("/XSetCompressor "), lstrlen(_T("/XSetCompressor "))))
{
char *p = argv[i] + lstrlen("/XSetCompressor ");
if(!lstrncmpi(p,"/FINAL ", lstrlen("/FINAL ")))
TCHAR *p = argv[i] + lstrlen(_T("/XSetCompressor "));
if(!lstrncmpi(p,_T("/FINAL "), lstrlen(_T("/FINAL "))))
{
p += lstrlen("/FINAL ");
p += lstrlen(_T("/FINAL "));
}
while (*p == ' ') p++;
while (*p == _T(' ')) p++;
for (j = (int) COMPRESSOR_SCRIPT + 1; j < (int) COMPRESSOR_BEST; j++)
{
@ -145,11 +148,11 @@ void ProcessCommandLine()
}
}
}
else if (!lstrcmpi(argv[i], "/ChooseCompressor"))
else if (!lstrcmpi(argv[i], _T("/ChooseCompressor")))
{
g_sdata.userSelectCompressor = TRUE;
}
else if (argv[i][0] == '-' || argv[i][0] == '/')
else if (argv[i][0] == _T('-') || argv[i][0] == _T('/'))
{
AddScriptCmdArgs(argv[i]);
}
@ -185,11 +188,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
CreateToolBar();
InitTooltips(g_sdata.hwnd);
SetBranding(g_sdata.hwnd);
HFONT hFont = CreateFont(14,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH|FF_DONTCARE,"Courier New");
HFONT hFont = CreateFont(14,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH|FF_DONTCARE,_T("Courier New"));
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,WM_SETFONT,(WPARAM)hFont,0);
RestoreWindowPos(g_sdata.hwnd);
RestoreCompressor();
SetScript("");
SetScript(_T(""));
g_sdata.compressor = COMPRESSOR_NONE_SELECTED;
g_sdata.userSelectCompressor = FALSE;
@ -243,7 +246,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case WM_DROPFILES: {
int num;
char szTmp[MAX_PATH];
TCHAR szTmp[MAX_PATH];
num = DragQueryFile((HDROP)wParam,(UINT)-1,NULL,0);
if (num==1) {
DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH);
@ -254,7 +257,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
CompileNSISScript();
}
} else {
MessageBox(hwndDlg,MULTIDROPERROR,"Error",MB_OK|MB_ICONSTOP);
MessageBox(hwndDlg,MULTIDROPERROR,_T("Error"),MB_OK|MB_ICONSTOP);
}
DragFinish((HDROP)wParam);
break;
@ -267,7 +270,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case WM_ENTERSIZEMOVE:
{
GetClientRect(g_sdata.hwnd, &g_resize.resizeRect);
return TRUE;
return TRUE;
}
case WM_SIZE:
{
@ -299,8 +302,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
if(g_sdata.compressor == COMPRESSOR_BEST) {
if (g_sdata.retcode==0 && FileExists(g_sdata.output_exe)) {
char temp_file_name[1024];
wsprintf(temp_file_name,"%s_makensisw_temp",g_sdata.output_exe);
TCHAR temp_file_name[1024];
wsprintf(temp_file_name,_T("%s_makensisw_temp"),g_sdata.output_exe);
if(!lstrcmpi(g_sdata.compressor_name,compressor_names[(int)COMPRESSOR_SCRIPT+1])) {
SetCompressorStats();
CopyFile(g_sdata.output_exe,temp_file_name,false);
@ -354,7 +357,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
if(this_compressor == ((int)COMPRESSOR_BEST - 1)) {
char buf[1024];
TCHAR buf[1024];
g_sdata.compressor_name = compressor_names[(int)COMPRESSOR_SCRIPT+1];
@ -369,7 +372,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
LogMessage(g_sdata.hwnd, g_sdata.compressor_stats);
}
DeleteFile(temp_file_name);
lstrcpy(g_sdata.compressor_stats,"");
lstrcpy(g_sdata.compressor_stats,_T(""));
}
else {
g_sdata.compressor_name = compressor_names[this_compressor+1];
@ -385,16 +388,16 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
if (!g_sdata.retcode) {
MessageBeep(MB_ICONASTERISK);
if (g_sdata.warnings)
SetTitle(g_sdata.hwnd,"Finished with Warnings");
SetTitle(g_sdata.hwnd,_T("Finished with Warnings"));
else
SetTitle(g_sdata.hwnd,"Finished Sucessfully");
SetTitle(g_sdata.hwnd,_T("Finished Sucessfully"));
// Added by Darren Owen (DrO) on 1/10/2003
if(g_sdata.recompile_test)
PostMessage(g_sdata.hwnd, WM_COMMAND, LOWORD(IDC_TEST), 0);
}
else {
MessageBeep(MB_ICONEXCLAMATION);
SetTitle(g_sdata.hwnd,"Compile Error: See Log for Details");
SetTitle(g_sdata.hwnd,_T("Compile Error: See Log for Details"));
}
// Added by Darren Owen (DrO) on 1/10/2003
@ -455,8 +458,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (cds->dwData) {
case MAKENSIS_NOTIFY_SCRIPT:
if (g_sdata.input_script) GlobalFree(g_sdata.input_script);
g_sdata.input_script = (char *)GlobalAlloc(GPTR, cds->cbData);
lstrcpy(g_sdata.input_script, (char *)cds->lpData);
g_sdata.input_script = (TCHAR *)GlobalAlloc(GPTR, cds->cbData * sizeof(TCHAR));
lstrcpy(g_sdata.input_script, (TCHAR *)cds->lpData);
break;
case MAKENSIS_NOTIFY_WARNING:
g_sdata.warnings++;
@ -465,8 +468,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
break;
case MAKENSIS_NOTIFY_OUTPUT:
if (g_sdata.output_exe) GlobalFree(g_sdata.output_exe);
g_sdata.output_exe = (char *)GlobalAlloc(GPTR, cds->cbData);
lstrcpy(g_sdata.output_exe, (char *)cds->lpData);
g_sdata.output_exe = (TCHAR *)GlobalAlloc(GPTR, cds->cbData * sizeof(TCHAR));
lstrcpy(g_sdata.output_exe, (TCHAR *)cds->lpData);
break;
}
return TRUE;
@ -476,11 +479,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (LOWORD(wParam)) {
case IDM_BROWSESCR: {
if (g_sdata.input_script) {
char str[MAX_PATH],*str2;
TCHAR str[MAX_PATH],*str2;
lstrcpy(str,g_sdata.input_script);
str2=my_strrchr(str,'\\');
str2=my_strrchr(str,_T('\\'));
if(str2!=NULL) *(str2+1)=0;
ShellExecute(g_sdata.hwnd,"open",str,NULL,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,_T("open"),str,NULL,NULL,SW_SHOWNORMAL);
}
return TRUE;
}
@ -491,12 +494,12 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
}
case IDM_NSISHOME:
{
ShellExecute(g_sdata.hwnd,"open",NSIS_URL,NULL,NULL,SW_SHOWNORMAL);
ShellExecuteA(g_sdata.hwnd,"open",NSIS_URL,NULL,NULL,SW_SHOWNORMAL);
return TRUE;
}
case IDM_FORUM:
{
ShellExecute(g_sdata.hwnd,"open",NSIS_FOR,NULL,NULL,SW_SHOWNORMAL);
ShellExecuteA(g_sdata.hwnd,"open",NSIS_FOR,NULL,NULL,SW_SHOWNORMAL);
return TRUE;
}
case IDM_NSISUPDATE:
@ -518,17 +521,17 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
{
if (!g_sdata.thread) {
OPENFILENAME l={sizeof(l),};
char buf[MAX_PATH];
TCHAR buf[MAX_PATH];
l.hwndOwner = hwndDlg;
l.lpstrFilter = "NSIS Script (*.nsi)\0*.nsi\0All Files (*.*)\0*.*\0";
l.lpstrFilter = _T("NSIS Script (*.nsi)\0*.nsi\0All Files (*.*)\0*.*\0");
l.lpstrFile = buf;
l.nMaxFile = MAX_STRING-1;
l.lpstrTitle = "Load Script";
l.lpstrDefExt = "log";
l.lpstrTitle = _T("Load Script");
l.lpstrDefExt = _T("log");
l.lpstrFileTitle = NULL;
l.lpstrInitialDir = NULL;
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
lstrcpy(buf,"");
lstrcpy(buf,_T(""));
if (GetOpenFileName(&l)) {
SetScript(buf);
PushMRUFile(g_sdata.script);
@ -582,18 +585,18 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case IDC_TEST:
{
if (g_sdata.output_exe) {
ShellExecute(g_sdata.hwnd,"open",g_sdata.output_exe,NULL,NULL,SW_SHOWNORMAL);
ShellExecute(g_sdata.hwnd,_T("open"),g_sdata.output_exe,NULL,NULL,SW_SHOWNORMAL);
}
return TRUE;
}
case IDM_EDITSCRIPT:
{
if (g_sdata.input_script) {
if ((int)ShellExecute(g_sdata.hwnd,"open",g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
char path[MAX_PATH];
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
TCHAR path[MAX_PATH];
if (GetWindowsDirectory(path,sizeof(path))) {
lstrcat(path,"\\notepad.exe");
ShellExecute(g_sdata.hwnd,"open",path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
lstrcat(path,_T("\\notepad.exe"));
ShellExecute(g_sdata.hwnd,_T("open"),path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
}
}
}
@ -625,21 +628,21 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
case IDM_SAVE:
{
OPENFILENAME l={sizeof(l),};
char buf[MAX_STRING];
TCHAR buf[MAX_STRING];
l.hwndOwner = hwndDlg;
l.lpstrFilter = "Log Files (*.log)\0*.log\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
l.lpstrFilter = _T("Log Files (*.log)\0*.log\0Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0");
l.lpstrFile = buf;
l.nMaxFile = MAX_STRING-1;
l.lpstrTitle = "Save Output";
l.lpstrDefExt = "log";
l.lpstrTitle = _T("Save Output");
l.lpstrDefExt = _T("log");
l.lpstrInitialDir = NULL;
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST;
lstrcpy(buf,"output");
lstrcpy(buf,_T("output"));
if (GetSaveFileName(&l)) {
HANDLE hFile = CreateFile(buf,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
if (hFile) {
int len=SendDlgItemMessage(g_sdata.hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
char *existing_text=(char*)GlobalAlloc(GPTR,len);
TCHAR *existing_text=(TCHAR*)GlobalAlloc(GPTR,len * sizeof(TCHAR));
existing_text[0]=0;
GetDlgItemText(g_sdata.hwnd, IDC_LOGWIN, existing_text, len);
DWORD dwWritten = 0;
@ -657,7 +660,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
g_find.fr.lStructSize = sizeof(FINDREPLACE);
g_find.fr.hwndOwner = hwndDlg;
g_find.fr.Flags = FR_NOUPDOWN;
g_find.fr.lpstrFindWhat = (char *)GlobalAlloc(GPTR, 128);
g_find.fr.lpstrFindWhat = (TCHAR *)GlobalAlloc(GPTR, 128 * sizeof(TCHAR));
if (!g_find.fr.lpstrFindWhat) return TRUE;
g_find.fr.wFindWhatLen = 128;
g_find.hwndFind = FindText(&g_find.fr);
@ -716,12 +719,12 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
else sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = true;
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
ErrorMessage(g_sdata.hwnd,"There was an error creating the output pipe.");
ErrorMessage(g_sdata.hwnd,_T("There was an error creating the output pipe."));
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 1;
}
if (!CreatePipe(&read_stdin,&newstdin,&sa,0)) {
ErrorMessage(g_sdata.hwnd,"There was an error creating the input pipe.");
ErrorMessage(g_sdata.hwnd,_T("There was an error creating the input pipe."));
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
return 1;
}
@ -732,8 +735,8 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
si.hStdError = newstdout;
si.hStdInput = newstdin;
if (!CreateProcess(NULL,g_sdata.compile_command,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
char buf[MAX_STRING];
wsprintf(buf,"Could not execute:\r\n %s.",g_sdata.compile_command);
TCHAR buf[MAX_STRING];
wsprintf(buf,_T("Could not execute:\r\n %s."),g_sdata.compile_command);
ErrorMessage(g_sdata.hwnd,buf);
CloseHandle(newstdout);
CloseHandle(read_stdout);
@ -746,7 +749,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
while (dwExit == STILL_ACTIVE || dwRead) {
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
if (dwRead) {
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
ReadFile(read_stdout, szBuf, sizeof(szBuf)-sizeof(TCHAR), &dwRead, NULL);
szBuf[dwRead] = 0;
LogMessage(g_sdata.hwnd, szBuf);
}
@ -804,16 +807,16 @@ BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
{
HFONT bfont = CreateFont(13,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, "Tahoma");
FIXED_PITCH|FF_DONTCARE, _T("Tahoma"));
HFONT bfontb = CreateFont(13,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, "Tahoma");
FIXED_PITCH|FF_DONTCARE, _T("Tahoma"));
HFONT rfont = CreateFont(12,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, "MS Shell Dlg");
FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
HFONT rfontb = CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_DONTCARE, "MS Shell Dlg");
FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
if (bfont&&bfontb) {
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)bfontb, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)bfont, FALSE);
@ -876,7 +879,7 @@ void EnableSymbolEditButtons(HWND hwndDlg)
}
}
void SetSymbols(HWND hwndDlg, char **symbols)
void SetSymbols(HWND hwndDlg, TCHAR **symbols)
{
int i = 0;
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_RESETCONTENT , 0, 0);
@ -892,16 +895,16 @@ void SetSymbols(HWND hwndDlg, char **symbols)
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
}
char **GetSymbols(HWND hwndDlg)
TCHAR **GetSymbols(HWND hwndDlg)
{
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCOUNT, 0, 0);
char **symbols = NULL;
TCHAR **symbols = NULL;
if(n > 0) {
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (n+1)*sizeof(char *));
symbols = (char **)GlobalLock(hMem);
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (n+1)*sizeof(TCHAR *));
symbols = (TCHAR **)GlobalLock(hMem);
for (int i = 0; i < n; i++) {
int len = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)i, 0);
symbols[i] = (char *)GlobalAlloc(GPTR, (len+1)*sizeof(char));
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, (len+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)i, (LPARAM)symbols[i]);
}
symbols[n] = NULL;
@ -928,8 +931,8 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_MAKENSIS_LOADSYMBOLSET:
{
char *name = (char *)wParam;
char **symbols = LoadSymbolSet(name);
TCHAR *name = (TCHAR *)wParam;
TCHAR **symbols = LoadSymbolSet(name);
HGLOBAL hMem;
SetSymbols(hwndDlg, symbols);
@ -942,8 +945,8 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_MAKENSIS_SAVESYMBOLSET:
{
char *name = (char *)wParam;
char **symbols = GetSymbols(hwndDlg);
TCHAR *name = (TCHAR *)wParam;
TCHAR **symbols = GetSymbols(hwndDlg);
HGLOBAL hMem;
if(symbols) {
@ -981,20 +984,20 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXTLENGTH, 0, 0);
if(n > 0) {
char *buf = (char *)GlobalAlloc(GPTR, (n+1)*sizeof(char));
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
if(my_strstr(buf," ") || my_strstr(buf,"\t")) {
MessageBox(hwndDlg,SYMBOLSERROR,"Error",MB_OK|MB_ICONSTOP);
if(my_strstr(buf,_T(" ")) || my_strstr(buf,_T("\t"))) {
MessageBox(hwndDlg,SYMBOLSERROR,_T("Error"),MB_OK|MB_ICONSTOP);
GlobalFree(buf);
break;
}
n = SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXTLENGTH, 0, 0);
if(n > 0) {
char *buf2 = (char *)GlobalAlloc(GPTR, (n+1)*sizeof(char));
TCHAR *buf2 = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXT, n+1, (LPARAM)buf2);
char *buf3 = (char *)GlobalAlloc(GPTR, (lstrlen(buf)+lstrlen(buf2)+2)*sizeof(char));
wsprintf(buf3,"%s=%s",buf,buf2);
TCHAR *buf3 = (TCHAR *)GlobalAlloc(GPTR, (lstrlen(buf)+lstrlen(buf2)+2)*sizeof(TCHAR));
wsprintf(buf3,_T("%s=%s"),buf,buf2);
GlobalFree(buf);
buf = buf3;
GlobalFree(buf2);
@ -1023,9 +1026,9 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
if(num == 1) {
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)index, 0);
if(n > 0) {
char *buf = (char *)GlobalAlloc(GPTR, (n+1)*sizeof(char));
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (n+1)*sizeof(TCHAR));
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
char *p = my_strstr(buf,"=");
TCHAR *p = my_strstr(buf,_T("="));
if(p) {
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
*p=0;
@ -1157,7 +1160,7 @@ BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
HKEY hSubKey;
if (RegOpenKeyEx(hKey,REGSYMSUBKEY,0,KEY_READ,&hSubKey) == ERROR_SUCCESS) {
char subkey[1024];
TCHAR subkey[1024];
int i=0;
while (RegEnumKey(hSubKey,i,subkey,sizeof(subkey)) == ERROR_SUCCESS) {
@ -1189,7 +1192,7 @@ BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
case IDOK:
{
HWND hwndEdit;
char name[SYMBOL_SET_NAME_MAXLEN+1];
TCHAR name[SYMBOL_SET_NAME_MAXLEN+1];
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
@ -1224,7 +1227,7 @@ BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0);
if(n != CB_ERR) {
long len = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXTLEN, (WPARAM)n, 0);
char *buf = (char *)GlobalAlloc(GPTR, (len+1)*sizeof(char));
TCHAR *buf = (TCHAR *)GlobalAlloc(GPTR, (len+1)*sizeof(TCHAR));
if(SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXT, (WPARAM)n, (LPARAM)buf) != CB_ERR) {
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_DELETESTRING, n, 0);
DeleteSymbolSet(buf);
@ -1269,7 +1272,7 @@ void SetCompressor(NCOMPRESSOR compressor)
if(g_sdata.compressor != compressor) {
WORD command;
char *compressor_name;
TCHAR *compressor_name;
if(compressor > COMPRESSOR_SCRIPT && compressor < COMPRESSOR_BEST) {
command = compressor_commands[(int)compressor];
@ -1282,7 +1285,7 @@ void SetCompressor(NCOMPRESSOR compressor)
else {
compressor = COMPRESSOR_SCRIPT;
command = IDM_COMPRESSOR_SCRIPT;
compressor_name = "";
compressor_name = _T("");
}
g_sdata.compressor = compressor;
g_sdata.compressor_name = compressor_name;

View file

@ -18,6 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Unicode support by Jim Park -- 08/10/2007
*/
#ifndef MAKENSIS_H
#define MAKENSIS_H
@ -25,6 +26,7 @@
#define _WIN32_IE 0x0400
#include <windows.h>
#include <commctrl.h>
#include "../ExDLL/nsis_tchar.h"
#include "utils.h"
#define _RICHEDIT_VER 0x0200
#include <richedit.h>
@ -35,39 +37,39 @@
#define NSIS_FOR "http://forums.winamp.com/forumdisplay.php?forumid=65"
#define NSIS_UPDATE "http://nsis.sourceforge.net/update.php?version="
#define NSIS_DL_URL "http://nsis.sourceforge.net/download/"
#define USAGE "Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSIS Script\""
#define COPYRIGHT "Copyright © 2002 Robert Rainwater"
#define CONTRIB "Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg"
#define USAGE _T("Usage:\r\n\r\n - File | Load Script...\r\n - Drag the .nsi file into this window\r\n - Right click the .nsi file and choose \"Compile NSIS Script\"")
#define COPYRIGHT _T("Copyright © 2002 Robert Rainwater")
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg")
#define DOCPATH "http://nsis.sourceforge.net/Docs/"
#define LOCALDOCS "\\NSIS.chm"
#define NSISERROR "Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe."
#define DLGERROR "Unable to intialize MakeNSISW."
#define SYMBOLSERROR "Symbol cannot contain whitespace characters"
#define MULTIDROPERROR "Dropping more than one script at a time is not supported"
#define NSISUPDATEPROMPT "Running NSIS Update will close MakeNSISW.\nContinue?"
#define LOCALDOCS _T("\\NSIS.chm")
#define NSISERROR _T("Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe.")
#define DLGERROR _T("Unable to intialize MakeNSISW.")
#define SYMBOLSERROR _T("Symbol cannot contain whitespace characters")
#define MULTIDROPERROR _T("Dropping more than one script at a time is not supported")
#define NSISUPDATEPROMPT _T("Running NSIS Update will close MakeNSISW.\nContinue?")
#define REGSEC HKEY_CURRENT_USER
#define REGSECDEF HKEY_LOCAL_MACHINE
#define REGKEY "Software\\NSIS"
#define REGLOC "MakeNSISWPlacement"
#define REGCOMPRESSOR "MakeNSISWCompressor"
#define REGSYMSUBKEY "Symbols"
#define REGMRUSUBKEY "MRU"
#define EXENAME "makensis.exe"
#define REGKEY _T("Software\\NSIS")
#define REGLOC _T("MakeNSISWPlacement")
#define REGCOMPRESSOR _T("MakeNSISWCompressor")
#define REGSYMSUBKEY _T("Symbols")
#define REGMRUSUBKEY _T("MRU")
#define EXENAME _T("makensis.exe")
#define MAX_STRING 256
#define TIMEOUT 100
#define MINWIDTH 350
#define MINHEIGHT 180
#define COMPRESSOR_MESSAGE "\n\nThe %s compressor created the smallest installer (%d bytes)."
#define RESTORED_COMPRESSOR_MESSAGE "\n\nThe %s compressor created the smallest installer (%d bytes)."
#define EXE_HEADER_COMPRESSOR_STAT "EXE header size:"
#define TOTAL_SIZE_COMPRESSOR_STAT "Total size:"
#define COMPRESSOR_MESSAGE _T("\n\nThe %s compressor created the smallest installer (%d bytes).")
#define RESTORED_COMPRESSOR_MESSAGE _T("\n\nThe %s compressor created the smallest installer (%d bytes).")
#define EXE_HEADER_COMPRESSOR_STAT _T("EXE header size:")
#define TOTAL_SIZE_COMPRESSOR_STAT _T("Total size:")
#define SYMBOL_SET_NAME_MAXLEN 40
#define LOAD_SYMBOL_SET_DLG_NAME "Load Symbol Definitions Set"
#define SAVE_SYMBOL_SET_DLG_NAME "Save Symbol Definitions Set"
#define LOAD_BUTTON_TEXT "Load"
#define SAVE_BUTTON_TEXT "Save"
#define LOAD_SYMBOL_SET_MESSAGE "Please select a name for the Symbol Definitions Set to load."
#define SAVE_SYMBOL_SET_MESSAGE "Please enter or select a name for the Symbol Definitions Set to save."
#define LOAD_SYMBOL_SET_DLG_NAME _T("Load Symbol Definitions Set")
#define SAVE_SYMBOL_SET_DLG_NAME _T("Save Symbol Definitions Set")
#define LOAD_BUTTON_TEXT _T("Load")
#define SAVE_BUTTON_TEXT _T("Save")
#define LOAD_SYMBOL_SET_MESSAGE _T("Please select a name for the Symbol Definitions Set to load.")
#define SAVE_SYMBOL_SET_MESSAGE _T("Please enter or select a name for the Symbol Definitions Set to save.")
#define WM_MAKENSIS_PROCESSCOMPLETE (WM_USER+1001)
#define WM_MAKENSIS_LOADSYMBOLSET (WM_USER+1002)
@ -93,22 +95,22 @@ typedef enum {
} NCOMPRESSOR;
#ifdef MAKENSISW_CPP
char *compressor_names[] = {"",
"zlib",
"/SOLID zlib",
"bzip2",
"/SOLID bzip2",
"lzma",
"/SOLID lzma",
"Best"};
char *compressor_display_names[] = {"Defined in Script/Compiler Default",
"ZLIB",
"ZLIB (solid)",
"BZIP2",
"BZIP2 (solid)",
"LZMA",
"LZMA (solid)",
"Best Compressor"};
TCHAR *compressor_names[] = {_T(""),
_T("zlib"),
_T("/SOLID zlib"),
_T("bzip2"),
_T("/SOLID bzip2"),
_T("lzma"),
_T("/SOLID lzma"),
_T("Best")};
TCHAR *compressor_display_names[] = {_T("Defined in Script/Compiler Default"),
_T("ZLIB"),
_T("ZLIB (solid)"),
_T("BZIP2"),
_T("BZIP2 (solid)"),
_T("LZMA"),
_T("LZMA (solid)"),
_T("Best Compressor")};
WORD compressor_commands[] = {IDM_COMPRESSOR_SCRIPT,
IDM_ZLIB,
IDM_ZLIB_SOLID,
@ -140,9 +142,9 @@ int compressor_strings[] = {IDS_SCRIPT,
// Extern Variables
extern const char* NSISW_VERSION;
extern const TCHAR* NSISW_VERSION;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow);
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, TCHAR *cmdParam, int cmdShow);
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
DWORD WINAPI MakeNSISProc(LPVOID p);
BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
@ -151,27 +153,27 @@ BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void SetScript(const char *script, bool clearArgs = true);
void SetScript(const TCHAR *script, bool clearArgs = true);
void CompileNSISScript();
char* BuildSymbols();
TCHAR* BuildSymbols();
void SetCompressor(NCOMPRESSOR);
void RestoreSymbols();
void SaveSymbols();
void DeleteSymbolSet(char *);
char** LoadSymbolSet(char *);
void SaveSymbolSet(char *, char **);
void DeleteSymbolSet(TCHAR *);
TCHAR** LoadSymbolSet(TCHAR *);
void SaveSymbolSet(TCHAR *, TCHAR **);
void RestoreMRUList();
void SaveMRUList();
typedef struct NSISScriptData {
char *script;
TCHAR *script;
HGLOBAL script_cmd_args;
char *compile_command;
char *output_exe;
char *input_script;
char *branding;
char *brandingv;
char **symbols;
TCHAR *compile_command;
TCHAR *output_exe;
TCHAR *input_script;
TCHAR *branding;
TCHAR *brandingv;
TCHAR **symbols;
int retcode;
BOOL userSelectCompressor;
DWORD logLength;
@ -188,9 +190,9 @@ typedef struct NSISScriptData {
CHARRANGE textrange;
NCOMPRESSOR default_compressor;
NCOMPRESSOR compressor;
char *compressor_name;
char compressor_stats[512];
char *best_compressor_name;
TCHAR *compressor_name;
TCHAR compressor_stats[512];
TCHAR *best_compressor_name;
// Added by Darren Owen (DrO) on 1/10/2003
int recompile_test;
} NSCRIPTDATA;

View file

@ -18,6 +18,8 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Unicode support by Jim Park -- 08/20/2007
*/
#define TOOLBAR_CPP
@ -25,6 +27,7 @@
#include "resource.h"
#include "noclib.h"
#include "toolbar.h"
#include "../ExDLL/nsis_tchar.h"
NTOOLBAR g_toolbar;
extern NSCRIPTDATA g_sdata;
@ -65,7 +68,7 @@ void CreateToolBar()
g_toolbar.hwnd = CreateWindowEx (
0L,
TOOLBARCLASSNAME,
"",
_T(""),
WS_CHILD | WS_VISIBLE | TBSTYLE_TRANSPARENT | TBSTYLE_FLAT,
0, 0, 0, 30,
g_sdata.hwnd,
@ -77,7 +80,7 @@ void CreateToolBar()
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LONG) &tbButton);
// For Comctl32.dll version detection
HMODULE hMod = GetModuleHandle("comctl32.dll");
HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));
if (GetProcAddress(hMod, "InitCommonControlsEx")) { // Version 4.70
// Modern toolbar, 24-bit bitmaps
@ -120,8 +123,8 @@ void UpdateToolBarCompressorButton()
{
int iBitmap;
int iString;
char szBuffer[64];
char temp[32];
TCHAR szBuffer[64];
TCHAR temp[32];
TOOLINFO ti;
my_memset(&ti, 0, sizeof(TOOLINFO));
@ -139,13 +142,13 @@ void UpdateToolBarCompressorButton()
sizeof(temp));
my_memset(szBuffer, 0, sizeof(szBuffer));
lstrcat(szBuffer,temp);
lstrcat(szBuffer," [");
lstrcat(szBuffer,_T(" ["));
LoadString(g_sdata.hInstance,
iString,
temp,
sizeof(temp));
lstrcat(szBuffer,temp);
lstrcat(szBuffer,"]");
lstrcat(szBuffer,_T("]"));
SendMessage(g_toolbar.hwnd, TB_CHANGEBITMAP, (WPARAM) IDM_COMPRESSOR, (LPARAM) MAKELPARAM(iBitmap, 0));
@ -155,14 +158,14 @@ void UpdateToolBarCompressorButton()
ti.hwnd = g_toolbar.hwnd;
ti.uId = (UINT)TBB_COMPRESSOR;
SendMessage(g_tip.tip, TTM_GETTOOLINFO, 0, (LPARAM) (LPTOOLINFO) &ti);
ti.lpszText = (LPSTR)szBuffer;
ti.lpszText = (LPTSTR)szBuffer;
SendMessage(g_tip.tip, TTM_SETTOOLINFO, 0, (LPARAM) (LPTOOLINFO) &ti);
}
void AddToolBarButtonTooltip(int id, int iString)
{
TOOLINFO ti;
char szBuffer[64];
TCHAR szBuffer[64];
RECT rect;
my_memset(&ti, 0, sizeof(TOOLINFO));
@ -179,7 +182,7 @@ void AddToolBarButtonTooltip(int id, int iString)
iString,
szBuffer,
sizeof(szBuffer));
ti.lpszText = (LPSTR) szBuffer;
ti.lpszText = (LPTSTR) szBuffer;
ti.rect.left =rect.left;
ti.rect.top = rect.top;
ti.rect.right = rect.right;

View file

@ -18,6 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Reviewed for Unicode support by Jim Park -- 08/20/2007
*/
#ifndef TOOLBAR_H
#define TOOLBAR_H

View file

@ -1,8 +1,11 @@
// Unicode support by Jim Park -- 08/20/2007
#include "makensisw.h"
#include "update.h"
#include "noclib.h"
#include "jnetlib/httpget.h"
#include "../ExDLL/nsis_tchar.h"
static BOOL update_initialized = FALSE;
@ -28,12 +31,12 @@ void FinalizeUpdate() {
int getProxyInfo(char *out) {
DWORD v=0;
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",0,KEY_READ,&hKey) == ERROR_SUCCESS) {
if (RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",0,KEY_READ,&hKey) == ERROR_SUCCESS) {
DWORD l = 4;
DWORD t;
if (RegQueryValueEx(hKey,"ProxyEnable",NULL,&t,(unsigned char *)&v,&l) == ERROR_SUCCESS && t == REG_DWORD) {
if (RegQueryValueExA(hKey,"ProxyEnable",NULL,&t,(unsigned char *)&v,&l) == ERROR_SUCCESS && t == REG_DWORD) {
l=8192;
if (RegQueryValueEx(hKey,"ProxyServer",NULL,&t,(unsigned char *)out,&l ) != ERROR_SUCCESS || t != REG_SZ) {
if (RegQueryValueExA(hKey,"ProxyServer",NULL,&t,(unsigned char *)out,&l ) != ERROR_SUCCESS || t != REG_SZ) {
v=0;
*out=0;
}
@ -53,6 +56,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
char url[300];
BOOL error = FALSE;
static char pbuf[8192];
static char ansiBuf[1024];
char *p=NULL;
*response = 0;
@ -72,9 +76,16 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
InitializeUpdate();
JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL);;
lstrcpy(url,NSIS_UPDATE);
lstrcat(url,g_sdata.brandingv);
lstrcpy(response,"");
lstrcpyA(url,NSIS_UPDATE);
#ifdef _UNICODE
WideCharToMultiByte(CP_ACP, 0, g_sdata.brandingv, -1, ansiBuf, sizeof(ansiBuf), NULL, NULL);
lstrcatA(url,ansiBuf);
#else
lstrcatA(url,g_sdata.brandingv);
#endif
lstrcpyA(response,"");
get->addheader("User-Agent: MakeNSISw (jnetlib)");
get->addheader("Accept:*/*");
get->connect(url);
@ -85,10 +96,10 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
while(len=get->bytes_available()) {
char b[RSZ];
if (len>RSZ) len=RSZ;
if (lstrlen(response)+len>RSZ) break;
if (lstrlenA(response)+len>RSZ) break;
len=get->get_bytes(b,len);
b[len]=0;
lstrcat(response,b);
lstrcatA(response,b);
}
}
if (st==1) break; //closed
@ -100,26 +111,26 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
}
if (error) {
char buf[1000];
wsprintf(buf,"There was a problem checking for an update. Please try again later.\n\nError: %s",get->geterrorstr());
MessageBox(g_sdata.hwnd,buf,"NSIS Update",MB_OK|MB_ICONINFORMATION);
wsprintfA(buf, "There was a problem checking for an update. Please try again later.\n\nError: %s",get->geterrorstr());
MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_OK|MB_ICONINFORMATION);
}
else if (*response=='1'&&lstrlen(response)>2) {
else if (*response=='1'&&lstrlenA(response)>2) {
char buf[200];
response+=2;
wsprintf(buf,"NSIS %s is now available. Would you like to download it now?",response);
if (MessageBox(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
ShellExecute(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
wsprintfA(buf, "NSIS %s is now available. Would you like to download it now?",response);
if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
ShellExecuteA(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
}
}
else if (*response=='2'&&lstrlen(response)>2) {
else if (*response=='2'&&lstrlenA(response)>2) {
char buf[200];
response+=2;
wsprintf(buf,"NSIS %s is now available. Would you like to download this preview release now?",response);
if (MessageBox(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
ShellExecute(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
wsprintfA(buf,"NSIS %s is now available. Would you like to download this preview release now?",response);
if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
ShellExecuteA(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
}
}
else MessageBox(g_sdata.hwnd,"There is no update available for NSIS at this time.","NSIS Update",MB_OK|MB_ICONINFORMATION);
else MessageBoxA(g_sdata.hwnd,"There is no update available for NSIS at this time.","NSIS Update",MB_OK|MB_ICONINFORMATION);
GlobalFree(response);
delete get;
EnableMenuItem(g_sdata.menu,IDM_NSISUPDATE,MF_ENABLED);
@ -129,9 +140,9 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
void Update() {
DWORD dwThreadId;
if (my_strstr(g_sdata.brandingv,"cvs"))
if (my_strstr(g_sdata.brandingv,_T("cvs")))
{
MessageBox(g_sdata.hwnd,"Cannot check for new version of nightly builds. To update, download a new nightly build.","NSIS Update",MB_OK|MB_ICONSTOP);
MessageBox(g_sdata.hwnd,_T("Cannot check for new version of nightly builds. To update, download a new nightly build."),_T("NSIS Update"),MB_OK|MB_ICONSTOP);
return;
}

View file

@ -1,3 +1,5 @@
/* Reviewed for Unicode support by Jim Park -- 08/18/2007
/* Initialize update objects. */
void InitializeUpdate();

View file

@ -18,6 +18,8 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Unicode support by Jim Park -- 08/20/2007
*/
#include "makensisw.h"
@ -28,46 +30,46 @@
NTOOLTIP g_tip;
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
char g_mru_list[MRU_LIST_SIZE][MAX_PATH] = { "", "", "", "", "" };
TCHAR g_mru_list[MRU_LIST_SIZE][MAX_PATH] = { _T(""), _T(""), _T(""), _T(""), _T("") };
extern NSCRIPTDATA g_sdata;
extern char *compressor_names[];
extern TCHAR *compressor_names[];
int SetArgv(const char *cmdLine, int *argc, char ***argv)
int SetArgv(const TCHAR *cmdLine, int *argc, TCHAR ***argv)
{
const char *p;
char *arg, *argSpace;
const TCHAR *p;
TCHAR *arg, *argSpace;
int size, argSpaceSize, inquote, copy, slashes;
size = 2;
for (p = cmdLine; *p != '\0'; p++) {
if ((*p == ' ') || (*p == '\t')) {
for (p = cmdLine; *p != _T('\0'); p++) {
if ((*p == _T(' ')) || (*p == _T('\t'))) {
size++;
while ((*p == ' ') || (*p == '\t')) {
while ((*p == _T(' ')) || (*p == _T('\t'))) {
p++;
}
if (*p == '\0') {
if (*p == _T('\0')) {
break;
}
}
}
argSpaceSize = size * sizeof(char *) + lstrlen(cmdLine) + 1;
argSpace = (char *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
argSpaceSize = size * sizeof(TCHAR *) + lstrlen(cmdLine) + 1;
argSpace = (TCHAR *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
if (!argSpace)
return 0;
*argv = (char **) argSpace;
argSpace += size * sizeof(char *);
*argv = (TCHAR **) argSpace;
argSpace += size * sizeof(TCHAR *);
size--;
p = cmdLine;
for (*argc = 0; *argc < size; (*argc)++) {
(*argv)[*argc] = arg = argSpace;
while ((*p == ' ') || (*p == '\t')) {
while ((*p == _T(' ')) || (*p == _T('\t'))) {
p++;
}
if (*p == '\0') {
if (*p == _T('\0')) {
break;
}
@ -75,14 +77,14 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
slashes = 0;
while (1) {
copy = 1;
while (*p == '\\') {
while (*p == _T('\\')) {
slashes++;
p++;
}
if (*p == '"') {
if (*p == _T('"')) {
if ((slashes & 1) == 0) {
copy = 0;
if ((inquote) && (p[1] == '"')) {
if ((inquote) && (p[1] == _T('"'))) {
p++;
copy = 1;
}
@ -94,12 +96,12 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
}
while (slashes) {
*arg = '\\';
*arg = _T('\\');
arg++;
slashes--;
}
if ((*p == '\0') || (!inquote && ((*p == ' ') || (*p == '\t')))) {
if ((*p == _T('\0')) || (!inquote && ((*p == _T(' ')) || (*p == _T('\t'))))) {
break;
}
if (copy != 0) {
@ -108,7 +110,7 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
}
p++;
}
*arg = '\0';
*arg = _T('\0');
argSpace = arg + 1;
}
(*argv)[*argc] = NULL;
@ -116,10 +118,10 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
return argSpaceSize;
}
void SetTitle(HWND hwnd,char *substr) {
char title[64];
if (substr==NULL) wsprintf(title,"MakeNSISW");
else wsprintf(title,"MakeNSISW - %s",substr);
void SetTitle(HWND hwnd,TCHAR *substr) {
TCHAR title[64];
if (substr==NULL) wsprintf(title,_T("MakeNSISW"));
else wsprintf(title,_T("MakeNSISW - %s"),substr);
SetWindowText(hwnd,title);
}
@ -130,9 +132,9 @@ void SetBranding(HWND hwnd) {
void CopyToClipboard(HWND hwnd) {
if (!hwnd||!OpenClipboard(hwnd)) return;
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE,len+1);
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE,(len+1)*sizeof(TCHAR));
if (!mem) { CloseClipboard(); return; }
char *existing_text = (char *)GlobalLock(mem);
TCHAR *existing_text = (TCHAR *)GlobalLock(mem);
if (!existing_text) { CloseClipboard(); return; }
EmptyClipboard();
existing_text[0]=0;
@ -143,20 +145,20 @@ void CopyToClipboard(HWND hwnd) {
}
void ClearLog(HWND hwnd) {
SetDlgItemText(hwnd, IDC_LOGWIN, "");
SetDlgItemText(hwnd, IDC_LOGWIN, _T(""));
}
void LogMessage(HWND hwnd,const char *str) {
void LogMessage(HWND hwnd,const TCHAR *str) {
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SETSEL, g_sdata.logLength, g_sdata.logLength);
g_sdata.logLength += lstrlen(str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (LPARAM)str);
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SCROLLCARET, 0, 0);
}
void ErrorMessage(HWND hwnd,const char *str) {
void ErrorMessage(HWND hwnd,const TCHAR *str) {
if (!str) return;
char buf[1028];
wsprintf(buf,"[Error] %s\r\n",str);
TCHAR buf[1028];
wsprintf(buf,_T("[Error] %s\r\n"),str);
LogMessage(hwnd,buf);
}
@ -218,7 +220,7 @@ void Items(HWND hwnd, int on){
void SetCompressorStats()
{
DWORD line_count, i;
char buf[1024];
TCHAR buf[1024];
bool found = false;
line_count = SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINECOUNT, 0, 0);
@ -237,7 +239,7 @@ void SetCompressorStats()
DWORD len = lstrlen(EXE_HEADER_COMPRESSOR_STAT);
if(!lstrncmp(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
found = true;
lstrcpy(g_sdata.compressor_stats,"\n\n");
lstrcpy(g_sdata.compressor_stats,_T("\n\n"));
lstrcat(g_sdata.compressor_stats,buf);
}
}
@ -245,7 +247,7 @@ void SetCompressorStats()
}
void CompileNSISScript() {
static char *s;
static TCHAR *s;
DragAcceptFiles(g_sdata.hwnd,FALSE);
ClearLog(g_sdata.hwnd);
SetTitle(g_sdata.hwnd,NULL);
@ -270,31 +272,31 @@ void CompileNSISScript() {
}
if (!g_sdata.compile_command) {
if (s) GlobalFree(s);
char *symbols = BuildSymbols();
TCHAR *symbols = BuildSymbols();
char compressor[40];
TCHAR compressor[40];
if(lstrlen(g_sdata.compressor_name)) {
wsprintf(compressor,"/X\"SetCompressor /FINAL %s\"",g_sdata.compressor_name);
wsprintf(compressor,_T("/X\"SetCompressor /FINAL %s\""),g_sdata.compressor_name);
}
else {
lstrcpy(compressor,"");
lstrcpy(compressor,_T(""));
}
char *args = (char *) GlobalLock(g_sdata.script_cmd_args);
TCHAR *args = (TCHAR *) GlobalLock(g_sdata.script_cmd_args);
g_sdata.compile_command = (char *) GlobalAlloc(
GPTR,
/* makensis.exe */ sizeof(EXENAME) + /* space */ 1 +
/* makensis.exe */ _countof(EXENAME) + /* space */ 1 +
/* script path */ lstrlen(g_sdata.script) + /* space */ 1 +
/* script cmd args */ lstrlen(args) + /* space */ 1 +
/* defines /Dblah=... */ lstrlen(symbols) + /* space */ 1 +
/* /XSetCompressor... */ lstrlen(compressor) + /* space */ 1 +
/* /NOTTIFYHWND + HWND */ sizeof("/NOTIFYHWND -4294967295") + /* space */ 1
);
/* /NOTTIFYHWND + HWND */ _countof(_T("/NOTIFYHWND -4294967295")) + /* space */ 1
);
wsprintf(
g_sdata.compile_command,
"%s %s %s /NOTIFYHWND %d %s -- \"%s\"",
_T("%s %s %s /NOTIFYHWND %d %s -- \"%s\""),
EXENAME,
compressor,
symbols,
@ -343,7 +345,7 @@ void RestoreWindowPos(HWND hwnd) {
if (OpenRegSettingsKey(hKey)) {
DWORD l = sizeof(p);
DWORD t;
if ((RegQueryValueEx(hKey,REGLOC,NULL,&t,(unsigned char*)&p,&l)==ERROR_SUCCESS)&&(t == REG_BINARY)&&(l==sizeof(p))) {
if ((RegQueryValueEx(hKey,REGLOC,NULL,&t,(LPBYTE)&p,&l)==ERROR_SUCCESS)&&(t == REG_BINARY)&&(l==sizeof(p))) {
int width, height;
int windowWidth, windowHeight;
@ -391,7 +393,7 @@ void SaveWindowPos(HWND hwnd) {
p.length = sizeof(p);
GetWindowPlacement(hwnd, &p);
if (OpenRegSettingsKey(hKey, true)) {
RegSetValueEx(hKey,REGLOC,0,REG_BINARY,(unsigned char*)&p,sizeof(p));
RegSetValueEx(hKey,REGLOC,0,REG_BINARY,(LPBYTE)&p,sizeof(p));
RegCloseKey(hKey);
}
}
@ -406,34 +408,34 @@ void SaveSymbols()
SaveSymbolSet(NULL, g_sdata.symbols);
}
void DeleteSymbolSet(char *name)
void DeleteSymbolSet(TCHAR *name)
{
if(name) {
HKEY hKey;
if (OpenRegSettingsKey(hKey)) {
char subkey[1024];
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
TCHAR subkey[1024];
wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name);
RegDeleteKey(hKey,subkey);
RegCloseKey(hKey);
}
}
}
char** LoadSymbolSet(char *name)
TCHAR** LoadSymbolSet(TCHAR *name)
{
HKEY hKey;
HKEY hSubKey;
char **symbols = NULL;
TCHAR **symbols = NULL;
if (OpenRegSettingsKey(hKey)) {
char subkey[1024];
TCHAR subkey[1024];
if(name) {
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name);
}
else {
lstrcpy(subkey,REGSYMSUBKEY);
}
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
char buf[8];
TCHAR buf[8];
DWORD l;
DWORD t;
DWORD bufSize;
@ -446,16 +448,16 @@ char** LoadSymbolSet(char *name)
if ((RegEnumValue(hSubKey,i, buf, &bufSize,NULL,&t,NULL,&l)==ERROR_SUCCESS)&&(t == REG_SZ)) {
if(symbols) {
GlobalUnlock(hMem);
hMem = GlobalReAlloc(hMem, (i+2)*sizeof(char *), GMEM_MOVEABLE|GMEM_ZEROINIT);
symbols = (char **)GlobalLock(hMem);
hMem = GlobalReAlloc(hMem, (i+2)*sizeof(TCHAR *), GMEM_MOVEABLE|GMEM_ZEROINIT);
symbols = (TCHAR **)GlobalLock(hMem);
}
else {
hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (i+2)*sizeof(char *));
symbols = (char **)GlobalLock(hMem);
hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (i+2)*sizeof(TCHAR *));
symbols = (TCHAR **)GlobalLock(hMem);
}
if(symbols) {
l++;
symbols[i] = (char *)GlobalAlloc(GPTR, l*sizeof(char));
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, l*sizeof(TCHAR));
if (symbols[i]) {
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&l);
}
@ -481,22 +483,22 @@ char** LoadSymbolSet(char *name)
return symbols;
}
void SaveSymbolSet(char *name, char **symbols)
void SaveSymbolSet(TCHAR *name, TCHAR **symbols)
{
HKEY hKey;
HKEY hSubKey;
int n = 0;
if (OpenRegSettingsKey(hKey, true)) {
char subkey[1024];
TCHAR subkey[1024];
if(name) {
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name);
}
else {
lstrcpy(subkey,REGSYMSUBKEY);
}
if (RegOpenKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
char buf[8];
TCHAR buf[8];
DWORD l;
while(TRUE) {
l = sizeof(buf);
@ -511,11 +513,11 @@ void SaveSymbolSet(char *name, char **symbols)
}
if(symbols) {
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
char buf[8];
TCHAR buf[8];
n = 0;
while(symbols[n]) {
wsprintf(buf,"%d",n);
RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)symbols[n],lstrlen(symbols[n])+1);
wsprintf(buf,_T("%d"),n);
RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)symbols[n],(lstrlen(symbols[n])+1)*sizeof(TCHAR));
n++;
}
RegCloseKey(hSubKey);
@ -551,9 +553,9 @@ void ResetSymbols() {
}
int InitBranding() {
char *s;
s = (char *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
wsprintf(s,"%s /version",EXENAME);
TCHAR *s;
s = (TCHAR *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
wsprintf(s,_T("%s /version"),EXENAME);
{
STARTUPINFO si={sizeof(si),};
SECURITY_ATTRIBUTES sa={sizeof(sa),};
@ -583,7 +585,7 @@ int InitBranding() {
CloseHandle(read_stdout);
return 0;
}
char szBuf[1024];
TCHAR szBuf[1024];
DWORD dwRead = 1;
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
return 0;
@ -591,9 +593,9 @@ int InitBranding() {
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
szBuf[dwRead] = 0;
if (lstrlen(szBuf)==0) return 0;
g_sdata.branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
wsprintf(g_sdata.branding,"NSIS %s",szBuf);
g_sdata.brandingv = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+1);
g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+6)*sizeof(TCHAR));
wsprintf(g_sdata.branding,_T("NSIS %s"),szBuf);
g_sdata.brandingv = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+1)*sizeof(TCHAR));
lstrcpy(g_sdata.brandingv,szBuf);
GlobalFree(s);
}
@ -613,8 +615,8 @@ void InitTooltips(HWND h) {
g_tip.tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
if (!g_tip.tip) return;
g_tip.hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
AddTip(GetDlgItem(h,IDCANCEL),TEXT("Close MakeNSISW"));
AddTip(GetDlgItem(h,IDC_TEST),TEXT("Test the installer generated by MakeNSISW"));
AddTip(GetDlgItem(h,IDCANCEL),_T("Close MakeNSISW"));
AddTip(GetDlgItem(h,IDC_TEST),_T("Test the installer generated by MakeNSISW"));
AddToolBarTooltips();
}
@ -622,7 +624,7 @@ void DestroyTooltips() {
UnhookWindowsHookEx(g_tip.hook);
}
void AddTip(HWND hWnd,LPSTR lpszToolTip) {
void AddTip(HWND hWnd,LPTSTR lpszToolTip) {
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND;
@ -646,44 +648,44 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
}
void ShowDocs() {
char pathf[MAX_PATH],*path;
TCHAR pathf[MAX_PATH],*path;
GetModuleFileName(NULL,pathf,sizeof(pathf));
path=my_strrchr(pathf,'\\');
path=my_strrchr(pathf,_T('\\'));
if(path!=NULL) *path=0;
lstrcat(pathf,LOCALDOCS);
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
ShellExecuteA(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
}
char* BuildSymbols()
TCHAR* BuildSymbols()
{
char *buf = NULL;
TCHAR *buf = NULL;
if(g_sdata.symbols) {
int i=0;
while(g_sdata.symbols[i]) {
if(buf) {
char *buf3 = (char *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(char));
wsprintf(buf3,"%s \"/D%s\"",buf,g_sdata.symbols[i]);
TCHAR *buf3 = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(TCHAR));
wsprintf(buf3,_T("%s \"/D%s\""),buf,g_sdata.symbols[i]);
GlobalFree(buf);
buf = buf3;
}
else {
buf = (char *)GlobalAlloc(GPTR,(lstrlen(g_sdata.symbols[i])+5)*sizeof(char));
wsprintf(buf,"\"/D%s\"",g_sdata.symbols[i]);
buf = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(g_sdata.symbols[i])+5)*sizeof(TCHAR));
wsprintf(buf,_T("\"/D%s\""),g_sdata.symbols[i]);
}
i++;
}
}
else {
buf = (char *)GlobalAlloc(GPTR, sizeof(char));
buf[0] = '\0';
buf = (TCHAR *)GlobalAlloc(GPTR, sizeof(TCHAR));
buf[0] = _T('\0');
}
return buf;
}
BOOL PopMRUFile(char* fname)
BOOL PopMRUFile(TCHAR* fname)
{
int i;
@ -698,7 +700,7 @@ BOOL PopMRUFile(char* fname)
for(j = i; j < MRU_LIST_SIZE-1; j++) {
lstrcpy(g_mru_list[j],g_mru_list[j+1]);
}
g_mru_list[MRU_LIST_SIZE-1][0]='\0';
g_mru_list[MRU_LIST_SIZE-1][0]=_T('\0');
return TRUE;
}
else {
@ -706,7 +708,7 @@ BOOL PopMRUFile(char* fname)
}
}
BOOL IsValidFile(char *fname)
BOOL IsValidFile(TCHAR *fname)
{
WIN32_FIND_DATA wfd;
HANDLE h;
@ -719,19 +721,19 @@ BOOL IsValidFile(char *fname)
return false;
}
void PushMRUFile(char* fname)
void PushMRUFile(TCHAR* fname)
{
int i;
DWORD rv;
char* file_part;
char full_file_name[MAX_PATH+1];
TCHAR* file_part;
TCHAR full_file_name[MAX_PATH+1];
if(!fname || fname[0] == '\0' || fname[0] == '/' || fname[0] == '-') {
if(!fname || fname[0] == _T('\0') || fname[0] == _T('/') || fname[0] == _T('-')) {
return;
}
my_memset(full_file_name,0,sizeof(full_file_name));
rv = GetFullPathName(fname,sizeof(full_file_name),full_file_name,&file_part);
rv = GetFullPathName(fname,_countof(full_file_name),full_file_name,&file_part);
if (rv == 0) {
return;
}
@ -751,9 +753,9 @@ void BuildMRUMenus()
HMENU hMenu = g_sdata.fileSubmenu;
int i;
MENUITEMINFO mii;
char buf[MRU_DISPLAY_LENGTH + 5/*number*/ + 1/*null*/];
char buf2[MRU_DISPLAY_LENGTH - 6];
char buf3[MRU_DISPLAY_LENGTH + 1];
TCHAR buf[MRU_DISPLAY_LENGTH + 5/*number*/ + 1/*null*/];
TCHAR buf2[MRU_DISPLAY_LENGTH - 6];
TCHAR buf3[MRU_DISPLAY_LENGTH + 1];
int n;
for(i = 0; i < MRU_LIST_SIZE; i++) {
@ -770,32 +772,32 @@ void BuildMRUMenus()
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = IDM_MRU_FILE+i;
mii.fType = MFT_STRING;
wsprintf(buf, "&%d ", i + 1);
wsprintf(buf, _T("&%d "), i + 1);
if(lstrlen(g_mru_list[i]) > MRU_DISPLAY_LENGTH) {
char *p = my_strrchr(g_mru_list[i],'\\');
TCHAR *p = my_strrchr(g_mru_list[i],_T('\\'));
if(p) {
p++;
if(lstrlen(p) > MRU_DISPLAY_LENGTH - 7) {
my_memset(buf2,0,sizeof(buf2));
lstrcpyn(buf2,p,MRU_DISPLAY_LENGTH - 9);
lstrcat(buf2,"...");
lstrcat(buf2,_T("..."));
lstrcpyn(buf3,g_mru_list[i],4);
lstrcat(buf,buf3);
lstrcat(buf,"...\\");
lstrcat(buf,_T("...\\"));
lstrcat(buf,buf2);
}
else {
lstrcpyn(buf3,g_mru_list[i],(MRU_DISPLAY_LENGTH - lstrlen(p) - 3));
lstrcat(buf,buf3);
lstrcat(buf,"...\\");
lstrcat(buf,_T("...\\"));
lstrcat(buf,p);
}
}
else {
lstrcpyn(buf3,g_mru_list[i],(MRU_DISPLAY_LENGTH-2));
lstrcat(buf,buf3);
lstrcat(buf,"...");
lstrcat(buf,_T("..."));
}
}
else {
@ -852,13 +854,13 @@ void RestoreMRUList()
int i;
if (OpenRegSettingsKey(hKey)) {
if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) {
char buf[8];
TCHAR buf[8];
DWORD l;
for(int i=0; i<MRU_LIST_SIZE; i++) {
wsprintf(buf,"%d",i);
wsprintf(buf,_T("%d"),i);
l = sizeof(g_mru_list[n]);
RegQueryValueEx(hSubKey,buf,NULL,NULL,(unsigned char*)g_mru_list[n],&l);
if(g_mru_list[n][0] != '\0') {
RegQueryValueEx(hSubKey,buf,NULL,NULL,(LPBYTE)g_mru_list[n],&l);
if(g_mru_list[n][0] != _T('\0')) {
n++;
}
}
@ -867,7 +869,7 @@ void RestoreMRUList()
RegCloseKey(hKey);
}
for(i = n; i < MRU_LIST_SIZE; i++) {
g_mru_list[i][0] = '\0';
g_mru_list[i][0] = _T('\0');
}
BuildMRUMenus();
@ -880,10 +882,11 @@ void SaveMRUList()
int i = 0;
if (OpenRegSettingsKey(hKey, true)) {
if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) {
char buf[8];
TCHAR buf[8];
for(i = 0; i < MRU_LIST_SIZE; i++) {
wsprintf(buf,"%d",i);
RegSetValueEx(hSubKey,buf,0,REG_SZ,(const unsigned char *)g_mru_list[i],lstrlen(g_mru_list[i]));
wsprintf(buf,_T("%d"),i);
// cbData must include the size of the terminating null character.
RegSetValueEx(hSubKey,buf,0,REG_SZ,(const BYTE*)g_mru_list[i],(lstrlen(g_mru_list[i]))*sizeof(TCHAR));
}
RegCloseKey(hSubKey);
}
@ -895,7 +898,7 @@ void ClearMRUList()
{
int i;
for(i=0; i<MRU_LIST_SIZE; i++) {
g_mru_list[i][0] = '\0';
g_mru_list[i][0] = _T('\0');
}
BuildMRUMenus();
@ -906,11 +909,11 @@ void RestoreCompressor()
HKEY hKey;
NCOMPRESSOR v = COMPRESSOR_SCRIPT;
if (OpenRegSettingsKey(hKey)) {
char compressor_name[32];
TCHAR compressor_name[32];
DWORD l = sizeof(compressor_name);
DWORD t;
if (RegQueryValueEx(hKey,REGCOMPRESSOR,NULL,&t,(unsigned char*)compressor_name,&l)==ERROR_SUCCESS) {
if (RegQueryValueEx(hKey,REGCOMPRESSOR,NULL,&t,(LPBYTE)compressor_name,&l)==ERROR_SUCCESS) {
int i;
for(i=(int)COMPRESSOR_SCRIPT; i<= (int)COMPRESSOR_BEST; i++) {
if(!lstrcmpi(compressor_names[i],compressor_name)) {
@ -935,13 +938,14 @@ void SaveCompressor()
}
if (OpenRegSettingsKey(hKey, true)) {
RegSetValueEx(hKey,REGCOMPRESSOR,0,REG_SZ,(unsigned char*)compressor_names[n],
lstrlen(compressor_names[n]));
// compressor_names, even if Unicode is saved as BYTE* data.
RegSetValueEx(hKey,REGCOMPRESSOR,0,REG_SZ,(const BYTE*)compressor_names[n],
lstrlen(compressor_names[n])*sizeof(TCHAR));
RegCloseKey(hKey);
}
}
BOOL FileExists(char *fname)
BOOL FileExists(TCHAR *fname)
{
WIN32_FIND_DATA wfd;
HANDLE h;

View file

@ -19,6 +19,8 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Unicode support by Jim Park -- 08/20/2007
*/
#ifndef UTILS_H
#define UTILS_H
@ -28,13 +30,13 @@
#define MRU_LIST_SIZE 5
#define MRU_DISPLAY_LENGTH 40
int SetArgv(const char *cmdLine, int *argc, char ***argv);
void SetTitle(HWND hwnd,char *substr);
int SetArgv(const TCHAR *cmdLine, int *argc, TCHAR ***argv);
void SetTitle(HWND hwnd,TCHAR *substr);
void SetBranding(HWND hwnd);
void CopyToClipboard(HWND hwnd);
void ClearLog(HWND hwnd);
void LogMessage(HWND hwnd,const char *str);
void ErrorMessage(HWND hwnd,const char *str);
void LogMessage(HWND hwnd,const TCHAR *str);
void ErrorMessage(HWND hwnd,const TCHAR *str);
#define DisableItems(hwnd) Items(hwnd, 0)
#define EnableItems(hwnd) Items(hwnd, 1)
void Items(HWND hwnd, int on);
@ -48,19 +50,19 @@ void ResetSymbols();
int InitBranding();
void InitTooltips(HWND h);
void DestroyTooltips();
void AddTip(HWND hWnd,LPSTR lpszToolTip);
void AddTip(HWND hWnd,LPTSTR lpszToolTip);
void ShowDocs();
void RestoreCompressor();
void SaveCompressor();
void SetCompressorStats();
BOOL PopMRUFile(char* fname);
void PushMRUFile(char* fname);
BOOL PopMRUFile(TCHAR* fname);
void PushMRUFile(TCHAR* fname);
void BuildMRUMenus();
void LoadMRUFile(int position);
void ClearMRUList();
BOOL FileExists(char *fname);
BOOL FileExists(TCHAR *fname);
HMENU FindSubMenu(HMENU hMenu, UINT uId);
#endif

View file

@ -1,6 +1,7 @@
/*
Copyright (c) 2002 Robert Rainwater
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
Contributors: Justin Frankel, Fritz Elfert, Amir Szekely and
Jim Park (Unicode Support)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -18,12 +19,13 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Unicode support by Jim Park -- 08/17/2007
*/
#define REALSTR(x) #x
#define STR(x) REALSTR(x)
#ifdef RELEASE
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE) " (NSIS Compiler Interface)";
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE) " (NSIS Compiler Interface)";
#else
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
#endif