Debian Codegraph @

Contrib/ExDLL/pluginapi.h

raw
1 #ifndef ___NSIS_PLUGIN__H___
2 #define ___NSIS_PLUGIN__H___
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #include "api.h"
9 #include "nsis_tchar.h" // BUGBUG: Why cannot our plugins use the compilers tchar.h?
10
11 #ifndef NSISCALL
12 # define NSISCALL WINAPI
13 #endif
14
15 #define EXDLL_INIT() { \
16 g_stringsize=string_size; \
17 g_stacktop=stacktop; \
18 g_variables=variables; }
19
20 typedef struct _stack_t {
21 struct _stack_t *next;
22 #ifdef UNICODE
23 WCHAR text[1]; // this should be the length of g_stringsize when allocating
24 #else
25 char text[1];
26 #endif
27 } stack_t;
28
29 enum
30 {
31 INST_0, // $0
32 INST_1, // $1
33 INST_2, // $2
34 INST_3, // $3
35 INST_4, // $4
36 INST_5, // $5
37 INST_6, // $6
38 INST_7, // $7
39 INST_8, // $8
40 INST_9, // $9
41 INST_R0, // $R0
42 INST_R1, // $R1
43 INST_R2, // $R2
44 INST_R3, // $R3
45 INST_R4, // $R4
46 INST_R5, // $R5
47 INST_R6, // $R6
48 INST_R7, // $R7
49 INST_R8, // $R8
50 INST_R9, // $R9
51 INST_CMDLINE, // $CMDLINE
52 INST_INSTDIR, // $INSTDIR
53 INST_OUTDIR, // $OUTDIR
54 INST_EXEDIR, // $EXEDIR
55 INST_LANG, // $LANGUAGE
56 __INST_LAST
57 };
58
59 extern unsigned int g_stringsize;
60 extern stack_t **g_stacktop;
61 extern LPTSTR g_variables;
62
63 void NSISCALL pushstring(LPCTSTR str);
64 void NSISCALL pushintptr(INT_PTR value);
65 #define pushint(v) pushintptr((INT_PTR)(v))
66 int NSISCALL popstring(LPTSTR str); // 0 on success, 1 on empty stack
67 int NSISCALL popstringn(LPTSTR str, int maxlen); // with length limit, pass 0 for g_stringsize
68 INT_PTR NSISCALL popintptr();
69 #define popint() ( (int) popintptr() )
70 int NSISCALL popint_or(); // with support for or'ing (2|4|8)
71 INT_PTR NSISCALL nsishelper_str_to_ptr(LPCTSTR s);
72 #define myatoi(s) ( (int) nsishelper_str_to_ptr(s) ) // converts a string to an integer
73 unsigned int NSISCALL myatou(LPCTSTR s); // converts a string to an unsigned integer, decimal only
74 int NSISCALL myatoi_or(LPCTSTR s); // with support for or'ing (2|4|8)
75 LPTSTR NSISCALL getuservariable(const int varnum);
76 void NSISCALL setuservariable(const int varnum, LPCTSTR var);
77
78 #ifdef UNICODE
79 #define PopStringW(x) popstring(x)
80 #define PushStringW(x) pushstring(x)
81 #define SetUserVariableW(x,y) setuservariable(x,y)
82
83 int NSISCALL PopStringA(LPSTR ansiStr);
84 void NSISCALL PushStringA(LPCSTR ansiStr);
85 void NSISCALL GetUserVariableW(const int varnum, LPWSTR wideStr);
86 void NSISCALL GetUserVariableA(const int varnum, LPSTR ansiStr);
87 void NSISCALL SetUserVariableA(const int varnum, LPCSTR ansiStr);
88
89 #else
90 // ANSI defs
91
92 #define PopStringA(x) popstring(x)
93 #define PushStringA(x) pushstring(x)
94 #define SetUserVariableA(x,y) setuservariable(x,y)
95
96 int NSISCALL PopStringW(LPWSTR wideStr);
97 void NSISCALL PushStringW(LPWSTR wideStr);
98 void NSISCALL GetUserVariableW(const int varnum, LPWSTR wideStr);
99 void NSISCALL GetUserVariableA(const int varnum, LPSTR ansiStr);
100 void NSISCALL SetUserVariableW(const int varnum, LPCWSTR wideStr);
101
102 #endif
103
104 #ifdef __cplusplus
105 }
106 #endif
107
108 #endif//!___NSIS_PLUGIN__H___