Rebrand get_info(xchatdir) but remain compatible for Perl and Python

This commit is contained in:
Berke Viktor 2012-10-30 09:59:58 +01:00
parent 66be50f335
commit 29f7a9180c
19 changed files with 48 additions and 48 deletions

View file

@ -52,7 +52,7 @@ static hexchat_plugin *ph;
* Returns the path to the key store file. * Returns the path to the key store file.
*/ */
gchar *get_config_filename() { gchar *get_config_filename() {
return g_build_filename(hexchat_get_info(ph, "xchatdirfs"), "addon_fishlim.conf", NULL); return g_build_filename(hexchat_get_info(ph, "hexchatdirfs"), "addon_fishlim.conf", NULL);
} }
/** /**

View file

@ -524,7 +524,7 @@ static int lxc_cb_load(char *word[], char *word_eol[], void *userdata)
} }
else else
{ {
xdir = hexchat_get_info (ph, "xchatdirfs"); xdir = hexchat_get_info (ph, "hexchatdirfs");
snprintf (file, PATH_MAX, "%s/addons/%s", xdir, word[2]); snprintf (file, PATH_MAX, "%s/addons/%s", xdir, word[2]);
} }
} }
@ -678,7 +678,7 @@ int hexchat_plugin_init(hexchat_plugin *plugin_handle,
hexchat_hook_command(ph, "UNLOAD", HEXCHAT_PRI_NORM, lxc_cb_unload, NULL, NULL); hexchat_hook_command(ph, "UNLOAD", HEXCHAT_PRI_NORM, lxc_cb_unload, NULL, NULL);
hexchat_hook_command(ph, "LUA", HEXCHAT_PRI_NORM, lxc_cb_lua, "Usage: LUA <code>, executes <code> in a new lua state", NULL); hexchat_hook_command(ph, "LUA", HEXCHAT_PRI_NORM, lxc_cb_lua, "Usage: LUA <code>, executes <code> in a new lua state", NULL);
xdir = hexchat_get_info (ph, "xchatdirfs"); xdir = hexchat_get_info (ph, "hexchatdirfs");
xsubdir = g_build_filename (xdir, "addons", NULL); xsubdir = g_build_filename (xdir, "addons", NULL);
lxc_autoload_from_path (xsubdir); lxc_autoload_from_path (xsubdir);
g_free (xsubdir); g_free (xsubdir);

View file

@ -15,7 +15,7 @@ EXTRA_DIST = mailcheck-config.h.in
# Remember to include this line in your Makefile.am # Remember to include this line in your Makefile.am
include @top_srcdir@/plugins/Make.plugin include @top_srcdir@/plugins/Make.plugin
libdir = $(xchatdir)/plugins libdir = $(hexchatdir)/plugins
lib_LTLIBRARIES = mailcheck.la lib_LTLIBRARIES = mailcheck.la
mailcheck_la_SOURCES = mailcheck.c mailcheck_la_SOURCES = mailcheck.c

View file

@ -87,7 +87,7 @@ void loadThemes(){
FILE *f; FILE *f;
hexchat_print(ph,"loading themes\n"); hexchat_print(ph,"loading themes\n");
hDir=(char*)calloc(1024,sizeof(char)); hDir=(char*)calloc(1024,sizeof(char));
strcpy(hDir,hexchat_get_info(ph,"xchatdirfs")); strcpy(hDir,hexchat_get_info(ph,"hexchatdirfs"));
hFile=str3cat(hDir,"\\","mpcInfo.theme.txt"); hFile=str3cat(hDir,"\\","mpcInfo.theme.txt");
f = fopen(hFile,"r"); f = fopen(hFile,"r");
if(f==NULL) if(f==NULL)

View file

@ -127,7 +127,7 @@ sub IRC::channel_list {
sub IRC::get_info { sub IRC::get_info {
my $id = shift; my $id = shift;
my @ids = qw(version nick channel server xchatdir away network host topic); my @ids = qw(version nick channel server hexchatdir xchatdir away network host topic);
if( $id >= 0 && $id <= 8 && $id != 5 ) { if( $id >= 0 && $id <= 8 && $id != 5 ) {
my $info = Xchat::get_info($ids[$id]); my $info = Xchat::get_info($ids[$id]);

View file

@ -471,7 +471,7 @@ sub context_info {
my @fields = ( my @fields = (
qw(away channel charset host id inputbox libdirfs modes network), qw(away channel charset host id inputbox libdirfs modes network),
qw(nick nickserv server topic version win_ptr win_status), qw(nick nickserv server topic version win_ptr win_status),
qw(xchatdir xchatdirfs state_cursor), qw(hexchatdir hexchatdirfs xchatdir xchatdirfs state_cursor),
); );
if( Xchat::set_context( $ctx ) ) { if( Xchat::set_context( $ctx ) ) {

View file

@ -683,16 +683,16 @@ C<$id> - one of the following case sensitive values
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>xchatdir</td> <td>xchat config directory encoded in UTF-8<br /> <td>hexchatdir</td> <td>HexChat config directory encoded in UTF-8<br />
examples:<br /> examples:<br />
/home/user/.xchat2<br /> /home/user/.config/hexchat<br />
C:\Documents and Settings\user\Application Data\X-Chat 2 C:\Users\user\Appdata\Roaming\HexChat
</td> </td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>xchatdirfs</td> <td>same as xchatdir except encoded in the locale file system encoding</td> <td>hexchatdirfs</td> <td>same as hexchatdir except encoded in the locale file system encoding</td>
<td></td> <td></td>
</tr> </tr>
</table> </table>

View file

@ -207,7 +207,7 @@ sub reload {
} }
sub reload_all { sub reload_all {
my @dirs = Xchat::get_info( "xchatdirfs" ) || Xchat::get_info( "xchatdir" ); my @dirs = Xchat::get_info( "hexchatdirfs" ) || Xchat::get_info( "hexchatdir" );
push @dirs, File::Spec->catdir( $dirs[0], "plugins" ); push @dirs, File::Spec->catdir( $dirs[0], "plugins" );
for my $dir ( @dirs ) { for my $dir ( @dirs ) {
my $auto_load_glob = File::Spec->catfile( $dir, "*.pl" ); my $auto_load_glob = File::Spec->catfile( $dir, "*.pl" );

View file

@ -6,7 +6,7 @@ my $last_modified;
my @servers; my @servers;
sub get { sub get {
my $server_file = Xchat::get_info( "xchatdirfs" ) . "/servlist_.conf"; my $server_file = Xchat::get_info( "hexchatdirfs" ) . "/servlist_.conf";
# recreate the list only if the server list file has changed # recreate the list only if the server list file has changed
if( -f $server_file && if( -f $server_file &&

View file

@ -144,9 +144,7 @@ perl_auto_load (void *unused)
#endif #endif
/* get the dir in local filesystem encoding (what opendir() expects!) */ /* get the dir in local filesystem encoding (what opendir() expects!) */
xdir = hexchat_get_info (ph, "xchatdirfs"); xdir = hexchat_get_info (ph, "hexchatdirfs");
if (!xdir) /* xchatdirfs is new for 2.0.9, will fail on older */
xdir = hexchat_get_info (ph, "xchatdir");
/* don't pollute the filesystem with script files, this only causes misuse of the folders /* don't pollute the filesystem with script files, this only causes misuse of the folders
* only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */ * only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
@ -796,7 +794,7 @@ XS (XS_Xchat_get_info)
if ( if (
!strncmp ("libdirfs", SvPV_nolen (id), 8) || !strncmp ("libdirfs", SvPV_nolen (id), 8) ||
!strncmp ("xchatdirfs", SvPV_nolen (id), 10) !strncmp ("hexchatdirfs", SvPV_nolen (id), 10)
) { ) {
XSRETURN_PV (RETVAL); XSRETURN_PV (RETVAL);
} else { } else {

View file

@ -393,13 +393,13 @@ Util_Autoload()
char *sub_dir; char *sub_dir;
/* we need local filesystem encoding for chdir, opendir etc */ /* we need local filesystem encoding for chdir, opendir etc */
xdir = hexchat_get_info(ph, "xchatdirfs"); xdir = hexchat_get_info(ph, "hexchatdirfs");
/* don't pollute the filesystem with script files, this only causes misuse of the folders /* don't pollute the filesystem with script files, this only causes misuse of the folders
* only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */ * only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
#if 0 #if 0
/* auto-load from ~/.config/hexchat/ or %APPDATA%\HexChat\ */ /* auto-load from ~/.config/hexchat/ or %APPDATA%\HexChat\ */
Util_Autoload_from(hexchat_get_info(ph, "xchatdirfs")); Util_Autoload_from(hexchat_get_info(ph, "hexchatdirfs"));
#endif #endif
/* auto-load from subdirectory addons */ /* auto-load from subdirectory addons */
@ -449,7 +449,7 @@ Util_Expand(char *filename)
g_free(expanded); g_free(expanded);
/* Check if ~/.config/hexchat/addons/<filename> exists. */ /* Check if ~/.config/hexchat/addons/<filename> exists. */
expanded = g_build_filename(hexchat_get_info(ph, "xchatdir"), expanded = g_build_filename(hexchat_get_info(ph, "hexchatdir"),
"addons", filename, NULL); "addons", filename, NULL);
if (g_file_test(expanded, G_FILE_TEST_EXISTS)) if (g_file_test(expanded, G_FILE_TEST_EXISTS))
return expanded; return expanded;

View file

@ -92,7 +92,7 @@ static char unknown[] = {
/* don't pollute the filesystem with script files, this only causes misuse of the folders /* don't pollute the filesystem with script files, this only causes misuse of the folders
* only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */ * only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
static char sourcedirs[] = { static char sourcedirs[] = {
"set files [lsort [glob -nocomplain -directory [xchatdir] \"/addons/*.tcl\"]]\n" "set files [lsort [glob -nocomplain -directory [hexchatdir] \"/addons/*.tcl\"]]\n"
"set init [lsearch -glob $files \"*/init.tcl\"]\n" "set init [lsearch -glob $files \"*/init.tcl\"]\n"
"if { $init > 0 } {\n" "if { $init > 0 } {\n"
"set initfile [lindex $files $init]\n" "set initfile [lindex $files $init]\n"
@ -121,8 +121,8 @@ static char inlinetcl[] = {
"proc ::server { args } { return [eval [join [list getinfo $args server]]] }\n" "proc ::server { args } { return [eval [join [list getinfo $args server]]] }\n"
"proc ::version { args } { return [eval [join [list getinfo $args version]]] }\n" "proc ::version { args } { return [eval [join [list getinfo $args version]]] }\n"
"proc ::win_status { args } { return [eval [join [list getinfo $args win_status]]] }\n" "proc ::win_status { args } { return [eval [join [list getinfo $args win_status]]] }\n"
"proc ::xchatdir { args } { return [eval [join [list getinfo $args xchatdir]]] }\n" "proc ::hexchatdir { args } { return [eval [join [list getinfo $args hexchatdir]]] }\n"
"proc ::xchatdirfs { args } { return [eval [join [list getinfo $args xchatdirfs]]] }\n" "proc ::hexchatdirfs { args } { return [eval [join [list getinfo $args hexchatdirfs]]] }\n"
"proc ::color { {arg {}} } { return \"\\003$arg\" }\n" "proc ::color { {arg {}} } { return \"\\003$arg\" }\n"
"proc ::bold { } { return \"\\002\" }\n" "proc ::bold { } { return \"\\002\" }\n"
@ -2013,7 +2013,7 @@ static int Command_TCL(char *word[], char *word_eol[], void *userdata)
static int Command_Source(char *word[], char *word_eol[], void *userdata) static int Command_Source(char *word[], char *word_eol[], void *userdata)
{ {
const char *xchatdir; const char *hexchatdir;
Tcl_DString ds; Tcl_DString ds;
struct stat dummy; struct stat dummy;
int len; int len;
@ -2030,7 +2030,7 @@ static int Command_Source(char *word[], char *word_eol[], void *userdata)
if (len > 4 && strcasecmp(".tcl", word[2] + len - 4) == 0) { if (len > 4 && strcasecmp(".tcl", word[2] + len - 4) == 0) {
xchatdir = hexchat_get_info(ph, "xchatdir"); hexchatdir = hexchat_get_info(ph, "hexchatdir");
Tcl_DStringInit(&ds); Tcl_DStringInit(&ds);
@ -2038,7 +2038,7 @@ static int Command_Source(char *word[], char *word_eol[], void *userdata)
Tcl_DStringAppend(&ds, word_eol[2], strlen(word_eol[2])); Tcl_DStringAppend(&ds, word_eol[2], strlen(word_eol[2]));
} else { } else {
if (!strchr(word_eol[2], '/')) { if (!strchr(word_eol[2], '/')) {
Tcl_DStringAppend(&ds, xchatdir, strlen(xchatdir)); Tcl_DStringAppend(&ds, hexchatdir, strlen(hexchatdir));
Tcl_DStringAppend(&ds, "/addons/", 8); Tcl_DStringAppend(&ds, "/addons/", 8);
Tcl_DStringAppend(&ds, word_eol[2], strlen(word_eol[2])); Tcl_DStringAppend(&ds, word_eol[2], strlen(word_eol[2]));
} }
@ -2083,7 +2083,7 @@ static int TCL_Event_Handler(void *userdata)
static void Tcl_Plugin_Init() static void Tcl_Plugin_Init()
{ {
int x; int x;
const char *xchatdir; const char *hexchatdir;
interp = Tcl_CreateInterp(); interp = Tcl_CreateInterp();
@ -2136,7 +2136,7 @@ static void Tcl_Plugin_Init()
for (x = 0; x < XC_SIZE; x++) for (x = 0; x < XC_SIZE; x++)
xc[x].hook = NULL; xc[x].hook = NULL;
xchatdir = hexchat_get_info(ph, "xchatdir"); hexchatdir = hexchat_get_info(ph, "hexchatdir");
if (Tcl_Eval(interp, unknown) == TCL_ERROR) { if (Tcl_Eval(interp, unknown) == TCL_ERROR) {
hexchat_printf(ph, "Error sourcing internal 'unknown' (%s)\n", Tcl_GetStringResult(interp)); hexchat_printf(ph, "Error sourcing internal 'unknown' (%s)\n", Tcl_GetStringResult(interp));

View file

@ -1,4 +1,4 @@
libdir = $(xchatdir)/plugins libdir = $(hexchatdir)/plugins
lib_LTLIBRARIES = xdcc.la lib_LTLIBRARIES = xdcc.la
xdcc_la_SOURCES = xdcc.c xdcc_la_SOURCES = xdcc.c

View file

@ -253,7 +253,7 @@ static void xdcc_save(void)
GSList *list; GSList *list;
fileoffer *offer; fileoffer *offer;
snprintf(buf, sizeof(buf), "%s/xdcclist.conf", hexchat_get_info(ph, "xchatdir")); snprintf(buf, sizeof(buf), "%s/xdcclist.conf", hexchat_get_info(ph, "hexchatdir"));
fp = fopen(buf, "w"); fp = fopen(buf, "w");
if(!fp) if(!fp)
@ -280,7 +280,7 @@ static void xdcc_load(void)
char dl[128]; char dl[128];
FILE *fp; FILE *fp;
snprintf(buf, sizeof(buf), "%s/xdcclist.conf", hexchat_get_info(ph, "xchatdir")); snprintf(buf, sizeof(buf), "%s/xdcclist.conf", hexchat_get_info(ph, "hexchatdir"));
fp = fopen(buf, "r"); fp = fopen(buf, "r");
if(!fp) if(!fp)

View file

@ -501,14 +501,14 @@ a context cannot be found.</p>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>xchatdir</td> <td>xchat config directory encoded in UTF-8<br /> <td>hexchatdir</td> <td>HexChat config directory encoded in UTF-8<br />
examples:<br /> examples:<br />
/home/user/.xchat2<br /> /home/user/.config/hexchat<br />
C:\Documents and Settings\user\Application Data\X-Chat 2 C:\Users\user\Appdata\Roaming\HexChat
</td> </td>
<td></td> <td></td>
</tr><tr> </tr><tr>
<td>xchatdirfs</td> <td>same as xchatdir except encoded in the locale file system encoding</td> <td>hexchatdirfs</td> <td>same as hexchatdir except encoded in the locale file system encoding</td>
<td></td> <td></td>
</tr> </tr>
</table><p>This function is used to retrieve certain information about the current </table><p>This function is used to retrieve certain information about the current

View file

@ -834,8 +834,8 @@ Changed in 2.6.1. If _servname_ is NULL, it finds the channel (or query) by the
<tr><td>version</td><td>HexChat version number.</td></tr> <tr><td>version</td><td>HexChat 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_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>win_status</td><td>window status: "active", "hidden" or "normal" (since 2.0.9).</td>
<tr><td>xchatdir</td><td>HexChat config directory, e.g.: /home/user/.config/hexchat <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>hexchatdir</td><td>HexChat config directory, e.g.: /home/user/.config/hexchat <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>HexChat config directory, e.g.: /home/user/.config/hexchat (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> <tr><td>hexchatdirfs</td><td>HexChat config directory, e.g.: /home/user/.config/hexchat.<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 hexchatdirfs, but hexchatdir instead.</small></td></tr>
</table> </table>
</blockquote> </blockquote>

View file

@ -162,7 +162,7 @@ are available to be queried:
* **server:** Current server name (what the server claims to be) or None if you are not connected. * **server:** Current server name (what the server claims to be) or None if you are not connected.
* **topic:** Current channel topic. * **topic:** Current channel topic.
* **version:** HexChat version number. * **version:** HexChat version number.
* **xchatdir:** HexChat config directory e.g.: "~/.config/hexchat". * **hexchatdir:** HexChat config directory e.g.: "~/.config/hexchat".
Example: Example:

View file

@ -95,7 +95,7 @@ before Eggdrop and is broadly considered the industry standard language for auto
<tr valign=top> <tr valign=top>
<td align=right><b>Example:</b></td> <td align=right><b>Example:</b></td>
<td><pre>/tcl puts "Hello, XChat World!" <td><pre>/tcl puts "Hello, XChat World!"
/tcl xchatdir</pre></td> /tcl hexchatdir</pre></td>
</tr> </tr>
@ -706,12 +706,12 @@ The following fields are currently defined:
</tr> </tr>
<tr> <tr>
<td>version </td> <td>version </td>
<td> xchat version number. <td> HexChat version number.
</td> </td>
</tr> </tr>
<tr> <tr>
<td>xchatdir </td> <td>hexchatdir </td>
<td> xchat config directory, e.g.: /home/user/.xchat.</td> <td> HexChat config directory, e.g.: /home/user/.config/hexchat.</td>
</tr> </tr>
</table><br> </table><br>
</td> </td>
@ -724,7 +724,7 @@ The following fields are currently defined:
<tr valign=top> <tr valign=top>
<td align=right nowrap><b>See Also:</b></td> <td align=right nowrap><b>See Also:</b></td>
<td><a href='#away'>away</a>, <a href='#channel'>channel</a>, <a href='#host'>host</a>, <a href='#me'>me</a>, <a href='#network'>network</a>, <a href='#server'>server</a>, <a href='#topic'>topic</a>, <a href='#version'>version</a>, <a href='#xchatdir'>xchatdir</a></td> <td><a href='#away'>away</a>, <a href='#channel'>channel</a>, <a href='#host'>host</a>, <a href='#me'>me</a>, <a href='#network'>network</a>, <a href='#server'>server</a>, <a href='#topic'>topic</a>, <a href='#version'>version</a>, <a href='#hexchatdir'>hexchatdir</a></td>
</tr> </tr>
@ -3581,7 +3581,7 @@ print "[timers]"</pre></td>
<tr valign=top> <tr valign=top>
<td align=right nowrap><b>See Also:</b></td> <td align=right nowrap><b>See Also:</b></td>
<td><a href='#xchatdir'>xchatdir</a></td> <td><a href='#hexchatdir'>hexchatdir</a></td>
</tr> </tr>
@ -3594,17 +3594,17 @@ print "[timers]"</pre></td>
<p> <p>
<a name='xchatdir'> </a> <a name='hexchatdir'> </a>
<table width=100% border=0 bgcolor=#eeeeee cellpadding=3 cellspacing=0> <table width=100% border=0 bgcolor=#eeeeee cellpadding=3 cellspacing=0>
<tr valign=top> <tr valign=top>
<td align=right width=1% ><b>Name:</b></td> <td align=right width=1% ><b>Name:</b></td>
<td>xchatdir - Returns the current xchat config directory.</td> <td>hexchatdir - Returns the current HexChat config directory.</td>
</tr> </tr>
<tr valign=top> <tr valign=top>
<td align=right><b>Synopsis:</b></td> <td align=right><b>Synopsis:</b></td>
<td><pre>xchatdir</pre></td> <td><pre>hexchatdir</pre></td>
</tr> </tr>
<tr valign=top> <tr valign=top>
@ -3614,7 +3614,7 @@ print "[timers]"</pre></td>
<tr valign=top> <tr valign=top>
<td align=right><b>Example:</b></td> <td align=right><b>Example:</b></td>
<td><pre>print "My XChat config directory is [xchatdir]"</pre></td> <td><pre>print "My XChat config directory is [hexchatdir]"</pre></td>
</tr> </tr>
<tr valign=top> <tr valign=top>

View file

@ -1054,9 +1054,11 @@ hexchat_get_info (hexchat_plugin *ph, const char *id)
return PACKAGE_VERSION; return PACKAGE_VERSION;
case 0xdd9b1abd: /* xchatdir */ case 0xdd9b1abd: /* xchatdir */
case 0x9a70daba: /* hexchatdir */
return get_xdir_utf8 (); return get_xdir_utf8 ();
case 0xe33f6c4a: /* xchatdirfs */ case 0xe33f6c4a: /* xchatdirfs */
case 0xc1a52107: /* hexchatdirfs */
return get_xdir_fs (); return get_xdir_fs ();
} }