Code cleanup
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1058 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
0910f0dd75
commit
19e6cde283
7 changed files with 49 additions and 95 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2002 Robert Rainwater
|
||||
Portions Copyright (c) 2002 Justin Frankel and Fritz Elfert
|
||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -24,18 +24,16 @@
|
|||
#include "resource.h"
|
||||
#include "noclib.h"
|
||||
|
||||
char *g_script;
|
||||
int g_retcode;
|
||||
|
||||
static RECT resizeRect;
|
||||
static int dx;
|
||||
static int dy;
|
||||
|
||||
char *g_script;
|
||||
int g_retcode;
|
||||
HINSTANCE g_hInstance;
|
||||
HWND g_hwnd;
|
||||
HANDLE g_hThread;
|
||||
BOOL g_warnings;
|
||||
|
||||
FINDREPLACE fr;
|
||||
UINT uFindReplaceMsg=0;
|
||||
HWND hwndFind=0;
|
||||
|
@ -43,20 +41,18 @@ HWND hwndFind=0;
|
|||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow) {
|
||||
HACCEL haccel;
|
||||
g_hInstance=GetModuleHandle(0);
|
||||
g_script=GetCommandLine(); // set commandline global string
|
||||
g_script=GetCommandLine();
|
||||
if (*g_script++=='"') while (*g_script++!='"');
|
||||
else while (*g_script++!=' ');
|
||||
while (*g_script==' ') g_script++;
|
||||
if (!InitBranding()) {
|
||||
MessageBox(0,"Unable to find makensis.exe.","Error",MB_ICONEXCLAMATION|MB_OK);
|
||||
MessageBox(0,NSISERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
|
||||
return 1;
|
||||
}
|
||||
ResetObjects();
|
||||
HWND hDialog = CreateDialog(g_hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
|
||||
if (!hDialog) {
|
||||
char buf [MAX_STRING];
|
||||
wsprintf(buf, "Error creating dialog box.\n\nError: %x", GetLastError ());
|
||||
MessageBox(0, buf, "Error", MB_ICONEXCLAMATION | MB_OK);
|
||||
MessageBox(0, DLGERROR, "Error", MB_ICONEXCLAMATION|MB_OK);
|
||||
return 1;
|
||||
}
|
||||
haccel = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDK_ACCEL));
|
||||
|
@ -301,8 +297,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
}
|
||||
case IDM_FIND:
|
||||
{
|
||||
if (!uFindReplaceMsg)
|
||||
uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
|
||||
if (!uFindReplaceMsg) uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
|
||||
my_memset(&fr, 0, sizeof(FINDREPLACE));
|
||||
fr.lStructSize = sizeof(FINDREPLACE);
|
||||
fr.hwndOwner = hwndDlg;
|
||||
|
@ -329,8 +324,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
ft.chrg.cpMax = SendDlgItemMessage(hwndDlg, IDC_LOGWIN, WM_GETTEXTLENGTH, 0, 0);
|
||||
ft.lpstrText = lpfr->lpstrFindWhat;
|
||||
ft.chrg.cpMin = SendDlgItemMessage(hwndDlg, IDC_LOGWIN, EM_FINDTEXTEX, flags, (LPARAM)&ft);
|
||||
if (ft.chrg.cpMin != -1)
|
||||
SendDlgItemMessage(hwndDlg, IDC_LOGWIN, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax);
|
||||
if (ft.chrg.cpMin != -1) SendDlgItemMessage(hwndDlg, IDC_LOGWIN, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax);
|
||||
else MessageBeep(MB_ICONASTERISK);
|
||||
}
|
||||
if (lpfr->Flags & FR_DIALOGTERM) hwndFind = 0;
|
||||
|
@ -345,7 +339,6 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
|||
SECURITY_DESCRIPTOR sd={0,};
|
||||
PROCESS_INFORMATION pi={0,};
|
||||
HANDLE newstdout=0,read_stdout=0;
|
||||
|
||||
OSVERSIONINFO osv={sizeof(osv)};
|
||||
GetVersionEx(&osv);
|
||||
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
||||
|
@ -374,11 +367,9 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
|||
PostMessage(g_hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char szBuf[1024];
|
||||
DWORD dwRead = 1;
|
||||
DWORD dwExit = !STILL_ACTIVE;
|
||||
|
||||
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
||||
if (dwRead) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2002 Robert Rainwater
|
||||
Portions Copyright (c) 2002 Justin Frankel and Fritz Elfert
|
||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -23,6 +23,7 @@
|
|||
#define MAKENSIS_H
|
||||
|
||||
#include <commctrl.h>
|
||||
#include "utils.h"
|
||||
|
||||
#define _RICHEDIT_VER 0x0200
|
||||
#include <RichEdit.h>
|
||||
|
@ -32,30 +33,34 @@
|
|||
#define NSIS_URL "http://sourceforge.net/projects/nsis/"
|
||||
#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 NSI\""
|
||||
#define COPYRIGHT "Copyright (c) 2002 Robert Rainwater"
|
||||
#define CONTRIBUTOR "Portions Copyright (c) 2002 Justin Frankel, Fritz Elfert, and Amir Szekely"
|
||||
#define CONTRIBUTOR "Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely"
|
||||
#define DOCPATH "http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/nsis/NSIS/docs/index.html?rev=HEAD"
|
||||
#define LOCALDOCS "\\docs\\index.html"
|
||||
#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 REGSEC HKEY_LOCAL_MACHINE
|
||||
#define REGKEY "Software\\NSIS"
|
||||
#define REGLOC "MakeNSISWPlacement"
|
||||
#define EXENAME "makensis.exe"
|
||||
#define MAX_STRING 256
|
||||
#define TIMEOUT 150
|
||||
#define TIMEOUT 100
|
||||
#define MINWIDTH 350
|
||||
#define MINHEIGHT 180
|
||||
#define REGSEC HKEY_LOCAL_MACHINE
|
||||
#define REGKEY "Software\\NSIS"
|
||||
#define REGLOC "MakeNSISWPlacement"
|
||||
|
||||
#define WM_MAKENSIS_PROCESSCOMPLETE (WM_USER+1001)
|
||||
|
||||
// Extern Variables
|
||||
extern const char *NSISW_VERSION;
|
||||
extern char *g_script;
|
||||
extern const char* NSISW_VERSION;
|
||||
extern char* g_script;
|
||||
extern HWND g_hwnd;
|
||||
extern HANDLE g_hThread;
|
||||
extern char *g_output_exe;
|
||||
extern char *g_input_script;
|
||||
extern int g_retcode;
|
||||
extern char * g_output_exe;
|
||||
extern char * g_input_script;
|
||||
extern int g_retcode;
|
||||
|
||||
// makensisw
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmdShow);
|
||||
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
DWORD WINAPI MakeNSISProc(LPVOID p);
|
||||
|
@ -63,20 +68,4 @@ BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
|
|||
BOOL CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
void CompileNSISScript();
|
||||
|
||||
// utils
|
||||
void SetTitle(HWND hwnd,char *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 DisableItems(HWND hwnd);
|
||||
void EnableItems(HWND hwnd);
|
||||
void RestoreWindowPos(HWND hwnd);
|
||||
void SaveWindowPos(HWND hwnd);
|
||||
void ResetObjects();
|
||||
int InitBranding();
|
||||
void InitTooltips(HWND h);
|
||||
void DestroyTooltips();
|
||||
void AddTip(HWND hWnd,LPSTR lpszToolTip);
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2002 Robert Rainwater
|
||||
Portions Copyright (c) 2002 Justin Frankel and Fritz Elfert
|
||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
||||
|
||||
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,21 +18,18 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
/*
|
||||
Contribution by kickik
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include "noclib.h"
|
||||
|
||||
// kickik's clib methods
|
||||
char *my_strrchr(const char *string, int c) {
|
||||
for (int i = lstrlen(string); i >= 0; i--)
|
||||
if (string[i] == c)
|
||||
return (char*)&string[i];
|
||||
for (int i=lstrlen(string); i>=0; i--)
|
||||
if (string[i]==c) return (char*)&string[i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *my_memset(void *dest, int c, size_t count) {
|
||||
for (size_t i = 0; i < count; i++) ((char*)dest)[i]=c;
|
||||
for (size_t i=0; i<count;i++) ((char*)dest)[i]=c;
|
||||
return dest;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2002 Robert Rainwater
|
||||
Portions Copyright (c) 2002 Justin Frankel and Fritz Elfert
|
||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
||||
|
||||
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,13 +18,11 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
/*
|
||||
Contribution by kickik
|
||||
*/
|
||||
#ifndef NOCLIB_H
|
||||
#define NOCLIB_H
|
||||
|
||||
// kickik's clib methods
|
||||
char *my_strrchr(const char *string, int c);
|
||||
void *my_memset(void *dest, int c, size_t count);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2002 Robert Rainwater
|
||||
Portions Copyright (c) 2002 Justin Frankel and Fritz Elfert
|
||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -25,6 +25,18 @@
|
|||
#include "noclib.h"
|
||||
|
||||
char *g_branding;
|
||||
char *g_output_exe;
|
||||
char *g_input_script;
|
||||
HWND g_tip;
|
||||
HWND g_tip_p;
|
||||
HHOOK g_hook;
|
||||
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
extern BOOL g_warnings;
|
||||
extern HANDLE g_hThread;
|
||||
extern int g_retcode;
|
||||
|
||||
static BOOL g_appended = FALSE;
|
||||
|
||||
void SetTitle(HWND hwnd,char *substr) {
|
||||
char title[64];
|
||||
|
@ -52,15 +64,10 @@ void CopyToClipboard(HWND hwnd) {
|
|||
CloseClipboard();
|
||||
}
|
||||
|
||||
|
||||
void ClearLog(HWND hwnd) {
|
||||
SetDlgItemText(hwnd, IDC_LOGWIN, "");
|
||||
}
|
||||
|
||||
char *g_output_exe;
|
||||
char *g_input_script;
|
||||
extern BOOL g_warnings;
|
||||
|
||||
void LogMessage(HWND hwnd,const char *str) {
|
||||
DWORD dwLength = SendDlgItemMessage(hwnd, IDC_LOGWIN, WM_GETTEXTLENGTH, 0, 0);
|
||||
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SETSEL, dwLength, dwLength);
|
||||
|
@ -93,7 +100,6 @@ void EnableItems(HWND hwnd) {
|
|||
#define MSG(a) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,0,0)
|
||||
#define MSG1(a,b) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,0)
|
||||
#define MSG2(a,b,c) SendDlgItemMessage(hwnd,IDC_LOGWIN,a,b,c)
|
||||
|
||||
if (g_input_script) {
|
||||
GlobalFree(g_input_script);
|
||||
g_input_script = 0;
|
||||
|
@ -102,7 +108,6 @@ void EnableItems(HWND hwnd) {
|
|||
GlobalFree(g_output_exe);
|
||||
g_output_exe = 0;
|
||||
}
|
||||
|
||||
TEXTRANGE tr;
|
||||
FINDTEXT ft;
|
||||
|
||||
|
@ -148,7 +153,6 @@ void EnableItems(HWND hwnd) {
|
|||
EnableMenuItem(m,IDM_EDITSCRIPT,MF_ENABLED);
|
||||
}
|
||||
|
||||
static BOOL g_appended = FALSE;
|
||||
void CompileNSISScript() {
|
||||
static char *s;
|
||||
DragAcceptFiles(g_hwnd,FALSE);
|
||||
|
@ -203,9 +207,6 @@ void SaveWindowPos(HWND hwnd) {
|
|||
}
|
||||
}
|
||||
|
||||
extern HANDLE g_hThread;
|
||||
extern int g_retcode;
|
||||
|
||||
void ResetObjects() {
|
||||
g_appended = FALSE;
|
||||
g_warnings = FALSE;
|
||||
|
@ -262,11 +263,6 @@ int InitBranding() {
|
|||
return 1;
|
||||
}
|
||||
|
||||
HWND g_tip;
|
||||
HWND g_tip_p;
|
||||
HHOOK g_hook;
|
||||
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void InitTooltips(HWND h) {
|
||||
if (h == NULL) return;
|
||||
g_tip_p = h;
|
||||
|
@ -274,15 +270,10 @@ void InitTooltips(HWND h) {
|
|||
icx.dwSize = sizeof(icx);
|
||||
icx.dwICC = ICC_BAR_CLASSES;
|
||||
InitCommonControlsEx(&icx);
|
||||
DWORD dwStyle = WS_POPUP | WS_BORDER | TTS_ALWAYSTIP;
|
||||
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
g_tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,
|
||||
NULL,dwStyle,0,0,0,0,
|
||||
h, NULL,
|
||||
GetModuleHandle(NULL),NULL);
|
||||
if (!g_tip) {
|
||||
return;
|
||||
}
|
||||
DWORD dwStyle = WS_POPUP | WS_BORDER | TTS_ALWAYSTIP;
|
||||
DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
g_tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
|
||||
if (!g_tip) return;
|
||||
g_hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
|
||||
AddTip(GetDlgItem(h,IDC_CLOSE),TEXT("Close MakeNSISW"));
|
||||
AddTip(GetDlgItem(h,IDC_TEST),TEXT("Test the installer generated by MakeNSISW"));
|
||||
|
@ -313,5 +304,4 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
|||
break;
|
||||
}
|
||||
return CallNextHookEx(g_hook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,16 +22,6 @@
|
|||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#define REGSEC HKEY_LOCAL_MACHINE // JF> modified this to HKLM so that
|
||||
// nsis uninstaller would remove. this means
|
||||
// window placement is shared across users, but
|
||||
// bfd.
|
||||
#define REGKEY "Software\\NSIS"
|
||||
#define REGLOC "MakeNSISWPlacement"
|
||||
|
||||
extern const char NSISW_VERSION[];
|
||||
|
||||
// Methods
|
||||
void SetTitle(HWND hwnd,char *substr);
|
||||
void SetBranding(HWND hwnd);
|
||||
void CopyToClipboard(HWND hwnd);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (c) 2002 Robert Rainwater
|
||||
Portions Copyright (c) 2002 Justin Frankel and Fritz Elfert
|
||||
Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
@ -19,12 +19,11 @@
|
|||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
// Turns a define into a string
|
||||
#define REALSTR(x) #x
|
||||
#define STR(x) REALSTR(x)
|
||||
|
||||
#ifdef RELEASE
|
||||
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE);
|
||||
#else
|
||||
const char *NSISW_VERSION = "MakeNSISW Local Build: " __DATE__;
|
||||
const char *NSISW_VERSION = "MakeNSISW Build: " __DATE__;
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue