remove special implementation of stack operations and use plugin.lib instead
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5835 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
7ee44a65dc
commit
41836a0f4a
7 changed files with 22 additions and 169 deletions
|
@ -5,7 +5,6 @@ files = Split("""
|
|||
input.c
|
||||
nsDialogs.c
|
||||
nsDialogs.def
|
||||
nsis.c
|
||||
rtl.c
|
||||
""")
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#include <plugin.h> // nsis plugin.h
|
||||
|
||||
#include "defs.h"
|
||||
#include "nsis.h"
|
||||
|
||||
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
|
||||
if (uMsg == BFFM_INITIALIZED)
|
||||
|
@ -22,13 +23,13 @@ void __declspec(dllexport) SelectFolderDialog(HWND hwndParent, int string_size,
|
|||
|
||||
EXDLL_INIT();
|
||||
|
||||
if (popstring(title, sizeof(initial)))
|
||||
if (popstringn(title, sizeof(initial)))
|
||||
{
|
||||
pushstring("error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (popstring(initial, sizeof(title)))
|
||||
if (popstringn(initial, sizeof(title)))
|
||||
{
|
||||
pushstring("error");
|
||||
return;
|
||||
|
@ -100,9 +101,9 @@ void __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, ch
|
|||
//ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER);
|
||||
ofn.Flags = OFN_CREATEPROMPT | OFN_EXPLORER;
|
||||
|
||||
popstring(type, sizeof(type));
|
||||
popstring(path, sizeof(path));
|
||||
popstring(filter, sizeof(filter));
|
||||
popstringn(type, sizeof(type));
|
||||
popstringn(path, sizeof(path));
|
||||
popstringn(filter, sizeof(filter));
|
||||
|
||||
save = !lstrcmpi(type, "save");
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include <plugin.h> // nsis plugin.h
|
||||
|
||||
#include "input.h"
|
||||
#include "defs.h"
|
||||
#include "nsis.h"
|
||||
#include "rtl.h"
|
||||
|
||||
extern struct nsDialog g_dialog;
|
||||
|
@ -55,22 +56,22 @@ int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height)
|
|||
dialogWidth = dialogRect.right;
|
||||
dialogHeight = dialogRect.bottom;
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
if (popstringn(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*x = ConvertPlacement(buf, dialogWidth, 0);
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
if (popstringn(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*y = ConvertPlacement(buf, dialogHeight, 1);
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
if (popstringn(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*width = ConvertPlacement(buf, dialogWidth, 0);
|
||||
|
||||
if (popstring(buf, 1024))
|
||||
if (popstringn(buf, 1024))
|
||||
return 1;
|
||||
|
||||
*height = ConvertPlacement(buf, dialogHeight, 1);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include <plugin.h> // nsis plugin.h
|
||||
|
||||
#include "defs.h"
|
||||
#include "nsis.h"
|
||||
#include "input.h"
|
||||
#include "rtl.h"
|
||||
|
||||
|
@ -299,19 +300,19 @@ void __declspec(dllexport) CreateControl(HWND hwndParent, int string_size, char
|
|||
return;
|
||||
}
|
||||
|
||||
if (popstring(className, 0))
|
||||
if (popstringn(className, 0))
|
||||
{
|
||||
pushstring("error");
|
||||
HeapFree(GetProcessHeap(), 0, className);
|
||||
return;
|
||||
}
|
||||
|
||||
style = (DWORD) popint();
|
||||
exStyle = (DWORD) popint();
|
||||
style = (DWORD) popint_or();
|
||||
exStyle = (DWORD) popint_or();
|
||||
|
||||
PopPlacement(&x, &y, &width, &height);
|
||||
|
||||
if (popstring(text, 0))
|
||||
if (popstringn(text, 0))
|
||||
{
|
||||
pushstring("error");
|
||||
HeapFree(GetProcessHeap(), 0, className);
|
||||
|
@ -418,7 +419,7 @@ void __declspec(dllexport) SetUserData(HWND hwndParent, int string_size, char *v
|
|||
|
||||
// set user data
|
||||
|
||||
popstring(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)
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include "nsis.h"
|
||||
|
||||
int g_stringsize;
|
||||
stack_t **g_stacktop;
|
||||
char *g_variables;
|
||||
|
||||
int NSDFUNC myatoi(const char *s)
|
||||
{
|
||||
int v=0;
|
||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
||||
{
|
||||
s++;
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s);
|
||||
if (c >= '0' && c <= '9') c-='0';
|
||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
||||
else break;
|
||||
v<<=4;
|
||||
v+=c;
|
||||
}
|
||||
}
|
||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s);
|
||||
if (c >= '0' && c <= '7') c-='0';
|
||||
else break;
|
||||
v<<=3;
|
||||
v+=c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int sign=0;
|
||||
if (*s == '-') sign++; else s--;
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s) - '0';
|
||||
if (c < 0 || c > 9) break;
|
||||
v*=10;
|
||||
v+=c;
|
||||
}
|
||||
if (sign) v = -v;
|
||||
}
|
||||
|
||||
// Support for simple ORed expressions
|
||||
if (*s == '|')
|
||||
{
|
||||
v |= myatoi(s+1);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
int NSDFUNC popstring(char *str, int size)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop || !*g_stacktop) return 1;
|
||||
th=(*g_stacktop);
|
||||
lstrcpyn(str,th->text,size?size:g_stringsize);
|
||||
*g_stacktop = th->next;
|
||||
GlobalFree((HGLOBAL)th);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NSDFUNC pushstring(const char *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop) return;
|
||||
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
|
||||
lstrcpyn(th->text,str,g_stringsize);
|
||||
th->next=*g_stacktop;
|
||||
*g_stacktop=th;
|
||||
}
|
||||
|
||||
int NSDFUNC popint()
|
||||
{
|
||||
char buf[1024];
|
||||
if (popstring(buf,sizeof(buf)))
|
||||
return 0;
|
||||
|
||||
return myatoi(buf);
|
||||
}
|
||||
|
||||
void NSDFUNC pushint(int value)
|
||||
{
|
||||
char buffer[1024];
|
||||
wsprintf(buffer, "%d", value);
|
||||
pushstring(buffer);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef __NS_DIALOGS__NSIS_H__
|
||||
#define __NS_DIALOGS__NSIS_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include "defs.h"
|
||||
|
||||
#define EXDLL_INIT() { \
|
||||
g_stringsize=string_size; \
|
||||
g_stacktop=stacktop; \
|
||||
g_variables=variables; }
|
||||
|
||||
// For page showing plug-ins
|
||||
#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
|
||||
#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
|
||||
#define NOTIFY_BYE_BYE 'x'
|
||||
|
||||
typedef struct _stack_t {
|
||||
struct _stack_t *next;
|
||||
char text[1]; // this should be the length of string_size
|
||||
} stack_t;
|
||||
|
||||
extern int g_stringsize;
|
||||
extern stack_t **g_stacktop;
|
||||
extern char *g_variables;
|
||||
|
||||
int NSDFUNC myatoi(const char *s);
|
||||
int NSDFUNC popstring(char *str, int size);
|
||||
void NSDFUNC pushstring(const char *str);
|
||||
int NSDFUNC popint();
|
||||
void NSDFUNC pushint(int value);
|
||||
|
||||
typedef struct {
|
||||
int autoclose;
|
||||
int all_user_var;
|
||||
int exec_error;
|
||||
int abort;
|
||||
int exec_reboot;
|
||||
int reboot_called;
|
||||
int XXX_cur_insttype; // deprecated
|
||||
int XXX_insttype_changed; // deprecated
|
||||
int silent;
|
||||
int instdir_error;
|
||||
int rtl;
|
||||
int errlvl;
|
||||
int alter_reg_view;
|
||||
} exec_flags_type;
|
||||
|
||||
typedef struct {
|
||||
exec_flags_type *exec_flags;
|
||||
int (__stdcall *ExecuteCodeSegment)(int, HWND);
|
||||
void (__stdcall *validate_filename)(char *);
|
||||
} extra_parameters;
|
||||
|
||||
|
||||
#endif//__NS_DIALOGS__NSIS_H__
|
|
@ -1,8 +1,9 @@
|
|||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
#include <plugin.h> // nsis plugin.h
|
||||
|
||||
#include "defs.h"
|
||||
#include "nsis.h"
|
||||
|
||||
#ifndef WS_EX_RIGHT
|
||||
# define WS_EX_RIGHT 0x1000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue