pluginapi.h 2.9 KB

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