/admin/win/nsi/nsis_processes/src/exdll.h
C++ Header | 136 lines | 83 code | 43 blank | 10 comment | 9 complexity | 42c22cab90699ca70255c708854439df MD5 | raw file
1#ifndef _EXDLL_H_ 2#define _EXDLL_H_ 3 4 5 6 7 8// 9// only include this file from one place in your DLL. 10// (it is all static, if you use it in two places it will fail) 11// 12#define EXDLL_INIT() { \ 13 g_stringsize = string_size; \ 14 g_stacktop = stacktop; \ 15 g_variables = variables; } 16 17 18 19 20// 21// For page showing plug-ins 22// 23#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) 24#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd) 25#define NOTIFY_BYE_BYE 'x' 26 27typedef struct _stack_t 28{ 29 struct _stack_t *next; 30 char text[1]; // this should be the length of string_size 31} stack_t; 32 33 34static unsigned int g_stringsize; 35static stack_t **g_stacktop; 36static char *g_variables; 37 38enum 39{ 40INST_0, // $0 41INST_1, // $1 42INST_2, // $2 43INST_3, // $3 44INST_4, // $4 45INST_5, // $5 46INST_6, // $6 47INST_7, // $7 48INST_8, // $8 49INST_9, // $9 50INST_R0, // $R0 51INST_R1, // $R1 52INST_R2, // $R2 53INST_R3, // $R3 54INST_R4, // $R4 55INST_R5, // $R5 56INST_R6, // $R6 57INST_R7, // $R7 58INST_R8, // $R8 59INST_R9, // $R9 60INST_CMDLINE, // $CMDLINE 61INST_INSTDIR, // $INSTDIR 62INST_OUTDIR, // $OUTDIR 63INST_EXEDIR, // $EXEDIR 64INST_LANG, // $LANGUAGE 65__INST_LAST 66}; 67 68 69 70 71 72// 73// utility functions (not required but often useful) 74// 75static int popstring( char *str ) 76{ 77 stack_t *th; 78 79 80 if( !g_stacktop || 81 !*g_stacktop ) 82 return 1; 83 84 th = (*g_stacktop); 85 lstrcpy( str, th->text ); 86 *g_stacktop = th->next; 87 GlobalFree( (HGLOBAL)th ); 88 89 return 0; 90} 91 92 93 94 95static void pushstring( char *str ) 96{ 97 stack_t *th; 98 99 100 if( !g_stacktop ) 101 return; 102 103 th = (stack_t*)GlobalAlloc( GPTR, sizeof(stack_t) + g_stringsize ); 104 lstrcpyn( th->text, str, g_stringsize ); 105 th->next = *g_stacktop; 106 *g_stacktop = th; 107} 108 109 110 111 112 113static char *getuservariable( int varnum ) 114{ 115 if( varnum < 0 || 116 varnum >= __INST_LAST ) 117 return NULL; 118 119 return (g_variables + varnum*g_stringsize); 120} 121 122 123 124 125 126static void setuservariable( int varnum, char *var ) 127{ 128 if( var != NULL && 129 varnum >= 0 && 130 varnum < __INST_LAST ) 131 lstrcpy( g_variables + varnum*g_stringsize, var ); 132} 133 134 135 136#endif//_EXDLL_H_