this patch adds 4 functions to the xchat plugin api:
- int xchat_set_pluginpref_str (xchat_plugin *ph, char *var, char *value)
- int xchat_get_pluginpref_str (xchat_plugin *ph, char *var, char *dest)
- int xchat_set_pluginpref_int (xchat_plugin *ph, char *var, int value);
- int xchat_get_pluginpref_int (xchat_plugin *ph, char *var);
and a helper function to util.c, which sanitizes filenames generated from plugin names (only alphanumeric values and _ are allowed). all config is saved in the default xchat profile dir, prefixed with plugin_. example: for "Do At" would be plugin_do_at.conf.
example set_str: xchat_set_pluginpref_str (ph, "var1", "asdf");
example get_str: xchat_get_pluginpref_str (ph, "var1", buffer);
example set_int: xchat_set_pluginpref_int (ph, "var2", 1234);
example get_int: int result = xchat_get_pluginpref_int (ph, "var2");
all functions return 0 for failure and 1 for success (like other functions) except xchat_get_pluginpref_int which returns the requested value, unless it failed to read it, in which case it returns -1.
patch was made for svn head, r1498 at the time of writing.
added an updated version of the patch, changes:
- use const chars where possible (like other plugin api commands)
- fix a cfgfiles.c bug where cfg_get_str could return a wrong value (when varnames include each other) which in turn could cause the client to crash
another update, which adds documentiation about the new functions in plugin20.html.
one more update, it adds an example to the xchat_set_pluginpref_int section in the documentation