Archive: Plugin arguments question


Plugin arguments question
In a plugin procedure, how can I know or detect the many of arguments inputed by the user?


popstring until it returns something other than 0


I though that I will be something in:


(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)

ooops (from NSIS\Contrib\ExDLL\exdll.c):
you should empty the stack of your parameters, and ONLY your
parameters.

so i guess its not so smart to popstring like that.

the way the system plugin does it(i think, was to lazy to check) is to have all parameters in one string and then it parses that string


The Banner plugin uses popstring I think...

-Stu


Originally posted by Lobo Lunar
I though that I will be something in:

(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
yes, i think you could parse the variables string


Originally posted by Afrow UK
The Banner plugin uses popstring I think...

-Stu
yes The Banner plugin and alot of other plugins use popstring, but not like this:

while( popstring(buf)==0 )DoSomething(but); //<--bad, dont do this

I think that it will be a nice idea to have this, with it the developer can stop the execution when isn't enough paramters...


while( popstring(buf)==0 )DoSomething(but); //<--bad, dont do this
Because buf will be null if you use the function and all the strings poped are destroyed in this case.

I suggest you to make a counter, like:

int nCounter;
char* buf;

while(popstring(buf)) {
nCounter += 1;

// Do something with the string or you'll lose it...
}

the easy option is to have a known end item such as '--' and only take off values upto then. that's what kichik suggested when i asked way back.

if the plugin has a fixed parameter list then just a fixed number of popstrings is fine, it's variable ones that cause the most problems and other values already on the stack don't help things either. but that's how things are with plugins at the moment.

-daz