mgillespie
16th July 2003 17:54 UTC
Maximum size of stack items.
I have a plugin DLL I wrote in C++, and it works a treat. It's quite a complex dll, and I want it to keep a log of it's actions, and any problems, and pass that back to the install script to log (I am using the optional enhanced logging).
The my DLL logfile does get quite large (a few KB).
This kinda works, but the log gets truncated. I have checked my code, and it seems to be putting it onto the stack OK, but the install engine is not retrieving it all, and truncates it.
Is this a known limitatation? Are they any other ways of doing this?
Thanks.
kichik
16th July 2003 18:02 UTC
Are you trying to put it all in one line? If so, then that must be the problem because NSIS uses wsprintf to format the log string. But wsprintf is limited to 1024. NSIS strings are also limited to 1024 bytes by default and so are stack items.
Try splitting it to a few lines, that should probably do the trick.
mgillespie
16th July 2003 18:18 UTC
I build the string up as 1 big logfile with \n newline chars to seperate eash log item, when the function finished, I stick the complete log onto the stack and pop it back off from within the script.
Is this correct?
Or are you suggesting that I stick each log item on the stack indivudually and keep track of how many items there are, pass that back and then pop them off 1 by 1? (could be hairy)
kichik
16th July 2003 18:24 UTC
It's not correct. What you've said is your only option, unless you want to increase the stack item size. But it's not recommended because it would just waste memory and to ensure it's enough you'd have to waste a lot.
Afrow UK
16th July 2003 18:25 UTC
It's the only way, because if you're string is longer than 1024 chars, then when you pop it off the stack into NSIS (as a variable) then it will be chopped down to 1024 strlen.
You will have to write each line to the stack one by one.
A good thing to do is to write ":end:" to the stack as the last string.
Then you can keep popping off the stack in NSIS, until the Popped string is :end: to signify to stop popping.
-Stu
kichik
16th July 2003 18:27 UTC
It's actually chopped when pushed. Stack items have constant size.
mgillespie
16th July 2003 21:43 UTC
Well I kinda got things working now. I modified my plugin source to add all the log items to the stack, at the start of the DLL code (after popping off any passed in params), I add my ENDLOG flag. My problem is now, is that the log is in reverse order. Is there a simple way to reverse it, should I do it script side, or plugin cpp side?
Thanks.
;/////////////////////////////////////////////////////////////////////
;//
;// Section - WritePluginLog
;//
;// Description - pulls all the entries backwards off the stack
;// until it finds the end (start) of the Plugin log.
;//
;/////////////////////////////////////////////////////////////////////
Function "WritePluginLog"
StartPopping:
Pop $R6
StrCmp $R6 "ENDLOG:" NoMore OutputDebug
OutputDebug:
LogText $R6
Goto StartPopping
NoMore:
FunctionEnd
kichik
16th July 2003 21:47 UTC
Doing it on the plug-in side would probably be easier because you can simply change pushstring to make the stack act as a queue. The source of pushstring is in ExDLL.h.