<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>XChat 2.0 Plugin Interface</title>
<style type="text/css">
<!--
body {
font-family: sans-serif;
background-color: #FFFBF0;
}
.cmd {
background-color: #dddddd;
color: #990066
}
.bbox {
font-family: monospace;
color: #fdfdfd;
background-color: #000;
border: 1px solid #00f;
padding: 4px;
text-align: left;
margin-left: 32px;
margin-right: 32px;
}
.box {
background-color: #ddddee;
border: 1px solid #000;
padding: 4px;
text-align: left;
margin-left: 32px;
margin-right: 32px;
}
-->
</style>
</head>
<body bgcolor="#FFFBF0" text="#000" link="#607060" vlink="#607060" alink="#607060">

<h1>XChat 2.0 Plugin Interface</h1>

<small>
<font size="-12">plugin20.html revision 2.86</font>
<br>Latest version of this document is available at: <a href="http://xchat.org/docs/plugin20.html">http://xchat.org/docs/plugin20.html</a></small>

<h2>1. Documentation:</h2>
<blockquote>
<a href="#intro">1.0 Introduction</a>
<br><a href="#sample">1.1 Sample plugin</a>
<br><a href="#word">1.2 What is word and word_eol?</a>
<br><a href="#lists">1.3 Lists and fields</a>
<br><a href="#win32">1.4 Plugins on Windows (Win32)</a>
<br><a href="#gui">1.5 Controlling the GUI</a>
<br>&nbsp; <a href="#gui">1.5.1 Basic Control</a>
<br>&nbsp; <a href="#menu">1.5.2 Custom Menu Items</a>
<br>&nbsp; <a href="#tray">1.5.3 System Tray</a>
<br><a href="#unicode">1.6 Handling UTF-8/Unicode strings</a>
</blockquote>

<h2>2. Function reference:</h2>
<blockquote>
<a href="#xchat_hook_command">xchat_hook_command</a>
<br><a href="#xchat_hook_fd">xchat_hook_fd</a>
<br><a href="#xchat_hook_print">xchat_hook_print</a>
<br><a href="#xchat_hook_server">xchat_hook_server</a>
<br><a href="#xchat_hook_timer">xchat_hook_timer</a>
<br><a href="#xchat_unhook">xchat_unhook</a>
<br>
<br><a href="#xchat_command">xchat_command</a>
<br><a href="#xchat_commandf">xchat_commandf</a>
<br><a href="#xchat_print">xchat_print</a>
<br><a href="#xchat_printf">xchat_printf</a>
<br><a href="#xchat_emit_print">xchat_emit_print</a>
<br><a href="#xchat_send_modes">xchat_send_modes</a>
<br>
<br><a href="#xchat_find_context">xchat_find_context</a>
<br><a href="#xchat_get_context">xchat_get_context</a>
<br><a href="#xchat_get_info">xchat_get_info</a>
<br><a href="#xchat_get_prefs">xchat_get_prefs</a>
<br><a href="#xchat_set_context">xchat_set_context</a>
<br>
<br><a href="#xchat_nickcmp">xchat_nickcmp</a>
<br><a href="#xchat_strip">xchat_strip</a>
<br><a href="#xchat_free">xchat_free</a>
<br>
<br><a href="#xchat_pluginpref_set_str">xchat_pluginpref_set_str</a>
<br><a href="#xchat_pluginpref_get_str">xchat_pluginpref_get_str</a>
<br><a href="#xchat_pluginpref_set_int">xchat_pluginpref_set_int</a>
<br><a href="#xchat_pluginpref_get_int">xchat_pluginpref_get_int</a>
<br><a href="#xchat_pluginpref_delete">xchat_pluginpref_delete</a>
<br><a href="#xchat_pluginpref_list">xchat_pluginpref_list</a>
<br>
<br><a href="#lists">xchat_list_get</a>
<br><a href="#lists">xchat_list_free</a>
<br><a href="#lists">xchat_list_fields</a> (not documented yet)
<br><a href="#lists">xchat_list_next</a>
<br><a href="#lists">xchat_list_str</a>
<br><a href="#lists">xchat_list_int</a>
<br><a href="#lists">xchat_list_time</a>
<br>
<br><a href="#xchat_plugingui_add">xchat_plugingui_add</a> (not documented yet)
<br><a href="#xchat_plugingui_remove">xchat_plugingui_remove</a> (not documented yet)
</blockquote><br>

<h3><a name=intro>Introduction</a></h3>
Plugins for XChat are written in C. The interface aims to keep 100%
binary compatability. This means that if you upgrade XChat, you will
not need to recompile your plugins, they'll continue to work. The
interface doesn't depend on any structures and offsets, so compiler
versions shouldn't have an impact either. The only real requirement of
an XChat plugin, is that it define a "xchat_plugin_init" symbol. This
is your entry point function, see the example below. You should make
all your global variables and functions <i>static</i>, so that a symbol
is not exported. There is no harm in exporting these symbols, but they
are not necessary and only pollute the name-space. Plugins are compiled as shared objects
(.so files), for example:
<br><br>
Most UNIX systems:<pre>
	gcc -Wl,--export-dynamic -Wall -O1 -shared -fPIC myplugin.c -o myplugin.so
</pre>
MacOSX:<pre>
	gcc -no-cpp-precomp -g -O2 -Wall -bundle -flat_namespace -undefined suppress -o myplugin.so myplugin.c
</pre>

See the <a href="#win32">Windows section</a> on how to compile a plugin
using visual studio.
<p>
All strings passed to and from plugins are encoded in UTF-8, regardless
of locale. <a href="#unicode">What does this mean</a>?
</p><br>

<h3><a name=sample>Sample plugin</a></h3>
This simple plugin autoOps anyone who joins a channel you're in. It also
adds a new command /AUTOOPTOGGLE, which can be used to turn the feature ON
or OFF. Every XChat plugin must define an xchat_plugin_init function, this
is the normal entry point. xchat_plugin_deinit is optional.
<br>
<div style="color: #ffffff; background-color: #111199;">
<pre>

<font color="#00ff00">#include </font><font color="#00ffff">&quot;xchat-plugin.h&quot;</font>

<font color="#00ff00">#define PNAME </font><font color="#00ffff">&quot;AutoOp&quot;</font>
<font color="#00ff00">#define PDESC </font><font color="#00ffff">&quot;Auto Ops anyone that joins&quot;</font>
<font color="#00ff00">#define PVERSION </font><font color="#00ffff">&quot;0.1&quot;</font>

<font color="#ffa500"><b>static</b></font> xchat_plugin *ph;   <font color="#bebebe"><b>/*</b></font><font color="#bebebe"><b> plugin handle </b></font><font color="#bebebe"><b>*/</b></font>
<font color="#ffa500"><b>static</b></font> <font color="#ffa500"><b>int</b></font> enable = <font color="#00ffff">1</font>;

<font color="#ffa500"><b>static</b></font> <font color="#ffa500"><b>int</b></font> join_cb(<font color="#ffa500"><b>char</b></font> *word[], <font color="#ffa500"><b>void</b></font> *userdata)
{
   <font color="#ffff00">if</font> (enable)
      <font color="#bebebe"><b>/*</b></font><font color="#bebebe"><b> Op ANYONE who joins </b></font><font color="#bebebe"><b>*/</b></font>
      xchat_commandf(ph, <font color="#00ffff">&quot;OP </font><font color="#ff00ff">%s</font><font color="#00ffff">&quot;</font>, word[<font color="#00ffff">1</font>]);
   <font color="#bebebe"><b>/*</b></font><font color="#bebebe"><b> word[1] is the nickname, as in the Settings-&gt;Advanced-&gt;TextEvents window in xchat </b></font><font color="#bebebe"><b>*/</b></font>

   <font color="#ffff00">return</font> XCHAT_EAT_NONE;  <font color="#bebebe"><b>/*</b></font><font color="#bebebe"><b> don't eat this event, xchat needs to see it! </b></font><font color="#bebebe"><b>*/</b></font<style>pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="cm">/*</span>
<span class="cm"> * match.h - matching header for X-Sys</span>
<span class="cm"> * Copyright (C) 2005 Tony Vroon</span>
<span class="cm"> *</span>
<span class="cm"> * This program is free software; you can redistribute it and/or modify</span>
<span class="cm"> * it under the terms of the GNU General Public License as published by</span>
<span class="cm"> * the Free Software Foundation; either version 2 of the License, or</span>
<span class="cm"> * (at your option) any later version.</span>
<span class="cm"> *</span>
<span class="cm"> * This program is distributed in the hope that it will be useful,</span>
<span class="cm"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="cm"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="cm"> * GNU General Public License for more details.</span>
<span class="cm"> *</span>
<span class="cm"> * You should have received a copy of the GNU General Public License</span>
<span class="cm"> * along with this program; if not, write to the Free Software</span>
<span class="cm"> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA</span>
<span class="cm"> */</span>

<span class="cp">#ifndef _MATCH_H_</span>
<span class="cp">#define _MATCH_H_</span>

<span class="kt">void</span><span class="w"> </span><span class="nf">find_match_char</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">match</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">result</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">find_match_double</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">match</span><span class="p">,</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="o">*</span><span class="n">result</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">find_match_double_hex</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">match</span><span class="p">,</span><span class="w"> </span><span class="kt">double</span><span class="w"> </span><span class="o">*</span><span class="n">result</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">find_match_int</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">match</span><span class="p">,</span><span class="w"> </span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">result</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">find_match_ll</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">match</span><span class="p">,</span><span class="w"> </span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="o">*</span><span class="n">result</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">format_output</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">arg</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">string</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">format</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">flat_format_output</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">arg</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">string</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">format</span><span class="p">);</span>
<span class="kt">float</span><span class="w"> </span><span class="nf">percentage</span><span class="p">(</span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="o">*</span><span class="n">free</span><span class="p">,</span><span class="w"> </span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="o">*</span><span class="n">total</span><span class="p">);</span>
<span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="nf">pretty_freespace</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">desc</span><span class="p">,</span><span class="w"> </span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="o">*</span><span class="n">free_k</span><span class="p">,</span><span class="w"> </span><span class="kt">unsigned</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="kt">long</span><span class="w"> </span><span class="o">*</span><span class="n">total_k</span><span class="p">);</span>
<span class="kt">void</span><span class="w"> </span><span class="nf">remove_leading_whitespace</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">);</span>
<span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="nf">decruft_filename</span><span class="p">(</span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">buffer</span><span class="p">);</span>

<span class="cp">#endif</span>
</pre></div>
</code></pre></div></td>
</tr>
</table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.causal.agency/cgit-pink/about/'>cgit-pink 1.4.1</a> (<a href='https://git-scm.com/'>git 2.36.1</a>) at 2025-03-21 02:48:26 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
2/testing/xcdns-src.zip">DNS Plugin</a>, which also contains a Makefile.
<br><br>
<font color=red>Caveat:</font> Plugins compiled on Win32 MUST have a
global variable called <b>ph</b>, which is the plugin_handle, much like
in the <a href="#sample">sample plugin</a> above.
<br><br>

<h3><a name=gui>Controlling the GUI</a></h3>
<p>
A simple way to perform basic GUI functions is to use the /GUI command.
You can execute this command through the input-box, or by calling
xchat_command(ph, "GUI .....");.
</p>
<blockquote>
	<table border=0 cellpadding=4>
	<tr><td>GUI ATTACH</td><td>Same function as "Attach Window" in the XChat menu (new for 2.6.2).</td></tr>
	<tr><td>GUI DETACH</td><td>Same function as "Detach Tab" in the XChat menu (new for 2.6.2).</td></tr>
	<tr><td>GUI APPLY</td><td>Similar to clicking OK in the settings window. Execute this after /SET to activate GUI changes (new for 2.8.0)</td></tr>
	<tr><td>GUI COLOR <i>n</i></td><td>Change the tab color of the current context, where n is a number from 0 to 3.</td></tr>
	<tr><td>GUI FOCUS</td><td>Focus the current window or tab.</td></tr>
	<tr><td>GUI FLASH</td><td>Flash the taskbar button. It will flash only if the window isn't focused and will stop when it is focused by the user.</td></tr>
	<tr><td>GUI HIDE</td><td>Hide the main xchat window completely (this is used by the Systray plugin).</td></tr>
	<tr><td>GUI ICONIFY</td><td>Iconify (minimize to taskbar) the current xchat window.</td></tr>
	<tr><td>GUI MSGBOX <i>text</i></td><td>Displays a asynchronous message box with your text (new for 2.4.5).</td></tr>
	<tr><td>GUI SHOW</td><td>Show the main xchat window (if currently hidden).</td></tr>
	</table>
</blockquote>
<p>
Note, the FLASH, ICONIFY and COLOR args were added in xchat 2.0.8, they
will not work with previous versions.
</p>
<a name=menu>Starting from 2.4.5 you can add your own items to the menu bar. The menu command has this syntax</a>:
<pre>
	MENU [-eX] [-i&lt;ICONFILE>] [-k&lt;mod>,&lt;key>] [-m] [-pX] [-rX,group] [-tX] {ADD|DEL} &lt;path> [command] [unselect command]</pre>
For example:
<pre>
	MENU -p5 ADD FServe
	MENU ADD "FServe/Show File List" "fs list"
	MENU ADD FServe/-
	MENU -k4,101 -t1 ADD "FServe/Enabled" "fs on" "fs off"
	MENU -e0 ADD "FServe/Do Something" "fs action"
</pre>
In the example above, it would be recommended to execute "MENU DEL FServe" inside your xchat_plugin_deinit function. The special item with name "-" will add a separator line.
<br><br>
Parameters and flags:
<blockquote>
<table border=1 cellpadding=4 rules=all>
<tr><td>-eX</td><td>Set enable flag to X. -e0 for disable, -e1 for enable. This lets you create a disabled (shaded) item.</td></tr>
<tr><td>-iFILE</td><td>Use an icon filename FILE (new for 2.8.0). Not supported for toggles or radio items.</td></tr>
<tr><td>-k&lt;mod>,&lt;key></td><td>Specify a keyboard shortcut. "mod" is the modifier which is a bitwise OR of: 1-SHIFT 4-CTRL 8-ALT in decimal. "key" is the key value in decimal, e.g. -k5,101 would specify SHIFT-CTRL-E.</td></tr>
<tr><td>-m</td><td>Specify that this label should be treated as <a href="http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html">Pango Markup</a> language. Since forward slash ("/") is already used in menu paths, you should replace closing tags with an ASCII 003 instead e.g.: xchat_command(ph, "MENU -m ADD \"&lt;b>Bold Menu&lt;\003b>\""); (new for 2.6.6).</td></tr>
<tr><td>-pX</td><td>Specify a menu item's position number. e.g. -p5 will cause the item to be inserted in the 5th place. New for 2.8.0: If the position is a negative number, it will be used as an offset from the bottom/right-most item.</td></tr>
<tr><td>-rX,group</td><td>Specify a radio menu item, with initial state X and a group name (new for 2.8.0). The group name should be the exact label of another menu item (without the path) that this item will be grouped with. For radio items, only a select command will be executed (no unselect command).</td></tr>
<tr><td>-tX</td><td>Specify a toggle menu item with an initial state. -t0 for an "unticked" item and -t1 for a "ticked" item.</td></tr>
</table>
</blockquote>

If you want to change an item's toggle state or enabled flag,
just ADD an item with exactly the same name and command and specify the -tX -eX parameters you need.
<br><br>It's also possible to add items to XChat's existing menus, for example:<br>
<pre>	MENU ADD "Settings/Sub Menu"
	MENU -t0 ADD "Settings/Sub Menu/My Setting" myseton mysetoff
</pre>
However, internal names and layouts of XChat's menu may change in the future, so use at own risk.
<br><br>
Here is an example of Radio items:
<pre>	MENU ADD "Language"
	MENU -r1,"English" ADD "Language/English" cmd1
	MENU -r0,"English" ADD "Language/Spanish" cmd2
	MENU -r0,"English" ADD "Language/German" cmd3</pre>
<br>
From 2.8.0, you can also change menus other than the main one (i.e popup menus). Currently they are:
<blockquote>
<table border=1 cellpadding=4 rules=all>
<tr bgcolor="#999999"><td>Root Name</td><td>Menu</td></tr>
<tr><td>$TAB</td><td>Tab menu (right click a channel/query tab or treeview row)</td></tr>
<tr><td>$TRAY</td><td>System Tray menu</td></tr>
<tr><td>$URL</td><td>URL link menu</td></tr>
<tr><td>$NICK</td><td>Userlist nick-name popup menu</td></tr>
<tr><td>$CHAN</td><td>Menu when clicking a channel in the text area (since 2.8.4)</td></tr>

</table>
</blockquote>
<pre>
	Example: MENU -p0 ADD "$TAB/Cycle Channel" cycle
</pre>

<br>
<a name=tray>Starting from 2.8.0 you can manipulate XChat's system tray icon using the /TRAY command</a>:
<pre>
 Usage: 
 TRAY -f &lt;timeout> &lt;file1> [&lt;file2>] Flash tray between two icons. Leave off file2 to use default xchat icon.
 TRAY -f &lt;filename>                  Set tray to a fixed icon.
 TRAY -i &lt;number>                    Flash tray with an internal icon.
                                     <small>2=Message 5=Highlight 8=Private 11=File</small>
 TRAY -t &lt;text>                      Set the tray tooltip.
 TRAY -b &lt;title> &lt;text>              Set the tray balloon.
                                     <small>Supported on Windows from 2.8.1 and 2.8.2 on Linux (libnotify required on Linux).</small>
</pre>
Filenames can be ICO or PNG format. PNG format is supported on Linux/BSD and Windows XP (but requires installation of GDI+ on Windows 2000). Set a timeout of -1 to use XChat's default.
<br><br>

<h3><a name=unicode>Handling UTF-8/Unicode strings</a></h3>
<p>
The XChat plugin API specifies that strings passed to and from xchat must be encoded in UTF-8.
<br><br>
What does this mean for the plugin programmer? You just have to be a little careful when
passing strings obtained from IRC to system calls. For example, if you're writing a file-server
bot, someone might message you a filename. Can you pass this filename directly to open()? Maybe!
If you're lazy... The correct thing to do is to convert the string to "system locale encoding",
otherwise your plugin will fail on non-ascii characters.
<br><br>
Here are examples on how to do this conversion on Unix and Windows. In this example, someone will
CTCP you the message "SHOWFILE &lt;filename&gt;".
<br><br>
</p>
<pre>
static int ctcp_cb(char *word[], char *word_eol[], void *userdata)
{
	if(strcmp(word[1], "SHOWFILE") == 0)
	{
		get_file_name(nick, word[2]);
	}

	return XCHAT_EAT_XCHAT;
}

static void get_file_name(char *nick, char *fname)
{
	char buf[256];
	FILE *fp;

<font color="#777777">	/* the fname is in UTF-8, because it came from the xchat API */</font>
</pre><font color="#33aa44">#ifdef _WIN32</font><pre>
	wchar_t wide_name[MAX_PATH];

<font color="#777777">	/* convert UTF-8 to WIDECHARs (aka UTF-16LE) */</font>
	if (MultiByteToWideChar(CP_UTF8, 0, fname, -1, wide_name, MAX_PATH) < 1)
		return;

<font color="#777777">	/* now we have WIDECHARs, so we can _wopen() or CreateFileW(). */
	/* _wfopen actually requires NT4, Win2000, XP or newer. */</font>
	fp = _wfopen(wide_name, "r");
</pre><font color="#33aa44">#else</font><pre>
	char *loc_name;

<font color="#777777">	/* convert UTF-8 to System Encoding */</font>
	loc_name = g_filename_from_utf8(fname, -1, 0, 0, 0);
	if(!loc_name)
		return;

<font color="#777777">	/* now open using the system's encoding */</font>
	fp = fopen(loc_name, "r");
	g_free(loc_name);
</pre><font color="#33aa44">#endif</font><pre>
	if (fp)
	{
		while (fgets (buf, sizeof(buf), fp))
		{
<font color="#777777">			/* send every line to the user that requested it */</font>
			xchat_commandf (ph, "QUOTE NOTICE %s :%s", nick, buf);
		}
		fclose (fp);
	}
}
</pre>



<br><br>

<h1>Functions</h1>

<h3><a class=cmd name="xchat_hook_command">&nbsp;xchat_hook_command()&nbsp;</a></h3>
<b>Prototype:</b> xchat_hook *xchat_hook_command(xchat_plugin *ph, const char *name, int pri, xchat_cmd_cb *callb, const char *help_text, void *userdata);
<br>
<br><b>Description:</b> Adds a new /command. This allows your program to
handle commands entered at the input box. To capture text without a "/" at 
the start (non-commands), you may hook a special name of "". i.e xchat_hook_command(ph, "", ...);.
<br>
Starting from version 2.6.8, commands hooked that begin with a period ('.') will be hidden in /HELP and /HELP -l.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>name:</b> Name of the command (without the forward slash).
<br><b>pri:</b> Priority of this command. Use XCHAT_PRI_NORM.
<br><b>callb:</b> Callback function. This will be called when the user executes the given command name.
<br><b>help_text:</b> String of text to display when the user executes /help for this command. May be NULL if you're lazy.
<br><b>userdata:</b> Pointer passed to the callback function.</blockquote>
<b>Returns:</b> Pointer to the hook. Can be passed to xchat_unhook.
<br>
<br><b>Example:</b>
<blockquote>
<pre>
static int onotice_cb(char *word[], char *word_eol[], void *userdata)
{
	if(word_eol[2][0] == 0)
	{
		xchat_printf(ph, "Second arg must be the message!\n");
		return XCHAT_EAT_ALL;
	}

	xchat_commandf(ph, "NOTICE @%s :%s", xchat_get_info(ph, "channel"), word_eol[2]);
	return XCHAT_EAT_ALL;
}

xchat_hook_command(ph, "ONOTICE", XCHAT_PRI_NORM, onotice_cb,
                   "Usage: ONOTICE &lt;message> Sends a notice to all ops", NULL);
</pre>
</blockquote>
<br>

<h3><a class=cmd name="xchat_hook_fd">&nbsp;xchat_hook_fd()&nbsp;</a></h3>
<b>Prototype:</b> xchat_hook *xchat_hook_fd(xchat_plugin *ph, int fd, int flags, xchat_fd_cb *callb, void *userdata);
<br>
<br><b>Description:</b> Hooks a socket or file descriptor. WIN32: Passing a pipe from MSVCR71, MSVCR80 or other variations is not supported at this time.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>fd:</b> The file descriptor or socket.
<br><b>flags:</b> One or more of XCHAT_FD_READ, XCHAT_FD_WRITE, XCHAT_FD_EXCEPTION, XCHAT_FD_NOTSOCKET. Use bitwise OR to combine them.
XCHAT_FD_NOTSOCKET tells xchat that the provided <b>fd</b> is not a socket, but a "MSVCRT.DLL" pipe.
<br><b>callb:</b> Callback function. This will be called when the socket is available for reading/writing or exception (depending on your chosen <b>flags</b>)
<br><b>userdata:</b> Pointer passed to the callback function.</blockquote>
<b>Returns:</b> Pointer to the hook. Can be passed to xchat_unhook.
<br><br><br>

<h3><a class=cmd name="xchat_hook_print">&nbsp;xchat_hook_print()&nbsp;</a></h3>
<b>Prototype:</b> <font color="#f8a400"><b>xchat_hook</b></font> *xchat_hook_print(<font color="#f8a400"><b>xchat_plugin</b></font> *ph, <font color="#f8a400"><b>const char</b></font> *name, <font color="#f8a400"><b>int</b></font> pri, <font color="#f8a400"><b>xchat_print_cb</b></font> *callb, <font color="#f8a400"><b>void</b></font> *userdata);
<br>
<br><b>Description:</b> Registers a function to trap any print events.
The event names may be any available in the "Advanced > Text Events" window.
There are also some extra "special" events you may hook using this function.
Currently they are:<blockquote>
"Open Context" - Called when a new xchat_context is created.
<br>"Close Context" - Called when a xchat_context pointer is closed.
<br>"Focus Tab" - Called when a tab is brought to front.
<br>"Focus Window" - Called a toplevel window is focused, or the main
tab-window is focused by the window manager.
<br>"DCC Chat Text" - Called when some text from a DCC Chat arrives. It provides these elements in the word[] array:<blockquote>word[1] Address
<br>word[2] Port
<br>word[3] Nick
<br>word[4] The Message
</blockquote>
"Key Press" - Called when some keys are pressed in the input-box (since 2.4.2). It provides these elements in the word[] array:<blockquote>word[1] Key Value
<br>word[2] State Bitfield (shift, capslock, alt)
<br>word[3] String version of the key
<br>word[4] Length of the string (may be 0 for unprintable keys)
</blockquote>
</blockquote>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>name:</b> Name of the print event (as in Edit Event Texts Window).
<br><b>pri:</b> Priority of this command. Use XCHAT_PRI_NORM.
<br><b>callb:</b> Callback function. This will be called when this event name is printed.
<br><b>userdata:</b> Pointer passed to the callback function.</blockquote>
<b>Returns:</b> Pointer to the hook. Can be passed to xchat_unhook.
<br>
<br><b>Example:</b>
<blockquote>
<pre>
static int youpart_cb(char *word[], void *userdata)
{
	xchat_printf(ph, "You have left channel %s\n", word[3]);
	return XCHAT_EAT_XCHAT;	/* dont let xchat do its normal printing */
}

xchat_hook_print(ph, "You Part", XCHAT_PRI_NORM, youpart_cb, NULL);
</pre>
</blockquote>
<br>

<h3><a class=cmd name="xchat_hook_server">&nbsp;xchat_hook_server()&nbsp;</a></h3>
<b>Prototype:</b> xchat_hook *xchat_hook_server(xchat_plugin *ph, const char *name, int pri, xchat_serv_cb *callb, void *userdata);
<br>
<br><b>Description:</b> Registers a function to be called when a certain server event occurs. You can
use this to trap PRIVMSG, NOTICE, PART, a server numeric etc... If you want to
hook every line that comes from the IRC server, you may use the special name of "RAW LINE".
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>name:</b> Name of the server event.
<br><b>pri:</b> Priority of this command. Use XCHAT_PRI_NORM.
<br><b>callb:</b> Callback function. This will be called when this event is received from the server.
<br><b>userdata:</b> Pointer passed to the callback function.</blockquote>
<b>Returns:</b> Pointer to the hook. Can be passed to xchat_unhook.
<br>
<br><b>Example:</b>
<blockquote>
<pre>
static int kick_cb(char *word[], char *word_eol[], void *userdata)
{
	xchat_printf(ph, "%s was kicked from %s (reason=%s)\n", word[4], word[3], word_eol[5]);
	return XCHAT_EAT_NONE;	/* don't eat this event, let other plugins and xchat see it too */
}

xchat_hook_server(ph, "KICK", XCHAT_PRI_NORM, kick_cb, NULL);
</pre>
</blockquote>
<br>

<h3><a class=cmd name="xchat_hook_timer">&nbsp;xchat_hook_timer()&nbsp;</a></h3>
<b>Prototype:</b> xchat_hook *xchat_hook_timer(xchat_plugin *ph, int timeout, xchat_timer_cb *callb, void *userdata);
<br>
<br><b>Description:</b> Registers a function to be called every "timeout" milliseconds.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>timeout:</b> Timeout in milliseconds (1000 is 1 second).
<br><b>callb:</b> Callback function. This will be called every "timeout" milliseconds.
<br><b>userdata:</b> Pointer passed to the callback function.</blockquote>
<b>Returns:</b> Pointer to the hook. Can be passed to xchat_unhook.
<br>
<br><b>Example:</b>
<blockquote>
<pre>
static xchat_hook *myhook;

static int stop_cb(char *word[], char *word_eol[], void *userdata)
{
	if(myhook != NULL)
	{
		xchat_unhook(ph, myhook);
		myhook = NULL;
		xchat_print(ph, "Timeout removed!\n");
	}

	return XCHAT_EAT_ALL;
}

static int timeout_cb(void *userdata)
{
	xchat_print(ph, "Annoying message every 5 seconds! Type /STOP to stop it.\n");
	return 1;	/* return 1 to keep the timeout going */
}

myhook = xchat_hook_timer(ph, 5000, timeout_cb, NULL);
xchat_hook_command(ph, "STOP", XCHAT_PRI_NORM, stop_cb, NULL, NULL);
</pre><br>
</blockquote>

<h3><a class=cmd name="xchat_unhook">&nbsp;xchat_unhook()&nbsp;</a></h3>
<b>Prototype:</b> void *xchat_unhook(xchat_plugin *ph, xchat_hook *hook);
<br>
<br><b>Description:</b> Unhooks any hook registered with xchat_hook_print/server/timer/command. When plugins are unloaded, all of its hooks are automatically
removed, so you don't need to call this within your xchat_plugin_deinit() function.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>hook:</b> Pointer to the hook, as returned by xchat_hook_*.
<br></blockquote>
<b>Returns:</b> The userdata you originally gave to xchat_hook_*.
<br><br>

<h3><a class=cmd name="xchat_command">&nbsp;xchat_command()&nbsp;</a></h3>
<b>Prototype:</b> void xchat_command(xchat_plugin *ph, const char *command);
<br>
<br><b>Description:</b> Executes a command as if it were typed in xchat's input box.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>command:</b> Command to execute, without the forward slash "/".
<br><br>
</blockquote>

<h3><a class=cmd name="xchat_commandf">&nbsp;xchat_commandf()&nbsp;</a></h3>
<b>Prototype:</b> void xchat_commandf(xchat_plugin *ph, const char *format, ...);
<br>
<br><b>Description:</b> Executes a command as if it were typed in xchat's input box and provides string formating like printf.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>format:</b> The format string.
<br><br>
</blockquote>

<h3><a class=cmd name="xchat_print">&nbsp;xchat_print()&nbsp;</a></h3>
<b>Prototype:</b> void xchat_print(xchat_plugin *ph, const char *text);
<br>
<br><b>Description:</b> Prints some text to the current tab/window.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>text:</b> Text to print. May contain mIRC color codes.
<br><br>
</blockquote>

<h3><a class=cmd name="xchat_printf">&nbsp;xchat_printf()&nbsp;</a></h3>
<b>Prototype:</b> void xchat_printf(xchat_plugin *ph, const char *format, ...);
<br>
<br><b>Description:</b> Prints some text to the current tab/window and provides formating like printf.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>format:</b> The format string.
<br><br>
</blockquote>

<h3><a class=cmd name="xchat_emit_print">&nbsp;xchat_emit_print()&nbsp;</a></h3>
<b>Prototype:</b> int xchat_emit_print(xchat_plugin *ph, const char *event_name, ...);
<br>
<br><b>Description:</b> Generates a print event. This can be any
event found in the Preferences > Advanced > Text Events window. The vararg parameter list
MUST always be NULL terminated. Special care should be taken when calling this function
inside a print callback (from xchat_hook_print), as not to cause endless recursion.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>event_name:</b> Text event to print.
<br><br>
</blockquote>
<b>Returns:</b> 1-Success 0-Failure.
<br><br>
<b>Example:</b>
<pre>
xchat_emit_print(ph, "Channel Message", "John", "Hi there", "@", NULL);
</pre>
<br><br>

<h3><a class=cmd name="xchat_send_modes">&nbsp;xchat_send_modes()&nbsp;</a><small>(new for 2.0.9)</small></h3>
<b>Prototype:</b> void xchat_send_modes (xchat_plugin *ph, const char *targets[], int ntargets, int modes_per_line, char sign, char mode)
<br>
<br><b>Description:</b> Sends a number of channel mode changes to the current channel. For example, you can Op a whole
group of people in one go. It may send multiple MODE lines if the request doesn't fit on one. Pass 0 for
<b>modes_per_line</b> to use the current server's maximum possible. This function should only be called while
in a channel context.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>targets:</b> Array of targets (strings). The names of people whom the action will be performed on.
<br><b>ntargets:</b> Number of elements in the array given.
<br><b>modes_per_line:</b> Maximum modes to send per line.
<br><b>sign:</b> Mode sign, '-' or '+'.
<br><b>mode:</b> Mode char, e.g. 'o' for Ops.<br>
</blockquote>
<b>Example:</b> (Ops the three names given)
<pre>
const char *names_to_Op[] = {"John", "Jack", "Jill"};
xchat_send_modes(ph, names_to_Op, 3, 0, '+', 'o');
</pre>
<br><br>

<h3><a class=cmd name="xchat_find_context">&nbsp;xchat_find_context()&nbsp;</a></h3>
<b>Prototype:</b> xchat_context *xchat_find_context(xchat_plugin *ph, const char *servname, const char *channel);
<br>
<br><b>Description:</b> Finds a context based on a channel and servername. If servname is NULL, it finds any channel (or query) by the given name. If channel is NULL, it finds the front-most tab/window of the given servname. If NULL is given for both arguments, the currently focused tab/window will be returned.<br>
Changed in 2.6.1. If servname is NULL, it finds the channel (or query) by the given name in the same server group as the current context. If that doesn't exists then find any by the given name.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>servname:</b> Servername or NULL.
<br><b>channel:</b> Channelname or NULL.
<br>
</blockquote>
<b>Returns:</b> Context pointer (for use with xchat_set_context) or NULL.
<br><br><br>

<h3><a class=cmd name="xchat_get_context">&nbsp;xchat_get_context()&nbsp;</a></h3>
<b>Prototype:</b> xchat_context *xchat_get_context(xchat_plugin *ph);
<br>
<br><b>Description:</b> Returns the current context for your plugin. You can use this later with xchat_set_context.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br>
</blockquote>
<b>Returns:</b> Context pointer (for use with xchat_set_context).
<br><br><br>

<h3><a class=cmd name="xchat_get_info">&nbsp;xchat_get_info()&nbsp;</a></h3>
<b>Prototype:</b> const char *xchat_get_info(xchat_plugin *ph, const char *id);
<br>
<br><b>Description:</b> Returns information based on your current context.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>id:</b> ID of the information you want. Currently supported IDs are (case sensitive):
	<blockquote>
	<table border=0>
	<tr><td width="18%">away</td><td>away reason or NULL if you are not away.</td></tr>
	<tr><td>channel</td><td>current channel name.</td></tr>
	<tr><td>charset</td><td>character-set used in the current context (since 2.4.2).</td></tr>
	<tr><td>event_text &lt;name></td><td>text event format string for <i>name</i> (since 2.8.2).</td></tr>
	<tr><td>gtkwin_ptr</td><td>(GtkWindow *) (since 2.8.9).</td></tr>
	<tr><td>host</td><td>real hostname of the server you connected to.</td></tr>
	<tr><td>inputbox</td><td>the input-box contents, what the user has typed (since 2.4.1).</td></tr>
	<tr><td>libdirfs</td><td>library directory. e.g. /usr/lib/xchat. The same directory used for auto-loading plugins (since 2.4.0).<small>This string isn't necessarily UTF-8, but local file system encoding.</small></td></tr>
	<tr><td>modes</td><td>channel modes, if known, or NULL (since 2.8.1).</td></tr>
	<tr><td>network</td><td>current network name or NULL.</td></tr>
	<tr><td>nick</td><td>your current nick name.</td></tr>
	<tr><td>nickserv</td><td>nickserv password for this network or NULL (since 2.4.3).</td></tr>
	<tr><td>server</td><td>current server name (what the server claims to be). NULL if you are not connected.</td></tr>
	<tr><td>topic</td><td>current channel topic.</td></tr>
	<tr><td>version</td><td>xchat version number.</td></tr>
	<tr><td>win_ptr</td><td>native window pointer. Unix: (GtkWindow *) Win32: HWND (since 2.6.0).</td></tr>
	<tr><td>win_status</td><td>window status: "active", "hidden" or "normal" (since 2.0.9).</td>
	<tr><td>xchatdir</td><td>xchat config directory, e.g.: /home/user/.xchat2 <small>This string is encoded in UTF-8, which means you _should_ convert it to "locale" encoding before using functions like open() or OpenFile(). For best <a href="#unicode">Unicode support</a> on Linux, convert this string using g_filename_from_utf8 and on Windows convert this string to UTF-16LE (wide) and use OpenFileW() etc.</small></td></tr>
	<tr><td>xchatdirfs</td><td>xchat config directory, e.g.: /home/user/.xchat2 (since 2.0.9).<small>This string is encoded in local file system encoding, making it ideal for direct use with functions like open() or OpenFile(). For real Unicode support on Windows, it's best not to use xchatdirfs, but xchatdir instead.</small></td></tr>
	</table>
	</blockquote>
</blockquote>
<b>Returns:</b> A string of the requested information, or NULL. This string must
not be freed and must be copied if needed after the call to xchat_get_info.
<br><br><br>

<h3><a class=cmd name="xchat_get_prefs">&nbsp;xchat_get_prefs()&nbsp;</a></h3>
<b>Prototype:</b> int xchat_get_prefs(xchat_plugin *ph, const char *name, const char **string, int *integer);
<br>
<br><b>Description:</b> Provides xchat's setting information (that which is available through the /set command).
A few extra bits of information are available that don't appear in the /set list, currently they are:
<br>
<blockquote>
	<table border=0 cellpadding=5>
	<tr><td width="18%">state_cursor</td><td>Current input-box cursor position (characters, not bytes). Since 2.4.2.</td></tr>
	<tr><td width="18%">id</td><td>Unique server id. Since 2.6.1.</td></tr>
	</table>
</blockquote>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>name:</b> Setting name required.
<br><b>string:</b> Pointer-pointer which to set.
<br><b>integer:</b> Pointer to an integer to set, if setting is a Boolean or Integer type.
</blockquote>
<b>Returns:</b> 0-Failed 1-Returned a string 2-Returned an Integer 3-Returned a Boolean.
<br><br><b>Example:</b>
<blockquote>
<pre>
{
	int i;
	const char *str;

	if (xchat_get_prefs (ph, "irc_nick1", &amp;str, &amp;i) == 1)
	{
		xchat_printf (ph, "Current nickname setting: %s\n", str);
	}
}</pre>
</blockquote>
<br><br>


<h3><a class=cmd name="xchat_set_context">&nbsp;xchat_set_context()&nbsp;</a></h3>
<b>Prototype:</b> int xchat_set_context(xchat_plugin *ph, xchat_context *ctx);
<br>
<br><b>Description:</b> Changes your current context to the one given.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>ctx:</b> Context to change to (obtained with xchat_get_context or xchat_find_context).
<br>
</blockquote>
<b>Returns:</b> 1 for success, 0 for failure.
<br><br><br>

<h3><a class=cmd name="xchat_nickcmp">&nbsp;xchat_nickcmp()&nbsp;</a></h3>
<b>Prototype:</b> int xchat_nickcmp(xchat_plugin *ph, const char *s1, const char *s2);
<br>
<br><b>Description:</b> Performs a nick name comparision, based on the current server connection. This might be a RFC1459 compliant string compare, or
plain ascii (in the case of DALNet). Use this to compare channels and nicknames. The function works the same way as strcasecmp.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>s1:</b> String to compare.
<br><b>s2:</b> String to compare s1 to.
<br>
</blockquote>
<b>Quote from RFC1459:</b>
<blockquote>
  Because of IRC's scandanavian origin, the characters {}| are
   considered to be the lower case equivalents of the characters []\,
   respectively. This is a critical issue when determining the
   equivalence of two nicknames.
</blockquote>
<b>Returns:</b>
       An integer
       less than, equal to, or greater than zero if s1 is found,
       respectively, to be less than, to match, or be greater than s2.
<br><br><br>

<h3><a class=cmd name="xchat_strip">&nbsp;xchat_strip()&nbsp;</a><small>(new for 2.4.2)</small></h3>
<b>Prototype:</b> char *xchat_strip(xchat_plugin *ph, const char *str, int len, int flags);
<br>
<br><b>Description:</b> Strips mIRC color codes and/or text attributes (bold, underlined etc) from the given string and returns a newly allocated string.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>str:</b> String to strip.
<br><b>len:</b> Length of the string (or -1 for NULL terminated).
<br><b>flags:</b> Bit-field of flags: 0-Strip mIRC colors, 1-Strip text attributes.
<br>
</blockquote>
<b>Returns:</b>
A newly allocated string or NULL for failure. You must free this string with xchat_free.
<br><br><b>Example:</b>
<blockquote>
<pre>
{
	char *new_text;

	/* strip both colors and attributes by using the 0 and 1 bits (1 BITWISE-OR 2) */
	new_text = xchat_strip(ph, "\00312Blue\003 \002Bold!\002", -1, 1 | 2);

	if(new_text)
	{
		/* new_text should now contain only "Blue Bold!" */
		xchat_printf(ph, "%s\n", new_text);
		xchat_free(ph, new_text);
	}
}</pre>
</blockquote>

<br><br>

<h3><a class=cmd name="xchat_free">&nbsp;xchat_free()&nbsp;</a><small>(new for 2.4.2)</small></h3>
<b>Prototype:</b> void xchat_free(xchat_plugin *ph, void *ptr);
<br>
<br><b>Description:</b> Frees a string returned by xchat_* functions. Currently only used to free strings from xchat_strip.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>ptr:</b> Pointer to free.
<br>
</blockquote>

<br><br>

<h3><a class=cmd name="xchat_pluginpref_set_str">&nbsp;xchat_pluginpref_set_str()&nbsp;</a><small>(new for 2.9.0)</small></h3>
<b>Prototype:</b> int xchat_pluginpref_set_str (xchat_plugin *ph, const char *var, const char *value);
<br>
<br><b>Description:</b> Saves a plugin-specific setting with string value to a plugin-specific config file.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>var:</b> Name of the setting to save.
<br><b>value:</b> String value of the the setting.
<br>
</blockquote>
<b>Returns:</b> 1 for success, 0 for failure.
<br><br><b>Example:</b>
<blockquote>
<pre>int xchat_plugin_init (xchat_plugin *plugin_handle,
			char **plugin_name,
			char **plugin_desc,
			char **plugin_version,
			char *arg)
{
	ph = plugin_handle;
	*plugin_name = "Tester Thingie";
	*plugin_desc = "Testing stuff";
	*plugin_version = "1.0";

	xchat_pluginpref_set_str (ph, "myvar1", "I want to save this string!");
	xchat_pluginpref_set_str (ph, "myvar2", "This is important, too.");

	return 1;       /* return 1 for success */
}</pre>
</blockquote>
In the example above, the settings will be saved to the plugin_tester_thingie.conf file, and its content will be:
<blockquote>
<pre>myvar1 = I want to save this string!
myvar2 = This is important, too.</pre>
</blockquote>
You should never need to edit this file manually.
<br><br><br>

<h3><a class=cmd name="xchat_pluginpref_get_str">&nbsp;xchat_pluginpref_get_str()&nbsp;</a><small>(new for 2.9.0)</small></h3>
<b>Prototype:</b> int xchat_pluginpref_get_str (xchat_plugin *ph, const char *var, char *dest);
<br>
<br><b>Description:</b> Loads a plugin-specific setting with string value from a plugin-specific config file.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>var:</b> Name of the setting to load.
<br><b>dest:</b> Array to save the loaded setting's string value to.
<br>
</blockquote>
<b>Returns:</b> 1 for success, 0 for failure.
<br><br><br>

<h3><a class=cmd name="xchat_pluginpref_set_int">&nbsp;xchat_pluginpref_set_int()&nbsp;</a><small>(new for 2.9.0)</small></h3>
<b>Prototype:</b> int xchat_pluginpref_set_int (xchat_plugin *ph, const char *var, int value);
<br>
<br><b>Description:</b> Saves a plugin-specific setting with decimal value to a plugin-specific config file.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>var:</b> Name of the setting to save.
<br><b>value:</b> Decimal value of the the setting.
<br>
</blockquote>
<b>Returns:</b> 1 for success, 0 for failure.
<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_pluginpref_set_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>
You only need these kind of complex checks if you're saving user input, which can be non-numeric.
<br><br><br>

<h3><a class=cmd name="xchat_pluginpref_get_int">&nbsp;xchat_pluginpref_get_int()&nbsp;</a><small>(new for 2.9.0)</small></h3>
<b>Prototype:</b> int xchat_pluginpref_get_int (xchat_plugin *ph, const char *var);
<br>
<br><b>Description:</b> Loads a plugin-specific setting with decimal value from a plugin-specific config file.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>var:</b> Name of the setting to load.
<br>
</blockquote>
<b>Returns:</b> The decimal value of the requested setting upon success, -1 for failure.
<br><br><br>

<h3><a class=cmd name="xchat_pluginpref_delete">&nbsp;xchat_pluginpref_delete()&nbsp;</a><small>(new for 2.9.0)</small></h3>
<b>Prototype:</b> int xchat_pluginpref_delete (xchat_plugin *ph, const char *var);
<br>
<br><b>Description:</b> Deletes a plugin-specific setting from a plugin-specific config file.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>var:</b> Name of the setting to delete.
<br>
</blockquote>
<b>Returns:</b> 1 for success, 0 for failure. If the given setting didn't exist, it also returns 1, so 1 only indicates that the setting won't exist after the call.
<br><br><br>

<h3><a class=cmd name="xchat_pluginpref_list">&nbsp;xchat_pluginpref_list()&nbsp;</a><small>(new for 2.9.0)</small></h3>
<b>Prototype:</b> int xchat_pluginpref_list (xchat_plugin *ph, char *dest);
<br>
<br><b>Description:</b> Builds a comma-separated list of the currently saved settings from a plugin-specific config file.
<br>
<br><b>Arguments:</b>
<blockquote><b>ph:</b> Plugin handle (as given to xchat_plugin_init).
<br><b>dest:</b> Array to save the list to.
<br>
</blockquote>
<b>Returns:</b> 1 for success, 0 for failure (nonexistent, empty or inaccessible config file).
<br><br><br>

</body>
</html>