diff options
author | Berke Viktor <berkeviktor@aol.com> | 2011-12-02 15:37:40 +0100 |
---|---|---|
committer | Berke Viktor <berkeviktor@aol.com> | 2011-12-02 15:37:40 +0100 |
commit | 71036733e31a72fa49bc992d8ca7217774c8e00c (patch) | |
tree | b9f42cce90de2151489a18b32efd5ee500721f9d /plugins/plugin20.html | |
parent | 588c862f662eef73b100e2170dc5484b56ee1526 (diff) |
add example for sanitizing xchat_set_pluginpref_int input
Diffstat (limited to 'plugins/plugin20.html')
-rw-r--r-- | plugins/plugin20.html | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/plugins/plugin20.html b/plugins/plugin20.html index b36490ba..a9aaaace 100644 --- a/plugins/plugin20.html +++ b/plugins/plugin20.html @@ -1068,7 +1068,32 @@ You should never need to edit this file manually. <br> </blockquote> <b>Returns:</b> 1 for success, 0 for failure. -<br><br><br> +<br><br><b>Example:</b> +<blockquote> +<pre>static int saveint_cb (char *word[], char *word_eol[], void *user_data) +{ + int buffer = atoi (word[2]); + + if (buffer > 0 && buffer < INT_MAX) + { + if (xchat_set_pluginpref_int (ph, "myint1", buffer)) + { + xchat_printf (ph, "Setting successfully saved!\n"); + } + else + { + xchat_printf (ph, "Error while saving!\n"); + } + } + else + { + xchat_printf (ph, "Invalid input!\n"); + } + + return XCHAT_EAT_XCHAT; +}</pre> +</blockquote> +<br><br> <h3><a class=cmd name="xchat_get_pluginpref_int"> xchat_get_pluginpref_int() </a><small>(new for 2.8.10)</small></h3> <b>Prototype:</b> int xchat_get_pluginpref_int (xchat_plugin *ph, const char *var); |