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:
parent
4e48722b63
commit
752d7d239a
209 changed files with 9698 additions and 7658 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
// For layered windows
|
// For layered windows
|
||||||
#define _WIN32_WINNT 0x0500
|
#define _WIN32_WINNT 0x0500
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ int g_rv;
|
||||||
int resolution;
|
int resolution;
|
||||||
int sleep_val, fadein_val, fadeout_val, state, timeleft, keycolor, nt50,
|
int sleep_val, fadein_val, fadeout_val, state, timeleft, keycolor, nt50,
|
||||||
alphaparam;
|
alphaparam;
|
||||||
const char classname[4] = "_sp";
|
const TCHAR classname[4] = _T("_sp");
|
||||||
|
|
||||||
typedef BOOL(_stdcall * _tSetLayeredWindowAttributesProc) (HWND hwnd, // handle to the layered window
|
typedef BOOL(_stdcall * _tSetLayeredWindowAttributesProc) (HWND hwnd, // handle to the layered window
|
||||||
COLORREF crKey, // specifies the color key
|
COLORREF crKey, // specifies the color key
|
||||||
|
@ -170,11 +171,11 @@ void CALLBACK TimeProc(UINT uID,
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t ** stacktop)
|
TCHAR *variables, stack_t ** stacktop)
|
||||||
{
|
{
|
||||||
DEVMODE dm;
|
DEVMODE dm;
|
||||||
char fn[MAX_PATH];
|
TCHAR fn[MAX_PATH];
|
||||||
char temp[64];
|
TCHAR temp[64];
|
||||||
|
|
||||||
g_rv = -1;
|
g_rv = -1;
|
||||||
resolution = RESOLUTION;
|
resolution = RESOLUTION;
|
||||||
|
@ -223,10 +224,10 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.lpszClassName = classname;
|
wc.lpszClassName = classname;
|
||||||
if (RegisterClass(&wc)) {
|
if (RegisterClass(&wc)) {
|
||||||
char fn2[MAX_PATH];
|
TCHAR fn2[MAX_PATH];
|
||||||
lstrcpy(fn2, fn);
|
lstrcpy(fn2, fn);
|
||||||
lstrcat(fn, ".bmp");
|
lstrcat(fn, _T(".bmp"));
|
||||||
lstrcat(fn2, ".wav");
|
lstrcat(fn2, _T(".wav"));
|
||||||
g_hbm =
|
g_hbm =
|
||||||
LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0,
|
LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0,
|
||||||
LR_CREATEDIBSECTION | LR_LOADFROMFILE);
|
LR_CREATEDIBSECTION | LR_LOADFROMFILE);
|
||||||
|
@ -235,7 +236,7 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
UINT timerEvent;
|
UINT timerEvent;
|
||||||
|
|
||||||
// Get Bitmap Information
|
// Get Bitmap Information
|
||||||
GetObject(g_hbm, sizeof(bm), (LPSTR) & bm);
|
GetObject(g_hbm, sizeof(bm), & bm);
|
||||||
|
|
||||||
myWnd =
|
myWnd =
|
||||||
CreateWindowEx(WS_EX_TOOLWINDOW |
|
CreateWindowEx(WS_EX_TOOLWINDOW |
|
||||||
|
@ -246,7 +247,7 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
// Set transparency / key color
|
// Set transparency / key color
|
||||||
if (nt50) {
|
if (nt50) {
|
||||||
// Get blending proc address
|
// Get blending proc address
|
||||||
HANDLE user32 = GetModuleHandle("user32");
|
HANDLE user32 = GetModuleHandle(_T("user32"));
|
||||||
SetLayeredWindowAttributesProc =
|
SetLayeredWindowAttributesProc =
|
||||||
(_tSetLayeredWindowAttributesProc) GetProcAddress(user32,
|
(_tSetLayeredWindowAttributesProc) GetProcAddress(user32,
|
||||||
"SetLayeredWindowAttributes");
|
"SetLayeredWindowAttributes");
|
||||||
|
@ -283,6 +284,6 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
UnregisterClass(wc.lpszClassName, g_hInstance);
|
UnregisterClass(wc.lpszClassName, g_hInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wsprintf(temp, "%d", g_rv);
|
wsprintf(temp, _T("%d"), g_rv);
|
||||||
pushstring(temp);
|
pushstring(temp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
#include "../../Source/exehead/resource.h"
|
#include "../../Source/exehead/resource.h"
|
||||||
|
|
||||||
|
// Unicode support added by Jim Park -- 08/02/2007
|
||||||
|
|
||||||
// Turn a pair of chars into a word
|
// Turn a pair of chars into a word
|
||||||
// Turn four chars into a dword
|
// Turn four chars into a dword
|
||||||
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
#ifdef __BIG_ENDIAN__ // Not very likely, but, still...
|
||||||
|
@ -17,7 +19,7 @@ HWND hwBanner;
|
||||||
HANDLE hThread;
|
HANDLE hThread;
|
||||||
BOOL bFailed;
|
BOOL bFailed;
|
||||||
|
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
|
|
||||||
BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK BannerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +118,7 @@ static UINT_PTR PluginCallback(enum NSPIM msg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
|
@ -155,13 +157,13 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) getWindow(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
void __declspec(dllexport) getWindow(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
wsprintf(buf, "%u", hwBanner);
|
wsprintf(buf, _T("%u"), hwBanner);
|
||||||
pushstring(buf);
|
pushstring(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) destroy(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
void __declspec(dllexport) destroy(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
if (!hwBanner)
|
if (!hwBanner)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
@ -8,9 +10,9 @@
|
||||||
g_stringsize=string_size; \
|
g_stringsize=string_size; \
|
||||||
g_stacktop=stacktop; }
|
g_stacktop=stacktop; }
|
||||||
|
|
||||||
#define NSISFunc(name) extern "C" void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
#define NSISFunc(name) extern "C" void __declspec(dllexport) name(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
|
|
||||||
char szTemp[2048];
|
TCHAR szTemp[2048];
|
||||||
HWND hWndImage, hWndParent;
|
HWND hWndImage, hWndParent;
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
|
@ -37,7 +39,7 @@ struct myImageList {
|
||||||
BYTE iType;
|
BYTE iType;
|
||||||
union {
|
union {
|
||||||
HBITMAP hBitmap;
|
HBITMAP hBitmap;
|
||||||
char *szText;
|
TCHAR *szText;
|
||||||
COLORREF cGradientFrom;
|
COLORREF cGradientFrom;
|
||||||
};
|
};
|
||||||
RECT rPos;
|
RECT rPos;
|
||||||
|
@ -80,14 +82,14 @@ NSISFunc(SetReturn) {
|
||||||
extra->RegisterPluginCallback(g_hInstance, PluginCallback);
|
extra->RegisterPluginCallback(g_hInstance, PluginCallback);
|
||||||
|
|
||||||
popstring(szTemp);
|
popstring(szTemp);
|
||||||
bReturn = !lstrcmpi(szTemp, "on");
|
bReturn = !lstrcmpi(szTemp, _T("on"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __stdcall my_pushstring(char *str)
|
static void __stdcall my_pushstring(TCHAR *str)
|
||||||
{
|
{
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
if (!g_stacktop || !bReturn) return;
|
if (!g_stacktop || !bReturn) return;
|
||||||
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
|
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+(g_stringsize*sizeof(TCHAR)));
|
||||||
lstrcpyn(th->text,str,g_stringsize);
|
lstrcpyn(th->text,str,g_stringsize);
|
||||||
th->next=*g_stacktop;
|
th->next=*g_stacktop;
|
||||||
*g_stacktop=th;
|
*g_stacktop=th;
|
||||||
|
@ -104,7 +106,7 @@ NSISFunc(SetBg) {
|
||||||
hWndParent = hwndParent;
|
hWndParent = hwndParent;
|
||||||
|
|
||||||
if (!hwndParent) {
|
if (!hwndParent) {
|
||||||
my_pushstring("can't find parent window");
|
my_pushstring(_T("can't find parent window"));
|
||||||
LCS();
|
LCS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -120,18 +122,18 @@ NSISFunc(SetBg) {
|
||||||
LoadCursor(0, IDC_ARROW),
|
LoadCursor(0, IDC_ARROW),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"NSISBGImage",
|
_T("NSISBGImage"),
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
ATOM atomClass = RegisterClassEx(&wc);
|
ATOM atomClass = RegisterClassEx(&wc);
|
||||||
if (!atomClass) {
|
if (!atomClass) {
|
||||||
my_pushstring("can't create window");
|
my_pushstring(_T("can't create window"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hWndImage = CreateWindowEx(
|
hWndImage = CreateWindowEx(
|
||||||
WS_EX_TOOLWINDOW,
|
WS_EX_TOOLWINDOW,
|
||||||
(LPSTR)(DWORD)atomClass,
|
(LPTSTR)(DWORD)atomClass,
|
||||||
0,
|
0,
|
||||||
WS_CLIPSIBLINGS|WS_POPUP,
|
WS_CLIPSIBLINGS|WS_POPUP,
|
||||||
0,
|
0,
|
||||||
|
@ -144,7 +146,7 @@ NSISFunc(SetBg) {
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
if (!hWndImage) {
|
if (!hWndImage) {
|
||||||
my_pushstring("can't create window");
|
my_pushstring(_T("can't create window"));
|
||||||
LCS();
|
LCS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +227,7 @@ done:
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_pushstring("success");
|
my_pushstring(_T("success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
NSISFunc(AddImage) {
|
NSISFunc(AddImage) {
|
||||||
|
@ -233,7 +235,7 @@ NSISFunc(AddImage) {
|
||||||
|
|
||||||
myImageList *newImg = (myImageList *)GlobalAlloc(GPTR, sizeof(myImageList));
|
myImageList *newImg = (myImageList *)GlobalAlloc(GPTR, sizeof(myImageList));
|
||||||
if (!newImg) {
|
if (!newImg) {
|
||||||
my_pushstring("memory allocation error");
|
my_pushstring(_T("memory allocation error"));
|
||||||
LCS();
|
LCS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +244,7 @@ NSISFunc(AddImage) {
|
||||||
newImg->cTransparent = (COLORREF)-1;
|
newImg->cTransparent = (COLORREF)-1;
|
||||||
|
|
||||||
popstring(szTemp);
|
popstring(szTemp);
|
||||||
if (!lstrcmpi(szTemp, "/TRANSPARENT")) {
|
if (!lstrcmpi(szTemp, _T("/TRANSPARENT"))) {
|
||||||
newImg->iType = MIL_TRANSPARENT_BITMAP;
|
newImg->iType = MIL_TRANSPARENT_BITMAP;
|
||||||
newImg->cTransparent = GetColor();
|
newImg->cTransparent = GetColor();
|
||||||
popstring(szTemp);
|
popstring(szTemp);
|
||||||
|
@ -265,7 +267,7 @@ NSISFunc(AddImage) {
|
||||||
while (img->next) img = img->next;
|
while (img->next) img = img->next;
|
||||||
img->next = newImg;
|
img->next = newImg;
|
||||||
|
|
||||||
my_pushstring("success");
|
my_pushstring(_T("success"));
|
||||||
|
|
||||||
LCS();
|
LCS();
|
||||||
}
|
}
|
||||||
|
@ -275,7 +277,7 @@ NSISFunc(AddText) {
|
||||||
|
|
||||||
myImageList *newImg = (myImageList *)GlobalAlloc(GPTR, sizeof(myImageList));
|
myImageList *newImg = (myImageList *)GlobalAlloc(GPTR, sizeof(myImageList));
|
||||||
if (!newImg) {
|
if (!newImg) {
|
||||||
my_pushstring("memory allocation error");
|
my_pushstring(_T("memory allocation error"));
|
||||||
LCS();
|
LCS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -283,9 +285,9 @@ NSISFunc(AddText) {
|
||||||
newImg->iType = MIL_TEXT;
|
newImg->iType = MIL_TEXT;
|
||||||
|
|
||||||
popstring(szTemp);
|
popstring(szTemp);
|
||||||
newImg->szText = (char *)GlobalAlloc(GPTR, lstrlen(szTemp)+1);
|
newImg->szText = (TCHAR *)GlobalAlloc(GPTR, (lstrlen(szTemp)+1)*sizeof(TCHAR));
|
||||||
if (!newImg->szText) {
|
if (!newImg->szText) {
|
||||||
my_pushstring("memory allocation error");
|
my_pushstring(_T("memory allocation error"));
|
||||||
GlobalFree(newImg);
|
GlobalFree(newImg);
|
||||||
LCS();
|
LCS();
|
||||||
return;
|
return;
|
||||||
|
@ -303,7 +305,7 @@ NSISFunc(AddText) {
|
||||||
while (img->next) img = img->next;
|
while (img->next) img = img->next;
|
||||||
img->next = newImg;
|
img->next = newImg;
|
||||||
|
|
||||||
my_pushstring("success");
|
my_pushstring(_T("success"));
|
||||||
|
|
||||||
LCS();
|
LCS();
|
||||||
}
|
}
|
||||||
|
@ -351,7 +353,7 @@ NSISFunc(Destroy) {
|
||||||
hWndImage = 0;
|
hWndImage = 0;
|
||||||
oldProc = NULL;
|
oldProc = NULL;
|
||||||
Clear(0, 0, 0, 0, 0);
|
Clear(0, 0, 0, 0, 0);
|
||||||
UnregisterClass("NSISBGImage", g_hInstance);
|
UnregisterClass(_T("NSISBGImage"), g_hInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSISFunc(Sound) {
|
NSISFunc(Sound) {
|
||||||
|
@ -576,7 +578,7 @@ HBITMAP __stdcall LoadBitmapFile(long right, long bottom, BITMAP *bBitmap)
|
||||||
{
|
{
|
||||||
HBITMAP hBitmap = (HBITMAP)LoadImage(0, szTemp, IMAGE_BITMAP, right, bottom, LR_LOADFROMFILE);
|
HBITMAP hBitmap = (HBITMAP)LoadImage(0, szTemp, IMAGE_BITMAP, right, bottom, LR_LOADFROMFILE);
|
||||||
if (!hBitmap || !GetObject(hBitmap, sizeof(BITMAP), (void *)bBitmap)) {
|
if (!hBitmap || !GetObject(hBitmap, sizeof(BITMAP), (void *)bBitmap)) {
|
||||||
my_pushstring("can't load bitmap");
|
my_pushstring(_T("can't load bitmap"));
|
||||||
if (hBitmap)
|
if (hBitmap)
|
||||||
DeleteObject(hBitmap);
|
DeleteObject(hBitmap);
|
||||||
LCS();
|
LCS();
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wininet.h>
|
#include <wininet.h>
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
|
||||||
#define NSISFunction(funcname) void __declspec(dllexport) funcname(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
#define NSISFunction(funcname) void __declspec(dllexport) funcname(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -16,8 +18,9 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
||||||
|
|
||||||
HMODULE hWinInet = NULL;
|
HMODULE hWinInet = NULL;
|
||||||
|
|
||||||
|
// GetProcAddress only takes ANSI.
|
||||||
FARPROC GetWinInetFunc(char *func) {
|
FARPROC GetWinInetFunc(char *func) {
|
||||||
hWinInet = LoadLibrary("wininet.dll");
|
hWinInet = LoadLibrary(_T("wininet.dll"));
|
||||||
if (hWinInet)
|
if (hWinInet)
|
||||||
return GetProcAddress(hWinInet, func);
|
return GetProcAddress(hWinInet, func);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -44,9 +47,9 @@ NSISFunction(AutodialOnline) {
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
if (pInternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0))
|
if (pInternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE, 0))
|
||||||
pushstring("online");
|
pushstring(_T("online"));
|
||||||
else
|
else
|
||||||
pushstring("offline");
|
pushstring(_T("offline"));
|
||||||
|
|
||||||
FreeWinInet();
|
FreeWinInet();
|
||||||
}
|
}
|
||||||
|
@ -62,9 +65,9 @@ NSISFunction(AutodialUnattended) {
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
if (pInternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED , 0))
|
if (pInternetAutodial(INTERNET_AUTODIAL_FORCE_UNATTENDED , 0))
|
||||||
pushstring("online");
|
pushstring(_T("online"));
|
||||||
else
|
else
|
||||||
pushstring("offline");
|
pushstring(_T("offline"));
|
||||||
|
|
||||||
FreeWinInet();
|
FreeWinInet();
|
||||||
}
|
}
|
||||||
|
@ -80,9 +83,9 @@ NSISFunction(AttemptConnect) {
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
if (pInternetAttemptConnect(0) == ERROR_SUCCESS)
|
if (pInternetAttemptConnect(0) == ERROR_SUCCESS)
|
||||||
pushstring("online");
|
pushstring(_T("online"));
|
||||||
else
|
else
|
||||||
pushstring("offline");
|
pushstring(_T("offline"));
|
||||||
|
|
||||||
FreeWinInet();
|
FreeWinInet();
|
||||||
}
|
}
|
||||||
|
@ -100,9 +103,9 @@ NSISFunction(GetConnectedState) {
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
if (pInternetGetConnectedState(&dwState, 0))
|
if (pInternetGetConnectedState(&dwState, 0))
|
||||||
pushstring("online");
|
pushstring(_T("online"));
|
||||||
else
|
else
|
||||||
pushstring("offline");
|
pushstring(_T("offline"));
|
||||||
|
|
||||||
FreeWinInet();
|
FreeWinInet();
|
||||||
}
|
}
|
||||||
|
@ -118,9 +121,9 @@ NSISFunction(AutodialHangup) {
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
if (pInternetAutodialHangup(0))
|
if (pInternetAutodialHangup(0))
|
||||||
pushstring("success");
|
pushstring(_T("success"));
|
||||||
else
|
else
|
||||||
pushstring("failure");
|
pushstring(_T("failure"));
|
||||||
|
|
||||||
FreeWinInet();
|
FreeWinInet();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ lib_files = Split("""
|
||||||
|
|
||||||
api_files = Split("""
|
api_files = Split("""
|
||||||
pluginapi.h
|
pluginapi.h
|
||||||
|
nsis_tchar.h
|
||||||
#Source/exehead/api.h
|
#Source/exehead/api.h
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ example = Split("""
|
||||||
exdll.dsw
|
exdll.dsw
|
||||||
exdll_with_unit.dpr
|
exdll_with_unit.dpr
|
||||||
exdll-vs2008.sln
|
exdll-vs2008.sln
|
||||||
exdll-vs2008.vcproj
|
exdll-vs2008.vcproj
|
||||||
nsis.pas
|
nsis.pas
|
||||||
extdll.inc
|
extdll.inc
|
||||||
""")
|
""")
|
||||||
|
|
|
@ -5,8 +5,11 @@ HINSTANCE g_hInstance;
|
||||||
|
|
||||||
HWND g_hwndParent;
|
HWND g_hwndParent;
|
||||||
|
|
||||||
|
// To work with Unicode version of NSIS, please use TCHAR-type
|
||||||
|
// functions for accessing the variables and the stack.
|
||||||
|
|
||||||
void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
|
void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop,
|
TCHAR *variables, stack_t **stacktop,
|
||||||
extra_parameters *extra)
|
extra_parameters *extra)
|
||||||
{
|
{
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
|
@ -23,8 +26,8 @@ void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
|
||||||
|
|
||||||
// do your stuff here
|
// do your stuff here
|
||||||
{
|
{
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
wsprintf(buf,"$0=%s\n",getuservariable(INST_0));
|
wsprintf(buf,_T("$0=%s\n"),getuservariable(INST_0));
|
||||||
MessageBox(g_hwndParent,buf,0,MB_OK);
|
MessageBox(g_hwndParent,buf,0,MB_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
214
Contrib/ExDLL/nsis_tchar.h
Normal file
214
Contrib/ExDLL/nsis_tchar.h
Normal file
|
@ -0,0 +1,214 @@
|
||||||
|
/*
|
||||||
|
* nsis_tchar.h
|
||||||
|
*
|
||||||
|
* This file is a part of NSIS.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1999-2007 Nullsoft and Contributors
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty.
|
||||||
|
*
|
||||||
|
* For Unicode support by Jim Park -- 08/30/2007
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Jim Park: Only those we use are listed here.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
|
||||||
|
#ifndef _T
|
||||||
|
#define __T(x) L ## x
|
||||||
|
#define _T(x) __T(x)
|
||||||
|
#define _TEXT(x) __T(x)
|
||||||
|
#endif
|
||||||
|
typedef wchar_t TCHAR;
|
||||||
|
typedef wchar_t _TUCHAR;
|
||||||
|
|
||||||
|
// program
|
||||||
|
#define _tmain wmain
|
||||||
|
#define _tWinMain wWinMain
|
||||||
|
#define _tenviron _wenviron
|
||||||
|
#define __targv __wargv
|
||||||
|
|
||||||
|
// printfs
|
||||||
|
#define _ftprintf fwprintf
|
||||||
|
#define _sntprintf _snwprintf
|
||||||
|
#define _stprintf _swprintf
|
||||||
|
#define _tprintf wprintf
|
||||||
|
#define _vftprintf vfwprintf
|
||||||
|
#define _vsntprintf _vsnwprintf
|
||||||
|
#define _vstprintf _vswprintf
|
||||||
|
|
||||||
|
// scanfs
|
||||||
|
#define _tscanf wscanf
|
||||||
|
#define _stscanf swscanf
|
||||||
|
|
||||||
|
// string manipulations
|
||||||
|
#define _tcscat wcscat
|
||||||
|
#define _tcschr wcschr
|
||||||
|
#define _tcsclen wcslen
|
||||||
|
#define _tcscpy wcscpy
|
||||||
|
#define _tcsdup _wcsdup
|
||||||
|
#define _tcslen wcslen
|
||||||
|
#define _tcsnccpy wcsncpy
|
||||||
|
#define _tcsncpy wcsncpy
|
||||||
|
#define _tcsrchr wcsrchr
|
||||||
|
#define _tcsstr wcsstr
|
||||||
|
#define _tcstok wcstok
|
||||||
|
|
||||||
|
// string comparisons
|
||||||
|
#define _tcscmp wcscmp
|
||||||
|
#define _tcsicmp _wcsicmp
|
||||||
|
#define _tcsncicmp _wcsnicmp
|
||||||
|
#define _tcsncmp wcsncmp
|
||||||
|
#define _tcsnicmp _wcsnicmp
|
||||||
|
|
||||||
|
// upper / lower
|
||||||
|
#define _tcslwr _wcslwr
|
||||||
|
#define _tcsupr _wcsupr
|
||||||
|
#define _totlower towlower
|
||||||
|
#define _totupper towupper
|
||||||
|
|
||||||
|
// conversions to numbers
|
||||||
|
#define _tcstoi64 _wcstoi64
|
||||||
|
#define _tcstol wcstol
|
||||||
|
#define _tcstoul wcstoul
|
||||||
|
#define _tstof _wtof
|
||||||
|
#define _tstoi _wtoi
|
||||||
|
#define _tstoi64 _wtoi64
|
||||||
|
#define _ttoi _wtoi
|
||||||
|
#define _ttoi64 _wtoi64
|
||||||
|
#define _ttol _wtol
|
||||||
|
|
||||||
|
// conversion from numbers to strings
|
||||||
|
#define _itot _itow
|
||||||
|
#define _ltot _ltow
|
||||||
|
#define _i64tot _i64tow
|
||||||
|
#define _ui64tot _ui64tow
|
||||||
|
|
||||||
|
// file manipulations
|
||||||
|
#define _tfopen _wfopen
|
||||||
|
#define _topen _wopen
|
||||||
|
#define _tremove _wremove
|
||||||
|
#define _tunlink _wunlink
|
||||||
|
|
||||||
|
// reading and writing to i/o
|
||||||
|
#define _fgettc fgetwc
|
||||||
|
#define _fgetts fgetws
|
||||||
|
#define _fputts fputws
|
||||||
|
#define _gettchar getwchar
|
||||||
|
|
||||||
|
// directory
|
||||||
|
#define _tchdir _wchdir
|
||||||
|
|
||||||
|
// environment
|
||||||
|
#define _tgetenv _wgetenv
|
||||||
|
#define _tsystem _wsystem
|
||||||
|
|
||||||
|
// time
|
||||||
|
#define _tcsftime wcsftime
|
||||||
|
|
||||||
|
#else // ANSI
|
||||||
|
|
||||||
|
#ifndef _T
|
||||||
|
#define _T(x) x
|
||||||
|
#define _TEXT(x) x
|
||||||
|
#endif
|
||||||
|
typedef char TCHAR;
|
||||||
|
typedef unsigned char _TUCHAR;
|
||||||
|
|
||||||
|
// program
|
||||||
|
#define _tmain main
|
||||||
|
#define _tWinMain WinMain
|
||||||
|
#define _tenviron environ
|
||||||
|
#define __targv __argv
|
||||||
|
|
||||||
|
// printfs
|
||||||
|
#define _ftprintf fprintf
|
||||||
|
#define _sntprintf _snprintf
|
||||||
|
#define _stprintf sprintf
|
||||||
|
#define _tprintf printf
|
||||||
|
#define _vftprintf vfprintf
|
||||||
|
#define _vsntprintf _vsnprintf
|
||||||
|
#define _vstprintf vsprintf
|
||||||
|
|
||||||
|
// scanfs
|
||||||
|
#define _tscanf scanf
|
||||||
|
#define _stscanf sscanf
|
||||||
|
|
||||||
|
// string manipulations
|
||||||
|
#define _tcscat strcat
|
||||||
|
#define _tcschr strchr
|
||||||
|
#define _tcsclen strlen
|
||||||
|
#define _tcscnlen strnlen
|
||||||
|
#define _tcscpy strcpy
|
||||||
|
#define _tcsdup _strdup
|
||||||
|
#define _tcslen strlen
|
||||||
|
#define _tcsnccpy strncpy
|
||||||
|
#define _tcsrchr strrchr
|
||||||
|
#define _tcsstr strstr
|
||||||
|
#define _tcstok strtok
|
||||||
|
|
||||||
|
// string comparisons
|
||||||
|
#define _tcscmp strcmp
|
||||||
|
#define _tcsicmp _stricmp
|
||||||
|
#define _tcsncmp strncmp
|
||||||
|
#define _tcsncicmp _strnicmp
|
||||||
|
#define _tcsnicmp _strnicmp
|
||||||
|
|
||||||
|
// upper / lower
|
||||||
|
#define _tcslwr _strlwr
|
||||||
|
#define _tcsupr _strupr
|
||||||
|
|
||||||
|
#define _totupper toupper
|
||||||
|
#define _totlower tolower
|
||||||
|
|
||||||
|
// conversions to numbers
|
||||||
|
#define _tcstol strtol
|
||||||
|
#define _tcstoul strtoul
|
||||||
|
#define _tstof atof
|
||||||
|
#define _tstoi atoi
|
||||||
|
#define _tstoi64 _atoi64
|
||||||
|
#define _tstoi64 _atoi64
|
||||||
|
#define _ttoi atoi
|
||||||
|
#define _ttoi64 _atoi64
|
||||||
|
#define _ttol atol
|
||||||
|
|
||||||
|
// conversion from numbers to strings
|
||||||
|
#define _i64tot _i64toa
|
||||||
|
#define _itot _itoa
|
||||||
|
#define _ltot _ltoa
|
||||||
|
#define _ui64tot _ui64toa
|
||||||
|
|
||||||
|
// file manipulations
|
||||||
|
#define _tfopen fopen
|
||||||
|
#define _topen _open
|
||||||
|
#define _tremove remove
|
||||||
|
#define _tunlink _unlink
|
||||||
|
|
||||||
|
// reading and writing to i/o
|
||||||
|
#define _fgettc fgetc
|
||||||
|
#define _fgetts fgets
|
||||||
|
#define _fputts fputs
|
||||||
|
#define _gettchar getchar
|
||||||
|
|
||||||
|
// directory
|
||||||
|
#define _tchdir _chdir
|
||||||
|
|
||||||
|
// environment
|
||||||
|
#define _tgetenv getenv
|
||||||
|
#define _tsystem system
|
||||||
|
|
||||||
|
// time
|
||||||
|
#define _tcsftime strftime
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// is functions (the same in Unicode / ANSI)
|
||||||
|
#define _istgraph isgraph
|
||||||
|
#define _istascii __isascii
|
||||||
|
|
||||||
|
#define __TFILE__ _T(__FILE__)
|
||||||
|
#define __TDATE__ _T(__DATE__)
|
||||||
|
#define __TTIME__ _T(__TIME__)
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
unsigned int g_stringsize;
|
unsigned int g_stringsize;
|
||||||
stack_t **g_stacktop;
|
stack_t **g_stacktop;
|
||||||
char *g_variables;
|
TCHAR *g_variables;
|
||||||
|
|
||||||
// utility functions (not required but often useful)
|
// utility functions (not required but often useful)
|
||||||
|
|
||||||
int NSISCALL popstring(char *str)
|
int NSISCALL popstring(TCHAR *str)
|
||||||
{
|
{
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
if (!g_stacktop || !*g_stacktop) return 1;
|
if (!g_stacktop || !*g_stacktop) return 1;
|
||||||
|
@ -19,7 +19,7 @@ int NSISCALL popstring(char *str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NSISCALL popstringn(char *str, int maxlen)
|
int NSISCALL popstringn(TCHAR *str, int maxlen)
|
||||||
{
|
{
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
if (!g_stacktop || !*g_stacktop) return 1;
|
if (!g_stacktop || !*g_stacktop) return 1;
|
||||||
|
@ -30,7 +30,7 @@ int NSISCALL popstringn(char *str, int maxlen)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSISCALL pushstring(const char *str)
|
void NSISCALL pushstring(const TCHAR *str)
|
||||||
{
|
{
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
if (!g_stacktop) return;
|
if (!g_stacktop) return;
|
||||||
|
@ -40,13 +40,13 @@ void NSISCALL pushstring(const char *str)
|
||||||
*g_stacktop=th;
|
*g_stacktop=th;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * NSISCALL getuservariable(const int varnum)
|
TCHAR * NSISCALL getuservariable(const int varnum)
|
||||||
{
|
{
|
||||||
if (varnum < 0 || varnum >= __INST_LAST) return NULL;
|
if (varnum < 0 || varnum >= __INST_LAST) return NULL;
|
||||||
return g_variables+varnum*g_stringsize;
|
return g_variables+varnum*g_stringsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSISCALL setuservariable(const int varnum, const char *var)
|
void NSISCALL setuservariable(const int varnum, const TCHAR *var)
|
||||||
{
|
{
|
||||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
|
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||||
lstrcpyA(g_variables + varnum*g_stringsize, var);
|
lstrcpyA(g_variables + varnum*g_stringsize, var);
|
||||||
|
@ -54,29 +54,29 @@ void NSISCALL setuservariable(const int varnum, const char *var)
|
||||||
|
|
||||||
// playing with integers
|
// playing with integers
|
||||||
|
|
||||||
int NSISCALL myatoi(const char *s)
|
int NSISCALL myatoi(const TCHAR *s)
|
||||||
{
|
{
|
||||||
int v=0;
|
int v=0;
|
||||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||||
else break;
|
else break;
|
||||||
v<<=4;
|
v<<=4;
|
||||||
v+=c;
|
v+=c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '7') c-='0';
|
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
|
||||||
else break;
|
else break;
|
||||||
v<<=3;
|
v<<=3;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -85,10 +85,10 @@ int NSISCALL myatoi(const char *s)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sign=0;
|
int sign=0;
|
||||||
if (*s == '-') sign++; else s--;
|
if (*s == _T('-')) sign++; else s--;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s) - '0';
|
int c=*(++s) - _T('0');
|
||||||
if (c < 0 || c > 9) break;
|
if (c < 0 || c > 9) break;
|
||||||
v*=10;
|
v*=10;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -99,14 +99,14 @@ int NSISCALL myatoi(const char *s)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned NSISCALL myatou(const char *s)
|
unsigned NSISCALL myatou(const TCHAR *s)
|
||||||
{
|
{
|
||||||
unsigned int v=0;
|
unsigned int v=0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
unsigned int c=*s++;
|
unsigned int c=*s++;
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||||
else break;
|
else break;
|
||||||
v*=10;
|
v*=10;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -114,29 +114,29 @@ unsigned NSISCALL myatou(const char *s)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NSISCALL myatoi_or(const char *s)
|
int NSISCALL myatoi_or(const TCHAR *s)
|
||||||
{
|
{
|
||||||
int v=0;
|
int v=0;
|
||||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||||
else break;
|
else break;
|
||||||
v<<=4;
|
v<<=4;
|
||||||
v+=c;
|
v+=c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '7') c-='0';
|
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
|
||||||
else break;
|
else break;
|
||||||
v<<=3;
|
v<<=3;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -145,10 +145,10 @@ int NSISCALL myatoi_or(const char *s)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sign=0;
|
int sign=0;
|
||||||
if (*s == '-') sign++; else s--;
|
if (*s == _T('-')) sign++; else s--;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s) - '0';
|
int c=*(++s) - _T('0');
|
||||||
if (c < 0 || c > 9) break;
|
if (c < 0 || c > 9) break;
|
||||||
v*=10;
|
v*=10;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -157,7 +157,7 @@ int NSISCALL myatoi_or(const char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support for simple ORed expressions
|
// Support for simple ORed expressions
|
||||||
if (*s == '|')
|
if (*s == _T('|'))
|
||||||
{
|
{
|
||||||
v |= myatoi_or(s+1);
|
v |= myatoi_or(s+1);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ int NSISCALL myatoi_or(const char *s)
|
||||||
|
|
||||||
int NSISCALL popint()
|
int NSISCALL popint()
|
||||||
{
|
{
|
||||||
char buf[128];
|
TCHAR buf[128];
|
||||||
if (popstringn(buf,sizeof(buf)))
|
if (popstringn(buf,sizeof(buf)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ int NSISCALL popint()
|
||||||
|
|
||||||
int NSISCALL popint_or()
|
int NSISCALL popint_or()
|
||||||
{
|
{
|
||||||
char buf[128];
|
TCHAR buf[128];
|
||||||
if (popstringn(buf,sizeof(buf)))
|
if (popstringn(buf,sizeof(buf)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ int NSISCALL popint_or()
|
||||||
|
|
||||||
void NSISCALL pushint(int value)
|
void NSISCALL pushint(int value)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
TCHAR buffer[1024];
|
||||||
wsprintf(buffer, "%d", value);
|
wsprintf(buffer, _T("%d"), value);
|
||||||
pushstring(buffer);
|
pushstring(buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
#include "nsis_tchar.h"
|
||||||
|
|
||||||
#ifndef NSISCALL
|
#ifndef NSISCALL
|
||||||
# define NSISCALL __stdcall
|
# define NSISCALL __stdcall
|
||||||
|
@ -18,7 +19,7 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct _stack_t {
|
typedef struct _stack_t {
|
||||||
struct _stack_t *next;
|
struct _stack_t *next;
|
||||||
char text[1]; // this should be the length of string_size
|
TCHAR text[1]; // this should be the length of string_size
|
||||||
} stack_t;
|
} stack_t;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -53,19 +54,25 @@ __INST_LAST
|
||||||
|
|
||||||
extern unsigned int g_stringsize;
|
extern unsigned int g_stringsize;
|
||||||
extern stack_t **g_stacktop;
|
extern stack_t **g_stacktop;
|
||||||
extern char *g_variables;
|
extern TCHAR *g_variables;
|
||||||
|
|
||||||
int NSISCALL popstring(char *str); // 0 on success, 1 on empty stack
|
int NSISCALL popstring(TCHAR *str); // 0 on success, 1 on empty stack
|
||||||
int NSISCALL popstringn(char *str, int maxlen); // with length limit, pass 0 for g_stringsize
|
int NSISCALL popstringn(TCHAR *str, int maxlen); // with length limit, pass 0 for g_stringsize
|
||||||
int NSISCALL popint(); // pops an integer
|
int NSISCALL popint(); // pops an integer
|
||||||
int NSISCALL popint_or(); // with support for or'ing (2|4|8)
|
int NSISCALL popint_or(); // with support for or'ing (2|4|8)
|
||||||
int NSISCALL myatoi(const char *s); // converts a string to an integer
|
int NSISCALL myatoi(const TCHAR *s); // converts a string to an integer
|
||||||
unsigned NSISCALL myatou(const char *s); // converts a string to an unsigned integer, decimal only
|
unsigned NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only
|
||||||
int NSISCALL myatoi_or(const char *s); // with support for or'ing (2|4|8)
|
int NSISCALL myatoi_or(const TCHAR *s); // with support for or'ing (2|4|8)
|
||||||
void NSISCALL pushstring(const char *str);
|
void NSISCALL pushstring(const TCHAR *str);
|
||||||
void NSISCALL pushint(int value);
|
void NSISCALL pushint(int value);
|
||||||
char * NSISCALL getuservariable(const int varnum);
|
TCHAR * NSISCALL getuservariable(const int varnum);
|
||||||
void NSISCALL setuservariable(const int varnum, const char *var);
|
void NSISCALL setuservariable(const int varnum, const TCHAR *var);
|
||||||
|
|
||||||
|
// ANSI defs
|
||||||
|
|
||||||
|
#define PopStringA(x) popstring(x)
|
||||||
|
#define PushStringA(x) pushstring(x)
|
||||||
|
#define SetUserVariableA(x,y) setuservariable(x,y)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
*
|
*
|
||||||
* See Readme.html for documentation and license
|
* See Readme.html for documentation and license
|
||||||
*
|
*
|
||||||
|
* Unicode support by Jim Park -- 08/01/2007
|
||||||
|
*
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -34,9 +36,9 @@ void WINAPI FREE(void *d) { if (d) GlobalFree((HGLOBAL)d); }
|
||||||
#define stricmp(x,y) lstrcmpi(x,y)
|
#define stricmp(x,y) lstrcmpi(x,y)
|
||||||
//#define abs(x) ((x) < 0 ? -(x) : (x))
|
//#define abs(x) ((x) < 0 ? -(x) : (x))
|
||||||
|
|
||||||
char *WINAPI STRDUP(const char *c)
|
TCHAR *WINAPI STRDUP(const TCHAR *c)
|
||||||
{
|
{
|
||||||
char *t=(char*)MALLOC(lstrlen(c)+1);
|
TCHAR *t=(TCHAR*)MALLOC((lstrlen(c)+1)*sizeof(TCHAR));
|
||||||
return lstrcpy(t,c);
|
return lstrcpy(t,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,27 +113,27 @@ char *WINAPI STRDUP(const char *c)
|
||||||
#define FLAG_FOCUS 0x10000000 // Controls that can receive focus
|
#define FLAG_FOCUS 0x10000000 // Controls that can receive focus
|
||||||
|
|
||||||
struct TableEntry {
|
struct TableEntry {
|
||||||
char *pszName;
|
TCHAR *pszName;
|
||||||
int nValue;
|
int nValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
int WINAPI LookupToken(TableEntry*, char*);
|
int WINAPI LookupToken(TableEntry*, TCHAR*);
|
||||||
int WINAPI LookupTokens(TableEntry*, char*);
|
int WINAPI LookupTokens(TableEntry*, TCHAR*);
|
||||||
|
|
||||||
void WINAPI ConvertNewLines(char *str);
|
void WINAPI ConvertNewLines(TCHAR *str);
|
||||||
|
|
||||||
// all allocated buffers must be first in the struct
|
// all allocated buffers must be first in the struct
|
||||||
// when adding more allocated buffers to FieldType, don't forget to change this define
|
// when adding more allocated buffers to FieldType, don't forget to change this define
|
||||||
#define FIELD_BUFFERS 6
|
#define FIELD_BUFFERS 6
|
||||||
struct FieldType {
|
struct FieldType {
|
||||||
char *pszText;
|
TCHAR *pszText;
|
||||||
char *pszState;
|
TCHAR *pszState;
|
||||||
char *pszRoot;
|
TCHAR *pszRoot;
|
||||||
|
|
||||||
char *pszListItems;
|
TCHAR *pszListItems;
|
||||||
char *pszFilter;
|
TCHAR *pszFilter;
|
||||||
|
|
||||||
char *pszValidateText;
|
TCHAR *pszValidateText;
|
||||||
int nMinLength;
|
int nMinLength;
|
||||||
int nMaxLength;
|
int nMaxLength;
|
||||||
|
|
||||||
|
@ -147,7 +149,7 @@ struct FieldType {
|
||||||
HANDLE hImage; // this is used by image/icon field to save the handle to the image
|
HANDLE hImage; // this is used by image/icon field to save the handle to the image
|
||||||
|
|
||||||
int nField; // field number in INI file
|
int nField; // field number in INI file
|
||||||
char *pszHwndEntry; // "HWND" or "HWND2"
|
TCHAR *pszHwndEntry; // "HWND" or "HWND2"
|
||||||
|
|
||||||
long wndProc;
|
long wndProc;
|
||||||
};
|
};
|
||||||
|
@ -156,7 +158,7 @@ struct FieldType {
|
||||||
// use a value larger than MAX_PATH to prevent need for excessive growing.
|
// use a value larger than MAX_PATH to prevent need for excessive growing.
|
||||||
#define BUFFER_SIZE 8192 // 8kb of mem is max char count in multiedit
|
#define BUFFER_SIZE 8192 // 8kb of mem is max char count in multiedit
|
||||||
|
|
||||||
char szBrowseButtonCaption[] = "...";
|
TCHAR szBrowseButtonCaption[] = _T("...");
|
||||||
|
|
||||||
HWND hConfigWindow = NULL;
|
HWND hConfigWindow = NULL;
|
||||||
HWND hMainWindow = NULL;
|
HWND hMainWindow = NULL;
|
||||||
|
@ -168,11 +170,11 @@ HINSTANCE m_hInstance = NULL;
|
||||||
|
|
||||||
struct _stack_t *pFilenameStackEntry = NULL;
|
struct _stack_t *pFilenameStackEntry = NULL;
|
||||||
|
|
||||||
char *pszFilename = NULL;
|
TCHAR *pszFilename = NULL;
|
||||||
char *pszTitle = NULL;
|
TCHAR *pszTitle = NULL;
|
||||||
char *pszCancelButtonText = NULL;
|
TCHAR *pszCancelButtonText = NULL;
|
||||||
char *pszNextButtonText = NULL;
|
TCHAR *pszNextButtonText = NULL;
|
||||||
char *pszBackButtonText = NULL;
|
TCHAR *pszBackButtonText = NULL;
|
||||||
|
|
||||||
int bBackEnabled = FALSE;
|
int bBackEnabled = FALSE;
|
||||||
int bCancelEnabled = FALSE; // by ORTIM: 13-August-2002
|
int bCancelEnabled = FALSE; // by ORTIM: 13-August-2002
|
||||||
|
@ -237,8 +239,8 @@ bool INLINE ValidateFields() {
|
||||||
if (((pField->nMaxLength > 0) && (nLength > pField->nMaxLength)) ||
|
if (((pField->nMaxLength > 0) && (nLength > pField->nMaxLength)) ||
|
||||||
((pField->nMinLength > 0) && (nLength < pField->nMinLength))) {
|
((pField->nMinLength > 0) && (nLength < pField->nMinLength))) {
|
||||||
if (pField->pszValidateText) {
|
if (pField->pszValidateText) {
|
||||||
char szTitle[1024];
|
TCHAR szTitle[1024];
|
||||||
GetWindowText(hMainWindow, szTitle, sizeof(szTitle));
|
GetWindowText(hMainWindow, szTitle, _countof(szTitle));
|
||||||
MessageBox(hConfigWindow, pField->pszValidateText, szTitle, MB_OK|MB_ICONWARNING);
|
MessageBox(hConfigWindow, pField->pszValidateText, szTitle, MB_OK|MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
mySetFocus(pField->hwnd);
|
mySetFocus(pField->hwnd);
|
||||||
|
@ -251,9 +253,9 @@ bool INLINE ValidateFields() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WINAPI SaveSettings(void) {
|
bool WINAPI SaveSettings(void) {
|
||||||
static char szField[25];
|
static TCHAR szField[25];
|
||||||
int nBufLen = BUFFER_SIZE;
|
int nBufLen = BUFFER_SIZE;
|
||||||
char *pszBuffer = (char*)MALLOC(nBufLen);
|
TCHAR *pszBuffer = (TCHAR*)MALLOC(nBufLen*sizeof(TCHAR));
|
||||||
if (!pszBuffer) return false;
|
if (!pszBuffer) return false;
|
||||||
|
|
||||||
int nIdx;
|
int nIdx;
|
||||||
|
@ -271,7 +273,7 @@ bool WINAPI SaveSettings(void) {
|
||||||
|
|
||||||
case FIELD_CHECKBOX:
|
case FIELD_CHECKBOX:
|
||||||
case FIELD_RADIOBUTTON:
|
case FIELD_RADIOBUTTON:
|
||||||
wsprintf(pszBuffer, "%d", !!mySendMessage(hwnd, BM_GETCHECK, 0, 0));
|
wsprintf(pszBuffer, _T("%d"), !!mySendMessage(hwnd, BM_GETCHECK, 0, 0));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIELD_LISTBOX:
|
case FIELD_LISTBOX:
|
||||||
|
@ -285,17 +287,17 @@ bool WINAPI SaveSettings(void) {
|
||||||
if (nLength > nBufLen) {
|
if (nLength > nBufLen) {
|
||||||
FREE(pszBuffer);
|
FREE(pszBuffer);
|
||||||
nBufLen = nLength;
|
nBufLen = nLength;
|
||||||
pszBuffer = (char*)MALLOC(nBufLen);
|
pszBuffer = (TCHAR*)MALLOC(nBufLen*sizeof(TCHAR));
|
||||||
if (!pszBuffer) return false;
|
if (!pszBuffer) return false;
|
||||||
}
|
}
|
||||||
char *pszItem = (char*)MALLOC(nBufLen);
|
TCHAR *pszItem = (TCHAR*)MALLOC(nBufLen*sizeof(TCHAR));
|
||||||
if (!pszItem) return false;
|
if (!pszItem) return false;
|
||||||
|
|
||||||
*pszBuffer = '\0';
|
*pszBuffer = _T('\0');
|
||||||
int nNumItems = mySendMessage(hwnd, LB_GETCOUNT, 0, 0);
|
int nNumItems = mySendMessage(hwnd, LB_GETCOUNT, 0, 0);
|
||||||
for (int nIdx2 = 0; nIdx2 < nNumItems; nIdx2++) {
|
for (int nIdx2 = 0; nIdx2 < nNumItems; nIdx2++) {
|
||||||
if (mySendMessage(hwnd, LB_GETSEL, nIdx2, 0) > 0) {
|
if (mySendMessage(hwnd, LB_GETSEL, nIdx2, 0) > 0) {
|
||||||
if (*pszBuffer) lstrcat(pszBuffer, "|");
|
if (*pszBuffer) lstrcat(pszBuffer, _T("|"));
|
||||||
mySendMessage(hwnd, LB_GETTEXT, (WPARAM)nIdx2, (LPARAM)pszItem);
|
mySendMessage(hwnd, LB_GETTEXT, (WPARAM)nIdx2, (LPARAM)pszItem);
|
||||||
lstrcat(pszBuffer, pszItem);
|
lstrcat(pszBuffer, pszItem);
|
||||||
}
|
}
|
||||||
|
@ -315,35 +317,38 @@ bool WINAPI SaveSettings(void) {
|
||||||
FREE(pszBuffer);
|
FREE(pszBuffer);
|
||||||
// add a bit extra so we do this less often
|
// add a bit extra so we do this less often
|
||||||
nBufLen = nLength + 20;
|
nBufLen = nLength + 20;
|
||||||
pszBuffer = (char*)MALLOC(nBufLen);
|
pszBuffer = (TCHAR*)MALLOC(nBufLen*sizeof(TCHAR));
|
||||||
if (!pszBuffer) return false;
|
if (!pszBuffer) return false;
|
||||||
}
|
}
|
||||||
*pszBuffer='"';
|
*pszBuffer=_T('"');
|
||||||
GetWindowText(hwnd, pszBuffer+1, nBufLen-1);
|
GetWindowText(hwnd, pszBuffer+1, nBufLen-1);
|
||||||
pszBuffer[nLength+1]='"';
|
pszBuffer[nLength+1]=_T('"');
|
||||||
pszBuffer[nLength+2]='\0';
|
pszBuffer[nLength+2]=_T('\0');
|
||||||
|
|
||||||
if (pField->nType == FIELD_TEXT && (pField->nFlags & FLAG_MULTILINE))
|
if (pField->nType == FIELD_TEXT && (pField->nFlags & FLAG_MULTILINE))
|
||||||
{
|
{
|
||||||
char *pszBuf2 = (char*)MALLOC(nBufLen*2); // double the size, consider the worst case, all chars are \r\n
|
TCHAR *pszBuf2 = (TCHAR*)MALLOC(nBufLen*2*sizeof(TCHAR)); // double the size, consider the worst case, all chars are \r\n
|
||||||
char *p1, *p2;
|
TCHAR *p1, *p2;
|
||||||
for (p1 = pszBuffer, p2 = pszBuf2; *p1; p1 = CharNext(p1), p2 = CharNext(p2))
|
for (p1 = pszBuffer, p2 = pszBuf2; *p1; p1 = CharNext(p1), p2 = CharNext(p2))
|
||||||
{
|
{
|
||||||
switch (*p1) {
|
switch (*p1) {
|
||||||
case '\t':
|
case _T('\t'):
|
||||||
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 't');
|
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 't');
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case _T('\n'):
|
||||||
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 'n');
|
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 'n');
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
case '\r':
|
case _T('\r'):
|
||||||
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 'r');
|
*(LPWORD)p2 = CHAR2_TO_WORD('\\', 'r');
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case _T('\\'):
|
||||||
*p2++ = '\\';
|
*p2++ = '\\';
|
||||||
|
// Jim Park: used to be p2++ but that's a bug that works because
|
||||||
|
// CharNext()'s behavior at terminating null char. But still
|
||||||
|
// definitely, unsafe.
|
||||||
default:
|
default:
|
||||||
lstrcpyn(p2, p1, CharNext(p1) - p1 + 1);
|
lstrcpyn(p2, p1, CharNext(p1) - p1 + 1);
|
||||||
break;
|
break;
|
||||||
|
@ -357,13 +362,13 @@ bool WINAPI SaveSettings(void) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wsprintf(szField, "Field %d", CurrField);
|
wsprintf(szField, _T("Field %d"), CurrField);
|
||||||
WritePrivateProfileString(szField, "State", pszBuffer, pszFilename);
|
WritePrivateProfileString(szField, _T("State"), pszBuffer, pszFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell NSIS which control was activated, if any
|
// Tell NSIS which control was activated, if any
|
||||||
wsprintf(pszBuffer, "%d", g_NotifyField);
|
wsprintf(pszBuffer, _T("%d"), g_NotifyField);
|
||||||
WritePrivateProfileString("Settings", "State", pszBuffer, pszFilename);
|
WritePrivateProfileString(_T("Settings"), _T("State"), pszBuffer, pszFilename);
|
||||||
|
|
||||||
FREE(pszBuffer);
|
FREE(pszBuffer);
|
||||||
|
|
||||||
|
@ -372,20 +377,20 @@ bool WINAPI SaveSettings(void) {
|
||||||
|
|
||||||
#define BROWSE_WIDTH 15
|
#define BROWSE_WIDTH 15
|
||||||
|
|
||||||
static char szResult[BUFFER_SIZE];
|
static TCHAR szResult[BUFFER_SIZE];
|
||||||
char *pszAppName;
|
TCHAR *pszAppName;
|
||||||
|
|
||||||
DWORD WINAPI myGetProfileString(LPCTSTR lpKeyName)
|
DWORD WINAPI myGetProfileString(LPCTSTR lpKeyName)
|
||||||
{
|
{
|
||||||
*szResult = '\0';
|
*szResult = _T('\0');
|
||||||
return GetPrivateProfileString(pszAppName, lpKeyName, "", szResult, BUFFER_SIZE, pszFilename);
|
return GetPrivateProfileString(pszAppName, lpKeyName, _T(""), szResult, BUFFER_SIZE, pszFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
char * WINAPI myGetProfileStringDup(LPCTSTR lpKeyName)
|
TCHAR * WINAPI myGetProfileStringDup(LPCTSTR lpKeyName)
|
||||||
{
|
{
|
||||||
int nSize = myGetProfileString(lpKeyName);
|
int nSize = myGetProfileString(lpKeyName);
|
||||||
if (nSize)
|
if (nSize)
|
||||||
return strdup(szResult);
|
return strdup(szResult); // uses STRDUP
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -396,25 +401,25 @@ UINT WINAPI myGetProfileInt(LPCTSTR lpKeyName, INT nDefault)
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI ReadSettings(void) {
|
int WINAPI ReadSettings(void) {
|
||||||
static char szField[25];
|
static TCHAR szField[25];
|
||||||
int nIdx, nCtrlIdx;
|
int nIdx, nCtrlIdx;
|
||||||
|
|
||||||
pszAppName = "Settings";
|
pszAppName = _T("Settings");
|
||||||
pszTitle = myGetProfileStringDup("Title");
|
pszTitle = myGetProfileStringDup(_T("Title"));
|
||||||
pszCancelButtonText = myGetProfileStringDup("CancelButtonText");
|
pszCancelButtonText = myGetProfileStringDup(_T("CancelButtonText"));
|
||||||
pszNextButtonText = myGetProfileStringDup("NextButtonText");
|
pszNextButtonText = myGetProfileStringDup(_T("NextButtonText"));
|
||||||
pszBackButtonText = myGetProfileStringDup("BackButtonText");
|
pszBackButtonText = myGetProfileStringDup(_T("BackButtonText"));
|
||||||
|
|
||||||
nNumFields = myGetProfileInt("NumFields", 0);
|
nNumFields = myGetProfileInt(_T("NumFields"), 0);
|
||||||
|
|
||||||
nRectId = myGetProfileInt("Rect", DEFAULT_RECT);
|
nRectId = myGetProfileInt(_T("Rect"), DEFAULT_RECT);
|
||||||
|
|
||||||
bBackEnabled = myGetProfileInt("BackEnabled", -1);
|
bBackEnabled = myGetProfileInt(_T("BackEnabled"), -1);
|
||||||
// by ORTIM: 13-August-2002
|
// by ORTIM: 13-August-2002
|
||||||
bCancelEnabled = myGetProfileInt("CancelEnabled", -1);
|
bCancelEnabled = myGetProfileInt(_T("CancelEnabled"), -1);
|
||||||
bCancelShow = myGetProfileInt("CancelShow", -1);
|
bCancelShow = myGetProfileInt(_T("CancelShow"), -1);
|
||||||
|
|
||||||
bRTL = myGetProfileInt("RTL", 0);
|
bRTL = myGetProfileInt(_T("RTL"), 0);
|
||||||
|
|
||||||
if (nNumFields > 0) {
|
if (nNumFields > 0) {
|
||||||
// make this twice as large for the worst case that every control is a browse button.
|
// make this twice as large for the worst case that every control is a browse button.
|
||||||
|
@ -426,117 +431,117 @@ int WINAPI ReadSettings(void) {
|
||||||
for (nIdx = 0, nCtrlIdx = 0; nCtrlIdx < nNumFields; nCtrlIdx++, nIdx++) {
|
for (nIdx = 0, nCtrlIdx = 0; nCtrlIdx < nNumFields; nCtrlIdx++, nIdx++) {
|
||||||
// Control types
|
// Control types
|
||||||
static TableEntry TypeTable[] = {
|
static TableEntry TypeTable[] = {
|
||||||
{ "LABEL", FIELD_LABEL },
|
{ _T("LABEL"), FIELD_LABEL },
|
||||||
{ "TEXT", FIELD_TEXT },
|
{ _T("TEXT"), FIELD_TEXT },
|
||||||
{ "PASSWORD", FIELD_TEXT },
|
{ _T("PASSWORD"), FIELD_TEXT },
|
||||||
{ "LISTBOX", FIELD_LISTBOX },
|
{ _T("LISTBOX"), FIELD_LISTBOX },
|
||||||
{ "COMBOBOX", FIELD_COMBOBOX },
|
{ _T("COMBOBOX"), FIELD_COMBOBOX },
|
||||||
{ "DROPLIST", FIELD_COMBOBOX },
|
{ _T("DROPLIST"), FIELD_COMBOBOX },
|
||||||
{ "FILEREQUEST", FIELD_FILEREQUEST },
|
{ _T("FILEREQUEST"), FIELD_FILEREQUEST },
|
||||||
{ "DIRREQUEST", FIELD_DIRREQUEST },
|
{ _T("DIRREQUEST"), FIELD_DIRREQUEST },
|
||||||
{ "CHECKBOX", FIELD_CHECKBOX },
|
{ _T("CHECKBOX"), FIELD_CHECKBOX },
|
||||||
{ "RADIOBUTTON", FIELD_RADIOBUTTON },
|
{ _T("RADIOBUTTON"), FIELD_RADIOBUTTON },
|
||||||
{ "ICON", FIELD_ICON },
|
{ _T("ICON"), FIELD_ICON },
|
||||||
{ "BITMAP", FIELD_BITMAP },
|
{ _T("BITMAP"), FIELD_BITMAP },
|
||||||
{ "GROUPBOX", FIELD_GROUPBOX },
|
{ _T("GROUPBOX"), FIELD_GROUPBOX },
|
||||||
#ifdef IO_ENABLE_LINK
|
#ifdef IO_ENABLE_LINK
|
||||||
{ "LINK", FIELD_LINK },
|
{ _T("LINK"), FIELD_LINK },
|
||||||
#else
|
#else
|
||||||
{ "LINK", FIELD_LABEL },
|
{ _T("LINK"), FIELD_LABEL },
|
||||||
#endif
|
#endif
|
||||||
{ "BUTTON", FIELD_BUTTON },
|
{ _T("BUTTON"), FIELD_BUTTON },
|
||||||
{ "HLINE", FIELD_HLINE },
|
{ _T("HLINE"), FIELD_HLINE },
|
||||||
{ "VLINE", FIELD_VLINE },
|
{ _T("VLINE"), FIELD_VLINE },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
// Control flags
|
// Control flags
|
||||||
static TableEntry FlagTable[] = {
|
static TableEntry FlagTable[] = {
|
||||||
{ "NOTIFY", LBS_NOTIFY },
|
{ _T("NOTIFY"), LBS_NOTIFY },
|
||||||
{ "WARN_IF_EXIST", OFN_OVERWRITEPROMPT },
|
{ _T("WARN_IF_EXIST"), OFN_OVERWRITEPROMPT },
|
||||||
{ "FILE_HIDEREADONLY", OFN_HIDEREADONLY },
|
{ _T("FILE_HIDEREADONLY"), OFN_HIDEREADONLY },
|
||||||
{ "MULTISELECT", LBS_MULTIPLESEL },
|
{ _T("MULTISELECT"), LBS_MULTIPLESEL },
|
||||||
{ "READONLY", FLAG_READONLY },
|
{ _T("READONLY"), FLAG_READONLY },
|
||||||
{ "RIGHT", BS_LEFTTEXT },
|
{ _T("RIGHT"), BS_LEFTTEXT },
|
||||||
{ "PASSWORD", FLAG_PASSWORD },
|
{ _T("PASSWORD"), FLAG_PASSWORD },
|
||||||
{ "ONLY_NUMBERS", FLAG_ONLYNUMBERS },
|
{ _T("ONLY_NUMBERS"), FLAG_ONLYNUMBERS },
|
||||||
{ "MULTILINE", FLAG_MULTILINE },
|
{ _T("MULTILINE"), FLAG_MULTILINE },
|
||||||
{ "NOWORDWRAP", FLAG_NOWORDWRAP },
|
{ _T("NOWORDWRAP"), FLAG_NOWORDWRAP },
|
||||||
{ "WANTRETURN", FLAG_WANTRETURN },
|
{ _T("WANTRETURN"), FLAG_WANTRETURN },
|
||||||
{ "EXTENDEDSELCT", LBS_EXTENDEDSEL },
|
{ _T("EXTENDEDSELCT"), LBS_EXTENDEDSEL },
|
||||||
{ "PATH_MUST_EXIST", OFN_PATHMUSTEXIST },
|
{ _T("PATH_MUST_EXIST"), OFN_PATHMUSTEXIST },
|
||||||
{ "FILE_MUST_EXIST", OFN_FILEMUSTEXIST },
|
{ _T("FILE_MUST_EXIST"), OFN_FILEMUSTEXIST },
|
||||||
{ "PROMPT_CREATE", OFN_CREATEPROMPT },
|
{ _T("PROMPT_CREATE"), OFN_CREATEPROMPT },
|
||||||
{ "DROPLIST", FLAG_DROPLIST },
|
{ _T("DROPLIST"), FLAG_DROPLIST },
|
||||||
{ "RESIZETOFIT", FLAG_RESIZETOFIT },
|
{ _T("RESIZETOFIT"), FLAG_RESIZETOFIT },
|
||||||
{ "NOTABSTOP", WS_TABSTOP },
|
{ _T("NOTABSTOP"), WS_TABSTOP },
|
||||||
{ "GROUP", WS_GROUP },
|
{ _T("GROUP"), WS_GROUP },
|
||||||
{ "REQ_SAVE", FLAG_SAVEAS },
|
{ _T("REQ_SAVE"), FLAG_SAVEAS },
|
||||||
{ "FILE_EXPLORER", OFN_EXPLORER },
|
{ _T("FILE_EXPLORER"), OFN_EXPLORER },
|
||||||
{ "HSCROLL", WS_HSCROLL },
|
{ _T("HSCROLL"), WS_HSCROLL },
|
||||||
{ "VSCROLL", WS_VSCROLL },
|
{ _T("VSCROLL"), WS_VSCROLL },
|
||||||
{ "DISABLED", WS_DISABLED },
|
{ _T("DISABLED"), WS_DISABLED },
|
||||||
{ "TRANSPARENT", TRANSPARENT_BMP },
|
{ _T("TRANSPARENT"), TRANSPARENT_BMP },
|
||||||
{ "FOCUS", FLAG_FOCUS },
|
{ _T("FOCUS"), FLAG_FOCUS },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
FieldType *pField = pFields + nIdx;
|
FieldType *pField = pFields + nIdx;
|
||||||
|
|
||||||
pField->nField = nCtrlIdx + 1;
|
pField->nField = nCtrlIdx + 1;
|
||||||
pField->pszHwndEntry = "HWND";
|
pField->pszHwndEntry = _T("HWND");
|
||||||
|
|
||||||
wsprintf(szField, "Field %d", nCtrlIdx + 1);
|
wsprintf(szField, _T("Field %d"), nCtrlIdx + 1);
|
||||||
pszAppName = szField;
|
pszAppName = szField;
|
||||||
|
|
||||||
// Get the control type
|
// Get the control type
|
||||||
myGetProfileString("TYPE");
|
myGetProfileString(_T("TYPE"));
|
||||||
pField->nType = LookupToken(TypeTable, szResult);
|
pField->nType = LookupToken(TypeTable, szResult);
|
||||||
if (pField->nType == FIELD_INVALID)
|
if (pField->nType == FIELD_INVALID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Lookup flags associated with the control type
|
// Lookup flags associated with the control type
|
||||||
pField->nFlags = LookupToken(FlagTable, szResult);
|
pField->nFlags = LookupToken(FlagTable, szResult);
|
||||||
myGetProfileString("Flags");
|
myGetProfileString(_T("Flags"));
|
||||||
pField->nFlags |= LookupTokens(FlagTable, szResult);
|
pField->nFlags |= LookupTokens(FlagTable, szResult);
|
||||||
|
|
||||||
// pszState must not be NULL!
|
// pszState must not be NULL!
|
||||||
myGetProfileString("State");
|
myGetProfileString(_T("State"));
|
||||||
pField->pszState = strdup(szResult);
|
pField->pszState = strdup(szResult); // uses STRDUP
|
||||||
|
|
||||||
// ListBox items list
|
// ListBox items list
|
||||||
{
|
{
|
||||||
int nResult = myGetProfileString("ListItems");
|
int nResult = myGetProfileString(_T("ListItems"));
|
||||||
if (nResult) {
|
if (nResult) {
|
||||||
// add an extra | character to the end to simplify the loop where we add the items.
|
// add an extra | character to the end to simplify the loop where we add the items.
|
||||||
pField->pszListItems = (char*)MALLOC(nResult + 2);
|
pField->pszListItems = (TCHAR*)MALLOC((nResult + 2)*sizeof(TCHAR));
|
||||||
strcpy(pField->pszListItems, szResult);
|
lstrcpy(pField->pszListItems, szResult);
|
||||||
pField->pszListItems[nResult] = '|';
|
pField->pszListItems[nResult] = _T('|');
|
||||||
pField->pszListItems[nResult + 1] = '\0';
|
pField->pszListItems[nResult + 1] = _T('\0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label Text - convert newline
|
// Label Text - convert newline
|
||||||
pField->pszText = myGetProfileStringDup("TEXT");
|
pField->pszText = myGetProfileStringDup(_T("TEXT"));
|
||||||
if (pField->nType == FIELD_LABEL || pField->nType == FIELD_LINK)
|
if (pField->nType == FIELD_LABEL || pField->nType == FIELD_LINK)
|
||||||
ConvertNewLines(pField->pszText);
|
ConvertNewLines(pField->pszText);
|
||||||
|
|
||||||
// Dir request - root folder
|
// Dir request - root folder
|
||||||
pField->pszRoot = myGetProfileStringDup("ROOT");
|
pField->pszRoot = myGetProfileStringDup(_T("ROOT"));
|
||||||
|
|
||||||
// ValidateText - convert newline
|
// ValidateText - convert newline
|
||||||
pField->pszValidateText = myGetProfileStringDup("ValidateText");
|
pField->pszValidateText = myGetProfileStringDup(_T("ValidateText"));
|
||||||
ConvertNewLines(pField->pszValidateText);
|
ConvertNewLines(pField->pszValidateText);
|
||||||
|
|
||||||
{
|
{
|
||||||
int nResult = GetPrivateProfileString(szField, "Filter", "All Files|*.*", szResult, sizeof(szResult), pszFilename);
|
int nResult = GetPrivateProfileString(szField, _T("Filter"), _T("All Files|*.*"), szResult, _countof(szResult), pszFilename);
|
||||||
if (nResult) {
|
if (nResult) {
|
||||||
// Convert the filter to the format required by Windows: NULL after each
|
// Convert the filter to the format required by Windows: NULL after each
|
||||||
// item followed by a terminating NULL
|
// item followed by a terminating NULL
|
||||||
pField->pszFilter = (char*)MALLOC(nResult + 2);
|
pField->pszFilter = (TCHAR*)MALLOC((nResult + 2)*sizeof(TCHAR));
|
||||||
strcpy(pField->pszFilter, szResult);
|
lstrcpy(pField->pszFilter, szResult);
|
||||||
char *pszPos = pField->pszFilter;
|
TCHAR *pszPos = pField->pszFilter;
|
||||||
while (*pszPos)
|
while (*pszPos)
|
||||||
{
|
{
|
||||||
if (*pszPos == '|')
|
if (*pszPos == _T('|'))
|
||||||
*pszPos++ = 0;
|
*pszPos++ = 0;
|
||||||
else
|
else
|
||||||
pszPos = CharNext(pszPos);
|
pszPos = CharNext(pszPos);
|
||||||
|
@ -544,15 +549,15 @@ int WINAPI ReadSettings(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pField->rect.left = myGetProfileInt("LEFT", 0);
|
pField->rect.left = myGetProfileInt(_T("LEFT"), 0);
|
||||||
pField->rect.top = myGetProfileInt("TOP", 0);
|
pField->rect.top = myGetProfileInt(_T("TOP"), 0);
|
||||||
pField->rect.right = myGetProfileInt("RIGHT", 0);
|
pField->rect.right = myGetProfileInt(_T("RIGHT"), 0);
|
||||||
pField->rect.bottom = myGetProfileInt("BOTTOM", 0);
|
pField->rect.bottom = myGetProfileInt(_T("BOTTOM"), 0);
|
||||||
pField->nMinLength = myGetProfileInt("MinLen", 0);
|
pField->nMinLength = myGetProfileInt(_T("MinLen"), 0);
|
||||||
pField->nMaxLength = myGetProfileInt("MaxLen", 0);
|
pField->nMaxLength = myGetProfileInt(_T("MaxLen"), 0);
|
||||||
|
|
||||||
// Text color for LINK control, default is pure blue
|
// Text color for LINK control, default is pure blue
|
||||||
pField->hImage = (HANDLE)myGetProfileInt("TxtColor", RGB(0,0,255));
|
pField->hImage = (HANDLE)myGetProfileInt(_T("TxtColor"), RGB(0,0,255));
|
||||||
|
|
||||||
pField->nControlID = 1200 + nIdx;
|
pField->nControlID = 1200 + nIdx;
|
||||||
if (pField->nType == FIELD_FILEREQUEST || pField->nType == FIELD_DIRREQUEST)
|
if (pField->nType == FIELD_FILEREQUEST || pField->nType == FIELD_DIRREQUEST)
|
||||||
|
@ -568,7 +573,7 @@ int WINAPI ReadSettings(void) {
|
||||||
pNewField->rect.top = pField->rect.top;
|
pNewField->rect.top = pField->rect.top;
|
||||||
pField->rect.right = pNewField->rect.left - 3;
|
pField->rect.right = pNewField->rect.left - 3;
|
||||||
pNewField->nField = nCtrlIdx + 1;
|
pNewField->nField = nCtrlIdx + 1;
|
||||||
pNewField->pszHwndEntry = "HWND2";
|
pNewField->pszHwndEntry = _T("HWND2");
|
||||||
nNumFields++;
|
nNumFields++;
|
||||||
nIdx++;
|
nIdx++;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +610,7 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify)
|
||||||
|
|
||||||
FieldType *pField = pFields + nIdx;
|
FieldType *pField = pFields + nIdx;
|
||||||
|
|
||||||
char szBrowsePath[MAX_PATH];
|
TCHAR szBrowsePath[MAX_PATH];
|
||||||
|
|
||||||
switch (pField->nType) {
|
switch (pField->nType) {
|
||||||
case FIELD_FILEREQUEST: {
|
case FIELD_FILEREQUEST: {
|
||||||
|
@ -615,10 +620,10 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify)
|
||||||
ofn.hwndOwner = hConfigWindow;
|
ofn.hwndOwner = hConfigWindow;
|
||||||
ofn.lpstrFilter = pField->pszFilter;
|
ofn.lpstrFilter = pField->pszFilter;
|
||||||
ofn.lpstrFile = szBrowsePath;
|
ofn.lpstrFile = szBrowsePath;
|
||||||
ofn.nMaxFile = sizeof(szBrowsePath);
|
ofn.nMaxFile = _countof(szBrowsePath);
|
||||||
ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
|
ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
|
||||||
|
|
||||||
GetWindowText(pField->hwnd, szBrowsePath, sizeof(szBrowsePath));
|
GetWindowText(pField->hwnd, szBrowsePath, _countof(szBrowsePath));
|
||||||
|
|
||||||
tryagain:
|
tryagain:
|
||||||
GetCurrentDirectory(BUFFER_SIZE, szResult); // save working dir
|
GetCurrentDirectory(BUFFER_SIZE, szResult); // save working dir
|
||||||
|
@ -629,7 +634,7 @@ LRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (szBrowsePath[0] && CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
|
else if (szBrowsePath[0] && CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
|
||||||
szBrowsePath[0] = '\0';
|
szBrowsePath[0] = _T('\0');
|
||||||
goto tryagain;
|
goto tryagain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,17 +885,17 @@ int WINAPI NumbersOnlyPasteWndProc(HWND hWin, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
|
|
||||||
if (hData)
|
if (hData)
|
||||||
{
|
{
|
||||||
char *lpData = (char *) GlobalLock(hData);
|
TCHAR *lpData = (TCHAR *) GlobalLock(hData);
|
||||||
if (lpData)
|
if (lpData)
|
||||||
{
|
{
|
||||||
int iLen = lstrlen(lpData);
|
int iLen = lstrlen(lpData);
|
||||||
char *lpFilteredData = (char *) MALLOC(iLen + 1);
|
TCHAR *lpFilteredData = (TCHAR *) MALLOC((iLen + 1)*sizeof(TCHAR));
|
||||||
|
|
||||||
if (lpFilteredData)
|
if (lpFilteredData)
|
||||||
{
|
{
|
||||||
for (int i = 0, j = 0; i < iLen; i++)
|
for (int i = 0, j = 0; i < iLen; i++)
|
||||||
{
|
{
|
||||||
if (lpData[i] >= '0' && lpData[i] <= '9')
|
if (lpData[i] >= _T('0') && lpData[i] <= _T('9'))
|
||||||
{
|
{
|
||||||
lpFilteredData[j] = lpData[i];
|
lpFilteredData[j] = lpData[i];
|
||||||
j++;
|
j++;
|
||||||
|
@ -926,14 +931,14 @@ int WINAPI createCfgDlg()
|
||||||
if (!mainwnd)
|
if (!mainwnd)
|
||||||
{
|
{
|
||||||
popstring(NULL);
|
popstring(NULL);
|
||||||
pushstring("error finding mainwnd");
|
pushstring(_T("error finding mainwnd"));
|
||||||
return 1; // cannot be used in silent mode unfortunately.
|
return 1; // cannot be used in silent mode unfortunately.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_stacktop || !*g_stacktop || !(pszFilename = (*g_stacktop)->text) || !pszFilename[0] || !ReadSettings())
|
if (!g_stacktop || !*g_stacktop || !(pszFilename = (*g_stacktop)->text) || !pszFilename[0] || !ReadSettings())
|
||||||
{
|
{
|
||||||
popstring(NULL);
|
popstring(NULL);
|
||||||
pushstring("error finding config");
|
pushstring(_T("error finding config"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +946,7 @@ int WINAPI createCfgDlg()
|
||||||
if (!childwnd)
|
if (!childwnd)
|
||||||
{
|
{
|
||||||
popstring(NULL);
|
popstring(NULL);
|
||||||
pushstring("error finding childwnd");
|
pushstring(_T("error finding childwnd"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -993,7 +998,7 @@ int WINAPI createCfgDlg()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
popstring(NULL);
|
popstring(NULL);
|
||||||
pushstring("error creating dialog");
|
pushstring(_T("error creating dialog"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,88 +1010,88 @@ int WINAPI createCfgDlg()
|
||||||
|
|
||||||
for (int nIdx = 0; nIdx < nNumFields; nIdx++) {
|
for (int nIdx = 0; nIdx < nNumFields; nIdx++) {
|
||||||
static struct {
|
static struct {
|
||||||
char* pszClass;
|
TCHAR* pszClass;
|
||||||
DWORD dwStyle;
|
DWORD dwStyle;
|
||||||
DWORD dwRTLStyle;
|
DWORD dwRTLStyle;
|
||||||
DWORD dwExStyle;
|
DWORD dwExStyle;
|
||||||
DWORD dwRTLExStyle;
|
DWORD dwRTLExStyle;
|
||||||
} ClassTable[] = {
|
} ClassTable[] = {
|
||||||
{ "STATIC", // FIELD_HLINE
|
{ _T("STATIC"), // FIELD_HLINE
|
||||||
DEFAULT_STYLES | SS_ETCHEDHORZ | SS_SUNKEN,
|
DEFAULT_STYLES | SS_ETCHEDHORZ | SS_SUNKEN,
|
||||||
DEFAULT_STYLES | SS_ETCHEDHORZ | SS_SUNKEN,
|
DEFAULT_STYLES | SS_ETCHEDHORZ | SS_SUNKEN,
|
||||||
WS_EX_TRANSPARENT,
|
WS_EX_TRANSPARENT,
|
||||||
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
||||||
{ "STATIC", // FIELD_VLINE
|
{ _T("STATIC"), // FIELD_VLINE
|
||||||
DEFAULT_STYLES | SS_ETCHEDVERT | SS_SUNKEN,
|
DEFAULT_STYLES | SS_ETCHEDVERT | SS_SUNKEN,
|
||||||
DEFAULT_STYLES | SS_ETCHEDVERT | SS_SUNKEN,
|
DEFAULT_STYLES | SS_ETCHEDVERT | SS_SUNKEN,
|
||||||
WS_EX_TRANSPARENT,
|
WS_EX_TRANSPARENT,
|
||||||
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
||||||
{ "STATIC", // FIELD_LABEL
|
{ _T("STATIC"), // FIELD_LABEL
|
||||||
DEFAULT_STYLES,
|
DEFAULT_STYLES,
|
||||||
DEFAULT_STYLES | SS_RIGHT,
|
DEFAULT_STYLES | SS_RIGHT,
|
||||||
WS_EX_TRANSPARENT,
|
WS_EX_TRANSPARENT,
|
||||||
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
||||||
{ "STATIC", // FIELD_ICON
|
{ _T("STATIC"), // FIELD_ICON
|
||||||
DEFAULT_STYLES | SS_ICON,
|
DEFAULT_STYLES | SS_ICON,
|
||||||
DEFAULT_STYLES | SS_ICON,
|
DEFAULT_STYLES | SS_ICON,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "STATIC", // FIELD_BITMAP
|
{ _T("STATIC"), // FIELD_BITMAP
|
||||||
DEFAULT_STYLES | SS_BITMAP,
|
DEFAULT_STYLES | SS_BITMAP,
|
||||||
DEFAULT_STYLES | SS_BITMAP,
|
DEFAULT_STYLES | SS_BITMAP,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "BUTTON", // FIELD_BROWSEBUTTON
|
{ _T("BUTTON"), // FIELD_BROWSEBUTTON
|
||||||
DEFAULT_STYLES | WS_TABSTOP,
|
DEFAULT_STYLES | WS_TABSTOP,
|
||||||
DEFAULT_STYLES | WS_TABSTOP,
|
DEFAULT_STYLES | WS_TABSTOP,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "BUTTON", // FIELD_LINK
|
{ _T("BUTTON"), // FIELD_LINK
|
||||||
DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW,
|
DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW | BS_RIGHT,
|
DEFAULT_STYLES | WS_TABSTOP | BS_OWNERDRAW | BS_RIGHT,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "BUTTON", // FIELD_BUTTON
|
{ _T("BUTTON"), // FIELD_BUTTON
|
||||||
DEFAULT_STYLES | WS_TABSTOP,
|
DEFAULT_STYLES | WS_TABSTOP,
|
||||||
DEFAULT_STYLES | WS_TABSTOP,
|
DEFAULT_STYLES | WS_TABSTOP,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "BUTTON", // FIELD_GROUPBOX
|
{ _T("BUTTON"), // FIELD_GROUPBOX
|
||||||
DEFAULT_STYLES | BS_GROUPBOX,
|
DEFAULT_STYLES | BS_GROUPBOX,
|
||||||
DEFAULT_STYLES | BS_GROUPBOX | BS_RIGHT,
|
DEFAULT_STYLES | BS_GROUPBOX | BS_RIGHT,
|
||||||
WS_EX_TRANSPARENT,
|
WS_EX_TRANSPARENT,
|
||||||
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
WS_EX_TRANSPARENT | RTL_EX_STYLES },
|
||||||
{ "BUTTON", // FIELD_CHECKBOX
|
{ _T("BUTTON"), // FIELD_CHECKBOX
|
||||||
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE,
|
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
|
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTOCHECKBOX | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "BUTTON", // FIELD_RADIOBUTTON
|
{ _T("BUTTON"), // FIELD_RADIOBUTTON
|
||||||
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE,
|
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
|
DEFAULT_STYLES | WS_TABSTOP | BS_TEXT | BS_VCENTER | BS_AUTORADIOBUTTON | BS_MULTILINE | BS_RIGHT | BS_LEFTTEXT,
|
||||||
0,
|
0,
|
||||||
RTL_EX_STYLES },
|
RTL_EX_STYLES },
|
||||||
{ "EDIT", // FIELD_TEXT
|
{ _T("EDIT"), // FIELD_TEXT
|
||||||
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
|
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
|
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
|
||||||
{ "EDIT", // FIELD_FILEREQUEST
|
{ _T("EDIT"), // FIELD_FILEREQUEST
|
||||||
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
|
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
|
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
|
||||||
{ "EDIT", // FIELD_DIRREQUEST
|
{ _T("EDIT"), // FIELD_DIRREQUEST
|
||||||
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
|
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
|
DEFAULT_STYLES | WS_TABSTOP | ES_AUTOHSCROLL | ES_RIGHT,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | RTL_EX_STYLES },
|
||||||
{ "COMBOBOX", // FIELD_COMBOBOX
|
{ _T("COMBOBOX"), // FIELD_COMBOBOX
|
||||||
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
|
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
|
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | CBS_AUTOHSCROLL | CBS_HASSTRINGS,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RIGHT | RTL_EX_STYLES },
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_RIGHT | RTL_EX_STYLES },
|
||||||
{ "LISTBOX", // FIELD_LISTBOX
|
{ _T("LISTBOX"), // FIELD_LISTBOX
|
||||||
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
|
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
|
||||||
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
|
DEFAULT_STYLES | WS_TABSTOP | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
|
||||||
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
|
||||||
|
@ -1133,7 +1138,7 @@ int WINAPI createCfgDlg()
|
||||||
rect.left = mainWndWidth - right;
|
rect.left = mainWndWidth - right;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *title = pField->pszText;
|
TCHAR *title = pField->pszText;
|
||||||
switch (pField->nType) {
|
switch (pField->nType) {
|
||||||
case FIELD_ICON:
|
case FIELD_ICON:
|
||||||
case FIELD_BITMAP:
|
case FIELD_BITMAP:
|
||||||
|
@ -1198,10 +1203,10 @@ int WINAPI createCfgDlg()
|
||||||
);
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
char szField[64];
|
TCHAR szField[64];
|
||||||
char szHwnd[64];
|
TCHAR szHwnd[64];
|
||||||
wsprintf(szField, "Field %d", pField->nField);
|
wsprintf(szField, _T("Field %d"), pField->nField);
|
||||||
wsprintf(szHwnd, "%d", hwCtrl);
|
wsprintf(szHwnd, _T("%d"), hwCtrl);
|
||||||
WritePrivateProfileString(szField, pField->pszHwndEntry, szHwnd, pszFilename);
|
WritePrivateProfileString(szField, pField->pszHwndEntry, szHwnd, pszFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1223,7 +1228,7 @@ int WINAPI createCfgDlg()
|
||||||
|
|
||||||
case FIELD_CHECKBOX:
|
case FIELD_CHECKBOX:
|
||||||
case FIELD_RADIOBUTTON:
|
case FIELD_RADIOBUTTON:
|
||||||
if (pField->pszState[0] == '1')
|
if (pField->pszState[0] == _T('1'))
|
||||||
mySendMessage(hwCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
mySendMessage(hwCtrl, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1242,12 +1247,12 @@ int WINAPI createCfgDlg()
|
||||||
nFindMsg = LB_FINDSTRINGEXACT;
|
nFindMsg = LB_FINDSTRINGEXACT;
|
||||||
nSetSelMsg = LB_SETCURSEL;
|
nSetSelMsg = LB_SETCURSEL;
|
||||||
}
|
}
|
||||||
char *pszStart, *pszEnd, *pszList;
|
TCHAR *pszStart, *pszEnd, *pszList;
|
||||||
pszStart = pszEnd = pszList = STRDUP(pField->pszListItems);
|
pszStart = pszEnd = pszList = STRDUP(pField->pszListItems);
|
||||||
// pszListItems has a trailing pipe
|
// pszListItems has a trailing pipe
|
||||||
while (*pszEnd) {
|
while (*pszEnd) {
|
||||||
if (*pszEnd == '|') {
|
if (*pszEnd == _T('|')) {
|
||||||
*pszEnd = '\0';
|
*pszEnd = _T('\0');
|
||||||
if (*pszStart)
|
if (*pszStart)
|
||||||
mySendMessage(hwCtrl, nAddMsg, 0, (LPARAM) pszStart);
|
mySendMessage(hwCtrl, nAddMsg, 0, (LPARAM) pszStart);
|
||||||
pszStart = ++pszEnd;
|
pszStart = ++pszEnd;
|
||||||
|
@ -1261,9 +1266,9 @@ int WINAPI createCfgDlg()
|
||||||
mySendMessage(hwCtrl, LB_SETSEL, FALSE, (LPARAM)-1);
|
mySendMessage(hwCtrl, LB_SETSEL, FALSE, (LPARAM)-1);
|
||||||
pszStart = pszEnd = pField->pszState;
|
pszStart = pszEnd = pField->pszState;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char c = *pszEnd;
|
TCHAR c = *pszEnd;
|
||||||
if (c == '|' || c == '\0') {
|
if (c == _T('|') || c == _T('\0')) {
|
||||||
*pszEnd = '\0';
|
*pszEnd = _T('\0');
|
||||||
if (*pszStart)
|
if (*pszStart)
|
||||||
{
|
{
|
||||||
int nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
|
int nItem = mySendMessage(hwCtrl, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszStart);
|
||||||
|
@ -1429,8 +1434,8 @@ int WINAPI createCfgDlg()
|
||||||
mySetWindowText(mainwnd,pszTitle);
|
mySetWindowText(mainwnd,pszTitle);
|
||||||
pFilenameStackEntry = *g_stacktop;
|
pFilenameStackEntry = *g_stacktop;
|
||||||
*g_stacktop = (*g_stacktop)->next;
|
*g_stacktop = (*g_stacktop)->next;
|
||||||
static char tmp[32];
|
static TCHAR tmp[32];
|
||||||
wsprintf(tmp,"%d",hConfigWindow);
|
wsprintf(tmp,_T("%d"),hConfigWindow);
|
||||||
pushstring(tmp);
|
pushstring(tmp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1477,7 +1482,7 @@ void WINAPI showCfgDlg()
|
||||||
|
|
||||||
int j = FIELD_BUFFERS;
|
int j = FIELD_BUFFERS;
|
||||||
while (j--)
|
while (j--)
|
||||||
FREE(((char **) pField)[j]);
|
FREE(((TCHAR **) pField)[j]);
|
||||||
|
|
||||||
if (pField->nType == FIELD_BITMAP) {
|
if (pField->nType == FIELD_BITMAP) {
|
||||||
DeleteObject(pField->hImage);
|
DeleteObject(pField->hImage);
|
||||||
|
@ -1488,18 +1493,18 @@ void WINAPI showCfgDlg()
|
||||||
}
|
}
|
||||||
FREE(pFields);
|
FREE(pFields);
|
||||||
|
|
||||||
pushstring(g_is_cancel?"cancel":g_is_back?"back":"success");
|
pushstring(g_is_cancel?_T("cancel"):g_is_back?_T("back"):_T("success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int initCalled;
|
int initCalled;
|
||||||
|
|
||||||
extern "C" void __declspec(dllexport) dialog(HWND hwndParent, int string_size,
|
extern "C" void __declspec(dllexport) dialog(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
hMainWindow=hwndParent;
|
hMainWindow=hwndParent;
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
if (initCalled) {
|
if (initCalled) {
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (createCfgDlg())
|
if (createCfgDlg())
|
||||||
|
@ -1514,14 +1519,16 @@ static UINT_PTR PluginCallback(enum NSPIM msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void __declspec(dllexport) initDialog(HWND hwndParent, int string_size,
|
extern "C" void __declspec(dllexport) initDialog(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop,
|
TCHAR *variables, stack_t **stacktop,
|
||||||
extra_parameters *extra)
|
extra_parameters *extra)
|
||||||
{
|
{
|
||||||
hMainWindow=hwndParent;
|
hMainWindow=hwndParent;
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
extra->RegisterPluginCallback(m_hInstance, PluginCallback);
|
extra->RegisterPluginCallback(m_hInstance, PluginCallback);
|
||||||
|
|
||||||
if (initCalled) {
|
if (initCalled) {
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (createCfgDlg())
|
if (createCfgDlg())
|
||||||
|
@ -1530,11 +1537,11 @@ extern "C" void __declspec(dllexport) initDialog(HWND hwndParent, int string_siz
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
extern "C" void __declspec(dllexport) show(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
if (!initCalled) {
|
if (!initCalled) {
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
initCalled--;
|
initCalled--;
|
||||||
|
@ -1548,23 +1555,41 @@ extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int WINAPI LookupToken(TableEntry* psTable_, char* pszToken_)
|
/**
|
||||||
|
* Looks up a single token in the psTable_ and returns its mapped numerical value.
|
||||||
|
*
|
||||||
|
* @param psTable_ The lookup table.
|
||||||
|
* @param pszToken_ The token to lookup.
|
||||||
|
* @return The integer value related to the token, otherwise 0.
|
||||||
|
*/
|
||||||
|
int WINAPI LookupToken(TableEntry* psTable_, TCHAR* pszToken_)
|
||||||
{
|
{
|
||||||
for (int i = 0; psTable_[i].pszName; i++)
|
for (int i = 0; psTable_[i].pszName; i++)
|
||||||
if (!stricmp(pszToken_, psTable_[i].pszName))
|
if (!lstrcmpi(pszToken_, psTable_[i].pszName))
|
||||||
return psTable_[i].nValue;
|
return psTable_[i].nValue;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI LookupTokens(TableEntry* psTable_, char* pszTokens_)
|
/**
|
||||||
|
* In a string of tokens separated by vertical bars '|', look them up in the
|
||||||
|
* Lookup Table psTable and return their logical OR of their subsequent
|
||||||
|
* integer values.
|
||||||
|
*
|
||||||
|
* @param psTable_ The lookup table to search in.
|
||||||
|
* @param pszToken String of tokens separated by '|' whose values are to be
|
||||||
|
* ORed together.
|
||||||
|
* @return The ORed value of the token values. If no tokens were found, it
|
||||||
|
* will return 0.
|
||||||
|
*/
|
||||||
|
int WINAPI LookupTokens(TableEntry* psTable_, TCHAR* pszTokens_)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
char *pszStart = pszTokens_;
|
TCHAR *pszStart = pszTokens_;
|
||||||
char *pszEnd = pszTokens_;
|
TCHAR *pszEnd = pszTokens_;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char c = *pszEnd;
|
TCHAR c = *pszEnd;
|
||||||
if (c == '|' || c == '\0') {
|
if (c == _T('|') || c == _T('\0')) {
|
||||||
*pszEnd = '\0';
|
*pszEnd = _T('\0');
|
||||||
n |= LookupToken(psTable_, pszStart);
|
n |= LookupToken(psTable_, pszStart);
|
||||||
*pszEnd = c;
|
*pszEnd = c;
|
||||||
if (!c)
|
if (!c)
|
||||||
|
@ -1577,8 +1602,15 @@ int WINAPI LookupTokens(TableEntry* psTable_, char* pszTokens_)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINAPI ConvertNewLines(char *str) {
|
/**
|
||||||
char *p1, *p2, *p3;
|
* ConvertNewLines takes a string and turns escape sequences written
|
||||||
|
* as separate chars e.g. "\\t" into the special char they represent
|
||||||
|
* '\t'. The transformation is done in place.
|
||||||
|
*
|
||||||
|
* @param str [in/out] The string to convert.
|
||||||
|
*/
|
||||||
|
void WINAPI ConvertNewLines(TCHAR *str) {
|
||||||
|
TCHAR *p1, *p2, *p3;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return;
|
return;
|
||||||
|
@ -1589,23 +1621,23 @@ void WINAPI ConvertNewLines(char *str) {
|
||||||
{
|
{
|
||||||
switch (*(LPWORD)p1)
|
switch (*(LPWORD)p1)
|
||||||
{
|
{
|
||||||
case CHAR2_TO_WORD('\\', 't'):
|
case CHAR2_TO_WORD(_T('\\'), _T('t')):
|
||||||
*p2 = '\t';
|
*p2 = _T('\t');
|
||||||
p1 += 2;
|
p1 += 2;
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
case CHAR2_TO_WORD('\\', 'n'):
|
case CHAR2_TO_WORD(_T('\\'), _T('n')):
|
||||||
*p2 = '\n';
|
*p2 = _T('\n');
|
||||||
p1 += 2;
|
p1 += 2;
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
case CHAR2_TO_WORD('\\', 'r'):
|
case CHAR2_TO_WORD(_T('\\'), _T('r')):
|
||||||
*p2 = '\r';
|
*p2 = _T('\r');
|
||||||
p1 += 2;
|
p1 += 2;
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
case CHAR2_TO_WORD('\\', '\\'):
|
case CHAR2_TO_WORD(_T('\\'), _T('\\')):
|
||||||
*p2 = '\\';
|
*p2 = _T('\\');
|
||||||
p1 += 2;
|
p1 += 2;
|
||||||
p2++;
|
p2++;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
#include <nsis/nsis_tchar.h>
|
||||||
|
|
||||||
// JF> updated usage
|
// JF> updated usage
|
||||||
// call like this:
|
// call like this:
|
||||||
|
@ -8,6 +9,8 @@
|
||||||
// LangDLL:LangDialog "Language Selection" "Choose a language" 2 French 1036 English 1033
|
// LangDLL:LangDialog "Language Selection" "Choose a language" 2 French 1036 English 1033
|
||||||
// or (the F after the 2 means we're supplying font information)
|
// or (the F after the 2 means we're supplying font information)
|
||||||
// LangDLL:LangDialog "Language Selection" "Choose a language" 2F French 1036 English 1033 12 Garamond
|
// LangDLL:LangDialog "Language Selection" "Choose a language" 2F French 1036 English 1033 12 Garamond
|
||||||
|
//
|
||||||
|
// Unicode support added by Jim Park -- 07/27/2007
|
||||||
|
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
@ -15,8 +18,8 @@
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
HWND g_hwndParent;
|
HWND g_hwndParent;
|
||||||
|
|
||||||
char temp[1024];
|
TCHAR temp[1024];
|
||||||
char g_wndtitle[1024], g_wndtext[1024];
|
TCHAR g_wndtitle[1024], g_wndtext[1024];
|
||||||
int dofont;
|
int dofont;
|
||||||
int docp;
|
int docp;
|
||||||
|
|
||||||
|
@ -24,15 +27,15 @@ int langs_num;
|
||||||
int visible_langs_num;
|
int visible_langs_num;
|
||||||
|
|
||||||
struct lang {
|
struct lang {
|
||||||
char *name;
|
TCHAR *name;
|
||||||
char *id;
|
TCHAR *id;
|
||||||
UINT cp;
|
UINT cp;
|
||||||
} *langs;
|
} *langs;
|
||||||
|
|
||||||
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int i, size;
|
int i, size;
|
||||||
char *selected_language = NULL;
|
TCHAR *selected_language = NULL;
|
||||||
static HFONT font;
|
static HFONT font;
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
@ -62,7 +65,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
size = myatou(temp);
|
size = myatou(temp);
|
||||||
if (!popstring(temp)) {
|
if (!popstring(temp)) {
|
||||||
LOGFONT f = {0,};
|
LOGFONT f = {0,};
|
||||||
if (lstrcmp(temp, "MS Shell Dlg")) {
|
if (lstrcmp(temp, _T("MS Shell Dlg"))) {
|
||||||
f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72);
|
f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72);
|
||||||
lstrcpy(f.lfFaceName, temp);
|
lstrcpy(f.lfFaceName, temp);
|
||||||
font = CreateFontIndirect(&f);
|
font = CreateFontIndirect(&f);
|
||||||
|
@ -84,17 +87,17 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
|
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
|
||||||
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0);
|
i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0);
|
||||||
if (i != CB_ERR && i) {
|
if (i != CB_ERR && i) {
|
||||||
pushstring((char *) i);
|
pushstring((TCHAR *) i);
|
||||||
} else {
|
} else {
|
||||||
// ?!
|
// ?!
|
||||||
pushstring("cancel");
|
pushstring(_T("cancel"));
|
||||||
}
|
}
|
||||||
// end dialog
|
// end dialog
|
||||||
EndDialog(hwndDlg, 0);
|
EndDialog(hwndDlg, 0);
|
||||||
break;
|
break;
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
// push "cancel" on the stack
|
// push "cancel" on the stack
|
||||||
pushstring("cancel");
|
pushstring(_T("cancel"));
|
||||||
// end dialog
|
// end dialog
|
||||||
EndDialog(hwndDlg, 0);
|
EndDialog(hwndDlg, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -111,7 +114,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
@ -130,12 +133,12 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
|
|
||||||
// parse flags
|
// parse flags
|
||||||
{
|
{
|
||||||
char *p=temp;
|
TCHAR *p=temp;
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
if (*p == 'A') doauto=1; // parse auto count flag
|
if (*p == _T('A')) doauto=1; // parse auto count flag
|
||||||
if (*p == 'F') dofont=1; // parse font flag
|
if (*p == _T('F')) dofont=1; // parse font flag
|
||||||
if (*p == 'C') docp=1; // parse codepage flag
|
if (*p == _T('C')) docp=1; // parse codepage flag
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,12 +176,12 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
// fill language struct
|
// fill language struct
|
||||||
for (i = 0; i < langs_num; i++) {
|
for (i = 0; i < langs_num; i++) {
|
||||||
if (popstring(temp)) { visible_langs_num = 0; break; }
|
if (popstring(temp)) { visible_langs_num = 0; break; }
|
||||||
langs[visible_langs_num].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
langs[visible_langs_num].name = (TCHAR*) GlobalAlloc(GPTR, (lstrlen(temp)+1)*sizeof(TCHAR));
|
||||||
if (!langs[visible_langs_num].name) { visible_langs_num = 0; break; }
|
if (!langs[visible_langs_num].name) { visible_langs_num = 0; break; }
|
||||||
lstrcpy(langs[visible_langs_num].name, temp);
|
lstrcpy(langs[visible_langs_num].name, temp);
|
||||||
|
|
||||||
if (popstring(temp)) { visible_langs_num = 0; break; }
|
if (popstring(temp)) { visible_langs_num = 0; break; }
|
||||||
langs[visible_langs_num].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
langs[visible_langs_num].id = (TCHAR*) GlobalAlloc(GPTR, (lstrlen(temp)+1)*sizeof(TCHAR));
|
||||||
if (!langs[visible_langs_num].id) { visible_langs_num = 0; break; }
|
if (!langs[visible_langs_num].id) { visible_langs_num = 0; break; }
|
||||||
lstrcpy(langs[visible_langs_num].id, temp);
|
lstrcpy(langs[visible_langs_num].id, temp);
|
||||||
|
|
||||||
|
@ -188,6 +191,10 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
langs[visible_langs_num].cp = myatou(temp);
|
langs[visible_langs_num].cp = myatou(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If Unicode, show everything.
|
||||||
|
#ifdef _UNICODE
|
||||||
|
visible_langs_num++;
|
||||||
|
#else
|
||||||
if (!docp || langs[visible_langs_num].cp == GetACP() || langs[visible_langs_num].cp == 0)
|
if (!docp || langs[visible_langs_num].cp == GetACP() || langs[visible_langs_num].cp == 0)
|
||||||
{
|
{
|
||||||
visible_langs_num++;
|
visible_langs_num++;
|
||||||
|
@ -197,6 +204,7 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
GlobalFree(langs[visible_langs_num].name);
|
GlobalFree(langs[visible_langs_num].name);
|
||||||
GlobalFree(langs[visible_langs_num].id);
|
GlobalFree(langs[visible_langs_num].id);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// pop the empty string to keep the stack clean
|
// pop the empty string to keep the stack clean
|
||||||
|
@ -213,7 +221,7 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
}
|
}
|
||||||
else if (visible_langs_num == 0)
|
else if (visible_langs_num == 0)
|
||||||
{
|
{
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
LibraryLocal - used by the Library.nsh macros
|
LibraryLocal - used by the Library.nsh macros
|
||||||
Get the version of local DLL and TLB files
|
Get the version of local DLL and TLB files
|
||||||
Written by Joost Verburg
|
Written by Joost Verburg
|
||||||
|
Unicode support by Jim Park -- 07/27/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../../Source/Platform.h"
|
#include "../../../Source/Platform.h"
|
||||||
|
#include "../../../Source/tstring.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -21,23 +23,27 @@ int g_noconfig=0;
|
||||||
int g_display_errors=1;
|
int g_display_errors=1;
|
||||||
FILE *g_output=stdout;
|
FILE *g_output=stdout;
|
||||||
|
|
||||||
int GetTLBVersion(string& filepath, DWORD& high, DWORD & low)
|
int GetTLBVersion(tstring& filepath, DWORD& high, DWORD & low)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
char fullpath[1024];
|
TCHAR fullpath[1024];
|
||||||
char *p;
|
TCHAR *p;
|
||||||
if (!GetFullPathName(filepath.c_str(), sizeof(fullpath), fullpath, &p))
|
if (!GetFullPathName(filepath.c_str(), _countof(fullpath), fullpath, &p))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
WCHAR *ole_filename = winchar_fromansi(fullpath);
|
|
||||||
|
|
||||||
ITypeLib* typeLib;
|
ITypeLib* typeLib;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
hr = LoadTypeLib(fullpath, &typeLib);
|
||||||
|
#else
|
||||||
|
// If built without UNICODE, we still need to convert this string to a Unicode string.
|
||||||
|
WCHAR *ole_filename = winchar_fromansi(fullpath);
|
||||||
hr = LoadTypeLib(ole_filename, &typeLib);
|
hr = LoadTypeLib(ole_filename, &typeLib);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
|
|
||||||
|
@ -67,16 +73,16 @@ int GetTLBVersion(string& filepath, DWORD& high, DWORD & low)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int _tmain(int argc, TCHAR* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
// Parse the command line
|
// Parse the command line
|
||||||
|
|
||||||
string cmdline;
|
tstring cmdline;
|
||||||
|
|
||||||
string mode;
|
tstring mode;
|
||||||
string filename;
|
tstring filename;
|
||||||
string filepath;
|
tstring filepath;
|
||||||
|
|
||||||
int filefound = 0;
|
int filefound = 0;
|
||||||
|
|
||||||
|
@ -90,7 +96,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Validate filename
|
// Validate filename
|
||||||
|
|
||||||
ifstream fs(filename.c_str());
|
tifstream fs(filename.c_str());
|
||||||
|
|
||||||
if (fs.is_open())
|
if (fs.is_open())
|
||||||
{
|
{
|
||||||
|
@ -110,7 +116,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// DLL / EXE
|
// DLL / EXE
|
||||||
|
|
||||||
if (mode.compare("D") == 0)
|
if (mode.compare(_T("D")) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
versionfound = GetDLLVersion(filename, high, low);
|
versionfound = GetDLLVersion(filename, high, low);
|
||||||
|
@ -119,7 +125,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// TLB
|
// TLB
|
||||||
|
|
||||||
if (mode.compare("T") == 0)
|
if (mode.compare(_T("T")) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
versionfound = GetTLBVersion(filename, high, low);
|
versionfound = GetTLBVersion(filename, high, low);
|
||||||
|
@ -130,23 +136,23 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Write the version to an NSIS header file
|
// Write the version to an NSIS header file
|
||||||
|
|
||||||
ofstream header(argv[3], ofstream::out);
|
tofstream header(argv[3], tofstream::out);
|
||||||
|
|
||||||
if (header)
|
if (header)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!filefound)
|
if (!filefound)
|
||||||
{
|
{
|
||||||
header << "!define LIBRARY_VERSION_FILENOTFOUND" << endl;
|
header << _T("!define LIBRARY_VERSION_FILENOTFOUND") << endl;
|
||||||
}
|
}
|
||||||
else if (!versionfound)
|
else if (!versionfound)
|
||||||
{
|
{
|
||||||
header << "!define LIBRARY_VERSION_NONE" << endl;
|
header << _T("!define LIBRARY_VERSION_NONE") << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header << "!define LIBRARY_VERSION_HIGH " << high << endl;
|
header << _T("!define LIBRARY_VERSION_HIGH ") << high << endl;
|
||||||
header << "!define LIBRARY_VERSION_LOW " << low << endl;
|
header << _T("!define LIBRARY_VERSION_LOW ") << low << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
header.close();
|
header.close();
|
||||||
|
|
|
@ -1,40 +1,41 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "../../ExDll/nsis_tchar.h"
|
||||||
|
|
||||||
#define STR_SIZE 1024
|
#define STR_SIZE 1024
|
||||||
|
|
||||||
void RegFile(char cmd, char *file, int x64);
|
void RegFile(TCHAR cmd, TCHAR *file, int x64);
|
||||||
void RegDll(char *file);
|
void RegDll(TCHAR *file);
|
||||||
void RegTypeLib(char *file);
|
void RegTypeLib(TCHAR *file);
|
||||||
void DeleteFileOnReboot(char *pszFile);
|
void DeleteFileOnReboot(TCHAR *pszFile);
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
char *cmdline;
|
TCHAR *cmdline;
|
||||||
char seekchar = ' ';
|
TCHAR seekchar = _T(' ');
|
||||||
|
|
||||||
cmdline = GetCommandLine();
|
cmdline = GetCommandLine();
|
||||||
if (*cmdline == '\"')
|
if (*cmdline == _T('\"'))
|
||||||
seekchar = *cmdline++;
|
seekchar = *cmdline++;
|
||||||
|
|
||||||
while (*cmdline && *cmdline != seekchar)
|
while (*cmdline && *cmdline != seekchar)
|
||||||
cmdline = CharNext(cmdline);
|
cmdline = CharNext(cmdline);
|
||||||
cmdline = CharNext(cmdline);
|
cmdline = CharNext(cmdline);
|
||||||
while (*cmdline == ' ')
|
while (*cmdline == _T(' '))
|
||||||
cmdline++;
|
cmdline++;
|
||||||
|
|
||||||
if (*cmdline++ != '/')
|
if (*cmdline++ != _T('/'))
|
||||||
{
|
{
|
||||||
ExitProcess(1);
|
ExitProcess(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*cmdline == 'S')
|
if (*cmdline == _T('S'))
|
||||||
{
|
{
|
||||||
HKEY rootkey;
|
HKEY rootkey;
|
||||||
|
|
||||||
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\NSIS.Library.RegTool.v3", 0, KEY_READ, &rootkey)))
|
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"), 0, KEY_READ, &rootkey)))
|
||||||
{
|
{
|
||||||
char keyname[STR_SIZE];
|
TCHAR keyname[STR_SIZE];
|
||||||
|
|
||||||
while (RegEnumKey(rootkey, 0, keyname, STR_SIZE) == ERROR_SUCCESS)
|
while (RegEnumKey(rootkey, 0, keyname, STR_SIZE) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -44,24 +45,24 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
{
|
{
|
||||||
DWORD t, count, l = sizeof(DWORD);
|
DWORD t, count, l = sizeof(DWORD);
|
||||||
|
|
||||||
if (SUCCEEDED(RegQueryValueEx(key, "count", NULL, &t, (LPBYTE) &count, &l)) && t == REG_DWORD)
|
if (SUCCEEDED(RegQueryValueEx(key, _T("count"), NULL, &t, (LPBYTE) &count, &l)) && t == REG_DWORD)
|
||||||
{
|
{
|
||||||
DWORD j;
|
DWORD j;
|
||||||
char valname[128], mode[3], file[STR_SIZE];
|
TCHAR valname[128], mode[3], file[STR_SIZE];
|
||||||
|
|
||||||
for (j = 1; j <= count; j++)
|
for (j = 1; j <= count; j++)
|
||||||
{
|
{
|
||||||
wsprintf(valname, "%u.mode", j);
|
wsprintf(valname, _T("%u.mode"), j);
|
||||||
l = sizeof(mode);
|
l = sizeof(mode);
|
||||||
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) mode, &l)) || t != REG_SZ)
|
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) mode, &l)) || t != REG_SZ)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
wsprintf(valname, "%u.file", j);
|
wsprintf(valname, _T("%u.file"), j);
|
||||||
l = STR_SIZE;
|
l = STR_SIZE;
|
||||||
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ)
|
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RegFile(mode[0], file, mode[1] == 'X');
|
RegFile(mode[0], file, mode[1] == _T('X'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,11 +72,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(rootkey);
|
RegCloseKey(rootkey);
|
||||||
RegDeleteKey(HKEY_LOCAL_MACHINE, "Software\\NSIS.Library.RegTool.v3");
|
RegDeleteKey(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
char file[STR_SIZE];
|
TCHAR file[STR_SIZE];
|
||||||
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
|
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
|
||||||
{
|
{
|
||||||
DeleteFileOnReboot(file);
|
DeleteFileOnReboot(file);
|
||||||
|
@ -87,11 +88,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||||
OleInitialize(NULL);
|
OleInitialize(NULL);
|
||||||
|
|
||||||
if (*cmdline == 'D')
|
if (*cmdline == _T('D'))
|
||||||
{
|
{
|
||||||
RegDll(cmdline + 1);
|
RegDll(cmdline + 1);
|
||||||
}
|
}
|
||||||
else if (*cmdline == 'T')
|
else if (*cmdline == _T('T'))
|
||||||
{
|
{
|
||||||
RegTypeLib(cmdline + 1);
|
RegTypeLib(cmdline + 1);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +107,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
|
|
||||||
void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
||||||
{
|
{
|
||||||
HMODULE kernel = GetModuleHandle("kernel32");
|
HMODULE kernel = GetModuleHandle(_T("kernel32"));
|
||||||
if (kernel)
|
if (kernel)
|
||||||
{
|
{
|
||||||
FARPROC proc = GetProcAddress(kernel, "Wow64EnableWow64FsRedirection");
|
FARPROC proc = GetProcAddress(kernel, "Wow64EnableWow64FsRedirection");
|
||||||
|
@ -121,26 +122,26 @@ void SafeWow64EnableWow64FsRedirection(BOOL Wow64FsEnableRedirection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegFile(char cmd, char *file, int x64)
|
void RegFile(TCHAR cmd, TCHAR *file, int x64)
|
||||||
{
|
{
|
||||||
char self[STR_SIZE];
|
TCHAR self[STR_SIZE];
|
||||||
char cmdline[STR_SIZE];
|
TCHAR cmdline[STR_SIZE];
|
||||||
|
|
||||||
int ready = 0;
|
int ready = 0;
|
||||||
|
|
||||||
if (!*file || (cmd != 'D' && cmd != 'T' && cmd != 'E'))
|
if (!*file || (cmd != _T('D') && cmd != _T('T') && cmd != _T('E')))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cmd == 'E')
|
if (cmd == _T('E'))
|
||||||
{
|
{
|
||||||
wsprintf(cmdline, "\"%s\" /regserver", file);
|
wsprintf(cmdline, _T("\"%s\" /regserver"), file);
|
||||||
ready++;
|
ready++;
|
||||||
}
|
}
|
||||||
else if (!x64)
|
else if (!x64)
|
||||||
{
|
{
|
||||||
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
|
if (GetModuleFileName(GetModuleHandle(NULL), self, STR_SIZE))
|
||||||
{
|
{
|
||||||
wsprintf(cmdline, "\"%s\" /%c%s", self, cmd, file);
|
wsprintf(cmdline, _T("\"%s\" /%c%s"), self, cmd, file);
|
||||||
ready++;
|
ready++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,7 @@ void RegFile(char cmd, char *file, int x64)
|
||||||
{
|
{
|
||||||
if (GetSystemDirectory(self, STR_SIZE))
|
if (GetSystemDirectory(self, STR_SIZE))
|
||||||
{
|
{
|
||||||
wsprintf(cmdline, "\"%s\\regsvr32.exe\" /s \"%s\"", self, file);
|
wsprintf(cmdline, _T("\"%s\\regsvr32.exe\" /s \"%s\""), self, file);
|
||||||
ready++;
|
ready++;
|
||||||
|
|
||||||
SafeWow64EnableWow64FsRedirection(FALSE);
|
SafeWow64EnableWow64FsRedirection(FALSE);
|
||||||
|
@ -176,7 +177,7 @@ void RegFile(char cmd, char *file, int x64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegDll(char *file)
|
void RegDll(TCHAR *file)
|
||||||
{
|
{
|
||||||
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
HMODULE mod = LoadLibraryEx(file, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||||
if (mod)
|
if (mod)
|
||||||
|
@ -188,7 +189,7 @@ void RegDll(char *file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegTypeLib(char *file)
|
void RegTypeLib(TCHAR *file)
|
||||||
{
|
{
|
||||||
WCHAR wfile[STR_SIZE];
|
WCHAR wfile[STR_SIZE];
|
||||||
|
|
||||||
|
@ -202,12 +203,12 @@ void RegTypeLib(char *file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *mystrstri(char *a, char *b)
|
TCHAR *mystrstri(TCHAR *a, TCHAR *b)
|
||||||
{
|
{
|
||||||
int l = lstrlen(b);
|
int l = lstrlen(b);
|
||||||
while (lstrlen(a) >= l)
|
while (lstrlen(a) >= l)
|
||||||
{
|
{
|
||||||
char c = a[l];
|
TCHAR c = a[l];
|
||||||
a[l] = 0;
|
a[l] = 0;
|
||||||
if (!lstrcmpi(a, b))
|
if (!lstrcmpi(a, b))
|
||||||
{
|
{
|
||||||
|
@ -222,23 +223,23 @@ char *mystrstri(char *a, char *b)
|
||||||
|
|
||||||
void mini_memcpy(void *out, const void *in, int len)
|
void mini_memcpy(void *out, const void *in, int len)
|
||||||
{
|
{
|
||||||
char *c_out=(char*)out;
|
TCHAR *c_out=(TCHAR*)out;
|
||||||
char *c_in=(char *)in;
|
TCHAR *c_in=(TCHAR *)in;
|
||||||
while (len-- > 0)
|
while (len-- > 0)
|
||||||
{
|
{
|
||||||
*c_out++=*c_in++;
|
*c_out++=*c_in++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteFileOnReboot(char *pszFile)
|
void DeleteFileOnReboot(TCHAR *pszFile)
|
||||||
{
|
{
|
||||||
BOOL fOk = 0;
|
BOOL fOk = 0;
|
||||||
HMODULE hLib=GetModuleHandle("KERNEL32.dll");
|
HMODULE hLib=GetModuleHandle(_T("KERNEL32.dll"));
|
||||||
if (hLib)
|
if (hLib)
|
||||||
{
|
{
|
||||||
typedef BOOL (WINAPI *mfea_t)(LPCSTR lpExistingFileName,LPCSTR lpNewFileName,DWORD dwFlags);
|
typedef BOOL (WINAPI *mfea_t)(LPCTSTR lpExistingFileName,LPCTSTR lpNewFileName,DWORD dwFlags);
|
||||||
mfea_t mfea;
|
mfea_t mfea;
|
||||||
mfea=(mfea_t) GetProcAddress(hLib,"MoveFileExA");
|
mfea=(mfea_t) GetProcAddress(hLib,_CRT_STRINGIZE(MoveFileEx));
|
||||||
if (mfea)
|
if (mfea)
|
||||||
{
|
{
|
||||||
fOk=mfea(pszFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
fOk=mfea(pszFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||||
|
@ -247,10 +248,10 @@ void DeleteFileOnReboot(char *pszFile)
|
||||||
|
|
||||||
if (!fOk)
|
if (!fOk)
|
||||||
{
|
{
|
||||||
static char szRenameLine[1024];
|
static TCHAR szRenameLine[1024];
|
||||||
static char wininit[1024];
|
static TCHAR wininit[1024];
|
||||||
int cchRenameLine;
|
int cchRenameLine;
|
||||||
char *szRenameSec = "[Rename]\r\n";
|
TCHAR *szRenameSec = _T("[Rename]\r\n");
|
||||||
HANDLE hfile, hfilemap;
|
HANDLE hfile, hfilemap;
|
||||||
DWORD dwFileSize, dwRenameLinePos;
|
DWORD dwFileSize, dwRenameLinePos;
|
||||||
|
|
||||||
|
@ -260,10 +261,10 @@ void DeleteFileOnReboot(char *pszFile)
|
||||||
spn = GetShortPathName(pszFile,wininit,1024);
|
spn = GetShortPathName(pszFile,wininit,1024);
|
||||||
if (!spn || spn > 1024)
|
if (!spn || spn > 1024)
|
||||||
return;
|
return;
|
||||||
cchRenameLine = wsprintf(szRenameLine,"NUL=%s\r\n",wininit);
|
cchRenameLine = wsprintf(szRenameLine,_T("NUL=%s\r\n"),wininit);
|
||||||
|
|
||||||
GetWindowsDirectory(wininit, 1024-16);
|
GetWindowsDirectory(wininit, 1024-16);
|
||||||
lstrcat(wininit, "\\wininit.ini");
|
lstrcat(wininit, _T("\\wininit.ini"));
|
||||||
hfile = CreateFile(wininit,
|
hfile = CreateFile(wininit,
|
||||||
GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
|
GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
|
||||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
@ -275,11 +276,11 @@ void DeleteFileOnReboot(char *pszFile)
|
||||||
|
|
||||||
if (hfilemap != NULL)
|
if (hfilemap != NULL)
|
||||||
{
|
{
|
||||||
LPSTR pszWinInit = (LPSTR) MapViewOfFile(hfilemap, FILE_MAP_WRITE, 0, 0, 0);
|
LPTSTR pszWinInit = (LPTSTR) MapViewOfFile(hfilemap, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
|
|
||||||
if (pszWinInit != NULL)
|
if (pszWinInit != NULL)
|
||||||
{
|
{
|
||||||
LPSTR pszRenameSecInFile = mystrstri(pszWinInit, szRenameSec);
|
LPTSTR pszRenameSecInFile = mystrstri(pszWinInit, szRenameSec);
|
||||||
if (pszRenameSecInFile == NULL)
|
if (pszRenameSecInFile == NULL)
|
||||||
{
|
{
|
||||||
lstrcpy(pszWinInit+dwFileSize, szRenameSec);
|
lstrcpy(pszWinInit+dwFileSize, szRenameSec);
|
||||||
|
@ -288,11 +289,11 @@ void DeleteFileOnReboot(char *pszFile)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *pszFirstRenameLine = pszRenameSecInFile+10;
|
TCHAR *pszFirstRenameLine = pszRenameSecInFile+10;
|
||||||
char *pszNextSec = mystrstri(pszFirstRenameLine,"\n[");
|
TCHAR *pszNextSec = mystrstri(pszFirstRenameLine,_T("\n["));
|
||||||
if (pszNextSec)
|
if (pszNextSec)
|
||||||
{
|
{
|
||||||
char *p = ++pszNextSec;
|
TCHAR *p = ++pszNextSec;
|
||||||
while (p < pszWinInit + dwFileSize) {
|
while (p < pszWinInit + dwFileSize) {
|
||||||
p[cchRenameLine] = *p;
|
p[cchRenameLine] = *p;
|
||||||
p++;
|
p++;
|
||||||
|
|
|
@ -3,19 +3,20 @@
|
||||||
NSIS plug-in for Type Library Registration/UnRegistration
|
NSIS plug-in for Type Library Registration/UnRegistration
|
||||||
Written by Joost Verburg
|
Written by Joost Verburg
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/23/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
#include <nsis/nsis_tchar.h>
|
||||||
|
|
||||||
#define NSISFunction(funcname) extern "C" void __declspec(dllexport) funcname(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
#define NSISFunction(funcname) extern "C" void __declspec(dllexport) funcname(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||||
|
|
||||||
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
extern "C" BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
|
||||||
|
|
||||||
NSISFunction(Register) {
|
NSISFunction(Register) {
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
@ -107,11 +108,11 @@ NSISFunction(GetLibVersion) {
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
|
||||||
char buf[33];
|
TCHAR buf[33];
|
||||||
|
|
||||||
wsprintf(buf, "%d", typelibAttr->wMajorVerNum);
|
wsprintf(buf, _T("%d"), typelibAttr->wMajorVerNum);
|
||||||
pushstring(buf);
|
pushstring(buf);
|
||||||
wsprintf(buf, "%d", typelibAttr->wMinorVerNum);
|
wsprintf(buf, _T("%d"), typelibAttr->wMinorVerNum);
|
||||||
pushstring(buf);
|
pushstring(buf);
|
||||||
|
|
||||||
typeLib->ReleaseTLibAttr(typelibAttr);
|
typeLib->ReleaseTLibAttr(typelibAttr);
|
||||||
|
@ -119,8 +120,8 @@ NSISFunction(GetLibVersion) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring("0");
|
pushstring(_T("0"));
|
||||||
pushstring("0");
|
pushstring(_T("0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
typeLib->Release();
|
typeLib->Release();
|
||||||
|
@ -128,8 +129,8 @@ NSISFunction(GetLibVersion) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring("0");
|
pushstring(_T("0"));
|
||||||
pushstring("0");
|
pushstring(_T("0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
// Unicode support by Jim Park -- 08/23/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define CBL(x) {x,#x}
|
#define CBL(x) {x,_T(#x)}
|
||||||
|
|
||||||
struct line {
|
struct line {
|
||||||
unsigned short id;
|
unsigned short id;
|
||||||
char *name;
|
TCHAR *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
line primary[] = {
|
line primary[] = {
|
||||||
|
@ -201,17 +204,17 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
|
||||||
}
|
}
|
||||||
else if (HIWORD(wParam) == CBN_SELCHANGE) {
|
else if (HIWORD(wParam) == CBN_SELCHANGE) {
|
||||||
if (SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0) != CB_ERR && SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0) != CB_ERR) {
|
if (SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0) != CB_ERR && SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0) != CB_ERR) {
|
||||||
char lang[512];
|
TCHAR lang[512];
|
||||||
wsprintf(lang, "Language ID: %d", MAKELANGID(primary[SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0)].id, sub[SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0)].id));
|
wsprintf(lang, _T("Language ID: %d"), MAKELANGID(primary[SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0)].id, sub[SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0)].id));
|
||||||
SetDlgItemText(hwndDlg, IDC_RESULT, lang);
|
SetDlgItemText(hwndDlg, IDC_RESULT, lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (LOWORD(wParam) == IDOK) {
|
else if (LOWORD(wParam) == IDOK) {
|
||||||
if (SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0) != CB_ERR && SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0) != CB_ERR) {
|
if (SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0) != CB_ERR && SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0) != CB_ERR) {
|
||||||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, 16);
|
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, 16*sizeof(TCHAR));
|
||||||
if (!hMem) return 0;
|
if (!hMem) return 0;
|
||||||
char *lang_id = (char *)GlobalLock(hMem);
|
TCHAR *lang_id = (TCHAR *)GlobalLock(hMem);
|
||||||
wsprintf(lang_id, "%u", MAKELANGID(primary[SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0)].id, sub[SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0)].id));
|
wsprintf(lang_id, _T("%u"), MAKELANGID(primary[SendDlgItemMessage(hwndDlg, IDC_PRIMARY, CB_GETCURSEL, 0, 0)].id, sub[SendDlgItemMessage(hwndDlg, IDC_SUB, CB_GETCURSEL, 0, 0)].id));
|
||||||
GlobalUnlock(hMem);
|
GlobalUnlock(hMem);
|
||||||
if (!OpenClipboard(hwndDlg)) return 0;
|
if (!OpenClipboard(hwndDlg)) return 0;
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
|
@ -224,9 +227,9 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
LPSTR lpCmdLine,
|
LPTSTR lpCmdLine,
|
||||||
int nCmdShow)
|
int nCmdShow)
|
||||||
{
|
{
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/17/2007
|
||||||
|
|
||||||
#define _WIN32_IE 0x0400
|
#define _WIN32_IE 0x0400
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
** License: see jnetlib.h
|
** 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 "netinc.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -57,14 +60,14 @@ int JNL_AsyncDNS::resolve(char *hostname, unsigned long *addr)
|
||||||
return 0;
|
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 == INADDR_NONE) return -1;
|
||||||
else if (m_addr)
|
else if (m_addr)
|
||||||
{
|
{
|
||||||
*addr=m_addr;
|
*addr=m_addr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lstrcpy(m_hostname,hostname);
|
lstrcpyA(m_hostname,hostname);
|
||||||
|
|
||||||
if (m_thread_kill)
|
if (m_thread_kill)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
** 4. enjoy.
|
** 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_
|
#ifndef _ASYNCDNS_H_
|
||||||
#define _ASYNCDNS_H_
|
#define _ASYNCDNS_H_
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: connection.cpp - JNL TCP connection implementation
|
** File: connection.cpp - JNL TCP connection implementation
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
|
**
|
||||||
|
** Reviewed for Unicode support by Jim Park -- 08/17/2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "netinc.h"
|
#include "netinc.h"
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
** make the socket close after sending all the data sent.
|
** make the socket close after sending all the data sent.
|
||||||
**
|
**
|
||||||
** 8. delete ye' ol' object.
|
** 8. delete ye' ol' object.
|
||||||
|
**
|
||||||
|
** Reviewed for Unicode Support by Jim Park -- 08/17/2007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CONNECTION_H_
|
#ifndef _CONNECTION_H_
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: httpget.cpp - JNL HTTP GET implementation
|
** File: httpget.cpp - JNL HTTP GET implementation
|
||||||
** License: see jnetlib.h
|
** 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"
|
#include "netinc.h"
|
||||||
|
@ -181,14 +187,14 @@ void JNL_HTTPGet::connect(char *url)
|
||||||
|
|
||||||
if (!m_http_proxyhost || !m_http_proxyhost[0])
|
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
|
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])
|
if (m_http_lpinfo&&m_http_lpinfo[0])
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,6 +37,12 @@
|
||||||
** note that user, pass, port, and /requestwhatever are all optional :)
|
** note that user, pass, port, and /requestwhatever are all optional :)
|
||||||
** note that also, http:// is really not important. if you do poo://
|
** note that also, http:// is really not important. if you do poo://
|
||||||
** or even leave out the http:// altogether, it will still work.
|
** 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_
|
#ifndef _HTTPGET_H_
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: netinc.h - network includes and portability defines (used internally)
|
** File: netinc.h - network includes and portability defines (used internally)
|
||||||
** License: see jnetlib.h
|
** 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_
|
#ifndef _NETINC_H_
|
||||||
|
@ -72,10 +78,10 @@ extern void mini_memset(void *,char,int);
|
||||||
extern void mini_memcpy(void *,void*,int);
|
extern void mini_memcpy(void *,void*,int);
|
||||||
#define memset mini_memset
|
#define memset mini_memset
|
||||||
#define memcpy mini_memcpy
|
#define memcpy mini_memcpy
|
||||||
#define strcpy lstrcpy
|
#define strcpy lstrcpyA
|
||||||
#define strncpy lstrcpyn
|
#define strncpy lstrcpynA
|
||||||
#define strcat lstrcat
|
#define strcat lstrcatA
|
||||||
#define strlen lstrlen
|
#define strlen lstrlenA
|
||||||
#define malloc(x) GlobalAlloc(GPTR,(x))
|
#define malloc(x) GlobalAlloc(GPTR,(x))
|
||||||
#define free(x) { if (x) GlobalFree(x); }
|
#define free(x) { if (x) GlobalFree(x); }
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: util.cpp - JNL implementation of basic network utilities
|
** File: util.cpp - JNL implementation of basic network utilities
|
||||||
** License: see jnetlib.h
|
** 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"
|
#include "netinc.h"
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
|
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
|
||||||
** gives you the dotted decimal notation of an integer ip address.
|
** 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_
|
#ifndef _UTIL_H_
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/18/2007
|
||||||
*/
|
*/
|
||||||
#define MAKENSISW_CPP
|
#define MAKENSISW_CPP
|
||||||
|
|
||||||
|
@ -34,7 +36,7 @@ NFINDREPLACE g_find;
|
||||||
extern NTOOLBAR g_toolbar;
|
extern NTOOLBAR g_toolbar;
|
||||||
int g_symbol_set_mode;
|
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;
|
MSG msg;
|
||||||
int status;
|
int status;
|
||||||
HACCEL haccel;
|
HACCEL haccel;
|
||||||
|
@ -44,19 +46,19 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char *cmdParam, int cmd
|
||||||
my_memset(&g_find,0,sizeof(NFINDREPLACE));
|
my_memset(&g_find,0,sizeof(NFINDREPLACE));
|
||||||
g_sdata.hInstance=GetModuleHandle(0);
|
g_sdata.hInstance=GetModuleHandle(0);
|
||||||
g_sdata.symbols = NULL;
|
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();
|
RestoreSymbols();
|
||||||
|
|
||||||
HINSTANCE hRichEditDLL = LoadLibrary("RichEd32.dll");
|
HINSTANCE hRichEditDLL = LoadLibrary(_T("RichEd32.dll"));
|
||||||
|
|
||||||
if (!InitBranding()) {
|
if (!InitBranding()) {
|
||||||
MessageBox(0,NSISERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
|
MessageBox(0,NSISERROR,_T("Error"),MB_ICONEXCLAMATION|MB_OK);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ResetObjects();
|
ResetObjects();
|
||||||
HWND hDialog = CreateDialog(g_sdata.hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
|
HWND hDialog = CreateDialog(g_sdata.hInstance,MAKEINTRESOURCE(DLG_MAIN),0,DialogProc);
|
||||||
if (!hDialog) {
|
if (!hDialog) {
|
||||||
MessageBox(0,DLGERROR,"Error",MB_ICONEXCLAMATION|MB_OK);
|
MessageBox(0,DLGERROR,_T("Error"),MB_ICONEXCLAMATION|MB_OK);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
haccel = LoadAccelerators(g_sdata.hInstance, MAKEINTRESOURCE(IDK_ACCEL));
|
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;
|
return msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScript(const char *script, bool clearArgs /*= true*/)
|
void SetScript(const TCHAR *script, bool clearArgs /*= true*/)
|
||||||
{
|
{
|
||||||
if (g_sdata.script)
|
if (g_sdata.script)
|
||||||
{
|
{
|
||||||
|
@ -94,24 +96,25 @@ void SetScript(const char *script, bool clearArgs /*= true*/)
|
||||||
GlobalFree(g_sdata.script_cmd_args);
|
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);
|
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,
|
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);
|
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, arg);
|
||||||
lstrcat(args, "\"");
|
lstrcat(args, _T("\""));
|
||||||
|
|
||||||
GlobalUnlock(g_sdata.script_cmd_args);
|
GlobalUnlock(g_sdata.script_cmd_args);
|
||||||
}
|
}
|
||||||
|
@ -119,23 +122,23 @@ void AddScriptCmdArgs(const char *arg)
|
||||||
void ProcessCommandLine()
|
void ProcessCommandLine()
|
||||||
{
|
{
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
TCHAR **argv;
|
||||||
int i, j;
|
int i, j;
|
||||||
int argSpaceSize;
|
int argSpaceSize;
|
||||||
|
|
||||||
argSpaceSize = SetArgv((char *)GetCommandLine(), &argc, &argv);
|
argSpaceSize = SetArgv((TCHAR *)GetCommandLine(), &argc, &argv);
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
for (i = 1; i < argc; i++)
|
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 ");
|
TCHAR *p = argv[i] + lstrlen(_T("/XSetCompressor "));
|
||||||
if(!lstrncmpi(p,"/FINAL ", lstrlen("/FINAL ")))
|
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++)
|
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;
|
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]);
|
AddScriptCmdArgs(argv[i]);
|
||||||
}
|
}
|
||||||
|
@ -185,11 +188,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
CreateToolBar();
|
CreateToolBar();
|
||||||
InitTooltips(g_sdata.hwnd);
|
InitTooltips(g_sdata.hwnd);
|
||||||
SetBranding(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);
|
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,WM_SETFONT,(WPARAM)hFont,0);
|
||||||
RestoreWindowPos(g_sdata.hwnd);
|
RestoreWindowPos(g_sdata.hwnd);
|
||||||
RestoreCompressor();
|
RestoreCompressor();
|
||||||
SetScript("");
|
SetScript(_T(""));
|
||||||
g_sdata.compressor = COMPRESSOR_NONE_SELECTED;
|
g_sdata.compressor = COMPRESSOR_NONE_SELECTED;
|
||||||
g_sdata.userSelectCompressor = FALSE;
|
g_sdata.userSelectCompressor = FALSE;
|
||||||
|
|
||||||
|
@ -243,7 +246,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
case WM_DROPFILES: {
|
case WM_DROPFILES: {
|
||||||
int num;
|
int num;
|
||||||
char szTmp[MAX_PATH];
|
TCHAR szTmp[MAX_PATH];
|
||||||
num = DragQueryFile((HDROP)wParam,(UINT)-1,NULL,0);
|
num = DragQueryFile((HDROP)wParam,(UINT)-1,NULL,0);
|
||||||
if (num==1) {
|
if (num==1) {
|
||||||
DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH);
|
DragQueryFile((HDROP)wParam,0,szTmp,MAX_PATH);
|
||||||
|
@ -254,7 +257,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
CompileNSISScript();
|
CompileNSISScript();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageBox(hwndDlg,MULTIDROPERROR,"Error",MB_OK|MB_ICONSTOP);
|
MessageBox(hwndDlg,MULTIDROPERROR,_T("Error"),MB_OK|MB_ICONSTOP);
|
||||||
}
|
}
|
||||||
DragFinish((HDROP)wParam);
|
DragFinish((HDROP)wParam);
|
||||||
break;
|
break;
|
||||||
|
@ -267,7 +270,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
case WM_ENTERSIZEMOVE:
|
case WM_ENTERSIZEMOVE:
|
||||||
{
|
{
|
||||||
GetClientRect(g_sdata.hwnd, &g_resize.resizeRect);
|
GetClientRect(g_sdata.hwnd, &g_resize.resizeRect);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_SIZE:
|
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.compressor == COMPRESSOR_BEST) {
|
||||||
if (g_sdata.retcode==0 && FileExists(g_sdata.output_exe)) {
|
if (g_sdata.retcode==0 && FileExists(g_sdata.output_exe)) {
|
||||||
char temp_file_name[1024];
|
TCHAR temp_file_name[1024];
|
||||||
wsprintf(temp_file_name,"%s_makensisw_temp",g_sdata.output_exe);
|
wsprintf(temp_file_name,_T("%s_makensisw_temp"),g_sdata.output_exe);
|
||||||
if(!lstrcmpi(g_sdata.compressor_name,compressor_names[(int)COMPRESSOR_SCRIPT+1])) {
|
if(!lstrcmpi(g_sdata.compressor_name,compressor_names[(int)COMPRESSOR_SCRIPT+1])) {
|
||||||
SetCompressorStats();
|
SetCompressorStats();
|
||||||
CopyFile(g_sdata.output_exe,temp_file_name,false);
|
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)) {
|
if(this_compressor == ((int)COMPRESSOR_BEST - 1)) {
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
|
|
||||||
g_sdata.compressor_name = compressor_names[(int)COMPRESSOR_SCRIPT+1];
|
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);
|
LogMessage(g_sdata.hwnd, g_sdata.compressor_stats);
|
||||||
}
|
}
|
||||||
DeleteFile(temp_file_name);
|
DeleteFile(temp_file_name);
|
||||||
lstrcpy(g_sdata.compressor_stats,"");
|
lstrcpy(g_sdata.compressor_stats,_T(""));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
g_sdata.compressor_name = compressor_names[this_compressor+1];
|
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) {
|
if (!g_sdata.retcode) {
|
||||||
MessageBeep(MB_ICONASTERISK);
|
MessageBeep(MB_ICONASTERISK);
|
||||||
if (g_sdata.warnings)
|
if (g_sdata.warnings)
|
||||||
SetTitle(g_sdata.hwnd,"Finished with Warnings");
|
SetTitle(g_sdata.hwnd,_T("Finished with Warnings"));
|
||||||
else
|
else
|
||||||
SetTitle(g_sdata.hwnd,"Finished Sucessfully");
|
SetTitle(g_sdata.hwnd,_T("Finished Sucessfully"));
|
||||||
// Added by Darren Owen (DrO) on 1/10/2003
|
// Added by Darren Owen (DrO) on 1/10/2003
|
||||||
if(g_sdata.recompile_test)
|
if(g_sdata.recompile_test)
|
||||||
PostMessage(g_sdata.hwnd, WM_COMMAND, LOWORD(IDC_TEST), 0);
|
PostMessage(g_sdata.hwnd, WM_COMMAND, LOWORD(IDC_TEST), 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBeep(MB_ICONEXCLAMATION);
|
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
|
// 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) {
|
switch (cds->dwData) {
|
||||||
case MAKENSIS_NOTIFY_SCRIPT:
|
case MAKENSIS_NOTIFY_SCRIPT:
|
||||||
if (g_sdata.input_script) GlobalFree(g_sdata.input_script);
|
if (g_sdata.input_script) GlobalFree(g_sdata.input_script);
|
||||||
g_sdata.input_script = (char *)GlobalAlloc(GPTR, cds->cbData);
|
g_sdata.input_script = (TCHAR *)GlobalAlloc(GPTR, cds->cbData * sizeof(TCHAR));
|
||||||
lstrcpy(g_sdata.input_script, (char *)cds->lpData);
|
lstrcpy(g_sdata.input_script, (TCHAR *)cds->lpData);
|
||||||
break;
|
break;
|
||||||
case MAKENSIS_NOTIFY_WARNING:
|
case MAKENSIS_NOTIFY_WARNING:
|
||||||
g_sdata.warnings++;
|
g_sdata.warnings++;
|
||||||
|
@ -465,8 +468,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
break;
|
break;
|
||||||
case MAKENSIS_NOTIFY_OUTPUT:
|
case MAKENSIS_NOTIFY_OUTPUT:
|
||||||
if (g_sdata.output_exe) GlobalFree(g_sdata.output_exe);
|
if (g_sdata.output_exe) GlobalFree(g_sdata.output_exe);
|
||||||
g_sdata.output_exe = (char *)GlobalAlloc(GPTR, cds->cbData);
|
g_sdata.output_exe = (TCHAR *)GlobalAlloc(GPTR, cds->cbData * sizeof(TCHAR));
|
||||||
lstrcpy(g_sdata.output_exe, (char *)cds->lpData);
|
lstrcpy(g_sdata.output_exe, (TCHAR *)cds->lpData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -476,11 +479,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
switch (LOWORD(wParam)) {
|
switch (LOWORD(wParam)) {
|
||||||
case IDM_BROWSESCR: {
|
case IDM_BROWSESCR: {
|
||||||
if (g_sdata.input_script) {
|
if (g_sdata.input_script) {
|
||||||
char str[MAX_PATH],*str2;
|
TCHAR str[MAX_PATH],*str2;
|
||||||
lstrcpy(str,g_sdata.input_script);
|
lstrcpy(str,g_sdata.input_script);
|
||||||
str2=my_strrchr(str,'\\');
|
str2=my_strrchr(str,_T('\\'));
|
||||||
if(str2!=NULL) *(str2+1)=0;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -491,12 +494,12 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
case IDM_NSISHOME:
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case IDM_FORUM:
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case IDM_NSISUPDATE:
|
case IDM_NSISUPDATE:
|
||||||
|
@ -518,17 +521,17 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
{
|
{
|
||||||
if (!g_sdata.thread) {
|
if (!g_sdata.thread) {
|
||||||
OPENFILENAME l={sizeof(l),};
|
OPENFILENAME l={sizeof(l),};
|
||||||
char buf[MAX_PATH];
|
TCHAR buf[MAX_PATH];
|
||||||
l.hwndOwner = hwndDlg;
|
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.lpstrFile = buf;
|
||||||
l.nMaxFile = MAX_STRING-1;
|
l.nMaxFile = MAX_STRING-1;
|
||||||
l.lpstrTitle = "Load Script";
|
l.lpstrTitle = _T("Load Script");
|
||||||
l.lpstrDefExt = "log";
|
l.lpstrDefExt = _T("log");
|
||||||
l.lpstrFileTitle = NULL;
|
l.lpstrFileTitle = NULL;
|
||||||
l.lpstrInitialDir = NULL;
|
l.lpstrInitialDir = NULL;
|
||||||
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
|
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
|
||||||
lstrcpy(buf,"");
|
lstrcpy(buf,_T(""));
|
||||||
if (GetOpenFileName(&l)) {
|
if (GetOpenFileName(&l)) {
|
||||||
SetScript(buf);
|
SetScript(buf);
|
||||||
PushMRUFile(g_sdata.script);
|
PushMRUFile(g_sdata.script);
|
||||||
|
@ -582,18 +585,18 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
case IDC_TEST:
|
case IDC_TEST:
|
||||||
{
|
{
|
||||||
if (g_sdata.output_exe) {
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case IDM_EDITSCRIPT:
|
case IDM_EDITSCRIPT:
|
||||||
{
|
{
|
||||||
if (g_sdata.input_script) {
|
if (g_sdata.input_script) {
|
||||||
if ((int)ShellExecute(g_sdata.hwnd,"open",g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
|
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),g_sdata.input_script,NULL,NULL,SW_SHOWNORMAL)<=32) {
|
||||||
char path[MAX_PATH];
|
TCHAR path[MAX_PATH];
|
||||||
if (GetWindowsDirectory(path,sizeof(path))) {
|
if (GetWindowsDirectory(path,sizeof(path))) {
|
||||||
lstrcat(path,"\\notepad.exe");
|
lstrcat(path,_T("\\notepad.exe"));
|
||||||
ShellExecute(g_sdata.hwnd,"open",path,g_sdata.input_script,NULL,SW_SHOWNORMAL);
|
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:
|
case IDM_SAVE:
|
||||||
{
|
{
|
||||||
OPENFILENAME l={sizeof(l),};
|
OPENFILENAME l={sizeof(l),};
|
||||||
char buf[MAX_STRING];
|
TCHAR buf[MAX_STRING];
|
||||||
l.hwndOwner = hwndDlg;
|
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.lpstrFile = buf;
|
||||||
l.nMaxFile = MAX_STRING-1;
|
l.nMaxFile = MAX_STRING-1;
|
||||||
l.lpstrTitle = "Save Output";
|
l.lpstrTitle = _T("Save Output");
|
||||||
l.lpstrDefExt = "log";
|
l.lpstrDefExt = _T("log");
|
||||||
l.lpstrInitialDir = NULL;
|
l.lpstrInitialDir = NULL;
|
||||||
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST;
|
l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST;
|
||||||
lstrcpy(buf,"output");
|
lstrcpy(buf,_T("output"));
|
||||||
if (GetSaveFileName(&l)) {
|
if (GetSaveFileName(&l)) {
|
||||||
HANDLE hFile = CreateFile(buf,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
|
HANDLE hFile = CreateFile(buf,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0);
|
||||||
if (hFile) {
|
if (hFile) {
|
||||||
int len=SendDlgItemMessage(g_sdata.hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
|
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;
|
existing_text[0]=0;
|
||||||
GetDlgItemText(g_sdata.hwnd, IDC_LOGWIN, existing_text, len);
|
GetDlgItemText(g_sdata.hwnd, IDC_LOGWIN, existing_text, len);
|
||||||
DWORD dwWritten = 0;
|
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.lStructSize = sizeof(FINDREPLACE);
|
||||||
g_find.fr.hwndOwner = hwndDlg;
|
g_find.fr.hwndOwner = hwndDlg;
|
||||||
g_find.fr.Flags = FR_NOUPDOWN;
|
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;
|
if (!g_find.fr.lpstrFindWhat) return TRUE;
|
||||||
g_find.fr.wFindWhatLen = 128;
|
g_find.fr.wFindWhatLen = 128;
|
||||||
g_find.hwndFind = FindText(&g_find.fr);
|
g_find.hwndFind = FindText(&g_find.fr);
|
||||||
|
@ -716,12 +719,12 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||||
else sa.lpSecurityDescriptor = NULL;
|
else sa.lpSecurityDescriptor = NULL;
|
||||||
sa.bInheritHandle = true;
|
sa.bInheritHandle = true;
|
||||||
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
|
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);
|
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!CreatePipe(&read_stdin,&newstdin,&sa,0)) {
|
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);
|
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -732,8 +735,8 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||||
si.hStdError = newstdout;
|
si.hStdError = newstdout;
|
||||||
si.hStdInput = newstdin;
|
si.hStdInput = newstdin;
|
||||||
if (!CreateProcess(NULL,g_sdata.compile_command,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
|
if (!CreateProcess(NULL,g_sdata.compile_command,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
|
||||||
char buf[MAX_STRING];
|
TCHAR buf[MAX_STRING];
|
||||||
wsprintf(buf,"Could not execute:\r\n %s.",g_sdata.compile_command);
|
wsprintf(buf,_T("Could not execute:\r\n %s."),g_sdata.compile_command);
|
||||||
ErrorMessage(g_sdata.hwnd,buf);
|
ErrorMessage(g_sdata.hwnd,buf);
|
||||||
CloseHandle(newstdout);
|
CloseHandle(newstdout);
|
||||||
CloseHandle(read_stdout);
|
CloseHandle(read_stdout);
|
||||||
|
@ -746,7 +749,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
||||||
while (dwExit == STILL_ACTIVE || dwRead) {
|
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||||
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
||||||
if (dwRead) {
|
if (dwRead) {
|
||||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
ReadFile(read_stdout, szBuf, sizeof(szBuf)-sizeof(TCHAR), &dwRead, NULL);
|
||||||
szBuf[dwRead] = 0;
|
szBuf[dwRead] = 0;
|
||||||
LogMessage(g_sdata.hwnd, szBuf);
|
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,
|
HFONT bfont = CreateFont(13,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
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,
|
HFONT bfontb = CreateFont(13,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
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,
|
HFONT rfont = CreateFont(12,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
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,
|
HFONT rfontb = CreateFont(12,0,0,0,FW_BOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
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) {
|
if (bfont&&bfontb) {
|
||||||
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)bfontb, FALSE);
|
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)bfontb, FALSE);
|
||||||
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)bfont, 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;
|
int i = 0;
|
||||||
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_RESETCONTENT , 0, 0);
|
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_RESETCONTENT , 0, 0);
|
||||||
|
@ -892,16 +895,16 @@ void SetSymbols(HWND hwndDlg, char **symbols)
|
||||||
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
EnableWindow(GetDlgItem(hwndDlg, IDDEL), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **GetSymbols(HWND hwndDlg)
|
TCHAR **GetSymbols(HWND hwndDlg)
|
||||||
{
|
{
|
||||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCOUNT, 0, 0);
|
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCOUNT, 0, 0);
|
||||||
char **symbols = NULL;
|
TCHAR **symbols = NULL;
|
||||||
if(n > 0) {
|
if(n > 0) {
|
||||||
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (n+1)*sizeof(char *));
|
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (n+1)*sizeof(TCHAR *));
|
||||||
symbols = (char **)GlobalLock(hMem);
|
symbols = (TCHAR **)GlobalLock(hMem);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
int len = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)i, 0);
|
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]);
|
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)i, (LPARAM)symbols[i]);
|
||||||
}
|
}
|
||||||
symbols[n] = NULL;
|
symbols[n] = NULL;
|
||||||
|
@ -928,8 +931,8 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
case WM_MAKENSIS_LOADSYMBOLSET:
|
case WM_MAKENSIS_LOADSYMBOLSET:
|
||||||
{
|
{
|
||||||
char *name = (char *)wParam;
|
TCHAR *name = (TCHAR *)wParam;
|
||||||
char **symbols = LoadSymbolSet(name);
|
TCHAR **symbols = LoadSymbolSet(name);
|
||||||
HGLOBAL hMem;
|
HGLOBAL hMem;
|
||||||
|
|
||||||
SetSymbols(hwndDlg, symbols);
|
SetSymbols(hwndDlg, symbols);
|
||||||
|
@ -942,8 +945,8 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
case WM_MAKENSIS_SAVESYMBOLSET:
|
case WM_MAKENSIS_SAVESYMBOLSET:
|
||||||
{
|
{
|
||||||
char *name = (char *)wParam;
|
TCHAR *name = (TCHAR *)wParam;
|
||||||
char **symbols = GetSymbols(hwndDlg);
|
TCHAR **symbols = GetSymbols(hwndDlg);
|
||||||
HGLOBAL hMem;
|
HGLOBAL hMem;
|
||||||
|
|
||||||
if(symbols) {
|
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);
|
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXTLENGTH, 0, 0);
|
||||||
if(n > 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);
|
SendDlgItemMessage(hwndDlg, IDC_SYMBOL, WM_GETTEXT, n+1, (LPARAM)buf);
|
||||||
if(my_strstr(buf," ") || my_strstr(buf,"\t")) {
|
if(my_strstr(buf,_T(" ")) || my_strstr(buf,_T("\t"))) {
|
||||||
MessageBox(hwndDlg,SYMBOLSERROR,"Error",MB_OK|MB_ICONSTOP);
|
MessageBox(hwndDlg,SYMBOLSERROR,_T("Error"),MB_OK|MB_ICONSTOP);
|
||||||
GlobalFree(buf);
|
GlobalFree(buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXTLENGTH, 0, 0);
|
n = SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXTLENGTH, 0, 0);
|
||||||
if(n > 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);
|
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXT, n+1, (LPARAM)buf2);
|
||||||
char *buf3 = (char *)GlobalAlloc(GPTR, (lstrlen(buf)+lstrlen(buf2)+2)*sizeof(char));
|
TCHAR *buf3 = (TCHAR *)GlobalAlloc(GPTR, (lstrlen(buf)+lstrlen(buf2)+2)*sizeof(TCHAR));
|
||||||
wsprintf(buf3,"%s=%s",buf,buf2);
|
wsprintf(buf3,_T("%s=%s"),buf,buf2);
|
||||||
GlobalFree(buf);
|
GlobalFree(buf);
|
||||||
buf = buf3;
|
buf = buf3;
|
||||||
GlobalFree(buf2);
|
GlobalFree(buf2);
|
||||||
|
@ -1023,9 +1026,9 @@ BOOL CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
if(num == 1) {
|
if(num == 1) {
|
||||||
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)index, 0);
|
int n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXTLEN, (WPARAM)index, 0);
|
||||||
if(n > 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);
|
SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETTEXT, (WPARAM)index, (LPARAM)buf);
|
||||||
char *p = my_strstr(buf,"=");
|
TCHAR *p = my_strstr(buf,_T("="));
|
||||||
if(p) {
|
if(p) {
|
||||||
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
|
SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_SETTEXT, 0, (LPARAM)(p+1));
|
||||||
*p=0;
|
*p=0;
|
||||||
|
@ -1157,7 +1160,7 @@ BOOL CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
|
||||||
HKEY hSubKey;
|
HKEY hSubKey;
|
||||||
|
|
||||||
if (RegOpenKeyEx(hKey,REGSYMSUBKEY,0,KEY_READ,&hSubKey) == ERROR_SUCCESS) {
|
if (RegOpenKeyEx(hKey,REGSYMSUBKEY,0,KEY_READ,&hSubKey) == ERROR_SUCCESS) {
|
||||||
char subkey[1024];
|
TCHAR subkey[1024];
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
while (RegEnumKey(hSubKey,i,subkey,sizeof(subkey)) == ERROR_SUCCESS) {
|
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:
|
case IDOK:
|
||||||
{
|
{
|
||||||
HWND hwndEdit;
|
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), 0, 0, 0); // Handle of list
|
||||||
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
|
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);
|
int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0);
|
||||||
if(n != CB_ERR) {
|
if(n != CB_ERR) {
|
||||||
long len = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXTLEN, (WPARAM)n, 0);
|
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) {
|
if(SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXT, (WPARAM)n, (LPARAM)buf) != CB_ERR) {
|
||||||
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_DELETESTRING, n, 0);
|
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_DELETESTRING, n, 0);
|
||||||
DeleteSymbolSet(buf);
|
DeleteSymbolSet(buf);
|
||||||
|
@ -1269,7 +1272,7 @@ void SetCompressor(NCOMPRESSOR compressor)
|
||||||
|
|
||||||
if(g_sdata.compressor != compressor) {
|
if(g_sdata.compressor != compressor) {
|
||||||
WORD command;
|
WORD command;
|
||||||
char *compressor_name;
|
TCHAR *compressor_name;
|
||||||
|
|
||||||
if(compressor > COMPRESSOR_SCRIPT && compressor < COMPRESSOR_BEST) {
|
if(compressor > COMPRESSOR_SCRIPT && compressor < COMPRESSOR_BEST) {
|
||||||
command = compressor_commands[(int)compressor];
|
command = compressor_commands[(int)compressor];
|
||||||
|
@ -1282,7 +1285,7 @@ void SetCompressor(NCOMPRESSOR compressor)
|
||||||
else {
|
else {
|
||||||
compressor = COMPRESSOR_SCRIPT;
|
compressor = COMPRESSOR_SCRIPT;
|
||||||
command = IDM_COMPRESSOR_SCRIPT;
|
command = IDM_COMPRESSOR_SCRIPT;
|
||||||
compressor_name = "";
|
compressor_name = _T("");
|
||||||
}
|
}
|
||||||
g_sdata.compressor = compressor;
|
g_sdata.compressor = compressor;
|
||||||
g_sdata.compressor_name = compressor_name;
|
g_sdata.compressor_name = compressor_name;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/10/2007
|
||||||
*/
|
*/
|
||||||
#ifndef MAKENSIS_H
|
#ifndef MAKENSIS_H
|
||||||
#define MAKENSIS_H
|
#define MAKENSIS_H
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
#define _WIN32_IE 0x0400
|
#define _WIN32_IE 0x0400
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#define _RICHEDIT_VER 0x0200
|
#define _RICHEDIT_VER 0x0200
|
||||||
#include <richedit.h>
|
#include <richedit.h>
|
||||||
|
@ -35,39 +37,39 @@
|
||||||
#define NSIS_FOR "http://forums.winamp.com/forumdisplay.php?forumid=65"
|
#define NSIS_FOR "http://forums.winamp.com/forumdisplay.php?forumid=65"
|
||||||
#define NSIS_UPDATE "http://nsis.sourceforge.net/update.php?version="
|
#define NSIS_UPDATE "http://nsis.sourceforge.net/update.php?version="
|
||||||
#define NSIS_DL_URL "http://nsis.sourceforge.net/download/"
|
#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 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 "Copyright © 2002 Robert Rainwater"
|
#define COPYRIGHT _T("Copyright © 2002 Robert Rainwater")
|
||||||
#define CONTRIB "Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg"
|
#define CONTRIB _T("Fritz Elfert, Justin Frankel, Amir Szekely, Sunil Kamath, Joost Verburg")
|
||||||
#define DOCPATH "http://nsis.sourceforge.net/Docs/"
|
#define DOCPATH "http://nsis.sourceforge.net/Docs/"
|
||||||
#define LOCALDOCS "\\NSIS.chm"
|
#define LOCALDOCS _T("\\NSIS.chm")
|
||||||
#define NSISERROR "Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe."
|
#define NSISERROR _T("Unable to intialize MakeNSIS. Please verify that makensis.exe is in the same directory as makensisw.exe.")
|
||||||
#define DLGERROR "Unable to intialize MakeNSISW."
|
#define DLGERROR _T("Unable to intialize MakeNSISW.")
|
||||||
#define SYMBOLSERROR "Symbol cannot contain whitespace characters"
|
#define SYMBOLSERROR _T("Symbol cannot contain whitespace characters")
|
||||||
#define MULTIDROPERROR "Dropping more than one script at a time is not supported"
|
#define MULTIDROPERROR _T("Dropping more than one script at a time is not supported")
|
||||||
#define NSISUPDATEPROMPT "Running NSIS Update will close MakeNSISW.\nContinue?"
|
#define NSISUPDATEPROMPT _T("Running NSIS Update will close MakeNSISW.\nContinue?")
|
||||||
#define REGSEC HKEY_CURRENT_USER
|
#define REGSEC HKEY_CURRENT_USER
|
||||||
#define REGSECDEF HKEY_LOCAL_MACHINE
|
#define REGSECDEF HKEY_LOCAL_MACHINE
|
||||||
#define REGKEY "Software\\NSIS"
|
#define REGKEY _T("Software\\NSIS")
|
||||||
#define REGLOC "MakeNSISWPlacement"
|
#define REGLOC _T("MakeNSISWPlacement")
|
||||||
#define REGCOMPRESSOR "MakeNSISWCompressor"
|
#define REGCOMPRESSOR _T("MakeNSISWCompressor")
|
||||||
#define REGSYMSUBKEY "Symbols"
|
#define REGSYMSUBKEY _T("Symbols")
|
||||||
#define REGMRUSUBKEY "MRU"
|
#define REGMRUSUBKEY _T("MRU")
|
||||||
#define EXENAME "makensis.exe"
|
#define EXENAME _T("makensis.exe")
|
||||||
#define MAX_STRING 256
|
#define MAX_STRING 256
|
||||||
#define TIMEOUT 100
|
#define TIMEOUT 100
|
||||||
#define MINWIDTH 350
|
#define MINWIDTH 350
|
||||||
#define MINHEIGHT 180
|
#define MINHEIGHT 180
|
||||||
#define COMPRESSOR_MESSAGE "\n\nThe %s compressor created the smallest installer (%d bytes)."
|
#define COMPRESSOR_MESSAGE _T("\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 RESTORED_COMPRESSOR_MESSAGE _T("\n\nThe %s compressor created the smallest installer (%d bytes).")
|
||||||
#define EXE_HEADER_COMPRESSOR_STAT "EXE header size:"
|
#define EXE_HEADER_COMPRESSOR_STAT _T("EXE header size:")
|
||||||
#define TOTAL_SIZE_COMPRESSOR_STAT "Total size:"
|
#define TOTAL_SIZE_COMPRESSOR_STAT _T("Total size:")
|
||||||
#define SYMBOL_SET_NAME_MAXLEN 40
|
#define SYMBOL_SET_NAME_MAXLEN 40
|
||||||
#define LOAD_SYMBOL_SET_DLG_NAME "Load Symbol Definitions Set"
|
#define LOAD_SYMBOL_SET_DLG_NAME _T("Load Symbol Definitions Set")
|
||||||
#define SAVE_SYMBOL_SET_DLG_NAME "Save Symbol Definitions Set"
|
#define SAVE_SYMBOL_SET_DLG_NAME _T("Save Symbol Definitions Set")
|
||||||
#define LOAD_BUTTON_TEXT "Load"
|
#define LOAD_BUTTON_TEXT _T("Load")
|
||||||
#define SAVE_BUTTON_TEXT "Save"
|
#define SAVE_BUTTON_TEXT _T("Save")
|
||||||
#define LOAD_SYMBOL_SET_MESSAGE "Please select a name for the Symbol Definitions Set to load."
|
#define LOAD_SYMBOL_SET_MESSAGE _T("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 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_PROCESSCOMPLETE (WM_USER+1001)
|
||||||
#define WM_MAKENSIS_LOADSYMBOLSET (WM_USER+1002)
|
#define WM_MAKENSIS_LOADSYMBOLSET (WM_USER+1002)
|
||||||
|
@ -93,22 +95,22 @@ typedef enum {
|
||||||
} NCOMPRESSOR;
|
} NCOMPRESSOR;
|
||||||
|
|
||||||
#ifdef MAKENSISW_CPP
|
#ifdef MAKENSISW_CPP
|
||||||
char *compressor_names[] = {"",
|
TCHAR *compressor_names[] = {_T(""),
|
||||||
"zlib",
|
_T("zlib"),
|
||||||
"/SOLID zlib",
|
_T("/SOLID zlib"),
|
||||||
"bzip2",
|
_T("bzip2"),
|
||||||
"/SOLID bzip2",
|
_T("/SOLID bzip2"),
|
||||||
"lzma",
|
_T("lzma"),
|
||||||
"/SOLID lzma",
|
_T("/SOLID lzma"),
|
||||||
"Best"};
|
_T("Best")};
|
||||||
char *compressor_display_names[] = {"Defined in Script/Compiler Default",
|
TCHAR *compressor_display_names[] = {_T("Defined in Script/Compiler Default"),
|
||||||
"ZLIB",
|
_T("ZLIB"),
|
||||||
"ZLIB (solid)",
|
_T("ZLIB (solid)"),
|
||||||
"BZIP2",
|
_T("BZIP2"),
|
||||||
"BZIP2 (solid)",
|
_T("BZIP2 (solid)"),
|
||||||
"LZMA",
|
_T("LZMA"),
|
||||||
"LZMA (solid)",
|
_T("LZMA (solid)"),
|
||||||
"Best Compressor"};
|
_T("Best Compressor")};
|
||||||
WORD compressor_commands[] = {IDM_COMPRESSOR_SCRIPT,
|
WORD compressor_commands[] = {IDM_COMPRESSOR_SCRIPT,
|
||||||
IDM_ZLIB,
|
IDM_ZLIB,
|
||||||
IDM_ZLIB_SOLID,
|
IDM_ZLIB_SOLID,
|
||||||
|
@ -140,9 +142,9 @@ int compressor_strings[] = {IDS_SCRIPT,
|
||||||
|
|
||||||
// Extern Variables
|
// 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);
|
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
DWORD WINAPI MakeNSISProc(LPVOID p);
|
DWORD WINAPI MakeNSISProc(LPVOID p);
|
||||||
BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
|
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 SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL CALLBACK SymbolSetProc(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);
|
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();
|
void CompileNSISScript();
|
||||||
char* BuildSymbols();
|
TCHAR* BuildSymbols();
|
||||||
void SetCompressor(NCOMPRESSOR);
|
void SetCompressor(NCOMPRESSOR);
|
||||||
void RestoreSymbols();
|
void RestoreSymbols();
|
||||||
void SaveSymbols();
|
void SaveSymbols();
|
||||||
void DeleteSymbolSet(char *);
|
void DeleteSymbolSet(TCHAR *);
|
||||||
char** LoadSymbolSet(char *);
|
TCHAR** LoadSymbolSet(TCHAR *);
|
||||||
void SaveSymbolSet(char *, char **);
|
void SaveSymbolSet(TCHAR *, TCHAR **);
|
||||||
void RestoreMRUList();
|
void RestoreMRUList();
|
||||||
void SaveMRUList();
|
void SaveMRUList();
|
||||||
|
|
||||||
typedef struct NSISScriptData {
|
typedef struct NSISScriptData {
|
||||||
char *script;
|
TCHAR *script;
|
||||||
HGLOBAL script_cmd_args;
|
HGLOBAL script_cmd_args;
|
||||||
char *compile_command;
|
TCHAR *compile_command;
|
||||||
char *output_exe;
|
TCHAR *output_exe;
|
||||||
char *input_script;
|
TCHAR *input_script;
|
||||||
char *branding;
|
TCHAR *branding;
|
||||||
char *brandingv;
|
TCHAR *brandingv;
|
||||||
char **symbols;
|
TCHAR **symbols;
|
||||||
int retcode;
|
int retcode;
|
||||||
BOOL userSelectCompressor;
|
BOOL userSelectCompressor;
|
||||||
DWORD logLength;
|
DWORD logLength;
|
||||||
|
@ -188,9 +190,9 @@ typedef struct NSISScriptData {
|
||||||
CHARRANGE textrange;
|
CHARRANGE textrange;
|
||||||
NCOMPRESSOR default_compressor;
|
NCOMPRESSOR default_compressor;
|
||||||
NCOMPRESSOR compressor;
|
NCOMPRESSOR compressor;
|
||||||
char *compressor_name;
|
TCHAR *compressor_name;
|
||||||
char compressor_stats[512];
|
TCHAR compressor_stats[512];
|
||||||
char *best_compressor_name;
|
TCHAR *best_compressor_name;
|
||||||
// Added by Darren Owen (DrO) on 1/10/2003
|
// Added by Darren Owen (DrO) on 1/10/2003
|
||||||
int recompile_test;
|
int recompile_test;
|
||||||
} NSCRIPTDATA;
|
} NSCRIPTDATA;
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/20/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define TOOLBAR_CPP
|
#define TOOLBAR_CPP
|
||||||
|
|
||||||
|
@ -25,6 +27,7 @@
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "noclib.h"
|
#include "noclib.h"
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
|
|
||||||
NTOOLBAR g_toolbar;
|
NTOOLBAR g_toolbar;
|
||||||
extern NSCRIPTDATA g_sdata;
|
extern NSCRIPTDATA g_sdata;
|
||||||
|
@ -65,7 +68,7 @@ void CreateToolBar()
|
||||||
g_toolbar.hwnd = CreateWindowEx (
|
g_toolbar.hwnd = CreateWindowEx (
|
||||||
0L,
|
0L,
|
||||||
TOOLBARCLASSNAME,
|
TOOLBARCLASSNAME,
|
||||||
"",
|
_T(""),
|
||||||
WS_CHILD | WS_VISIBLE | TBSTYLE_TRANSPARENT | TBSTYLE_FLAT,
|
WS_CHILD | WS_VISIBLE | TBSTYLE_TRANSPARENT | TBSTYLE_FLAT,
|
||||||
0, 0, 0, 30,
|
0, 0, 0, 30,
|
||||||
g_sdata.hwnd,
|
g_sdata.hwnd,
|
||||||
|
@ -77,7 +80,7 @@ void CreateToolBar()
|
||||||
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LONG) &tbButton);
|
SendMessage(g_toolbar.hwnd, TB_ADDBUTTONS, BUTTONCOUNT, (LONG) &tbButton);
|
||||||
|
|
||||||
// For Comctl32.dll version detection
|
// For Comctl32.dll version detection
|
||||||
HMODULE hMod = GetModuleHandle("comctl32.dll");
|
HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));
|
||||||
|
|
||||||
if (GetProcAddress(hMod, "InitCommonControlsEx")) { // Version 4.70
|
if (GetProcAddress(hMod, "InitCommonControlsEx")) { // Version 4.70
|
||||||
// Modern toolbar, 24-bit bitmaps
|
// Modern toolbar, 24-bit bitmaps
|
||||||
|
@ -120,8 +123,8 @@ void UpdateToolBarCompressorButton()
|
||||||
{
|
{
|
||||||
int iBitmap;
|
int iBitmap;
|
||||||
int iString;
|
int iString;
|
||||||
char szBuffer[64];
|
TCHAR szBuffer[64];
|
||||||
char temp[32];
|
TCHAR temp[32];
|
||||||
TOOLINFO ti;
|
TOOLINFO ti;
|
||||||
|
|
||||||
my_memset(&ti, 0, sizeof(TOOLINFO));
|
my_memset(&ti, 0, sizeof(TOOLINFO));
|
||||||
|
@ -139,13 +142,13 @@ void UpdateToolBarCompressorButton()
|
||||||
sizeof(temp));
|
sizeof(temp));
|
||||||
my_memset(szBuffer, 0, sizeof(szBuffer));
|
my_memset(szBuffer, 0, sizeof(szBuffer));
|
||||||
lstrcat(szBuffer,temp);
|
lstrcat(szBuffer,temp);
|
||||||
lstrcat(szBuffer," [");
|
lstrcat(szBuffer,_T(" ["));
|
||||||
LoadString(g_sdata.hInstance,
|
LoadString(g_sdata.hInstance,
|
||||||
iString,
|
iString,
|
||||||
temp,
|
temp,
|
||||||
sizeof(temp));
|
sizeof(temp));
|
||||||
lstrcat(szBuffer,temp);
|
lstrcat(szBuffer,temp);
|
||||||
lstrcat(szBuffer,"]");
|
lstrcat(szBuffer,_T("]"));
|
||||||
|
|
||||||
SendMessage(g_toolbar.hwnd, TB_CHANGEBITMAP, (WPARAM) IDM_COMPRESSOR, (LPARAM) MAKELPARAM(iBitmap, 0));
|
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.hwnd = g_toolbar.hwnd;
|
||||||
ti.uId = (UINT)TBB_COMPRESSOR;
|
ti.uId = (UINT)TBB_COMPRESSOR;
|
||||||
SendMessage(g_tip.tip, TTM_GETTOOLINFO, 0, (LPARAM) (LPTOOLINFO) &ti);
|
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);
|
SendMessage(g_tip.tip, TTM_SETTOOLINFO, 0, (LPARAM) (LPTOOLINFO) &ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddToolBarButtonTooltip(int id, int iString)
|
void AddToolBarButtonTooltip(int id, int iString)
|
||||||
{
|
{
|
||||||
TOOLINFO ti;
|
TOOLINFO ti;
|
||||||
char szBuffer[64];
|
TCHAR szBuffer[64];
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
my_memset(&ti, 0, sizeof(TOOLINFO));
|
my_memset(&ti, 0, sizeof(TOOLINFO));
|
||||||
|
@ -179,7 +182,7 @@ void AddToolBarButtonTooltip(int id, int iString)
|
||||||
iString,
|
iString,
|
||||||
szBuffer,
|
szBuffer,
|
||||||
sizeof(szBuffer));
|
sizeof(szBuffer));
|
||||||
ti.lpszText = (LPSTR) szBuffer;
|
ti.lpszText = (LPTSTR) szBuffer;
|
||||||
ti.rect.left =rect.left;
|
ti.rect.left =rect.left;
|
||||||
ti.rect.top = rect.top;
|
ti.rect.top = rect.top;
|
||||||
ti.rect.right = rect.right;
|
ti.rect.right = rect.right;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
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
|
#ifndef TOOLBAR_H
|
||||||
#define TOOLBAR_H
|
#define TOOLBAR_H
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
// Unicode support by Jim Park -- 08/20/2007
|
||||||
|
|
||||||
#include "makensisw.h"
|
#include "makensisw.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "noclib.h"
|
#include "noclib.h"
|
||||||
|
|
||||||
#include "jnetlib/httpget.h"
|
#include "jnetlib/httpget.h"
|
||||||
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
|
|
||||||
static BOOL update_initialized = FALSE;
|
static BOOL update_initialized = FALSE;
|
||||||
|
|
||||||
|
@ -28,12 +31,12 @@ void FinalizeUpdate() {
|
||||||
int getProxyInfo(char *out) {
|
int getProxyInfo(char *out) {
|
||||||
DWORD v=0;
|
DWORD v=0;
|
||||||
HKEY hKey;
|
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 l = 4;
|
||||||
DWORD t;
|
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;
|
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;
|
v=0;
|
||||||
*out=0;
|
*out=0;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +56,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
char url[300];
|
char url[300];
|
||||||
BOOL error = FALSE;
|
BOOL error = FALSE;
|
||||||
static char pbuf[8192];
|
static char pbuf[8192];
|
||||||
|
static char ansiBuf[1024];
|
||||||
char *p=NULL;
|
char *p=NULL;
|
||||||
*response = 0;
|
*response = 0;
|
||||||
|
|
||||||
|
@ -72,9 +76,16 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
InitializeUpdate();
|
InitializeUpdate();
|
||||||
|
|
||||||
JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL);;
|
JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL);;
|
||||||
lstrcpy(url,NSIS_UPDATE);
|
lstrcpyA(url,NSIS_UPDATE);
|
||||||
lstrcat(url,g_sdata.brandingv);
|
|
||||||
lstrcpy(response,"");
|
#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("User-Agent: MakeNSISw (jnetlib)");
|
||||||
get->addheader("Accept:*/*");
|
get->addheader("Accept:*/*");
|
||||||
get->connect(url);
|
get->connect(url);
|
||||||
|
@ -85,10 +96,10 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
while(len=get->bytes_available()) {
|
while(len=get->bytes_available()) {
|
||||||
char b[RSZ];
|
char b[RSZ];
|
||||||
if (len>RSZ) len=RSZ;
|
if (len>RSZ) len=RSZ;
|
||||||
if (lstrlen(response)+len>RSZ) break;
|
if (lstrlenA(response)+len>RSZ) break;
|
||||||
len=get->get_bytes(b,len);
|
len=get->get_bytes(b,len);
|
||||||
b[len]=0;
|
b[len]=0;
|
||||||
lstrcat(response,b);
|
lstrcatA(response,b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (st==1) break; //closed
|
if (st==1) break; //closed
|
||||||
|
@ -100,26 +111,26 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
char buf[1000];
|
char buf[1000];
|
||||||
wsprintf(buf,"There was a problem checking for an update. Please try again later.\n\nError: %s",get->geterrorstr());
|
wsprintfA(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);
|
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];
|
char buf[200];
|
||||||
response+=2;
|
response+=2;
|
||||||
wsprintf(buf,"NSIS %s is now available. Would you like to download it now?",response);
|
wsprintfA(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) {
|
if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
|
||||||
ShellExecute(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
|
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];
|
char buf[200];
|
||||||
response+=2;
|
response+=2;
|
||||||
wsprintf(buf,"NSIS %s is now available. Would you like to download this preview release now?",response);
|
wsprintfA(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) {
|
if (MessageBoxA(g_sdata.hwnd,buf,"NSIS Update",MB_YESNO|MB_ICONINFORMATION)==IDYES) {
|
||||||
ShellExecute(g_sdata.hwnd,"open",NSIS_DL_URL,NULL,NULL,SW_SHOWNORMAL);
|
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);
|
GlobalFree(response);
|
||||||
delete get;
|
delete get;
|
||||||
EnableMenuItem(g_sdata.menu,IDM_NSISUPDATE,MF_ENABLED);
|
EnableMenuItem(g_sdata.menu,IDM_NSISUPDATE,MF_ENABLED);
|
||||||
|
@ -129,9 +140,9 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
||||||
void Update() {
|
void Update() {
|
||||||
DWORD dwThreadId;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* Reviewed for Unicode support by Jim Park -- 08/18/2007
|
||||||
|
|
||||||
/* Initialize update objects. */
|
/* Initialize update objects. */
|
||||||
void InitializeUpdate();
|
void InitializeUpdate();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/20/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "makensisw.h"
|
#include "makensisw.h"
|
||||||
|
@ -28,46 +30,46 @@
|
||||||
NTOOLTIP g_tip;
|
NTOOLTIP g_tip;
|
||||||
LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
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 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;
|
const TCHAR *p;
|
||||||
char *arg, *argSpace;
|
TCHAR *arg, *argSpace;
|
||||||
int size, argSpaceSize, inquote, copy, slashes;
|
int size, argSpaceSize, inquote, copy, slashes;
|
||||||
|
|
||||||
size = 2;
|
size = 2;
|
||||||
for (p = cmdLine; *p != '\0'; p++) {
|
for (p = cmdLine; *p != _T('\0'); p++) {
|
||||||
if ((*p == ' ') || (*p == '\t')) {
|
if ((*p == _T(' ')) || (*p == _T('\t'))) {
|
||||||
size++;
|
size++;
|
||||||
while ((*p == ' ') || (*p == '\t')) {
|
while ((*p == _T(' ')) || (*p == _T('\t'))) {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
if (*p == '\0') {
|
if (*p == _T('\0')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argSpaceSize = size * sizeof(char *) + lstrlen(cmdLine) + 1;
|
argSpaceSize = size * sizeof(TCHAR *) + lstrlen(cmdLine) + 1;
|
||||||
argSpace = (char *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
|
argSpace = (TCHAR *) GlobalAlloc(GMEM_FIXED, argSpaceSize);
|
||||||
if (!argSpace)
|
if (!argSpace)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*argv = (char **) argSpace;
|
*argv = (TCHAR **) argSpace;
|
||||||
argSpace += size * sizeof(char *);
|
argSpace += size * sizeof(TCHAR *);
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
p = cmdLine;
|
p = cmdLine;
|
||||||
for (*argc = 0; *argc < size; (*argc)++) {
|
for (*argc = 0; *argc < size; (*argc)++) {
|
||||||
(*argv)[*argc] = arg = argSpace;
|
(*argv)[*argc] = arg = argSpace;
|
||||||
while ((*p == ' ') || (*p == '\t')) {
|
while ((*p == _T(' ')) || (*p == _T('\t'))) {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
if (*p == '\0') {
|
if (*p == _T('\0')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,14 +77,14 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
|
||||||
slashes = 0;
|
slashes = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
copy = 1;
|
copy = 1;
|
||||||
while (*p == '\\') {
|
while (*p == _T('\\')) {
|
||||||
slashes++;
|
slashes++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
if (*p == '"') {
|
if (*p == _T('"')) {
|
||||||
if ((slashes & 1) == 0) {
|
if ((slashes & 1) == 0) {
|
||||||
copy = 0;
|
copy = 0;
|
||||||
if ((inquote) && (p[1] == '"')) {
|
if ((inquote) && (p[1] == _T('"'))) {
|
||||||
p++;
|
p++;
|
||||||
copy = 1;
|
copy = 1;
|
||||||
}
|
}
|
||||||
|
@ -94,12 +96,12 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (slashes) {
|
while (slashes) {
|
||||||
*arg = '\\';
|
*arg = _T('\\');
|
||||||
arg++;
|
arg++;
|
||||||
slashes--;
|
slashes--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*p == '\0') || (!inquote && ((*p == ' ') || (*p == '\t')))) {
|
if ((*p == _T('\0')) || (!inquote && ((*p == _T(' ')) || (*p == _T('\t'))))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (copy != 0) {
|
if (copy != 0) {
|
||||||
|
@ -108,7 +110,7 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
*arg = '\0';
|
*arg = _T('\0');
|
||||||
argSpace = arg + 1;
|
argSpace = arg + 1;
|
||||||
}
|
}
|
||||||
(*argv)[*argc] = NULL;
|
(*argv)[*argc] = NULL;
|
||||||
|
@ -116,10 +118,10 @@ int SetArgv(const char *cmdLine, int *argc, char ***argv)
|
||||||
return argSpaceSize;
|
return argSpaceSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetTitle(HWND hwnd,char *substr) {
|
void SetTitle(HWND hwnd,TCHAR *substr) {
|
||||||
char title[64];
|
TCHAR title[64];
|
||||||
if (substr==NULL) wsprintf(title,"MakeNSISW");
|
if (substr==NULL) wsprintf(title,_T("MakeNSISW"));
|
||||||
else wsprintf(title,"MakeNSISW - %s",substr);
|
else wsprintf(title,_T("MakeNSISW - %s"),substr);
|
||||||
SetWindowText(hwnd,title);
|
SetWindowText(hwnd,title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +132,9 @@ void SetBranding(HWND hwnd) {
|
||||||
void CopyToClipboard(HWND hwnd) {
|
void CopyToClipboard(HWND hwnd) {
|
||||||
if (!hwnd||!OpenClipboard(hwnd)) return;
|
if (!hwnd||!OpenClipboard(hwnd)) return;
|
||||||
int len=SendDlgItemMessage(hwnd,IDC_LOGWIN,WM_GETTEXTLENGTH,0,0);
|
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; }
|
if (!mem) { CloseClipboard(); return; }
|
||||||
char *existing_text = (char *)GlobalLock(mem);
|
TCHAR *existing_text = (TCHAR *)GlobalLock(mem);
|
||||||
if (!existing_text) { CloseClipboard(); return; }
|
if (!existing_text) { CloseClipboard(); return; }
|
||||||
EmptyClipboard();
|
EmptyClipboard();
|
||||||
existing_text[0]=0;
|
existing_text[0]=0;
|
||||||
|
@ -143,20 +145,20 @@ void CopyToClipboard(HWND hwnd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearLog(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);
|
SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SETSEL, g_sdata.logLength, g_sdata.logLength);
|
||||||
g_sdata.logLength += lstrlen(str);
|
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);
|
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;
|
if (!str) return;
|
||||||
char buf[1028];
|
TCHAR buf[1028];
|
||||||
wsprintf(buf,"[Error] %s\r\n",str);
|
wsprintf(buf,_T("[Error] %s\r\n"),str);
|
||||||
LogMessage(hwnd,buf);
|
LogMessage(hwnd,buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +220,7 @@ void Items(HWND hwnd, int on){
|
||||||
void SetCompressorStats()
|
void SetCompressorStats()
|
||||||
{
|
{
|
||||||
DWORD line_count, i;
|
DWORD line_count, i;
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
line_count = SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINECOUNT, 0, 0);
|
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);
|
DWORD len = lstrlen(EXE_HEADER_COMPRESSOR_STAT);
|
||||||
if(!lstrncmp(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
|
if(!lstrncmp(buf,EXE_HEADER_COMPRESSOR_STAT,len)) {
|
||||||
found = true;
|
found = true;
|
||||||
lstrcpy(g_sdata.compressor_stats,"\n\n");
|
lstrcpy(g_sdata.compressor_stats,_T("\n\n"));
|
||||||
lstrcat(g_sdata.compressor_stats,buf);
|
lstrcat(g_sdata.compressor_stats,buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +247,7 @@ void SetCompressorStats()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompileNSISScript() {
|
void CompileNSISScript() {
|
||||||
static char *s;
|
static TCHAR *s;
|
||||||
DragAcceptFiles(g_sdata.hwnd,FALSE);
|
DragAcceptFiles(g_sdata.hwnd,FALSE);
|
||||||
ClearLog(g_sdata.hwnd);
|
ClearLog(g_sdata.hwnd);
|
||||||
SetTitle(g_sdata.hwnd,NULL);
|
SetTitle(g_sdata.hwnd,NULL);
|
||||||
|
@ -270,31 +272,31 @@ void CompileNSISScript() {
|
||||||
}
|
}
|
||||||
if (!g_sdata.compile_command) {
|
if (!g_sdata.compile_command) {
|
||||||
if (s) GlobalFree(s);
|
if (s) GlobalFree(s);
|
||||||
char *symbols = BuildSymbols();
|
TCHAR *symbols = BuildSymbols();
|
||||||
|
|
||||||
char compressor[40];
|
TCHAR compressor[40];
|
||||||
if(lstrlen(g_sdata.compressor_name)) {
|
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 {
|
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(
|
g_sdata.compile_command = (char *) GlobalAlloc(
|
||||||
GPTR,
|
GPTR,
|
||||||
/* makensis.exe */ sizeof(EXENAME) + /* space */ 1 +
|
/* makensis.exe */ _countof(EXENAME) + /* space */ 1 +
|
||||||
/* script path */ lstrlen(g_sdata.script) + /* space */ 1 +
|
/* script path */ lstrlen(g_sdata.script) + /* space */ 1 +
|
||||||
/* script cmd args */ lstrlen(args) + /* space */ 1 +
|
/* script cmd args */ lstrlen(args) + /* space */ 1 +
|
||||||
/* defines /Dblah=... */ lstrlen(symbols) + /* space */ 1 +
|
/* defines /Dblah=... */ lstrlen(symbols) + /* space */ 1 +
|
||||||
/* /XSetCompressor... */ lstrlen(compressor) + /* space */ 1 +
|
/* /XSetCompressor... */ lstrlen(compressor) + /* space */ 1 +
|
||||||
/* /NOTTIFYHWND + HWND */ sizeof("/NOTIFYHWND -4294967295") + /* space */ 1
|
/* /NOTTIFYHWND + HWND */ _countof(_T("/NOTIFYHWND -4294967295")) + /* space */ 1
|
||||||
);
|
);
|
||||||
|
|
||||||
wsprintf(
|
wsprintf(
|
||||||
g_sdata.compile_command,
|
g_sdata.compile_command,
|
||||||
"%s %s %s /NOTIFYHWND %d %s -- \"%s\"",
|
_T("%s %s %s /NOTIFYHWND %d %s -- \"%s\""),
|
||||||
EXENAME,
|
EXENAME,
|
||||||
compressor,
|
compressor,
|
||||||
symbols,
|
symbols,
|
||||||
|
@ -343,7 +345,7 @@ void RestoreWindowPos(HWND hwnd) {
|
||||||
if (OpenRegSettingsKey(hKey)) {
|
if (OpenRegSettingsKey(hKey)) {
|
||||||
DWORD l = sizeof(p);
|
DWORD l = sizeof(p);
|
||||||
DWORD t;
|
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 width, height;
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
|
|
||||||
|
@ -391,7 +393,7 @@ void SaveWindowPos(HWND hwnd) {
|
||||||
p.length = sizeof(p);
|
p.length = sizeof(p);
|
||||||
GetWindowPlacement(hwnd, &p);
|
GetWindowPlacement(hwnd, &p);
|
||||||
if (OpenRegSettingsKey(hKey, true)) {
|
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);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,34 +408,34 @@ void SaveSymbols()
|
||||||
SaveSymbolSet(NULL, g_sdata.symbols);
|
SaveSymbolSet(NULL, g_sdata.symbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteSymbolSet(char *name)
|
void DeleteSymbolSet(TCHAR *name)
|
||||||
{
|
{
|
||||||
if(name) {
|
if(name) {
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
if (OpenRegSettingsKey(hKey)) {
|
if (OpenRegSettingsKey(hKey)) {
|
||||||
char subkey[1024];
|
TCHAR subkey[1024];
|
||||||
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
|
wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name);
|
||||||
RegDeleteKey(hKey,subkey);
|
RegDeleteKey(hKey,subkey);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char** LoadSymbolSet(char *name)
|
TCHAR** LoadSymbolSet(TCHAR *name)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
HKEY hSubKey;
|
HKEY hSubKey;
|
||||||
char **symbols = NULL;
|
TCHAR **symbols = NULL;
|
||||||
if (OpenRegSettingsKey(hKey)) {
|
if (OpenRegSettingsKey(hKey)) {
|
||||||
char subkey[1024];
|
TCHAR subkey[1024];
|
||||||
if(name) {
|
if(name) {
|
||||||
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
|
wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lstrcpy(subkey,REGSYMSUBKEY);
|
lstrcpy(subkey,REGSYMSUBKEY);
|
||||||
}
|
}
|
||||||
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
||||||
char buf[8];
|
TCHAR buf[8];
|
||||||
DWORD l;
|
DWORD l;
|
||||||
DWORD t;
|
DWORD t;
|
||||||
DWORD bufSize;
|
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 ((RegEnumValue(hSubKey,i, buf, &bufSize,NULL,&t,NULL,&l)==ERROR_SUCCESS)&&(t == REG_SZ)) {
|
||||||
if(symbols) {
|
if(symbols) {
|
||||||
GlobalUnlock(hMem);
|
GlobalUnlock(hMem);
|
||||||
hMem = GlobalReAlloc(hMem, (i+2)*sizeof(char *), GMEM_MOVEABLE|GMEM_ZEROINIT);
|
hMem = GlobalReAlloc(hMem, (i+2)*sizeof(TCHAR *), GMEM_MOVEABLE|GMEM_ZEROINIT);
|
||||||
symbols = (char **)GlobalLock(hMem);
|
symbols = (TCHAR **)GlobalLock(hMem);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (i+2)*sizeof(char *));
|
hMem = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, (i+2)*sizeof(TCHAR *));
|
||||||
symbols = (char **)GlobalLock(hMem);
|
symbols = (TCHAR **)GlobalLock(hMem);
|
||||||
}
|
}
|
||||||
if(symbols) {
|
if(symbols) {
|
||||||
l++;
|
l++;
|
||||||
symbols[i] = (char *)GlobalAlloc(GPTR, l*sizeof(char));
|
symbols[i] = (TCHAR *)GlobalAlloc(GPTR, l*sizeof(TCHAR));
|
||||||
if (symbols[i]) {
|
if (symbols[i]) {
|
||||||
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&l);
|
RegQueryValueEx(hSubKey,buf,NULL,&t,(unsigned char*)symbols[i],&l);
|
||||||
}
|
}
|
||||||
|
@ -481,22 +483,22 @@ char** LoadSymbolSet(char *name)
|
||||||
return symbols;
|
return symbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveSymbolSet(char *name, char **symbols)
|
void SaveSymbolSet(TCHAR *name, TCHAR **symbols)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
HKEY hSubKey;
|
HKEY hSubKey;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (OpenRegSettingsKey(hKey, true)) {
|
if (OpenRegSettingsKey(hKey, true)) {
|
||||||
char subkey[1024];
|
TCHAR subkey[1024];
|
||||||
if(name) {
|
if(name) {
|
||||||
wsprintf(subkey,"%s\\%s",REGSYMSUBKEY,name);
|
wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lstrcpy(subkey,REGSYMSUBKEY);
|
lstrcpy(subkey,REGSYMSUBKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RegOpenKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
if (RegOpenKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
||||||
char buf[8];
|
TCHAR buf[8];
|
||||||
DWORD l;
|
DWORD l;
|
||||||
while(TRUE) {
|
while(TRUE) {
|
||||||
l = sizeof(buf);
|
l = sizeof(buf);
|
||||||
|
@ -511,11 +513,11 @@ void SaveSymbolSet(char *name, char **symbols)
|
||||||
}
|
}
|
||||||
if(symbols) {
|
if(symbols) {
|
||||||
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) {
|
||||||
char buf[8];
|
TCHAR buf[8];
|
||||||
n = 0;
|
n = 0;
|
||||||
while(symbols[n]) {
|
while(symbols[n]) {
|
||||||
wsprintf(buf,"%d",n);
|
wsprintf(buf,_T("%d"),n);
|
||||||
RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)symbols[n],lstrlen(symbols[n])+1);
|
RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)symbols[n],(lstrlen(symbols[n])+1)*sizeof(TCHAR));
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
RegCloseKey(hSubKey);
|
RegCloseKey(hSubKey);
|
||||||
|
@ -551,9 +553,9 @@ void ResetSymbols() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int InitBranding() {
|
int InitBranding() {
|
||||||
char *s;
|
TCHAR *s;
|
||||||
s = (char *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
|
s = (TCHAR *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
|
||||||
wsprintf(s,"%s /version",EXENAME);
|
wsprintf(s,_T("%s /version"),EXENAME);
|
||||||
{
|
{
|
||||||
STARTUPINFO si={sizeof(si),};
|
STARTUPINFO si={sizeof(si),};
|
||||||
SECURITY_ATTRIBUTES sa={sizeof(sa),};
|
SECURITY_ATTRIBUTES sa={sizeof(sa),};
|
||||||
|
@ -583,7 +585,7 @@ int InitBranding() {
|
||||||
CloseHandle(read_stdout);
|
CloseHandle(read_stdout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char szBuf[1024];
|
TCHAR szBuf[1024];
|
||||||
DWORD dwRead = 1;
|
DWORD dwRead = 1;
|
||||||
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
|
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -591,9 +593,9 @@ int InitBranding() {
|
||||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
||||||
szBuf[dwRead] = 0;
|
szBuf[dwRead] = 0;
|
||||||
if (lstrlen(szBuf)==0) return 0;
|
if (lstrlen(szBuf)==0) return 0;
|
||||||
g_sdata.branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
|
g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+6)*sizeof(TCHAR));
|
||||||
wsprintf(g_sdata.branding,"NSIS %s",szBuf);
|
wsprintf(g_sdata.branding,_T("NSIS %s"),szBuf);
|
||||||
g_sdata.brandingv = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+1);
|
g_sdata.brandingv = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+1)*sizeof(TCHAR));
|
||||||
lstrcpy(g_sdata.brandingv,szBuf);
|
lstrcpy(g_sdata.brandingv,szBuf);
|
||||||
GlobalFree(s);
|
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);
|
g_tip.tip = CreateWindowEx(dwExStyle,TOOLTIPS_CLASS,NULL,dwStyle,0,0,0,0,h,NULL,GetModuleHandle(NULL),NULL);
|
||||||
if (!g_tip.tip) return;
|
if (!g_tip.tip) return;
|
||||||
g_tip.hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
|
g_tip.hook = SetWindowsHookEx(WH_GETMESSAGE,TipHookProc,NULL, GetCurrentThreadId());
|
||||||
AddTip(GetDlgItem(h,IDCANCEL),TEXT("Close MakeNSISW"));
|
AddTip(GetDlgItem(h,IDCANCEL),_T("Close MakeNSISW"));
|
||||||
AddTip(GetDlgItem(h,IDC_TEST),TEXT("Test the installer generated by MakeNSISW"));
|
AddTip(GetDlgItem(h,IDC_TEST),_T("Test the installer generated by MakeNSISW"));
|
||||||
AddToolBarTooltips();
|
AddToolBarTooltips();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +624,7 @@ void DestroyTooltips() {
|
||||||
UnhookWindowsHookEx(g_tip.hook);
|
UnhookWindowsHookEx(g_tip.hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTip(HWND hWnd,LPSTR lpszToolTip) {
|
void AddTip(HWND hWnd,LPTSTR lpszToolTip) {
|
||||||
TOOLINFO ti;
|
TOOLINFO ti;
|
||||||
ti.cbSize = sizeof(TOOLINFO);
|
ti.cbSize = sizeof(TOOLINFO);
|
||||||
ti.uFlags = TTF_IDISHWND;
|
ti.uFlags = TTF_IDISHWND;
|
||||||
|
@ -646,44 +648,44 @@ LRESULT CALLBACK TipHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowDocs() {
|
void ShowDocs() {
|
||||||
char pathf[MAX_PATH],*path;
|
TCHAR pathf[MAX_PATH],*path;
|
||||||
GetModuleFileName(NULL,pathf,sizeof(pathf));
|
GetModuleFileName(NULL,pathf,sizeof(pathf));
|
||||||
path=my_strrchr(pathf,'\\');
|
path=my_strrchr(pathf,_T('\\'));
|
||||||
if(path!=NULL) *path=0;
|
if(path!=NULL) *path=0;
|
||||||
lstrcat(pathf,LOCALDOCS);
|
lstrcat(pathf,LOCALDOCS);
|
||||||
if ((int)ShellExecute(g_sdata.hwnd,"open",pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
if ((int)ShellExecute(g_sdata.hwnd,_T("open"),pathf,NULL,NULL,SW_SHOWNORMAL)<=32)
|
||||||
ShellExecute(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
|
ShellExecuteA(g_sdata.hwnd,"open",DOCPATH,NULL,NULL,SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* BuildSymbols()
|
TCHAR* BuildSymbols()
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
TCHAR *buf = NULL;
|
||||||
|
|
||||||
if(g_sdata.symbols) {
|
if(g_sdata.symbols) {
|
||||||
int i=0;
|
int i=0;
|
||||||
while(g_sdata.symbols[i]) {
|
while(g_sdata.symbols[i]) {
|
||||||
if(buf) {
|
if(buf) {
|
||||||
char *buf3 = (char *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(char));
|
TCHAR *buf3 = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(buf)+lstrlen(g_sdata.symbols[i])+6)*sizeof(TCHAR));
|
||||||
wsprintf(buf3,"%s \"/D%s\"",buf,g_sdata.symbols[i]);
|
wsprintf(buf3,_T("%s \"/D%s\""),buf,g_sdata.symbols[i]);
|
||||||
GlobalFree(buf);
|
GlobalFree(buf);
|
||||||
buf = buf3;
|
buf = buf3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf = (char *)GlobalAlloc(GPTR,(lstrlen(g_sdata.symbols[i])+5)*sizeof(char));
|
buf = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(g_sdata.symbols[i])+5)*sizeof(TCHAR));
|
||||||
wsprintf(buf,"\"/D%s\"",g_sdata.symbols[i]);
|
wsprintf(buf,_T("\"/D%s\""),g_sdata.symbols[i]);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf = (char *)GlobalAlloc(GPTR, sizeof(char));
|
buf = (TCHAR *)GlobalAlloc(GPTR, sizeof(TCHAR));
|
||||||
buf[0] = '\0';
|
buf[0] = _T('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL PopMRUFile(char* fname)
|
BOOL PopMRUFile(TCHAR* fname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -698,7 +700,7 @@ BOOL PopMRUFile(char* fname)
|
||||||
for(j = i; j < MRU_LIST_SIZE-1; j++) {
|
for(j = i; j < MRU_LIST_SIZE-1; j++) {
|
||||||
lstrcpy(g_mru_list[j],g_mru_list[j+1]);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -706,7 +708,7 @@ BOOL PopMRUFile(char* fname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL IsValidFile(char *fname)
|
BOOL IsValidFile(TCHAR *fname)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA wfd;
|
WIN32_FIND_DATA wfd;
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
@ -719,19 +721,19 @@ BOOL IsValidFile(char *fname)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushMRUFile(char* fname)
|
void PushMRUFile(TCHAR* fname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
DWORD rv;
|
DWORD rv;
|
||||||
char* file_part;
|
TCHAR* file_part;
|
||||||
char full_file_name[MAX_PATH+1];
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_memset(full_file_name,0,sizeof(full_file_name));
|
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) {
|
if (rv == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -751,9 +753,9 @@ void BuildMRUMenus()
|
||||||
HMENU hMenu = g_sdata.fileSubmenu;
|
HMENU hMenu = g_sdata.fileSubmenu;
|
||||||
int i;
|
int i;
|
||||||
MENUITEMINFO mii;
|
MENUITEMINFO mii;
|
||||||
char buf[MRU_DISPLAY_LENGTH + 5/*number*/ + 1/*null*/];
|
TCHAR buf[MRU_DISPLAY_LENGTH + 5/*number*/ + 1/*null*/];
|
||||||
char buf2[MRU_DISPLAY_LENGTH - 6];
|
TCHAR buf2[MRU_DISPLAY_LENGTH - 6];
|
||||||
char buf3[MRU_DISPLAY_LENGTH + 1];
|
TCHAR buf3[MRU_DISPLAY_LENGTH + 1];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
||||||
|
@ -770,32 +772,32 @@ void BuildMRUMenus()
|
||||||
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
|
||||||
mii.wID = IDM_MRU_FILE+i;
|
mii.wID = IDM_MRU_FILE+i;
|
||||||
mii.fType = MFT_STRING;
|
mii.fType = MFT_STRING;
|
||||||
wsprintf(buf, "&%d ", i + 1);
|
wsprintf(buf, _T("&%d "), i + 1);
|
||||||
if(lstrlen(g_mru_list[i]) > MRU_DISPLAY_LENGTH) {
|
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) {
|
if(p) {
|
||||||
p++;
|
p++;
|
||||||
if(lstrlen(p) > MRU_DISPLAY_LENGTH - 7) {
|
if(lstrlen(p) > MRU_DISPLAY_LENGTH - 7) {
|
||||||
my_memset(buf2,0,sizeof(buf2));
|
my_memset(buf2,0,sizeof(buf2));
|
||||||
lstrcpyn(buf2,p,MRU_DISPLAY_LENGTH - 9);
|
lstrcpyn(buf2,p,MRU_DISPLAY_LENGTH - 9);
|
||||||
lstrcat(buf2,"...");
|
lstrcat(buf2,_T("..."));
|
||||||
|
|
||||||
lstrcpyn(buf3,g_mru_list[i],4);
|
lstrcpyn(buf3,g_mru_list[i],4);
|
||||||
lstrcat(buf,buf3);
|
lstrcat(buf,buf3);
|
||||||
lstrcat(buf,"...\\");
|
lstrcat(buf,_T("...\\"));
|
||||||
lstrcat(buf,buf2);
|
lstrcat(buf,buf2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lstrcpyn(buf3,g_mru_list[i],(MRU_DISPLAY_LENGTH - lstrlen(p) - 3));
|
lstrcpyn(buf3,g_mru_list[i],(MRU_DISPLAY_LENGTH - lstrlen(p) - 3));
|
||||||
lstrcat(buf,buf3);
|
lstrcat(buf,buf3);
|
||||||
lstrcat(buf,"...\\");
|
lstrcat(buf,_T("...\\"));
|
||||||
lstrcat(buf,p);
|
lstrcat(buf,p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lstrcpyn(buf3,g_mru_list[i],(MRU_DISPLAY_LENGTH-2));
|
lstrcpyn(buf3,g_mru_list[i],(MRU_DISPLAY_LENGTH-2));
|
||||||
lstrcat(buf,buf3);
|
lstrcat(buf,buf3);
|
||||||
lstrcat(buf,"...");
|
lstrcat(buf,_T("..."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -852,13 +854,13 @@ void RestoreMRUList()
|
||||||
int i;
|
int i;
|
||||||
if (OpenRegSettingsKey(hKey)) {
|
if (OpenRegSettingsKey(hKey)) {
|
||||||
if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
||||||
char buf[8];
|
TCHAR buf[8];
|
||||||
DWORD l;
|
DWORD l;
|
||||||
for(int i=0; i<MRU_LIST_SIZE; i++) {
|
for(int i=0; i<MRU_LIST_SIZE; i++) {
|
||||||
wsprintf(buf,"%d",i);
|
wsprintf(buf,_T("%d"),i);
|
||||||
l = sizeof(g_mru_list[n]);
|
l = sizeof(g_mru_list[n]);
|
||||||
RegQueryValueEx(hSubKey,buf,NULL,NULL,(unsigned char*)g_mru_list[n],&l);
|
RegQueryValueEx(hSubKey,buf,NULL,NULL,(LPBYTE)g_mru_list[n],&l);
|
||||||
if(g_mru_list[n][0] != '\0') {
|
if(g_mru_list[n][0] != _T('\0')) {
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -867,7 +869,7 @@ void RestoreMRUList()
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
for(i = n; i < MRU_LIST_SIZE; i++) {
|
for(i = n; i < MRU_LIST_SIZE; i++) {
|
||||||
g_mru_list[i][0] = '\0';
|
g_mru_list[i][0] = _T('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildMRUMenus();
|
BuildMRUMenus();
|
||||||
|
@ -880,10 +882,11 @@ void SaveMRUList()
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (OpenRegSettingsKey(hKey, true)) {
|
if (OpenRegSettingsKey(hKey, true)) {
|
||||||
if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) {
|
||||||
char buf[8];
|
TCHAR buf[8];
|
||||||
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
for(i = 0; i < MRU_LIST_SIZE; i++) {
|
||||||
wsprintf(buf,"%d",i);
|
wsprintf(buf,_T("%d"),i);
|
||||||
RegSetValueEx(hSubKey,buf,0,REG_SZ,(const unsigned char *)g_mru_list[i],lstrlen(g_mru_list[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);
|
RegCloseKey(hSubKey);
|
||||||
}
|
}
|
||||||
|
@ -895,7 +898,7 @@ void ClearMRUList()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<MRU_LIST_SIZE; i++) {
|
for(i=0; i<MRU_LIST_SIZE; i++) {
|
||||||
g_mru_list[i][0] = '\0';
|
g_mru_list[i][0] = _T('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildMRUMenus();
|
BuildMRUMenus();
|
||||||
|
@ -906,11 +909,11 @@ void RestoreCompressor()
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
NCOMPRESSOR v = COMPRESSOR_SCRIPT;
|
NCOMPRESSOR v = COMPRESSOR_SCRIPT;
|
||||||
if (OpenRegSettingsKey(hKey)) {
|
if (OpenRegSettingsKey(hKey)) {
|
||||||
char compressor_name[32];
|
TCHAR compressor_name[32];
|
||||||
DWORD l = sizeof(compressor_name);
|
DWORD l = sizeof(compressor_name);
|
||||||
DWORD t;
|
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;
|
int i;
|
||||||
for(i=(int)COMPRESSOR_SCRIPT; i<= (int)COMPRESSOR_BEST; i++) {
|
for(i=(int)COMPRESSOR_SCRIPT; i<= (int)COMPRESSOR_BEST; i++) {
|
||||||
if(!lstrcmpi(compressor_names[i],compressor_name)) {
|
if(!lstrcmpi(compressor_names[i],compressor_name)) {
|
||||||
|
@ -935,13 +938,14 @@ void SaveCompressor()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OpenRegSettingsKey(hKey, true)) {
|
if (OpenRegSettingsKey(hKey, true)) {
|
||||||
RegSetValueEx(hKey,REGCOMPRESSOR,0,REG_SZ,(unsigned char*)compressor_names[n],
|
// compressor_names, even if Unicode is saved as BYTE* data.
|
||||||
lstrlen(compressor_names[n]));
|
RegSetValueEx(hKey,REGCOMPRESSOR,0,REG_SZ,(const BYTE*)compressor_names[n],
|
||||||
|
lstrlen(compressor_names[n])*sizeof(TCHAR));
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL FileExists(char *fname)
|
BOOL FileExists(TCHAR *fname)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA wfd;
|
WIN32_FIND_DATA wfd;
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/20/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
@ -28,13 +30,13 @@
|
||||||
#define MRU_LIST_SIZE 5
|
#define MRU_LIST_SIZE 5
|
||||||
#define MRU_DISPLAY_LENGTH 40
|
#define MRU_DISPLAY_LENGTH 40
|
||||||
|
|
||||||
int SetArgv(const char *cmdLine, int *argc, char ***argv);
|
int SetArgv(const TCHAR *cmdLine, int *argc, TCHAR ***argv);
|
||||||
void SetTitle(HWND hwnd,char *substr);
|
void SetTitle(HWND hwnd,TCHAR *substr);
|
||||||
void SetBranding(HWND hwnd);
|
void SetBranding(HWND hwnd);
|
||||||
void CopyToClipboard(HWND hwnd);
|
void CopyToClipboard(HWND hwnd);
|
||||||
void ClearLog(HWND hwnd);
|
void ClearLog(HWND hwnd);
|
||||||
void LogMessage(HWND hwnd,const char *str);
|
void LogMessage(HWND hwnd,const TCHAR *str);
|
||||||
void ErrorMessage(HWND hwnd,const char *str);
|
void ErrorMessage(HWND hwnd,const TCHAR *str);
|
||||||
#define DisableItems(hwnd) Items(hwnd, 0)
|
#define DisableItems(hwnd) Items(hwnd, 0)
|
||||||
#define EnableItems(hwnd) Items(hwnd, 1)
|
#define EnableItems(hwnd) Items(hwnd, 1)
|
||||||
void Items(HWND hwnd, int on);
|
void Items(HWND hwnd, int on);
|
||||||
|
@ -48,19 +50,19 @@ void ResetSymbols();
|
||||||
int InitBranding();
|
int InitBranding();
|
||||||
void InitTooltips(HWND h);
|
void InitTooltips(HWND h);
|
||||||
void DestroyTooltips();
|
void DestroyTooltips();
|
||||||
void AddTip(HWND hWnd,LPSTR lpszToolTip);
|
void AddTip(HWND hWnd,LPTSTR lpszToolTip);
|
||||||
void ShowDocs();
|
void ShowDocs();
|
||||||
void RestoreCompressor();
|
void RestoreCompressor();
|
||||||
void SaveCompressor();
|
void SaveCompressor();
|
||||||
void SetCompressorStats();
|
void SetCompressorStats();
|
||||||
|
|
||||||
BOOL PopMRUFile(char* fname);
|
BOOL PopMRUFile(TCHAR* fname);
|
||||||
void PushMRUFile(char* fname);
|
void PushMRUFile(TCHAR* fname);
|
||||||
void BuildMRUMenus();
|
void BuildMRUMenus();
|
||||||
void LoadMRUFile(int position);
|
void LoadMRUFile(int position);
|
||||||
void ClearMRUList();
|
void ClearMRUList();
|
||||||
|
|
||||||
BOOL FileExists(char *fname);
|
BOOL FileExists(TCHAR *fname);
|
||||||
|
|
||||||
HMENU FindSubMenu(HMENU hMenu, UINT uId);
|
HMENU FindSubMenu(HMENU hMenu, UINT uId);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2002 Robert Rainwater
|
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
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@ -18,12 +19,13 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
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 REALSTR(x) #x
|
||||||
#define STR(x) REALSTR(x)
|
#define STR(x) REALSTR(x)
|
||||||
|
|
||||||
#ifdef RELEASE
|
#ifdef RELEASE
|
||||||
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE) " (NSIS Compiler Interface)";
|
const char *NSISW_VERSION = "MakeNSISW " STR(RELEASE) " (NSIS Compiler Interface)";
|
||||||
#else
|
#else
|
||||||
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
|
const char *NSISW_VERSION = "MakeNSISW " __DATE__;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
#include "MyMath.h"
|
#include "MyMath.h"
|
||||||
|
@ -15,12 +17,12 @@ int UserVarsCount, UserFuncsCount;
|
||||||
UserVar UserVars[MAX_USER_VARS];
|
UserVar UserVars[MAX_USER_VARS];
|
||||||
UserFunc UserFuncs[MAX_USER_FUNCS];
|
UserFunc UserFuncs[MAX_USER_FUNCS];
|
||||||
|
|
||||||
void PrintTree(ExpressionItem *root, char *str);
|
void PrintTree(ExpressionItem *root, TCHAR *str);
|
||||||
void ParseString(char *&sp, ExpressionItem* &itemplace);
|
void ParseString(TCHAR *&sp, ExpressionItem* &itemplace);
|
||||||
void CleanupItems(ExpressionItem* &itemplace);
|
void CleanupItems(ExpressionItem* &itemplace);
|
||||||
void PlaceVariable(char *&vb, ParseInfo *pi);
|
void PlaceVariable(TCHAR *&vb, ParseInfo *pi);
|
||||||
|
|
||||||
void PlaceNewItem(char *&vb, ParseInfo *pi, int precedence)
|
void PlaceNewItem(TCHAR *&vb, ParseInfo *pi, int precedence)
|
||||||
{
|
{
|
||||||
ExpressionItem *newroot;
|
ExpressionItem *newroot;
|
||||||
PlaceVariable(vb, pi);
|
PlaceVariable(vb, pi);
|
||||||
|
@ -56,12 +58,12 @@ void PlaceNewItem(char *&vb, ParseInfo *pi, int precedence)
|
||||||
#define NSIS_VARS_STACK 25
|
#define NSIS_VARS_STACK 25
|
||||||
#define NSIS_VARS_NSTACK 26
|
#define NSIS_VARS_NSTACK 26
|
||||||
|
|
||||||
typedef char smallstr[2];
|
typedef TCHAR smallstr[2];
|
||||||
const smallstr NSISVariablesNames[NSIS_VARS_COUNT] = {{'r','0'}, {'r','1'}, {'r','2'}, {'r','3'}, {'r','4'}, {'r','5'}, {'r','6'}, {'r','7'}, {'r','8'}, {'r','9'},
|
const smallstr NSISVariablesNames[NSIS_VARS_COUNT] = {{_T('r'),_T('0')}, {_T('r'),_T('1')}, {_T('r'),_T('2')}, {_T('r'),_T('3')}, {_T('r'),_T('4')}, {_T('r'),_T('5')}, {_T('r'),_T('6')}, {_T('r'),_T('7')}, {_T('r'),_T('8')}, {_T('r'),_T('9')},
|
||||||
{'R','0'}, {'R','1'}, {'R','2'}, {'R','3'}, {'R','4'}, {'R','5'}, {'R','6'}, {'R','7'}, {'R','8'}, {'R','9'},
|
{_T('R'),_T('0')}, {_T('R'),_T('1')}, {_T('R'),_T('2')}, {_T('R'),_T('3')}, {_T('R'),_T('4')}, {_T('R'),_T('5')}, {_T('R'),_T('6')}, {_T('R'),_T('7')}, {_T('R'),_T('8')}, {_T('R'),_T('9')},
|
||||||
{'C','L'}, {'I','D'}, {'O','D'}, {'E','D'}, {'L','G'}, {'S',0}, {'N','S'}};
|
{_T('C'),_T('L')}, {_T('I'),_T('D')}, {_T('O'),_T('D')}, {_T('E'),_T('D')}, {_T('L'),_T('G')}, {_T('S'),0}, {_T('N'),_T('S')}};
|
||||||
|
|
||||||
ExpressionItem *FindVariable(char *varname)
|
ExpressionItem *FindVariable(TCHAR *varname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -98,7 +100,7 @@ ExpressionItem *FindVariable(char *varname)
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaceVariable(char *&vb, ParseInfo *pi)
|
void PlaceVariable(TCHAR *&vb, ParseInfo *pi)
|
||||||
{
|
{
|
||||||
if (vb <= pi->valbuf) return;
|
if (vb <= pi->valbuf) return;
|
||||||
*vb = 0;
|
*vb = 0;
|
||||||
|
@ -112,43 +114,43 @@ typedef double (*math_di)(double, int*);
|
||||||
|
|
||||||
#define MATHFUNCNUM 29
|
#define MATHFUNCNUM 29
|
||||||
const MathFunction MathFunctions[MATHFUNCNUM] = {
|
const MathFunction MathFunctions[MATHFUNCNUM] = {
|
||||||
{{'s','i','n'}, ITF_MATH1 >> 8, sin},
|
{{_T('s'),_T('i'),_T('n')}, ITF_MATH1 >> 8, sin},
|
||||||
{{'s','n','h'}, ITF_MATH1 >> 8, sinh},
|
{{_T('s'),_T('n'),_T('h')}, ITF_MATH1 >> 8, sinh},
|
||||||
{{'a','s','n'}, ITF_MATH1 >> 8, asin},
|
{{_T('a'),_T('s'),_T('n')}, ITF_MATH1 >> 8, asin},
|
||||||
{{'c','o','s'}, ITF_MATH1 >> 8, cos},
|
{{_T('c'),_T('o'),_T('s')}, ITF_MATH1 >> 8, cos},
|
||||||
{{'c','s','h'}, ITF_MATH1 >> 8, cosh},
|
{{_T('c'),_T('s'),_T('h')}, ITF_MATH1 >> 8, cosh},
|
||||||
{{'a','c','s'}, ITF_MATH1 >> 8, acos},
|
{{_T('a'),_T('c'),_T('s')}, ITF_MATH1 >> 8, acos},
|
||||||
{{'t','a','n'}, ITF_MATH1 >> 8, tan},
|
{{_T('t'),_T('a'),_T('n')}, ITF_MATH1 >> 8, tan},
|
||||||
{{'t','n','h'}, ITF_MATH1 >> 8, tanh},
|
{{_T('t'),_T('n'),_T('h')}, ITF_MATH1 >> 8, tanh},
|
||||||
{{'a','t','n'}, ITF_MATH1 >> 8, atan},
|
{{_T('a'),_T('t'),_T('n')}, ITF_MATH1 >> 8, atan},
|
||||||
{{'a','b','s'}, ITF_MATH1 >> 8, fabs},
|
{{_T('a'),_T('b'),_T('s')}, ITF_MATH1 >> 8, fabs},
|
||||||
{{'l','n',0}, ITF_MATH1 >> 8, log},
|
{{_T('l'),_T('n'),0}, ITF_MATH1 >> 8, log},
|
||||||
{{'l','o','g'}, ITF_MATH1 >> 8, log10},
|
{{_T('l'),_T('o'),_T('g')}, ITF_MATH1 >> 8, log10},
|
||||||
{{'e','x','p'}, ITF_MATH1 >> 8, exp},
|
{{_T('e'),_T('x'),_T('p')}, ITF_MATH1 >> 8, exp},
|
||||||
{{'s','q','t'}, ITF_MATH1 >> 8, sqrt},
|
{{_T('s'),_T('q'),_T('t')}, ITF_MATH1 >> 8, sqrt},
|
||||||
{{'c','e','l'}, ITF_MATH1 >> 8, ceil},
|
{{_T('c'),_T('e'),_T('l')}, ITF_MATH1 >> 8, ceil},
|
||||||
{{'f','l','r'}, ITF_MATH1 >> 8, floor},
|
{{_T('f'),_T('l'),_T('r')}, ITF_MATH1 >> 8, floor},
|
||||||
|
|
||||||
{{'a','t','2'}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_d2)atan2},
|
{{_T('a'),_T('t'),_T('2')}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_d2)atan2},
|
||||||
{{'p','o','w'}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_d2)pow},
|
{{_T('p'),_T('o'),_T('w')}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_d2)pow},
|
||||||
{{'f','m','d'}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_d2)fmod},
|
{{_T('f'),_T('m'),_T('d')}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_d2)fmod},
|
||||||
|
|
||||||
// type conversions
|
// type conversions
|
||||||
{{'i',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_INT},
|
{{_T('i'),0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_INT},
|
||||||
{{'s',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_STRING},
|
{{_T('s'),0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_STRING},
|
||||||
{{'f',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_FLOAT},
|
{{_T('f'),0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_FLOAT},
|
||||||
{{'a',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_ARRAY},
|
{{_T('a'),0,0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_ARRAY},
|
||||||
#define ITFT_CARRAY_ID 23
|
#define ITFT_CARRAY_ID 23
|
||||||
{{'c','a',0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_ARRAY},
|
{{_T('c'),_T('a'),0}, ITF_TYPE >> 8, (Math1FuncPtr)ITC_ARRAY},
|
||||||
{{'f','f',0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_FLOATF},
|
{{_T('f'),_T('f'),0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_FLOATF},
|
||||||
{{'l',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_LEN},
|
{{_T('l'),0,0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_LEN},
|
||||||
{{'c',0,0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_CHAR},
|
{{_T('c'),0,0}, ITF_TYPE >> 8, (Math1FuncPtr)FTT_CHAR},
|
||||||
|
|
||||||
{{'f','e','x'}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_di)frexp},
|
{{_T('f'),_T('e'),_T('x')}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_di)frexp},
|
||||||
{{'m','d','f'}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_ddp)modf},
|
{{_T('m'),_T('d'),_T('f')}, ITF_MATH2 >> 8, (Math1FuncPtr)(math_ddp)modf},
|
||||||
};
|
};
|
||||||
|
|
||||||
void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
void PlaceFunction(TCHAR *&vb, TCHAR *&sp, ParseInfo *pi, int redefine)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ExpressionItem *item = pi->item = AllocItem();
|
ExpressionItem *item = pi->item = AllocItem();
|
||||||
|
@ -163,7 +165,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
// get first argument
|
// get first argument
|
||||||
sp++;
|
sp++;
|
||||||
ParseString(sp, *((ExpressionItem **)(&item->param1)));
|
ParseString(sp, *((ExpressionItem **)(&item->param1)));
|
||||||
if (*sp == ',')
|
if (*sp == _T(','))
|
||||||
{
|
{
|
||||||
// get second argument
|
// get second argument
|
||||||
sp++;
|
sp++;
|
||||||
|
@ -185,7 +187,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
item->type = IT_FUNCTION | ITF_USER | i;
|
item->type = IT_FUNCTION | ITF_USER | i;
|
||||||
// get arguments list
|
// get arguments list
|
||||||
ExpressionItem **newplace = ((ExpressionItem **)(&pi->item->param1));
|
ExpressionItem **newplace = ((ExpressionItem **)(&pi->item->param1));
|
||||||
while (*sp != ')')
|
while (*sp != _T(')'))
|
||||||
{
|
{
|
||||||
*newplace = AllocItem();
|
*newplace = AllocItem();
|
||||||
(*newplace)->type = IT_EXPRESSION;
|
(*newplace)->type = IT_EXPRESSION;
|
||||||
|
@ -203,7 +205,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
|
|
||||||
// it's user function define
|
// it's user function define
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
char buffer[128], *buf = buffer;
|
TCHAR buffer[128], *buf = buffer;
|
||||||
|
|
||||||
// workaround for redefine flag - if the function already present,
|
// workaround for redefine flag - if the function already present,
|
||||||
// it will be cleared and redefined
|
// it will be cleared and redefined
|
||||||
|
@ -219,10 +221,10 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
sp++;
|
sp++;
|
||||||
switch (*sp)
|
switch (*sp)
|
||||||
{
|
{
|
||||||
case ' ':
|
case _T(' '):
|
||||||
break;
|
break;
|
||||||
case ',':
|
case _T(','):
|
||||||
case ')':
|
case _T(')'):
|
||||||
if (buf > buffer)
|
if (buf > buffer)
|
||||||
{
|
{
|
||||||
*buf = 0;
|
*buf = 0;
|
||||||
|
@ -234,7 +236,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
flags <<= 1;
|
flags <<= 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '&':
|
case _T('&'):
|
||||||
flags |= 1;
|
flags |= 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -242,7 +244,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (*sp != ')');
|
while (*sp != _T(')'));
|
||||||
|
|
||||||
// prepare flag for fast analisys
|
// prepare flag for fast analisys
|
||||||
for (i = 0; i < f->varsnum; i++)
|
for (i = 0; i < f->varsnum; i++)
|
||||||
|
@ -253,7 +255,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
}
|
}
|
||||||
|
|
||||||
// find nearest round bracket - function body
|
// find nearest round bracket - function body
|
||||||
while (*sp != '(' && *sp) sp++;
|
while (*sp != _T('(') && *sp) sp++;
|
||||||
if (!*sp)
|
if (!*sp)
|
||||||
return;
|
return;
|
||||||
sp++;
|
sp++;
|
||||||
|
@ -265,17 +267,17 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// dump function (in debug mode)
|
// dump function (in debug mode)
|
||||||
char place[1024];
|
TCHAR place[1024];
|
||||||
wsprintf(place, "function %s(", f->name);
|
wsprintf(place, _T("function %s("), f->name);
|
||||||
flags = f->varflags;
|
flags = f->varflags;
|
||||||
for (i = 0; i < f->varsnum; i++)
|
for (i = 0; i < f->varsnum; i++)
|
||||||
{
|
{
|
||||||
if (flags&1) lstrcat(place, "&");
|
if (flags&1) lstrcat(place, _T("&"));
|
||||||
lstrcat(place, UserVars[f->vars[i]].name);
|
lstrcat(place, UserVars[f->vars[i]].name);
|
||||||
if (i < f->varsnum-1) lstrcat(place, ", ");
|
if (i < f->varsnum-1) lstrcat(place, _T(", "));
|
||||||
flags >>= 1;
|
flags >>= 1;
|
||||||
}
|
}
|
||||||
lstrcat(place, ")");
|
lstrcat(place, _T(")"));
|
||||||
PrintTree(f->root, place);
|
PrintTree(f->root, place);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -290,7 +292,7 @@ void PlaceFunction(char *&vb, char *&sp, ParseInfo *pi, int redefine)
|
||||||
#define PO_USESPRE 0x40 // operator will use pre operand
|
#define PO_USESPRE 0x40 // operator will use pre operand
|
||||||
#define PO_USESPOST 0x80 // operator will use post operan
|
#define PO_USESPOST 0x80 // operator will use post operan
|
||||||
|
|
||||||
void PlaceOp(char *&vb, int type, int precedence, ParseInfo *pi)
|
void PlaceOp(TCHAR *&vb, int type, int precedence, ParseInfo *pi)
|
||||||
{
|
{
|
||||||
PlaceVariable(vb, pi);
|
PlaceVariable(vb, pi);
|
||||||
if ((type & PO_UNARYPRE) && (!pi->item))
|
if ((type & PO_UNARYPRE) && (!pi->item))
|
||||||
|
@ -332,54 +334,54 @@ void PlaceOp(char *&vb, int type, int precedence, ParseInfo *pi)
|
||||||
const OpStruct Operators[OPSNUM] =
|
const OpStruct Operators[OPSNUM] =
|
||||||
{
|
{
|
||||||
// three byte ops
|
// three byte ops
|
||||||
{{'>','>','='}, 14, ITO_SHR | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{{_T('>'),_T('>'),_T('=')}, 14, ITO_SHR | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{{'<','<','='}, 14, ITO_SHL | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{{_T('<'),_T('<'),_T('=')}, 14, ITO_SHL | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
|
|
||||||
// two byte ops
|
// two byte ops
|
||||||
// !!! don't forget to change Set Operator Precedence !!!
|
// !!! don't forget to change Set Operator Precedence !!!
|
||||||
{"-=", 14, ITO_MINUS | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("-="), 14, ITO_MINUS | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"+=", 14, ITO_PLUS | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("+="), 14, ITO_PLUS | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"/=", 14, ITO_DIV | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("/="), 14, ITO_DIV | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"*=", 14, ITO_MUL | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("*="), 14, ITO_MUL | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"|=", 14, ITO_OR | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("|="), 14, ITO_OR | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"&=", 14, ITO_AND | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("&="), 14, ITO_AND | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"^=", 14, ITO_XOR | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("^="), 14, ITO_XOR | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"%=", 14, ITO_MOD | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("%="), 14, ITO_MOD | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"--", 2, ITO_DEC | PO_POSTNONCONST | PO_PRENONCONST | PO_UNARYPRE | PO_UNARYPOST | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("--"), 2, ITO_DEC | PO_POSTNONCONST | PO_PRENONCONST | PO_UNARYPRE | PO_UNARYPOST | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{"++", 2, ITO_INC | PO_POSTNONCONST | PO_PRENONCONST | PO_UNARYPRE | PO_UNARYPOST | PO_SET | PO_USESPRE | PO_USESPOST},
|
{_T("++"), 2, ITO_INC | PO_POSTNONCONST | PO_PRENONCONST | PO_UNARYPRE | PO_UNARYPOST | PO_SET | PO_USESPRE | PO_USESPOST},
|
||||||
{">>", 6, ITO_SHR | PO_USESPRE | PO_USESPOST},
|
{_T(">>"), 6, ITO_SHR | PO_USESPRE | PO_USESPOST},
|
||||||
{"<<", 6, ITO_SHL | PO_USESPRE | PO_USESPOST},
|
{_T("<<"), 6, ITO_SHL | PO_USESPRE | PO_USESPOST},
|
||||||
|
|
||||||
// logical
|
// logical
|
||||||
{"&&", 12, ITO_LAND | PO_USESPRE | PO_USESPOST},
|
{_T("&&"), 12, ITO_LAND | PO_USESPRE | PO_USESPOST},
|
||||||
{"||", 13, ITO_LOR | PO_USESPRE | PO_USESPOST},
|
{_T("||"), 13, ITO_LOR | PO_USESPRE | PO_USESPOST},
|
||||||
|
|
||||||
// comparisons
|
// comparisons
|
||||||
{"<=", 7, ITO_LE | PO_USESPRE | PO_USESPOST},
|
{_T("<="), 7, ITO_LE | PO_USESPRE | PO_USESPOST},
|
||||||
{"=<", 7, ITO_LE | PO_USESPRE | PO_USESPOST},
|
{_T("=<"), 7, ITO_LE | PO_USESPRE | PO_USESPOST},
|
||||||
{">=", 7, ITO_GE | PO_USESPRE | PO_USESPOST},
|
{_T(">="), 7, ITO_GE | PO_USESPRE | PO_USESPOST},
|
||||||
{"=>", 7, ITO_GE | PO_USESPRE | PO_USESPOST},
|
{_T("=>"), 7, ITO_GE | PO_USESPRE | PO_USESPOST},
|
||||||
{"!=", 8, ITO_NE | PO_USESPRE | PO_USESPOST},
|
{_T("!="), 8, ITO_NE | PO_USESPRE | PO_USESPOST},
|
||||||
{"==", 8, ITO_EQ | PO_USESPRE | PO_USESPOST},
|
{_T("=="), 8, ITO_EQ | PO_USESPRE | PO_USESPOST},
|
||||||
|
|
||||||
// single byte ops
|
// single byte ops
|
||||||
// !!! don't forget to change Set Operator Precedence !!!
|
// !!! don't forget to change Set Operator Precedence !!!
|
||||||
{"=", 14, ITO_SET | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPOST},
|
{_T("="), 14, ITO_SET | PO_PRENONCONST | PO_LASTOP | PO_SET | PO_USESPOST},
|
||||||
{"+", 5, ITO_PLUS | PO_USESPRE | PO_USESPOST},
|
{_T("+"), 5, ITO_PLUS | PO_USESPRE | PO_USESPOST},
|
||||||
{"-", 5, ITO_MINUS | PO_USESPRE | PO_USESPOST | PO_UNARYPRE},
|
{_T("-"), 5, ITO_MINUS | PO_USESPRE | PO_USESPOST | PO_UNARYPRE},
|
||||||
{"*", 4, ITO_MUL | PO_USESPRE | PO_USESPOST | PO_UNARYPRE},
|
{_T("*"), 4, ITO_MUL | PO_USESPRE | PO_USESPOST | PO_UNARYPRE},
|
||||||
{"/", 4, ITO_DIV | PO_USESPRE | PO_USESPOST},
|
{_T("/"), 4, ITO_DIV | PO_USESPRE | PO_USESPOST},
|
||||||
{"%", 4, ITO_MOD | PO_USESPRE | PO_USESPOST},
|
{_T("%"), 4, ITO_MOD | PO_USESPRE | PO_USESPOST},
|
||||||
{"<", 7, ITO_LS | PO_USESPRE | PO_USESPOST},
|
{_T("<"), 7, ITO_LS | PO_USESPRE | PO_USESPOST},
|
||||||
{">", 7, ITO_GR | PO_USESPRE | PO_USESPOST},
|
{_T(">"), 7, ITO_GR | PO_USESPRE | PO_USESPOST},
|
||||||
{"&", 9, ITO_AND | PO_USESPRE | PO_USESPOST | PO_UNARYPRE},
|
{_T("&"), 9, ITO_AND | PO_USESPRE | PO_USESPOST | PO_UNARYPRE},
|
||||||
{"|", 11, ITO_OR | PO_USESPRE | PO_USESPOST},
|
{_T("|"), 11, ITO_OR | PO_USESPRE | PO_USESPOST},
|
||||||
{"^", 10, ITO_XOR | PO_USESPRE | PO_USESPOST},
|
{_T("^"), 10, ITO_XOR | PO_USESPRE | PO_USESPOST},
|
||||||
{"~", 3, ITO_NOT | PO_USESPOST | PO_UNARYPRE},
|
{_T("~"), 3, ITO_NOT | PO_USESPOST | PO_UNARYPRE},
|
||||||
{"!", 3, ITO_LNOT |PO_USESPOST | PO_UNARYPRE}
|
{_T("!"), 3, ITO_LNOT |PO_USESPOST | PO_UNARYPRE}
|
||||||
};
|
};
|
||||||
|
|
||||||
void CheckForOperator(char *&sp, char *&vb, ParseInfo *pi)
|
void CheckForOperator(TCHAR *&sp, TCHAR *&vb, ParseInfo *pi)
|
||||||
{
|
{
|
||||||
for (int op = 0; op < OPSNUM; op++)
|
for (int op = 0; op < OPSNUM; op++)
|
||||||
{
|
{
|
||||||
|
@ -397,44 +399,44 @@ void CheckForOperator(char *&sp, char *&vb, ParseInfo *pi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseString(char *&sp, ExpressionItem* &itemplace)
|
void ParseString(TCHAR *&sp, ExpressionItem* &itemplace)
|
||||||
{
|
{
|
||||||
ParseInfo pi = {0, NULL, NULL, &itemplace, &itemplace};
|
ParseInfo pi = {0, NULL, NULL, &itemplace, &itemplace};
|
||||||
|
|
||||||
int redefine = 0;
|
int redefine = 0;
|
||||||
char *vb = pi.valbuf;
|
TCHAR *vb = pi.valbuf;
|
||||||
// cycle until current expression end
|
// cycle until current expression end
|
||||||
while ((*sp != 0) && (*sp != ')') && (*sp != '}') &&
|
while ((*sp != 0) && (*sp != _T(')')) && (*sp != _T('}')) &&
|
||||||
(*sp != ']') && (*sp != ','))
|
(*sp != _T(']')) && (*sp != _T(',')))
|
||||||
{
|
{
|
||||||
int processed = 1;
|
int processed = 1;
|
||||||
switch (*sp)
|
switch (*sp)
|
||||||
{
|
{
|
||||||
case ' ':
|
case _T(' '):
|
||||||
case '\t':
|
case _T('\t'):
|
||||||
sp++;
|
sp++;
|
||||||
break;
|
break;
|
||||||
case ';':
|
case _T(';'):
|
||||||
// expression delimeter
|
// expression delimeter
|
||||||
PlaceNewItem(vb, &pi, 255);
|
PlaceNewItem(vb, &pi, 255);
|
||||||
if (*pi.root) pi.SetupNewRoot = 1;
|
if (*pi.root) pi.SetupNewRoot = 1;
|
||||||
sp++;
|
sp++;
|
||||||
break;
|
break;
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case _T('5'): case _T('6'): case _T('7'): case _T('8'): case _T('9'):
|
||||||
// variable & function names could contain numbers as non first chars
|
// variable & function names could contain numbers as non first chars
|
||||||
if (vb > pi.valbuf)
|
if (vb > pi.valbuf)
|
||||||
{
|
{
|
||||||
processed = FALSE;
|
processed = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '\'': case '\"': case '`':
|
case _T('\''): case _T('\"'): case _T('`'):
|
||||||
// constant meet
|
// constant meet
|
||||||
pi.item = AllocItem();
|
pi.item = AllocItem();
|
||||||
StringToItem(sp, pi.item, STI_STRING | STI_FLOAT | STI_INT);
|
StringToItem(sp, pi.item, STI_STRING | STI_FLOAT | STI_INT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '(': // start of function or expression
|
case _T('('): // start of function or expression
|
||||||
if (vb > pi.valbuf)
|
if (vb > pi.valbuf)
|
||||||
{
|
{
|
||||||
// thats function
|
// thats function
|
||||||
|
@ -444,14 +446,14 @@ void ParseString(char *&sp, ExpressionItem* &itemplace)
|
||||||
// expression
|
// expression
|
||||||
sp++;
|
sp++;
|
||||||
ParseString(sp, pi.item);
|
ParseString(sp, pi.item);
|
||||||
if (*sp == ')') sp++;
|
if (*sp == _T(')')) sp++;
|
||||||
}
|
}
|
||||||
redefine = 0;
|
redefine = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '#': // start of one of logical expresions
|
case _T('#'): // start of one of logical expresions
|
||||||
sp++;
|
sp++;
|
||||||
if ((*sp != '[') && (*sp != '{'))
|
if ((*sp != _T('[')) && (*sp != _T('{')))
|
||||||
{
|
{
|
||||||
// function redefine flag
|
// function redefine flag
|
||||||
redefine = 1;
|
redefine = 1;
|
||||||
|
@ -460,14 +462,14 @@ void ParseString(char *&sp, ExpressionItem* &itemplace)
|
||||||
{
|
{
|
||||||
pi.item = AllocItem();
|
pi.item = AllocItem();
|
||||||
// IF or WHILE
|
// IF or WHILE
|
||||||
pi.item->type = ((*sp == '[')?(IT_LOGIC | ITL_IF):(IT_LOGIC | ITL_WHILE));
|
pi.item->type = ((*sp == _T('['))?(IT_LOGIC | ITL_IF):(IT_LOGIC | ITL_WHILE));
|
||||||
// first expr - logic statement
|
// first expr - logic statement
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
ParseString(sp, *((ExpressionItem **)(&pi.item->param1)));
|
ParseString(sp, *((ExpressionItem **)(&pi.item->param1)));
|
||||||
// ok, second expr - then, third - else statement.. others???
|
// ok, second expr - then, third - else statement.. others???
|
||||||
ExpressionItem **newplace = ((ExpressionItem **)(&pi.item->param2));
|
ExpressionItem **newplace = ((ExpressionItem **)(&pi.item->param2));
|
||||||
while (*sp == ',')
|
while (*sp == _T(','))
|
||||||
{
|
{
|
||||||
*newplace = AllocItem();
|
*newplace = AllocItem();
|
||||||
(*newplace)->type = IT_EXPRESSION;
|
(*newplace)->type = IT_EXPRESSION;
|
||||||
|
@ -479,14 +481,14 @@ void ParseString(char *&sp, ExpressionItem* &itemplace)
|
||||||
sp++;
|
sp++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '[':
|
case _T('['):
|
||||||
{
|
{
|
||||||
// thats array access
|
// thats array access
|
||||||
PlaceOp(vb, IT_ARRAY | ITA_ACCESS | PO_UNARYPOST, 1, &pi);
|
PlaceOp(vb, IT_ARRAY | ITA_ACCESS | PO_UNARYPOST, 1, &pi);
|
||||||
sp++;
|
sp++;
|
||||||
// item index
|
// item index
|
||||||
ParseString(sp, *(ExpressionItem **)&(pi.item->param2));
|
ParseString(sp, *(ExpressionItem **)&(pi.item->param2));
|
||||||
if (*sp == ',')
|
if (*sp == _T(','))
|
||||||
{
|
{
|
||||||
// two indexes - string access
|
// two indexes - string access
|
||||||
ExpressionItem *it = AllocItem();
|
ExpressionItem *it = AllocItem();
|
||||||
|
@ -502,7 +504,7 @@ void ParseString(char *&sp, ExpressionItem* &itemplace)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '{': // start of array define
|
case _T('{'): // start of array define
|
||||||
{
|
{
|
||||||
// array define - constists of array copy operator and array define itself
|
// array define - constists of array copy operator and array define itself
|
||||||
|
|
||||||
|
@ -516,7 +518,7 @@ void ParseString(char *&sp, ExpressionItem* &itemplace)
|
||||||
ArrayDesc *ad = *((ArrayDesc**)&(ai->param1));
|
ArrayDesc *ad = *((ArrayDesc**)&(ai->param1));
|
||||||
|
|
||||||
// parse array initializers
|
// parse array initializers
|
||||||
while (*sp != '}')
|
while (*sp != _T('}'))
|
||||||
{
|
{
|
||||||
sp++;
|
sp++;
|
||||||
ParseString(sp, ad->array[ad->count]);
|
ParseString(sp, ad->array[ad->count]);
|
||||||
|
@ -527,9 +529,9 @@ void ParseString(char *&sp, ExpressionItem* &itemplace)
|
||||||
sp++;
|
sp++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '-': case '+': case '<': case '=': case '>':
|
case _T('-'): case _T('+'): case _T('<'): case _T('='): case _T('>'):
|
||||||
case '/': case '*': case '~': case '^': case '!':
|
case _T('/'): case _T('*'): case _T('~'): case _T('^'): case _T('!'):
|
||||||
case '&': case '|': case '%':
|
case _T('&'): case _T('|'): case _T('%'):
|
||||||
CheckForOperator(sp, vb, &pi);
|
CheckForOperator(sp, vb, &pi);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -594,8 +596,8 @@ void CleanupItems(ExpressionItem* &itemplace)
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
HANDLE myfile;
|
HANDLE myfile;
|
||||||
|
|
||||||
char *opsnames[] = {"", "-", "+", "<<", ">>", "*", "/", "=", "&&", "||", "++", "--",
|
TCHAR *opsnames[] = {_T(""), _T("-"), _T("+"), _T("<<"), _T(">>"), _T("*"), _T("/"), _T("="), _T("&&"), _T("||"), _T("++"), _T("--"),
|
||||||
"=<", ">=", "!=", "==", "<", ">", "&", "%", "|", "^", "~", "!"};
|
_T("=<"), _T(">="), _T("!="), _T("=="), _T("<"), _T(">"), _T("&"), _T("%"), _T("|"), _T("^"), _T("~"), _T("!")};
|
||||||
|
|
||||||
void PrintNode(int index, int spaces, ExpressionItem* itemplace)
|
void PrintNode(int index, int spaces, ExpressionItem* itemplace)
|
||||||
{
|
{
|
||||||
|
@ -605,7 +607,7 @@ void PrintNode(int index, int spaces, ExpressionItem* itemplace)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
DWORD wrote;
|
DWORD wrote;
|
||||||
char buffer[1024], *place = buffer;
|
TCHAR buffer[1024], *place = buffer;
|
||||||
for (int k = 0; k < spaces; k++)
|
for (int k = 0; k < spaces; k++)
|
||||||
*(place++) = 32;
|
*(place++) = 32;
|
||||||
*place = 0;
|
*place = 0;
|
||||||
|
@ -613,100 +615,100 @@ void PrintNode(int index, int spaces, ExpressionItem* itemplace)
|
||||||
switch (item->type & ITEMTYPE)
|
switch (item->type & ITEMTYPE)
|
||||||
{
|
{
|
||||||
case IT_EXPRESSION:
|
case IT_EXPRESSION:
|
||||||
wsprintf(place, "Expression Place-Holder ");
|
wsprintf(place, _T("Expression Place-Holder "));
|
||||||
break;
|
break;
|
||||||
case IT_CONST:
|
case IT_CONST:
|
||||||
switch (item->type & ITEMSUBTYPE)
|
switch (item->type & ITEMSUBTYPE)
|
||||||
{
|
{
|
||||||
case ITC_STRING:
|
case ITC_STRING:
|
||||||
wsprintf(place, "String: \"%s\"", (char *) item->param1);
|
wsprintf(place, _T("String: \"%s\""), (TCHAR *) item->param1);
|
||||||
break;
|
break;
|
||||||
case ITC_INT:
|
case ITC_INT:
|
||||||
wsprintf(place, "Int: ");
|
wsprintf(place, _T("Int: "));
|
||||||
itoa64(*((__int64*)&(item->param1)), place+5);
|
itoa64(*((__int64*)&(item->param1)), place+5);
|
||||||
break;
|
break;
|
||||||
case ITC_FLOAT:
|
case ITC_FLOAT:
|
||||||
wsprintf(place, "Float: ");
|
wsprintf(place, _T("Float: "));
|
||||||
FloatFormat(place+7, *((double*)&(item->param1)), 6);
|
FloatFormat(place+7, *((double*)&(item->param1)), 6);
|
||||||
break;
|
break;
|
||||||
case ITC_ARRAY:
|
case ITC_ARRAY:
|
||||||
ArrayDesc *ad = (ArrayDesc*) item->param1;
|
ArrayDesc *ad = (ArrayDesc*) item->param1;
|
||||||
wsprintf(place, "Array, ptr %08X, size %d, count %d, references %d",
|
wsprintf(place, _T("Array, ptr %08X, size %d, count %d, references %d"),
|
||||||
ad->array, ad->size, ad->count, ad->references);
|
ad->array, ad->size, ad->count, ad->references);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strcat(place, " ");
|
_tcscat(place, _T(" "));
|
||||||
break;
|
break;
|
||||||
case IT_OPERATOR:
|
case IT_OPERATOR:
|
||||||
wsprintf(place, "Op: %s%s ", opsnames[(item->type & ITEMSUBTYPE) >> 8], (item->type & PO_SET)?("(=)"):(""));
|
wsprintf(place, _T("Op: %s%s "), opsnames[(item->type & ITEMSUBTYPE) >> 8], (item->type & PO_SET)?(_T("(=)")):(_T("")));
|
||||||
break;
|
break;
|
||||||
case IT_VARIABLE:
|
case IT_VARIABLE:
|
||||||
switch (item->type & ITEMSUBTYPE)
|
switch (item->type & ITEMSUBTYPE)
|
||||||
{
|
{
|
||||||
case ITV_NSIS:
|
case ITV_NSIS:
|
||||||
{
|
{
|
||||||
char buffer[128];
|
TCHAR buffer[128];
|
||||||
buffer[0] = NSISVariablesNames[item->type & ITEMOPTIONS][0];
|
buffer[0] = NSISVariablesNames[item->type & ITEMOPTIONS][0];
|
||||||
buffer[1] = NSISVariablesNames[item->type & ITEMOPTIONS][1];
|
buffer[1] = NSISVariablesNames[item->type & ITEMOPTIONS][1];
|
||||||
buffer[2] = 0;
|
buffer[2] = 0;
|
||||||
wsprintf(place, "Var: %s (%d) ",
|
wsprintf(place, _T("Var: %s (%d) "),
|
||||||
buffer,
|
buffer,
|
||||||
item->type & ITEMOPTIONS);
|
item->type & ITEMOPTIONS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ITV_USER:
|
case ITV_USER:
|
||||||
wsprintf(place, "Var: %s (%d) ", UserVars[item->type & ITEMOPTIONS].name, item->type & ITEMOPTIONS);
|
wsprintf(place, _T("Var: %s (%d) "), UserVars[item->type & ITEMOPTIONS].name, item->type & ITEMOPTIONS);
|
||||||
break;
|
break;
|
||||||
case ITV_STACK:
|
case ITV_STACK:
|
||||||
wsprintf(place, "Plugin Stack ");
|
wsprintf(place, _T("Plugin Stack "));
|
||||||
break;
|
break;
|
||||||
case ITV_NSTACK:
|
case ITV_NSTACK:
|
||||||
wsprintf(place, "NSIS Stack ");
|
wsprintf(place, _T("NSIS Stack "));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IT_LOGIC:
|
case IT_LOGIC:
|
||||||
if ((item->type & ITEMSUBTYPE) == ITL_IF)
|
if ((item->type & ITEMSUBTYPE) == ITL_IF)
|
||||||
wsprintf(place, "IF ");
|
wsprintf(place, _T("IF "));
|
||||||
else
|
else
|
||||||
wsprintf(place, "WHILE ");
|
wsprintf(place, _T("WHILE "));
|
||||||
break;
|
break;
|
||||||
case IT_FUNCTION:
|
case IT_FUNCTION:
|
||||||
if (((item->type & ITEMSUBTYPE) == ITF_MATH1) ||
|
if (((item->type & ITEMSUBTYPE) == ITF_MATH1) ||
|
||||||
((item->type & ITEMSUBTYPE) == ITF_MATH2) ||
|
((item->type & ITEMSUBTYPE) == ITF_MATH2) ||
|
||||||
((item->type & ITEMSUBTYPE) == ITF_TYPE))
|
((item->type & ITEMSUBTYPE) == ITF_TYPE))
|
||||||
{
|
{
|
||||||
char buffer[128];
|
TCHAR buffer[128];
|
||||||
buffer[0] = (MathFunctions[item->type &ITEMOPTIONS].name)[0];
|
buffer[0] = (MathFunctions[item->type &ITEMOPTIONS].name)[0];
|
||||||
buffer[1] = (MathFunctions[item->type &ITEMOPTIONS].name)[1];
|
buffer[1] = (MathFunctions[item->type &ITEMOPTIONS].name)[1];
|
||||||
buffer[2] = (MathFunctions[item->type &ITEMOPTIONS].name)[2];
|
buffer[2] = (MathFunctions[item->type &ITEMOPTIONS].name)[2];
|
||||||
buffer[3] = 0;
|
buffer[3] = 0;
|
||||||
wsprintf(place, "Built-In Function %s() [%d] ",
|
wsprintf(place, _T("Built-In Function %s() [%d] "),
|
||||||
buffer,
|
buffer,
|
||||||
item->type &ITEMOPTIONS);
|
item->type &ITEMOPTIONS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UserFunc *f = &(UserFuncs[item->type & ITEMOPTIONS]);
|
UserFunc *f = &(UserFuncs[item->type & ITEMOPTIONS]);
|
||||||
wsprintf(place, "User Function: %s(", f->name);
|
wsprintf(place, _T("User Function: %s("), f->name);
|
||||||
int flags = f->varflags;
|
int flags = f->varflags;
|
||||||
for (int i = 0; i < f->varsnum; i++)
|
for (int i = 0; i < f->varsnum; i++)
|
||||||
{
|
{
|
||||||
if (flags&1) lstrcat(place, "&");
|
if (flags&1) lstrcat(place, _T("&"));
|
||||||
lstrcat(place, UserVars[f->vars[i]].name);
|
lstrcat(place, UserVars[f->vars[i]].name);
|
||||||
if (i < f->varsnum-1) lstrcat(place, ", ");
|
if (i < f->varsnum-1) lstrcat(place, _T(", "));
|
||||||
flags >>= 1;
|
flags >>= 1;
|
||||||
}
|
}
|
||||||
lstrcat(place, ") ");
|
lstrcat(place, _T(") "));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IT_ARRAY:
|
case IT_ARRAY:
|
||||||
wsprintf(place, "Array access [] ");
|
wsprintf(place, _T("Array access [] "));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
place += lstrlen(place);
|
place += lstrlen(place);
|
||||||
wsprintf(place, "Addr: %08X Type: %08X Next: %08X Param1: %08X Param2: %08X", item, item->type, item->next, item->param1, item->param2);
|
wsprintf(place, _T("Addr: %08X Type: %08X Next: %08X Param1: %08X Param2: %08X"), item, item->type, item->next, item->param1, item->param2);
|
||||||
lstrcat(place, "\n");
|
lstrcat(place, _T("\n"));
|
||||||
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
||||||
if (((item->type & ITEMTYPE) != IT_CONST) && ((item->type & (ITEMTYPE|ITEMSUBTYPE)) != (IT_VARIABLE|ITV_ARRITEM)))
|
if (((item->type & ITEMTYPE) != IT_CONST) && ((item->type & (ITEMTYPE|ITEMSUBTYPE)) != (IT_VARIABLE|ITV_ARRITEM)))
|
||||||
{
|
{
|
||||||
|
@ -719,13 +721,13 @@ void PrintNode(int index, int spaces, ExpressionItem* itemplace)
|
||||||
show = 1;
|
show = 1;
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
wsprintf(place, "Sub1:\n");
|
wsprintf(place, _T("Sub1:\n"));
|
||||||
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
||||||
}
|
}
|
||||||
PrintNode(1, spaces + 4, *((ExpressionItem**) &item->param1));
|
PrintNode(1, spaces + 4, *((ExpressionItem**) &item->param1));
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
wsprintf(place, "Sub2:\n");
|
wsprintf(place, _T("Sub2:\n"));
|
||||||
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
||||||
}
|
}
|
||||||
PrintNode(2, spaces + 4, *((ExpressionItem**) &item->param2));
|
PrintNode(2, spaces + 4, *((ExpressionItem**) &item->param2));
|
||||||
|
@ -743,12 +745,12 @@ void PrintNode(int index, int spaces, ExpressionItem* itemplace)
|
||||||
} while (item != NULL);
|
} while (item != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintTree(ExpressionItem *root, char *str)
|
void PrintTree(ExpressionItem *root, TCHAR *str)
|
||||||
{
|
{
|
||||||
myfile = CreateFile("d:\\math.debug", GENERIC_ALL, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, 0);
|
myfile = CreateFile(_T("d:\\math.debug"), GENERIC_ALL, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, 0);
|
||||||
SetFilePointer(myfile, 0, NULL, FILE_END);
|
SetFilePointer(myfile, 0, NULL, FILE_END);
|
||||||
char buffer[1024]; DWORD wrote;
|
TCHAR buffer[1024]; DWORD wrote;
|
||||||
wsprintf(buffer, "New tree for \'%s\'\n", str);
|
wsprintf(buffer, _T("New tree for \'%s\'\n"), str);
|
||||||
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
WriteFile(myfile, buffer, lstrlen(buffer), &wrote, NULL);
|
||||||
|
|
||||||
PrintNode(0, 4, root);
|
PrintNode(0, 4, root);
|
||||||
|
@ -776,7 +778,7 @@ void CopyArray(ExpressionItem *&item)
|
||||||
|
|
||||||
void ItemToType(ExpressionItem* &item, int type)
|
void ItemToType(ExpressionItem* &item, int type)
|
||||||
{
|
{
|
||||||
char *buffer, *bp;
|
TCHAR *buffer, *bp;
|
||||||
if (item == NULL) return;
|
if (item == NULL) return;
|
||||||
int itemt = item->type & ITEMTYPE, oldtype = item->type & ITEMSUBTYPE;
|
int itemt = item->type & ITEMTYPE, oldtype = item->type & ITEMSUBTYPE;
|
||||||
|
|
||||||
|
@ -796,7 +798,7 @@ void ItemToType(ExpressionItem* &item, int type)
|
||||||
*((double *)&(item->param1)) = (double) *((__int64 *)&(item->param1));
|
*((double *)&(item->param1)) = (double) *((__int64 *)&(item->param1));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bp = buffer = (char*) item->param1;
|
bp = buffer = (TCHAR*) item->param1;
|
||||||
StringToItem(buffer, item, STI_FLOAT);
|
StringToItem(buffer, item, STI_FLOAT);
|
||||||
dbgGlobalFree(bp);
|
dbgGlobalFree(bp);
|
||||||
}
|
}
|
||||||
|
@ -806,7 +808,7 @@ void ItemToType(ExpressionItem* &item, int type)
|
||||||
*((__int64 *)&(item->param1)) = (__int64) *((double *)&(item->param1));
|
*((__int64 *)&(item->param1)) = (__int64) *((double *)&(item->param1));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bp = buffer = (char*) item->param1;
|
bp = buffer = (TCHAR*) item->param1;
|
||||||
StringToItem(buffer, item, STI_INT);
|
StringToItem(buffer, item, STI_INT);
|
||||||
dbgGlobalFree(bp);
|
dbgGlobalFree(bp);
|
||||||
}
|
}
|
||||||
|
@ -814,7 +816,7 @@ void ItemToType(ExpressionItem* &item, int type)
|
||||||
case ITC_ARRAY:
|
case ITC_ARRAY:
|
||||||
if (oldtype == ITC_STRING)
|
if (oldtype == ITC_STRING)
|
||||||
{
|
{
|
||||||
char *buf = (char*) item->param1;
|
TCHAR *buf = (TCHAR*) item->param1;
|
||||||
int len = lstrlen(buf)+1;
|
int len = lstrlen(buf)+1;
|
||||||
ExpressionItem *ni = AllocArray(lstrlen(buf)+1);
|
ExpressionItem *ni = AllocArray(lstrlen(buf)+1);
|
||||||
ArrayDesc *ad = (ArrayDesc*) ni->param1;
|
ArrayDesc *ad = (ArrayDesc*) ni->param1;
|
||||||
|
@ -843,7 +845,7 @@ void SaveResult(ExpressionItem *var, ExpressionItem *result)
|
||||||
case ITV_NSIS:
|
case ITV_NSIS:
|
||||||
{
|
{
|
||||||
// store string result direct to NSIS variable
|
// store string result direct to NSIS variable
|
||||||
char *ptr = g_variables + varindex*g_stringsize;
|
TCHAR *ptr = g_variables + varindex*g_stringsize;
|
||||||
ItemToString(ptr, result);
|
ItemToString(ptr, result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -869,7 +871,7 @@ void SaveResult(ExpressionItem *var, ExpressionItem *result)
|
||||||
break;
|
break;
|
||||||
case ITV_NSTACK:
|
case ITV_NSTACK:
|
||||||
{
|
{
|
||||||
char *buf = AllocString();
|
TCHAR *buf = AllocString();
|
||||||
ItemToString(buf, result);
|
ItemToString(buf, result);
|
||||||
pushstring(buf);
|
pushstring(buf);
|
||||||
dbgGlobalFree(buf);
|
dbgGlobalFree(buf);
|
||||||
|
@ -912,7 +914,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
{
|
{
|
||||||
// nsis
|
// nsis
|
||||||
result = AllocItem();
|
result = AllocItem();
|
||||||
char *variable = getuservariable(ioptions);
|
TCHAR *variable = getuservariable(ioptions);
|
||||||
StringToItem(variable, result, options);
|
StringToItem(variable, result, options);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -947,7 +949,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
case ITV_NSTACK:
|
case ITV_NSTACK:
|
||||||
{
|
{
|
||||||
// NSIS stack
|
// NSIS stack
|
||||||
char buffer[1024], *buf = buffer;
|
TCHAR buffer[1024], *buf = buffer;
|
||||||
result = AllocItem();
|
result = AllocItem();
|
||||||
popstring(buffer);
|
popstring(buffer);
|
||||||
StringToItem(buf, result, options);
|
StringToItem(buf, result, options);
|
||||||
|
@ -1111,8 +1113,8 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
case ITC_STRING:
|
case ITC_STRING:
|
||||||
{
|
{
|
||||||
int ir = -666;
|
int ir = -666;
|
||||||
char *i1 = (item1)?((char*)item1->param1):(NULL);
|
TCHAR *i1 = (item1)?((TCHAR*)item1->param1):(NULL);
|
||||||
char *i2 = (item2)?((char*)item2->param1):(NULL);
|
TCHAR *i2 = (item2)?((TCHAR*)item2->param1):(NULL);
|
||||||
int sc = (i1 && i2)?(lstrcmp(i1, i2)):((i1)?(1):((i2)?(-1):(0)));
|
int sc = (i1 && i2)?(lstrcmp(i1, i2)):((i1)?(1):((i2)?(-1):(0)));
|
||||||
|
|
||||||
switch (subtype)
|
switch (subtype)
|
||||||
|
@ -1277,7 +1279,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
result = AllocItem();
|
result = AllocItem();
|
||||||
result->type = IT_CONST | ITC_STRING;
|
result->type = IT_CONST | ITC_STRING;
|
||||||
result->param1 = (EIPARAM) AllocString();
|
result->param1 = (EIPARAM) AllocString();
|
||||||
FloatFormat((char*) result->param1, value, format);
|
FloatFormat((TCHAR*) result->param1, value, format);
|
||||||
CleanupItems(arg1); CleanupItems(arg2);
|
CleanupItems(arg1); CleanupItems(arg2);
|
||||||
} else if (newtype == FTT_LEN)
|
} else if (newtype == FTT_LEN)
|
||||||
{
|
{
|
||||||
|
@ -1297,7 +1299,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
if ((result->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST|ITC_STRING))
|
if ((result->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST|ITC_STRING))
|
||||||
{
|
{
|
||||||
// ok, that's string
|
// ok, that's string
|
||||||
int len = lstrlen((char*)result->param1);
|
int len = lstrlen((TCHAR*)result->param1);
|
||||||
dbgGlobalFree((HGLOBAL) result->param1);
|
dbgGlobalFree((HGLOBAL) result->param1);
|
||||||
*((__int64*)&(result->param1)) = (__int64) len;
|
*((__int64*)&(result->param1)) = (__int64) len;
|
||||||
result->type = IT_CONST | ITC_INT;
|
result->type = IT_CONST | ITC_INT;
|
||||||
|
@ -1309,7 +1311,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
if ((result->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST|ITC_STRING))
|
if ((result->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST|ITC_STRING))
|
||||||
{
|
{
|
||||||
// ok, that's string - convert first char to int
|
// ok, that's string - convert first char to int
|
||||||
int chr = (*((char*)result->param1)) & 0xFF;
|
int chr = (*((TCHAR*)result->param1)) & 0xFF;
|
||||||
dbgGlobalFree((HGLOBAL) result->param1);
|
dbgGlobalFree((HGLOBAL) result->param1);
|
||||||
*((__int64*)&(result->param1)) = (__int64) chr;
|
*((__int64*)&(result->param1)) = (__int64) chr;
|
||||||
result->type = IT_CONST | ITC_INT;
|
result->type = IT_CONST | ITC_INT;
|
||||||
|
@ -1320,8 +1322,8 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
// ok, that's int - convert to new string (char+0)
|
// ok, that's int - convert to new string (char+0)
|
||||||
int chr = (int) (*((__int64*)&(result->param1))) & 0xFF;
|
int chr = (int) (*((__int64*)&(result->param1))) & 0xFF;
|
||||||
result->param1 = (EIPARAM) AllocString();
|
result->param1 = (EIPARAM) AllocString();
|
||||||
*((char*)result->param1) = (char) chr;
|
*((TCHAR*)result->param1) = (TCHAR) chr;
|
||||||
*((char*)(result->param1+1)) = (char) 0;
|
*((TCHAR*)(result->param1+1)) = (TCHAR) 0;
|
||||||
result->type = IT_CONST | ITC_STRING;
|
result->type = IT_CONST | ITC_STRING;
|
||||||
break;
|
break;
|
||||||
} else CleanupItems(result);
|
} else CleanupItems(result);
|
||||||
|
@ -1380,7 +1382,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
if ((aritem->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST | ITC_STRING))
|
if ((aritem->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST | ITC_STRING))
|
||||||
{
|
{
|
||||||
// argument is string
|
// argument is string
|
||||||
char *str = (char*)(aritem->param1);
|
TCHAR *str = (TCHAR*)(aritem->param1);
|
||||||
int len = lstrlen(str);
|
int len = lstrlen(str);
|
||||||
// have we two indexes or one?
|
// have we two indexes or one?
|
||||||
if ((*((ExpressionItem **) &(item->param2)))->type != IT_EXPRESSION)
|
if ((*((ExpressionItem **) &(item->param2)))->type != IT_EXPRESSION)
|
||||||
|
@ -1428,7 +1430,7 @@ void RunTree(ExpressionItem *from, ExpressionItem* &result, int options)
|
||||||
if (pos2 >= len) pos2 = len-1;
|
if (pos2 >= len) pos2 = len-1;
|
||||||
|
|
||||||
// copy string part
|
// copy string part
|
||||||
char* lpos = str + (pos2-pos1);
|
TCHAR* lpos = str + (pos2-pos1);
|
||||||
while (str <= lpos)
|
while (str <= lpos)
|
||||||
{
|
{
|
||||||
*str = *(str + pos1);
|
*str = *(str + pos1);
|
||||||
|
@ -1490,11 +1492,11 @@ HINSTANCE g_hInstance;
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void __declspec(dllexport) Script(HWND hwndParent, int string_size,
|
void __declspec(dllexport) Script(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop,
|
TCHAR *variables, stack_t **stacktop,
|
||||||
extra_parameters *extra)
|
extra_parameters *extra)
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
char *buffer = AllocString(), *buf = buffer;
|
TCHAR *buffer = AllocString(), *buf = buffer;
|
||||||
ExpressionItem *root = NULL; // root of current tree
|
ExpressionItem *root = NULL; // root of current tree
|
||||||
|
|
||||||
// keep loaded to save user defined variables
|
// keep loaded to save user defined variables
|
||||||
|
@ -1552,7 +1554,7 @@ void CleanAll(int init)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
g_hInstance = hInst;
|
g_hInstance = hInst;
|
||||||
CleanAll(ul_reason_for_call == DLL_PROCESS_ATTACH);
|
CleanAll(ul_reason_for_call == DLL_PROCESS_ATTACH);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
@ -23,7 +25,7 @@ HGLOBAL watchGlobalAlloc(UINT Flags, UINT size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *AllocString();
|
TCHAR *AllocString();
|
||||||
ExpressionItem *AllocItem();
|
ExpressionItem *AllocItem();
|
||||||
ExpressionItem *AllocArray(int size);
|
ExpressionItem *AllocArray(int size);
|
||||||
ExpressionItem *CopyItem(ExpressionItem *item, int NeedConst = 0);
|
ExpressionItem *CopyItem(ExpressionItem *item, int NeedConst = 0);
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "MyMath.h"
|
#include "MyMath.h"
|
||||||
#include "Math.h"
|
#include "Math.h"
|
||||||
|
|
||||||
// Converts String to Int (Dec, Hex) or Float value
|
// Converts String to Int (Dec, Hex) or Float value
|
||||||
void StringToItem(char *&s, ExpressionItem *item, int options)
|
void StringToItem(TCHAR *&s, ExpressionItem *item, int options)
|
||||||
{
|
{
|
||||||
item->type = IT_CONST | ITC_INT;
|
item->type = IT_CONST | ITC_INT;
|
||||||
__int64 &v=*((__int64*)&(item->param1));
|
__int64 &v=*((__int64*)&(item->param1));
|
||||||
|
@ -14,19 +16,19 @@ void StringToItem(char *&s, ExpressionItem *item, int options)
|
||||||
if (!s) return;
|
if (!s) return;
|
||||||
|
|
||||||
// String-value
|
// String-value
|
||||||
if ((((options & (STI_FLOAT | STI_INT)) == 0) || *s == '\'' || *s == '\"' || *s == '`' ||
|
if ((((options & (STI_FLOAT | STI_INT)) == 0) || *s == _T('\'') || *s == _T('\"') || *s == _T('`') ||
|
||||||
((*s != '+') && (*s != '-') && ((*s < '0') || (*s > '9'))))
|
((*s != _T('+')) && (*s != _T('-')) && ((*s < _T('0')) || (*s > _T('9')))))
|
||||||
&& (options & STI_STRING))
|
&& (options & STI_STRING))
|
||||||
{
|
{
|
||||||
// end of string char
|
// end of string char
|
||||||
char eol = 0;
|
TCHAR eol = 0;
|
||||||
if (*s == '\'' || *s == '\"' || *s == '`') eol = *s;
|
if (*s == _T('\'') || *s == _T('\"') || *s == _T('`')) eol = *s;
|
||||||
else s--;
|
else s--;
|
||||||
|
|
||||||
item->type = IT_CONST | ITC_STRING;
|
item->type = IT_CONST | ITC_STRING;
|
||||||
// allocate memory buffer for string
|
// allocate memory buffer for string
|
||||||
char *sp;
|
TCHAR *sp;
|
||||||
sp = *((char**)&(item->param1)) = AllocString();
|
sp = *((TCHAR**)&(item->param1)) = AllocString();
|
||||||
while (*(++s) && (*s != eol))
|
while (*(++s) && (*s != eol))
|
||||||
{
|
{
|
||||||
*(sp++) = *s;
|
*(sp++) = *s;
|
||||||
|
@ -36,18 +38,18 @@ void StringToItem(char *&s, ExpressionItem *item, int options)
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// strip leading spaces and tabs
|
// strip leading spaces and tabs
|
||||||
while ((*s == ' ') || (*s == '\t')) s++;
|
while ((*s == _T(' ')) || (*s == _T('\t'))) s++;
|
||||||
// Hex-value
|
// Hex-value
|
||||||
if ((options & STI_INT) && *s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
if ((options & STI_INT) && *s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
while (*(s+1) == '0') *s++;
|
while (*(s+1) == _T('0')) *s++;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||||
else break;
|
else break;
|
||||||
v<<=4;
|
v<<=4;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -57,13 +59,13 @@ void StringToItem(char *&s, ExpressionItem *item, int options)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sign=0, numsignif = 0;
|
int sign=0, numsignif = 0;
|
||||||
if (*s == '-') sign++; else s--;
|
if (*s == _T('-')) sign++; else s--;
|
||||||
while (*(s+1) == '0') *s++;
|
while (*(s+1) == _T('0')) *s++;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s) - '0'; numsignif++;
|
int c=*(++s) - _T('0'); numsignif++;
|
||||||
if ((options & STI_FLOAT) &&
|
if ((options & STI_FLOAT) &&
|
||||||
((c == ('e'-'0')) || (c==('E'-'0')) || (c==('.'-'0'))
|
((c == (_T('e')-_T('0'))) || (c==(_T('E')-_T('0'))) || (c==(_T('.')-_T('0')))
|
||||||
|| (numsignif > 18)))
|
|| (numsignif > 18)))
|
||||||
{
|
{
|
||||||
// Switch to floating point conversion rountine
|
// Switch to floating point conversion rountine
|
||||||
|
@ -74,16 +76,16 @@ void StringToItem(char *&s, ExpressionItem *item, int options)
|
||||||
while ((c >= 0) && (c <= 9))
|
while ((c >= 0) && (c <= 9))
|
||||||
{
|
{
|
||||||
d = d*10.0 + (double) c;
|
d = d*10.0 + (double) c;
|
||||||
c=*(++s) - '0';
|
c=*(++s) - _T('0');
|
||||||
}
|
}
|
||||||
|
|
||||||
// sub-decimal part
|
// sub-decimal part
|
||||||
if (c == ('.'-'0'))
|
if (c == (_T('.')-_T('0')))
|
||||||
{
|
{
|
||||||
double pwr = 1.0, dec = 0.0;
|
double pwr = 1.0, dec = 0.0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
c=*(++s) - '0';
|
c=*(++s) - _T('0');
|
||||||
if ((c < 0) || (c > 9)) break;
|
if ((c < 0) || (c > 9)) break;
|
||||||
dec = dec*10.0 + (double) c;
|
dec = dec*10.0 + (double) c;
|
||||||
pwr *= 10.0;
|
pwr *= 10.0;
|
||||||
|
@ -91,19 +93,19 @@ void StringToItem(char *&s, ExpressionItem *item, int options)
|
||||||
d += dec/pwr;
|
d += dec/pwr;
|
||||||
}
|
}
|
||||||
// exponental part
|
// exponental part
|
||||||
if ((c == ('E'-'0')) || (c == ('e'-'0')))
|
if ((c == (_T('E')-_T('0'))) || (c == (_T('e')-_T('0'))))
|
||||||
{
|
{
|
||||||
int expc = 0, esign = 0;
|
int expc = 0, esign = 0;
|
||||||
s++;
|
s++;
|
||||||
// detect exponential sign
|
// detect exponential sign
|
||||||
if ((*s == '+') || (*s == '-'))
|
if ((*s == _T('+')) || (*s == _T('-')))
|
||||||
esign = (*s == '-');
|
esign = (*s == _T('-'));
|
||||||
else s--;
|
else s--;
|
||||||
|
|
||||||
// detect exp value
|
// detect exp value
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
c=*(++s) - '0';
|
c=*(++s) - _T('0');
|
||||||
if ((c < 0) || (c > 9)) break;
|
if ((c < 0) || (c > 9)) break;
|
||||||
expc = expc*10 + c;
|
expc = expc*10 + c;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +141,7 @@ void StringToItem(char *&s, ExpressionItem *item, int options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemToString(char *sbuf, ExpressionItem *item)
|
void ItemToString(TCHAR *sbuf, ExpressionItem *item)
|
||||||
{
|
{
|
||||||
if ((item == NULL) || ((item->type & ITEMTYPE) != IT_CONST))
|
if ((item == NULL) || ((item->type & ITEMTYPE) != IT_CONST))
|
||||||
{
|
{
|
||||||
|
@ -151,7 +153,7 @@ void ItemToString(char *sbuf, ExpressionItem *item)
|
||||||
{
|
{
|
||||||
case ITC_STRING:
|
case ITC_STRING:
|
||||||
{
|
{
|
||||||
char *ptr = *((char**)&(item->param1));
|
TCHAR *ptr = *((TCHAR**)&(item->param1));
|
||||||
while (*(sbuf++) = *(ptr++));
|
while (*(sbuf++) = *(ptr++));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -161,7 +163,7 @@ void ItemToString(char *sbuf, ExpressionItem *item)
|
||||||
for (int index = 0; index < ad->count; index++)
|
for (int index = 0; index < ad->count; index++)
|
||||||
if ((ad->array[index]) &&
|
if ((ad->array[index]) &&
|
||||||
((ad->array[index]->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST | ITC_INT)))
|
((ad->array[index]->type & (ITEMTYPE|ITEMSUBTYPE)) == (IT_CONST | ITC_INT)))
|
||||||
if ((*(sbuf++) = (char) *((__int64*)&(ad->array[index]->param1))) == 0)
|
if ((*(sbuf++) = (TCHAR) *((__int64*)&(ad->array[index]->param1))) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -174,21 +176,21 @@ void ItemToString(char *sbuf, ExpressionItem *item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void itoa64(__int64 i, char *buffer)
|
void itoa64(__int64 i, TCHAR *buffer)
|
||||||
{
|
{
|
||||||
char buf[128], *b = buf;
|
TCHAR buf[128], *b = buf;
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
*(buffer++) = '-';
|
*(buffer++) = _T('-');
|
||||||
i = -i;
|
i = -i;
|
||||||
}
|
}
|
||||||
if (i == 0) *(buffer++) = '0';
|
if (i == 0) *(buffer++) = _T('0');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (i > 0)
|
while (i > 0)
|
||||||
{
|
{
|
||||||
*(b++) = '0' + ((char) (i%10));
|
*(b++) = _T('0') + ((TCHAR) (i%10));
|
||||||
i /= 10;
|
i /= 10;
|
||||||
}
|
}
|
||||||
while (b > buf) *(buffer++) = *(--b);
|
while (b > buf) *(buffer++) = *(--b);
|
||||||
|
@ -196,12 +198,12 @@ void itoa64(__int64 i, char *buffer)
|
||||||
*buffer = 0;
|
*buffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define POS_INFINITY "#INF"
|
#define POS_INFINITY _T("#INF")
|
||||||
#define NEG_INFINITY "-#INF"
|
#define NEG_INFINITY _T("-#INF")
|
||||||
|
|
||||||
void FloatFormat(char *s, double value, int options)
|
void FloatFormat(TCHAR *s, double value, int options)
|
||||||
{
|
{
|
||||||
char format[128];
|
TCHAR format[128];
|
||||||
int prec = options & 0xF;
|
int prec = options & 0xF;
|
||||||
|
|
||||||
*s = 0;
|
*s = 0;
|
||||||
|
@ -217,25 +219,25 @@ void FloatFormat(char *s, double value, int options)
|
||||||
|
|
||||||
if (options & FF_NOEXP)
|
if (options & FF_NOEXP)
|
||||||
{
|
{
|
||||||
sprintf(format, "%%.%df", prec);
|
_stprintf(format, _T("%%.%df"), prec);
|
||||||
}
|
}
|
||||||
else if (options & FF_EXP)
|
else if (options & FF_EXP)
|
||||||
{
|
{
|
||||||
sprintf(format, "%%.%de", prec);
|
_stprintf(format, _T("%%.%de"), prec);
|
||||||
}
|
}
|
||||||
else if (options & FF_LEXP)
|
else if (options & FF_LEXP)
|
||||||
{
|
{
|
||||||
sprintf(format, "%%.%dE", prec);
|
_stprintf(format, _T("%%.%dE"), prec);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(format, "%%.%dg", prec);
|
_stprintf(format, _T("%%.%dg"), prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(s, format, value);
|
_stprintf(s, format, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lstrcmpn(char *s1, const char *s2, int chars)
|
int lstrcmpn(TCHAR *s1, const TCHAR *s2, int chars)
|
||||||
{
|
{
|
||||||
while ((chars > 0) && (*s1) && (*s2) && (*(s1) == *(s2))) chars--, s1++, s2++;
|
while ((chars > 0) && (*s1) && (*s2) && (*(s1) == *(s2))) chars--, s1++, s2++;
|
||||||
if ((chars == 0) || (*s1 == *s2)) return 0;
|
if ((chars == 0) || (*s1 == *s2)) return 0;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -97,13 +99,13 @@ typedef struct __ParseInfo
|
||||||
ExpressionItem *OpsStack;
|
ExpressionItem *OpsStack;
|
||||||
ExpressionItem **place;
|
ExpressionItem **place;
|
||||||
ExpressionItem **root;
|
ExpressionItem **root;
|
||||||
char valbuf[108];
|
TCHAR valbuf[108];
|
||||||
} ParseInfo;
|
} ParseInfo;
|
||||||
|
|
||||||
#define OPERATOR_SET_PRECEDENCE 14
|
#define OPERATOR_SET_PRECEDENCE 14
|
||||||
typedef struct __OpStruct
|
typedef struct __OpStruct
|
||||||
{
|
{
|
||||||
char name[3];
|
TCHAR name[3];
|
||||||
unsigned char precedence;
|
unsigned char precedence;
|
||||||
unsigned short int type;
|
unsigned short int type;
|
||||||
} OpStruct;
|
} OpStruct;
|
||||||
|
@ -111,16 +113,16 @@ typedef struct __OpStruct
|
||||||
#define MAX_USER_VARS 256
|
#define MAX_USER_VARS 256
|
||||||
typedef struct __UserVar
|
typedef struct __UserVar
|
||||||
{
|
{
|
||||||
char name[28];
|
TCHAR name[28];
|
||||||
ExpressionItem *item;
|
ExpressionItem *item;
|
||||||
} UserVar;
|
} UserVar;
|
||||||
|
|
||||||
#define MAX_USER_FUNCS 256
|
#define MAX_USER_FUNCS 256
|
||||||
typedef struct __UserFunc
|
typedef struct __UserFunc
|
||||||
{
|
{
|
||||||
char name[20];
|
TCHAR name[20];
|
||||||
unsigned char vars[31];
|
unsigned char vars[31]; // only used for indexing
|
||||||
unsigned char varsnum;
|
unsigned char varsnum; // number of vars < 256
|
||||||
unsigned int varflags;
|
unsigned int varflags;
|
||||||
ExpressionItem *root;
|
ExpressionItem *root;
|
||||||
} UserFunc;
|
} UserFunc;
|
||||||
|
@ -140,7 +142,7 @@ typedef double (*Math2dFuncPtr)(double arg, double *arg2);
|
||||||
|
|
||||||
typedef struct __MathFunction
|
typedef struct __MathFunction
|
||||||
{
|
{
|
||||||
char name[3];
|
TCHAR name[3];
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
Math1FuncPtr fptr;
|
Math1FuncPtr fptr;
|
||||||
} MathFunction;
|
} MathFunction;
|
||||||
|
@ -159,8 +161,8 @@ typedef struct __MathFunction
|
||||||
#define RTO_PREFFEREDTYPE 0xFF00
|
#define RTO_PREFFEREDTYPE 0xFF00
|
||||||
void RunTree(ExpressionItem *from, ExpressionItem* &result, int type);
|
void RunTree(ExpressionItem *from, ExpressionItem* &result, int type);
|
||||||
|
|
||||||
void StringToItem(char *&sbuf, ExpressionItem *item, int options);
|
void StringToItem(TCHAR *&sbuf, ExpressionItem *item, int options);
|
||||||
void ItemToString(char *sbuf, ExpressionItem *item);
|
void ItemToString(TCHAR *sbuf, ExpressionItem *item);
|
||||||
void FloatFormat(char *sbuf, double value, int options);
|
void FloatFormat(TCHAR *sbuf, double value, int options);
|
||||||
void itoa64(__int64 i, char *buffer);
|
void itoa64(__int64 i, TCHAR *buffer);
|
||||||
int lstrcmpn(char *s1, const char *s2, int chars);
|
int lstrcmpn(TCHAR *s1, const TCHAR *s2, int chars);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/22/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "MyMath.h"
|
#include "MyMath.h"
|
||||||
#include "Math.h"
|
#include "Math.h"
|
||||||
|
@ -28,15 +30,15 @@ void watchGlobal()
|
||||||
for (int i = 0; i < blocksnum; i++)
|
for (int i = 0; i < blocksnum; i++)
|
||||||
if (blocks[i] != NULL)
|
if (blocks[i] != NULL)
|
||||||
{
|
{
|
||||||
_RPT2(_CRT_WARN, "Memory leak %d at %8X\n", i, blocks[i]);
|
_RPT2(_CRT_WARN, _T("Memory leak %d at %8X\n"), i, blocks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *AllocString()
|
TCHAR *AllocString()
|
||||||
{
|
{
|
||||||
return (char*) dbgGlobalAlloc(GPTR,g_stringsize);
|
return (TCHAR*) dbgGlobalAlloc(GPTR,g_stringsize*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionItem *AllocItem()
|
ExpressionItem *AllocItem()
|
||||||
|
@ -82,7 +84,7 @@ ExpressionItem *CopyItem(ExpressionItem *citem, int NeedConst)
|
||||||
if ((item->type & (ITEMTYPE | ITEMSUBTYPE)) == (IT_CONST | ITC_STRING))
|
if ((item->type & (ITEMTYPE | ITEMSUBTYPE)) == (IT_CONST | ITC_STRING))
|
||||||
{
|
{
|
||||||
item->param1 = (EIPARAM) AllocString();
|
item->param1 = (EIPARAM) AllocString();
|
||||||
lstrcpy((LPSTR) item->param1, (LPSTR) citem->param1);
|
lstrcpy((LPTSTR) item->param1, (LPTSTR) citem->param1);
|
||||||
} else if (((item->type & (ITEMTYPE | ITEMSUBTYPE)) == (IT_CONST | ITC_ARRAY))
|
} else if (((item->type & (ITEMTYPE | ITEMSUBTYPE)) == (IT_CONST | ITC_ARRAY))
|
||||||
||
|
||
|
||||||
((item->type & (ITEMTYPE | ITEMSUBTYPE)) == (IT_VARIABLE | ITV_ARRITEM)))
|
((item->type & (ITEMTYPE | ITEMSUBTYPE)) == (IT_VARIABLE | ITV_ARRITEM)))
|
||||||
|
|
|
@ -1,38 +1,44 @@
|
||||||
target = "NSIS"
|
target = "NSIS"
|
||||||
|
Import('BuildUtil env')
|
||||||
|
|
||||||
files = Split("""
|
files = Split("""
|
||||||
nsismenu/nsismenu.cpp
|
nsismenu/nsismenu.cpp
|
||||||
nsismenu/nslinks.cpp
|
nsismenu/nslinks.cpp
|
||||||
""")
|
""")
|
||||||
|
|
||||||
resources = Split("""
|
resources = Split("""
|
||||||
nsismenu/nsisicon.ico
|
nsismenu/nsisicon.ico
|
||||||
""")
|
""")
|
||||||
|
|
||||||
rc = 'nsismenu/nsismenu.rc'
|
rc = 'nsismenu/nsismenu.rc'
|
||||||
|
|
||||||
libs = Split("""
|
libs = Split("""
|
||||||
advapi32
|
advapi32
|
||||||
comctl32
|
comctl32
|
||||||
gdi32
|
gdi32
|
||||||
shell32
|
shell32
|
||||||
user32
|
user32
|
||||||
wxbase28
|
|
||||||
wxmsw28_core
|
|
||||||
wxmsw28_html
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
if env['UNICODE']:
|
||||||
|
libs.append(["wxbase28u", "wxmsw28u_core", "wxmsw28u_html"])
|
||||||
|
else:
|
||||||
|
libs.append(["wxbase28", "wxmsw28_core", "wxmsw28_html"])
|
||||||
|
|
||||||
html = Split("""
|
html = Split("""
|
||||||
#Menu/index.html
|
#Menu/index.html
|
||||||
""")
|
""")
|
||||||
|
|
||||||
images = Split("""
|
images = Split("""
|
||||||
#Menu/images/header.gif
|
#Menu/images/line.gif
|
||||||
#Menu/images/line.gif
|
#Menu/images/site.gif
|
||||||
#Menu/images/site.gif
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
Import('BuildUtil env')
|
|
||||||
|
if env['UNICODE']:
|
||||||
|
images.append("#Menu/images/Unicode/header.gif")
|
||||||
|
else:
|
||||||
|
images.append("#Menu/images/header.gif")
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
@ -40,56 +46,60 @@ from os.path import join
|
||||||
if env['PLATFORM'] != 'win32' and WhereIs('wx-config') or \
|
if env['PLATFORM'] != 'win32' and WhereIs('wx-config') or \
|
||||||
env['PLATFORM'] == 'win32' and os.environ.has_key('WXWIN'):
|
env['PLATFORM'] == 'win32' and os.environ.has_key('WXWIN'):
|
||||||
|
|
||||||
# build
|
# build
|
||||||
|
|
||||||
if env['PLATFORM'] != 'win32':
|
if env['PLATFORM'] != 'win32':
|
||||||
rc = libs = []
|
rc = libs = []
|
||||||
|
|
||||||
nsis_menu = BuildUtil(
|
nsis_menu = BuildUtil(
|
||||||
target,
|
target,
|
||||||
files,
|
files,
|
||||||
libs,
|
libs,
|
||||||
res = rc,
|
res = rc,
|
||||||
resources = resources,
|
resources = resources,
|
||||||
flags = ['$MSVCRT_FLAG', '$EXCEPTION_FLAG'],
|
flags = ['$MSVCRT_FLAG', '$EXCEPTION_FLAG'],
|
||||||
root_util = True,
|
root_util = True,
|
||||||
cross_platform = True
|
cross_platform = True
|
||||||
)
|
)
|
||||||
|
|
||||||
# manifest
|
# manifest
|
||||||
|
|
||||||
if env.has_key('MSVS_VERSION'):
|
if env.has_key('MSVS_VERSION'):
|
||||||
if float(env['MSVS_VERSION'].replace('Exp','')) >= 8.0:
|
if float(env['MSVS_VERSION'].replace('Exp','')) >= 8.0:
|
||||||
manifest = env.SideEffect('%s.exe.manifest' % target, nsis_menu)
|
manifest = env.SideEffect('%s.exe.manifest' % target, nsis_menu)
|
||||||
env.DistributeBin(manifest, alias='install-utils')
|
env.DistributeBin(manifest, alias='install-utils')
|
||||||
|
|
||||||
# set directories
|
# set directories
|
||||||
|
|
||||||
if nsis_menu[0].env['PLATFORM'] == 'win32':
|
if nsis_menu[0].env['PLATFORM'] == 'win32':
|
||||||
wxlib = [join(os.environ['WXWIN'], 'lib', 'vc_libnsis')]
|
wxinc = [join(os.environ['WXWIN'], 'include')]
|
||||||
wxinc = [
|
|
||||||
join(os.environ['WXWIN'], 'include'),
|
|
||||||
join(os.environ['WXWIN'], 'lib', 'vc_libnsis', 'msw')
|
|
||||||
]
|
|
||||||
nsis_menu[0].env.Append(LIBPATH = wxlib)
|
|
||||||
nsis_menu[0].env.Append(CPPPATH = wxinc)
|
|
||||||
else:
|
|
||||||
nsis_menu[0].env.ParseConfig('wx-config --cxxflags --libs')
|
|
||||||
|
|
||||||
# install menu files
|
if env['UNICODE']:
|
||||||
|
wxlib = [join(os.environ['WXWIN'], 'lib', 'vc_libunsis')]
|
||||||
|
wxinc.append(join(os.environ['WXWIN'], 'lib', 'vc_libunsis', 'mswu'))
|
||||||
|
else:
|
||||||
|
wxlib = [join(os.environ['WXWIN'], 'lib', 'vc_libnsis')]
|
||||||
|
wxinc.append(join(os.environ['WXWIN'], 'lib', 'vc_libnsis', 'msw'))
|
||||||
|
|
||||||
env.DistributeMenu(html, alias='install-utils')
|
nsis_menu[0].env.Append(LIBPATH = wxlib)
|
||||||
env.DistributeMenu(images, path='images', alias='install-utils')
|
nsis_menu[0].env.Append(CPPPATH = wxinc)
|
||||||
|
else:
|
||||||
|
nsis_menu[0].env.ParseConfig('wx-config --cxxflags --libs')
|
||||||
|
|
||||||
|
# install menu files
|
||||||
|
|
||||||
|
env.DistributeMenu(html, alias='install-utils')
|
||||||
|
env.DistributeMenu(images, path='images', alias='install-utils')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# no wxWidgets
|
# no wxWidgets
|
||||||
def err(target, source, env):
|
def err(target, source, env):
|
||||||
if env['PLATFORM'] == 'win32':
|
if env['PLATFORM'] == 'win32':
|
||||||
print '*** error: WXWIN must be set to build NSIS Menu!'
|
print '*** error: WXWIN must be set to build NSIS Menu!'
|
||||||
else:
|
else:
|
||||||
print '*** error: wx-config must be in the PATH to build NSIS Menu!'
|
print '*** error: wx-config must be in the PATH to build NSIS Menu!'
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cmd = env.Command(target, files, Action(err, ''))
|
cmd = env.Command(target, files, Action(err, ''))
|
||||||
env.Alias('NSIS Menu', cmd)
|
env.Alias('NSIS Menu', cmd)
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// NSIS MENU
|
// NSIS MENU
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/23/2007
|
||||||
|
// Basically, compiling wxWidgets as Unicode should do it.
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx/wx.h".
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
@ -100,7 +103,7 @@ private:
|
||||||
|
|
||||||
// Create the main application window
|
// Create the main application window
|
||||||
MyFrame *frame = new MyFrame(_("NSIS Menu"),
|
MyFrame *frame = new MyFrame(_("NSIS Menu"),
|
||||||
wxPoint(50, 50), wxSize(600 + wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_X), 355 + wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_X)));
|
wxPoint(50, 50), wxSize(600 + wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_X), 365 + wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_X)));
|
||||||
|
|
||||||
// Show it and tell the application that it's our main window
|
// Show it and tell the application that it's our main window
|
||||||
|
|
||||||
|
@ -154,10 +157,10 @@ void MyFrame::OnLink(wxHtmlLinkEvent& event)
|
||||||
if (e == NULL || e->LeftUp())
|
if (e == NULL || e->LeftUp())
|
||||||
{
|
{
|
||||||
const wxString href = event.GetLinkInfo().GetHref();
|
const wxString href = event.GetLinkInfo().GetHref();
|
||||||
if (href.Left(3).IsSameAs((const wxChar*)"EX:", false))
|
if (href.Left(3).IsSameAs((const wxChar*) wxT("EX:"), false))
|
||||||
{
|
{
|
||||||
wxString url = href.Mid(3);
|
wxString url = href.Mid(3);
|
||||||
if (url.Left(7).IsSameAs((const wxChar*)"http://", false) || url.Left(6).IsSameAs((const wxChar*)"irc://", false))
|
if (url.Left(7).IsSameAs((const wxChar*) wxT("http://"), false) || url.Left(6).IsSameAs((const wxChar*) wxT("irc://"), false))
|
||||||
{
|
{
|
||||||
::wxLaunchDefaultBrowser(url);
|
::wxLaunchDefaultBrowser(url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
// Name: src/html/m_links.cpp
|
// Name: src/html/m_links.cpp
|
||||||
// Purpose: wxHtml module for links & anchors
|
// Purpose: wxHtml module for links & anchors
|
||||||
// Author: Vaclav Slavik
|
// Author: Vaclav Slavik
|
||||||
// RCS-ID: $Id: nslinks.cpp,v 1.1 2007/02/24 18:57:09 kichik Exp $
|
// RCS-ID: $Id: nslinks.cpp,v 1.2 2007/03/08 01:47:14 pabs3 Exp $
|
||||||
// Copyright: (c) 1999 Vaclav Slavik
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/23/2007
|
||||||
|
// Basically, compiling wxWidgets as Unicode should do it.
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
@ -60,10 +63,10 @@ TAG_HANDLER_BEGIN(A, "A")
|
||||||
wxColour colour = m_WParser->GetLinkColor();
|
wxColour colour = m_WParser->GetLinkColor();
|
||||||
wxHtmlLinkInfo linkInfo(name, target);
|
wxHtmlLinkInfo linkInfo(name, target);
|
||||||
|
|
||||||
if (name.Left(3).IsSameAs((const wxChar*)"EX:", false))
|
if (name.Left(3).IsSameAs((const wxChar*) wxT("EX:"), false))
|
||||||
{
|
{
|
||||||
wxString url = name.Mid(3);
|
wxString url = name.Mid(3);
|
||||||
if (!url.Left(7).IsSameAs((const wxChar*)"http://", false) && !url.Left(6).IsSameAs((const wxChar*)"irc://", false))
|
if (!url.Left(7).IsSameAs((const wxChar*) wxT("http://"), false) && !url.Left(6).IsSameAs((const wxChar*) wxT("irc://"), false))
|
||||||
{
|
{
|
||||||
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
|
wxString exePath = wxStandardPaths::Get().GetExecutablePath();
|
||||||
wxString path = ::wxPathOnly(exePath);
|
wxString path = ::wxPathOnly(exePath);
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
// RCS-ID: $Id: setup0.h,v 1.246 2006/11/09 00:54:51 VZ Exp $
|
// RCS-ID: $Id: setup0.h,v 1.246 2006/11/09 00:54:51 VZ Exp $
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/01/2007
|
||||||
|
// (This one is the ANSI version.)
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_SETUP_H_
|
#ifndef _WX_SETUP_H_
|
||||||
|
|
|
@ -1,12 +1,42 @@
|
||||||
|
@echo off
|
||||||
if not exist setup.h goto setup_error
|
if not exist setup.h goto setup_error
|
||||||
if not exist "%WXWIN%\build\msw\makefile.vc" goto error
|
if not exist "%WXWIN%\build\msw\makefile.vc" goto error
|
||||||
set OLDCD=%CD%
|
set OLDCD=%CD%
|
||||||
cd /D "%WXWIN%\build\msw"
|
cd /D "%WXWIN%\build\msw"
|
||||||
|
rem Save the old setup.h as old_setup.h in the starting dir.
|
||||||
copy /y "%WXWIN%\include\wx\msw\setup.h" "%OLDCD%\old_setup.h"
|
copy /y "%WXWIN%\include\wx\msw\setup.h" "%OLDCD%\old_setup.h"
|
||||||
copy /y "%OLDCD%\setup.h" "%WXWIN%\include\wx\msw\setup.h"
|
|
||||||
|
if "%1" == "unicode" goto unicode
|
||||||
|
if "%1" == "ansi" goto ansi
|
||||||
|
:ansi
|
||||||
|
rem Ask if we want to delete this dir.
|
||||||
|
echo Deleting...
|
||||||
rd /S ..\..\lib\vc_libnsis
|
rd /S ..\..\lib\vc_libnsis
|
||||||
|
|
||||||
|
echo ### building ANSI version ###
|
||||||
|
rem Copy the ANSI version of setup.h to WXWIN setup.
|
||||||
|
copy /y "%OLDCD%\setup.h" "%WXWIN%\include\wx\msw\setup.h"
|
||||||
|
echo Deleting...
|
||||||
rd /S vc_mswnsis
|
rd /S vc_mswnsis
|
||||||
nmake -f makefile.vc CFG=nsis BUILD=release RUNTIME_LIBS=dynamic SHARED=0 UNICODE=0 WXUNIV=0 USE_OPENGL=0 USE_ODBC=0 USE_HTML=1 USE_XRC=0
|
nmake -f makefile.vc CFG=nsis BUILD=release RUNTIME_LIBS=static SHARED=0 UNICODE=0 WXUNIV=0 USE_OPENGL=0 USE_ODBC=0 USE_HTML=1 USE_XRC=0
|
||||||
|
if "%1" == "" goto unicode
|
||||||
|
if "%1" == "all" goto unicode
|
||||||
|
goto finish
|
||||||
|
|
||||||
|
:unicode
|
||||||
|
rem Ask if we want to delete this dir.
|
||||||
|
echo Deleting...
|
||||||
|
rd /S ..\..\lib\vc_libunsis
|
||||||
|
|
||||||
|
echo ### building UNICODE version ###
|
||||||
|
rem Copy the UNICODE version of setup.h to WXWIN setup.
|
||||||
|
copy /y "%OLDCD%\setup_unicode.h" "%WXWIN%\include\wx\msw\setup.h"
|
||||||
|
echo Deleting...
|
||||||
|
rd /S vc_mswunsis
|
||||||
|
nmake -f makefile.vc CFG=unsis BUILD=release RUNTIME_LIBS=static SHARED=0 UNICODE=1 WXUNIV=0 USE_OPENGL=0 USE_ODBC=0 USE_HTML=1 USE_XRC=0
|
||||||
|
|
||||||
|
:finish
|
||||||
|
rem Restore the setup.h
|
||||||
copy /y "%OLDCD%\old_setup.h" "%WXWIN%\include\wx\msw\setup.h"
|
copy /y "%OLDCD%\old_setup.h" "%WXWIN%\include\wx\msw\setup.h"
|
||||||
cd /D "%OLDCD%"
|
cd /D "%OLDCD%"
|
||||||
goto done
|
goto done
|
||||||
|
|
|
@ -1,82 +1,86 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: asyncdns.cpp - JNL portable asynchronous DNS implementation
|
** File: asyncdns.cpp - JNL portable asynchronous DNS implementation
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
*/
|
**
|
||||||
|
** Unicode support by Jim Park -- 08/24/2007
|
||||||
|
*/
|
||||||
#include "netinc.h"
|
|
||||||
#include "util.h"
|
// Jim Park: For Unicode Support, all string functions must explicitly use
|
||||||
#include "asyncdns.h"
|
// ANSI versions if UNICODE is defined.
|
||||||
|
|
||||||
JNL_AsyncDNS::JNL_AsyncDNS()
|
#include "netinc.h"
|
||||||
{
|
#include "util.h"
|
||||||
m_thread=0;
|
#include "asyncdns.h"
|
||||||
m_addr=0;
|
|
||||||
m_hostname[0]=0;
|
JNL_AsyncDNS::JNL_AsyncDNS()
|
||||||
}
|
{
|
||||||
|
m_thread=0;
|
||||||
JNL_AsyncDNS::~JNL_AsyncDNS()
|
m_addr=0;
|
||||||
{
|
m_hostname[0]=0;
|
||||||
wait_for_thread_death();
|
}
|
||||||
}
|
|
||||||
|
JNL_AsyncDNS::~JNL_AsyncDNS()
|
||||||
unsigned long WINAPI JNL_AsyncDNS::_threadfunc(LPVOID _d)
|
{
|
||||||
{
|
wait_for_thread_death();
|
||||||
JNL_AsyncDNS *_this=(JNL_AsyncDNS*)_d;
|
}
|
||||||
struct hostent *hostentry;
|
|
||||||
hostentry=::gethostbyname(_this->m_hostname);
|
unsigned long WINAPI JNL_AsyncDNS::_threadfunc(LPVOID _d)
|
||||||
if (hostentry)
|
{
|
||||||
{
|
JNL_AsyncDNS *_this=(JNL_AsyncDNS*)_d;
|
||||||
_this->m_addr=*((int*)hostentry->h_addr);
|
struct hostent *hostentry;
|
||||||
}
|
hostentry=::gethostbyname(_this->m_hostname);
|
||||||
else
|
if (hostentry)
|
||||||
_this->m_addr=INADDR_NONE;
|
{
|
||||||
return 0;
|
_this->m_addr=*((int*)hostentry->h_addr);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
int JNL_AsyncDNS::resolve(char *hostname, unsigned long *addr)
|
_this->m_addr=INADDR_NONE;
|
||||||
{
|
return 0;
|
||||||
// return 0 on success, 1 on wait, -1 on unresolvable
|
}
|
||||||
unsigned long ip=inet_addr(hostname);
|
|
||||||
if (ip != INADDR_NONE)
|
int JNL_AsyncDNS::resolve(char *hostname, unsigned long *addr)
|
||||||
{
|
{
|
||||||
*addr=ip;
|
// return 0 on success, 1 on wait, -1 on unresolvable
|
||||||
return 0;
|
unsigned long ip=inet_addr(hostname);
|
||||||
}
|
if (ip != INADDR_NONE)
|
||||||
|
{
|
||||||
if (lstrcmpi(m_hostname,hostname)) m_addr=0;
|
*addr=ip;
|
||||||
else if (m_addr == INADDR_NONE)
|
return 0;
|
||||||
{
|
}
|
||||||
wait_for_thread_death();
|
|
||||||
return -1;
|
if (lstrcmpiA(m_hostname,hostname)) m_addr=0;
|
||||||
}
|
else if (m_addr == INADDR_NONE)
|
||||||
else if (m_addr)
|
{
|
||||||
{
|
wait_for_thread_death();
|
||||||
*addr=m_addr;
|
return -1;
|
||||||
wait_for_thread_death();
|
}
|
||||||
return 0;
|
else if (m_addr)
|
||||||
}
|
{
|
||||||
lstrcpy(m_hostname,hostname);
|
*addr=m_addr;
|
||||||
|
wait_for_thread_death();
|
||||||
if (!m_thread)
|
return 0;
|
||||||
{
|
}
|
||||||
DWORD id;
|
lstrcpyA(m_hostname,hostname);
|
||||||
m_thread=CreateThread(NULL,0,_threadfunc,(LPVOID)this,0,&id);
|
|
||||||
if (!m_thread) return -1;
|
if (!m_thread)
|
||||||
}
|
{
|
||||||
return 1;
|
DWORD id;
|
||||||
}
|
m_thread=CreateThread(NULL,0,_threadfunc,(LPVOID)this,0,&id);
|
||||||
|
if (!m_thread) return -1;
|
||||||
void JNL_AsyncDNS::wait_for_thread_death()
|
}
|
||||||
{
|
return 1;
|
||||||
if (m_thread)
|
}
|
||||||
{
|
|
||||||
WaitForSingleObject(m_thread,INFINITE);
|
void JNL_AsyncDNS::wait_for_thread_death()
|
||||||
CloseHandle(m_thread);
|
{
|
||||||
}
|
if (m_thread)
|
||||||
|
{
|
||||||
m_thread=0;
|
WaitForSingleObject(m_thread,INFINITE);
|
||||||
}
|
CloseHandle(m_thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_thread=0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,39 +1,43 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: asyncdns.h - JNL portable asynchronous DNS interface
|
** File: asyncdns.h - JNL portable asynchronous DNS interface
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
**
|
**
|
||||||
** Usage:
|
** Usage:
|
||||||
** 1. Create JNL_AsyncDNS object, optionally with the number of cache entries.
|
** 1. Create JNL_AsyncDNS object, optionally with the number of cache entries.
|
||||||
** 2. call resolve() to resolve a hostname into an address. The return value of
|
** 2. call resolve() to resolve a hostname into an address. The return value of
|
||||||
** resolve is 0 on success (host successfully resolved), 1 on wait (meaning
|
** resolve is 0 on success (host successfully resolved), 1 on wait (meaning
|
||||||
** try calling resolve() with the same hostname in a few hundred milliseconds
|
** try calling resolve() with the same hostname in a few hundred milliseconds
|
||||||
** or so), or -1 on error (i.e. the host can't resolve).
|
** or so), or -1 on error (i.e. the host can't resolve).
|
||||||
** 4. enjoy.
|
** 4. enjoy.
|
||||||
*/
|
**
|
||||||
|
** Unicode support by Jim Park -- 08/24/2007
|
||||||
#ifndef _ASYNCDNS_H_
|
*/
|
||||||
#define _ASYNCDNS_H_
|
|
||||||
|
// Jim Park: Inet host name is strictly ANSI, no UNICODE for now.
|
||||||
class JNL_AsyncDNS
|
|
||||||
{
|
#ifndef _ASYNCDNS_H_
|
||||||
public:
|
#define _ASYNCDNS_H_
|
||||||
JNL_AsyncDNS();
|
|
||||||
~JNL_AsyncDNS();
|
class JNL_AsyncDNS
|
||||||
|
{
|
||||||
int resolve(char *hostname, unsigned long *addr); // return 0 on success, 1 on wait, -1 on unresolvable
|
public:
|
||||||
|
JNL_AsyncDNS();
|
||||||
private:
|
~JNL_AsyncDNS();
|
||||||
void wait_for_thread_death();
|
|
||||||
|
int resolve(char *hostname, unsigned long *addr); // return 0 on success, 1 on wait, -1 on unresolvable
|
||||||
char m_hostname[256];
|
|
||||||
unsigned long m_addr;
|
private:
|
||||||
|
void wait_for_thread_death();
|
||||||
HANDLE m_thread;
|
|
||||||
static unsigned long WINAPI _threadfunc(LPVOID _d);
|
char m_hostname[256];
|
||||||
|
unsigned long m_addr;
|
||||||
};
|
|
||||||
|
HANDLE m_thread;
|
||||||
#endif //_ASYNCDNS_H_
|
static unsigned long WINAPI _threadfunc(LPVOID _d);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_ASYNCDNS_H_
|
||||||
|
|
|
@ -1,445 +1,447 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: connection.cpp - JNL TCP connection implementation
|
** File: connection.cpp - JNL TCP connection implementation
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
*/
|
**
|
||||||
|
** Unicode support by Jim Park -- 08/24/2007
|
||||||
#include "netinc.h"
|
*/
|
||||||
#include "util.h"
|
|
||||||
#include "connection.h"
|
#include "netinc.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "connection.h"
|
||||||
JNL_Connection::JNL_Connection(JNL_AsyncDNS *dns, int sendbufsize, int recvbufsize)
|
|
||||||
{
|
|
||||||
m_errorstr="";
|
JNL_Connection::JNL_Connection(JNL_AsyncDNS *dns, int sendbufsize, int recvbufsize)
|
||||||
if (dns == JNL_CONNECTION_AUTODNS)
|
{
|
||||||
{
|
m_errorstr="";
|
||||||
m_dns=new JNL_AsyncDNS();
|
if (dns == JNL_CONNECTION_AUTODNS)
|
||||||
m_dns_owned=1;
|
{
|
||||||
}
|
m_dns=new JNL_AsyncDNS();
|
||||||
else
|
m_dns_owned=1;
|
||||||
{
|
}
|
||||||
m_dns=dns;
|
else
|
||||||
m_dns_owned=0;
|
{
|
||||||
}
|
m_dns=dns;
|
||||||
m_recv_buffer_len=recvbufsize;
|
m_dns_owned=0;
|
||||||
m_send_buffer_len=sendbufsize;
|
}
|
||||||
m_recv_buffer=(char*)malloc(m_recv_buffer_len);
|
m_recv_buffer_len=recvbufsize;
|
||||||
m_send_buffer=(char*)malloc(m_send_buffer_len);
|
m_send_buffer_len=sendbufsize;
|
||||||
m_socket=-1;
|
m_recv_buffer=(char*)malloc(m_recv_buffer_len);
|
||||||
m_remote_port=0;
|
m_send_buffer=(char*)malloc(m_send_buffer_len);
|
||||||
m_state=STATE_NOCONNECTION;
|
m_socket=-1;
|
||||||
m_recv_len=m_recv_pos=0;
|
m_remote_port=0;
|
||||||
m_send_len=m_send_pos=0;
|
m_state=STATE_NOCONNECTION;
|
||||||
m_host[0]=0;
|
m_recv_len=m_recv_pos=0;
|
||||||
memset(&m_saddr,0,sizeof(m_saddr));
|
m_send_len=m_send_pos=0;
|
||||||
}
|
m_host[0]=0;
|
||||||
|
memset(&m_saddr,0,sizeof(m_saddr));
|
||||||
void JNL_Connection::connect(int s, struct sockaddr_in *loc)
|
}
|
||||||
{
|
|
||||||
close(1);
|
void JNL_Connection::connect(int s, struct sockaddr_in *loc)
|
||||||
m_socket=s;
|
{
|
||||||
m_remote_port=0;
|
close(1);
|
||||||
m_dns=NULL;
|
m_socket=s;
|
||||||
if (loc) m_saddr=*loc;
|
m_remote_port=0;
|
||||||
else memset(&m_saddr,0,sizeof(m_saddr));
|
m_dns=NULL;
|
||||||
if (m_socket != -1)
|
if (loc) m_saddr=*loc;
|
||||||
{
|
else memset(&m_saddr,0,sizeof(m_saddr));
|
||||||
SET_SOCK_BLOCK(m_socket,0);
|
if (m_socket != -1)
|
||||||
m_state=STATE_CONNECTED;
|
{
|
||||||
}
|
SET_SOCK_BLOCK(m_socket,0);
|
||||||
else
|
m_state=STATE_CONNECTED;
|
||||||
{
|
}
|
||||||
m_errorstr="invalid socket passed to connect";
|
else
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
}
|
m_errorstr="invalid socket passed to connect";
|
||||||
}
|
m_state=STATE_ERROR;
|
||||||
|
}
|
||||||
void JNL_Connection::connect(char *hostname, int port)
|
}
|
||||||
{
|
|
||||||
close(1);
|
void JNL_Connection::connect(char *hostname, int port)
|
||||||
m_remote_port=(short)port;
|
{
|
||||||
m_socket=::socket(AF_INET,SOCK_STREAM,0);
|
close(1);
|
||||||
if (m_socket==-1)
|
m_remote_port=(short)port;
|
||||||
{
|
m_socket=::socket(AF_INET,SOCK_STREAM,0);
|
||||||
m_errorstr="creating socket";
|
if (m_socket==-1)
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
}
|
m_errorstr="creating socket";
|
||||||
else
|
m_state=STATE_ERROR;
|
||||||
{
|
}
|
||||||
SET_SOCK_BLOCK(m_socket,0);
|
else
|
||||||
strncpy(m_host,hostname,sizeof(m_host)-1);
|
{
|
||||||
m_host[sizeof(m_host)-1]=0;
|
SET_SOCK_BLOCK(m_socket,0);
|
||||||
memset(&m_saddr,0,sizeof(m_saddr));
|
strncpy(m_host,hostname,sizeof(m_host)-1);
|
||||||
if (!m_host[0])
|
m_host[sizeof(m_host)-1]=0;
|
||||||
{
|
memset(&m_saddr,0,sizeof(m_saddr));
|
||||||
m_errorstr="empty hostname";
|
if (!m_host[0])
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
}
|
m_errorstr="empty hostname";
|
||||||
else
|
m_state=STATE_ERROR;
|
||||||
{
|
}
|
||||||
m_state=STATE_RESOLVING;
|
else
|
||||||
m_saddr.sin_family=AF_INET;
|
{
|
||||||
m_saddr.sin_port=htons((unsigned short)port);
|
m_state=STATE_RESOLVING;
|
||||||
m_saddr.sin_addr.s_addr=inet_addr(hostname);
|
m_saddr.sin_family=AF_INET;
|
||||||
}
|
m_saddr.sin_port=htons((unsigned short)port);
|
||||||
}
|
m_saddr.sin_addr.s_addr=inet_addr(hostname);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
JNL_Connection::~JNL_Connection()
|
}
|
||||||
{
|
|
||||||
if (m_socket >= 0)
|
JNL_Connection::~JNL_Connection()
|
||||||
{
|
{
|
||||||
::shutdown(m_socket, SHUT_RDWR);
|
if (m_socket >= 0)
|
||||||
::closesocket(m_socket);
|
{
|
||||||
m_socket=-1;
|
::shutdown(m_socket, SHUT_RDWR);
|
||||||
}
|
::closesocket(m_socket);
|
||||||
free(m_recv_buffer);
|
m_socket=-1;
|
||||||
free(m_send_buffer);
|
}
|
||||||
if (m_dns_owned)
|
free(m_recv_buffer);
|
||||||
{
|
free(m_send_buffer);
|
||||||
delete m_dns;
|
if (m_dns_owned)
|
||||||
}
|
{
|
||||||
}
|
delete m_dns;
|
||||||
|
}
|
||||||
void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent, int *bytes_rcvd)
|
}
|
||||||
{
|
|
||||||
int bytes_allowed_to_send=(max_send_bytes<0)?m_send_buffer_len:max_send_bytes;
|
void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent, int *bytes_rcvd)
|
||||||
int bytes_allowed_to_recv=(max_recv_bytes<0)?m_recv_buffer_len:max_recv_bytes;
|
{
|
||||||
|
int bytes_allowed_to_send=(max_send_bytes<0)?m_send_buffer_len:max_send_bytes;
|
||||||
if (bytes_sent) *bytes_sent=0;
|
int bytes_allowed_to_recv=(max_recv_bytes<0)?m_recv_buffer_len:max_recv_bytes;
|
||||||
if (bytes_rcvd) *bytes_rcvd=0;
|
|
||||||
|
if (bytes_sent) *bytes_sent=0;
|
||||||
switch (m_state)
|
if (bytes_rcvd) *bytes_rcvd=0;
|
||||||
{
|
|
||||||
case STATE_RESOLVING:
|
switch (m_state)
|
||||||
if (m_saddr.sin_addr.s_addr == INADDR_NONE)
|
{
|
||||||
{
|
case STATE_RESOLVING:
|
||||||
int a=m_dns?m_dns->resolve(m_host,(unsigned long int *)&m_saddr.sin_addr.s_addr):-1;
|
if (m_saddr.sin_addr.s_addr == INADDR_NONE)
|
||||||
if (!a) { m_state=STATE_CONNECTING; }
|
{
|
||||||
else if (a == 1)
|
int a=m_dns?m_dns->resolve(m_host,(unsigned long int *)&m_saddr.sin_addr.s_addr):-1;
|
||||||
{
|
if (!a) { m_state=STATE_CONNECTING; }
|
||||||
m_state=STATE_RESOLVING;
|
else if (a == 1)
|
||||||
break;
|
{
|
||||||
}
|
m_state=STATE_RESOLVING;
|
||||||
else
|
break;
|
||||||
{
|
}
|
||||||
m_errorstr="resolving hostname";
|
else
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
return;
|
m_errorstr="resolving hostname";
|
||||||
}
|
m_state=STATE_ERROR;
|
||||||
}
|
return;
|
||||||
if (!::connect(m_socket,(struct sockaddr *)&m_saddr,16))
|
}
|
||||||
{
|
}
|
||||||
m_state=STATE_CONNECTED;
|
if (!::connect(m_socket,(struct sockaddr *)&m_saddr,16))
|
||||||
}
|
{
|
||||||
else if (ERRNO!=EINPROGRESS)
|
m_state=STATE_CONNECTED;
|
||||||
{
|
}
|
||||||
m_errorstr="connecting to host";
|
else if (ERRNO!=EINPROGRESS)
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
}
|
m_errorstr="connecting to host";
|
||||||
else { m_state=STATE_CONNECTING; }
|
m_state=STATE_ERROR;
|
||||||
break;
|
}
|
||||||
case STATE_CONNECTING:
|
else { m_state=STATE_CONNECTING; }
|
||||||
{
|
break;
|
||||||
fd_set f[3];
|
case STATE_CONNECTING:
|
||||||
FD_ZERO(&f[0]);
|
{
|
||||||
FD_ZERO(&f[1]);
|
fd_set f[3];
|
||||||
FD_ZERO(&f[2]);
|
FD_ZERO(&f[0]);
|
||||||
FD_SET(m_socket,&f[0]);
|
FD_ZERO(&f[1]);
|
||||||
FD_SET(m_socket,&f[1]);
|
FD_ZERO(&f[2]);
|
||||||
FD_SET(m_socket,&f[2]);
|
FD_SET(m_socket,&f[0]);
|
||||||
struct timeval tv;
|
FD_SET(m_socket,&f[1]);
|
||||||
memset(&tv,0,sizeof(tv));
|
FD_SET(m_socket,&f[2]);
|
||||||
if (select(m_socket+1,&f[0],&f[1],&f[2],&tv)==-1)
|
struct timeval tv;
|
||||||
{
|
memset(&tv,0,sizeof(tv));
|
||||||
m_errorstr="connecting to host (calling select())";
|
if (select(m_socket+1,&f[0],&f[1],&f[2],&tv)==-1)
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
}
|
m_errorstr="connecting to host (calling select())";
|
||||||
else if (FD_ISSET(m_socket,&f[1]))
|
m_state=STATE_ERROR;
|
||||||
{
|
}
|
||||||
m_state=STATE_CONNECTED;
|
else if (FD_ISSET(m_socket,&f[1]))
|
||||||
}
|
{
|
||||||
else if (FD_ISSET(m_socket,&f[2]))
|
m_state=STATE_CONNECTED;
|
||||||
{
|
}
|
||||||
m_errorstr="connecting to host";
|
else if (FD_ISSET(m_socket,&f[2]))
|
||||||
m_state=STATE_ERROR;
|
{
|
||||||
}
|
m_errorstr="connecting to host";
|
||||||
}
|
m_state=STATE_ERROR;
|
||||||
break;
|
}
|
||||||
case STATE_CONNECTED:
|
}
|
||||||
case STATE_CLOSING:
|
break;
|
||||||
if (m_send_len>0 && bytes_allowed_to_send>0)
|
case STATE_CONNECTED:
|
||||||
{
|
case STATE_CLOSING:
|
||||||
int len=m_send_buffer_len-m_send_pos;
|
if (m_send_len>0 && bytes_allowed_to_send>0)
|
||||||
if (len > m_send_len) len=m_send_len;
|
{
|
||||||
if (len > bytes_allowed_to_send) len=bytes_allowed_to_send;
|
int len=m_send_buffer_len-m_send_pos;
|
||||||
if (len > 0)
|
if (len > m_send_len) len=m_send_len;
|
||||||
{
|
if (len > bytes_allowed_to_send) len=bytes_allowed_to_send;
|
||||||
int res=::send(m_socket,m_send_buffer+m_send_pos,len,0);
|
if (len > 0)
|
||||||
if (res==-1 && ERRNO != EWOULDBLOCK)
|
{
|
||||||
{
|
int res=::send(m_socket,m_send_buffer+m_send_pos,len,0);
|
||||||
// m_state=STATE_CLOSED;
|
if (res==-1 && ERRNO != EWOULDBLOCK)
|
||||||
// return;
|
{
|
||||||
}
|
// m_state=STATE_CLOSED;
|
||||||
if (res>0)
|
// return;
|
||||||
{
|
}
|
||||||
bytes_allowed_to_send-=res;
|
if (res>0)
|
||||||
if (bytes_sent) *bytes_sent+=res;
|
{
|
||||||
m_send_pos+=res;
|
bytes_allowed_to_send-=res;
|
||||||
m_send_len-=res;
|
if (bytes_sent) *bytes_sent+=res;
|
||||||
}
|
m_send_pos+=res;
|
||||||
}
|
m_send_len-=res;
|
||||||
if (m_send_pos>=m_send_buffer_len)
|
}
|
||||||
{
|
}
|
||||||
m_send_pos=0;
|
if (m_send_pos>=m_send_buffer_len)
|
||||||
if (m_send_len>0)
|
{
|
||||||
{
|
m_send_pos=0;
|
||||||
len=m_send_buffer_len-m_send_pos;
|
if (m_send_len>0)
|
||||||
if (len > m_send_len) len=m_send_len;
|
{
|
||||||
if (len > bytes_allowed_to_send) len=bytes_allowed_to_send;
|
len=m_send_buffer_len-m_send_pos;
|
||||||
int res=::send(m_socket,m_send_buffer+m_send_pos,len,0);
|
if (len > m_send_len) len=m_send_len;
|
||||||
if (res==-1 && ERRNO != EWOULDBLOCK)
|
if (len > bytes_allowed_to_send) len=bytes_allowed_to_send;
|
||||||
{
|
int res=::send(m_socket,m_send_buffer+m_send_pos,len,0);
|
||||||
// m_state=STATE_CLOSED;
|
if (res==-1 && ERRNO != EWOULDBLOCK)
|
||||||
}
|
{
|
||||||
if (res>0)
|
// m_state=STATE_CLOSED;
|
||||||
{
|
}
|
||||||
bytes_allowed_to_send-=res;
|
if (res>0)
|
||||||
if (bytes_sent) *bytes_sent+=res;
|
{
|
||||||
m_send_pos+=res;
|
bytes_allowed_to_send-=res;
|
||||||
m_send_len-=res;
|
if (bytes_sent) *bytes_sent+=res;
|
||||||
}
|
m_send_pos+=res;
|
||||||
}
|
m_send_len-=res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_recv_len<m_recv_buffer_len)
|
}
|
||||||
{
|
}
|
||||||
int len=m_recv_buffer_len-m_recv_pos;
|
if (m_recv_len<m_recv_buffer_len)
|
||||||
if (len > m_recv_buffer_len-m_recv_len) len=m_recv_buffer_len-m_recv_len;
|
{
|
||||||
if (len > bytes_allowed_to_recv) len=bytes_allowed_to_recv;
|
int len=m_recv_buffer_len-m_recv_pos;
|
||||||
if (len>0)
|
if (len > m_recv_buffer_len-m_recv_len) len=m_recv_buffer_len-m_recv_len;
|
||||||
{
|
if (len > bytes_allowed_to_recv) len=bytes_allowed_to_recv;
|
||||||
int res=::recv(m_socket,m_recv_buffer+m_recv_pos,len,0);
|
if (len>0)
|
||||||
if (res == 0 || (res < 0 && ERRNO != EWOULDBLOCK))
|
{
|
||||||
{
|
int res=::recv(m_socket,m_recv_buffer+m_recv_pos,len,0);
|
||||||
m_state=STATE_CLOSED;
|
if (res == 0 || (res < 0 && ERRNO != EWOULDBLOCK))
|
||||||
break;
|
{
|
||||||
}
|
m_state=STATE_CLOSED;
|
||||||
if (res > 0)
|
break;
|
||||||
{
|
}
|
||||||
bytes_allowed_to_recv-=res;
|
if (res > 0)
|
||||||
if (bytes_rcvd) *bytes_rcvd+=res;
|
{
|
||||||
m_recv_pos+=res;
|
bytes_allowed_to_recv-=res;
|
||||||
m_recv_len+=res;
|
if (bytes_rcvd) *bytes_rcvd+=res;
|
||||||
}
|
m_recv_pos+=res;
|
||||||
}
|
m_recv_len+=res;
|
||||||
if (m_recv_pos >= m_recv_buffer_len)
|
}
|
||||||
{
|
}
|
||||||
m_recv_pos=0;
|
if (m_recv_pos >= m_recv_buffer_len)
|
||||||
if (m_recv_len < m_recv_buffer_len)
|
{
|
||||||
{
|
m_recv_pos=0;
|
||||||
len=m_recv_buffer_len-m_recv_len;
|
if (m_recv_len < m_recv_buffer_len)
|
||||||
if (len > bytes_allowed_to_recv) len=bytes_allowed_to_recv;
|
{
|
||||||
if (len > 0)
|
len=m_recv_buffer_len-m_recv_len;
|
||||||
{
|
if (len > bytes_allowed_to_recv) len=bytes_allowed_to_recv;
|
||||||
int res=::recv(m_socket,m_recv_buffer+m_recv_pos,len,0);
|
if (len > 0)
|
||||||
if (res == 0 || (res < 0 && ERRNO != EWOULDBLOCK))
|
{
|
||||||
{
|
int res=::recv(m_socket,m_recv_buffer+m_recv_pos,len,0);
|
||||||
m_state=STATE_CLOSED;
|
if (res == 0 || (res < 0 && ERRNO != EWOULDBLOCK))
|
||||||
break;
|
{
|
||||||
}
|
m_state=STATE_CLOSED;
|
||||||
if (res > 0)
|
break;
|
||||||
{
|
}
|
||||||
bytes_allowed_to_recv-=res;
|
if (res > 0)
|
||||||
if (bytes_rcvd) *bytes_rcvd+=res;
|
{
|
||||||
m_recv_pos+=res;
|
bytes_allowed_to_recv-=res;
|
||||||
m_recv_len+=res;
|
if (bytes_rcvd) *bytes_rcvd+=res;
|
||||||
}
|
m_recv_pos+=res;
|
||||||
}
|
m_recv_len+=res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_state == STATE_CLOSING)
|
}
|
||||||
{
|
}
|
||||||
if (m_send_len < 1) m_state = STATE_CLOSED;
|
if (m_state == STATE_CLOSING)
|
||||||
}
|
{
|
||||||
break;
|
if (m_send_len < 1) m_state = STATE_CLOSED;
|
||||||
default: break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
default: break;
|
||||||
|
}
|
||||||
void JNL_Connection::close(int quick)
|
}
|
||||||
{
|
|
||||||
if (quick || m_state == STATE_RESOLVING || m_state == STATE_CONNECTING)
|
void JNL_Connection::close(int quick)
|
||||||
{
|
{
|
||||||
m_state=STATE_CLOSED;
|
if (quick || m_state == STATE_RESOLVING || m_state == STATE_CONNECTING)
|
||||||
if (m_socket >= 0)
|
{
|
||||||
{
|
m_state=STATE_CLOSED;
|
||||||
::shutdown(m_socket, SHUT_RDWR);
|
if (m_socket >= 0)
|
||||||
::closesocket(m_socket);
|
{
|
||||||
}
|
::shutdown(m_socket, SHUT_RDWR);
|
||||||
m_socket=-1;
|
::closesocket(m_socket);
|
||||||
memset(m_recv_buffer,0,m_recv_buffer_len);
|
}
|
||||||
memset(m_send_buffer,0,m_send_buffer_len);
|
m_socket=-1;
|
||||||
m_remote_port=0;
|
memset(m_recv_buffer,0,m_recv_buffer_len);
|
||||||
m_recv_len=m_recv_pos=0;
|
memset(m_send_buffer,0,m_send_buffer_len);
|
||||||
m_send_len=m_send_pos=0;
|
m_remote_port=0;
|
||||||
m_host[0]=0;
|
m_recv_len=m_recv_pos=0;
|
||||||
memset(&m_saddr,0,sizeof(m_saddr));
|
m_send_len=m_send_pos=0;
|
||||||
}
|
m_host[0]=0;
|
||||||
else
|
memset(&m_saddr,0,sizeof(m_saddr));
|
||||||
{
|
}
|
||||||
if (m_state == STATE_CONNECTED) m_state=STATE_CLOSING;
|
else
|
||||||
}
|
{
|
||||||
}
|
if (m_state == STATE_CONNECTED) m_state=STATE_CLOSING;
|
||||||
|
}
|
||||||
int JNL_Connection::send_bytes_in_queue(void)
|
}
|
||||||
{
|
|
||||||
return m_send_len;
|
int JNL_Connection::send_bytes_in_queue(void)
|
||||||
}
|
{
|
||||||
|
return m_send_len;
|
||||||
int JNL_Connection::send_bytes_available(void)
|
}
|
||||||
{
|
|
||||||
return m_send_buffer_len-m_send_len;
|
int JNL_Connection::send_bytes_available(void)
|
||||||
}
|
{
|
||||||
|
return m_send_buffer_len-m_send_len;
|
||||||
int JNL_Connection::send(char *data, int length)
|
}
|
||||||
{
|
|
||||||
if (length > send_bytes_available())
|
int JNL_Connection::send(char *data, int length)
|
||||||
{
|
{
|
||||||
return -1;
|
if (length > send_bytes_available())
|
||||||
}
|
{
|
||||||
|
return -1;
|
||||||
int write_pos=m_send_pos+m_send_len;
|
}
|
||||||
if (write_pos >= m_send_buffer_len)
|
|
||||||
{
|
int write_pos=m_send_pos+m_send_len;
|
||||||
write_pos-=m_send_buffer_len;
|
if (write_pos >= m_send_buffer_len)
|
||||||
}
|
{
|
||||||
|
write_pos-=m_send_buffer_len;
|
||||||
int len=m_send_buffer_len-write_pos;
|
}
|
||||||
if (len > length)
|
|
||||||
{
|
int len=m_send_buffer_len-write_pos;
|
||||||
len=length;
|
if (len > length)
|
||||||
}
|
{
|
||||||
|
len=length;
|
||||||
memcpy(m_send_buffer+write_pos,data,len);
|
}
|
||||||
if (length > len)
|
|
||||||
{
|
memcpy(m_send_buffer+write_pos,data,len);
|
||||||
memcpy(m_send_buffer,data+len,length-len);
|
if (length > len)
|
||||||
}
|
{
|
||||||
m_send_len+=length;
|
memcpy(m_send_buffer,data+len,length-len);
|
||||||
return 0;
|
}
|
||||||
}
|
m_send_len+=length;
|
||||||
|
return 0;
|
||||||
int JNL_Connection::send_string(char *line)
|
}
|
||||||
{
|
|
||||||
return send(line,strlen(line));
|
int JNL_Connection::send_string(char *line)
|
||||||
}
|
{
|
||||||
|
return send(line,strlen(line));
|
||||||
int JNL_Connection::recv_bytes_available(void)
|
}
|
||||||
{
|
|
||||||
return m_recv_len;
|
int JNL_Connection::recv_bytes_available(void)
|
||||||
}
|
{
|
||||||
|
return m_recv_len;
|
||||||
int JNL_Connection::peek_bytes(char *data, int maxlength)
|
}
|
||||||
{
|
|
||||||
if (maxlength > m_recv_len)
|
int JNL_Connection::peek_bytes(char *data, int maxlength)
|
||||||
{
|
{
|
||||||
maxlength=m_recv_len;
|
if (maxlength > m_recv_len)
|
||||||
}
|
{
|
||||||
int read_pos=m_recv_pos-m_recv_len;
|
maxlength=m_recv_len;
|
||||||
if (read_pos < 0)
|
}
|
||||||
{
|
int read_pos=m_recv_pos-m_recv_len;
|
||||||
read_pos += m_recv_buffer_len;
|
if (read_pos < 0)
|
||||||
}
|
{
|
||||||
int len=m_recv_buffer_len-read_pos;
|
read_pos += m_recv_buffer_len;
|
||||||
if (len > maxlength)
|
}
|
||||||
{
|
int len=m_recv_buffer_len-read_pos;
|
||||||
len=maxlength;
|
if (len > maxlength)
|
||||||
}
|
{
|
||||||
memcpy(data,m_recv_buffer+read_pos,len);
|
len=maxlength;
|
||||||
if (len < maxlength)
|
}
|
||||||
{
|
memcpy(data,m_recv_buffer+read_pos,len);
|
||||||
memcpy(data+len,m_recv_buffer,maxlength-len);
|
if (len < maxlength)
|
||||||
}
|
{
|
||||||
|
memcpy(data+len,m_recv_buffer,maxlength-len);
|
||||||
return maxlength;
|
}
|
||||||
}
|
|
||||||
|
return maxlength;
|
||||||
int JNL_Connection::recv_bytes(char *data, int maxlength)
|
}
|
||||||
{
|
|
||||||
|
int JNL_Connection::recv_bytes(char *data, int maxlength)
|
||||||
int ml=peek_bytes(data,maxlength);
|
{
|
||||||
m_recv_len-=ml;
|
|
||||||
return ml;
|
int ml=peek_bytes(data,maxlength);
|
||||||
}
|
m_recv_len-=ml;
|
||||||
|
return ml;
|
||||||
int JNL_Connection::getbfromrecv(int pos, int remove)
|
}
|
||||||
{
|
|
||||||
int read_pos=m_recv_pos-m_recv_len + pos;
|
int JNL_Connection::getbfromrecv(int pos, int remove)
|
||||||
if (pos < 0 || pos > m_recv_len) return -1;
|
{
|
||||||
if (read_pos < 0)
|
int read_pos=m_recv_pos-m_recv_len + pos;
|
||||||
{
|
if (pos < 0 || pos > m_recv_len) return -1;
|
||||||
read_pos += m_recv_buffer_len;
|
if (read_pos < 0)
|
||||||
}
|
{
|
||||||
if (read_pos >= m_recv_buffer_len)
|
read_pos += m_recv_buffer_len;
|
||||||
{
|
}
|
||||||
read_pos-=m_recv_buffer_len;
|
if (read_pos >= m_recv_buffer_len)
|
||||||
}
|
{
|
||||||
if (remove) m_recv_len--;
|
read_pos-=m_recv_buffer_len;
|
||||||
return m_recv_buffer[read_pos];
|
}
|
||||||
}
|
if (remove) m_recv_len--;
|
||||||
|
return m_recv_buffer[read_pos];
|
||||||
int JNL_Connection::recv_lines_available(void)
|
}
|
||||||
{
|
|
||||||
int l=recv_bytes_available();
|
int JNL_Connection::recv_lines_available(void)
|
||||||
int lcount=0;
|
{
|
||||||
int lastch=0;
|
int l=recv_bytes_available();
|
||||||
int pos;
|
int lcount=0;
|
||||||
for (pos=0; pos < l; pos ++)
|
int lastch=0;
|
||||||
{
|
int pos;
|
||||||
int t=getbfromrecv(pos,0);
|
for (pos=0; pos < l; pos ++)
|
||||||
if (t == -1) return lcount;
|
{
|
||||||
if ((t=='\r' || t=='\n') &&(
|
int t=getbfromrecv(pos,0);
|
||||||
(lastch != '\r' && lastch != '\n') || lastch==t
|
if (t == -1) return lcount;
|
||||||
)) lcount++;
|
if ((t=='\r' || t=='\n') &&(
|
||||||
lastch=t;
|
(lastch != '\r' && lastch != '\n') || lastch==t
|
||||||
}
|
)) lcount++;
|
||||||
return lcount;
|
lastch=t;
|
||||||
}
|
}
|
||||||
|
return lcount;
|
||||||
int JNL_Connection::recv_line(char *line, int maxlength)
|
}
|
||||||
{
|
|
||||||
if (maxlength > m_recv_len) maxlength=m_recv_len;
|
int JNL_Connection::recv_line(char *line, int maxlength)
|
||||||
while (maxlength--)
|
{
|
||||||
{
|
if (maxlength > m_recv_len) maxlength=m_recv_len;
|
||||||
int t=getbfromrecv(0,1);
|
while (maxlength--)
|
||||||
if (t == -1)
|
{
|
||||||
{
|
int t=getbfromrecv(0,1);
|
||||||
*line=0;
|
if (t == -1)
|
||||||
return 0;
|
{
|
||||||
}
|
*line=0;
|
||||||
if (t == '\r' || t == '\n')
|
return 0;
|
||||||
{
|
}
|
||||||
int r=getbfromrecv(0,0);
|
if (t == '\r' || t == '\n')
|
||||||
if ((r == '\r' || r == '\n') && r != t) getbfromrecv(0,1);
|
{
|
||||||
*line=0;
|
int r=getbfromrecv(0,0);
|
||||||
return 0;
|
if ((r == '\r' || r == '\n') && r != t) getbfromrecv(0,1);
|
||||||
}
|
*line=0;
|
||||||
*line++=(char)t;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
*line++=(char)t;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
unsigned long JNL_Connection::get_interface(void)
|
}
|
||||||
{
|
|
||||||
if (m_socket==-1) return 0;
|
unsigned long JNL_Connection::get_interface(void)
|
||||||
struct sockaddr_in sin;
|
{
|
||||||
memset(&sin,0,sizeof(sin));
|
if (m_socket==-1) return 0;
|
||||||
socklen_t len=16;
|
struct sockaddr_in sin;
|
||||||
if (::getsockname(m_socket,(struct sockaddr *)&sin,&len)) return 0;
|
memset(&sin,0,sizeof(sin));
|
||||||
return (unsigned long) sin.sin_addr.s_addr;
|
socklen_t len=16;
|
||||||
}
|
if (::getsockname(m_socket,(struct sockaddr *)&sin,&len)) return 0;
|
||||||
|
return (unsigned long) sin.sin_addr.s_addr;
|
||||||
|
}
|
||||||
|
|
|
@ -1,135 +1,138 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: connection.h - JNL TCP connection interface
|
** File: connection.h - JNL TCP connection interface
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
**
|
**
|
||||||
** Usage:
|
** Usage:
|
||||||
** 1. Create a JNL_Connection object, optionally specifying a JNL_AsyncDNS
|
** 1. Create a JNL_Connection object, optionally specifying a JNL_AsyncDNS
|
||||||
** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto),
|
** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto),
|
||||||
** and the send and receive buffer sizes.
|
** and the send and receive buffer sizes.
|
||||||
** 2. Call connect() to have it connect to a host/port (the hostname will be
|
** 2. Call connect() to have it connect to a host/port (the hostname will be
|
||||||
** resolved if possible).
|
** resolved if possible).
|
||||||
** 3. call run() with the maximum send/recv amounts, and optionally parameters
|
** 3. call run() with the maximum send/recv amounts, and optionally parameters
|
||||||
** so you can tell how much has been send/received. You want to do this a lot, while:
|
** so you can tell how much has been send/received. You want to do this a lot, while:
|
||||||
** 4. check get_state() to check the state of the connection. The states are:
|
** 4. check get_state() to check the state of the connection. The states are:
|
||||||
** JNL_Connection::STATE_ERROR
|
** JNL_Connection::STATE_ERROR
|
||||||
** - an error has occurred on the connection. the connection has closed,
|
** - an error has occurred on the connection. the connection has closed,
|
||||||
** and you can no longer write to the socket (there still might be
|
** and you can no longer write to the socket (there still might be
|
||||||
** data in the receive buffer - use recv_bytes_available()).
|
** data in the receive buffer - use recv_bytes_available()).
|
||||||
** JNL_Connection::STATE_NOCONNECTION
|
** JNL_Connection::STATE_NOCONNECTION
|
||||||
** - no connection has been made yet. call connect() already! :)
|
** - no connection has been made yet. call connect() already! :)
|
||||||
** JNL_Connection::STATE_RESOLVING
|
** JNL_Connection::STATE_RESOLVING
|
||||||
** - the connection is still waiting for a JNL_AsycnDNS to resolve the
|
** - the connection is still waiting for a JNL_AsycnDNS to resolve the
|
||||||
** host.
|
** host.
|
||||||
** JNL_Connection::STATE_CONNECTING
|
** JNL_Connection::STATE_CONNECTING
|
||||||
** - the asynchronous call to connect() is still running.
|
** - the asynchronous call to connect() is still running.
|
||||||
** JNL_Connection::STATE_CONNECTED
|
** JNL_Connection::STATE_CONNECTED
|
||||||
** - the connection has connected, all is well.
|
** - the connection has connected, all is well.
|
||||||
** JNL_Connection::STATE_CLOSING
|
** JNL_Connection::STATE_CLOSING
|
||||||
** - the connection is closing. This happens after a call to close,
|
** - the connection is closing. This happens after a call to close,
|
||||||
** without the quick parameter set. This means that the connection
|
** without the quick parameter set. This means that the connection
|
||||||
** will close once the data in the send buffer is sent (data could
|
** will close once the data in the send buffer is sent (data could
|
||||||
** still be being received when it would be closed). After it is
|
** still be being received when it would be closed). After it is
|
||||||
** closed, the state will transition to:
|
** closed, the state will transition to:
|
||||||
** JNL_Connection::STATE_CLOSED
|
** JNL_Connection::STATE_CLOSED
|
||||||
** - the connection has closed, generally without error. There still
|
** - the connection has closed, generally without error. There still
|
||||||
** might be data in the receieve buffer, use recv_bytes_available().
|
** might be data in the receieve buffer, use recv_bytes_available().
|
||||||
** 5. Use send() and send_string() to send data. You can use
|
** 5. Use send() and send_string() to send data. You can use
|
||||||
** send_bytes_in_queue() to see how much has yet to go out, or
|
** send_bytes_in_queue() to see how much has yet to go out, or
|
||||||
** send_bytes_available() to see how much you can write. If you use send()
|
** send_bytes_available() to see how much you can write. If you use send()
|
||||||
** or send_string() and not enough room is available, both functions will
|
** or send_string() and not enough room is available, both functions will
|
||||||
** return error ( < 0)
|
** return error ( < 0)
|
||||||
** 6. Use recv() and recv_line() to get data. If you want to see how much data
|
** 6. Use recv() and recv_line() to get data. If you want to see how much data
|
||||||
** there is, use recv_bytes_available() and recv_lines_available(). If you
|
** there is, use recv_bytes_available() and recv_lines_available(). If you
|
||||||
** call recv() and not enough data is available, recv() will return how much
|
** call recv() and not enough data is available, recv() will return how much
|
||||||
** data was actually read. See comments at the function defs.
|
** data was actually read. See comments at the function defs.
|
||||||
**
|
**
|
||||||
** 7. To close, call close(1) for a quick close, or close() for a close that will
|
** 7. To close, call close(1) for a quick close, or close() for a close that will
|
||||||
** make the socket close after sending all the data sent.
|
** make the socket close after sending all the data sent.
|
||||||
**
|
**
|
||||||
** 8. delete ye' ol' object.
|
** 8. delete ye' ol' object.
|
||||||
*/
|
**
|
||||||
|
** Unicode support by Jim Park -- 08/24/2007
|
||||||
#ifndef _CONNECTION_H_
|
** Keep all the stuff here strictly ANSI.
|
||||||
#define _CONNECTION_H_
|
*/
|
||||||
|
|
||||||
#include "asyncdns.h"
|
#ifndef _CONNECTION_H_
|
||||||
|
#define _CONNECTION_H_
|
||||||
#define JNL_CONNECTION_AUTODNS ((JNL_AsyncDNS*)-1)
|
|
||||||
|
#include "asyncdns.h"
|
||||||
class JNL_Connection
|
|
||||||
{
|
#define JNL_CONNECTION_AUTODNS ((JNL_AsyncDNS*)-1)
|
||||||
public:
|
|
||||||
typedef enum
|
class JNL_Connection
|
||||||
{
|
{
|
||||||
STATE_ERROR,
|
public:
|
||||||
STATE_NOCONNECTION,
|
typedef enum
|
||||||
STATE_RESOLVING,
|
{
|
||||||
STATE_CONNECTING,
|
STATE_ERROR,
|
||||||
STATE_CONNECTED,
|
STATE_NOCONNECTION,
|
||||||
STATE_CLOSING,
|
STATE_RESOLVING,
|
||||||
STATE_CLOSED
|
STATE_CONNECTING,
|
||||||
} state;
|
STATE_CONNECTED,
|
||||||
|
STATE_CLOSING,
|
||||||
JNL_Connection(JNL_AsyncDNS *dns=JNL_CONNECTION_AUTODNS, int sendbufsize=8192, int recvbufsize=8192);
|
STATE_CLOSED
|
||||||
~JNL_Connection();
|
} state;
|
||||||
|
|
||||||
void connect(char *hostname, int port);
|
JNL_Connection(JNL_AsyncDNS *dns=JNL_CONNECTION_AUTODNS, int sendbufsize=8192, int recvbufsize=8192);
|
||||||
void connect(int sock, struct sockaddr_in *loc=NULL); // used by the listen object, usually not needed by users.
|
~JNL_Connection();
|
||||||
|
|
||||||
void run(int max_send_bytes=-1, int max_recv_bytes=-1, int *bytes_sent=NULL, int *bytes_rcvd=NULL);
|
void connect(char *hostname, int port);
|
||||||
int get_state() { return m_state; }
|
void connect(int sock, struct sockaddr_in *loc=NULL); // used by the listen object, usually not needed by users.
|
||||||
char *get_errstr() { return m_errorstr; }
|
|
||||||
|
void run(int max_send_bytes=-1, int max_recv_bytes=-1, int *bytes_sent=NULL, int *bytes_rcvd=NULL);
|
||||||
void close(int quick=0);
|
int get_state() { return m_state; }
|
||||||
void flush_send(void) { m_send_len=m_send_pos=0; }
|
char *get_errstr() { return m_errorstr; }
|
||||||
|
|
||||||
int send_bytes_in_queue(void);
|
void close(int quick=0);
|
||||||
int send_bytes_available(void);
|
void flush_send(void) { m_send_len=m_send_pos=0; }
|
||||||
int send(char *data, int length); // returns -1 if not enough room
|
|
||||||
int send_string(char *line); // returns -1 if not enough room
|
int send_bytes_in_queue(void);
|
||||||
|
int send_bytes_available(void);
|
||||||
|
int send(char *data, int length); // returns -1 if not enough room
|
||||||
int recv_bytes_available(void);
|
int send_string(char *line); // returns -1 if not enough room
|
||||||
int recv_bytes(char *data, int maxlength); // returns actual bytes read
|
|
||||||
unsigned int recv_int(void);
|
|
||||||
int recv_lines_available(void);
|
int recv_bytes_available(void);
|
||||||
int recv_line(char *line, int maxlength); // returns 0 if the line was terminated with a \r or \n, 1 if not.
|
int recv_bytes(char *data, int maxlength); // returns actual bytes read
|
||||||
// (i.e. if you specify maxlength=10, and the line is 12 bytes long
|
unsigned int recv_int(void);
|
||||||
// it will return 1. or if there is no \r or \n and that's all the data
|
int recv_lines_available(void);
|
||||||
// the connection has.)
|
int recv_line(char *line, int maxlength); // returns 0 if the line was terminated with a \r or \n, 1 if not.
|
||||||
int peek_bytes(char *data, int maxlength); // returns bytes peeked
|
// (i.e. if you specify maxlength=10, and the line is 12 bytes long
|
||||||
|
// it will return 1. or if there is no \r or \n and that's all the data
|
||||||
unsigned long get_interface(void); // this returns the interface the connection is on
|
// the connection has.)
|
||||||
unsigned long get_remote(void) { return m_saddr.sin_addr.s_addr; } // remote host ip.
|
int peek_bytes(char *data, int maxlength); // returns bytes peeked
|
||||||
short get_remote_port(void) { return m_remote_port; } // this returns the remote port of connection
|
|
||||||
|
unsigned long get_interface(void); // this returns the interface the connection is on
|
||||||
protected:
|
unsigned long get_remote(void) { return m_saddr.sin_addr.s_addr; } // remote host ip.
|
||||||
int m_socket;
|
short get_remote_port(void) { return m_remote_port; } // this returns the remote port of connection
|
||||||
short m_remote_port;
|
|
||||||
char *m_recv_buffer;
|
protected:
|
||||||
char *m_send_buffer;
|
int m_socket;
|
||||||
int m_recv_buffer_len;
|
short m_remote_port;
|
||||||
int m_send_buffer_len;
|
char *m_recv_buffer;
|
||||||
|
char *m_send_buffer;
|
||||||
int m_recv_pos;
|
int m_recv_buffer_len;
|
||||||
int m_recv_len;
|
int m_send_buffer_len;
|
||||||
int m_send_pos;
|
|
||||||
int m_send_len;
|
int m_recv_pos;
|
||||||
|
int m_recv_len;
|
||||||
struct sockaddr_in m_saddr;
|
int m_send_pos;
|
||||||
char m_host[256];
|
int m_send_len;
|
||||||
|
|
||||||
JNL_AsyncDNS *m_dns;
|
struct sockaddr_in m_saddr;
|
||||||
int m_dns_owned;
|
char m_host[256];
|
||||||
|
|
||||||
state m_state;
|
JNL_AsyncDNS *m_dns;
|
||||||
char *m_errorstr;
|
int m_dns_owned;
|
||||||
|
|
||||||
int getbfromrecv(int pos, int remove); // used by recv_line*
|
state m_state;
|
||||||
|
char *m_errorstr;
|
||||||
};
|
|
||||||
|
int getbfromrecv(int pos, int remove); // used by recv_line*
|
||||||
#endif // _Connection_H_
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _Connection_H_
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,109 +1,113 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: httpget.h - JNL interface for doing HTTP GETs.
|
** File: httpget.h - JNL interface for doing HTTP GETs.
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
**
|
**
|
||||||
** Usage:
|
** Usage:
|
||||||
** 1. Create a JNL_HTTPGet object, optionally specifying a JNL_AsyncDNS
|
** 1. Create a JNL_HTTPGet object, optionally specifying a JNL_AsyncDNS
|
||||||
** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto),
|
** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto),
|
||||||
** and the receive buffer size, and a string specifying proxy (or NULL
|
** and the receive buffer size, and a string specifying proxy (or NULL
|
||||||
** for none). See note on proxy string below.
|
** for none). See note on proxy string below.
|
||||||
** 2. call addheader() to add whatever headers you want. It is recommended to
|
** 2. call addheader() to add whatever headers you want. It is recommended to
|
||||||
** add at least the following two:
|
** add at least the following two:
|
||||||
** addheader("User-Agent:MyApp (Mozilla)");
|
** addheader("User-Agent:MyApp (Mozilla)");
|
||||||
*/// addheader("Accept:*/*");
|
*/// addheader("Accept:*/*");
|
||||||
/* ( the comment weirdness is there so I Can do the star-slash :)
|
/* ( the comment weirdness is there so I Can do the star-slash :)
|
||||||
** 3. Call connect() with the URL you wish to GET (see URL string note below)
|
** 3. Call connect() with the URL you wish to GET (see URL string note below)
|
||||||
** 4. Call run() once in a while, checking to see if it returns -1
|
** 4. Call run() once in a while, checking to see if it returns -1
|
||||||
** (if it does return -1, call geterrorstr() to see what the error is).
|
** (if it does return -1, call geterrorstr() to see what the error is).
|
||||||
** (if it returns 1, no big deal, the connection has closed).
|
** (if it returns 1, no big deal, the connection has closed).
|
||||||
** 5. While you're at it, you can call bytes_available() to see if any data
|
** 5. While you're at it, you can call bytes_available() to see if any data
|
||||||
** from the http stream is available, or getheader() to see if any headers
|
** from the http stream is available, or getheader() to see if any headers
|
||||||
** are available, or getreply() to see the HTTP reply, or getallheaders()
|
** are available, or getreply() to see the HTTP reply, or getallheaders()
|
||||||
** to get a double null terminated, null delimited list of headers returned.
|
** to get a double null terminated, null delimited list of headers returned.
|
||||||
** 6. If you want to read from the stream, call get_bytes (which returns how much
|
** 6. If you want to read from the stream, call get_bytes (which returns how much
|
||||||
** was actually read).
|
** was actually read).
|
||||||
** 7. content_length() is a helper function that uses getheader() to check the
|
** 7. content_length() is a helper function that uses getheader() to check the
|
||||||
** content-length header.
|
** content-length header.
|
||||||
** 8. Delete ye' ol' object when done.
|
** 8. Delete ye' ol' object when done.
|
||||||
**
|
**
|
||||||
** Proxy String:
|
** Proxy String:
|
||||||
** should be in the format of host:port, or user@host:port, or
|
** should be in the format of host:port, or user@host:port, or
|
||||||
** user:password@host:port. if port is not specified, 80 is assumed.
|
** user:password@host:port. if port is not specified, 80 is assumed.
|
||||||
** URL String:
|
** URL String:
|
||||||
** should be in the format of http://user:pass@host:port/requestwhatever
|
** should be in the format of http://user:pass@host:port/requestwhatever
|
||||||
** note that user, pass, port, and /requestwhatever are all optional :)
|
** note that user, pass, port, and /requestwhatever are all optional :)
|
||||||
** note that also, http:// is really not important. if you do poo://
|
** note that also, http:// is really not important. if you do poo://
|
||||||
** or even leave out the http:// altogether, it will still work.
|
** or even leave out the http:// altogether, it will still work.
|
||||||
*/
|
**
|
||||||
|
** Reviewed for Unicode support by Jim Park -- 08/24/2004
|
||||||
#ifndef _HTTPGET_H_
|
** Everything remains ANSI. Made sure all TCHAR style functions were
|
||||||
#define _HTTPGET_H_
|
** changed to strictly ANSI.
|
||||||
|
*/
|
||||||
#include "connection.h"
|
|
||||||
|
#ifndef _HTTPGET_H_
|
||||||
class JNL_HTTPGet
|
#define _HTTPGET_H_
|
||||||
{
|
|
||||||
public:
|
#include "connection.h"
|
||||||
JNL_HTTPGet(JNL_AsyncDNS *dns=JNL_CONNECTION_AUTODNS, int recvbufsize=16384, char *proxy=NULL);
|
|
||||||
~JNL_HTTPGet();
|
class JNL_HTTPGet
|
||||||
|
{
|
||||||
void addheader(char *header);
|
public:
|
||||||
|
JNL_HTTPGet(JNL_AsyncDNS *dns=JNL_CONNECTION_AUTODNS, int recvbufsize=16384, char *proxy=NULL);
|
||||||
void connect(char *url);
|
~JNL_HTTPGet();
|
||||||
|
|
||||||
int run(); // returns: 0 if all is OK. -1 if error (call geterrorstr()). 1 if connection closed.
|
void addheader(char *header);
|
||||||
|
|
||||||
int get_status(); // returns 0 if connecting, 1 if reading headers,
|
void connect(char *url);
|
||||||
// 2 if reading content, -1 if error.
|
|
||||||
|
int run(); // returns: 0 if all is OK. -1 if error (call geterrorstr()). 1 if connection closed.
|
||||||
char *getallheaders(); // double null terminated, null delimited list
|
|
||||||
char *getheader(char *headername);
|
int get_status(); // returns 0 if connecting, 1 if reading headers,
|
||||||
char *getreply() { return m_reply; }
|
// 2 if reading content, -1 if error.
|
||||||
int getreplycode(); // returns 0 if none yet, otherwise returns http reply code.
|
|
||||||
|
char *getallheaders(); // double null terminated, null delimited list
|
||||||
char *geterrorstr() { return m_errstr;}
|
char *getheader(char *headername);
|
||||||
|
char *getreply() { return m_reply; }
|
||||||
int bytes_available();
|
int getreplycode(); // returns 0 if none yet, otherwise returns http reply code.
|
||||||
int get_bytes(char *buf, int len);
|
|
||||||
int peek_bytes(char *buf, int len);
|
char *geterrorstr() { return m_errstr;}
|
||||||
|
|
||||||
__int64 content_length();
|
int bytes_available();
|
||||||
|
int get_bytes(char *buf, int len);
|
||||||
JNL_Connection *get_con() { return m_con; }
|
int peek_bytes(char *buf, int len);
|
||||||
|
|
||||||
public:
|
__int64 content_length();
|
||||||
void reinit();
|
|
||||||
void deinit();
|
JNL_Connection *get_con() { return m_con; }
|
||||||
void seterrstr(char *str) { if (m_errstr) free(m_errstr); m_errstr=(char*)malloc(strlen(str)+1); strcpy(m_errstr,str); }
|
|
||||||
|
public:
|
||||||
void do_parse_url(char *url, char **host, int *port, char **req, char **lp);
|
void reinit();
|
||||||
void do_encode_mimestr(char *in, char *out);
|
void deinit();
|
||||||
|
void seterrstr(char *str) { if (m_errstr) free(m_errstr); m_errstr=(char*)malloc(strlen(str)+1); strcpy(m_errstr,str); }
|
||||||
JNL_AsyncDNS *m_dns;
|
|
||||||
JNL_Connection *m_con;
|
void do_parse_url(char *url, char **host, int *port, char **req, char **lp);
|
||||||
int m_recvbufsize;
|
void do_encode_mimestr(char *in, char *out);
|
||||||
|
|
||||||
int m_http_state;
|
JNL_AsyncDNS *m_dns;
|
||||||
|
JNL_Connection *m_con;
|
||||||
int m_http_port;
|
int m_recvbufsize;
|
||||||
char *m_http_url;
|
|
||||||
char *m_http_host;
|
int m_http_state;
|
||||||
char *m_http_lpinfo;
|
|
||||||
char *m_http_request;
|
int m_http_port;
|
||||||
|
char *m_http_url;
|
||||||
char *m_http_proxylpinfo;
|
char *m_http_host;
|
||||||
char *m_http_proxyhost;
|
char *m_http_lpinfo;
|
||||||
int m_http_proxyport;
|
char *m_http_request;
|
||||||
|
|
||||||
char *m_sendheaders;
|
char *m_http_proxylpinfo;
|
||||||
char *m_recvheaders;
|
char *m_http_proxyhost;
|
||||||
int m_recvheaders_size;
|
int m_http_proxyport;
|
||||||
char *m_reply;
|
|
||||||
|
char *m_sendheaders;
|
||||||
char *m_errstr;
|
char *m_recvheaders;
|
||||||
};
|
int m_recvheaders_size;
|
||||||
|
char *m_reply;
|
||||||
#endif // _HTTPGET_H_
|
|
||||||
|
char *m_errstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _HTTPGET_H_
|
||||||
|
|
|
@ -1,42 +1,46 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: netinc.h - network includes and portability defines (used internally)
|
** File: netinc.h - network includes and portability defines (used internally)
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
*/
|
**
|
||||||
|
** Unicode support by Jim Park -- 08/24/2007
|
||||||
#ifndef _NETINC_H_
|
*/
|
||||||
#define _NETINC_H_
|
|
||||||
|
#ifndef _NETINC_H_
|
||||||
#include <windows.h>
|
#define _NETINC_H_
|
||||||
#include "util.h"
|
|
||||||
|
#include <windows.h>
|
||||||
#define strcasecmp(x,y) stricmp(x,y)
|
#include "util.h"
|
||||||
#define ERRNO (WSAGetLastError())
|
|
||||||
#define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); }
|
#define strcasecmp(x,y) stricmp(x,y)
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define ERRNO (WSAGetLastError())
|
||||||
#define EINPROGRESS WSAEWOULDBLOCK
|
#define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); }
|
||||||
#define memset mini_memset
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
#define memcpy mini_memcpy
|
#define EINPROGRESS WSAEWOULDBLOCK
|
||||||
#define strcpy lstrcpy
|
#define memset mini_memset
|
||||||
#define strncpy lstrcpyn
|
#define memcpy mini_memcpy
|
||||||
#define strcat lstrcat
|
// Jim Park: For Unicode support, we need to distinguish whether we are working on
|
||||||
#define strlen lstrlen
|
// Unicode or ANSI.
|
||||||
#define malloc(x) (new char[x])
|
#define strcpy lstrcpyA
|
||||||
#define free(x) {delete [] x;}
|
#define strncpy lstrcpynA
|
||||||
typedef int socklen_t;
|
#define strcat lstrcatA
|
||||||
|
#define strlen lstrlenA
|
||||||
#ifndef INADDR_NONE
|
#define malloc(x) (new char[x])
|
||||||
#define INADDR_NONE 0xffffffff
|
#define free(x) {delete [] x;}
|
||||||
#endif
|
typedef int socklen_t;
|
||||||
|
|
||||||
#ifndef INADDR_ANY
|
#ifndef INADDR_NONE
|
||||||
#define INADDR_ANY 0
|
#define INADDR_NONE 0xffffffff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SHUT_RDWR
|
#ifndef INADDR_ANY
|
||||||
#define SHUT_RDWR 2
|
#define INADDR_ANY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //_NETINC_H_
|
#ifndef SHUT_RDWR
|
||||||
|
#define SHUT_RDWR 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //_NETINC_H_
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,85 +1,88 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: util.cpp - JNL implementation of basic network utilities
|
** File: util.cpp - JNL implementation of basic network utilities
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
*/
|
**
|
||||||
|
** Unicode support by Jim Park -- 08/24/2007
|
||||||
#include "netinc.h"
|
** Keep everything here strictly ANSI. No TCHAR style stuff.
|
||||||
|
*/
|
||||||
#include "util.h"
|
|
||||||
|
#include "netinc.h"
|
||||||
int my_atoi(char *s)
|
|
||||||
{
|
#include "util.h"
|
||||||
int sign=0;
|
|
||||||
int v=0;
|
int my_atoi(char *s)
|
||||||
if (*s == '-') { s++; sign++; }
|
{
|
||||||
for (;;)
|
int sign=0;
|
||||||
{
|
int v=0;
|
||||||
int c=*s++ - '0';
|
if (*s == '-') { s++; sign++; }
|
||||||
if (c < 0 || c > 9) break;
|
for (;;)
|
||||||
v*=10;
|
{
|
||||||
v+=c;
|
int c=*s++ - '0';
|
||||||
}
|
if (c < 0 || c > 9) break;
|
||||||
if (sign) return -(int) v;
|
v*=10;
|
||||||
return (int)v;
|
v+=c;
|
||||||
}
|
}
|
||||||
|
if (sign) return -(int) v;
|
||||||
__int64 myatoi64(char *s)
|
return (int)v;
|
||||||
{
|
}
|
||||||
__int64 v=0;
|
|
||||||
int sign=0;
|
__int64 myatoi64(char *s)
|
||||||
|
{
|
||||||
if (*s == '-')
|
__int64 v=0;
|
||||||
sign++;
|
int sign=0;
|
||||||
else
|
|
||||||
s--;
|
if (*s == '-')
|
||||||
|
sign++;
|
||||||
for (;;)
|
else
|
||||||
{
|
s--;
|
||||||
int c=*(++s) - '0';
|
|
||||||
if (c < 0 || c > 9) break;
|
for (;;)
|
||||||
v*=10;
|
{
|
||||||
v+=c;
|
int c=*(++s) - '0';
|
||||||
}
|
if (c < 0 || c > 9) break;
|
||||||
|
v*=10;
|
||||||
if (sign)
|
v+=c;
|
||||||
v = -v;
|
}
|
||||||
|
|
||||||
return v;
|
if (sign)
|
||||||
}
|
v = -v;
|
||||||
|
|
||||||
void myitoa64(__int64 i, char *buffer)
|
return v;
|
||||||
{
|
}
|
||||||
char buf[128], *b = buf;
|
|
||||||
|
void myitoa64(__int64 i, char *buffer)
|
||||||
if (i < 0)
|
{
|
||||||
{
|
char buf[128], *b = buf;
|
||||||
*(buffer++) = '-';
|
|
||||||
i = -i;
|
if (i < 0)
|
||||||
}
|
{
|
||||||
if (i == 0) *(buffer++) = '0';
|
*(buffer++) = '-';
|
||||||
else
|
i = -i;
|
||||||
{
|
}
|
||||||
while (i > 0)
|
if (i == 0) *(buffer++) = '0';
|
||||||
{
|
else
|
||||||
*(b++) = '0' + ((char) (i%10));
|
{
|
||||||
i /= 10;
|
while (i > 0)
|
||||||
}
|
{
|
||||||
while (b > buf) *(buffer++) = *(--b);
|
*(b++) = '0' + ((char) (i%10));
|
||||||
}
|
i /= 10;
|
||||||
*buffer = 0;
|
}
|
||||||
}
|
while (b > buf) *(buffer++) = *(--b);
|
||||||
|
}
|
||||||
void mini_memset(void *o,char i,int l)
|
*buffer = 0;
|
||||||
{
|
}
|
||||||
char *oo=(char*)o;
|
|
||||||
while (l-- > 0) *oo++=i;
|
void mini_memset(void *o,char i,int l)
|
||||||
}
|
{
|
||||||
void mini_memcpy(void *o,void*i,int l)
|
char *oo=(char*)o;
|
||||||
{
|
while (l-- > 0) *oo++=i;
|
||||||
char *oo=(char*)o;
|
}
|
||||||
char *ii=(char*)i;
|
void mini_memcpy(void *o,void*i,int l)
|
||||||
while (l-- > 0) *oo++=*ii++;
|
{
|
||||||
}
|
char *oo=(char*)o;
|
||||||
|
char *ii=(char*)i;
|
||||||
|
while (l-- > 0) *oo++=*ii++;
|
||||||
|
}
|
||||||
|
|
|
@ -1,36 +1,38 @@
|
||||||
/*
|
/*
|
||||||
** JNetLib
|
** JNetLib
|
||||||
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
** Copyright (C) 2000-2001 Nullsoft, Inc.
|
||||||
** Author: Justin Frankel
|
** Author: Justin Frankel
|
||||||
** File: util.h - JNL interface for basic network utilities
|
** File: util.h - JNL interface for basic network utilities
|
||||||
** License: see jnetlib.h
|
** License: see jnetlib.h
|
||||||
**
|
**
|
||||||
** routines you may be interested in:
|
** routines you may be interested in:
|
||||||
** JNL::open_socketlib();
|
** JNL::open_socketlib();
|
||||||
** opens the socket library. Call this once before using any network
|
** opens the socket library. Call this once before using any network
|
||||||
** code. If you create a new thread, call this again. Only really an
|
** code. If you create a new thread, call this again. Only really an
|
||||||
** issue for Win32 support, but use it anyway for portability/
|
** issue for Win32 support, but use it anyway for portability/
|
||||||
**
|
**
|
||||||
** JNL::close_Socketlib();
|
** JNL::close_Socketlib();
|
||||||
** closes the socketlib. Call this when you're done with the network,
|
** closes the socketlib. Call this when you're done with the network,
|
||||||
** after all your JNetLib objects have been destroyed.
|
** after all your JNetLib objects have been destroyed.
|
||||||
**
|
**
|
||||||
** unsigned long JNL::ipstr_to_addr(const char *cp);
|
** unsigned long JNL::ipstr_to_addr(const char *cp);
|
||||||
** gives you the integer representation of a ip address in dotted
|
** gives you the integer representation of a ip address in dotted
|
||||||
** decimal form.
|
** decimal form.
|
||||||
**
|
**
|
||||||
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
|
** JNL::addr_to_ipstr(unsigned long addr, char *host, int maxhostlen);
|
||||||
** gives you the dotted decimal notation of an integer ip address.
|
** gives you the dotted decimal notation of an integer ip address.
|
||||||
**
|
**
|
||||||
*/
|
** Reviewed for Unicode support by Jim Park -- 08/24/2007
|
||||||
|
** Keep the functions here strictly ANSI.
|
||||||
#ifndef _UTIL_H_
|
*/
|
||||||
#define _UTIL_H_
|
|
||||||
|
#ifndef _UTIL_H_
|
||||||
int my_atoi(char *p);
|
#define _UTIL_H_
|
||||||
__int64 myatoi64(char *s);
|
|
||||||
void myitoa64(__int64 i, char *buffer);
|
int my_atoi(char *p);
|
||||||
void mini_memset(void *,char,int);
|
__int64 myatoi64(char *s);
|
||||||
void mini_memcpy(void *,void*,int);
|
void myitoa64(__int64 i, char *buffer);
|
||||||
|
void mini_memset(void *,char,int);
|
||||||
#endif //_UTIL_H_
|
void mini_memcpy(void *,void*,int);
|
||||||
|
|
||||||
|
#endif //_UTIL_H_
|
||||||
|
|
|
@ -13,7 +13,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
{
|
{
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
RECT vp;
|
RECT vp;
|
||||||
GetObject(g_hbm, sizeof(bm), (LPSTR)&bm);
|
GetObject(g_hbm, sizeof(bm), (LPTSTR)&bm);
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &vp, 0);
|
||||||
SetWindowLong(hwnd,GWL_STYLE,0);
|
SetWindowLong(hwnd,GWL_STYLE,0);
|
||||||
SetWindowPos(hwnd,NULL,
|
SetWindowPos(hwnd,NULL,
|
||||||
|
@ -55,11 +55,11 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
void __declspec(dllexport) show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
char fn[MAX_PATH];
|
TCHAR fn[MAX_PATH];
|
||||||
char temp[64];
|
TCHAR temp[64];
|
||||||
char *sleep=temp;
|
TCHAR *sleep=temp;
|
||||||
|
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
@ -68,16 +68,16 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable
|
||||||
popstring(fn);
|
popstring(fn);
|
||||||
|
|
||||||
sleep_val=0;
|
sleep_val=0;
|
||||||
while (*sleep >= '0' && *sleep <= '9')
|
while (*sleep >= _T('0') && *sleep <= _T('9'))
|
||||||
{
|
{
|
||||||
sleep_val*=10;
|
sleep_val*=10;
|
||||||
sleep_val+=*sleep++-'0';
|
sleep_val+=*sleep++-_T('0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fn[0] && sleep_val>0)
|
if (fn[0] && sleep_val>0)
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
char classname[4]="_sp";
|
TCHAR classname[4]=_T("_sp");
|
||||||
static WNDCLASS wc;
|
static WNDCLASS wc;
|
||||||
wc.lpfnWndProc = WndProc;
|
wc.lpfnWndProc = WndProc;
|
||||||
wc.hInstance = g_hInstance;
|
wc.hInstance = g_hInstance;
|
||||||
|
@ -85,10 +85,10 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable
|
||||||
wc.lpszClassName = classname;
|
wc.lpszClassName = classname;
|
||||||
if (RegisterClass(&wc))
|
if (RegisterClass(&wc))
|
||||||
{
|
{
|
||||||
char fn2[MAX_PATH];
|
TCHAR fn2[MAX_PATH];
|
||||||
lstrcpy(fn2,fn);
|
lstrcpy(fn2,fn);
|
||||||
lstrcat(fn,".bmp");
|
lstrcat(fn,_T(".bmp"));
|
||||||
lstrcat(fn2,".wav");
|
lstrcat(fn2,_T(".wav"));
|
||||||
g_hbm=LoadImage(NULL,fn,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
|
g_hbm=LoadImage(NULL,fn,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
|
||||||
if (g_hbm)
|
if (g_hbm)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +114,6 @@ void __declspec(dllexport) show(HWND hwndParent, int string_size, char *variable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wsprintf(temp,"%d",g_rv);
|
wsprintf(temp,_T("%d"),g_rv);
|
||||||
pushstring(temp);
|
pushstring(temp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@ HWND hwChild;
|
||||||
HWND g_hwStartMenuSelect;
|
HWND g_hwStartMenuSelect;
|
||||||
HWND g_hwDirList;
|
HWND g_hwDirList;
|
||||||
|
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
char text[1024];
|
TCHAR text[1024];
|
||||||
char progname[1024];
|
TCHAR progname[1024];
|
||||||
char lastused[1024];
|
TCHAR lastused[1024];
|
||||||
char checkbox[1024];
|
TCHAR checkbox[1024];
|
||||||
|
|
||||||
int autoadd;
|
int autoadd;
|
||||||
int g_done;
|
int g_done;
|
||||||
|
@ -23,7 +23,7 @@ int rtl;
|
||||||
|
|
||||||
void *lpWndProcOld;
|
void *lpWndProcOld;
|
||||||
|
|
||||||
void (__stdcall *validate_filename)(char *);
|
void (__stdcall *validate_filename)(TCHAR *);
|
||||||
|
|
||||||
BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
static BOOL CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static BOOL CALLBACK ParentWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
@ -34,7 +34,7 @@ static UINT_PTR PluginCallback(enum NSPIM msg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) Init(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) Init(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
HWND hwStartMenuSelect;
|
HWND hwStartMenuSelect;
|
||||||
|
|
||||||
|
@ -62,35 +62,35 @@ void __declspec(dllexport) Init(HWND hwndParent, int string_size, char *variable
|
||||||
hwChild = GetDlgItem(hwndParent, 1018);
|
hwChild = GetDlgItem(hwndParent, 1018);
|
||||||
if (!hwChild)
|
if (!hwChild)
|
||||||
{
|
{
|
||||||
pushstring("error finding childwnd");
|
pushstring(_T("error finding childwnd"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
popstring(buf);
|
popstring(buf);
|
||||||
|
|
||||||
while (buf[0] == '/')
|
while (buf[0] == _T('/'))
|
||||||
{
|
{
|
||||||
if (!lstrcmpi(buf+1, "noicon"))
|
if (!lstrcmpi(buf+1, _T("noicon")))
|
||||||
{
|
{
|
||||||
noicon = 1;
|
noicon = 1;
|
||||||
}
|
}
|
||||||
else if (!lstrcmpi(buf+1, "rtl"))
|
else if (!lstrcmpi(buf+1, _T("rtl")))
|
||||||
{
|
{
|
||||||
rtl = 1;
|
rtl = 1;
|
||||||
}
|
}
|
||||||
else if (!lstrcmpi(buf+1, "text"))
|
else if (!lstrcmpi(buf+1, _T("text")))
|
||||||
{
|
{
|
||||||
popstring(text);
|
popstring(text);
|
||||||
}
|
}
|
||||||
else if (!lstrcmpi(buf+1, "autoadd"))
|
else if (!lstrcmpi(buf+1, _T("autoadd")))
|
||||||
{
|
{
|
||||||
autoadd = 1;
|
autoadd = 1;
|
||||||
}
|
}
|
||||||
else if (!lstrcmpi(buf+1, "lastused"))
|
else if (!lstrcmpi(buf+1, _T("lastused")))
|
||||||
{
|
{
|
||||||
popstring(lastused);
|
popstring(lastused);
|
||||||
}
|
}
|
||||||
else if (!lstrcmpi(buf+1, "checknoshortcuts"))
|
else if (!lstrcmpi(buf+1, _T("checknoshortcuts")))
|
||||||
{
|
{
|
||||||
popstring(checkbox);
|
popstring(checkbox);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ void __declspec(dllexport) Init(HWND hwndParent, int string_size, char *variable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring("error reading parameters");
|
pushstring(_T("error reading parameters"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,19 +115,19 @@ void __declspec(dllexport) Init(HWND hwndParent, int string_size, char *variable
|
||||||
g_hwStartMenuSelect = hwStartMenuSelect;
|
g_hwStartMenuSelect = hwStartMenuSelect;
|
||||||
if (!hwStartMenuSelect)
|
if (!hwStartMenuSelect)
|
||||||
{
|
{
|
||||||
pushstring("error creating dialog");
|
pushstring(_T("error creating dialog"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lpWndProcOld = (void *) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentWndProc);
|
lpWndProcOld = (void *) SetWindowLong(hwndParent, DWL_DLGPROC, (long) ParentWndProc);
|
||||||
wsprintf(buf, "%u", hwStartMenuSelect);
|
wsprintf(buf, _T("%u"), hwStartMenuSelect);
|
||||||
pushstring(buf);
|
pushstring(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) Show(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
|
void __declspec(dllexport) Show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
HWND hwStartMenuSelect = g_hwStartMenuSelect;
|
HWND hwStartMenuSelect = g_hwStartMenuSelect;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ void __declspec(dllexport) Show(HWND hwndParent, int string_size, char *variable
|
||||||
SetWindowLong(hwndParent, DWL_DLGPROC, (long) lpWndProcOld);
|
SetWindowLong(hwndParent, DWL_DLGPROC, (long) lpWndProcOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) Select(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) Select(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
Init(hwndParent, string_size, variables, stacktop, extra);
|
Init(hwndParent, string_size, variables, stacktop, extra);
|
||||||
if (g_hwStartMenuSelect)
|
if (g_hwStartMenuSelect)
|
||||||
|
@ -312,7 +312,7 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowText(hwText, *text ? text : "Select the Start Menu folder in which you would like to create the program's shortcuts:");
|
SetWindowText(hwText, *text ? text : _T("Select the Start Menu folder in which you would like to create the program's shortcuts:"));
|
||||||
|
|
||||||
ProgressiveSetWindowPos(
|
ProgressiveSetWindowPos(
|
||||||
hwLocation,
|
hwLocation,
|
||||||
|
@ -321,7 +321,7 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
MulDiv(12, baseUnitY, 8)
|
MulDiv(12, baseUnitY, 8)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (*lastused == '>')
|
if (*lastused == _T('>'))
|
||||||
{
|
{
|
||||||
CheckDlgButton(hwndDlg, IDC_CHECK, BST_CHECKED);
|
CheckDlgButton(hwndDlg, IDC_CHECK, BST_CHECKED);
|
||||||
lstrcpy(lastused, lstrcpy(buf, lastused) + 1);
|
lstrcpy(lastused, lstrcpy(buf, lastused) + 1);
|
||||||
|
@ -370,7 +370,7 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
SendMessage(hwDirList, LB_GETTEXT, SendMessage(hwDirList, LB_GETCURSEL, 0, 0), (WPARAM)buf);
|
SendMessage(hwDirList, LB_GETTEXT, SendMessage(hwDirList, LB_GETCURSEL, 0, 0), (WPARAM)buf);
|
||||||
if (autoadd)
|
if (autoadd)
|
||||||
lstrcat(lstrcat(buf, "\\"), progname);
|
lstrcat(lstrcat(buf, _T("\\")), progname);
|
||||||
SetWindowText(hwLocation, buf);
|
SetWindowText(hwLocation, buf);
|
||||||
}
|
}
|
||||||
else if (LOWORD(wParam) == IDC_CHECK && HIWORD(wParam) == BN_CLICKED)
|
else if (LOWORD(wParam) == IDC_CHECK && HIWORD(wParam) == BN_CLICKED)
|
||||||
|
@ -383,27 +383,27 @@ BOOL CALLBACK dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
GetWindowText(hwLocation, buf, MAX_PATH);
|
GetWindowText(hwLocation, buf, MAX_PATH);
|
||||||
validate_filename(buf);
|
validate_filename(buf);
|
||||||
EnableWindow(GetDlgItem(hwParent, IDOK), *buf != '\0');
|
EnableWindow(GetDlgItem(hwParent, IDOK), *buf != _T('\0'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_USER+666:
|
case WM_USER+666:
|
||||||
g_done = 1;
|
g_done = 1;
|
||||||
if (wParam == NOTIFY_BYE_BYE)
|
if (wParam == NOTIFY_BYE_BYE)
|
||||||
pushstring("cancel");
|
pushstring(_T("cancel"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetWindowText(hwLocation, buf + 1, MAX_PATH);
|
GetWindowText(hwLocation, buf + 1, MAX_PATH);
|
||||||
validate_filename(buf);
|
validate_filename(buf);
|
||||||
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK) == BST_CHECKED)
|
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK) == BST_CHECKED)
|
||||||
{
|
{
|
||||||
buf[0] = '>';
|
buf[0] = _T('>');
|
||||||
pushstring(buf);
|
pushstring(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring(buf + 1);
|
pushstring(buf + 1);
|
||||||
}
|
}
|
||||||
pushstring("success");
|
pushstring(_T("success"));
|
||||||
}
|
}
|
||||||
case WM_CTLCOLORSTATIC:
|
case WM_CTLCOLORSTATIC:
|
||||||
case WM_CTLCOLOREDIT:
|
case WM_CTLCOLOREDIT:
|
||||||
|
@ -440,7 +440,7 @@ void AddFolderFromReg(int nFolder)
|
||||||
if (!buf[0])
|
if (!buf[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lstrcat(buf, "\\*.*");
|
lstrcat(buf, _T("\\*.*"));
|
||||||
hSearch = FindFirstFile(buf, &FileData);
|
hSearch = FindFirstFile(buf, &FileData);
|
||||||
if (hSearch != INVALID_HANDLE_VALUE)
|
if (hSearch != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -448,9 +448,9 @@ void AddFolderFromReg(int nFolder)
|
||||||
{
|
{
|
||||||
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (*(WORD*)FileData.cFileName != *(WORD*)".")
|
if (*(WORD*)FileData.cFileName != *(WORD*)_T("."))
|
||||||
{
|
{
|
||||||
if (*(WORD*)FileData.cFileName != *(WORD*)".." || FileData.cFileName[2])
|
if (*(WORD*)FileData.cFileName != *(WORD*)_T("..") || FileData.cFileName[2])
|
||||||
{
|
{
|
||||||
if (SendMessage(g_hwDirList, LB_FINDSTRINGEXACT, (WPARAM) -1, (LPARAM)FileData.cFileName) == LB_ERR)
|
if (SendMessage(g_hwDirList, LB_FINDSTRINGEXACT, (WPARAM) -1, (LPARAM)FileData.cFileName) == LB_ERR)
|
||||||
SendMessage(g_hwDirList, LB_ADDSTRING, 0, (LPARAM)FileData.cFileName);
|
SendMessage(g_hwDirList, LB_ADDSTRING, 0, (LPARAM)FileData.cFileName);
|
||||||
|
|
|
@ -7,7 +7,7 @@ typedef struct tagTempStack TempStack;
|
||||||
struct tagTempStack
|
struct tagTempStack
|
||||||
{
|
{
|
||||||
TempStack *Next;
|
TempStack *Next;
|
||||||
char Data[0];
|
TCHAR Data[0];
|
||||||
};
|
};
|
||||||
TempStack *tempstack = NULL;
|
TempStack *tempstack = NULL;
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@ PLUGINFUNCTIONSHORT(Copy)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
HANDLE source, dest;
|
HANDLE source, dest;
|
||||||
char *str;
|
TCHAR *str;
|
||||||
// Get the string
|
// Get the string
|
||||||
if ((str = system_popstring()) == NULL) return;
|
if ((str = system_popstring()) == NULL) return;
|
||||||
|
|
||||||
// Check for size option
|
// Check for size option
|
||||||
if (str[0] == '/')
|
if (str[0] == _T('/'))
|
||||||
{
|
{
|
||||||
size = (int) myatoi64(str+1);
|
size = (int) myatoi64(str+1);
|
||||||
dest = (HANDLE) popint64();
|
dest = (HANDLE) popint64();
|
||||||
|
@ -65,15 +65,15 @@ PLUGINFUNCTIONEND
|
||||||
PLUGINFUNCTION(Store)
|
PLUGINFUNCTION(Store)
|
||||||
{
|
{
|
||||||
TempStack *tmp;
|
TempStack *tmp;
|
||||||
int size = ((INST_R9+1)*g_stringsize);
|
int size = ((INST_R9+1)*g_stringsize*sizeof(TCHAR));
|
||||||
|
|
||||||
char *command, *cmd = command = system_popstring();
|
TCHAR *command, *cmd = command = system_popstring();
|
||||||
while (*cmd != 0)
|
while (*cmd != 0)
|
||||||
{
|
{
|
||||||
switch (*(cmd++))
|
switch (*(cmd++))
|
||||||
{
|
{
|
||||||
case 's':
|
case _T('s'):
|
||||||
case 'S':
|
case _T('S'):
|
||||||
// Store the whole variables range
|
// Store the whole variables range
|
||||||
tmp = (TempStack*) GlobalAlloc(GPTR, sizeof(TempStack)+size);
|
tmp = (TempStack*) GlobalAlloc(GPTR, sizeof(TempStack)+size);
|
||||||
tmp->Next = tempstack;
|
tmp->Next = tempstack;
|
||||||
|
@ -82,8 +82,8 @@ PLUGINFUNCTION(Store)
|
||||||
// Fill with data
|
// Fill with data
|
||||||
copymem(tempstack->Data, g_variables, size);
|
copymem(tempstack->Data, g_variables, size);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case _T('l'):
|
||||||
case 'L':
|
case _T('L'):
|
||||||
if (tempstack == NULL) break;
|
if (tempstack == NULL) break;
|
||||||
|
|
||||||
// Fill with data
|
// Fill with data
|
||||||
|
@ -94,15 +94,15 @@ PLUGINFUNCTION(Store)
|
||||||
GlobalFree((HANDLE) tempstack);
|
GlobalFree((HANDLE) tempstack);
|
||||||
tempstack = tmp;
|
tempstack = tmp;
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case _T('P'):
|
||||||
*cmd += 10;
|
*cmd += 10;
|
||||||
case 'p':
|
case _T('p'):
|
||||||
GlobalFree((HANDLE) system_pushstring(system_getuservariable(*(cmd++)-'0')));
|
GlobalFree((HANDLE) system_pushstring(system_getuservariable(*(cmd++)-_T('0'))));
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case _T('R'):
|
||||||
*cmd += 10;
|
*cmd += 10;
|
||||||
case 'r':
|
case _T('r'):
|
||||||
GlobalFree((HANDLE) system_setuservariable(*(cmd++)-'0', system_popstring()));
|
GlobalFree((HANDLE) system_setuservariable(*(cmd++)-_T('0'), system_popstring()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/23/2007
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Plugin.h"
|
#include "Plugin.h"
|
||||||
#include "Buffers.h"
|
#include "Buffers.h"
|
||||||
|
@ -5,19 +7,19 @@
|
||||||
|
|
||||||
HWND g_hwndParent;
|
HWND g_hwndParent;
|
||||||
|
|
||||||
char *AllocString()
|
TCHAR *AllocString()
|
||||||
{
|
{
|
||||||
return (char*) GlobalAlloc(GPTR,g_stringsize);
|
return (TCHAR*) GlobalAlloc(GPTR,g_stringsize*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *AllocStr(char *str)
|
TCHAR *AllocStr(TCHAR *str)
|
||||||
{
|
{
|
||||||
return lstrcpy(AllocString(), str);
|
return lstrcpy(AllocString(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* system_popstring()
|
TCHAR* system_popstring()
|
||||||
{
|
{
|
||||||
char *str;
|
TCHAR *str;
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
|
|
||||||
if (!g_stacktop || !*g_stacktop) return NULL;
|
if (!g_stacktop || !*g_stacktop) return NULL;
|
||||||
|
@ -31,24 +33,24 @@ char* system_popstring()
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *system_pushstring(char *str)
|
TCHAR *system_pushstring(TCHAR *str)
|
||||||
{
|
{
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
if (!g_stacktop) return str;
|
if (!g_stacktop) return str;
|
||||||
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
|
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+(g_stringsize*sizeof(TCHAR)));
|
||||||
lstrcpyn(th->text,str,g_stringsize);
|
lstrcpyn(th->text,str,g_stringsize);
|
||||||
th->next=*g_stacktop;
|
th->next=*g_stacktop;
|
||||||
*g_stacktop=th;
|
*g_stacktop=th;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *system_getuservariable(int varnum)
|
TCHAR *system_getuservariable(int varnum)
|
||||||
{
|
{
|
||||||
if (varnum < 0 || varnum >= __INST_LAST) return AllocString();
|
if (varnum < 0 || varnum >= __INST_LAST) return AllocString();
|
||||||
return AllocStr(g_variables+varnum*g_stringsize);
|
return AllocStr(g_variables+varnum*g_stringsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *system_setuservariable(int varnum, char *var)
|
TCHAR *system_setuservariable(int varnum, TCHAR *var)
|
||||||
{
|
{
|
||||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST) {
|
if (var != NULL && varnum >= 0 && varnum < __INST_LAST) {
|
||||||
lstrcpy (g_variables + varnum*g_stringsize, var);
|
lstrcpy (g_variables + varnum*g_stringsize, var);
|
||||||
|
@ -57,31 +59,31 @@ char *system_setuservariable(int varnum, char *var)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updated for int64 and simple bitwise operations
|
// Updated for int64 and simple bitwise operations
|
||||||
__int64 myatoi64(char *s)
|
__int64 myatoi64(TCHAR *s)
|
||||||
{
|
{
|
||||||
__int64 v=0;
|
__int64 v=0;
|
||||||
// Check for right input
|
// Check for right input
|
||||||
if (!s) return 0;
|
if (!s) return 0;
|
||||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
|
||||||
{
|
{
|
||||||
s++;
|
s++;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||||
else break;
|
else break;
|
||||||
v<<=4;
|
v<<=4;
|
||||||
v+=c;
|
v+=c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s);
|
int c=*(++s);
|
||||||
if (c >= '0' && c <= '7') c-='0';
|
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
|
||||||
else break;
|
else break;
|
||||||
v<<=3;
|
v<<=3;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -90,10 +92,10 @@ __int64 myatoi64(char *s)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int sign=0;
|
int sign=0;
|
||||||
if (*s == '-') sign++; else s--;
|
if (*s == _T('-')) sign++; else s--;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int c=*(++s) - '0';
|
int c=*(++s) - _T('0');
|
||||||
if (c < 0 || c > 9) break;
|
if (c < 0 || c > 9) break;
|
||||||
v*=10;
|
v*=10;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -102,7 +104,7 @@ __int64 myatoi64(char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support for simple ORed expressions
|
// Support for simple ORed expressions
|
||||||
if (*s == '|')
|
if (*s == _T('|'))
|
||||||
{
|
{
|
||||||
v |= myatoi64(s+1);
|
v |= myatoi64(s+1);
|
||||||
}
|
}
|
||||||
|
@ -110,21 +112,21 @@ __int64 myatoi64(char *s)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void myitoa64(__int64 i, char *buffer)
|
void myitoa64(__int64 i, TCHAR *buffer)
|
||||||
{
|
{
|
||||||
char buf[128], *b = buf;
|
TCHAR buf[128], *b = buf;
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
*(buffer++) = '-';
|
*(buffer++) = _T('-');
|
||||||
i = -i;
|
i = -i;
|
||||||
}
|
}
|
||||||
if (i == 0) *(buffer++) = '0';
|
if (i == 0) *(buffer++) = _T('0');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (i > 0)
|
while (i > 0)
|
||||||
{
|
{
|
||||||
*(b++) = '0' + ((char) (i%10));
|
*(b++) = _T('0') + ((TCHAR) (i%10));
|
||||||
i /= 10;
|
i /= 10;
|
||||||
}
|
}
|
||||||
while (b > buf) *(buffer++) = *(--b);
|
while (b > buf) *(buffer++) = *(--b);
|
||||||
|
@ -135,7 +137,7 @@ void myitoa64(__int64 i, char *buffer)
|
||||||
int popint64()
|
int popint64()
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
char *str;
|
TCHAR *str;
|
||||||
if ((str = system_popstring()) == NULL) return -1;
|
if ((str = system_popstring()) == NULL) return -1;
|
||||||
value = (int) myatoi64(str);
|
value = (int) myatoi64(str);
|
||||||
GlobalFree(str);
|
GlobalFree(str);
|
||||||
|
@ -144,14 +146,14 @@ int popint64()
|
||||||
|
|
||||||
void system_pushint(int value)
|
void system_pushint(int value)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
TCHAR buffer[1024];
|
||||||
wsprintf(buffer, "%d", value);
|
wsprintf(buffer, _T("%d"), value);
|
||||||
system_pushstring(buffer);
|
system_pushstring(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *copymem(char *output, char *input, int size)
|
TCHAR *copymem(TCHAR *output, TCHAR *input, int size)
|
||||||
{
|
{
|
||||||
char *out = output;
|
TCHAR *out = output;
|
||||||
if ((input != NULL) && (output != NULL))
|
if ((input != NULL) && (output != NULL))
|
||||||
while (size-- > 0) *(out++) = *(input++);
|
while (size-- > 0) *(out++) = *(input++);
|
||||||
return output;
|
return output;
|
||||||
|
|
|
@ -5,29 +5,29 @@
|
||||||
|
|
||||||
#define PLUGINFUNCTION(name) \
|
#define PLUGINFUNCTION(name) \
|
||||||
void __declspec(dllexport) name( \
|
void __declspec(dllexport) name( \
|
||||||
HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra) { \
|
HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) { \
|
||||||
/*g_hwndParent=hwndParent;*/ \
|
/*g_hwndParent=hwndParent;*/ \
|
||||||
EXDLL_INIT(); \
|
EXDLL_INIT(); \
|
||||||
extra->RegisterPluginCallback(g_hInstance, NSISCallback);
|
extra->RegisterPluginCallback(g_hInstance, NSISCallback);
|
||||||
#define PLUGINFUNCTIONEND }
|
#define PLUGINFUNCTIONEND }
|
||||||
|
|
||||||
#define PLUGINFUNCTIONSHORT(name) void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) { \
|
#define PLUGINFUNCTIONSHORT(name) void __declspec(dllexport) name(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) { \
|
||||||
g_stringsize=string_size; \
|
g_stringsize=string_size; \
|
||||||
g_stacktop=stacktop;
|
g_stacktop=stacktop;
|
||||||
|
|
||||||
extern char *AllocStr(char *str);
|
extern TCHAR *AllocStr(TCHAR *str);
|
||||||
extern void myitoa64(__int64 i, char *buffer);
|
extern void myitoa64(__int64 i, TCHAR *buffer);
|
||||||
extern char *AllocString();
|
extern TCHAR *AllocString();
|
||||||
extern char *system_getuservariable(int varnum);
|
extern TCHAR *system_getuservariable(int varnum);
|
||||||
extern char *system_setuservariable(int varnum, char *var);
|
extern TCHAR *system_setuservariable(int varnum, TCHAR *var);
|
||||||
extern char* system_popstring(); // NULL - stack empty
|
extern TCHAR* system_popstring(); // NULL - stack empty
|
||||||
extern char* system_pushstring(char *str);
|
extern TCHAR* system_pushstring(TCHAR *str);
|
||||||
extern __int64 myatoi64(char *s);
|
extern __int64 myatoi64(TCHAR *s);
|
||||||
extern int popint64(); // -1 -> stack empty
|
extern int popint64(); // -1 -> stack empty
|
||||||
extern void system_pushint(int value);
|
extern void system_pushint(int value);
|
||||||
|
|
||||||
extern HANDLE GlobalCopy(HANDLE Old);
|
extern HANDLE GlobalCopy(HANDLE Old);
|
||||||
extern char *copymem(char *output, char *input, int size);
|
extern TCHAR *copymem(TCHAR *output, TCHAR *input, int size);
|
||||||
|
|
||||||
extern UINT_PTR NSISCallback(enum NSPIM);
|
extern UINT_PTR NSISCallback(enum NSPIM);
|
||||||
|
|
||||||
|
|
|
@ -45,15 +45,15 @@ int CallbackIndex;
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
|
|
||||||
// Return to callback caller with stack restore
|
// Return to callback caller with stack restore
|
||||||
char retexpr[4];
|
TCHAR retexpr[4];
|
||||||
HANDLE retaddr;
|
HANDLE retaddr;
|
||||||
|
|
||||||
char *GetResultStr(SystemProc *proc)
|
TCHAR *GetResultStr(SystemProc *proc)
|
||||||
{
|
{
|
||||||
char *buf = AllocString();
|
TCHAR *buf = AllocString();
|
||||||
if (proc->ProcResult == PR_OK) lstrcpy(buf, "ok");
|
if (proc->ProcResult == PR_OK) lstrcpy(buf, _T("ok"));
|
||||||
else if (proc->ProcResult == PR_ERROR) lstrcpy(buf, "error");
|
else if (proc->ProcResult == PR_ERROR) lstrcpy(buf, _T("error"));
|
||||||
else if (proc->ProcResult == PR_CALLBACK) wsprintf(buf, "callback%d", proc->CallbackIndex);
|
else if (proc->ProcResult == PR_CALLBACK) wsprintf(buf, _T("callback%d"), proc->CallbackIndex);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,16 +61,16 @@ char *GetResultStr(SystemProc *proc)
|
||||||
|
|
||||||
// System log debugging turned on
|
// System log debugging turned on
|
||||||
#define SYSTEM_LOG_ADD(a) { register int _len = lstrlen(syslogbuf); lstrcpyn(syslogbuf + _len, a, sizeof(syslogbuf) - _len); }
|
#define SYSTEM_LOG_ADD(a) { register int _len = lstrlen(syslogbuf); lstrcpyn(syslogbuf + _len, a, sizeof(syslogbuf) - _len); }
|
||||||
#define SYSTEM_LOG_POST { SYSTEM_LOG_ADD("\n"); WriteToLog(syslogbuf); *syslogbuf = 0; }
|
#define SYSTEM_LOG_POST { SYSTEM_LOG_ADD(_T("\n")); WriteToLog(syslogbuf); *syslogbuf = 0; }
|
||||||
|
|
||||||
HANDLE logfile = NULL;
|
HANDLE logfile = NULL;
|
||||||
char syslogbuf[4096] = "";
|
TCHAR syslogbuf[4096] = _T("");
|
||||||
int logop = 0;
|
int logop = 0;
|
||||||
|
|
||||||
void WriteToLog(char *buffer)
|
void WriteToLog(TCHAR *buffer)
|
||||||
{
|
{
|
||||||
DWORD written;
|
DWORD written;
|
||||||
char timebuffer[128];
|
TCHAR timebuffer[128];
|
||||||
|
|
||||||
GetTickCount();
|
GetTickCount();
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ void WriteToLog(char *buffer)
|
||||||
|
|
||||||
SetFilePointer(logfile, 0, 0, FILE_END);
|
SetFilePointer(logfile, 0, 0, FILE_END);
|
||||||
|
|
||||||
wsprintf(timebuffer, "%04d %04d.%03d ", (++logop)%10000, (GetTickCount() / 1000) % 10000,
|
wsprintf(timebuffer, _T("%04d %04d.%03d "), (++logop)%10000, (GetTickCount() / 1000) % 10000,
|
||||||
GetTickCount() % 1000);
|
GetTickCount() % 1000);
|
||||||
|
|
||||||
_RPT0(_CRT_WARN, timebuffer);
|
_RPT0(_CRT_WARN, timebuffer);
|
||||||
|
@ -91,14 +91,14 @@ void WriteToLog(char *buffer)
|
||||||
|
|
||||||
PLUGINFUNCTION(Debug)
|
PLUGINFUNCTION(Debug)
|
||||||
{
|
{
|
||||||
char *o1;
|
TCHAR *o1;
|
||||||
o1 = system_popstring();
|
o1 = system_popstring();
|
||||||
|
|
||||||
if (logfile == NULL)
|
if (logfile == NULL)
|
||||||
if (lstrlen(o1) > 0)
|
if (lstrlen(o1) > 0)
|
||||||
{
|
{
|
||||||
SYSTEMTIME t;
|
SYSTEMTIME t;
|
||||||
char buffer[1024], buftime[1024], bufdate[1024];
|
TCHAR buffer[1024], buftime[1024], bufdate[1024];
|
||||||
|
|
||||||
// Init debugging
|
// Init debugging
|
||||||
logfile = CreateFile(o1, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
logfile = CreateFile(o1, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
|
@ -110,7 +110,7 @@ PLUGINFUNCTION(Debug)
|
||||||
GetLocalTime(&t);
|
GetLocalTime(&t);
|
||||||
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, buftime, 1024);
|
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, buftime, 1024);
|
||||||
GetDateFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, bufdate, 1024);
|
GetDateFormat(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, &t, NULL, bufdate, 1024);
|
||||||
wsprintf(buffer, "System, %s %s [build "__TIME__" "__DATE__"]\n", buftime, bufdate);
|
wsprintf(buffer, _T("System, %s %s [build "__TIME__" ")__DATE___T("]\n"), buftime, bufdate);
|
||||||
WriteToLog(buffer);
|
WriteToLog(buffer);
|
||||||
} else ;
|
} else ;
|
||||||
else
|
else
|
||||||
|
@ -121,7 +121,7 @@ PLUGINFUNCTION(Debug)
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// Stop debugging
|
// Stop debugging
|
||||||
WriteToLog("Debug stopped.\n\n\n");
|
WriteToLog(_T("Debug stopped.\n\n\n"));
|
||||||
CloseHandle(logfile);
|
CloseHandle(logfile);
|
||||||
logfile = NULL;
|
logfile = NULL;
|
||||||
}
|
}
|
||||||
|
@ -141,15 +141,15 @@ PLUGINFUNCTION(Get)
|
||||||
SystemProc *proc = PrepareProc(FALSE);
|
SystemProc *proc = PrepareProc(FALSE);
|
||||||
if (proc == NULL)
|
if (proc == NULL)
|
||||||
{
|
{
|
||||||
system_pushstring("error");
|
system_pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTEM_LOG_ADD("Get ");
|
SYSTEM_LOG_ADD(_T("Get "));
|
||||||
SYSTEM_LOG_ADD(proc->DllName);
|
SYSTEM_LOG_ADD(proc->DllName);
|
||||||
SYSTEM_LOG_ADD("::");
|
SYSTEM_LOG_ADD(_T("::"));
|
||||||
SYSTEM_LOG_ADD(proc->ProcName);
|
SYSTEM_LOG_ADD(proc->ProcName);
|
||||||
SYSTEM_LOG_ADD("\n");
|
SYSTEM_LOG_ADD(_T("\n"));
|
||||||
SYSTEM_LOG_POST;
|
SYSTEM_LOG_POST;
|
||||||
if ((proc->Options & POPT_ALWRETURN) != 0)
|
if ((proc->Options & POPT_ALWRETURN) != 0)
|
||||||
{
|
{
|
||||||
|
@ -178,11 +178,11 @@ PLUGINFUNCTION(Call)
|
||||||
if (proc == NULL)
|
if (proc == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SYSTEM_LOG_ADD("Call ");
|
SYSTEM_LOG_ADD(_T("Call "));
|
||||||
SYSTEM_LOG_ADD(proc->DllName);
|
SYSTEM_LOG_ADD(proc->DllName);
|
||||||
SYSTEM_LOG_ADD("::");
|
SYSTEM_LOG_ADD(_T("::"));
|
||||||
SYSTEM_LOG_ADD(proc->ProcName);
|
SYSTEM_LOG_ADD(proc->ProcName);
|
||||||
SYSTEM_LOG_ADD("\n");
|
SYSTEM_LOG_ADD(_T("\n"));
|
||||||
if (proc->ProcResult != PR_CALLBACK)
|
if (proc->ProcResult != PR_CALLBACK)
|
||||||
ParamAllocate(proc);
|
ParamAllocate(proc);
|
||||||
ParamsIn(proc);
|
ParamsIn(proc);
|
||||||
|
@ -253,13 +253,13 @@ PLUGINFUNCTION(Call)
|
||||||
PLUGINFUNCTIONSHORT(Int64Op)
|
PLUGINFUNCTIONSHORT(Int64Op)
|
||||||
{
|
{
|
||||||
__int64 i1, i2 = 0, i3, i4;
|
__int64 i1, i2 = 0, i3, i4;
|
||||||
char *op, *o1, *o2;
|
TCHAR *op, *o1, *o2;
|
||||||
char buf[128];
|
TCHAR buf[128];
|
||||||
|
|
||||||
// Get strings
|
// Get strings
|
||||||
o1 = system_popstring(); op = system_popstring();
|
o1 = system_popstring(); op = system_popstring();
|
||||||
i1 = myatoi64(o1); // convert first arg to int64
|
i1 = myatoi64(o1); // convert first arg to int64
|
||||||
if ((*op != '~') && (*op != '!'))
|
if ((*op != _T('~')) && (*op != _T('!')))
|
||||||
{
|
{
|
||||||
// get second arg, convert it, free it
|
// get second arg, convert it, free it
|
||||||
o2 = system_popstring();
|
o2 = system_popstring();
|
||||||
|
@ -270,25 +270,25 @@ PLUGINFUNCTIONSHORT(Int64Op)
|
||||||
// operation
|
// operation
|
||||||
switch (*op)
|
switch (*op)
|
||||||
{
|
{
|
||||||
case '+': i1 += i2; break;
|
case _T('+'): i1 += i2; break;
|
||||||
case '-': i1 -= i2; break;
|
case _T('-'): i1 -= i2; break;
|
||||||
case '*': i1 *= i2; break;
|
case _T('*'): i1 *= i2; break;
|
||||||
case '/':
|
case _T('/'):
|
||||||
case '%':
|
case _T('%'):
|
||||||
// It's unclear, but in this case compiler will use DivMod rountine
|
// It's unclear, but in this case compiler will use DivMod rountine
|
||||||
// instead of two separate Div and Mod rountines.
|
// instead of two separate Div and Mod rountines.
|
||||||
if (i2 == 0) { i3 = 0; i4 = i1; }
|
if (i2 == 0) { i3 = 0; i4 = i1; }
|
||||||
else {i3 = i1 / i2; i4 = i1 % i2; }
|
else {i3 = i1 / i2; i4 = i1 % i2; }
|
||||||
if (*op == '/') i1 = i3; else i1 = i4;
|
if (*op == _T('/')) i1 = i3; else i1 = i4;
|
||||||
break;
|
break;
|
||||||
case '|': if (op[1] == '|') i1 = i1 || i2; else i1 |= i2; break;
|
case _T('|'): if (op[1] == _T('|')) i1 = i1 || i2; else i1 |= i2; break;
|
||||||
case '&': if (op[1] == '&') i1 = i1 && i2; else i1 &= i2; break;
|
case _T('&'): if (op[1] == _T('&')) i1 = i1 && i2; else i1 &= i2; break;
|
||||||
case '^': i1 ^= i2; break;
|
case _T('^'): i1 ^= i2; break;
|
||||||
case '~': i1 = ~i1; break;
|
case _T('~'): i1 = ~i1; break;
|
||||||
case '!': i1 = !i1; break;
|
case _T('!'): i1 = !i1; break;
|
||||||
case '<': if (op[1] == '<') i1 = i1 << i2; else i1 = i1 < i2; break;
|
case _T('<'): if (op[1] == _T('<')) i1 = i1 << i2; else i1 = i1 < i2; break;
|
||||||
case '>': if (op[1] == '>') i1 = i1 >> i2; else i1 = i1 > i2; break;
|
case _T('>'): if (op[1] == _T('>')) i1 = i1 >> i2; else i1 = i1 > i2; break;
|
||||||
case '=': i1 = (i1 == i2); break;
|
case _T('='): i1 = (i1 == i2); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output and freedom
|
// Output and freedom
|
||||||
|
@ -297,11 +297,11 @@ PLUGINFUNCTIONSHORT(Int64Op)
|
||||||
GlobalFree(o1); GlobalFree(op);
|
GlobalFree(o1); GlobalFree(op);
|
||||||
} PLUGINFUNCTIONEND
|
} PLUGINFUNCTIONEND
|
||||||
|
|
||||||
__int64 GetIntFromString(char **p)
|
__int64 GetIntFromString(TCHAR **p)
|
||||||
{
|
{
|
||||||
char buffer[128], *b = buffer;
|
TCHAR buffer[128], *b = buffer;
|
||||||
(*p)++; // First character should be skipped
|
(*p)++; // First character should be skipped
|
||||||
while (((**p >= 'a') && (**p <= 'f')) || ((**p >= 'A') && (**p <= 'F')) || ((**p >= '0') && (**p <= '9')) || (**p == 'X') || (**p == '-') || (**p == 'x') || (**p == '|')) *(b++) = *((*p)++);
|
while (((**p >= _T('a')) && (**p <= _T('f'))) || ((**p >= _T('A')) && (**p <= _T('F'))) || ((**p >= _T('0')) && (**p <= _T('9'))) || (**p == _T('X')) || (**p == _T('-')) || (**p == _T('x')) || (**p == _T('|'))) *(b++) = *((*p)++);
|
||||||
*b = 0;
|
*b = 0;
|
||||||
(*p)--; // We should point at last digit
|
(*p)--; // We should point at last digit
|
||||||
return myatoi64(buffer);
|
return myatoi64(buffer);
|
||||||
|
@ -316,7 +316,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
temp = 0, temp2, temp3, temp4;
|
temp = 0, temp2, temp3, temp4;
|
||||||
BOOL param_defined = FALSE;
|
BOOL param_defined = FALSE;
|
||||||
SystemProc *proc = NULL;
|
SystemProc *proc = NULL;
|
||||||
char *ibuf, *ib, *sbuf, *cbuf, *cb;
|
TCHAR *ibuf, *ib, *sbuf, *cbuf, *cb;
|
||||||
|
|
||||||
// Retrieve proc specs
|
// Retrieve proc specs
|
||||||
cb = (cbuf = AllocString()); // Current String buffer
|
cb = (cbuf = AllocString()); // Current String buffer
|
||||||
|
@ -339,16 +339,16 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
switch (*ib)
|
switch (*ib)
|
||||||
{
|
{
|
||||||
case 0x0: SectionType = -1; break;
|
case 0x0: SectionType = -1; break;
|
||||||
case '#': SectionType = PST_PROC; ProcType = PT_NOTHING; break;
|
case _T('#'): SectionType = PST_PROC; ProcType = PT_NOTHING; break;
|
||||||
case '(':
|
case _T('('):
|
||||||
SectionType = PST_PARAMS;
|
SectionType = PST_PARAMS;
|
||||||
// fake-real parameter: for COM interfaces first param is Interface Pointer
|
// fake-real parameter: for COM interfaces first param is Interface Pointer
|
||||||
ParamIndex = ((ProcType == PT_VTABLEPROC)?(2):(1));
|
ParamIndex = ((ProcType == PT_VTABLEPROC)?(2):(1));
|
||||||
temp3 = temp = 0;
|
temp3 = temp = 0;
|
||||||
param_defined = FALSE;
|
param_defined = FALSE;
|
||||||
break;
|
break;
|
||||||
case ')': SectionType = PST_RETURN; temp3 = temp = 0; break;
|
case _T(')'): SectionType = PST_RETURN; temp3 = temp = 0; break;
|
||||||
case '?': SectionType = PST_OPTIONS; temp = 1; break;
|
case _T('?'): SectionType = PST_OPTIONS; temp = 1; break;
|
||||||
default:
|
default:
|
||||||
changed = FALSE;
|
changed = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -437,18 +437,18 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
case PST_PROC:
|
case PST_PROC:
|
||||||
switch (*ib)
|
switch (*ib)
|
||||||
{
|
{
|
||||||
case ':':
|
case _T(':'):
|
||||||
case '-':
|
case _T('-'):
|
||||||
// Is it '::'
|
// Is it '::'
|
||||||
if ((*(ib) == '-') && (*(ib+1) == '>'))
|
if ((*(ib) == _T('-')) && (*(ib+1) == _T('>')))
|
||||||
{
|
{
|
||||||
ProcType = PT_VTABLEPROC;
|
ProcType = PT_VTABLEPROC;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if ((*(ib+1) != ':') || (*(ib) == '-')) break;
|
if ((*(ib+1) != _T(':')) || (*(ib) == _T('-'))) break;
|
||||||
ProcType = PT_PROC;
|
ProcType = PT_PROC;
|
||||||
}
|
}
|
||||||
ib++; // Skip next ':'
|
ib++; // Skip next _T(':')
|
||||||
|
|
||||||
if (cb > cbuf)
|
if (cb > cbuf)
|
||||||
{
|
{
|
||||||
|
@ -459,7 +459,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
// Ok
|
// Ok
|
||||||
ChangesDone = PCD_DONE;
|
ChangesDone = PCD_DONE;
|
||||||
break;
|
break;
|
||||||
case '*':
|
case _T('*'):
|
||||||
// Structure defenition
|
// Structure defenition
|
||||||
ProcType = PT_STRUCT;
|
ProcType = PT_STRUCT;
|
||||||
ChangesDone = PCD_DONE;
|
ChangesDone = PCD_DONE;
|
||||||
|
@ -474,9 +474,9 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
temp2 = -1; temp4 = 0; // Our type placeholder
|
temp2 = -1; temp4 = 0; // Our type placeholder
|
||||||
switch (*ib)
|
switch (*ib)
|
||||||
{
|
{
|
||||||
case ' ':
|
case _T(' '):
|
||||||
break;
|
break;
|
||||||
case '_': // No param cutting specifier
|
case _T('_'): // No param cutting specifier
|
||||||
if (proc->ParamCount > ParamIndex) ParamIndex = proc->ParamCount;
|
if (proc->ParamCount > ParamIndex) ParamIndex = proc->ParamCount;
|
||||||
temp3 = temp = 0; // Clear parameter options
|
temp3 = temp = 0; // Clear parameter options
|
||||||
if (proc->ParamCount != ((ProcType == PT_VTABLEPROC) ? 1 : 0))
|
if (proc->ParamCount != ((ProcType == PT_VTABLEPROC) ? 1 : 0))
|
||||||
|
@ -488,59 +488,59 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
param_defined = TRUE;
|
param_defined = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ',': // Next param
|
case _T(','): // Next param
|
||||||
temp3 = temp = 0; // Clear parameter options
|
temp3 = temp = 0; // Clear parameter options
|
||||||
ParamIndex++;
|
ParamIndex++;
|
||||||
param_defined = TRUE;
|
param_defined = TRUE;
|
||||||
break;
|
break;
|
||||||
case '&':
|
case _T('&'):
|
||||||
temp = 1; break; // Special parameter option
|
temp = 1; break; // Special parameter option
|
||||||
case '*':
|
case _T('*'):
|
||||||
temp = -1; break; // Pointer parameter option
|
temp = -1; break; // Pointer parameter option
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
case 'v':
|
case _T('v'):
|
||||||
case 'V': temp2 = PAT_VOID; break;
|
case _T('V'): temp2 = PAT_VOID; break;
|
||||||
case 'i':
|
case _T('i'):
|
||||||
case 'I': temp2 = PAT_INT; break;
|
case _T('I'): temp2 = PAT_INT; break;
|
||||||
case 'l':
|
case _T('l'):
|
||||||
case 'L': temp2 = PAT_LONG; break;
|
case _T('L'): temp2 = PAT_LONG; break;
|
||||||
case 'm':
|
case _T('m'):
|
||||||
case 'M':
|
case _T('M'):
|
||||||
case 't':
|
case _T('t'):
|
||||||
case 'T': temp2 = PAT_STRING; break;
|
case _T('T'): temp2 = PAT_STRING; break;
|
||||||
case 'g':
|
case _T('g'):
|
||||||
case 'G': temp2 = PAT_GUID; break;
|
case _T('G'): temp2 = PAT_GUID; break;
|
||||||
case 'w':
|
case _T('w'):
|
||||||
case 'W': temp2 = PAT_WSTRING; break;
|
case _T('W'): temp2 = PAT_WSTRING; break;
|
||||||
case 'k':
|
case _T('k'):
|
||||||
case 'K': temp2 = PAT_CALLBACK; break;
|
case _T('K'): temp2 = PAT_CALLBACK; break;
|
||||||
|
|
||||||
// Input output specifiers
|
// Input output specifiers
|
||||||
case '.': temp3++; break; // skip specifier
|
case _T('.'): temp3++; break; // skip specifier
|
||||||
|
|
||||||
case 'R':
|
case _T('R'):
|
||||||
temp4 = ((int) GetIntFromString(&ib))+1;
|
temp4 = ((int) GetIntFromString(&ib))+1;
|
||||||
if (temp4 < 11) temp4 += 10;
|
if (temp4 < 11) temp4 += 10;
|
||||||
break;
|
break;
|
||||||
case 'r': temp4 = ((int) GetIntFromString(&ib))+1; break; // Register
|
case _T('r'): temp4 = ((int) GetIntFromString(&ib))+1; break; // Register
|
||||||
|
|
||||||
case '-':
|
case _T('-'):
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case _T('5'): case _T('6'): case _T('7'): case _T('8'): case _T('9'):
|
||||||
// Numeric inline
|
// Numeric inline
|
||||||
if (temp3 == 0)
|
if (temp3 == 0)
|
||||||
{
|
{
|
||||||
ib--;
|
ib--;
|
||||||
// It's stupid, I know, but I'm too laze to do another thing
|
// It's stupid, I know, but I'm too laze to do another thing
|
||||||
myitoa64(GetIntFromString(&(ib)),(char *)(temp4 = (int) AllocString()));
|
myitoa64(GetIntFromString(&(ib)),(TCHAR *)(temp4 = (int) AllocString()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\"': case '\'': case '`':
|
case _T('\"'): case _T('\''): case _T('`'):
|
||||||
// Character inline
|
// Character inline
|
||||||
{
|
{
|
||||||
char start = *ib;
|
TCHAR start = *ib;
|
||||||
cb = cbuf;
|
cb = cbuf;
|
||||||
// copy inline
|
// copy inline
|
||||||
while (!((*(++ib) == start) && (*(ib+1) != start)) && (*ib))
|
while (!((*(++ib) == start) && (*(ib+1) != start)) && (*ib))
|
||||||
|
@ -554,18 +554,18 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case _T('s'):
|
||||||
case 'S': temp4 = -1; break; // Stack
|
case _T('S'): temp4 = -1; break; // Stack
|
||||||
case 'c':
|
case _T('c'):
|
||||||
case 'C': temp4 = INST_CMDLINE+1; break;
|
case _T('C'): temp4 = INST_CMDLINE+1; break;
|
||||||
case 'd':
|
case _T('d'):
|
||||||
case 'D': temp4 = INST_INSTDIR+1; break;
|
case _T('D'): temp4 = INST_INSTDIR+1; break;
|
||||||
case 'o':
|
case _T('o'):
|
||||||
case 'O': temp4 = INST_OUTDIR+1; break;
|
case _T('O'): temp4 = INST_OUTDIR+1; break;
|
||||||
case 'e':
|
case _T('e'):
|
||||||
case 'E': temp4 = INST_EXEDIR+1; break;
|
case _T('E'): temp4 = INST_EXEDIR+1; break;
|
||||||
case 'a':
|
case _T('a'):
|
||||||
case 'A': temp4 = INST_LANG+1; break;
|
case _T('A'): temp4 = INST_LANG+1; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Param type changed?
|
// Param type changed?
|
||||||
|
@ -608,25 +608,25 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
temp2 = 0;
|
temp2 = 0;
|
||||||
switch (*ib)
|
switch (*ib)
|
||||||
{
|
{
|
||||||
case ' ':
|
case _T(' '):
|
||||||
break;
|
break;
|
||||||
case '!': temp = -temp; break;
|
case _T('!'): temp = -temp; break;
|
||||||
case 'c':
|
case _T('c'):
|
||||||
temp2 = POPT_CDECL;
|
temp2 = POPT_CDECL;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case _T('r'):
|
||||||
temp2 = POPT_ALWRETURN;
|
temp2 = POPT_ALWRETURN;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case _T('n'):
|
||||||
temp2 = POPT_NEVERREDEF;
|
temp2 = POPT_NEVERREDEF;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case _T('s'):
|
||||||
temp2 = POPT_GENSTACK;
|
temp2 = POPT_GENSTACK;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case _T('e'):
|
||||||
temp2 = POPT_ERROR;
|
temp2 = POPT_ERROR;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case _T('u'):
|
||||||
temp2 = POPT_UNLOAD;
|
temp2 = POPT_UNLOAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ SystemProc *PrepareProc(BOOL NeedForCall)
|
||||||
if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL)
|
if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL)
|
||||||
{
|
{
|
||||||
// automatic A discover
|
// automatic A discover
|
||||||
lstrcat(proc->ProcName, "A");
|
lstrcat(proc->ProcName, _T("A"));
|
||||||
if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL)
|
if ((proc->Proc = GetProcAddress(proc->Dll, proc->ProcName)) == NULL)
|
||||||
proc->ProcResult = PR_ERROR;
|
proc->ProcResult = PR_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -742,7 +742,7 @@ void ParamAllocate(SystemProc *proc)
|
||||||
void ParamsIn(SystemProc *proc)
|
void ParamsIn(SystemProc *proc)
|
||||||
{
|
{
|
||||||
int i, *place;
|
int i, *place;
|
||||||
char *realbuf;
|
TCHAR *realbuf;
|
||||||
LPWSTR wstr;
|
LPWSTR wstr;
|
||||||
|
|
||||||
i = (proc->ParamCount > 0)?(1):(0);
|
i = (proc->ParamCount > 0)?(1):(0);
|
||||||
|
@ -751,14 +751,14 @@ void ParamsIn(SystemProc *proc)
|
||||||
ProcParameter *par = &proc->Params[i];
|
ProcParameter *par = &proc->Params[i];
|
||||||
// Step 1: retrive value
|
// Step 1: retrive value
|
||||||
if ((par->Input == IOT_NONE) || (par->Input == IOT_INLINE))
|
if ((par->Input == IOT_NONE) || (par->Input == IOT_INLINE))
|
||||||
realbuf = AllocStr("");
|
realbuf = AllocStr(_T(""));
|
||||||
else if (par->Input == IOT_STACK) realbuf = system_popstring();
|
else if (par->Input == IOT_STACK) realbuf = system_popstring();
|
||||||
else if ((par->Input > 0) && (par->Input <= __INST_LAST))
|
else if ((par->Input > 0) && (par->Input <= __INST_LAST))
|
||||||
realbuf = system_getuservariable(par->Input - 1);
|
realbuf = system_getuservariable(par->Input - 1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Inline input, will be freed as realbuf
|
// Inline input, will be freed as realbuf
|
||||||
realbuf = (char*) par->Input;
|
realbuf = (TCHAR*) par->Input;
|
||||||
par->Input = IOT_INLINE;
|
par->Input = IOT_INLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,8 +809,8 @@ void ParamsIn(SystemProc *proc)
|
||||||
|
|
||||||
#ifdef SYSTEM_LOG_DEBUG
|
#ifdef SYSTEM_LOG_DEBUG
|
||||||
{
|
{
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
wsprintf(buf, "\t\t\tParam In %d: type %d value 0x%08X value2 0x%08X\n", i,
|
wsprintf(buf, _T("\t\t\tParam In %d: type %d value 0x%08X value2 0x%08X\n"), i,
|
||||||
par->Type, par->Value, par->_value);
|
par->Type, par->Value, par->_value);
|
||||||
SYSTEM_LOG_ADD(buf);
|
SYSTEM_LOG_ADD(buf);
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,7 @@ void ParamsDeAllocate(SystemProc *proc)
|
||||||
void ParamsOut(SystemProc *proc)
|
void ParamsOut(SystemProc *proc)
|
||||||
{
|
{
|
||||||
int i, *place;
|
int i, *place;
|
||||||
char *realbuf;
|
TCHAR *realbuf;
|
||||||
LPWSTR wstr;
|
LPWSTR wstr;
|
||||||
|
|
||||||
i = proc->ParamCount;
|
i = proc->ParamCount;
|
||||||
|
@ -853,19 +853,19 @@ void ParamsOut(SystemProc *proc)
|
||||||
switch (proc->Params[i].Type)
|
switch (proc->Params[i].Type)
|
||||||
{
|
{
|
||||||
case PAT_VOID:
|
case PAT_VOID:
|
||||||
lstrcpy(realbuf,"");
|
lstrcpy(realbuf,_T(""));
|
||||||
break;
|
break;
|
||||||
case PAT_INT:
|
case PAT_INT:
|
||||||
wsprintf(realbuf, "%d", *((int*) place));
|
wsprintf(realbuf, _T("%d"), *((int*) place));
|
||||||
break;
|
break;
|
||||||
case PAT_LONG:
|
case PAT_LONG:
|
||||||
myitoa64(*((__int64*) place), realbuf);
|
myitoa64(*((__int64*) place), realbuf);
|
||||||
break;
|
break;
|
||||||
case PAT_STRING:
|
case PAT_STRING:
|
||||||
{
|
{
|
||||||
unsigned num = lstrlen(*((char**) place));
|
unsigned num = lstrlen(*((TCHAR**) place));
|
||||||
if (num >= g_stringsize) num = g_stringsize-1;
|
if (num >= g_stringsize) num = g_stringsize-1;
|
||||||
lstrcpyn(realbuf,*((char**) place), num+1);
|
lstrcpyn(realbuf,*((TCHAR**) place), num+1);
|
||||||
realbuf[num] = 0;
|
realbuf[num] = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -880,7 +880,7 @@ void ParamsOut(SystemProc *proc)
|
||||||
WideCharToMultiByte(CP_ACP, 0, wstr, g_stringsize, realbuf, g_stringsize, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, wstr, g_stringsize, realbuf, g_stringsize, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
case PAT_CALLBACK:
|
case PAT_CALLBACK:
|
||||||
wsprintf(realbuf, "%d", proc->Params[i].Value);
|
wsprintf(realbuf, _T("%d"), proc->Params[i].Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ void ParamsOut(SystemProc *proc)
|
||||||
|
|
||||||
HANDLE CreateCallback(SystemProc *cbproc)
|
HANDLE CreateCallback(SystemProc *cbproc)
|
||||||
{
|
{
|
||||||
char *mem;
|
TCHAR *mem;
|
||||||
|
|
||||||
if (cbproc->Proc == NULL)
|
if (cbproc->Proc == NULL)
|
||||||
{
|
{
|
||||||
|
@ -911,11 +911,11 @@ HANDLE CreateCallback(SystemProc *cbproc)
|
||||||
cbproc->CallbackIndex = ++(CallbackIndex);
|
cbproc->CallbackIndex = ++(CallbackIndex);
|
||||||
cbproc->Options |= POPT_PERMANENT;
|
cbproc->Options |= POPT_PERMANENT;
|
||||||
|
|
||||||
mem = (char *) (cbproc->Proc = VirtualAlloc(NULL, 10, MEM_COMMIT, PAGE_EXECUTE_READWRITE));
|
mem = (TCHAR *) (cbproc->Proc = VirtualAlloc(NULL, 10, MEM_COMMIT, PAGE_EXECUTE_READWRITE));
|
||||||
*(mem++) = (char) 0xB8; // Mov eax, const
|
*(mem++) = (TCHAR) 0xB8; // Mov eax, const
|
||||||
*((int *)mem) = (int) cbproc;
|
*((int *)mem) = (int) cbproc;
|
||||||
mem += sizeof(int);
|
mem += sizeof(int);
|
||||||
*(mem++) = (char) 0xe9; // Jmp relative
|
*(mem++) = (TCHAR) 0xe9; // Jmp relative
|
||||||
*((int *)mem) = (int) RealCallBack;
|
*((int *)mem) = (int) RealCallBack;
|
||||||
*((int *)mem) -= ((int) mem) + 4;
|
*((int *)mem) -= ((int) mem) + 4;
|
||||||
}
|
}
|
||||||
|
@ -928,9 +928,9 @@ void CallStruct(SystemProc *proc)
|
||||||
{
|
{
|
||||||
BOOL ssflag;
|
BOOL ssflag;
|
||||||
int i, structsize = 0, size = 0;
|
int i, structsize = 0, size = 0;
|
||||||
char *st, *ptr;
|
TCHAR *st, *ptr;
|
||||||
|
|
||||||
SYSTEM_LOG_ADD("\t\tStruct...");
|
SYSTEM_LOG_ADD(_T("\t\tStruct..."));
|
||||||
|
|
||||||
// Calculate the structure size
|
// Calculate the structure size
|
||||||
for (i = 1; i <= proc->ParamCount; i++)
|
for (i = 1; i <= proc->ParamCount; i++)
|
||||||
|
@ -947,7 +947,7 @@ void CallStruct(SystemProc *proc)
|
||||||
if (structsize == 0) structsize = (int) GlobalSize((HANDLE) proc->Proc);
|
if (structsize == 0) structsize = (int) GlobalSize((HANDLE) proc->Proc);
|
||||||
|
|
||||||
// Pointer to current data
|
// Pointer to current data
|
||||||
st = (char*) proc->Proc;
|
st = (TCHAR*) proc->Proc;
|
||||||
|
|
||||||
for (i = 1; i <= proc->ParamCount; i++)
|
for (i = 1; i <= proc->ParamCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -958,7 +958,7 @@ void CallStruct(SystemProc *proc)
|
||||||
{
|
{
|
||||||
// Normal
|
// Normal
|
||||||
size = proc->Params[i].Size*4;
|
size = proc->Params[i].Size*4;
|
||||||
ptr = (char*) &(proc->Params[i].Value);
|
ptr = (TCHAR*) &(proc->Params[i].Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -979,13 +979,13 @@ void CallStruct(SystemProc *proc)
|
||||||
// clear unused value bits
|
// clear unused value bits
|
||||||
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];
|
proc->Params[i].Value &= intmask[((size >= 0) && (size < 4))?(size):(0)];
|
||||||
// pointer
|
// pointer
|
||||||
ptr = (char*) &(proc->Params[i].Value);
|
ptr = (TCHAR*) &(proc->Params[i].Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PAT_STRING:
|
case PAT_STRING:
|
||||||
case PAT_GUID:
|
case PAT_GUID:
|
||||||
case PAT_WSTRING:
|
case PAT_WSTRING:
|
||||||
ptr = (char*) proc->Params[i].Value; break;
|
ptr = (TCHAR*) proc->Params[i].Value; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,7 +1037,7 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
||||||
LastError = 0;
|
LastError = 0;
|
||||||
LastProc = NULL;
|
LastProc = NULL;
|
||||||
CallbackIndex = 0;
|
CallbackIndex = 0;
|
||||||
retexpr[0] = (char) 0xC2;
|
retexpr[0] = (TCHAR) 0xC2;
|
||||||
retexpr[2] = 0x00;
|
retexpr[2] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1158,7 +1158,7 @@ unsigned int Get_valueOffsetParam(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sets "CLONE" option
|
Sets _T("CLONE") option
|
||||||
*/
|
*/
|
||||||
void SetCloneOption(SystemProc *proc)
|
void SetCloneOption(SystemProc *proc)
|
||||||
{
|
{
|
||||||
|
@ -1166,7 +1166,7 @@ void SetCloneOption(SystemProc *proc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sets Result of procedure call to be "OK"
|
Sets Result of procedure call to be _T("OK")
|
||||||
*/
|
*/
|
||||||
void SetProcResultOk(SystemProc *proc)
|
void SetProcResultOk(SystemProc *proc)
|
||||||
{
|
{
|
||||||
|
@ -1174,7 +1174,7 @@ void SetProcResultOk(SystemProc *proc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sets Result of procedure call to be "CALLBACK"
|
Sets Result of procedure call to be _T("CALLBACK")
|
||||||
*/
|
*/
|
||||||
void SetProcResultCallback(SystemProc *proc)
|
void SetProcResultCallback(SystemProc *proc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,8 @@ struct tag_SystemProc
|
||||||
{
|
{
|
||||||
int ProcType;
|
int ProcType;
|
||||||
int ProcResult;
|
int ProcResult;
|
||||||
char DllName[1024];
|
TCHAR DllName[1024];
|
||||||
char ProcName[1024];
|
TCHAR ProcName[1024];
|
||||||
HANDLE Dll;
|
HANDLE Dll;
|
||||||
HANDLE Proc;
|
HANDLE Proc;
|
||||||
int Options;
|
int Options;
|
||||||
|
|
|
@ -109,6 +109,7 @@
|
||||||
; UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);
|
; UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);
|
||||||
!define sysSetTimer "user32::SetTimer(i, i, i, k) i"
|
!define sysSetTimer "user32::SetTimer(i, i, i, k) i"
|
||||||
|
|
||||||
|
; DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR LpBuffer);
|
||||||
!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStringsA(i, i) i'
|
!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStringsA(i, i) i'
|
||||||
|
|
||||||
!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i'
|
!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceExA(t, *l, *l, *l) i'
|
||||||
|
|
|
@ -8,7 +8,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
|
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
|
||||||
LTEXT "",IDC_INTROTEXT,25,0,241,23
|
LTEXT "",IDC_INTROTEXT,25,0,241,23
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,24,266,105
|
WS_TABSTOP | 0x804,0,24,266,105
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ FONT 8, "MS Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
|
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
|
||||||
LTEXT "",IDC_INTROTEXT,25,0,241,23
|
LTEXT "",IDC_INTROTEXT,25,0,241,23
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,24,266,85
|
WS_TABSTOP | 0x804,0,24,266,85
|
||||||
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
|
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
|
||||||
WS_TABSTOP,0,110,266,9
|
WS_TABSTOP,0,110,266,9
|
||||||
|
@ -32,7 +32,7 @@ FONT 8, "MS Shell Dlg"
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
|
ICON IDI_ICON2,IDC_ULICON,0,0,22,20
|
||||||
LTEXT "",IDC_INTROTEXT,25,0,241,23
|
LTEXT "",IDC_INTROTEXT,25,0,241,23
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,24,266,95
|
WS_TABSTOP | 0x804,0,24,266,95
|
||||||
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
|
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
|
||||||
WS_TABSTOP,0,120,266,9
|
WS_TABSTOP,0,120,266,9
|
||||||
|
|
|
@ -7,7 +7,7 @@ STYLE DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CAPTION
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "",1040,0,0,300,15,NOT WS_GROUP
|
LTEXT "",1040,0,0,300,15,NOT WS_GROUP
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,15,300,93
|
WS_TABSTOP | 0x804,0,15,300,93
|
||||||
LTEXT "",IDC_INTROTEXT,0,113,300,26,NOT WS_GROUP
|
LTEXT "",IDC_INTROTEXT,0,113,300,26,NOT WS_GROUP
|
||||||
END
|
END
|
||||||
|
@ -98,7 +98,7 @@ STYLE DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CAPTION
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "",1040,0,0,300,15,NOT WS_GROUP
|
LTEXT "",1040,0,0,300,15,NOT WS_GROUP
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,15,300,73
|
WS_TABSTOP | 0x804,0,15,300,73
|
||||||
LTEXT "",IDC_INTROTEXT,0,93,300,26,NOT WS_GROUP
|
LTEXT "",IDC_INTROTEXT,0,93,300,26,NOT WS_GROUP
|
||||||
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
|
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
|
||||||
|
@ -112,7 +112,7 @@ STYLE DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CAPTION
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "",1040,0,0,300,15,NOT WS_GROUP
|
LTEXT "",1040,0,0,300,15,NOT WS_GROUP
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,15,300,83
|
WS_TABSTOP | 0x804,0,15,300,83
|
||||||
LTEXT "",IDC_INTROTEXT,0,103,300,26,NOT WS_GROUP
|
LTEXT "",IDC_INTROTEXT,0,103,300,26,NOT WS_GROUP
|
||||||
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
|
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <richedit.h>
|
||||||
|
|
||||||
#ifndef IDC_STATIC
|
#ifndef IDC_STATIC
|
||||||
#define IDC_STATIC (-1)
|
#define IDC_STATIC (-1)
|
||||||
|
|
|
@ -8,7 +8,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON 103,IDC_ULICON,0,0,20,20
|
ICON 103,IDC_ULICON,0,0,20,20
|
||||||
LTEXT "",IDC_INTROTEXT,25,0,241,23,NOT WS_GROUP
|
LTEXT "",IDC_INTROTEXT,25,0,241,23,NOT WS_GROUP
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,24,266,47
|
WS_TABSTOP | 0x804,0,24,266,47
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON 103,IDC_ULICON,0,0,20,20
|
ICON 103,IDC_ULICON,0,0,20,20
|
||||||
LTEXT "",IDC_INTROTEXT,25,0,241,23,NOT WS_GROUP
|
LTEXT "",IDC_INTROTEXT,25,0,241,23,NOT WS_GROUP
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,24,266,27
|
WS_TABSTOP | 0x804,0,24,266,27
|
||||||
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
|
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTORADIOBUTTON |
|
||||||
WS_TABSTOP,0,50,266,9
|
WS_TABSTOP,0,50,266,9
|
||||||
|
@ -105,7 +105,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON 103,IDC_ULICON,0,0,20,20
|
ICON 103,IDC_ULICON,0,0,20,20
|
||||||
LTEXT "",IDC_INTROTEXT,25,0,241,23,NOT WS_GROUP
|
LTEXT "",IDC_INTROTEXT,25,0,241,23,NOT WS_GROUP
|
||||||
CONTROL "",IDC_EDIT1,"RichEdit20A",WS_BORDER | WS_VSCROLL |
|
CONTROL "",IDC_EDIT1,RICHEDIT_CLASS,WS_BORDER | WS_VSCROLL |
|
||||||
WS_TABSTOP | 0x804,0,24,266,37
|
WS_TABSTOP | 0x804,0,24,266,37
|
||||||
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
|
CONTROL "",IDC_LICENSEAGREE,"Button",BS_AUTOCHECKBOX |
|
||||||
WS_TABSTOP,0,60,266,9
|
WS_TABSTOP,0,60,266,9
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
// ui.cpp : Defines the entry point for the application.
|
// ui.cpp : Defines the entry point for the application.
|
||||||
//
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/10/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include "../ExDLL/nsis_tchar.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
HWND m_curwnd;
|
HWND m_curwnd;
|
||||||
|
|
||||||
char* windows[] = {
|
TCHAR* windows[] = {
|
||||||
MAKEINTRESOURCE(IDD_LICENSE),
|
MAKEINTRESOURCE(IDD_LICENSE),
|
||||||
MAKEINTRESOURCE(IDD_SELCOM),
|
MAKEINTRESOURCE(IDD_SELCOM),
|
||||||
MAKEINTRESOURCE(IDD_DIR),
|
MAKEINTRESOURCE(IDD_DIR),
|
||||||
|
@ -34,11 +36,11 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
|
||||||
static int i = -1;
|
static int i = -1;
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
SetWindowText(hwndDlg, "NSIS User Interface - Testing");
|
SetWindowText(hwndDlg, _T("NSIS User Interface - Testing"));
|
||||||
SetWindowText(GetDlgItem(hwndDlg, IDC_VERSTR), "NSIS version");
|
SetWindowText(GetDlgItem(hwndDlg, IDC_VERSTR), _T("NSIS version"));
|
||||||
SetWindowText(GetDlgItem(hwndDlg, IDC_BACK), "< Back");
|
SetWindowText(GetDlgItem(hwndDlg, IDC_BACK), _T("< Back"));
|
||||||
SetWindowText(GetDlgItem(hwndDlg, IDOK), "Next >");
|
SetWindowText(GetDlgItem(hwndDlg, IDOK), _T("Next >"));
|
||||||
SetWindowText(GetDlgItem(hwndDlg, IDCANCEL), "Cancel");
|
SetWindowText(GetDlgItem(hwndDlg, IDCANCEL), _T("Cancel"));
|
||||||
ShowWindow(GetDlgItem(hwndDlg, IDC_BACK), SW_SHOW);
|
ShowWindow(GetDlgItem(hwndDlg, IDC_BACK), SW_SHOW);
|
||||||
ShowWindow(GetDlgItem(hwndDlg, IDC_CHILDRECT), SW_SHOW);
|
ShowWindow(GetDlgItem(hwndDlg, IDC_CHILDRECT), SW_SHOW);
|
||||||
SendMessage(hwndDlg, WM_COMMAND, MAKEWORD(IDOK, 0), 0);
|
SendMessage(hwndDlg, WM_COMMAND, MAKEWORD(IDOK, 0), 0);
|
||||||
|
@ -53,7 +55,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i >= (int)sizeof(windows)/sizeof(char*)) {
|
if (i >= (int)sizeof(windows)/sizeof(TCHAR*)) {
|
||||||
i--;
|
i--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -78,14 +80,14 @@ BOOL CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
LPSTR lpCmdLine,
|
LPTSTR lpCmdLine,
|
||||||
int nCmdShow)
|
int nCmdShow)
|
||||||
{
|
{
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
LoadLibrary("RichEd32.dll");
|
LoadLibrary(_T("RichEd32.dll"));
|
||||||
|
|
||||||
g_hInstance = GetModuleHandle(0);
|
g_hInstance = GetModuleHandle(0);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
// Unicode support by Jim Park -- 08/23/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
typedef BOOL (WINAPI*CHECKTOKENMEMBERSHIP)(HANDLE TokenHandle,PSID SidToCheck,PBOOL IsMember);
|
typedef BOOL (WINAPI*CHECKTOKENMEMBERSHIP)(HANDLE TokenHandle,PSID SidToCheck,PBOOL IsMember);
|
||||||
CHECKTOKENMEMBERSHIP _CheckTokenMembership=NULL;
|
CHECKTOKENMEMBERSHIP _CheckTokenMembership=NULL;
|
||||||
|
|
||||||
void __declspec(dllexport) GetName(HWND hwndParent, int string_size,
|
void __declspec(dllexport) GetName(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
|
@ -12,35 +14,35 @@ void __declspec(dllexport) GetName(HWND hwndParent, int string_size,
|
||||||
DWORD dwStringSize = g_stringsize;
|
DWORD dwStringSize = g_stringsize;
|
||||||
stack_t *th;
|
stack_t *th;
|
||||||
if (!g_stacktop) return;
|
if (!g_stacktop) return;
|
||||||
th = (stack_t*) GlobalAlloc(GPTR, sizeof(stack_t) + g_stringsize);
|
th = (stack_t*) GlobalAlloc(GPTR, sizeof(stack_t) + g_stringsize*sizeof(TCHAR));
|
||||||
GetUserName(th->text, &dwStringSize);
|
GetUserName(th->text, &dwStringSize);
|
||||||
th->next = *g_stacktop;
|
th->next = *g_stacktop;
|
||||||
*g_stacktop = th;
|
*g_stacktop = th;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
|
TCHAR* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
|
||||||
{
|
{
|
||||||
char *group = NULL;
|
TCHAR *group = NULL;
|
||||||
HANDLE hToken = NULL;
|
HANDLE hToken = NULL;
|
||||||
struct group
|
struct group
|
||||||
{
|
{
|
||||||
DWORD auth_id;
|
DWORD auth_id;
|
||||||
char *name;
|
TCHAR *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct group groups[] =
|
struct group groups[] =
|
||||||
{
|
{
|
||||||
{DOMAIN_ALIAS_RID_USERS, "User"},
|
{DOMAIN_ALIAS_RID_USERS, _T("User")},
|
||||||
// every user belongs to the users group, hence users come before guests
|
// every user belongs to the users group, hence users come before guests
|
||||||
{DOMAIN_ALIAS_RID_GUESTS, "Guest"},
|
{DOMAIN_ALIAS_RID_GUESTS, _T("Guest")},
|
||||||
{DOMAIN_ALIAS_RID_POWER_USERS, "Power"},
|
{DOMAIN_ALIAS_RID_POWER_USERS, _T("Power")},
|
||||||
{DOMAIN_ALIAS_RID_ADMINS, "Admin"}
|
{DOMAIN_ALIAS_RID_ADMINS, _T("Admin")}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GetVersion() & 0x80000000) // Not NT
|
if (GetVersion() & 0x80000000) // Not NT
|
||||||
{
|
{
|
||||||
return "Admin";
|
return _T("Admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
// First we must open a handle to the access token for this thread.
|
// First we must open a handle to the access token for this thread.
|
||||||
|
@ -58,7 +60,7 @@ char* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
|
||||||
// GetUserName is in advapi32.dll so we can avoid Load/Freelibrary
|
// GetUserName is in advapi32.dll so we can avoid Load/Freelibrary
|
||||||
_CheckTokenMembership=
|
_CheckTokenMembership=
|
||||||
(CHECKTOKENMEMBERSHIP) GetProcAddress(
|
(CHECKTOKENMEMBERSHIP) GetProcAddress(
|
||||||
GetModuleHandle("ADVAPI32"), "CheckTokenMembership");
|
GetModuleHandle(_T("ADVAPI32")), "CheckTokenMembership");
|
||||||
|
|
||||||
// Use "old school" membership check?
|
// Use "old school" membership check?
|
||||||
if (!CheckTokenForGroupDeny || _CheckTokenMembership == NULL)
|
if (!CheckTokenForGroupDeny || _CheckTokenMembership == NULL)
|
||||||
|
@ -121,18 +123,18 @@ char* GetAccountTypeHelper(BOOL CheckTokenForGroupDeny)
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return _T("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) GetAccountType(HWND hwndParent, int string_size,
|
void __declspec(dllexport) GetAccountType(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
pushstring(GetAccountTypeHelper(TRUE));
|
pushstring(GetAccountTypeHelper(TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) GetOriginalAccountType(HWND hwndParent, int string_size,
|
void __declspec(dllexport) GetOriginalAccountType(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
TCHAR *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
pushstring(GetAccountTypeHelper(FALSE));
|
pushstring(GetAccountTypeHelper(FALSE));
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#include "Checksums.h"
|
#include "Checksums.h"
|
||||||
|
|
||||||
|
@ -82,7 +84,8 @@ void streamMD5(bistream& data, md5_byte_t digest[16]) {
|
||||||
md5_finish(&state, digest);
|
md5_finish(&state, digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
TChecksum::TChecksum(std::string& fileName) : mode(MD5) {
|
// Jim Park: string -> tstring.
|
||||||
|
TChecksum::TChecksum(tstring& fileName) : mode(MD5) {
|
||||||
bifstream data;
|
bifstream data;
|
||||||
data.open(fileName.c_str(), ios::binary | ios::in);
|
data.open(fileName.c_str(), ios::binary | ios::in);
|
||||||
data.seekg(0, ios::beg);
|
data.seekg(0, ios::beg);
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(Checksums_H)
|
#if !defined(Checksums_H)
|
||||||
#define Checksums_H
|
#define Checksums_H
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "GlobalTypes.h"
|
#include "GlobalTypes.h"
|
||||||
|
#include "tchar.h"
|
||||||
|
|
||||||
typedef uint32_t crc32_t;
|
typedef uint32_t crc32_t;
|
||||||
|
|
||||||
|
@ -39,7 +42,7 @@
|
||||||
enum { CRC32, MD5 } mode;
|
enum { CRC32, MD5 } mode;
|
||||||
|
|
||||||
TChecksum() : mode(MD5) { }
|
TChecksum() : mode(MD5) { }
|
||||||
TChecksum(std::string& fileName);
|
TChecksum(tstring& fileName);
|
||||||
|
|
||||||
void loadMD5(md5_byte_t newdigest[16]);
|
void loadMD5(md5_byte_t newdigest[16]);
|
||||||
void loadCRC32(crc32_t newcrc);
|
void loadCRC32(crc32_t newcrc);
|
||||||
|
|
|
@ -22,9 +22,12 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
|
|
||||||
#include "ChunkedFile.h"
|
#include "ChunkedFile.h"
|
||||||
|
#include "tchar.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -32,15 +35,15 @@ using namespace std;
|
||||||
chunks(NULL) {
|
chunks(NULL) {
|
||||||
|
|
||||||
chunkCount = fSize / chunkSize;
|
chunkCount = fSize / chunkSize;
|
||||||
cout << "[ChunkedFile] Filesize of " << static_cast<unsigned int>(fSize) << " gives " << static_cast<unsigned int>(chunkCount) << " chunks.\n";
|
tout << _T("[ChunkedFile] Filesize of ") << static_cast<unsigned int>(fSize) << _T(" gives ") << static_cast<unsigned int>(chunkCount) << _T(" chunks.\n");
|
||||||
|
|
||||||
cout << "[ChunkedFile] Memory to be used by those chunks: " << sizeof(FileChunk) * chunkCount << " bytes...";
|
tout << _T("[ChunkedFile] Memory to be used by those chunks: ") << sizeof(FileChunk) * chunkCount << _T(" bytes...");
|
||||||
if(chunkCount == 0) {
|
if(chunkCount == 0) {
|
||||||
chunks = NULL;
|
chunks = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chunks = new FileChunk[chunkCount];
|
chunks = new FileChunk[chunkCount];
|
||||||
cout << " allocated.\n";
|
tout << _T(" allocated.\n");
|
||||||
|
|
||||||
unsigned char* data = new unsigned char[chunkSize];
|
unsigned char* data = new unsigned char[chunkSize];
|
||||||
for(TFileOffset i = 0; i < chunkCount; i++) {
|
for(TFileOffset i = 0; i < chunkCount; i++) {
|
||||||
|
@ -50,9 +53,9 @@ using namespace std;
|
||||||
}
|
}
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
cout << "[ChunkedFile] Sorting chunks... ";
|
tout << _T("[ChunkedFile] Sorting chunks... ");
|
||||||
std::sort(chunks,chunks + chunkCount);
|
std::sort(chunks,chunks + chunkCount);
|
||||||
cout << "done.\n";
|
tout << _T("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(ChunkedFile_H)
|
#if !defined(ChunkedFile_H)
|
||||||
#define ChunkedFile_H
|
#define ChunkedFile_H
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#include "FileFormat1.h"
|
#include "FileFormat1.h"
|
||||||
#include "GlobalTypes.h"
|
#include "GlobalTypes.h"
|
||||||
|
@ -126,7 +128,7 @@ namespace FileFormat1 {
|
||||||
TFileOffset endOffset = in.tellg();
|
TFileOffset endOffset = in.tellg();
|
||||||
if(sourceChecksum == *removeCRC) {
|
if(sourceChecksum == *removeCRC) {
|
||||||
if(existanceIsError) {
|
if(existanceIsError) {
|
||||||
throw "Source file with the exact same contents already exists in patch!\nUse /R option (replace) to replace it with this patch!";
|
throw _T("Source file with the exact same contents already exists in patch!\nUse /R option (replace) to replace it with this patch!");
|
||||||
}
|
}
|
||||||
fileCount--;
|
fileCount--;
|
||||||
} else {
|
} else {
|
||||||
|
@ -192,7 +194,7 @@ namespace FileFormat1 {
|
||||||
// calculate area inbetween this block and the next
|
// calculate area inbetween this block and the next
|
||||||
TFileOffset notFoundStart = current->targetOffset+current->size;
|
TFileOffset notFoundStart = current->targetOffset+current->size;
|
||||||
if(notFoundStart > next->targetOffset) {
|
if(notFoundStart > next->targetOffset) {
|
||||||
throw "makeBinaryPatch input problem: there was overlap";
|
throw _T("makeBinaryPatch input problem: there was overlap");
|
||||||
}
|
}
|
||||||
TFileOffset notFoundSize = next->targetOffset - notFoundStart;
|
TFileOffset notFoundSize = next->targetOffset - notFoundStart;
|
||||||
if(notFoundSize > 0) {
|
if(notFoundSize > 0) {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(FileFormat1_H)
|
#if !defined(FileFormat1_H)
|
||||||
#define FileFormat1_H
|
#define FileFormat1_H
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
|
|
||||||
#include "GlobalTypes.h"
|
#include "GlobalTypes.h"
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(GlobalTypes_H)
|
#if !defined(GlobalTypes_H)
|
||||||
#define GlobalTypes_H
|
#define GlobalTypes_H
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
|
|
||||||
#include "POSIXUtil.h"
|
#include "POSIXUtil.h"
|
||||||
|
@ -54,13 +56,13 @@ namespace POSIX {
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
/* do it the old way on Win32, because POSIX does not get timezone stuff right */
|
/* do it the old way on Win32, because POSIX does not get timezone stuff right */
|
||||||
ALT_FILETIME getFileTime(const char* sFileName) {
|
ALT_FILETIME getFileTime(const TCHAR* sFileName) {
|
||||||
FILETIME temp;
|
FILETIME temp;
|
||||||
GetSystemTimeAsFileTime(&temp);
|
GetSystemTimeAsFileTime(&temp);
|
||||||
HANDLE h = CreateFile(sFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
HANDLE h = CreateFile(sFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
cerr << "Cannot read file time of " << sFileName << "\n";
|
terr << _T("Cannot read file time of ") << sFileName << _T("\n");
|
||||||
} else {
|
} else {
|
||||||
GetFileTime(h, NULL, NULL, &temp);
|
GetFileTime(h, NULL, NULL, &temp);
|
||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
|
@ -77,7 +79,7 @@ namespace POSIX {
|
||||||
time_t currentTime = time(NULL);
|
time_t currentTime = time(NULL);
|
||||||
|
|
||||||
if(stat(sFileName, &buf)) {
|
if(stat(sFileName, &buf)) {
|
||||||
cerr << "Cannot read file time of " << sFileName << "\n";
|
terr << _T("Cannot read file time of ") << sFileName << _T("\n");
|
||||||
} else {
|
} else {
|
||||||
/* get the time from the file */
|
/* get the time from the file */
|
||||||
currentTime = buf.st_mtime;
|
currentTime = buf.st_mtime;
|
||||||
|
@ -88,11 +90,11 @@ namespace POSIX {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t getFileSize(const char* sFileName) {
|
uint32_t getFileSize(const TCHAR* sFileName) {
|
||||||
std::ifstream f;
|
std::ifstream f;
|
||||||
f.open(sFileName, std::ios_base::binary | std::ios_base::in);
|
f.open(sFileName, std::ios_base::binary | std::ios_base::in);
|
||||||
if (!f.good() || f.eof() || !f.is_open()) {
|
if (!f.good() || f.eof() || !f.is_open()) {
|
||||||
throw "File could not be read (getFileSize)";
|
throw _T("File could not be read (getFileSize)");
|
||||||
}
|
}
|
||||||
f.seekg(0, std::ios_base::beg);
|
f.seekg(0, std::ios_base::beg);
|
||||||
std::ifstream::pos_type begin_pos = f.tellg();
|
std::ifstream::pos_type begin_pos = f.tellg();
|
||||||
|
@ -101,29 +103,29 @@ namespace POSIX {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
string getTempFile() {
|
tstring getTempFile() {
|
||||||
char buffer[MAX_PATH];
|
TCHAR buffer[MAX_PATH];
|
||||||
if(GetTempFileName(".","vpatch",0,buffer) == 0) {
|
if(GetTempFileName(_T("."),_T("vpatch"),0,buffer) == 0) {
|
||||||
cerr << "Cannot create temporary filename";
|
terr << _T("Cannot create temporary filename");
|
||||||
}
|
}
|
||||||
return string(buffer);
|
return tstring(buffer);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
string getTempFile() {
|
tstring getTempFile() {
|
||||||
char t[] = "/tmp/genpatXXXXXX";
|
TCHAR t[] = _T("/tmp/genpatXXXXXX");
|
||||||
|
|
||||||
mode_t old_umask = umask(0077);
|
mode_t old_umask = umask(0077);
|
||||||
|
|
||||||
int fd = mkstemp(t);
|
int fd = mkstemp(t);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
cerr << "Cannot create temporary filename";
|
terr << _T("Cannot create temporary filename");
|
||||||
return "";
|
return _T("");
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
umask(old_umask);
|
umask(old_umask);
|
||||||
|
|
||||||
return string(t);
|
return tstring(t);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,14 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(POSIXUtil_H)
|
#if !defined(POSIXUtil_H)
|
||||||
#define POSIXUtil_H
|
#define POSIXUtil_H
|
||||||
#include "GlobalTypes.h"
|
#include "GlobalTypes.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "tchar.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -36,9 +39,9 @@
|
||||||
uint32_t dwHighDateTime;
|
uint32_t dwHighDateTime;
|
||||||
} ALT_FILETIME;
|
} ALT_FILETIME;
|
||||||
|
|
||||||
ALT_FILETIME getFileTime(const char* sFileName);
|
ALT_FILETIME getFileTime(const TCHAR* sFileName);
|
||||||
uint32_t getFileSize(const char* sFileName);
|
uint32_t getFileSize(const TCHAR* sFileName);
|
||||||
string getTempFile();
|
tstring getTempFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // POSIXUtil_H
|
#endif // POSIXUtil_H
|
||||||
|
|
|
@ -22,7 +22,10 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
|
#include "tchar.h"
|
||||||
#include "PatchGenerator.h"
|
#include "PatchGenerator.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -85,12 +88,12 @@ void PatchGenerator::execute(vector<SameBlock*>& sameBlocks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to update the memory cache of target
|
// we need to update the memory cache of target
|
||||||
cout << "[CacheReload] File position = " << static_cast<unsigned int>(targetCDataBaseOffset) << "\n";
|
tout << _T("[CacheReload] File position = ") << static_cast<unsigned int>(targetCDataBaseOffset) << _T("\n");
|
||||||
|
|
||||||
target.seekg(targetCDataBaseOffset,ios::beg);
|
target.seekg(targetCDataBaseOffset,ios::beg);
|
||||||
target.read(reinterpret_cast<char*>(targetCData),targetCDataSize);
|
target.read(reinterpret_cast<char*>(targetCData),targetCDataSize);
|
||||||
}
|
}
|
||||||
//cout << currentOffset << " ";
|
//tout << currentOffset << _T(" ");
|
||||||
|
|
||||||
SameBlock* currentSameBlock = findBlock(sourceTree,currentOffset);
|
SameBlock* currentSameBlock = findBlock(sourceTree,currentOffset);
|
||||||
|
|
||||||
|
@ -108,9 +111,9 @@ void PatchGenerator::execute(vector<SameBlock*>& sameBlocks) {
|
||||||
|
|
||||||
// debug info
|
// debug info
|
||||||
if(beVerbose) {
|
if(beVerbose) {
|
||||||
cout << "Block found: " << static_cast<unsigned int>(currentSameBlock->targetOffset)
|
tout << _T("Block found: ") << static_cast<unsigned int>(currentSameBlock->targetOffset)
|
||||||
<< " " << static_cast<unsigned int>(currentSameBlock->size)
|
<< _T(" ") << static_cast<unsigned int>(currentSameBlock->size)
|
||||||
<< " (source offset=" << static_cast<unsigned int>(currentSameBlock->sourceOffset) << ")\n";
|
<< _T(" (source offset=") << static_cast<unsigned int>(currentSameBlock->sourceOffset) << _T(")\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentOffset = currentSameBlock->targetOffset + currentSameBlock->size;
|
currentOffset = currentSameBlock->targetOffset + currentSameBlock->size;
|
||||||
|
@ -172,8 +175,8 @@ SameBlock* PatchGenerator::findBlock(ChunkedFile* sourceTree,
|
||||||
if(beVerbose) {
|
if(beVerbose) {
|
||||||
if(maxMatches != 0) {
|
if(maxMatches != 0) {
|
||||||
if(matchCount == maxMatches) {
|
if(matchCount == maxMatches) {
|
||||||
cout << "[FindBlock] Abort due to >" << static_cast<unsigned int>(maxMatches)
|
tout << _T("[FindBlock] Abort due to >") << static_cast<unsigned int>(maxMatches)
|
||||||
<< " matches; file position = " << static_cast<unsigned int>(targetFileStartOffset) << "\n";
|
<< _T(" matches; file position = ") << static_cast<unsigned int>(targetFileStartOffset) << _T("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(PatchGenerator_H)
|
#if !defined(PatchGenerator_H)
|
||||||
#define PatchGenerator_H
|
#define PatchGenerator_H
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
(nothing changed.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "adler32.h"
|
#include "adler32.h"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Adler32
|
// Adler32
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#if !defined(Adler32_H)
|
#if !defined(Adler32_H)
|
||||||
#define Adler32_H
|
#define Adler32_H
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma argsused
|
#pragma argsused
|
||||||
|
@ -31,10 +33,12 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "tchar.h"
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#define OPT_CHAR '/'
|
#define OPT_CHAR _T('/')
|
||||||
#else
|
#else
|
||||||
#define OPT_CHAR '-'
|
#define OPT_CHAR _T('-')
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "GlobalTypes.h"
|
#include "GlobalTypes.h"
|
||||||
|
@ -46,14 +50,14 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
int main( int argc, char * argv[] ) {
|
int _tmain( int argc, TCHAR * argv[] ) {
|
||||||
cout << "GenPat v3.1\n";
|
tout << _T("GenPat v3.1\n");
|
||||||
cout << "===========\n\n(c) 2001-2005 Van de Sande Productions\n";
|
tout << _T("===========\n\n(c) 2001-2005 Van de Sande Productions\n");
|
||||||
cout << "Website: http://www.tibed.net/vpatch\n\n";
|
tout << _T("Website: http://www.tibed.net/vpatch\n\n");
|
||||||
|
|
||||||
string sourceFileName;
|
tstring sourceFileName;
|
||||||
string targetFileName;
|
tstring targetFileName;
|
||||||
string patchFileName;
|
tstring patchFileName;
|
||||||
|
|
||||||
bool showHelp = true;
|
bool showHelp = true;
|
||||||
|
|
||||||
|
@ -65,30 +69,30 @@ int main( int argc, char * argv[] ) {
|
||||||
int fileNameArgument = 0;
|
int fileNameArgument = 0;
|
||||||
if(argc > 1) {
|
if(argc > 1) {
|
||||||
for(int i = 1; i < argc; i++) {
|
for(int i = 1; i < argc; i++) {
|
||||||
string s(argv[i]);
|
tstring s(argv[i]);
|
||||||
if(s.size() > 0) {
|
if(s.size() > 0) {
|
||||||
if(s[0] == OPT_CHAR) {
|
if(s[0] == OPT_CHAR) {
|
||||||
if(s.size() > 1) {
|
if(s.size() > 1) {
|
||||||
if((s[1] == 'v') || (s[1] == 'V')) {
|
if((s[1] == _T('v')) || (s[1] == _T('V'))) {
|
||||||
beVerbose = true;
|
beVerbose = true;
|
||||||
}
|
}
|
||||||
if((s[1] == 'o') || (s[1] == 'O')) {
|
if((s[1] == _T('o')) || (s[1] == _T('O'))) {
|
||||||
beOptimal = true;
|
beOptimal = true;
|
||||||
}
|
}
|
||||||
if((s[1] == 'r') || (s[1] == 'R')) {
|
if((s[1] == _T('r')) || (s[1] == _T('R'))) {
|
||||||
existanceIsError = false;
|
existanceIsError = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(s.size() > 2) {
|
if(s.size() > 2) {
|
||||||
if((s[1] == 'b') || (s[1] == 'B')) {
|
if((s[1] == _T('b')) || (s[1] == _T('B'))) {
|
||||||
if(s[2] == '=') {
|
if(s[2] == _T('=')) {
|
||||||
istringstream ss(s.substr(3));
|
tistringstream ss(s.substr(3));
|
||||||
ss >> blockSize;
|
ss >> blockSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((s[1] == 'a') || (s[1] == 'A')) {
|
if((s[1] == _T('a')) || (s[1] == _T('A'))) {
|
||||||
if(s[2] == '=') {
|
if(s[2] == _T('=')) {
|
||||||
istringstream ss(s.substr(3));
|
tistringstream ss(s.substr(3));
|
||||||
ss >> maxMatches;
|
ss >> maxMatches;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +110,7 @@ int main( int argc, char * argv[] ) {
|
||||||
showHelp = false;
|
showHelp = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cerr << "WARNING: extra filename argument not used: " << s << "\n";
|
terr << _T("WARNING: extra filename argument not used: ") << s << _T("\n");
|
||||||
}
|
}
|
||||||
fileNameArgument++;
|
fileNameArgument++;
|
||||||
}
|
}
|
||||||
|
@ -117,45 +121,45 @@ int main( int argc, char * argv[] ) {
|
||||||
maxMatches = 0;
|
maxMatches = 0;
|
||||||
}
|
}
|
||||||
if(showHelp) {
|
if(showHelp) {
|
||||||
cout << "This program will take (sourcefile) as input and create a (patchfile).\n";
|
tout << _T("This program will take (sourcefile) as input and create a (patchfile).\n");
|
||||||
cout << "With this patchfile, you can convert a (sourcefile) into (targetfile).\n\n";
|
tout << _T("With this patchfile, you can convert a (sourcefile) into (targetfile).\n\n");
|
||||||
cout << "Command line info:\n";
|
tout << _T("Command line info:\n");
|
||||||
cout << " GENPAT (sourcefile) (targetfile) (patchfile)\n\n";
|
tout << _T(" GENPAT (sourcefile) (targetfile) (patchfile)\n\n");
|
||||||
|
|
||||||
cout << "Command line option (optional):\n";
|
tout << _T("Command line option (optional):\n");
|
||||||
cout << OPT_CHAR << "R Replace a patch with same contents as source silently if it\n already exists.\n";
|
tout << OPT_CHAR << _T("R Replace a patch with same contents as source silently if it\n already exists.\n");
|
||||||
cout << OPT_CHAR << "B=64 Set blocksize (default=64), multiple of 2 is required.\n";
|
tout << OPT_CHAR << _T("B=64 Set blocksize (default=64), multiple of 2 is required.\n");
|
||||||
cout << OPT_CHAR << "V More verbose information during patch creation.\n";
|
tout << OPT_CHAR << _T("V More verbose information during patch creation.\n");
|
||||||
cout << OPT_CHAR << "O Deactivate match limit of the " << OPT_CHAR << "A switch (sometimes smaller patches).\n";
|
tout << OPT_CHAR << _T("O Deactivate match limit of the ") << OPT_CHAR << _T("A switch (sometimes smaller patches).\n");
|
||||||
cout << OPT_CHAR << "A=500 Maximum number of block matches per block (improves performance).\n";
|
tout << OPT_CHAR << _T("A=500 Maximum number of block matches per block (improves performance).\n");
|
||||||
cout << " Default is 500, larger is slower. Use " << OPT_CHAR << "V to see the cut-off aborts.\n\n";
|
tout << _T(" Default is 500, larger is slower. Use ") << OPT_CHAR << _T("V to see the cut-off aborts.\n\n");
|
||||||
cout << "Note: filenames should never start with " << OPT_CHAR << " character!\n\n";
|
tout << _T("Note: filenames should never start with ") << OPT_CHAR << _T(" character!\n\n");
|
||||||
cout << "Possible exit codes:\n";
|
tout << _T("Possible exit codes:\n");
|
||||||
cout << " 0 Success\n";
|
tout << _T(" 0 Success\n");
|
||||||
cout << " 1 Arguments missing\n";
|
tout << _T(" 1 Arguments missing\n");
|
||||||
cout << " 2 Other error\n";
|
tout << _T(" 2 Other error\n");
|
||||||
cout << " 3 Source file already has a patch in specified patch file (=error)\n";
|
tout << _T(" 3 Source file already has a patch in specified patch file (=error)\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "[Source] " << sourceFileName.c_str() << "\n";
|
tout << _T("[Source] ") << sourceFileName.c_str() << _T("\n");
|
||||||
cout << "[Target] " << targetFileName.c_str() << "\n[PatchFile] " << patchFileName.c_str() << "\n";
|
tout << _T("[Target] ") << targetFileName.c_str() << _T("\n[PatchFile] ") << patchFileName.c_str() << _T("\n");
|
||||||
|
|
||||||
// get the file sizes
|
// get the file sizes
|
||||||
TFileOffset sourceSize = 0;
|
TFileOffset sourceSize = 0;
|
||||||
try {
|
try {
|
||||||
sourceSize = POSIX::getFileSize(sourceFileName.c_str());
|
sourceSize = POSIX::getFileSize(sourceFileName.c_str());
|
||||||
}
|
}
|
||||||
catch(char* s) {
|
catch(TCHAR* s) {
|
||||||
cerr << "Source file size reading failed: " << s << "\n";
|
terr << _T("Source file size reading failed: ") << s << _T("\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
TFileOffset targetSize;
|
TFileOffset targetSize;
|
||||||
try {
|
try {
|
||||||
targetSize = POSIX::getFileSize(targetFileName.c_str());
|
targetSize = POSIX::getFileSize(targetFileName.c_str());
|
||||||
}
|
}
|
||||||
catch(const char* s) {
|
catch(const TCHAR* s) {
|
||||||
cerr << "Target file size reading failed: " << s << "\n";
|
terr << _T("Target file size reading failed: ") << s << _T("\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,8 +169,8 @@ int main( int argc, char * argv[] ) {
|
||||||
TChecksum* targetCRC = new TChecksum(targetFileName);
|
TChecksum* targetCRC = new TChecksum(targetFileName);
|
||||||
targetCRC->mode = TChecksum::MD5; // default
|
targetCRC->mode = TChecksum::MD5; // default
|
||||||
|
|
||||||
string tempFileName = POSIX::getTempFile();
|
tstring tempFileName = POSIX::getTempFile();
|
||||||
if (tempFileName == "")
|
if (tempFileName == _T(""))
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
// open the files
|
// open the files
|
||||||
|
@ -183,8 +187,8 @@ int main( int argc, char * argv[] ) {
|
||||||
TFileOffset previousPatchSize = 0;
|
TFileOffset previousPatchSize = 0;
|
||||||
try {
|
try {
|
||||||
previousPatchSize = POSIX::getFileSize(patchFileName.c_str());
|
previousPatchSize = POSIX::getFileSize(patchFileName.c_str());
|
||||||
} catch(const char* s) {
|
} catch(const TCHAR* s) {
|
||||||
cout << "Patch file does not yet exist: " << s << ", it will be created.\n";
|
tout << _T("Patch file does not yet exist: ") << s << _T(", it will be created.\n");
|
||||||
std::ofstream newfile;
|
std::ofstream newfile;
|
||||||
newfile.open(patchFileName.c_str(), std::ios_base::binary | std::ios_base::out);
|
newfile.open(patchFileName.c_str(), std::ios_base::binary | std::ios_base::out);
|
||||||
newfile.close();
|
newfile.close();
|
||||||
|
@ -195,8 +199,8 @@ int main( int argc, char * argv[] ) {
|
||||||
try {
|
try {
|
||||||
// this will copy the contents of previousPatch to patch, but without sourceCRC
|
// this will copy the contents of previousPatch to patch, but without sourceCRC
|
||||||
fileCount = FileFormat1::removeExistingPatch(previousPatch,previousPatchSize,patch,sourceCRC,existanceIsError);
|
fileCount = FileFormat1::removeExistingPatch(previousPatch,previousPatchSize,patch,sourceCRC,existanceIsError);
|
||||||
} catch(const char* s) {
|
} catch(const TCHAR* s) {
|
||||||
cerr << "ERROR: " << s << "\n";
|
terr << _T("ERROR: ") << s << _T("\n");
|
||||||
patch.close();
|
patch.close();
|
||||||
unlink(tempFileName.c_str());
|
unlink(tempFileName.c_str());
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -204,9 +208,9 @@ int main( int argc, char * argv[] ) {
|
||||||
|
|
||||||
// set them to the same checksum mode
|
// set them to the same checksum mode
|
||||||
targetCRC->mode = sourceCRC->mode;
|
targetCRC->mode = sourceCRC->mode;
|
||||||
cout << "[Checksum] Kind of checksums used: ";
|
tout << _T("[Checksum] Kind of checksums used: ");
|
||||||
if(targetCRC->mode == TChecksum::MD5) cout << "MD5\n";
|
if(targetCRC->mode == TChecksum::MD5) tout << _T("MD5\n");
|
||||||
if(targetCRC->mode == TChecksum::CRC32) cout << "CRC32\n";
|
if(targetCRC->mode == TChecksum::CRC32) tout << _T("CRC32\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,26 +231,26 @@ int main( int argc, char * argv[] ) {
|
||||||
}
|
}
|
||||||
if((blockSize >> 1) == orgBlockSize) blockSize = orgBlockSize;
|
if((blockSize >> 1) == orgBlockSize) blockSize = orgBlockSize;
|
||||||
if(blockSize != orgBlockSize) {
|
if(blockSize != orgBlockSize) {
|
||||||
cout << "[BlockSizeFix] Your blocksize had to be fixed since it is not a multiple of 2\n";
|
tout << _T("[BlockSizeFix] Your blocksize had to be fixed since it is not a multiple of 2\n");
|
||||||
}
|
}
|
||||||
if(blockSize < 16) {
|
if(blockSize < 16) {
|
||||||
blockSize = 16;
|
blockSize = 16;
|
||||||
cout << "[BlockSizeFix] Your blocksize had to be fixed since it is smaller than 16\n";
|
tout << _T("[BlockSizeFix] Your blocksize had to be fixed since it is smaller than 16\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
gen->blockSize = blockSize;
|
gen->blockSize = blockSize;
|
||||||
cout << "[BlockSize] " << static_cast<unsigned int>(gen->blockSize) << " bytes\n";
|
tout << _T("[BlockSize] ") << static_cast<unsigned int>(gen->blockSize) << _T(" bytes\n");
|
||||||
|
|
||||||
gen->maxMatches = maxMatches;
|
gen->maxMatches = maxMatches;
|
||||||
if(gen->maxMatches == 0) {
|
if(gen->maxMatches == 0) {
|
||||||
cout << "[FindBlockMatchLimit] Unlimited matches\n";
|
tout << _T("[FindBlockMatchLimit] Unlimited matches\n");
|
||||||
} else {
|
} else {
|
||||||
cout << "[FindBlockMatchLimit] " << gen->maxMatches << " matches\n";
|
tout << _T("[FindBlockMatchLimit] ") << gen->maxMatches << _T(" matches\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
gen->beVerbose = beVerbose;
|
gen->beVerbose = beVerbose;
|
||||||
if(beVerbose) {
|
if(beVerbose) {
|
||||||
cout << "[Debug] Verbose output during patch generation activated.\n";
|
tout << _T("[Debug] Verbose output during patch generation activated.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create sameBlock storage
|
// create sameBlock storage
|
||||||
|
@ -279,20 +283,20 @@ int main( int argc, char * argv[] ) {
|
||||||
std::ofstream clearF;
|
std::ofstream clearF;
|
||||||
clearF.open(tempFileName.c_str(), std::ios_base::binary | std::ios_base::out);
|
clearF.open(tempFileName.c_str(), std::ios_base::binary | std::ios_base::out);
|
||||||
}
|
}
|
||||||
catch(string s) {
|
catch(tstring s) {
|
||||||
cerr << "Error thrown: " << s.c_str();
|
terr << _T("Error thrown: ") << s.c_str();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
catch(const char* s) {
|
catch(const TCHAR* s) {
|
||||||
cerr << "Error thrown: " << s;
|
terr << _T("Error thrown: ") << s;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cerr << "There was a problem opening the files.\n";
|
terr << _T("There was a problem opening the files.\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if(*sourceCRC == *targetCRC)
|
if(*sourceCRC == *targetCRC)
|
||||||
cerr << "WARNING: source and target file have equal CRCs!";
|
terr << _T("WARNING: source and target file have equal CRCs!");
|
||||||
delete sourceCRC;
|
delete sourceCRC;
|
||||||
delete targetCRC;
|
delete targetCRC;
|
||||||
unlink(tempFileName.c_str());
|
unlink(tempFileName.c_str());
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
L. Peter Deutsch
|
L. Peter Deutsch
|
||||||
ghost@aladdin.com
|
ghost@aladdin.com
|
||||||
|
|
||||||
|
Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
*/
|
*/
|
||||||
/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */
|
/* $Id: md5.c,v 1.1 2005/09/17 09:25:44 kichik Exp $ */
|
||||||
/*
|
/*
|
||||||
Independent implementation of MD5 (RFC 1321).
|
Independent implementation of MD5 (RFC 1321).
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
L. Peter Deutsch
|
L. Peter Deutsch
|
||||||
ghost@aladdin.com
|
ghost@aladdin.com
|
||||||
|
|
||||||
|
Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
*/
|
*/
|
||||||
/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
|
/* $Id: md5.h,v 1.1 2005/09/17 09:25:44 kichik Exp $ */
|
||||||
/*
|
/*
|
||||||
Independent implementation of MD5 (RFC 1321).
|
Independent implementation of MD5 (RFC 1321).
|
||||||
|
|
||||||
|
|
28
Contrib/VPatch/Source/GenPat/tchar.h
Normal file
28
Contrib/VPatch/Source/GenPat/tchar.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Added for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#ifdef _UNICODE
|
||||||
|
# define tout wcout
|
||||||
|
# define terr wcerr
|
||||||
|
# define __T(x) L ## x
|
||||||
|
# define _T(x) __T(x)
|
||||||
|
# define _tmain wmain
|
||||||
|
# define _tunlink _wunlink
|
||||||
|
|
||||||
|
typedef std::wstring tstring;
|
||||||
|
typedef std::wistringstream tistringstream;
|
||||||
|
|
||||||
|
typedef wchar_t TCHAR;
|
||||||
|
#else
|
||||||
|
# define tout cout
|
||||||
|
# define terr cerr
|
||||||
|
# define _T(x) x
|
||||||
|
# define _tmain main
|
||||||
|
# define _tunlink _unlink
|
||||||
|
|
||||||
|
typedef std::string tstring;
|
||||||
|
typedef std::istringstream tistringstream;
|
||||||
|
typedef char TCHAR;
|
||||||
|
#endif
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#include "apply_patch.h"
|
#include "apply_patch.h"
|
||||||
#include "checksum.h"
|
#include "checksum.h"
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#ifndef apply_patch_INCLUDED
|
#ifndef apply_patch_INCLUDED
|
||||||
#define apply_patch_INCLUDED
|
#define apply_patch_INCLUDED
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#include "checksum.h"
|
#include "checksum.h"
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
// The functions return ANSI strings so we use PushStringA to push it on
|
||||||
|
// to the return stack correctly.
|
||||||
|
|
||||||
#ifndef checksum_INCLUDED
|
#ifndef checksum_INCLUDED
|
||||||
#define checksum_INCLUDED
|
#define checksum_INCLUDED
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
L. Peter Deutsch
|
L. Peter Deutsch
|
||||||
ghost@aladdin.com
|
ghost@aladdin.com
|
||||||
|
|
||||||
|
Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
*/
|
*/
|
||||||
/* $Id: md5.c,v 1.1 2005/09/17 09:25:44 kichik Exp $ */
|
/* $Id: md5.c,v 1.2 2005/09/20 17:42:28 kichik Exp $ */
|
||||||
/*
|
/*
|
||||||
Independent implementation of MD5 (RFC 1321).
|
Independent implementation of MD5 (RFC 1321).
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,10 @@
|
||||||
L. Peter Deutsch
|
L. Peter Deutsch
|
||||||
ghost@aladdin.com
|
ghost@aladdin.com
|
||||||
|
|
||||||
|
Reviewed for Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
|
/* $Id: md5.h,v 1.1 2005/09/17 09:25:44 kichik Exp $ */
|
||||||
/*
|
/*
|
||||||
Independent implementation of MD5 (RFC 1321).
|
Independent implementation of MD5 (RFC 1321).
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not be
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
// misrepresented as being the original software.
|
// misrepresented as being the original software.
|
||||||
// 3. This notice may not be removed or altered from any source distribution.
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Unicode support by Jim Park -- 08/29/2007
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -36,15 +38,15 @@ HINSTANCE g_hInstance;
|
||||||
HWND g_hwndParent;
|
HWND g_hwndParent;
|
||||||
|
|
||||||
void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop) {
|
TCHAR *variables, stack_t **stacktop) {
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
{
|
{
|
||||||
char source[MAX_PATH];
|
TCHAR source[MAX_PATH];
|
||||||
char dest[MAX_PATH];
|
TCHAR dest[MAX_PATH];
|
||||||
char exename[MAX_PATH];
|
TCHAR exename[MAX_PATH];
|
||||||
HANDLE hPatch, hSource, hDest;
|
HANDLE hPatch, hSource, hDest;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@ void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
||||||
hPatch = CreateFile(exename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
hPatch = CreateFile(exename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (hPatch == INVALID_HANDLE_VALUE) {
|
if (hPatch == INVALID_HANDLE_VALUE) {
|
||||||
pushstring("Unable to open patch file");
|
pushstring(_T("Unable to open patch file"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +65,7 @@ void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (hSource == INVALID_HANDLE_VALUE) {
|
if (hSource == INVALID_HANDLE_VALUE) {
|
||||||
CloseHandle(hPatch);
|
CloseHandle(hPatch);
|
||||||
pushstring("Unable to open source file");
|
pushstring(_T("Unable to open source file"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +74,7 @@ void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
||||||
if (hDest == INVALID_HANDLE_VALUE) {
|
if (hDest == INVALID_HANDLE_VALUE) {
|
||||||
CloseHandle(hPatch);
|
CloseHandle(hPatch);
|
||||||
CloseHandle(hSource);
|
CloseHandle(hSource);
|
||||||
pushstring("Unable to open output file");
|
pushstring(_T("Unable to open output file"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,16 +86,16 @@ void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
||||||
|
|
||||||
if ((result != PATCH_SUCCESS)) {
|
if ((result != PATCH_SUCCESS)) {
|
||||||
if (result == PATCH_ERROR)
|
if (result == PATCH_ERROR)
|
||||||
pushstring("An error occured while patching");
|
pushstring(_T("An error occured while patching"));
|
||||||
else if (result == PATCH_CORRUPT)
|
else if (result == PATCH_CORRUPT)
|
||||||
pushstring("Patch data is invalid or corrupt");
|
pushstring(_T("Patch data is invalid or corrupt"));
|
||||||
else if (result == PATCH_NOMATCH)
|
else if (result == PATCH_NOMATCH)
|
||||||
pushstring("No suitable patches were found");
|
pushstring(_T("No suitable patches were found"));
|
||||||
else if (result == PATCH_UPTODATE)
|
else if (result == PATCH_UPTODATE)
|
||||||
pushstring("OK, new version already installed");
|
pushstring(_T("OK, new version already installed"));
|
||||||
DeleteFile(dest);
|
DeleteFile(dest);
|
||||||
} else {
|
} else {
|
||||||
pushstring("OK");
|
pushstring(_T("OK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -102,13 +104,13 @@ void __declspec(dllexport) vpatchfile(HWND hwndParent, int string_size,
|
||||||
|
|
||||||
#ifdef DLL_CHECKSUMS
|
#ifdef DLL_CHECKSUMS
|
||||||
void __declspec(dllexport) GetFileCRC32(HWND hwndParent, int string_size,
|
void __declspec(dllexport) GetFileCRC32(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop) {
|
TCHAR *variables, stack_t **stacktop) {
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH];
|
TCHAR filename[MAX_PATH];
|
||||||
char crc_string[9];
|
char crc_string[9];
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
unsigned long crc;
|
unsigned long crc;
|
||||||
|
@ -119,17 +121,17 @@ void __declspec(dllexport) GetFileCRC32(HWND hwndParent, int string_size,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (hFile == INVALID_HANDLE_VALUE) {
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
//pushstring("ERROR: Unable to open file for CRC32 calculation");
|
//pushstring("ERROR: Unable to open file for CRC32 calculation");
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FileCRC(hFile, &crc)) {
|
if (!FileCRC(hFile, &crc)) {
|
||||||
//pushstring("ERROR: Unable to calculate CRC32");
|
//pushstring("ERROR: Unable to calculate CRC32");
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
} else {
|
} else {
|
||||||
crc_string[8] = '\0';
|
crc_string[8] = '\0';
|
||||||
CRC32ToString(crc_string,crc);
|
CRC32ToString(crc_string,crc);
|
||||||
pushstring(crc_string);
|
PushStringA(crc_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
@ -137,13 +139,13 @@ void __declspec(dllexport) GetFileCRC32(HWND hwndParent, int string_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) GetFileMD5(HWND hwndParent, int string_size,
|
void __declspec(dllexport) GetFileMD5(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop) {
|
TCHAR *variables, stack_t **stacktop) {
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH];
|
TCHAR filename[MAX_PATH];
|
||||||
char md5_string[33];
|
char md5_string[33];
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
md5_byte_t digest[16];
|
md5_byte_t digest[16];
|
||||||
|
@ -154,17 +156,17 @@ void __declspec(dllexport) GetFileMD5(HWND hwndParent, int string_size,
|
||||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (hFile == INVALID_HANDLE_VALUE) {
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
//pushstring("ERROR: Unable to open file for MD5 calculation");
|
//pushstring("ERROR: Unable to open file for MD5 calculation");
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FileMD5(hFile, digest)) {
|
if (!FileMD5(hFile, digest)) {
|
||||||
//pushstring("ERROR: Unable to calculate MD5");
|
//pushstring("ERROR: Unable to calculate MD5");
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
} else {
|
} else {
|
||||||
md5_string[32] = '\0';
|
md5_string[32] = '\0';
|
||||||
MD5ToString(md5_string,digest);
|
MD5ToString(md5_string,digest);
|
||||||
pushstring(md5_string);
|
PushStringA(md5_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
// Unicode support by Jim Park -- 08/10/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
#include <nsis/nsis_tchar.h>
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
@ -12,26 +15,26 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
BROWSEINFO bi;
|
BROWSEINFO bi;
|
||||||
|
|
||||||
char result[MAX_PATH];
|
TCHAR result[MAX_PATH];
|
||||||
char initial[MAX_PATH];
|
TCHAR initial[MAX_PATH];
|
||||||
char title[1024];
|
TCHAR title[1024];
|
||||||
LPITEMIDLIST resultPIDL;
|
LPITEMIDLIST resultPIDL;
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
|
||||||
if (popstringn(title, sizeof(initial)))
|
if (popstringn(title, _countof(initial)))
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (popstringn(initial, sizeof(title)))
|
if (popstringn(initial, _countof(title)))
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +67,7 @@ void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size,
|
||||||
resultPIDL = SHBrowseForFolder(&bi);
|
resultPIDL = SHBrowseForFolder(&bi);
|
||||||
if (!resultPIDL)
|
if (!resultPIDL)
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,21 +77,21 @@ void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CoTaskMemFree(resultPIDL);
|
CoTaskMemFree(resultPIDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
OPENFILENAME ofn={0,}; // XXX WTF
|
OPENFILENAME ofn={0,}; // XXX WTF
|
||||||
int save;
|
int save;
|
||||||
char type[5];
|
TCHAR type[5];
|
||||||
static char path[1024];
|
static TCHAR path[1024];
|
||||||
static char filter[1024];
|
static TCHAR filter[1024];
|
||||||
static char currentDirectory[1024];
|
static TCHAR currentDirectory[1024];
|
||||||
static char initialDir[1024];
|
static TCHAR initialDir[1024];
|
||||||
DWORD gfa;
|
DWORD gfa;
|
||||||
|
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
|
@ -105,7 +108,7 @@ void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, ch
|
||||||
popstringn(path, sizeof(path));
|
popstringn(path, sizeof(path));
|
||||||
popstringn(filter, sizeof(filter));
|
popstringn(filter, sizeof(filter));
|
||||||
|
|
||||||
save = !lstrcmpi(type, "save");
|
save = !lstrcmpi(type, _T("save"));
|
||||||
|
|
||||||
// Check if the path given is a folder. If it is we initialize the
|
// Check if the path given is a folder. If it is we initialize the
|
||||||
// ofn.lpstrInitialDir parameter
|
// ofn.lpstrInitialDir parameter
|
||||||
|
@ -114,21 +117,21 @@ void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, ch
|
||||||
{
|
{
|
||||||
lstrcpy(initialDir, path);
|
lstrcpy(initialDir, path);
|
||||||
ofn.lpstrInitialDir = initialDir;
|
ofn.lpstrInitialDir = initialDir;
|
||||||
path[0] = '\0'; // disable initial file selection as path is actually a directory
|
path[0] = _T('\0'); // disable initial file selection as path is actually a directory
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter[0])
|
if (!filter[0])
|
||||||
{
|
{
|
||||||
lstrcpy(filter, "All Files|*.*");
|
lstrcpy(filter, _T("All Files|*.*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Convert the filter to the format required by Windows: NULL after each
|
// Convert the filter to the format required by Windows: NULL after each
|
||||||
// item followed by a terminating NULL
|
// item followed by a terminating NULL
|
||||||
char *p = filter;
|
TCHAR *p = filter;
|
||||||
while (*p) // XXX take care for 1024
|
while (*p) // XXX take care for 1024
|
||||||
{
|
{
|
||||||
if (*p == '|')
|
if (*p == _T('|'))
|
||||||
{
|
{
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
}
|
}
|
||||||
|
@ -149,19 +152,19 @@ void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, ch
|
||||||
}
|
}
|
||||||
else if (CommDlgExtendedError() == FNERR_INVALIDFILENAME)
|
else if (CommDlgExtendedError() == FNERR_INVALIDFILENAME)
|
||||||
{
|
{
|
||||||
*path = '\0';
|
*path = _T('\0');
|
||||||
if ((save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)))
|
if ((save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)))
|
||||||
{
|
{
|
||||||
pushstring(path);
|
pushstring(path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore working dir
|
// restore working dir
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/24/2007
|
||||||
|
|
||||||
#ifndef __NS_DIALOGS__DEFS_H__
|
#ifndef __NS_DIALOGS__DEFS_H__
|
||||||
#define __NS_DIALOGS__DEFS_H__
|
#define __NS_DIALOGS__DEFS_H__
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ struct nsControl
|
||||||
{
|
{
|
||||||
HWND window;
|
HWND window;
|
||||||
enum nsControlType type;
|
enum nsControlType type;
|
||||||
char userData[USERDATA_SIZE];
|
TCHAR userData[USERDATA_SIZE];
|
||||||
struct nsControlCallbacks callbacks;
|
struct nsControlCallbacks callbacks;
|
||||||
WNDPROC oldWndProc;
|
WNDPROC oldWndProc;
|
||||||
};
|
};
|
||||||
|
@ -64,6 +66,6 @@ struct nsDialog
|
||||||
struct nsControl* controls;
|
struct nsControl* controls;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NSCONTROL_ID_PROP "NSIS: nsControl pointer property"
|
#define NSCONTROL_ID_PROP _T("NSIS: nsControl pointer property")
|
||||||
|
|
||||||
#endif//__NS_DIALOGS__DEFS_H__
|
#endif//__NS_DIALOGS__DEFS_H__
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/24/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
@ -8,12 +10,12 @@
|
||||||
|
|
||||||
extern struct nsDialog g_dialog;
|
extern struct nsDialog g_dialog;
|
||||||
|
|
||||||
static int NSDFUNC ConvertPlacement(char *str, int total, int height)
|
static int NSDFUNC ConvertPlacement(TCHAR *str, int total, int height)
|
||||||
{
|
{
|
||||||
char unit = *CharPrev(str, str + lstrlen(str));
|
TCHAR unit = *CharPrev(str, str + lstrlen(str));
|
||||||
int x = myatoi(str);
|
int x = myatoi(str);
|
||||||
|
|
||||||
if (unit == '%')
|
if (unit == _T('%'))
|
||||||
{
|
{
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +24,7 @@ static int NSDFUNC ConvertPlacement(char *str, int total, int height)
|
||||||
|
|
||||||
return MulDiv(total, x, 100);
|
return MulDiv(total, x, 100);
|
||||||
}
|
}
|
||||||
else if (unit == 'u')
|
else if (unit == _T('u'))
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height)
|
||||||
RECT dialogRect;
|
RECT dialogRect;
|
||||||
int dialogWidth;
|
int dialogWidth;
|
||||||
int dialogHeight;
|
int dialogHeight;
|
||||||
char buf[1024];
|
TCHAR buf[1024];
|
||||||
|
|
||||||
GetClientRect(g_dialog.hwDialog, &dialogRect);
|
GetClientRect(g_dialog.hwDialog, &dialogRect);
|
||||||
dialogWidth = dialogRect.right;
|
dialogWidth = dialogRect.right;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Reviewed for Unicode support by Jim Park -- 08/24/2007
|
||||||
|
|
||||||
#ifndef __NS_DIALOGS__INPUT_H__
|
#ifndef __NS_DIALOGS__INPUT_H__
|
||||||
#define __NS_DIALOGS__INPUT_H__
|
#define __NS_DIALOGS__INPUT_H__
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Unicode support by Jim Park -- 08/10/2007
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <nsis/pluginapi.h> // nsis plugin
|
#include <nsis/pluginapi.h> // nsis plugin
|
||||||
|
@ -99,34 +101,34 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ctl->callbacks.onChange)
|
if (ctl->callbacks.onChange)
|
||||||
{
|
{
|
||||||
pushint((int) hwCtl);
|
pushint((int) hwCtl);
|
||||||
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
|
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
|
else if (HIWORD(wParam) == LBN_SELCHANGE && ctl->type == NSCTL_LISTBOX)
|
||||||
{
|
{
|
||||||
if (ctl->callbacks.onChange)
|
if (ctl->callbacks.onChange)
|
||||||
{
|
{
|
||||||
pushint((int) hwCtl);
|
pushint((int) hwCtl);
|
||||||
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
|
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
|
else if ((HIWORD(wParam) == CBN_EDITUPDATE || HIWORD(wParam) == CBN_SELCHANGE)
|
||||||
&& ctl->type == NSCTL_COMBOBOX)
|
&& ctl->type == NSCTL_COMBOBOX)
|
||||||
{
|
{
|
||||||
if (ctl->callbacks.onChange)
|
if (ctl->callbacks.onChange)
|
||||||
{
|
{
|
||||||
pushint((int) hwCtl);
|
pushint((int) hwCtl);
|
||||||
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
|
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onChange - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
|
else if (HIWORD(wParam) == STN_CLICKED && ctl->type == NSCTL_STATIC)
|
||||||
{
|
{
|
||||||
if (ctl->callbacks.onClick)
|
if (ctl->callbacks.onClick)
|
||||||
{
|
{
|
||||||
pushint((int) hwCtl);
|
pushint((int) hwCtl);
|
||||||
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
|
g_pluginParms->ExecuteCodeSegment(ctl->callbacks.onClick - 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -154,7 +156,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
|
DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
|
||||||
RECT rc;
|
RECT rc;
|
||||||
char text[1024];
|
TCHAR text[1024];
|
||||||
|
|
||||||
// http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
|
// http://blogs.msdn.com/oldnewthing/archive/2005/05/03/414317.aspx#414357
|
||||||
// says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make
|
// says we should call SystemParametersInfo(SPI_GETKEYBOARDCUES,...) to make
|
||||||
|
@ -171,7 +173,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
rc = lpdis->rcItem;
|
rc = lpdis->rcItem;
|
||||||
|
|
||||||
// Get button's text
|
// Get button's text
|
||||||
text[0] = '\0';
|
text[0] = _T('\0');
|
||||||
GetWindowText(lpdis->hwndItem, text, 1024);
|
GetWindowText(lpdis->hwndItem, text, 1024);
|
||||||
|
|
||||||
// Calculate needed size of the control
|
// Calculate needed size of the control
|
||||||
|
@ -242,7 +244,7 @@ static UINT_PTR PluginCallback(enum NSPIM msg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) Create(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
HWND hwPlacementRect;
|
HWND hwPlacementRect;
|
||||||
RECT rcPlacement;
|
RECT rcPlacement;
|
||||||
|
@ -262,7 +264,7 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variab
|
||||||
|
|
||||||
if (g_dialog.hwDialog == NULL)
|
if (g_dialog.hwDialog == NULL)
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +290,10 @@ void __declspec(dllexport) Create(HWND hwndParent, int string_size, char *variab
|
||||||
pushint((int) g_dialog.hwDialog);
|
pushint((int) g_dialog.hwDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
char *className;
|
TCHAR *className;
|
||||||
char *text;
|
TCHAR *text;
|
||||||
|
|
||||||
HWND hwItem;
|
HWND hwItem;
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
@ -300,18 +302,18 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
|
||||||
|
|
||||||
// get info from stack
|
// get info from stack
|
||||||
|
|
||||||
className = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, g_stringsize * 2);
|
className = (TCHAR *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (g_stringsize * 2)*sizeof(TCHAR));
|
||||||
text = &className[g_stringsize];
|
text = &className[g_stringsize];
|
||||||
|
|
||||||
if (!className)
|
if (!className)
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (popstringn(className, 0))
|
if (popstringn(className, 0))
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
HeapFree(GetProcessHeap(), 0, className);
|
HeapFree(GetProcessHeap(), 0, className);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +325,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
|
||||||
|
|
||||||
if (popstringn(text, 0))
|
if (popstringn(text, 0))
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
HeapFree(GetProcessHeap(), 0, className);
|
HeapFree(GetProcessHeap(), 0, className);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -338,21 +340,21 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
|
||||||
g_dialog.controls,
|
g_dialog.controls,
|
||||||
g_dialog.controlCount * sizeof(struct nsControl));
|
g_dialog.controlCount * sizeof(struct nsControl));
|
||||||
|
|
||||||
if (!lstrcmpi(className, "BUTTON"))
|
if (!lstrcmpi(className, _T("BUTTON")))
|
||||||
g_dialog.controls[id].type = NSCTL_BUTTON;
|
g_dialog.controls[id].type = NSCTL_BUTTON;
|
||||||
else if (!lstrcmpi(className, "EDIT"))
|
else if (!lstrcmpi(className, _T("EDIT")))
|
||||||
g_dialog.controls[id].type = NSCTL_EDIT;
|
g_dialog.controls[id].type = NSCTL_EDIT;
|
||||||
else if (!lstrcmpi(className, "COMBOBOX"))
|
else if (!lstrcmpi(className, _T("COMBOBOX")))
|
||||||
g_dialog.controls[id].type = NSCTL_COMBOBOX;
|
g_dialog.controls[id].type = NSCTL_COMBOBOX;
|
||||||
else if (!lstrcmpi(className, "LISTBOX"))
|
else if (!lstrcmpi(className, _T("LISTBOX")))
|
||||||
g_dialog.controls[id].type = NSCTL_LISTBOX;
|
g_dialog.controls[id].type = NSCTL_LISTBOX;
|
||||||
else if (!lstrcmpi(className, "RichEdit"))
|
else if (!lstrcmpi(className, _T("RichEdit")))
|
||||||
g_dialog.controls[id].type = NSCTL_RICHEDIT;
|
g_dialog.controls[id].type = NSCTL_RICHEDIT;
|
||||||
else if (!lstrcmpi(className, "RICHEDIT_CLASS"))
|
else if (!lstrcmpi(className, _T("RICHEDIT_CLASS")))
|
||||||
g_dialog.controls[id].type = NSCTL_RICHEDIT2;
|
g_dialog.controls[id].type = NSCTL_RICHEDIT2;
|
||||||
else if (!lstrcmpi(className, "STATIC"))
|
else if (!lstrcmpi(className, _T("STATIC")))
|
||||||
g_dialog.controls[id].type = NSCTL_STATIC;
|
g_dialog.controls[id].type = NSCTL_STATIC;
|
||||||
else if (!lstrcmpi(className, "LINK"))
|
else if (!lstrcmpi(className, _T("LINK")))
|
||||||
g_dialog.controls[id].type = NSCTL_LINK;
|
g_dialog.controls[id].type = NSCTL_LINK;
|
||||||
else
|
else
|
||||||
g_dialog.controls[id].type = NSCTL_UNKNOWN;
|
g_dialog.controls[id].type = NSCTL_UNKNOWN;
|
||||||
|
@ -365,7 +367,7 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
|
||||||
|
|
||||||
hwItem = CreateWindowEx(
|
hwItem = CreateWindowEx(
|
||||||
exStyle,
|
exStyle,
|
||||||
lstrcmpi(className, "LINK") ? className : "BUTTON",
|
lstrcmpi(className, _T("LINK")) ? className : _T("BUTTON"),
|
||||||
text,
|
text,
|
||||||
style,
|
style,
|
||||||
x, y, width, height,
|
x, y, width, height,
|
||||||
|
@ -399,12 +401,12 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
|
||||||
}
|
}
|
||||||
|
|
||||||
// for backward compatibility (2.29 had CreateItem)
|
// for backward compatibility (2.29 had CreateItem)
|
||||||
void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) CreateItem(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
CreateControl(hwndParent, string_size, variables, stacktop, extra);
|
CreateControl(hwndParent, string_size, variables, stacktop, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
HWND hwCtl;
|
HWND hwCtl;
|
||||||
struct nsControl* ctl;
|
struct nsControl* ctl;
|
||||||
|
@ -431,7 +433,7 @@ void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *v
|
||||||
popstringn(ctl->userData, USERDATA_SIZE);
|
popstringn(ctl->userData, USERDATA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
HWND hwCtl;
|
HWND hwCtl;
|
||||||
struct nsControl* ctl;
|
struct nsControl* ctl;
|
||||||
|
@ -442,7 +444,7 @@ void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, char *v
|
||||||
|
|
||||||
if (!IsWindow(hwCtl))
|
if (!IsWindow(hwCtl))
|
||||||
{
|
{
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +454,7 @@ void __declspec(dllexport) GetUserData(HWND hwndParent, int string_size, char *v
|
||||||
|
|
||||||
if (ctl == NULL)
|
if (ctl == NULL)
|
||||||
{
|
{
|
||||||
pushstring("");
|
pushstring(_T(""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +469,7 @@ void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
||||||
g_pluginParms->ExecuteCodeSegment(idEvent - 1, 0);
|
g_pluginParms->ExecuteCodeSegment(idEvent - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
UINT callback;
|
UINT callback;
|
||||||
UINT interval;
|
UINT interval;
|
||||||
|
@ -489,7 +491,7 @@ void __declspec(dllexport) CreateTimer(HWND hwndParent, int string_size, char *v
|
||||||
TimerProc);
|
TimerProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsdKillTimer(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void nsdKillTimer(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
UINT id;
|
UINT id;
|
||||||
|
|
||||||
|
@ -546,27 +548,27 @@ void NSDFUNC SetDialogCallback(size_t callbackIdx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __declspec(dllexport) OnClick(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) OnClick(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
SetControlCallback(CTL_CALLBACK_IDX(onClick));
|
SetControlCallback(CTL_CALLBACK_IDX(onClick));
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) OnChange(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) OnChange(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
SetControlCallback(CTL_CALLBACK_IDX(onChange));
|
SetControlCallback(CTL_CALLBACK_IDX(onChange));
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) OnNotify(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) OnNotify(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
SetControlCallback(CTL_CALLBACK_IDX(onNotify));
|
SetControlCallback(CTL_CALLBACK_IDX(onNotify));
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) OnBack(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) OnBack(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
SetDialogCallback(DLG_CALLBACK_IDX(onBack));
|
SetDialogCallback(DLG_CALLBACK_IDX(onBack));
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) Show(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) Show(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
// tell NSIS to remove old inner dialog and pass handle of the new inner dialog
|
// tell NSIS to remove old inner dialog and pass handle of the new inner dialog
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
extern struct nsDialog g_dialog;
|
extern struct nsDialog g_dialog;
|
||||||
|
|
||||||
void __declspec(dllexport) SetRTL(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
|
void __declspec(dllexport) SetRTL(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
|
||||||
{
|
{
|
||||||
g_dialog.rtl = (BOOL) popint();
|
g_dialog.rtl = (BOOL) popint();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ freely, subject to the following restrictions:
|
||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Unicode support by Jim Park -- 08/24/2007
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
@ -35,11 +37,12 @@ HWND g_hwndParent;
|
||||||
HWND g_hwndList;
|
HWND g_hwndList;
|
||||||
|
|
||||||
void ExecScript(BOOL log);
|
void ExecScript(BOOL log);
|
||||||
void LogMessage(const char *pStr, BOOL bOEM);
|
void LogMessage(const TCHAR *pStr, BOOL bOEM);
|
||||||
char *my_strstr(char *a, char *b);
|
TCHAR *my_strstr(TCHAR *a, TCHAR *b);
|
||||||
unsigned int my_atoi(char *s);
|
unsigned int my_atoi(TCHAR *s);
|
||||||
|
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);
|
||||||
|
|
||||||
void __declspec(dllexport) Exec(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) {
|
void __declspec(dllexport) Exec(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) {
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
{
|
{
|
||||||
|
@ -47,7 +50,7 @@ void __declspec(dllexport) Exec(HWND hwndParent, int string_size, char *variable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) ExecToLog(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) {
|
void __declspec(dllexport) ExecToLog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) {
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
{
|
{
|
||||||
|
@ -55,7 +58,7 @@ void __declspec(dllexport) ExecToLog(HWND hwndParent, int string_size, char *var
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __declspec(dllexport) ExecToStack(HWND hwndParent, int string_size, char *variables, stack_t **stacktop) {
|
void __declspec(dllexport) ExecToStack(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop) {
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
EXDLL_INIT();
|
EXDLL_INIT();
|
||||||
{
|
{
|
||||||
|
@ -69,7 +72,7 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TAB_REPLACE " "
|
#define TAB_REPLACE _T(" ")
|
||||||
#define TAB_REPLACE_SIZE (sizeof(TAB_REPLACE)-1)
|
#define TAB_REPLACE_SIZE (sizeof(TAB_REPLACE)-1)
|
||||||
|
|
||||||
// Turn a pair of chars into a word
|
// Turn a pair of chars into a word
|
||||||
|
@ -88,7 +91,7 @@ BOOL IsWOW64() {
|
||||||
LPFN_ISWOW64PROCESS fnIsWow64Process;
|
LPFN_ISWOW64PROCESS fnIsWow64Process;
|
||||||
|
|
||||||
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
|
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
|
||||||
GetModuleHandle("kernel32"), "IsWow64Process");
|
GetModuleHandle(_T("kernel32")), "IsWow64Process");
|
||||||
|
|
||||||
if (fnIsWow64Process != NULL) {
|
if (fnIsWow64Process != NULL) {
|
||||||
if (fnIsWow64Process(GetCurrentProcess(), &wow64)) {
|
if (fnIsWow64Process(GetCurrentProcess(), &wow64)) {
|
||||||
|
@ -100,27 +103,28 @@ BOOL IsWOW64() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecScript(int log) {
|
void ExecScript(int log) {
|
||||||
char szRet[128] = "";
|
TCHAR szRet[128] = _T("");
|
||||||
char meDLLPath[MAX_PATH];
|
TCHAR meDLLPath[MAX_PATH];
|
||||||
char *executor;
|
TCHAR *executor;
|
||||||
char *g_exec;
|
TCHAR *g_exec;
|
||||||
char *pExec;
|
TCHAR *pExec;
|
||||||
unsigned int g_to;
|
unsigned int g_to;
|
||||||
BOOL bOEM;
|
BOOL bOEM;
|
||||||
|
|
||||||
if (!IsWOW64()) {
|
if (!IsWOW64()) {
|
||||||
char *p;
|
TCHAR* p;
|
||||||
int nComSpecSize;
|
int nComSpecSize;
|
||||||
|
|
||||||
nComSpecSize = GetModuleFileName(g_hInst, meDLLPath, MAX_PATH) + 2; // 2 chars for quotes
|
nComSpecSize = GetModuleFileName(g_hInst, meDLLPath, MAX_PATH) + 2; // 2 chars for quotes
|
||||||
g_exec = (char *)GlobalAlloc(GPTR, sizeof(char)*g_stringsize+nComSpecSize+2); // 1 for space, 1 for null
|
g_exec = (TCHAR *)GlobalAlloc(GPTR, sizeof(TCHAR)*(g_stringsize+nComSpecSize+2)); // 1 for space, 1 for null
|
||||||
p = meDLLPath + nComSpecSize - 2; // point p at null char of meDLLPath
|
p = meDLLPath + nComSpecSize - 2; // point p at null char of meDLLPath
|
||||||
*g_exec = '"';
|
*g_exec = _T('"');
|
||||||
executor = g_exec + 1;
|
executor = g_exec + 1;
|
||||||
|
|
||||||
|
// Look for the last '\' in path.
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (*p == '\\')
|
if (*p == _T('\\'))
|
||||||
break;
|
break;
|
||||||
p = CharPrev(meDLLPath, p);
|
p = CharPrev(meDLLPath, p);
|
||||||
}
|
}
|
||||||
|
@ -128,15 +132,15 @@ void ExecScript(int log) {
|
||||||
if (p == meDLLPath)
|
if (p == meDLLPath)
|
||||||
{
|
{
|
||||||
// bad path
|
// bad path
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
GlobalFree(g_exec);
|
GlobalFree(g_exec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = 0;
|
*p = 0;
|
||||||
GetTempFileName(meDLLPath, "ns", 0, executor);
|
GetTempFileName(meDLLPath, _T("ns"), 0, executor); // executor = new temp file name in module path.
|
||||||
*p = '\\';
|
*p = _T('\\');
|
||||||
if (CopyFile(meDLLPath, executor, FALSE))
|
if (CopyFile(meDLLPath, executor, FALSE)) // copy current DLL to temp file in module path.
|
||||||
{
|
{
|
||||||
HANDLE hFile, hMapping;
|
HANDLE hFile, hMapping;
|
||||||
LPBYTE pMapView;
|
LPBYTE pMapView;
|
||||||
|
@ -147,25 +151,27 @@ void ExecScript(int log) {
|
||||||
if (pMapView)
|
if (pMapView)
|
||||||
{
|
{
|
||||||
pNTHeaders = (PIMAGE_NT_HEADERS)(pMapView + ((PIMAGE_DOS_HEADER)pMapView)->e_lfanew);
|
pNTHeaders = (PIMAGE_NT_HEADERS)(pMapView + ((PIMAGE_DOS_HEADER)pMapView)->e_lfanew);
|
||||||
|
// Turning the copied DLL into a stripped down executable.
|
||||||
pNTHeaders->FileHeader.Characteristics = IMAGE_FILE_32BIT_MACHINE | IMAGE_FILE_LOCAL_SYMS_STRIPPED |
|
pNTHeaders->FileHeader.Characteristics = IMAGE_FILE_32BIT_MACHINE | IMAGE_FILE_LOCAL_SYMS_STRIPPED |
|
||||||
IMAGE_FILE_LINE_NUMS_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE;
|
IMAGE_FILE_LINE_NUMS_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE;
|
||||||
|
// Windows character-mode user interface (CUI) subsystem.
|
||||||
pNTHeaders->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
|
pNTHeaders->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
|
||||||
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD)WinMain - (DWORD)g_hInst;
|
pNTHeaders->OptionalHeader.AddressOfEntryPoint = (DWORD)_tWinMain - (DWORD)g_hInst;
|
||||||
UnmapViewOfFile(pMapView);
|
UnmapViewOfFile(pMapView);
|
||||||
}
|
}
|
||||||
CloseHandle(hMapping);
|
CloseHandle(hMapping);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
lstrcat(g_exec, "\"");
|
lstrcat(g_exec, _T("\""));
|
||||||
|
|
||||||
// add space
|
// add space
|
||||||
pExec = g_exec + lstrlen(g_exec);
|
pExec = g_exec + lstrlen(g_exec);
|
||||||
*pExec = ' ';
|
*pExec = _T(' ');
|
||||||
pExec++;
|
pExec++;
|
||||||
} else {
|
} else {
|
||||||
executor = NULL;
|
executor = NULL;
|
||||||
g_exec = (char *)GlobalAlloc(GPTR, sizeof(char)*g_stringsize+1); // 1 for null
|
g_exec = (TCHAR *)GlobalAlloc(GPTR, sizeof(TCHAR)*(g_stringsize+1)); // 1 for NULL
|
||||||
pExec = g_exec;
|
pExec = g_exec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,18 +179,24 @@ void ExecScript(int log) {
|
||||||
bOEM = FALSE; // default is no OEM->ANSI conversion
|
bOEM = FALSE; // default is no OEM->ANSI conversion
|
||||||
|
|
||||||
g_hwndList = NULL;
|
g_hwndList = NULL;
|
||||||
if (g_hwndParent)
|
|
||||||
g_hwndList = FindWindowEx(FindWindowEx(g_hwndParent,NULL,"#32770",NULL),NULL,"SysListView32",NULL);
|
// g_hwndParent = the caller, usually NSIS installer.
|
||||||
|
if (g_hwndParent) // The window class name for dialog boxes is "#32770"
|
||||||
|
g_hwndList = FindWindowEx(FindWindowEx(g_hwndParent,NULL,_T("#32770"),NULL),NULL,_T("SysListView32"),NULL);
|
||||||
|
|
||||||
|
// g_exec is the complete command to run: It has the copy of this DLL turned
|
||||||
|
// into an executable right now.
|
||||||
|
|
||||||
params:
|
params:
|
||||||
|
// Get the command I need to run from the NSIS stack.
|
||||||
popstring(pExec);
|
popstring(pExec);
|
||||||
if (my_strstr(pExec, "/TIMEOUT=") == pExec) {
|
if (my_strstr(pExec, _T("/TIMEOUT=")) == pExec) {
|
||||||
char *szTimeout = pExec + 9;
|
TCHAR *szTimeout = pExec + 9;
|
||||||
g_to = my_atoi(szTimeout);
|
g_to = my_atoi(szTimeout);
|
||||||
*pExec = 0;
|
*pExec = 0;
|
||||||
goto params;
|
goto params;
|
||||||
}
|
}
|
||||||
if (!lstrcmpi(pExec, "/OEM")) {
|
if (!lstrcmpi(pExec, _T("/OEM"))) {
|
||||||
bOEM = TRUE;
|
bOEM = TRUE;
|
||||||
*pExec = 0;
|
*pExec = 0;
|
||||||
goto params;
|
goto params;
|
||||||
|
@ -192,12 +204,14 @@ params:
|
||||||
|
|
||||||
if (!pExec[0])
|
if (!pExec[0])
|
||||||
{
|
{
|
||||||
pushstring("error");
|
pushstring(_T("error"));
|
||||||
*(pExec-2) = '\0'; // skip space and quote
|
*(pExec-2) = _T('\0'); // skip space and quote
|
||||||
if (executor) DeleteFile(executor);
|
if (executor) DeleteFile(executor);
|
||||||
GlobalFree(g_exec);
|
GlobalFree(g_exec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Got all the params off the stack.
|
||||||
|
|
||||||
{
|
{
|
||||||
STARTUPINFO si={sizeof(si),};
|
STARTUPINFO si={sizeof(si),};
|
||||||
|
@ -211,20 +225,20 @@ params:
|
||||||
DWORD dwExit = 0;
|
DWORD dwExit = 0;
|
||||||
DWORD dwWait = WAIT_TIMEOUT;
|
DWORD dwWait = WAIT_TIMEOUT;
|
||||||
DWORD dwLastOutput;
|
DWORD dwLastOutput;
|
||||||
static char szBuf[1024];
|
static TCHAR szBuf[1024];
|
||||||
HGLOBAL hUnusedBuf = NULL;
|
HGLOBAL hUnusedBuf = NULL;
|
||||||
char *szUnusedBuf = 0;
|
TCHAR *szUnusedBuf = 0;
|
||||||
|
|
||||||
if (log) {
|
if (log) {
|
||||||
hUnusedBuf = GlobalAlloc(GHND, log & 2 ? g_stringsize : sizeof(szBuf)*4);
|
hUnusedBuf = GlobalAlloc(GHND, log & 2 ? (g_stringsize*sizeof(TCHAR)) : sizeof(szBuf)*4);
|
||||||
if (!hUnusedBuf) {
|
if (!hUnusedBuf) {
|
||||||
lstrcpy(szRet, "error");
|
lstrcpy(szRet, _T("error"));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
szUnusedBuf = (char *)GlobalLock(hUnusedBuf);
|
szUnusedBuf = (TCHAR *)GlobalLock(hUnusedBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetVersionEx(&osv);
|
GetVersionEx(&osv); // Get OS info
|
||||||
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
||||||
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
|
InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
|
||||||
SetSecurityDescriptorDacl(&sd,true,NULL,false);
|
SetSecurityDescriptorDacl(&sd,true,NULL,false);
|
||||||
|
@ -234,11 +248,11 @@ params:
|
||||||
sa.lpSecurityDescriptor = NULL;
|
sa.lpSecurityDescriptor = NULL;
|
||||||
sa.bInheritHandle = true;
|
sa.bInheritHandle = true;
|
||||||
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
|
if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
|
||||||
lstrcpy(szRet, "error");
|
lstrcpy(szRet, _T("error"));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!CreatePipe(&read_stdin,&newstdin,&sa,0)) {
|
if (!CreatePipe(&read_stdin,&newstdin,&sa,0)) {
|
||||||
lstrcpy(szRet, "error");
|
lstrcpy(szRet, _T("error"));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,12 +263,13 @@ params:
|
||||||
si.hStdOutput = newstdout;
|
si.hStdOutput = newstdout;
|
||||||
si.hStdError = newstdout;
|
si.hStdError = newstdout;
|
||||||
if (!CreateProcess(NULL,g_exec,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
|
if (!CreateProcess(NULL,g_exec,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
|
||||||
lstrcpy(szRet, "error");
|
lstrcpy(szRet, _T("error"));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwLastOutput = GetTickCount();
|
dwLastOutput = GetTickCount();
|
||||||
|
|
||||||
|
// Now I'm talking with an executable copy of myself.
|
||||||
while (dwWait != WAIT_OBJECT_0 || dwRead) {
|
while (dwWait != WAIT_OBJECT_0 || dwRead) {
|
||||||
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
PeekNamedPipe(read_stdout, 0, 0, 0, &dwRead, NULL);
|
||||||
if (dwRead) {
|
if (dwRead) {
|
||||||
|
@ -262,16 +277,16 @@ params:
|
||||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
||||||
szBuf[dwRead] = 0;
|
szBuf[dwRead] = 0;
|
||||||
if (log) {
|
if (log) {
|
||||||
char *p, *p2;
|
TCHAR *p, *p2;
|
||||||
SIZE_T iReqLen = lstrlen(szBuf) + lstrlen(szUnusedBuf);
|
SIZE_T iReqLen = lstrlen(szBuf) + lstrlen(szUnusedBuf);
|
||||||
if (GlobalSize(hUnusedBuf) < iReqLen && (iReqLen < g_stringsize || !(log & 2))) {
|
if (GlobalSize(hUnusedBuf) < iReqLen && (iReqLen < g_stringsize || !(log & 2))) {
|
||||||
GlobalUnlock(hUnusedBuf);
|
GlobalUnlock(hUnusedBuf);
|
||||||
hUnusedBuf = GlobalReAlloc(hUnusedBuf, iReqLen+sizeof(szBuf), GHND);
|
hUnusedBuf = GlobalReAlloc(hUnusedBuf, iReqLen+sizeof(szBuf), GHND);
|
||||||
if (!hUnusedBuf) {
|
if (!hUnusedBuf) {
|
||||||
lstrcpy(szRet, "error");
|
lstrcpy(szRet, _T("error"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
szUnusedBuf = (char *)GlobalLock(hUnusedBuf);
|
szUnusedBuf = (TCHAR *)GlobalLock(hUnusedBuf);
|
||||||
}
|
}
|
||||||
p = szUnusedBuf; // get the old left overs
|
p = szUnusedBuf; // get the old left overs
|
||||||
if (iReqLen < g_stringsize || !(log & 2)) lstrcat(p, szBuf);
|
if (iReqLen < g_stringsize || !(log & 2)) lstrcat(p, szBuf);
|
||||||
|
@ -280,33 +295,33 @@ params:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(log & 2)) {
|
if (!(log & 2)) {
|
||||||
while ((p = my_strstr(p, "\t"))) {
|
while ((p = my_strstr(p, _T("\t")))) {
|
||||||
if ((int)(p - szUnusedBuf) > (int)(GlobalSize(hUnusedBuf) - TAB_REPLACE_SIZE - 1))
|
if ((int)(p - szUnusedBuf) > (int)(GlobalSize(hUnusedBuf) - TAB_REPLACE_SIZE - 1))
|
||||||
{
|
{
|
||||||
*p++ = ' ';
|
*p++ = _T(' ');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len = lstrlen(p);
|
int len = lstrlen(p);
|
||||||
char *c_out=(char*)p+TAB_REPLACE_SIZE+len;
|
TCHAR *c_out=(TCHAR*)p+TAB_REPLACE_SIZE+len;
|
||||||
char *c_in=(char *)p+len;
|
TCHAR *c_in=(TCHAR *)p+len;
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
*c_out--=*c_in--;
|
*c_out--=*c_in--;
|
||||||
}
|
}
|
||||||
|
|
||||||
lstrcpy(p, TAB_REPLACE);
|
lstrcpy(p, TAB_REPLACE);
|
||||||
p += TAB_REPLACE_SIZE;
|
p += TAB_REPLACE_SIZE;
|
||||||
*p = ' ';
|
*p = _T(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = szUnusedBuf; // get the old left overs
|
p = szUnusedBuf; // get the old left overs
|
||||||
for (p2 = p; *p2;) {
|
for (p2 = p; *p2;) {
|
||||||
if (*p2 == '\r') {
|
if (*p2 == _T('\r')) {
|
||||||
*p2++ = 0;
|
*p2++ = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (*p2 == '\n') {
|
if (*p2 == _T('\n')) {
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
while (!*p && p != p2) p++;
|
while (!*p && p != p2) p++;
|
||||||
LogMessage(p, bOEM);
|
LogMessage(p, bOEM);
|
||||||
|
@ -318,7 +333,7 @@ params:
|
||||||
|
|
||||||
// If data was taken out from the unused buffer, move p contents to the start of szUnusedBuf
|
// If data was taken out from the unused buffer, move p contents to the start of szUnusedBuf
|
||||||
if (p != szUnusedBuf) {
|
if (p != szUnusedBuf) {
|
||||||
char *p2 = szUnusedBuf;
|
TCHAR *p2 = szUnusedBuf;
|
||||||
while (*p) *p2++ = *p++;
|
while (*p) *p2++ = *p++;
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +343,7 @@ params:
|
||||||
else {
|
else {
|
||||||
if (g_to && GetTickCount() > dwLastOutput+g_to) {
|
if (g_to && GetTickCount() > dwLastOutput+g_to) {
|
||||||
TerminateProcess(pi.hProcess, -1);
|
TerminateProcess(pi.hProcess, -1);
|
||||||
lstrcpy(szRet, "timeout");
|
lstrcpy(szRet, _T("timeout"));
|
||||||
}
|
}
|
||||||
else Sleep(LOOPTIMEOUT);
|
else Sleep(LOOPTIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -341,8 +356,8 @@ done:
|
||||||
if (log & 2) pushstring(szUnusedBuf);
|
if (log & 2) pushstring(szUnusedBuf);
|
||||||
if (log & 1 && *szUnusedBuf) LogMessage(szUnusedBuf, bOEM);
|
if (log & 1 && *szUnusedBuf) LogMessage(szUnusedBuf, bOEM);
|
||||||
if ( dwExit == STATUS_ILLEGAL_INSTRUCTION )
|
if ( dwExit == STATUS_ILLEGAL_INSTRUCTION )
|
||||||
lstrcpy(szRet, "error");
|
lstrcpy(szRet, _T("error"));
|
||||||
if (!szRet[0]) wsprintf(szRet,"%d",dwExit);
|
if (!szRet[0]) wsprintf(szRet,_T("%d"),dwExit);
|
||||||
pushstring(szRet);
|
pushstring(szRet);
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
|
@ -350,7 +365,7 @@ done:
|
||||||
CloseHandle(read_stdout);
|
CloseHandle(read_stdout);
|
||||||
CloseHandle(newstdin);
|
CloseHandle(newstdin);
|
||||||
CloseHandle(read_stdin);
|
CloseHandle(read_stdin);
|
||||||
*(pExec-2) = '\0'; // skip space and quote
|
*(pExec-2) = _T('\0'); // skip space and quote
|
||||||
if (executor) DeleteFile(executor);
|
if (executor) DeleteFile(executor);
|
||||||
GlobalFree(g_exec);
|
GlobalFree(g_exec);
|
||||||
if (log) {
|
if (log) {
|
||||||
|
@ -361,27 +376,27 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tim Kosse's LogMessage
|
// Tim Kosse's LogMessage
|
||||||
void LogMessage(const char *pStr, BOOL bOEM) {
|
void LogMessage(const TCHAR *pStr, BOOL bOEM) {
|
||||||
LVITEM item={0};
|
LVITEM item={0};
|
||||||
int nItemCount;
|
int nItemCount;
|
||||||
if (!g_hwndList) return;
|
if (!g_hwndList) return;
|
||||||
//if (!lstrlen(pStr)) return;
|
//if (!lstrlen(pStr)) return;
|
||||||
if (bOEM == TRUE) OemToCharBuff(pStr, (char *)pStr, lstrlen(pStr));
|
if (bOEM == TRUE) OemToCharBuff(pStr, (TCHAR *)pStr, lstrlen(pStr));
|
||||||
nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
|
||||||
item.mask=LVIF_TEXT;
|
item.mask=LVIF_TEXT;
|
||||||
item.pszText=(char *)pStr;
|
item.pszText=(TCHAR *)pStr;
|
||||||
item.cchTextMax=0;
|
item.cchTextMax=0;
|
||||||
item.iItem=nItemCount;
|
item.iItem=nItemCount;
|
||||||
ListView_InsertItem(g_hwndList, &item);
|
ListView_InsertItem(g_hwndList, &item);
|
||||||
ListView_EnsureVisible(g_hwndList, item.iItem, 0);
|
ListView_EnsureVisible(g_hwndList, item.iItem, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *my_strstr(char *a, char *b)
|
TCHAR *my_strstr(TCHAR *a, TCHAR *b)
|
||||||
{
|
{
|
||||||
int l = lstrlen(b);
|
int l = lstrlen(b);
|
||||||
while (lstrlen(a) >= l)
|
while (lstrlen(a) >= l)
|
||||||
{
|
{
|
||||||
char c = a[l];
|
TCHAR c = a[l];
|
||||||
a[l] = 0;
|
a[l] = 0;
|
||||||
if (!lstrcmpi(a, b))
|
if (!lstrcmpi(a, b))
|
||||||
{
|
{
|
||||||
|
@ -394,25 +409,25 @@ char *my_strstr(char *a, char *b)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int my_atoi(char *s) {
|
unsigned int my_atoi(TCHAR *s) {
|
||||||
unsigned int v=0;
|
unsigned int v=0;
|
||||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X')) {
|
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X'))) {
|
||||||
s+=2;
|
s+=2;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c=*s++;
|
int c=*s++;
|
||||||
if (c >= '0' && c <= '9') c-='0';
|
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||||
else break;
|
else break;
|
||||||
v<<=4;
|
v<<=4;
|
||||||
v+=c;
|
v+=c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0') {
|
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0')) {
|
||||||
s++;
|
s++;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c=*s++;
|
int c=*s++;
|
||||||
if (c >= '0' && c <= '7') c-='0';
|
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
|
||||||
else break;
|
else break;
|
||||||
v<<=3;
|
v<<=3;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -420,7 +435,7 @@ unsigned int my_atoi(char *s) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c=*s++ - '0';
|
int c=*s++ - _T('0');
|
||||||
if (c < 0 || c > 9) break;
|
if (c < 0 || c > 9) break;
|
||||||
v*=10;
|
v*=10;
|
||||||
v+=c;
|
v+=c;
|
||||||
|
@ -429,14 +444,14 @@ unsigned int my_atoi(char *s) {
|
||||||
return (int)v;
|
return (int)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
DWORD Ret;
|
DWORD Ret;
|
||||||
STARTUPINFO si = {0};
|
STARTUPINFO si = {0};
|
||||||
PROCESS_INFORMATION pi = {0};
|
PROCESS_INFORMATION pi = {0};
|
||||||
char command_line[1024];
|
TCHAR command_line[1024];
|
||||||
char seekchar=' ';
|
TCHAR seekchar=_T(' ');
|
||||||
char *cmdline;
|
TCHAR *cmdline;
|
||||||
|
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
// Make child process use this app's standard files. Not needed because the handles
|
// Make child process use this app's standard files. Not needed because the handles
|
||||||
|
@ -448,12 +463,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
lstrcpyn(command_line, GetCommandLine(), 1024);
|
lstrcpyn(command_line, GetCommandLine(), 1024);
|
||||||
|
|
||||||
cmdline = command_line;
|
cmdline = command_line;
|
||||||
if (*cmdline == '\"') seekchar = *cmdline++;
|
if (*cmdline == _T('\"')) seekchar = *cmdline++;
|
||||||
|
|
||||||
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
|
while (*cmdline && *cmdline != seekchar) cmdline=CharNext(cmdline);
|
||||||
cmdline=CharNext(cmdline);
|
cmdline=CharNext(cmdline);
|
||||||
// skip any spaces before the arguments
|
// skip any spaces before the arguments
|
||||||
while (*cmdline && *cmdline == ' ') cmdline++;
|
while (*cmdline && *cmdline == _T(' ')) cmdline++;
|
||||||
|
|
||||||
Ret = CreateProcess (NULL, cmdline,
|
Ret = CreateProcess (NULL, cmdline,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue