other-licenses/nsis/Contrib/ExDLL/exdllutil.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:e95c22c2c65a
1 // Unicode support by Jim Park -- 08/23/2007
2 // Jim Park: Should probably turn this into a nice class for C++ programs.
3
4 #pragma once
5 #include <windows.h>
6 #include <tchar.h>
7 // only include this file from one place in your DLL.
8 // (it is all static, if you use it in two places it will fail)
9
10 #define EXDLL_INIT() { \
11 g_stringsize=string_size; \
12 g_stacktop=stacktop; \
13 g_variables=variables; }
14
15 // For page showing plug-ins
16 #define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8)
17 #define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd)
18
19 /* Jim Park: This char is compared as an int value and therefore
20 it's fine as an ASCII. Do not need to change to wchar_t since
21 it will get the same integer value. */
22 #define NOTIFY_BYE_BYE _T('x')
23
24 typedef struct _stack_t {
25 struct _stack_t *next;
26 TCHAR text[1]; // this should be the length of string_size
27 } stack_t;
28
29 static unsigned int g_stringsize;
30 static stack_t **g_stacktop;
31 static TCHAR *g_variables;
32
33
34 enum
35 {
36 INST_0, // $0
37 INST_1, // $1
38 INST_2, // $2
39 INST_3, // $3
40 INST_4, // $4
41 INST_5, // $5
42 INST_6, // $6
43 INST_7, // $7
44 INST_8, // $8
45 INST_9, // $9
46 INST_R0, // $R0
47 INST_R1, // $R1
48 INST_R2, // $R2
49 INST_R3, // $R3
50 INST_R4, // $R4
51 INST_R5, // $R5
52 INST_R6, // $R6
53 INST_R7, // $R7
54 INST_R8, // $R8
55 INST_R9, // $R9
56 INST_CMDLINE, // $CMDLINE
57 INST_INSTDIR, // $INSTDIR
58 INST_OUTDIR, // $OUTDIR
59 INST_EXEDIR, // $EXEDIR
60 INST_LANG, // $LANGUAGE
61 __INST_LAST
62 };
63
64 typedef struct {
65 int autoclose;
66 int all_user_var;
67 int exec_error;
68 int abort;
69 int exec_reboot;
70 int reboot_called;
71 int XXX_cur_insttype; // deprecated
72 int XXX_insttype_changed; // deprecated
73 int silent;
74 int instdir_error;
75 int rtl;
76 int errlvl;
77 int alter_reg_view;
78 } exec_flags_type;
79
80 typedef struct {
81 exec_flags_type *exec_flags;
82 int (__stdcall *ExecuteCodeSegment)(int, HWND);
83 void (__stdcall *validate_filename)(TCHAR *);
84 } extra_parameters;
85
86 static int __stdcall popstring(TCHAR *str); // 0 on success, 1 on empty stack
87 static void __stdcall pushstring(const TCHAR *str);
88 static char * __stdcall getuservariable(const int varnum);
89 static void __stdcall setuservariable(const int varnum, const TCHAR *var);
90
91 #ifdef _UNICODE
92 #define PopStringW(x) popstring(x)
93 #define PushStringW(x) pushstring(x)
94 #define SetUserVariableW(x,y) setuservariable(x,y)
95
96 static int __stdcall PopStringA(char* ansiStr);
97 static void __stdcall PushStringA(const char* ansiStr);
98 static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
99 static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
100 static void __stdcall SetUserVariableA(const int varnum, const char* ansiStr);
101
102 #else
103 // ANSI defs
104
105 #define PopStringA(x) popstring(x)
106 #define PushStringA(x) pushstring(x)
107 #define SetUserVariableA(x,y) setuservariable(x,y)
108
109 static int __stdcall PopStringW(wchar_t* wideStr);
110 static void __stdcall PushStringW(wchar_t* wideStr);
111 static void __stdcall GetUserVariableW(const int varnum, wchar_t* wideStr);
112 static void __stdcall GetUserVariableA(const int varnum, char* ansiStr);
113 static void __stdcall SetUserVariableW(const int varnum, const wchar_t* wideStr);
114
115 #endif
116
117 static BOOL __stdcall IsUnicode(void)
118 static TCHAR* __stdcall AllocString();
119

mercurial