pluginapi.h 3.0 KB

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