Merge branch 'wdk'

This commit is contained in:
Berke Viktor 2012-07-11 19:46:46 +02:00
commit 1ea726a918
416 changed files with 62125 additions and 2755 deletions

136
COPYING.rtf Normal file
View File

@ -0,0 +1,136 @@
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\lang1033\f0\fs20 GNU GENERAL PUBLIC LICENSE\par
\par
Version 2, June 1991\par
\par
Copyright (C) 1989, 1991 Free Software Foundation, Inc. \par
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\par
\par
Everyone is permitted to copy and distribute verbatim copies\par
of this license document, but changing it is not allowed.\par
\par
Preamble\par
\par
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.\par
\par
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.\par
\par
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.\par
\par
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\par
\par
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.\par
\par
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.\par
\par
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.\par
\par
The precise terms and conditions for copying, distribution and modification follow.\par
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\par
\par
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".\par
\par
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.\par
\par
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.\par
\par
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.\par
\par
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:\par
\par
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. \par
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. \par
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) \par
\par
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.\par
\par
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.\par
\par
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.\par
\par
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:\par
\par
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, \par
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, \par
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) \par
\par
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.\par
\par
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.\par
\par
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.\par
\par
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.\par
\par
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.\par
\par
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.\par
\par
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.\par
\par
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.\par
\par
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.\par
\par
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.\par
\par
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\par
\par
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.\par
\par
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.\par
\par
NO WARRANTY\par
\par
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\par
\par
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\par
END OF TERMS AND CONDITIONS\par
How to Apply These Terms to Your New Programs\par
\par
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\par
\par
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.\par
\par
one line to give the program's name and an idea of what it does.\par
Copyright (C) yyyy name of author\par
\par
This program is free software; you can redistribute it and/or\par
modify it under the terms of the GNU General Public License\par
as published by the Free Software Foundation; either version 2\par
of the License, or (at your option) any later version.\par
\par
This program is distributed in the hope that it will be useful,\par
but WITHOUT ANY WARRANTY; without even the implied warranty of\par
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\par
GNU General Public License for more details.\par
\par
You should have received a copy of the GNU General Public License\par
along with this program; if not, write to the Free Software\par
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\par
\par
Also add information on how to contact you by electronic and paper mail.\par
\par
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:\par
\par
Gnomovision version 69, Copyright (C) year name of author\par
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details\par
type `show w'. This is free software, and you are welcome\par
to redistribute it under certain conditions; type `show c' \par
for details.\par
\par
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.\par
\par
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:\par
\par
Yoyodyne, Inc., hereby disclaims all copyright\par
interest in the program `Gnomovision'\par
(which makes passes at compilers) written \par
by James Hacker.\par
\par
signature of Ty Coon, 1 April 1989\par
Ty Coon, President of Vice\par
\par
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. \par
}

16
config.h Normal file
View File

@ -0,0 +1,16 @@
#define LOCALEDIR "./locale"
#define ENABLE_NLS
#define USE_GMODULE
#define USE_PLUGIN
#define USE_OPENSSL
#define USE_LIBSEXY
#define USE_IPV6
#define HAVE_ISO_CODES
#define PACKAGE_NAME "xchat"
#define PACKAGE_VERSION "1508-3"
#define XCHAT_RELEASE "2.8.8"
#define XCHATLIBDIR "."
#define XCHATSHAREDIR "."
#define OLD_PERL
#define GETTEXT_PACKAGE "xchat"
#define PACKAGE_TARNAME "xchat-2.8.8"

View File

@ -40,6 +40,7 @@ dnl AH_VERBATIM([USE_GNOME],[#undef USE_GNOME])
AH_VERBATIM([USE_SHM],[#undef USE_SHM])
AH_VERBATIM([USE_GTKSPELL],[#undef USE_GTKSPELL])
AH_VERBATIM([USE_LIBSEXY],[#undef USE_LIBSEXY])
AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES])
AH_VERBATIM([USE_LIBNOTIFY],[#undef USE_LIBNOTIFY])
AH_VERBATIM([USE_IPV6],[#undef USE_IPV6])
AH_VERBATIM([USE_MMX],[#undef USE_MMX])
@ -549,7 +550,14 @@ if test "$spell" = "libsexy" ; then
fi
if test "$spell" = "static" ; then
PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.0.0, [
AC_DEFINE(HAVE_ISO_CODES)
AC_DEFINE(USE_LIBSEXY)
GUI_CFLAGS="$GUI_CFLAGS -I/usr/include/libxml2"
LIBS="$LIBS -lxml2"
], [
AC_MSG_ERROR("Cannot find libxml2")
])
fi
dnl *********************************************************************

264
plugins/checksum/checksum.c Normal file
View File

@ -0,0 +1,264 @@
/* XChat-WDK
* Copyright (c) 2010-2012 Berke Viktor.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <openssl/sha.h>
#include "xchat-plugin.h"
#define BUFSIZE 32768
#define DEFAULT_LIMIT 256 /* default size is 256 MiB */
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef stat64
#define stat64 _stat64
#endif
static xchat_plugin *ph; /* plugin handle */
static const char name[] = "Checksum";
static const char desc[] = "Calculate checksum for DCC file transfers";
static const char version[] = "3.0";
/* Use of OpenSSL SHA256 interface: http://adamlamers.com/?p=5 */
static void
sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65])
{
int i;
for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
{
sprintf (outputBuffer + (i * 2), "%02x", hash[i]);
}
outputBuffer[64] = 0;
}
static void
sha256 (char *string, char outputBuffer[65])
{
int i;
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init (&sha256);
SHA256_Update (&sha256, string, strlen (string));
SHA256_Final (hash, &sha256);
for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
{
sprintf (outputBuffer + (i * 2), "%02x", hash[i]);
}
outputBuffer[64] = 0;
}
static int
sha256_file (char *path, char outputBuffer[65])
{
int bytesRead;
unsigned char *buffer;
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
FILE *file = fopen (path, "rb");
if (!file)
{
return -534;
}
SHA256_Init (&sha256);
buffer = malloc (BUFSIZE);
bytesRead = 0;
if (!buffer)
{
return ENOMEM;
}
while ((bytesRead = fread (buffer, 1, BUFSIZE, file)))
{
SHA256_Update (&sha256, buffer, bytesRead);
}
SHA256_Final (hash, &sha256);
sha256_hash_string (hash, outputBuffer);
fclose (file);
free (buffer);
return 0;
}
static void
set_limit (char* size)
{
int buffer = atoi (size);
if (buffer > 0 && buffer < INT_MAX)
{
if (xchat_pluginpref_set_int (ph, "limit", buffer))
{
xchat_printf (ph, "File size limit has successfully been set to: %d MiB\n", buffer);
}
else
{
xchat_printf (ph, "File access error while saving!\n");
}
}
else
{
xchat_printf (ph, "Invalid input!\n");
}
}
static int
get_limit ()
{
int size = xchat_pluginpref_get_int (ph, "limit");
if (size <= -1 || size >= INT_MAX)
{
return DEFAULT_LIMIT;
}
else
{
return size;
}
}
static void
print_limit ()
{
xchat_printf (ph, "File size limit for checksums: %d MiB", get_limit ());
}
static int
dccrecv_cb (char *word[], void *userdata)
{
int result;
struct stat64 buffer; /* buffer for storing file info */
char sum[65]; /* buffer for checksum */
result = stat64 (word[2], &buffer);
if (result == 0) /* stat returns 0 on success */
{
if (buffer.st_size <= (unsigned long long) get_limit () * 1048576)
{
sha256_file (word[2], sum); /* word[2] is the full filename */
/* try to print the checksum in the privmsg tab of the sender */
xchat_set_context (ph, xchat_find_context (ph, NULL, word[3]));
xchat_printf (ph, "SHA-256 checksum for %s (local): %s\n", word[1], sum);
}
else
{
xchat_set_context (ph, xchat_find_context (ph, NULL, word[3]));
xchat_printf (ph, "SHA-256 checksum for %s (local): (size limit reached, no checksum calculated, you can increase it with /CHECKSUM INC)\n", word[1]);
}
}
else
{
xchat_printf (ph, "File access error!\n");
}
return XCHAT_EAT_NONE;
}
static int
dccoffer_cb (char *word[], void *userdata)
{
int result;
struct stat64 buffer; /* buffer for storing file info */
char sum[65]; /* buffer for checksum */
result = stat64 (word[3], &buffer);
if (result == 0) /* stat returns 0 on success */
{
if (buffer.st_size <= (unsigned long long) get_limit () * 1048576)
{
sha256_file (word[3], sum); /* word[3] is the full filename */
xchat_commandf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): %s", word[2], word[1], sum);
}
else
{
xchat_set_context (ph, xchat_find_context (ph, NULL, word[3]));
xchat_printf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): (size limit reached, no checksum calculated)", word[2], word[1]);
}
}
else
{
xchat_printf (ph, "File access error!\n");
}
return XCHAT_EAT_NONE;
}
static void
checksum (char *word[], void *userdata)
{
if (!stricmp ("GET", word[2]))
{
print_limit ();
}
else if (!stricmp ("SET", word[2]))
{
set_limit (word[3]);
}
else
{
xchat_printf (ph, "Usage: /CHECKSUM GET|INC|DEC\n");
xchat_printf (ph, " GET - print the maximum file size (in MiB) to be hashed\n");
xchat_printf (ph, " SET <filesize> - set the maximum file size (in MiB) to be hashed\n");
}
}
int
xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
ph = plugin_handle;
*plugin_name = name;
*plugin_desc = desc;
*plugin_version = version;
/* this is required for the very first run */
if (xchat_pluginpref_get_int (ph, "limit") == -1)
{
xchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT);
}
xchat_hook_command (ph, "CHECKSUM", XCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", 0);
xchat_hook_print (ph, "DCC RECV Complete", XCHAT_PRI_NORM, dccrecv_cb, NULL);
xchat_hook_print (ph, "DCC Offer", XCHAT_PRI_NORM, dccoffer_cb, NULL);
xchat_printf (ph, "%s plugin loaded\n", name);
return 1;
}
int
xchat_plugin_deinit (void)
{
xchat_printf (ph, "%s plugin unloaded\n", name);
return 1;
}

View File

@ -0,0 +1,3 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>checksum</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcchecksum</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcchecksum</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHECKSUM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>checksum.def</ModuleDefinitionFile>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;CHECKSUM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>checksum.def</ModuleDefinitionFile>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="checksum.c" />
</ItemGroup>
<ItemGroup>
<None Include="checksum.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="checksum.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="checksum.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: checksum.obj checksum.def
link $(LDFLAGS) $(LIBS) /dll /out:xcchecksum.dll /def:checksum.def checksum.obj
checksum.def:
echo EXPORTS > checksum.def
echo xchat_plugin_init >> checksum.def
echo xchat_plugin_deinit >> checksum.def
checksum.obj: checksum.c makefile.mak
cl $(CFLAGS) /I.. checksum.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

329
plugins/dns/dns.c Normal file
View File

@ -0,0 +1,329 @@
/* XChat Win32 DNS Plugin
* Copyright (C) 2003-2004 Peter Zelezny.
* Copyright (C) 2012 Berke Viktor.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/*
* Requires MS Visual Studio and IPV6 headers to compile (run nmake).
* Compiling with gcc (mingw) will fail due to missing gai_strerror.
*/
#define DNS_VERSION "2.4"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define USE_IPV6
#ifdef WIN32
#ifdef USE_IPV6
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <winsock2.h>
#endif
#else
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
#endif
#include "xchat-plugin.h"
#include "thread.h"
#define HELP "Usage: DNS <nickname|hostname|numerical address>\n"
#define HEAD "\0034[DNS]\017\t"
#define PIPE_READ 0
#define PIPE_WRITE 1
#define MAX_HOSTNAME 128
static xchat_plugin *ph;
static thread *active_thread = NULL;
static int
waitline (void *source, char *buf, int bufsize)
{
int i = 0;
int len;
while(1)
{
len = 1;
/* we can't read() here, due to glib's giowin32 */
if(ph->xchat_read_fd(ph, source, buf + i, &len) != 0)
return -1;
if(buf[i] == '\n' || bufsize == i + 1)
{
buf[i] = 0;
return i;
}
i++;
}
}
static void *
thread_function (void *ud)
{
#ifdef USE_IPV6
struct addrinfo *ent;
struct addrinfo *cur;
struct addrinfo hints;
#else
struct hostent *ent;
#endif
thread *th = ud;
int fd = th->pipe_fd[PIPE_WRITE];
int ret;
char ipstring[MAX_HOSTNAME];
char reverse[MAX_HOSTNAME];
// int i;
active_thread = th;
#ifdef USE_IPV6
memset (&hints, 0, sizeof (hints));
hints.ai_family = PF_UNSPEC; /* support ipv6 and ipv4 */
hints.ai_flags = AI_CANONNAME;
// hints.ai_socktype = SOCK_STREAM;
ret = getaddrinfo (th->userdata, NULL, &hints, &ent);
if (ret != 0)
{
sprintf (ipstring, "1%d\n", ret); /* failed */
write (fd, ipstring, strlen (ipstring));
// Sleep (3000);
active_thread = NULL;
return 0;
}
// i = 0;
cur = ent;
while (cur)
{
/* find the numeric IP number */
ipstring[0] = 0;
getnameinfo (cur->ai_addr, cur->ai_addrlen,
ipstring, sizeof (ipstring), NULL, 0, NI_NUMERICHOST);
if (cur->ai_canonname)
{
/* force reverse lookup if canonname & ipstring are the same */
if (/*i == 0 &&*/ strcmp (cur->ai_canonname, ipstring) == 0)
goto lamecode;
}
if (cur->ai_canonname)
{
write (fd, "0", 1);
write (fd, ipstring, strlen (ipstring));
write (fd, "\n", 1);
write (fd, cur->ai_canonname, strlen (cur->ai_canonname));
} else
{
lamecode:
// ret = 1;
// if (i == 0)
{
/* reverse lookup */
reverse[0] = 0;
ret = getnameinfo (cur->ai_addr, cur->ai_addrlen,
reverse, sizeof (reverse), NULL, 0, NI_NAMEREQD);
}
write (fd, "0", 1);
write (fd, ipstring, strlen (ipstring));
write (fd, "\n", 1);
if (ret == 0)
write (fd, reverse, strlen (reverse));
}
write (fd, "\n", 1);
// i++;
cur = cur->ai_next;
}
/* tell the parent we're done */
write (fd, "2\n", 2);
freeaddrinfo (ent);
#else
ent = gethostbyname (th->userdata);
if (ent)
{
write (fd, "0", 1);
write (fd, ent->h_name, strlen (ent->h_name));
write (fd, "\n", 1);
write (fd, ent->h_name, strlen (ent->h_name));
write (fd, "\n", 1);
write (fd, "2\n", 2);
} else
{
write (fd, "10\n", 1);
}
#endif
// Sleep (3000);
active_thread = NULL; /* race condition, better than nothing */
return 0;
}
static int
dns_close_pipe (int fd)
{
close (fd);
return 0;
}
/* read messages comming from the child (through the pipe) */
static int
dns_read_cb (int fd, int flags, thread *th, void *source)
{
char buf[512];
char buf2[512];
while (waitline (source, buf, sizeof (buf)))
{
switch (buf[0])
{
case '0': /* got data to show */
waitline (source, buf2, sizeof (buf2));
if (buf2[0] == 0)
xchat_printf(ph, HEAD"\002Numerical\002: %s\n", buf + 1);
else
xchat_printf(ph, HEAD"\002Canonical\002: %s \002Numerical\002: %s\n", buf2, buf + 1);
return 1;
case '1': /* failed */
xchat_printf(ph, HEAD"Lookup failed. %s\n", gai_strerrorA (atoi (buf + 1)));
case '2': /* done */
// close (th->pipe_fd[PIPE_WRITE]);
// close (th->pipe_fd[PIPE_READ]);
xchat_hook_timer(ph, 3000, dns_close_pipe, (void *)th->pipe_fd[PIPE_WRITE]);
xchat_hook_timer(ph, 4000, dns_close_pipe, (void *)th->pipe_fd[PIPE_READ]);
free (th->userdata); /* hostname strdup'ed */
free (th);
return 0;
}
}
return 1;
}
/* find hostname from nickname (search the userlist, current chan only) */
static char *
find_nick_host (char *nick)
{
xchat_list *list;
char *at;
const char *host;
list = xchat_list_get (ph, "users");
if (!list)
return NULL;
while (xchat_list_next (ph, list))
{
if (stricmp (nick, xchat_list_str (ph, list, "nick")) == 0)
{
host = xchat_list_str (ph, list, "host");
if (host)
{
at = strrchr (host, '@');
if (at)
return at + 1;
}
break;
}
}
return NULL;
}
static int
dns_cmd_cb (char *word[], char *word_eol[], void *ud)
{
thread *th;
char *nickhost;
if (!word[2][0])
{
xchat_print (ph, HELP);
return XCHAT_EAT_ALL;
}
th = thread_new ();
if (th)
{
nickhost = find_nick_host (word[2]);
if (nickhost)
{
xchat_printf (ph, HEAD"Looking up %s (%s)...\n", nickhost, word[2]);
th->userdata = strdup (nickhost);
} else
{
xchat_printf (ph, HEAD"Looking up %s...\n", word[2]);
th->userdata = strdup (word[2]);
}
if (thread_start (th, thread_function, th))
{
xchat_hook_fd(ph, th->pipe_fd[PIPE_READ],
XCHAT_FD_READ | XCHAT_FD_EXCEPTION | XCHAT_FD_NOTSOCKET,
(void *)dns_read_cb, th);
}
}
return XCHAT_EAT_ALL;
}
int
xchat_plugin_deinit (xchat_plugin *plugin_handle)
{
while (active_thread) /* children will set this var to NULL soon... */
{
Sleep (1000);
}
xchat_printf (ph, "DNS plugin unloaded\n");
return 1;
}
int
xchat_plugin_init
(xchat_plugin *plugin_handle, char **plugin_name,
char **plugin_desc, char **plugin_version, char *arg)
{
/* we need to save this for use with any xchat_* functions */
ph = plugin_handle;
*plugin_name = "DNS";
*plugin_desc = "Threaded IPv4/6 DNS Command";
*plugin_version = DNS_VERSION;
xchat_hook_command(ph, "DNS", XCHAT_PRI_LOW, dns_cmd_cb, HELP, 0);
xchat_printf (ph, "DNS plugin loaded\n");
return 1; /* return 1 for success */
}

3
plugins/dns/dns.def Normal file
View File

@ -0,0 +1,3 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit

114
plugins/dns/dns.vcxproj Normal file
View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3786FA8C-3E76-45E3-984E-FCCFF44729C9}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>dns</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcdns</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcdns</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DNS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>dns.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;DNS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>dns.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="dns.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dns.c" />
<ClCompile Include="thread.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="thread.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="dns.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dns.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="thread.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="thread.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

22
plugins/dns/makefile.mak Normal file
View File

@ -0,0 +1,22 @@
include "..\..\src\makeinc.mak"
DNS_OBJECTS = \
dns.obj \
thread.obj
all: $(DNS_OBJECTS) dns.def
link $(LDFLAGS) $(LIBS) /dll /out:xcdns.dll /def:dns.def $(DNS_OBJECTS)
dns.def:
echo EXPORTS > dns.def
echo xchat_plugin_init >> dns.def
echo xchat_plugin_deinit >> dns.def
.c.obj:
$(CC) $(CFLAGS) $(GLIB) /I.. /c $<
clean:
del *.obj
del *.dll
del *.exp
del *.lib

33
plugins/dns/thread.c Normal file
View File

@ -0,0 +1,33 @@
#include <fcntl.h>
#include "thread.h"
thread *
thread_new (void)
{
thread *th;
th = calloc (1, sizeof (*th));
if (!th)
{
return NULL;
}
if (_pipe (th->pipe_fd, 4096, _O_BINARY) == -1)
{
free (th);
return NULL;
}
return th;
}
int
thread_start (thread *th, void *(*start_routine)(void *), void *arg)
{
DWORD id;
CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, arg, 0, (DWORD *)&id));
th->threadid = id;
return 1;
}

11
plugins/dns/thread.h Normal file
View File

@ -0,0 +1,11 @@
#include <windows.h>
typedef struct
{
DWORD threadid;
int pipe_fd[2];
void *userdata;
} thread;
thread *thread_new (void);
int thread_start (thread *th, void *(*start_routine)(void *), void *arg);

94
plugins/doat/doat.c Normal file
View File

@ -0,0 +1,94 @@
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING or http://lwsitu.com/xchat/COPYING
* for more details. */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "xchat-plugin.h"
static xchat_plugin *ph;
static int
parse_command( char *word[], char *word_eol[], void *userdata ) {
char *channel = NULL, *server = NULL, *token = NULL;
/* char *save_ptr1 = NULL;*/
char *str1 = NULL;
char *delimiter = NULL;
xchat_context *ctx = NULL;
if( word[2] != NULL && word[3] != NULL ) {
for( str1 = word[2]; ; str1 = NULL ) {
/* token = strtok_r( str1, ",", &save_ptr1 );*/
token = strtok( str1, "," );
/* printf( "token: %s\n", token );*/
if( token == NULL ) {
break;
}
channel = strdup( token );
delimiter = strchr( channel, '/' );
server = NULL;
if( delimiter != NULL ) {
*delimiter = '\0';
if( strlen( delimiter + 1 ) > 0 ) {
server = strdup( delimiter + 1 );
}
}
/* /Network form */
if( strlen( channel ) == 0 ) {
free( channel );
channel = NULL;
}
/* printf( "channel[%s] server[%s]\n", channel, server );*/
if( (ctx = xchat_find_context( ph, server, channel ) ) != NULL ) {
if( xchat_set_context( ph, ctx ) ) {
xchat_command( ph, word_eol[3] );
}
}
if( channel != NULL ) {
free( channel );
}
if( server != NULL ) {
free( server );
}
}
}
return XCHAT_EAT_XCHAT;
}
int
xchat_plugin_init( xchat_plugin * plugin_handle, char **plugin_name,
char **plugin_desc, char **plugin_version, char *arg ) {
ph = plugin_handle;
*plugin_name = "Do At";
*plugin_version = "1.0001";
*plugin_desc = "Perform an arbitrary command on multiple channels";
xchat_hook_command( ph, "doat", XCHAT_PRI_NORM, parse_command, "DOAT [channel,list,/network] [command], perform a command on multiple contexts", NULL );
xchat_print (ph, "Do At plugin loaded\n");
return 1;
}
int
xchat_plugin_deinit (void)
{
xchat_print (ph, "Do At plugin unloaded\n");
return 1;
}

3
plugins/doat/doat.def Normal file
View File

@ -0,0 +1,3 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit

106
plugins/doat/doat.vcxproj Normal file
View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4980AF24-9D42-427D-A8E6-0DF3B97C455D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>doat</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcdoat</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcdoat</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>doat.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="doat.c" />
</ItemGroup>
<ItemGroup>
<None Include="doat.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="doat.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="doat.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

18
plugins/doat/makefile.mak Normal file
View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: doat.obj doat.def
link $(LDFLAGS) $(LIBS) /dll /out:xcdoat.dll /def:doat.def doat.obj
doat.def:
echo EXPORTS > doat.def
echo xchat_plugin_init >> doat.def
echo xchat_plugin_deinit >> doat.def
doat.obj: doat.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. doat.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

502
plugins/ewc/COPYING Normal file
View File

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

231
plugins/ewc/ewc.c Normal file
View File

@ -0,0 +1,231 @@
/*
EasyWinampControl - A Winamp "What's playing" plugin for Xchat
Copyright (C) Yann HAMON & contributors
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "xchat-plugin.h"
#include <windows.h>
static xchat_plugin *ph; /* plugin handle */
static int enable = 1;
// For example, circularstrstr("winamp", "pwi", 3) would return 5 (the index of p)
int circularstrstr(char* a, char* b, int nb)
{
int equal = 1;
int length;
int pos=-1;
int i, j;
length = strlen(a);
for (i=0; i<length && pos == -1; ++i) {
equal = 1;
for (j=0; j<nb;j++) {
if (a[(i+j)%length] != b[j])
equal = 0;
}
if (equal == 1)
pos = i;
}
return pos;
}
void GetCurrentSongsName(HWND hwndWinamp, char* title, int titlesize)
{
int pos;
char *title2;
int i, j=0;
int length;
char *p;
GetWindowText(hwndWinamp, title, titlesize);
length = strlen(title);
if ((pos = circularstrstr(title, "- Winamp ***", 12)) != -1) {
// The option "scroll song title in taskbar" is on
title2 = (char*) malloc (titlesize*sizeof(char));
for (i=(pos+12)%length; i!=pos; i=(i+1)%length)
title2[j++] = title[i];
title2[j] = '\0';
p = title2;
while (p<title2+titlesize && *p != '.')
p++;
p+=2; // Delete the . and the following white space
strcpy(title, p);
free(title2);
}
else {
p = title;
while (p<title+titlesize && *p != '.')
p++;
p+=2; // Delete the . and the following white space
if (p<title+titlesize)
strncpy(title, p, titlesize-(p-title));
// Delete the trailing "- winamp"
p = title + titlesize - 1;
while (p>title && *p != '-') p--;
*p = '\0';
}
}
// Controlling winamp
static int wcmd_cb(char *word[], char *word_eol[], void *userdata)
{
// Everything's here : http://winamp.com/nsdn/winamp2x/dev/sdk/api.php
// The previous url seems dead, see http://forums.winamp.com/showthread.php?threadid=180297
HWND hwndWinamp = NULL;
if ((hwndWinamp = FindWindow("Winamp v1.x",NULL)) == NULL) {
xchat_print(ph, "Winamp's window not found - Is winamp really running?\n");
}
else {
if (strcmp(word[1], "") == 0)
xchat_print(ph, "Usage: wcmd [command]\n");
else if (strcmp(word[2], "next") == 0) {
xchat_print(ph, "Loading next song...\n");
SendMessage (hwndWinamp, WM_COMMAND, 40048, 0);
}
else if (strcmp(word[2], "prev") == 0) {
xchat_print(ph, "Loading previous song...\n");
SendMessage (hwndWinamp, WM_COMMAND, 40044, 0);
}
else if (strcmp(word[2], "play") == 0) {
xchat_print(ph, "Playin'...\n");
SendMessage (hwndWinamp, WM_COMMAND, 40045, 0);
}
else if (strcmp(word[2], "stop") == 0) {
xchat_print(ph, "Winamp stopped!...\n");
SendMessage (hwndWinamp, WM_COMMAND, 40047, 0);
}
else if (strcmp(word[2], "pause") == 0) {
SendMessage (hwndWinamp, WM_COMMAND, 40046, 0);
}
}
return XCHAT_EAT_ALL;
}
// Display current song
static int wp_cb(char *word[], char *word_eol[], void *userdata)
{
HWND hwndWinamp = NULL;
int bitrate, length, elapsed, minutes, seconds, eminutes, eseconds, samplerate, nbchannels;
char elapsedtime[7];
char totaltime[7];
char this_title[1024];
if ((hwndWinamp = FindWindow("Winamp v1.x",NULL)) == NULL)
xchat_print(ph, "Winamp's window not found - Is winamp really running?\n");
else {
//Winamp's running
// Seems buggy when winamp2's agent is running, and winamp not (or winamp3) -> crashes xchat.
SendMessage(hwndWinamp, WM_USER, (WPARAM)0, (LPARAM)125);
if ((samplerate = SendMessage(hwndWinamp, WM_USER, (WPARAM)0, (LPARAM)126)) == 0) {
xchat_print(ph, "Could not get current song's samplerate... !?\n");
return XCHAT_EAT_ALL;
}
if ((bitrate = SendMessage(hwndWinamp, WM_USER, (WPARAM)1, (LPARAM)126)) == 0) {
xchat_print(ph, "Could not get current song's bitrate... !?\n");
return XCHAT_EAT_ALL;
}
if ((nbchannels = SendMessage(hwndWinamp, WM_USER, (WPARAM)2, (LPARAM)126)) == 0) {
xchat_print(ph, "Could not get the number of channels... !?\n");
return XCHAT_EAT_ALL;
}
if ((length = SendMessage(hwndWinamp, WM_USER, (WPARAM)1, (LPARAM)105)) == 0) {
// Could be buggy when streaming audio or video, returned length is unexpected;
// How to detect is Winamp is streaming, and display ??:?? in that case?
xchat_print(ph, "Could not get current song's length... !?\n");
return XCHAT_EAT_ALL;
}
else {
minutes = length/60;
seconds = length%60;
if (seconds>9)
wsprintf(totaltime, "%d:%d", minutes, seconds);
else
wsprintf(totaltime, "%d:0%d", minutes, seconds);
}
if ((elapsed = SendMessage(hwndWinamp, WM_USER, (WPARAM)0, (LPARAM)105)) == 0) {
xchat_print(ph, "Could not get current song's elapsed time... !?\n");
return XCHAT_EAT_ALL;
}
else {
eminutes = (elapsed/1000)/60; /* kinda stupid sounding, but e is for elapsed */
eseconds = (elapsed/1000)%60;
if (eseconds>9)
wsprintf(elapsedtime, "%d:%d", eminutes, eseconds);
else
wsprintf(elapsedtime, "%d:0%d", eminutes, eseconds);
}
if ((bitrate = SendMessage(hwndWinamp, WM_USER, (WPARAM)1, (LPARAM)126)) == 0) {
xchat_print(ph, "Could not get current song's bitrate... !?\n");
return XCHAT_EAT_ALL;
}
GetCurrentSongsName(hwndWinamp, this_title, 1024);
xchat_commandf(ph, "dispcurrsong %d %d %d %s %s %s", samplerate, bitrate, nbchannels, elapsedtime, totaltime, this_title);
}
return XCHAT_EAT_ALL; /* eat this command so xchat and other plugins can't process it */
}
int xchat_plugin_init(xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
{
/* we need to save this for use with any xchat_* functions */
ph = plugin_handle;
*plugin_name = "EasyWinampControl";
*plugin_desc = "Some commands to remotely control winamp";
*plugin_version = "1.2";
xchat_hook_command(ph, "wp", XCHAT_PRI_NORM, wp_cb,
"Usage: wp", 0);
xchat_hook_command(ph, "wcmd", XCHAT_PRI_NORM, wcmd_cb,
"Usage: wcmd [play|pause|stop|prev|next]", 0);
xchat_print(ph, "EasyWinampControl plugin loaded\n");
return 1; /* return 1 for success */
}
int xchat_plugin_deinit(void)
{
xchat_print(ph, "EasyWinampControl plugin unloaded\n");
return 1;
}

18
plugins/ewc/makefile.mak Normal file
View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: ewc.obj ewc.def
link $(LDFLAGS) $(LIBS) /dll /out:xcewc.dll /def:ewc.def ewc.obj
ewc.def:
echo EXPORTS > ewc.def
echo xchat_plugin_init >> ewc.def
echo xchat_plugin_deinit >> ewc.def
ewc.obj: ewc.c makefile.mak
cl $(CFLAGS) ewc.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

138
plugins/exec/exec.c Normal file
View File

@ -0,0 +1,138 @@
/* XChat-WDK
* Copyright (c) 2011 Berke Viktor.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <windows.h>
#include <time.h>
#include "xchat-plugin.h"
static xchat_plugin *ph; /* plugin handle */
static const char name[] = "Exec";
static const char desc[] = "Execute commands inside XChat";
static const char version[] = "1.1";
static int
run_command (char *word[], char *word_eol[], void *userdata)
{
char commandLine[1024];
char buffer[4096];
DWORD dwRead = 0;
DWORD dwLeft = 0;
DWORD dwAvail = 0;
time_t start;
double timeElapsed;
HANDLE readPipe;
HANDLE writePipe;
STARTUPINFO sInfo;
PROCESS_INFORMATION pInfo;
SECURITY_ATTRIBUTES secattr;
ZeroMemory (&secattr, sizeof (secattr));
secattr.nLength = sizeof (secattr);
secattr.bInheritHandle = TRUE;
if (strlen (word[2]) > 0)
{
strcpy (commandLine, "cmd.exe /c ");
if (!stricmp("-O", word[2]))
{
/*strcat (commandLine, word_eol[3]);*/
xchat_printf (ph, "Printing Exec output to others is not supported yet.\n");
return XCHAT_EAT_XCHAT;
}
else
{
strcat (commandLine, word_eol[2]);
}
CreatePipe (&readPipe, &writePipe, &secattr, 0); /* might be replaced with MyCreatePipeEx */
ZeroMemory (&sInfo, sizeof (sInfo));
ZeroMemory (&pInfo, sizeof (pInfo));
sInfo.cb = sizeof (sInfo);
sInfo.dwFlags = STARTF_USESTDHANDLES;
sInfo.hStdInput = NULL;
sInfo.hStdOutput = writePipe;
sInfo.hStdError = writePipe;
CreateProcess (0, commandLine, 0, 0, TRUE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, 0, 0, &sInfo, &pInfo);
CloseHandle (writePipe);
start = time (0);
while (PeekNamedPipe (readPipe, buffer, 1, &dwRead, &dwAvail, &dwLeft) && timeElapsed < 10)
{
if (dwRead)
{
if (ReadFile (readPipe, buffer, sizeof (buffer) - 1, &dwRead, NULL) && dwRead != 0 )
{
/* avoid garbage */
buffer[dwRead] = '\0';
xchat_printf (ph, "%s", buffer);
}
}
else
{
/* this way we'll more likely get full lines */
SleepEx (100, TRUE);
}
timeElapsed = difftime (time (0), start);
}
}
/* display a newline to separate things */
xchat_printf (ph, "\n");
if (timeElapsed >= 10)
{
xchat_printf (ph, "Command took too much time to run, execution aborted.\n");
}
CloseHandle (readPipe);
CloseHandle (pInfo.hProcess);
CloseHandle (pInfo.hThread);
return XCHAT_EAT_XCHAT;
}
int
xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
ph = plugin_handle;
*plugin_name = name;
*plugin_desc = desc;
*plugin_version = version;
xchat_hook_command (ph, "EXEC", XCHAT_PRI_NORM, run_command, "Usage: /EXEC [-O] - execute commands inside XChat", 0);
xchat_printf (ph, "%s plugin loaded\n", name);
return 1; /* return 1 for success */
}
int
xchat_plugin_deinit (void)
{
xchat_printf (ph, "%s plugin unloaded\n", name);
return 1;
}

3
plugins/exec/exec.def Normal file
View File

@ -0,0 +1,3 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit

106
plugins/exec/exec.vcxproj Normal file
View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{17E4BE39-76F7-4A06-AD21-EFD0C5091F76}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>exec</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcexec</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcexec</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;EXEC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>exec.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;EXEC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>exec.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="exec.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="exec.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="exec.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="exec.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

18
plugins/exec/makefile.mak Normal file
View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: exec.obj exec.def
link $(LDFLAGS) $(LIBS) /dll /out:xcexec.dll /def:exec.def exec.obj
exec.def:
echo EXPORTS > exec.def
echo xchat_plugin_init >> exec.def
echo xchat_plugin_deinit >> exec.def
exec.obj: exec.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. exec.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

16
plugins/fishlim/INSTALL Normal file
View File

@ -0,0 +1,16 @@
Install dependencies (on Debian/Ubuntu):
sudo apt-get install build-essential libglib2.0-dev libssl-dev
Build the plugin with:
make
Install with:
sudo make install

21
plugins/fishlim/LICENSE Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) 2010-2011 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

40
plugins/fishlim/Makefile Normal file
View File

@ -0,0 +1,40 @@
OURCFLAGS = -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic `pkg-config --cflags glib-2.0 libcrypto` -DG_DISABLE_DEPRECATED=1 -fPIC $(CFLAGS)
#OURLINKFLAGS = `pkg-config --libs glib-2.0 libcrypto` -shared -fPIC -Wl,-z,defs $(CFLAGS) $(LDFLAGS)
OURLINKFLAGS = `pkg-config --libs glib-2.0 libcrypto` $(CFLAGS) $(LDFLAGS)
BASE_OBJECTS = irc.o fish.o keystore.o misc.o
PLUGIN_OBJECTS = $(BASE_OBJECTS) plugin_xchat.o
TEST_OBJECTS = $(BASE_OBJECTS) test.o
all: fishlim.so test
fish.o: fish.h keystore.h misc.h
irc.o: irc.h
keystore.o: keystore.h irc.h fish.h misc.h plugin_xchat.h
misc.o: misc.h
test.o: fish.h
plugin_xchat.o: fish.h irc.h keystore.h plugin_xchat.h
.c.o:
$(CC) $(OURCFLAGS) -c $< -o $@
fishlim.so: $(PLUGIN_OBJECTS)
$(CC) -shared $(OURLINKFLAGS) $(PLUGIN_OBJECTS) -o $@
test: $(TEST_OBJECTS)
$(CC) $(TEST_OBJECTS) -o $@ $(OURLINKFLAGS)
.PHONY: all clean distclean install uninstall
clean:
-$(RM) -f $(PLUGIN_OBJECTS) $(TEST_OBJECTS) fishlim.so test
distclean: clean
install: fishlim.so
install -d $(DESTDIR)/usr/lib/xchat/plugins/
install -m 644 fishlim.so $(DESTDIR)/usr/lib/xchat/plugins/
uninstall:
rm $(DESTDIR)/usr/lib/xchat/plugins/fishlim.so

45
plugins/fishlim/README Normal file
View File

@ -0,0 +1,45 @@
FiSHLiM
http://fishlim.kodafritt.se/
FiSHLiM is an XChat plugin for FiSH IRC encryption. It's my attempt at making
a simple, lightweight and secure plugin for this encryption protocol.
For installation instructions, see the INSTALL file.
Features
--------
Working:
* Sending/receiving messages
* Topic decryption
* Using unecrypted keys / keys without a password from blow.ini
* Pure protocol-level filtering (works with highlighting, nick coloring etc)
* Partially encrypted messages (i.e. prefixed with nickname by a bouncer)
Not working:
* Key exchange
* Password-protected key storage
* Topic encryption
* Remote exploitation (hopefully!)
* Plaintext content that contain +OK is decrypted twice
Commands
--------
/setkey [nick or #channel] password
Sets the encryption key for the nick or channel to password. The keys
are stored in the configuration file in ~/.xchat2/blow.ini
/delkey nick-or-#channel
Deletes the given nick or channel from the configuration file.

5
plugins/fishlim/bool.h Normal file
View File

@ -0,0 +1,5 @@
/* stdbool.h replacement for MSVC */
#define false 0
#define true 1
#define bool _Bool
typedef int _Bool;

192
plugins/fishlim/fish.c Normal file
View File

@ -0,0 +1,192 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include <openssl/blowfish.h>
#include "keystore.h"
#include "fish.h"
#define IB 64
static const char fish_base64[64] = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const signed char fish_unbase64[256] = {
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB,
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB,
// ! " # $ % & ' ( ) * + , - . /
IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB, 0, 1,
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
2, 3, 4, 5, 6, 7, 8, 9, 10,11,IB,IB,IB,IB,IB,IB,
// @ A B C D E F G H I J K L M N O
IB,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52,
// P Q R S T U V W X Y Z [ \ ] ^ _
53,54,55,56,57,58,59,60, 61,62,63,IB,IB,IB,IB,IB,
// ` a b c d e f g h i j k l m n o
IB,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26,
// p q r s t u v w x y z { | } ~ <del>
27,28,29,30,31,32,33,34, 35,36,37,IB,IB,IB,IB,IB,
};
#define GET_BYTES(dest, source) do { \
*((dest)++) = ((source) >> 24) & 0xFF; \
*((dest)++) = ((source) >> 16) & 0xFF; \
*((dest)++) = ((source) >> 8) & 0xFF; \
*((dest)++) = (source) & 0xFF; \
} while (0);
char *fish_encrypt(const char *key, size_t keylen, const char *message) {
BF_KEY bfkey;
size_t messagelen;
size_t i;
int j;
char *encrypted;
char *end;
unsigned char bit;
unsigned char word;
unsigned char d;
BF_set_key(&bfkey, keylen, (const unsigned char*)key);
messagelen = strlen(message);
if (messagelen == 0) return NULL;
encrypted = malloc(((messagelen-1)/8)*12 + 12 + 1); // each 8-byte block becomes 12 bytes
end = encrypted;
if (!encrypted) return NULL;
while (*message) {
// Read 8 bytes (a Blowfish block)
BF_LONG binary[2] = { 0, 0 };
unsigned char c;
for (i = 0; i < 8; i++) {
c = message[i];
binary[i >> 2] |= c << 8*(3 - (i&3));
if (c == '\0') break;
}
message += 8;
// Encrypt block
BF_encrypt(binary, &bfkey);
// Emit FiSH-BASE64
bit = 0;
word = 1;
for (j = 0; j < 12; j++) {
d = fish_base64[(binary[word] >> bit) & 63];
*(end++) = d;
bit += 6;
if (j == 5) {
bit = 0;
word = 0;
}
}
// Stop if a null terminator was found
if (c == '\0') break;
}
*end = '\0';
return encrypted;
}
char *fish_decrypt(const char *key, size_t keylen, const char *data) {
BF_KEY bfkey;
size_t i;
char *decrypted;
char *end;
unsigned char bit;
unsigned char word;
unsigned char d;
BF_set_key(&bfkey, keylen, (const unsigned char*)key);
decrypted = malloc(strlen(data)+1);
end = decrypted;
if (!decrypted) return NULL;
while (*data) {
// Convert from FiSH-BASE64
BF_LONG binary[2] = { 0, 0 };
bit = 0;
word = 1;
for (i = 0; i < 12; i++) {
d = fish_unbase64[(const unsigned char)*(data++)];
if (d == IB) goto decrypt_end;
binary[word] |= d << bit;
bit += 6;
if (i == 5) {
bit = 0;
word = 0;
}
}
// Decrypt block
BF_decrypt(binary, &bfkey);
// Copy to buffer
GET_BYTES(end, binary[0]);
GET_BYTES(end, binary[1]);
}
decrypt_end:
*end = '\0';
return decrypted;
}
/**
* Encrypts a message (see fish_decrypt). The key is searched for in the
* key store.
*/
char *fish_encrypt_for_nick(const char *nick, const char *data) {
char *key;
char *encrypted;
// Look for key
key = keystore_get_key(nick);
if (!key) return NULL;
// Encrypt
encrypted = fish_encrypt(key, strlen(key), data);
free(key);
return encrypted;
}
/**
* Decrypts a message (see fish_decrypt). The key is searched for in the
* key store.
*/
char *fish_decrypt_from_nick(const char *nick, const char *data) {
char *key;
char *decrypted;
// Look for key
key = keystore_get_key(nick);
if (!key) return NULL;
// Decrypt
decrypted = fish_decrypt(key, strlen(key), data);
free(key);
return decrypted;
}

42
plugins/fishlim/fish.h Normal file
View File

@ -0,0 +1,42 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef FISH_H
#define FISH_H
#ifdef _MSC_VER
#include "bool.h"
#else
#include <stdbool.h>
#endif
#include <stddef.h>
char *fish_encrypt(const char *key, size_t keylen, const char *message);
char *fish_decrypt(const char *key, size_t keylen, const char *data);
char *fish_encrypt_for_nick(const char *nick, const char *data);
char *fish_decrypt_from_nick(const char *nick, const char *data);
#endif

View File

@ -0,0 +1,4 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit
xchat_plugin_get_info

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3C4F42FC-292A-420B-B63D-C03DFBDD8E4E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>fishlim</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcfishlim</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcfishlim</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="fishlim.def" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="bool.h" />
<ClInclude Include="fish.h" />
<ClInclude Include="irc.h" />
<ClInclude Include="keystore.h" />
<ClInclude Include="misc.h" />
<ClInclude Include="plugin_xchat.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="fish.c" />
<ClCompile Include="irc.c" />
<ClCompile Include="keystore.c" />
<ClCompile Include="misc.c" />
<ClCompile Include="plugin_xchat.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="fishlim.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="bool.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="fish.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="irc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="keystore.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="misc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="plugin_xchat.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="fish.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="irc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="keystore.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="misc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="plugin_xchat.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

112
plugins/fishlim/irc.c Normal file
View File

@ -0,0 +1,112 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdlib.h>
#include <string.h>
#include "irc.h"
/**
* Parses an IRC message. The words array should contain the message splitted
* at spaces. The prefix and command is extracted from the message, and
* parameters_offset is set to the index of the first parameter.
*/
bool irc_parse_message(const char *words[],
const char **prefix, const char **command,
size_t *parameters_offset) {
size_t w = 1;
if (prefix) *prefix = NULL;
if (command) *command = NULL;
// See if the message starts with a prefix (sender user)
if (words[w][0] == ':') {
if (prefix) *prefix = &words[w][1];
w++;
}
// Check command
if (words[w][0] == '\0') return false;
if (command) *command = words[w];
w++;
*parameters_offset = w;
return true;
}
/**
* Finds the nick part of a "IRC prefix", which can have any
* of the following forms:
*
* nick
* nick@host
* nick!ident
* nick!ident@host
*/
char *irc_prefix_get_nick(const char *prefix) {
const char *end;
char *nick;
size_t length;
if (!prefix) return NULL;
// Find end of nick
end = prefix;
while (*end != '\0' && *end != '!' && *end != '@') end++;
// Allocate string
length = end - prefix;
nick = malloc(length+1);
if (!nick) return NULL;
// Copy to string
memcpy(nick, prefix, length);
nick[length] = '\0';
return nick;
}
/**
* Compares two nick names. Return 0 if equal. Otherwise the return value is
* less than zero if a is less than b or greater than zero if a is greater
* than b.
*/
int irc_nick_cmp(const char *a, const char *b) {
char ac;
char bc;
char diff;
for (;;) {
ac = *(a++);
bc = *(b++);
// Change into IRC uppercase (see RFC 2812 section 2.2)
if (ac >= 'a' && ac <= '~') ac &= ~0x20;
if (bc >= 'a' && bc <= '~') bc &= ~0x20;
diff = ac - bc;
if (diff) return diff;
if (!ac) return 0;
}
}

43
plugins/fishlim/irc.h Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef IRC_H
#define IRC_H
#ifdef _MSC_VER
#include "bool.h"
#else
#include <stdbool.h>
#endif
#include <stddef.h>
bool irc_parse_message(const char *words[],
const char **prefix, const char **command,
size_t *parameters_offset);
char *irc_prefix_get_nick(const char *prefix);
int irc_nick_cmp(const char *a, const char *b);
#endif

209
plugins/fishlim/keystore.c Normal file
View File

@ -0,0 +1,209 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "irc.h"
#include "fish.h"
#include "misc.h"
#include "keystore.h"
#include "plugin_xchat.h"
static char *keystore_password = NULL;
/**
* Opens the key store file: ~/.xchat2/blow.ini
*/
static GKeyFile *getConfigFile() {
gchar *filename = get_config_filename();
GKeyFile *keyfile = g_key_file_new();
g_key_file_load_from_file(keyfile, filename,
G_KEY_FILE_KEEP_COMMENTS |
G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
g_free(filename);
return keyfile;
}
/**
* Returns the key store password, or the default.
*/
static const char *get_keystore_password() {
return (keystore_password != NULL ?
keystore_password :
// Silly default value...
"blowinikey");
}
/**
* Gets a value for a nick/channel from blow.ini. Unlike
* g_key_file_get_string, this function is case insensitive.
*/
static gchar *get_nick_value(GKeyFile *keyfile, const char *nick, const char *item) {
gchar **group;
gchar **groups = g_key_file_get_groups(keyfile, NULL);
gchar *result = NULL;
for (group = groups; *group != NULL; group++) {
if (!irc_nick_cmp(*group, nick)) {
result = g_key_file_get_string(keyfile, *group, item, NULL);
break;
}
}
g_strfreev(groups);
return result;
}
/**
* Extracts a key from the key store file.
*/
char *keystore_get_key(const char *nick) {
// Get the key
GKeyFile *keyfile = getConfigFile();
gchar *value = get_nick_value(keyfile, nick, "key");
g_key_file_free(keyfile);
if (!value) return NULL;
if (strncmp(value, "+OK ", 4) != 0) {
// Key is stored in plaintext
return import_glib_string(value);
} else {
// Key is encrypted
const char *encrypted = value+4;
const char *password = get_keystore_password();
char *decrypted = fish_decrypt(password, strlen(password), encrypted);
g_free(value);
return decrypted;
}
}
/**
* Deletes a nick and the associated key in the key store file.
*/
static bool delete_nick(GKeyFile *keyfile, const char *nick) {
gchar **group;
gchar **groups = g_key_file_get_groups(keyfile, NULL);
bool ok = false;
for (group = groups; *group != NULL; group++) {
if (!irc_nick_cmp(*group, nick)) {
ok = g_key_file_remove_group(keyfile, *group, NULL);
break;
}
}
g_strfreev(groups);
return ok;
}
/**
* Writes the key store file to disk.
*/
static bool save_keystore(GKeyFile *keyfile) {
char *filename;
bool ok;
// Serialize
gsize file_length;
gchar *file_data = g_key_file_to_data(keyfile, &file_length, NULL);
if (!file_data) return false;
// Write to file
filename = get_config_filename();
ok = g_file_set_contents(filename, file_data, file_length, NULL);
g_free(filename);
g_free(file_data);
return ok;
}
/**
* Sets a key in the key store file.
*/
bool keystore_store_key(const char *nick, const char *key) {
const char *password;
char *encrypted;
char *wrapped;
bool ok = false;
GKeyFile *keyfile = getConfigFile();
// Remove old key
delete_nick(keyfile, nick);
// Add new key
password = get_keystore_password();
if (password) {
// Encrypt the password
encrypted = fish_encrypt(password, strlen(password), key);
if (!encrypted) goto end;
// Prepend "+OK "
wrapped = g_strconcat("+OK ", encrypted, NULL);
g_free(encrypted);
// Store encrypted in file
g_key_file_set_string(keyfile, nick, "key", wrapped);
free(wrapped);
} else {
// Store unencrypted in file
g_key_file_set_string(keyfile, nick, "key", key);
}
// Save key store file
ok = save_keystore(keyfile);
end:
g_key_file_free(keyfile);
return ok;
}
/**
* Deletes a nick from the key store.
*/
bool keystore_delete_nick(const char *nick) {
GKeyFile *keyfile = getConfigFile();
// Delete entry
bool ok = delete_nick(keyfile, nick);
// Save
if (ok) save_keystore(keyfile);
g_key_file_free(keyfile);
return ok;
}
void keystore_secure_free(void *ptr, size_t size) {
secure_erase(ptr, size);
free(ptr);
}

View File

@ -0,0 +1,42 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef KEYSTORE_H
#define KEYSTORE_H
#ifdef _MSC_VER
#include "bool.h"
#else
#include <stdbool.h>
#endif
#include <stddef.h>
char *keystore_get_key(const char *nick);
bool keystore_store_key(const char *nick, const char *key);
bool keystore_delete_nick(const char *nick);
void keystore_secure_free(void *ptr, size_t size);
#endif

View File

@ -0,0 +1,30 @@
include "..\..\src\makeinc.mak"
TARGET = xcfishlim.dll
CFLAGS = $(CFLAGS)
FISHLIM_OBJECTS = \
fish.obj \
irc.obj \
keystore.obj \
misc.obj \
plugin_xchat.obj
all: $(FISHLIM_OBJECTS) fishlim.def
link $(LDFLAGS) $(LIBS) /dll /out:xcfishlim.dll /def:fishlim.def $(FISHLIM_OBJECTS)
fishlim.def:
echo EXPORTS > fishlim.def
echo xchat_plugin_init >> fishlim.def
echo xchat_plugin_deinit >> fishlim.def
echo xchat_plugin_get_info >> fishlim.def
.c.obj:
$(CC) $(CFLAGS) $(GLIB) /I.. /c $<
clean:
del *.obj
del *.dll
del *.exp
del *.lib

54
plugins/fishlim/misc.c Normal file
View File

@ -0,0 +1,54 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "misc.h"
void secure_erase(void *ptr, size_t size) {
// "volatile" prevents this code from being optimized away
volatile char* volptr = ptr;
while (size--) *volptr++ = 0;
}
/**
* Re-allocates a string with the native allocator.
*/
char *import_glib_string(gchar *gstr) {
size_t size;
char *native;
if (g_mem_is_system_malloc()) return gstr;
size = strlen(gstr)+1;
native = malloc(size);
memcpy(native, gstr, size);
secure_erase(gstr, size);
g_free(gstr);
return native;
}

36
plugins/fishlim/misc.h Normal file
View File

@ -0,0 +1,36 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef MISC_H
#define MISC_H
void secure_erase(void *ptr, size_t size);
#ifdef __G_LIB_H__
char *import_glib_string(gchar *gstr);
#endif
#endif

View File

@ -0,0 +1,296 @@
/*
Copyright (c) 2010-2011 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <glib.h>
#include <stdlib.h>
#include <string.h>
// #pragma GCC visibility push(default)
#ifdef _MSC_VER
#include "xchat-plugin.h"
#else
#include <xchat/xchat-plugin.h>
#endif
#define XCHAT_MAX_WORDS 32
// #pragma GCC visibility pop
//#define EXPORT __attribute((visibility("default")))
//#define EXPORT
#include "fish.h"
#include "keystore.h"
#include "irc.h"
static const char plugin_name[] = "FiSHLiM";
static const char plugin_desc[] = "Encryption plugin for the FiSH protocol. Less is More!";
static const char plugin_version[] = "0.0.16";
static const char usage_setkey[] = "Usage: SETKEY [<nick or #channel>] <password>, sets the key for a channel or nick";
static const char usage_delkey[] = "Usage: DELKEY <nick or #channel>, deletes the key for a channel or nick";
static xchat_plugin *ph;
/**
* Returns the path to the key store file.
*/
gchar *get_config_filename() {
return g_build_filename(xchat_get_info(ph, "xchatdirfs"), "blow.ini", NULL);
}
/**
* Appends data to a string. Returns true if there was sufficient memory.
* Frees *s and returns false if an error occurs.
*/
static bool append(char **s, size_t *length, const char *data) {
size_t datalen = strlen(data);
char *extended = realloc(*s, *length + datalen + 1);
if (!extended) {
free(*s);
return false;
}
memcpy(extended + *length, data, datalen + 1);
*s = extended;
*length += datalen;
return true;
}
/*static int handle_debug(char *word[], char *word_eol[], void *userdata) {
xchat_printf(ph, "debug incoming: ");
for (size_t i = 1; word[i] != NULL && word[i][0] != '\0'; i++) {
xchat_printf(ph, ">%s< ", word[i]);
}
xchat_printf(ph, "\n");
return XCHAT_EAT_NONE;
}*/
/**
* Called when a message is to be sent.
*/
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
const char *own_nick;
// Encrypt the message if possible
const char *channel = xchat_get_info(ph, "channel");
char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]);
if (!encrypted) return XCHAT_EAT_NONE;
// Display message
own_nick = xchat_get_info(ph, "nick");
xchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL);
// Send message
xchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
free(encrypted);
return XCHAT_EAT_XCHAT;
}
/**
* Called when a channel message or private message is received.
*/
static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
const char *prefix;
const char *command;
const char *recipient;
const char *encrypted;
const char *peice;
char *sender_nick;
char *decrypted;
char *message;
size_t w;
size_t ew;
size_t uw;
size_t length;
if (!irc_parse_message((const char **)word, &prefix, &command, &w))
return XCHAT_EAT_NONE;
// Topic (command 332) has an extra parameter
if (!strcmp(command, "332")) w++;
// Look for encrypted data
for (ew = w+1; ew < XCHAT_MAX_WORDS-1; ew++) {
const char *s = (ew == w+1 ? word[ew]+1 : word[ew]);
if (strcmp(s, "+OK") == 0 || strcmp(s, "mcps") == 0) goto has_encrypted_data;
}
return XCHAT_EAT_NONE;
has_encrypted_data: ;
// Extract sender nick and recipient nick/channel
sender_nick = irc_prefix_get_nick(prefix);
recipient = word[w];
// Try to decrypt with these (the keys are searched for in the key store)
encrypted = word[ew+1];
decrypted = fish_decrypt_from_nick(recipient, encrypted);
if (!decrypted) decrypted = fish_decrypt_from_nick(sender_nick, encrypted);
// Check for error
if (!decrypted) goto decrypt_error;
// Build unecrypted message
message = NULL;
length = 0;
if (!append(&message, &length, "RECV")) goto decrypt_error;
for (uw = 1; uw < XCHAT_MAX_WORDS; uw++) {
if (word[uw][0] != '\0' && !append(&message, &length, " ")) goto decrypt_error;
if (uw == ew) {
// Add the encrypted data
peice = decrypted;
uw++; // Skip "OK+"
if (ew == w+1) {
// Prefix with colon, which gets stripped out otherwise
if (!append(&message, &length, ":")) goto decrypt_error;
}
} else {
// Add unencrypted data (for example, a prefix from a bouncer or bot)
peice = word[uw];
}
if (!append(&message, &length, peice)) goto decrypt_error;
}
free(decrypted);
// Simulate unencrypted message
//xchat_printf(ph, "simulating: %s\n", message);
xchat_command(ph, message);
free(message);
free(sender_nick);
return XCHAT_EAT_XCHAT;
decrypt_error:
free(decrypted);
free(sender_nick);
return XCHAT_EAT_NONE;
}
/**
* Command handler for /setkey
*/
static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
const char *nick;
const char *key;
// Check syntax
if (*word[2] == '\0') {
xchat_printf(ph, "%s\n", usage_setkey);
return XCHAT_EAT_XCHAT;
}
if (*word[3] == '\0') {
// /setkey password
nick = xchat_get_info(ph, "channel");
key = word_eol[2];
} else {
// /setkey #channel password
nick = word[2];
key = word_eol[3];
}
// Set password
if (keystore_store_key(nick, key)) {
xchat_printf(ph, "Stored key for %s\n", nick);
} else {
xchat_printf(ph, "\00305Failed to store key in blow.ini\n", nick, key);
}
return XCHAT_EAT_XCHAT;
}
/**
* Command handler for /delkey
*/
static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
const char *nick;
// Check syntax
if (*word[2] == '\0' || *word[3] != '\0') {
xchat_printf(ph, "%s\n", usage_delkey);
return XCHAT_EAT_XCHAT;
}
nick = word_eol[2];
// Delete the given nick from the key store
if (keystore_delete_nick(nick)) {
xchat_printf(ph, "Deleted key for %s\n", nick);
} else {
xchat_printf(ph, "\00305Failed to delete key in blow.ini!\n", nick);
}
return XCHAT_EAT_XCHAT;
}
/**
* Returns the plugin name version information.
*/
void xchat_plugin_get_info(const char **name, const char **desc,
const char **version, void **reserved) {
*name = plugin_name;
*desc = plugin_desc;
*version = plugin_version;
}
/**
* Plugin entry point.
*/
int xchat_plugin_init(xchat_plugin *plugin_handle,
const char **name,
const char **desc,
const char **version,
char *arg) {
ph = plugin_handle;
/* Send our info to XChat */
*name = plugin_name;
*desc = plugin_desc;
*version = plugin_version;
/* Register commands */
xchat_hook_command(ph, "SETKEY", XCHAT_PRI_NORM, handle_setkey, usage_setkey, NULL);
xchat_hook_command(ph, "DELKEY", XCHAT_PRI_NORM, handle_delkey, usage_delkey, NULL);
/* Add handlers */
xchat_hook_command(ph, "", XCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
xchat_hook_server(ph, "NOTICE", XCHAT_PRI_NORM, handle_incoming, NULL);
xchat_hook_server(ph, "PRIVMSG", XCHAT_PRI_NORM, handle_incoming, NULL);
//xchat_hook_server(ph, "RAW LINE", XCHAT_PRI_NORM, handle_debug, NULL);
xchat_hook_server(ph, "TOPIC", XCHAT_PRI_NORM, handle_incoming, NULL);
xchat_hook_server(ph, "332", XCHAT_PRI_NORM, handle_incoming, NULL);
xchat_printf(ph, "%s plugin loaded\n", plugin_name);
/* Return success */
return 1;
}
int xchat_plugin_deinit(void) {
xchat_printf(ph, "%s plugin unloaded\n", plugin_name);
return 1;
}

View File

@ -0,0 +1,31 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef XCHAT_PLUGIN_H
#define XCHAT_PLUGIN_H
gchar *get_config_filename();
#endif

91
plugins/fishlim/test.c Normal file
View File

@ -0,0 +1,91 @@
/*
Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include "fish.h"
// We can't use the XChat plugin API from here...
gchar *get_config_filename() {
const gchar *homedir = g_get_home_dir();
return g_build_filename(homedir, ".xchat2", "blow.ini", NULL);
}
static int decrypt(int nick_count, char *nicks[]) {
char encrypted[8192];
while (fgets(encrypted, sizeof(encrypted), stdin)) {
char *msg;
for (int i = 0; i < nick_count; i++) {
msg = fish_decrypt_from_nick(nicks[i], encrypted);
if (msg) goto success;
}
fprintf(stderr, "None of the recipients were found in the key store!\n");
return 1;
success:
fprintf(stderr, "Decrypted text >>>%s<<<\n", msg);
}
return 0;
}
static int encrypt(int nick_count, char *nicks[]) {
char message[8192];
while (fgets(message, sizeof(message), stdin)) {
// Remove newline character
char *newline = strchr(message, '\n');
if (newline) *newline = '\0';
bool error = false;
for (int i = 0; i < nick_count; i++) {
char *encrypted = fish_encrypt_for_nick(nicks[i], message);
if (encrypted) {
fprintf(stderr, "Encrypted [%s]: >>>%s<<<\n", nicks[i], encrypted);
} else {
error = true;
}
}
if (error) {
fprintf(stderr, "Some of the recipients were't found in the key store!\n");
return 1;
}
}
return 0;
}
int main(int argc, char *argv[]) {
if (argc < 2) {
fprintf(stderr, "usage: %s [-e] nick...\n", argv[0]);
return 2;
}
if (strcmp(argv[1], "-e") == 0) {
return encrypt(argc-2, &argv[2]);
} else {
return decrypt(argc-1, &argv[1]);
}
}

69
plugins/gtkpref/gtkpref.c Normal file
View File

@ -0,0 +1,69 @@
/* XChat-WDK
* Copyright (c) 2011 Berke Viktor.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <windows.h>
#include "xchat-plugin.h"
static xchat_plugin *ph; /* plugin handle */
static void
launch_tool ()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory (&si, sizeof (si));
si.cb = sizeof (si);
ZeroMemory (&pi, sizeof (pi));
if (!CreateProcess ( NULL, "gtk2-prefs.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
xchat_print (ph, "Error launching the GTK+ Preference Tool! Maybe the executable is missing?");
}
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
}
int
xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
ph = plugin_handle;
*plugin_name = "GTKPref";
*plugin_desc = "GTK+ Preference Tool Launcher";
*plugin_version = "1.0";
xchat_hook_command (ph, "GTKPREF", XCHAT_PRI_NORM, launch_tool, 0, 0);
xchat_command (ph, "MENU -ietc\\gtkpref.png ADD \"Settings/GTK+ Preferences\" \"GTKPREF\"");
return 1; /* return 1 for success */
}
int
xchat_plugin_deinit (void)
{
xchat_command (ph, "MENU DEL \"Settings/GTK+ Preferences\"");
return 1;
}

View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: gtkpref.obj gtkpref.def
link $(LDFLAGS) $(LIBS) /dll /out:xcgtkpref.dll /def:gtkpref.def gtkpref.obj
gtkpref.def:
echo EXPORTS > gtkpref.def
echo xchat_plugin_init >> gtkpref.def
echo xchat_plugin_deinit >> gtkpref.def
gtkpref.obj: gtkpref.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. gtkpref.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

1882
plugins/lua/lua.c Normal file

File diff suppressed because it is too large Load Diff

3
plugins/lua/lua.def Normal file
View File

@ -0,0 +1,3 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit

134
plugins/lua/lua.vcxproj Normal file
View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{646B4316-C8B8-4DB6-B6AE-E586929E5729}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>lua</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(LuaOutput)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(LuaOutput)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUA_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>"$(LuaLib).lib";;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LUA_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>"$(LuaLib).lib";;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Link>
<AdditionalDependencies>"$(LuaLib).lib";$(DepLibs);dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<AdditionalDependencies>"$(LuaLib).lib";$(DepLibs);dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;$(OwnFlags);snprintf=g_snprintf;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<ModuleDefinitionFile>lua.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;$(OwnFlags);snprintf=g_snprintf;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<ModuleDefinitionFile>lua.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="lua.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="lua.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="lua.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="lua.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

20
plugins/lua/makefile.mak Normal file
View File

@ -0,0 +1,20 @@
include "..\..\src\makeinc.mak"
DIRENTLIB = ..\..\src\common\dirent-win32.lib
all: lua.obj lua.def
link $(LDFLAGS) $(LIBS) /dll /out:xclua.dll $(LUALIB).lib $(DIRENTLIB) /def:lua.def lua.obj
lua.def:
echo EXPORTS > lua.def
echo xchat_plugin_init >> lua.def
echo xchat_plugin_deinit >> lua.def
lua.obj: lua.c makefile.mak
cl $(CFLAGS) /I.. /Dsnprintf=g_snprintf lua.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

71
plugins/makefile.mak Normal file
View File

@ -0,0 +1,71 @@
all:
@cd checksum
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\gtkpref
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\dns
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\doat
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\exec
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\fishlim
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\lua
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\mpcinfo
@-$(MAKE) /nologo /s /f makefile.mak $@
# @cd ..\nonbmp
# @-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\python
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\tcl
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\upd
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\xsasl
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\xtray
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\winamp
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\winsys
@-$(MAKE) /nologo /s /f makefile.mak $@
@cd ..\wmpa
@-$(MAKE) /nologo /s /f makefile.mak $@
clean:
@cd checksum
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\gtkpref
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\dns
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\doat
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\exec
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\fishlim
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\lua
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\mpcinfo
@-$(MAKE) /nologo /s /f makefile.mak clean $@
# @cd ..\nonbmp
# @-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\python
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\tcl
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\upd
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\xsasl
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\xtray
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\winamp
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\winsys
@-$(MAKE) /nologo /s /f makefile.mak clean $@
@cd ..\wmpa
@-$(MAKE) /nologo /s /f makefile.mak clean $@

167
plugins/mpcinfo/functions.c Normal file
View File

@ -0,0 +1,167 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
typedef int (*MYPROC)(HWND,HWND,char*,char*,BOOL,BOOL);
int dllProc(char *name, char *data){
HINSTANCE hinstLib;
hinstLib = LoadLibrary("mpcinfo");
//MYPROC proc;
int res;
if (hinstLib != NULL){
//proc = ;
if ((MYPROC) GetProcAddress(hinstLib, name)!=NULL){
res=(MYPROC)(NULL,NULL,data,NULL,TRUE,TRUE);
}
else{fprintf(stderr,"can't get proc: %s\n",name);res=-2;}
}
else{fprintf(stderr,"can't access dll\n");return -1;}
FreeLibrary(hinstLib);
return res;
}
*/
/*
int dllProc(char *name, char *data)
{
static HMODULE lib = NULL;
if (!lib)
{
lib = LoadLibraryA ("mpcinfo");
if (!lib)
{
return FALSE;
}
FreeLibrary (lib);
}
return TRUE;
}
*/
char *split(char *text, char seperator){
//if (DEBUG==1) putlog("splitting");
int i;int pos=-1;
for (i=0;i<strlen(text);i++){
if (text[i]==seperator){pos=i;i=strlen(text)+1;}
}
if (pos==-1) return text;
text[pos]=0;
return &(text[pos+1]);
}
int endsWith(char *text, char *suffix){
char *tmp=strstr(text,suffix);
if (tmp==NULL) return 0;
if (strlen(tmp)==strlen(suffix)) return 1;
return 0;
}
int inStr(char *s1, int sl1, char *s2){
//if (DEBUG==1) putlog("checking instr");
int i;int j;
for(i=0;i<sl1-strlen(s2);i++){
for (j=0;j<strlen(s2);j++){
if (s1[i+j]!=s2[j]) j=strlen(s2)+2;
}
if (j==strlen(s2)) return i;
}
return -1;
}
static char *subString(char *text, int first, int length, int spcKill){
//if (DEBUG==1) putlog("creating substring");
char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1));
int i;
ret[length]=0;
for (i=0;i<length;i++){
ret[i]=text[i+first];
//if (ret[i]==0) ret[i]='0';
}
if (spcKill==1){
for (i=length-1;i>=0;i--){
if (ret[i]==32) ret[i]=0;
else i=-1;
}
}
//if (DEBUG==1) putlog("substring created");
return ret;
}
static char *substring(char *text, int first, int length){return subString(text,first,length,0);}
char *readLine(FILE *f){
//if (DEBUG==1) putlog("reading line from file");
char *buffer=(char*)calloc(1024,sizeof(char)); //malloc(sizeof(char)*1024);
int pos=0;
int cc=0;
while((cc!=EOF)&&(pos<1024)&&(cc!=10)){
cc=fgetc(f);
if ((cc!=10)&&(cc!=13)){
if (cc==EOF) buffer[pos]=0;
else buffer[pos]=(char)cc;pos++;
}
}
if (buffer[pos]==EOF) xchat_printf(ph,"EOF: %i\n",pos);
return buffer;
}
char *toUpper(char *text){
//if (DEBUG==1) putlog("converting text to upper case");
char *ret=(char*) calloc(strlen(text)+1,sizeof(char));
int i;
for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]);
ret[strlen(text)]=0;
//if (DEBUG==1) putlog("uc done");
return ret;
}
static char *str3cat(char *s1, char *s2, char *s3){
//if (DEBUG==1) putlog("cating 3 strings");
char *ret=(char*)calloc(strlen(s1)+strlen(s2)+strlen(s3)+1,sizeof(char));
strcpy(ret,s1);strcat(ret,s2);strcat(ret,s3);
ret[strlen(s1)+strlen(s2)+strlen(s3)]=0;
//if (DEBUG==1) putlog("strings cated");
return ret;
}
char *replace(char *text, char *from, char *to){
//if (DEBUG==1) putlog("replacing");
char *ret=(char*)calloc( strlen(text)+(strlen(to)-strlen(from)),sizeof(char));
char *left;
char *right;
int pos=inStr(text,strlen(text),from);
if (pos!=-1){
left=substring(text,0,pos);
right=substring(text,pos+strlen(from),strlen(text)-(pos+strlen(from)));
ret=str3cat(left,to,right);
return replace(ret,from,to);
}
//if (DEBUG==1) putlog("replaced");
return text;
}
char *intReplaceF(char *text, char *from, int to, char *form){
//if (DEBUG==1) putlog("replaceF");
char *buffer=(char*) calloc(16,sizeof(char));
sprintf(buffer,form,to);
//if (DEBUG==1) putlog("replaceF done");
return replace(text,from,buffer);
}
char *intReplace(char *text, char *from, int to){return intReplaceF(text,from,to,"%i");}

View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: mpcinfo.obj mpcinfo.def
link $(LDFLAGS) $(LIBS) /dll /out:xcmpcinfo.dll /def:mpcinfo.def mpcinfo.obj
mpcinfo.def:
echo EXPORTS > mpcinfo.def
echo xchat_plugin_init >> mpcinfo.def
echo xchat_plugin_deinit >> mpcinfo.def
mpcinfo.obj: mpcinfo.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. mpcinfo.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

361
plugins/mpcinfo/mp3Info.c Normal file
View File

@ -0,0 +1,361 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//#include <stdio.h>
#include <sys/stat.h>
//#include "functions.c"
struct tagInfo{
int mode;
int cbr;
int bitrate;
unsigned int freq;
char *artist;
char *title;
char *album;
char *comment;
char *genre;
//int genre;
//int track;
};
static int RATES[2][3][15]={
{//mpeg2
{-1,8,16,24,32,64,80,56,64,128,160,112,128,256,320},//layer3 (V2)
{-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384},//layer2 (V2)
{-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448},//layer1 (V2)
},
{//mpeg1
{-1,32,40,48,56,64,80,96,112,128,160,192,224,256,320},//layer3 (V1)
{-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384},//layer2 (V1)
{-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448},//layer1 (V1)
}};
static int FREQS[2][4]={{22050,24000,16000,-1},{44100,48000,32000,-1}};
//static double FRATES[]={38.5,32.5,27.8,0.0};
static char GENRES[][50]={"Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal",
"New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno","Industrial",
"Alternative","Ska","Death Metal","Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk",
"Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound Clip","Gospel","Noise",
"AlternRock","Bass","Soul","Punk","Space","Meditative","Instrumental Pop","Instrumental Rock","Ethnic","Gothic",
"Darkwave","Techno-Industrial","Electronic","Pop-Folk","Eurodance","Dream","Southern Rock","Comedy","Cult","Gangsta",
"Top 40","Christian Rap","Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychadelic","Rave","Showtunes",
"Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka","Retro","Musical","Rock & Roll","Hard Rock",
//################## END OF OFFICIAL ID3 TAGS, WINAMP TAGS BELOW ########################################
"Folk","Folk/Rock","National Folk","Swing","Fast Fusion","Bebob","Latin","Revival","Celtic","Bluegrass",
"Avantgarde","Gothic Rock","Progressive Rock","Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band","Chorus","Easy Listening","Acoustic",
"Humour","Speech","Chanson","Opera","Chamber Music","Sonata","Symphony","Booty Bass","Primus","Porn Groove",
"Satire","Slow Jam","Club","Tango","Samba","Folklore","Ballad","Poweer Ballad","Rhytmic Soul","Freestyle",
"Duet","Punk Rock","Drum Solo","A Capela","Euro-House","Dance Hall",
//################## FOUND AT http://en.wikipedia.org/wiki/ID3 ###########################################
"Goa","Drum & Bass","Club-House","Hardcore",
"Terror","Indie","BritPop","Negerpunk","Polsk Punk","Beat","Christian Gangsta Rap","Heavy Metal","Black Metal","Crossover",
"Contemporary Christian","Christian Rock","Merengue","Salsa","Thrash Metal","Anime","JPop","Synthpop"
};
static char MODES [][13]={"Stereo","Joint-Stereo","Dual-Channel","Mono"};
int iPow(int x, int y){return (int)(pow((double)x,(double) y));}
int str2int(char *text){
//if (DEBUG==1) putlog("converting string to int");
int i;
int ret=0;
for (i=1;i<=strlen(text);i++){
if ((text[strlen(text)-i]>57)||(text[strlen(text)-i]<48)){
xchat_printf(ph,"invalid char in string: %i",text[strlen(text)-i]);
return 255;
}
ret+=((int)text[strlen(text)-i]-48)*iPow(10,i-1);
}
//xchat_printf(ph, "str2int(%s)=%i",text,ret);
//if (DEBUG==1) putlog("int converted");
return ret;
}
/*
static int getSize(char *file){
//if (DEBUG==1) putlog("reading filesize");
struct stat info;
if (stat(file,&info)!=0) return -1;
return info.st_size;
}*/
/*
int inStr(char *s1, int sl1, char *s2){
//if (DEBUG==1) putlog("checking instr");
int i;int j;
for(i=0;i<sl1-strlen(s2);i++){
for (j=0;j<strlen(s2);j++){
if (s1[i+j]!=s2[j]) j=strlen(s2)+2;
}
if (j==strlen(s2)) return i;
}
return -1;
}
static char *subString(char *text, int first, int length, int spcKill){
//if (DEBUG==1) putlog("creating substring");
char *ret=(char*) calloc (length+1,sizeof(char)); //malloc(sizeof(char)*(length+1));
ret[length]=0;int i;
for (i=0;i<length;i++){
ret[i]=text[i+first];
//if (ret[i]==0) ret[i]='0';
}
if (spcKill==1){
for (i=length-1;i>=0;i--){
if (ret[i]==32) ret[i]=0;
else i=-1;
}
}
//if (DEBUG==1) putlog("substring created");
return ret;
}
static char *substring(char *text, int first, int length){return subString(text,first,length,0);} //1
*/
static char *tagExtract(char *tag, int tagLen, char* info){
//if (DEBUG==1) putlog("extracting tag");
int pos, len, i;
pos=inStr(tag,tagLen,info);
//xchat_printf(ph,"pos=%i",pos);
if (pos==-1) return "";//NULL;
//printf("position of %s = %i\n",info,pos);
len=0;
//for (i=pos;i<pos+10;i++)printf("tag[%i]=%i \n",i,tag[i]);
for (i=0;i<4;i++) {
len+=tag[pos+strlen(info)+i]*iPow(255,3-i);
}
//printf("Tag-Length: %i\n",len);
if (strcmp("COMM",info)!=0) return substring(tag,pos+7+strlen(info),len-1);//11
return substring(tag,pos+7+strlen(info),len-1);//11
//char *ct=substring(tag,pos+7+strlen(info),len-1);//11
//return substring(ct,strlen(ct)+1,len-1-strlen(ct)); //<-- do not understand, what i did here :(
}
struct tagInfo readID3V1(char *file){
//if (DEBUG==1) putlog("reading ID3V1");
FILE *f;
struct tagInfo ret;
int res, i, c, val;
char *tag;
char *id;
char *tmp;
tag = (char*) malloc(sizeof(char)*129);
ret.artist=NULL;
f=fopen(file,"rb");
if (f==NULL){
xchat_print(ph,"file not found while trying to read id3v1");
//if (DEBUG==1) putlog("file not found while trying to read id3v1");
return ret;
}
//int offset=getSize(file)-128;
res=fseek(f,-128,SEEK_END);
if (res!=0) {printf("seek failed\n");fclose(f);return ret;}
//long int pos=ftell(f);
//printf("position= %li\n",pos);
for (i=0;i<128;i++) {
c=fgetc(f);
if (c==EOF) {xchat_printf(ph,"read ID3V1 failed\n");fclose(f);return ret;}
tag[i]=(char)c;
}
fclose(f);
//printf("tag readed: \n");
id=substring(tag,0,3);
//printf("header: %s\n",id);
if (strcmp(id,"TAG")!=0){xchat_printf(ph,"no id3 v1 found\n");return ret;}
ret.title=subString(tag,3,30,1);
ret.artist=subString(tag,33,30,1);
ret.album=subString(tag,63,30,1);
ret.comment=subString(tag,97,30,1);
tmp=substring(tag,127,1);
//ret.genre=substring(tag,127,1);
val=(int)tmp[0];
if (val<0)val+=256;
//xchat_printf(ph, "tmp[0]=%i (%i)",val,tmp[0]);
if ((val<148)&&(val>=0))
ret.genre=GENRES[val];//#############changed
else {
ret.genre="unknown";
//xchat_printf(ph, "tmp[0]=%i (%i)",val,tmp[0]);
}
//xchat_printf(ph, "tmp: \"%s\" -> %i",tmp,tmp[0]);
//xchat_printf(ph,"genre \"%s\"",ret.genre);
//if (DEBUG==1) putlog("id3v1 extracted");
return ret;
}
char *extractID3Genre(char *tag){
//if (DEBUG==1) putlog("extracting id3 genre");
if (tag[strlen(tag)-1]==')'){
tag[strlen(tag)-1]=0;
tag=&tag[1];
return GENRES[str2int(tag)];
//return tag;
}
else{
int i;
//xchat_print(ph, "Using 2 criteria");
for (i=0;i<strlen(tag);i++){
if (tag[i]==')'){ tag=&tag[i]+1;return tag;}
//return tag;
}
}
return "[152] failed";
}
struct tagInfo readID3V2(char *file){
//if (DEBUG==1) putlog("reading id3v2");
FILE *f;
int i, c, len;
char header[10];
char *tag;
struct tagInfo ret;
f = fopen(file,"rb");
//xchat_printf(ph,"file :%s",file);
if (f==NULL)
{
xchat_print(ph,"file not found whilt trying to read ID3V2");
//if (DEBUG==1)putlog("file not found while trying to read ID3V2");
return ret;
}
ret.artist=NULL;
for (i=0;i<10;i++){
c=fgetc(f);
if (c==EOF){
//putlog("found eof while reading id3v2");
return ret;
}
header[i]=(char)c;
}
if (strstr(header,"ID3")==header){
//xchat_printf(ph,"found id3v2\n");
len=0;
for (i=6;i<10;i++) len+=(int)header[i]*iPow(256,9-i);
//char *tag=(char*)malloc(sizeof(char)*len);
tag=(char*) calloc(len,sizeof(char)); //malloc(sizeof(char)*len);
for (i=0;i<len;i++){c=fgetc(f);tag[i]=(char)c;}
//xchat_printf(ph,"tag length: %i\n",len);
//xchat_printf(ph,"tag: %s\n",tag);
fclose(f);
ret.comment=tagExtract(tag,len,"COMM");
//xchat_printf(ph,"Comment: %s\n",ret.comment);
ret.genre=tagExtract(tag,len,"TCON");
//if (strcmp(ret.genre,"(127)")==0) ret.genre="unknown";
//xchat_printf(ph, "ret.genre = %s",ret.genre);
if ((ret.genre!=NULL)&&(ret.genre[0]=='(')) ret.genre=extractID3Genre(ret.genre);
//xchat_printf(ph,"genre: %s\n",ret.genre);
ret.title=tagExtract(tag,len,"TIT2");
//xchat_printf(ph,"Title: %s\n",ret.title);
ret.album=tagExtract(tag,len,"TALB");
//xchat_printf(ph,"Album: %s\n",ret.album);
ret.artist=tagExtract(tag,len,"TPE1");
//xchat_printf(ph,"Artist: %s\n",ret.artist);
}
else{fclose(f);printf("no id3v2 tag found\n"); return ret;}
//printf("id2v2 done\n");
//if (DEBUG==1) putlog("id3v2 readed");
return ret;
}
struct tagInfo readHeader(char *file){
//if (DEBUG==1) putlog("reading header");
FILE *f;
//int buffer[5120];
int versionB, layerB, bitrateB, freqB, modeB;
int header[4];
int count=0;
int cc=0;
struct tagInfo info;
info.artist=NULL;
f = fopen(file,"rb");
if (f==NULL)
{
xchat_print(ph,"file not found while trying to read mp3 header");
//if (DEBUG==1) putlog("file not found while trying to read mp3 header");
return info;
}
//struct tagInfo tagv2
info=readID3V2(file);
//struct tagInfo tagv1;//=readID3V1(file);
//if (tagv2.artist!=NULL){info=tagv2;}
//else {
if (info.artist==NULL){
//printf("searching for id3v1\n");
//tagv1=readID3V1(file);
info=readID3V1(file); //#####################
}
/*
if (tagv1.artist!=NULL){
//printf("Artist: %s\nTitle: %s\nAlbum: %s\nComment: %s\nGenre: %s\n",tagv1.artist,tagv1.title,tagv1.album,tagv1.comment,tagv1.genre);
info=tagv1;
}
*/
while ((count<5120)&&(cc!=EOF)&&(cc!=255)) {cc=fgetc(f);count++;}
if ((cc==EOF)||(count==5119)) printf("no header found\n");
else {
//printf("located header at %i\n",count);
header[0]=255;
for (count=1;count<4;count++){
header[count]=fgetc(f);
//printf("header[%i]=%i\n",count,header[count]);
}
versionB=(header[1]&8)>>3;
layerB=(header[1]&6)>>1;
bitrateB=(header[2]&240)>>4; //4
freqB=(header[2]&12)>>2;//2
modeB=(header[3]&192)>>6;//6
//printf("Mpeg: %i\nLayer: %i\nBitrate: %i\nFreq: %i\nMode: %i\n",versionB, layerB, bitrateB, freqB, modeB);
//int Bitrate=RATES[versionB][layerB-1][bitrateB];
//int Freq=FREQS[versionB][freqB];
info.bitrate=RATES[versionB][layerB-1][bitrateB];
info.freq=FREQS[versionB][freqB];
info.mode=modeB;
}
fclose(f);
//if (DEBUG==1) putlog("header readed");
return info;
}
/*
static void printMp3Info(char *file){
//printf("\nScanning Mp3-File for Informations: %s\n",file);
//printf("size:\t%10d byte\n",getSize(file));
struct tagInfo info =readHeader(file);
printf("%s | %10d",file,getSize(file));
if (info.bitrate>0){
//printf("Bitrate: %i\nFreq: %i\nMode: %s\n",info.bitrate,info.freq,MODES[info.mode]);
printf(" | %i kbps | %i kHz | %s",info.bitrate,info.freq,MODES[info.mode]);
//if (info.artist!=NULL) printf("\nArtist: %s\nTitle: %s\nAlbum: %s\nComment: %s\nGenre: %s\n",info.artist,info.title,info.album,info.comment,info.genre);
if (info.artist!=NULL) {
printf("| %s | %s | %s | %s | %s",info.artist,info.title,info.album,info.comment,info.genre);
//printf("| %s ",info.title);//,info.title,info.album,info.comment,info.genre
}
}
printf("\n");
}
*/

149
plugins/mpcinfo/mpcInfo.c Normal file
View File

@ -0,0 +1,149 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//static int DEBUG=0;
static char *VERSION="0.0.6";
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include "xchat-plugin.h"
static xchat_plugin *ph;
#include "functions.c"
#include "mp3Info.c"
#include "oggInfo.c"
#include "theme.c"
static int print_themes (char *word[], char *word_eol[], void *userdata){
printThemes();
return XCHAT_EAT_ALL;
}
static int mpc_themeReload(char *word[], char *word_eol[], void *userdata){
themeInit();
loadThemes();
return XCHAT_EAT_ALL;
}
static int mpc_tell(char *word[], char *word_eol[], void *userdata){
char *tTitle, *zero, *oggLine, *line;
struct tagInfo info;
HWND hwnd = FindWindow("MediaPlayerClassicW",NULL);
if (hwnd==0) {xchat_command(ph, randomLine(notRunTheme));return XCHAT_EAT_ALL;}
tTitle=(char*)malloc(sizeof(char)*1024);
GetWindowText(hwnd, tTitle, 1024);
zero=strstr(tTitle," - Media Player Classic");
if (zero!=NULL) zero[0]=0;
else xchat_print(ph,"pattern not found");
if ((tTitle[1]==':')&&(tTitle[2]=='\\')){
//xchat_print(ph,"seams to be full path");
if (endsWith(tTitle,".mp3")==1){
//xchat_print(ph,"seams to be a mp3 file");
info = readHeader(tTitle);
if ((info.artist!=NULL)&&(strcmp(info.artist,"")!=0)){
char *mode=MODES[info.mode];
//xchat_printf(ph,"mode: %s\n",mode);
char *mp3Line=randomLine(mp3Theme);
mp3Line=replace(mp3Line,"%art",info.artist);
mp3Line=replace(mp3Line,"%tit",info.title);
mp3Line=replace(mp3Line,"%alb",info.album);
mp3Line=replace(mp3Line,"%com",info.comment);
mp3Line=replace(mp3Line,"%gen",info.genre);
//mp3Line=replace(mp3Line,"%time",pos);
//mp3Line=replace(mp3Line,"%length",len);
//mp3Line=replace(mp3Line,"%ver",waVers);
//mp3Line=intReplace(mp3Line,"%br",br);
//mp3Line=intReplace(mp3Line,"%frq",frq);
mp3Line=intReplace(mp3Line,"%br",info.bitrate);
mp3Line=intReplace(mp3Line,"%frq",info.freq);
mp3Line=replace(mp3Line,"%mode",mode);
//mp3Line=replace(mp3Line,"%size",size);
//mp3Line=intReplace(mp3Line,"%perc",perc);
//mp3Line=replace(mp3Line,"%plTitle",title);
mp3Line=replace(mp3Line,"%file",tTitle);
xchat_command(ph, mp3Line);
return XCHAT_EAT_ALL;
}
}
if (endsWith(tTitle,".ogg")==1){
xchat_printf(ph,"Ogg detected\n");
info = getOggHeader(tTitle);
if (info.artist!=NULL){
char *cbr;
if (info.cbr==1) cbr="CBR"; else cbr="VBR";
oggLine=randomLine(oggTheme);
//if (cue==1) oggLine=cueLine;
//xchat_printf(ph,"ogg-line: %s\n",oggLine);
oggLine=replace(oggLine,"%art",info.artist);
oggLine=replace(oggLine,"%tit",info.title);
oggLine=replace(oggLine,"%alb",info.album);
oggLine=replace(oggLine,"%com",info.comment);
oggLine=replace(oggLine,"%gen",info.genre);
//oggLine=replace(oggLine,"%time",pos);
//oggLine=replace(oggLine,"%length",len);
//oggLine=replace(oggLine,"%ver",waVers);
oggLine=intReplace(oggLine,"%chan",info.mode);
oggLine=replace(oggLine,"%cbr",cbr);
oggLine=intReplace(oggLine,"%br",info.bitrate/1000);//br);
oggLine=intReplace(oggLine,"%frq",info.freq);
//oggLine=replace(oggLine,"%size",size);
//oggLine=intReplace(oggLine,"%perc",perc);
//oggLine=replace(oggLine,"%plTitle",title);
oggLine=replace(oggLine,"%file",tTitle);
xchat_command(ph, oggLine);
return XCHAT_EAT_ALL;
}
}
}
line=randomLine(titleTheme);
line=replace(line,"%title", tTitle);
xchat_command(ph,line);
return XCHAT_EAT_ALL;
}
int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg){
ph = plugin_handle;
*plugin_name = "mpcInfo";
*plugin_desc = "Information-Script for Media Player Classic";
*plugin_version=VERSION;
xchat_hook_command(ph, "mpc", XCHAT_PRI_NORM, mpc_tell,"no help text", 0);
xchat_hook_command(ph, "mpc_themes", XCHAT_PRI_NORM, print_themes,"no help text", 0);
xchat_hook_command(ph, "mpc_reloadthemes", XCHAT_PRI_NORM, mpc_themeReload,"no help text", 0);
xchat_command (ph, "MENU -ietc\\music.png ADD \"Window/Display Current Song (MPC)\" \"MPC\"");
themeInit();
loadThemes();
xchat_printf(ph, "%s %s plugin loaded\n",*plugin_name, VERSION);
return 1;
}
int
xchat_plugin_deinit (void)
{
xchat_command (ph, "MENU DEL \"Window/Display Current Song (MPC)\"");
xchat_print (ph, "mpcInfo plugin unloaded\n");
return 1;
}

View File

@ -0,0 +1,3 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B0E36D93-CA2A-49FE-9EB9-9C96C6016EEC}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>mpcinfo</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcmpcinfo</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>xcmpcinfo</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;MPCINFO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>mpcinfo.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="mpcinfo.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="mpcInfo.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="mpcinfo.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="mpcInfo.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

122
plugins/mpcinfo/oggInfo.c Normal file
View File

@ -0,0 +1,122 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
static int getOggInt(char *buff, int beg, int bytes){
//if (DEBUG==1) putlog("getOggInt");
int ret=0;
int i;
for (i=0;i<bytes;i++){
if (buff[i+beg]>=0) ret+=buff[i+beg]*iPow(256,i);else ret+=(256+buff[i+beg])*iPow(256,i);
//printf("[%i]=%i\n",i,buff[i+beg]);
}
return ret;
}
static char *upperStr(char *text){
//if (DEBUG==1) putlog("converting text to uc");
//printf("upperStr(%s)\n",text);
int i;
char *ret=(char*) malloc(sizeof(char)*(strlen(text)+1));
ret[strlen(text)]=0;
for (i=0;i<strlen(text);i++) ret[i]=toupper(text[i]);
//printf("Result: %s\n",ret);
return ret;
}
struct tagInfo getOggHeader(char *file){
//if (DEBUG==1) putlog("reading ogg header");
char header[4096];
int i, c;
int h1pos, h3pos, maxBr, nomBr, minBr, pos, count, tagLen;
char *sub;
char *name;
char *val;
char *HEADLOC1, *HEADLOC3, *HEADLOC5;
FILE *f;
struct tagInfo info;
info.artist=NULL;
f = fopen(file,"rb");
if (f==NULL){
xchat_print(ph,"file not found while trying to read ogg header");
//if (DEBUG==1) putlog("file not found while trying to read ogg header");
return info;
}
for (i=0;i<4095;i++) {c=fgetc(f);header[i]=(char)c;}
fclose(f);
HEADLOC1="_vorbis";
HEADLOC1[0]=1;
HEADLOC3="_vorbis";
HEADLOC3[0]=3;
HEADLOC5="_vorbis";
HEADLOC5[0]=5;
h1pos=inStr(header,4096,HEADLOC1);
h3pos=inStr(header,4096,HEADLOC3);
//int h5pos=inStr(header,4096,HEADLOC5); //not needed
//printf("loc1: %i\n",h1pos);printf("loc3: %i\n",h3pos);printf("loc5: %i\n",h5pos);
maxBr=getOggInt(header,h1pos+7+9,4);
nomBr=getOggInt(header,h1pos+7+13,4);
minBr=getOggInt(header,h1pos+7+17,4);
info.freq=getOggInt(header,h1pos+7+5,4);
info.mode=header[h1pos+7+4];
info.bitrate=nomBr;
if (((maxBr==nomBr)&&(nomBr=minBr))||((minBr==0)&&(maxBr==0))||((minBr=-1)&&(maxBr=-1)) )info.cbr=1;else info.cbr=0;
printf("bitrates: %i|%i|%i\n",maxBr,nomBr,minBr);
printf("freq: %i\n",info.freq);
pos=h3pos+7;
pos+=getOggInt(header,pos,4)+4;
count=getOggInt(header,pos,4);
//printf("tags: %i\n",count);
pos+=4;
info.artist=NULL;info.title=NULL;info.album=NULL;info.comment=NULL;info.genre=NULL;
for (i=0;i<count;i++){
tagLen=getOggInt(header,pos,4);
//printf("taglength: %i\n",tagLen);
sub=substring(header,pos+4,tagLen);
name=upperStr(substring(sub,0,inStr(sub,tagLen,"=")));
val=substring(sub,inStr(sub,tagLen,"=")+1,tagLen-inStr(sub,tagLen,"=")-1);
//printf("Tag: %s\n",sub);
//printf("Name: %s\n",name);
//printf("value: %s\n",val);
if (strcmp(name,"ARTIST")==0) info.artist=val;
if (strcmp(name,"TITLE")==0) info.title=val;
if (strcmp(name,"ALBUM")==0) info.album=val;
if (strcmp(name,"GENRE")==0) info.genre=val;
if (strcmp(name,"COMMENT")==0) info.comment=val;
pos+=4+tagLen;
}
if (info.artist==NULL) info.artist="";
if (info.album==NULL) info.album ="";
if (info.title==NULL) info.title="";
if (info.genre==NULL) info.genre="";
if (info.comment==NULL) info.comment="";
printf("Artist: %s\nTitle: %s\nAlbum: %s\n",info.artist,info.title, info.album);
printf("Genre: %s\nComment: %s\nMode: %i\nCBR: %i\n",info.genre,info.comment,info.mode,info.cbr);
//if (DEBUG==1) putlog("ogg header readed");
return info;
}
/*
void printOggInfo(char *file){
printf("Scanning Ogg-File for Informations: %s\n",file);
printf("size:\t%10d byte\n",getSize(file));
struct tagInfo info = getOggHeader(file);
}
*/

136
plugins/mpcinfo/theme.c Normal file
View File

@ -0,0 +1,136 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <time.h>
struct theme{
int size;
char **line;
};
static struct theme notRunTheme;
static struct theme titleTheme;
static struct theme mp3Theme;
static struct theme oggTheme;
void themeInit(){
//if (DEBUG==1) putlog("init theme");
/*mp3Theme.size=0;oggTheme.size=0;cueTheme.size=0;streamTheme.size=0;etcTheme.size=0;
stopTheme.size=0;pauseTheme.size=0;*/
notRunTheme.size=0;titleTheme.size=0;
srand((unsigned int)time((time_t *)NULL));
//if (DEBUG==1) putlog("theme init done");
}
void printTheme(struct theme data){
int i;
for (i=0;i<data.size;i++) xchat_printf(ph,"line[%i]=%s\n",i,data.line[i]);
}
void printThemes(){
xchat_printf(ph,"\nNotRun-Theme:\n");printTheme(notRunTheme);
xchat_printf(ph,"\nMP3-Theme:\n");printTheme(mp3Theme);
xchat_printf(ph,"\nOGG-Theme:\n");printTheme(oggTheme);
xchat_printf(ph,"\nTitle-Theme:\n");printTheme(titleTheme);
}
void cbFix(char *line){
//if (DEBUG==1) putlog("cbfix");
int i, j;
for (i=0;i<strlen(line);i++){
if (line[i]=='%'){
if ((line[i+1]=='C')||(line[i+1]=='B')||(line[i+1]=='U')||(line[i+1]=='O')||(line[i+1]=='R')){
if(line[i+1]=='C') line[i]=3;
if(line[i+1]=='B') line[i]=2;
if(line[i+1]=='U') line[i]=37;
if(line[i+1]=='O') line[i]=17;
if(line[i+1]=='R') line[i]=26;
for (j=i+1;j<strlen(line)-1;j++) line[j]=line[j+1];
line[strlen(line)-1]=0;
}
}
}
//if (DEBUG==1) putlog("cbfix done");
}
struct theme themeAdd(struct theme data, char *info){
//if (DEBUG==1) putlog("adding theme");
struct theme ret;
char **newLine=(char **)calloc(data.size+1,sizeof(char*));
int i;
for (i=0;i<data.size;i++) newLine[i]=data.line[i];
cbFix(info);
newLine[data.size]=info;
ret.line=newLine;ret.size=data.size+1;
//if (DEBUG==1) putlog("theme added");
return ret;
}
void loadThemes(){
char *hDir, *hFile, *line, *val;
FILE *f;
xchat_print(ph,"loading themes\n");
hDir=(char*)calloc(1024,sizeof(char));
strcpy(hDir,xchat_get_info(ph,"xchatdirfs"));
hFile=str3cat(hDir,"\\","mpcInfo.theme.txt");
f = fopen(hFile,"r");
if(f==NULL)
{
xchat_print(ph,"no theme in homedir, checking global theme");
f=fopen("mpcInfo.theme.txt","r");
}
//xchat_printf(ph,"file_desc: %p\n",f);
if (f==NULL) xchat_print(ph, "no theme found, using hardcoded\n");
else {
if (f > 0)
{
line=" ";
} else
{
line="\0";
}
while (line[0]!=0)
{
line=readLine(f);
val=split(line,'=');
printf("line: %s\n",line);
printf("val: %s\n",val);
if (strcmp(toUpper(line),"OFF_LINE")==0) notRunTheme=themeAdd(notRunTheme,val);
if (strcmp(toUpper(line),"TITLE_LINE")==0) titleTheme=themeAdd(titleTheme,val);
if (strcmp(toUpper(line),"MP3_LINE")==0) mp3Theme=themeAdd(mp3Theme,val);
if (strcmp(toUpper(line),"OGG_LINE")==0) mp3Theme=themeAdd(oggTheme,val);
}
fclose(f);
xchat_print(ph, "theme loaded successfull\n");
}
if (notRunTheme.size==0) notRunTheme=themeAdd(notRunTheme,"say Media Player Classic not running");
if (titleTheme.size==0) titleTheme=themeAdd(titleTheme,"say Playing %title in Media Player Classic");
if (mp3Theme.size==0) mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%mode] in Media Player Classic ");
if (oggTheme.size==0) oggTheme=themeAdd(oggTheme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%chan channels] in Media Player Classic ");
//mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%time|%length|%perc%|%br kbps|%frq kHz|%mode] in Media Player Classic ");
}
int rnd(int max){
return rand()%max;
}
char *randomLine(struct theme data){
return data.line[rnd(data.size)];
}

View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: nonbmp.obj nonbmp.def
link $(LDFLAGS) $(LIBS) /dll /out:xcnonbmp.dll /def:nonbmp.def nonbmp.obj
nonbmp.def:
echo EXPORTS > nonbmp.def
echo xchat_plugin_init >> nonbmp.def
echo xchat_plugin_deinit >> nonbmp.def
nonbmp.obj: nonbmp.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. nonbmp.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

87
plugins/nonbmp/nonbmp.c Normal file
View File

@ -0,0 +1,87 @@
#include <stdlib.h>
#include <glib.h>
#include <string.h>
#include "xchat-plugin.h"
static xchat_plugin *ph;
static const char name[] = "Non-BMP";
static const char desc[] = "Replace non-BMP characters with replacement characters";
static const char version[] = "1.0000";
static int recursing = 0;
static int filter(
char *word[],
char *word_eol[],
void *unused
) {
gunichar *line;
gchar *utf8_line;
glong length;
glong index;
if( recursing ) {
return XCHAT_EAT_NONE;
}
/* the input has already been checked so we can use the _fast version */
line = g_utf8_to_ucs4_fast(
(char *)word_eol[1],
-1, /* NUL terminated input */
&length
);
for( index = 0; index < length; index++ ) {
if( line[ index ] > 0xFFFF ) {
line[ index ] = 0xFFFD; /* replacement character */
}
}
utf8_line = g_ucs4_to_utf8(
line,
-1, /* NUL terminated input */
NULL, /* items read */
NULL, /* items written */
NULL /* ignore conversion error */
);
if( utf8_line == NULL ) {
/* conversion failed ... I guess we are screwed? */
g_free( line );
return XCHAT_EAT_NONE;
}
recursing = 1;
xchat_commandf( ph, "RECV %s", utf8_line );
recursing = 0;
g_free( line );
g_free( utf8_line );
return XCHAT_EAT_ALL;
}
int xchat_plugin_init(
xchat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg
) {
/* int index = 0;*/
ph = plugin_handle;
*plugin_name = name;
*plugin_desc = desc;
*plugin_version = version;
xchat_hook_server( ph, "RAW LINE", XCHAT_PRI_HIGHEST, filter, (void *)NULL );
xchat_printf (ph, "%s plugin loaded\n", name);
return 1;
}
int
xchat_plugin_deinit (void)
{
xchat_printf (ph, "%s plugin unloaded\n", name);
return 1;
}

View File

@ -0,0 +1,40 @@
include "..\..\src\makeinc.mak"
DIRENTLIB = ..\..\src\common\dirent-win32.lib
TARGET = $(PERL512OUTPUT)
all: $(TARGET)
perl.def:
echo EXPORTS > perl.def
echo xchat_plugin_init >> perl.def
echo xchat_plugin_deinit >> perl.def
echo xchat_plugin_get_info >> perl.def
perl.obj: perl.c
$(CC) $(CFLAGS) perl.c $(GLIB) /I$(PERL512PATH)\perl\lib\CORE /I.. /DPERL_DLL=\"$(PERL512LIB).dll\"
perl512.def:
gendef $(PERL512PATH)\perl\bin\perl512.dll
$(PERL512LIB).lib: perl512.def
!ifdef X64
lib /nologo /machine:x64 /def:perl512.def
!else
lib /nologo /machine:x86 /def:perl512.def
!endif
perl.c: xchat.pm.h
xchat.pm.h: lib/Xchat.pm lib/IRC.pm
perl.exe generate_header
$(TARGET): perl.obj perl.def $(PERL512LIB).lib
$(LINK) /DLL /out:$(TARGET) perl.obj $(LDFLAGS) $(PERL512LIB).lib /delayload:$(PERL512LIB).dll $(DIRENTLIB) delayimp.lib user32.lib shell32.lib advapi32.lib /def:perl.def
clean:
@del $(TARGET)
@del *.obj
@del *.def
@del *.lib
@del *.exp

View File

@ -0,0 +1,42 @@
include "..\..\src\makeinc.mak"
DIRENTLIB = ..\..\src\common\dirent-win32.lib
TARGET = $(PERL514OUTPUT)
all: $(TARGET)
perl.def:
echo EXPORTS > perl.def
echo xchat_plugin_init >> perl.def
echo xchat_plugin_deinit >> perl.def
echo xchat_plugin_get_info >> perl.def
# MSVC only supports __inline, while GCC only supports __inline__. This is defined incorretly
# in lib\CORE\config.h in Strawberry Perl, see #define PERL_STATIC_INLINE static __inline__
perl.obj: perl.c
$(CC) $(CFLAGS) perl.c $(GLIB) /I$(PERL514PATH)\perl\lib\CORE /I.. /DPERL_DLL=\"$(PERL514LIB).dll\" /D__inline__=__inline
perl514.def:
gendef $(PERL514PATH)\perl\bin\perl514.dll
$(PERL514LIB).lib: perl514.def
!ifdef X64
lib /nologo /machine:x64 /def:perl514.def
!else
lib /nologo /machine:x86 /def:perl514.def
!endif
perl.c: xchat.pm.h
xchat.pm.h: lib/Xchat.pm lib/IRC.pm
perl.exe generate_header
$(TARGET): perl.obj perl.def $(PERL514LIB).lib
$(LINK) /DLL /out:$(TARGET) perl.obj $(LDFLAGS) $(PERL514LIB).lib /delayload:$(PERL514LIB).dll $(DIRENTLIB) delayimp.lib user32.lib shell32.lib advapi32.lib /def:perl.def
clean:
@del $(TARGET)
@del *.obj
@del *.def
@del *.lib
@del *.exp

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{987E9374-98A1-44BA-946F-D3472D7A7055}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>perl512</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(Perl512Output)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(Perl512Output)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL512_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>$(Perl512Path)\perl\lib\CORE;$(IntDir);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(Perl512Lib).lib;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(Perl512Lib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<PreBuildEvent>
<Command>"$(GendefPath)\gendef" "$(Perl512Path)\perl\bin\$(Perl512Lib).dll"
move $(Perl512Lib).def "$(IntDir)"
lib /nologo /machine:x86 "/def:$(IntDir)$(Perl512Lib).def" "/out:$(OutDir)\$(Perl512Lib).lib"
"$(Perl512Path)\perl\bin\perl.exe" generate_header
move irc.pm.h "$(IntDir)"
move xchat.pm.h "$(IntDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;PERL512_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>$(Perl512Path)\perl\lib\CORE;$(IntDir);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(Perl512Lib).lib;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(Perl512Lib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<PreBuildEvent>
<Command>"$(GendefPath)\gendef" "$(Perl512Path)\perl\bin\$(Perl512Lib).dll"
move $(Perl512Lib).def "$(IntDir)"
lib /nologo /machine:x64 "/def:$(IntDir)$(Perl512Lib).def" "/out:$(OutDir)\$(Perl512Lib).lib"
"$(Perl512Path)\perl\bin\perl.exe" generate_header
move irc.pm.h "$(IntDir)"
move xchat.pm.h "$(IntDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="perl.c" />
</ItemGroup>
<ItemGroup>
<None Include="perl.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="perl.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="perl.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C4C9FA6F-F990-4C7B-85F6-CD8F4F5728F0}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>perl514</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(Perl514Output)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(Perl514Output)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL514_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(Perl514Path)\perl\lib\CORE;$(IntDir);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(Perl514Lib).lib;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(Perl514Lib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<PreBuildEvent>
<Command>"$(GendefPath)\gendef" "$(Perl514Path)\perl\bin\$(Perl514Lib).dll"
move $(Perl514Lib).def "$(IntDir)"
lib /nologo /machine:x86 "/def:$(IntDir)$(Perl514Lib).def" "/out:$(OutDir)\$(Perl514Lib).lib"
"$(Perl514Path)\perl\bin\perl.exe" generate_header
move irc.pm.h "$(IntDir)"
move xchat.pm.h "$(IntDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;PERL514_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(Perl514Path)\perl\lib\CORE;$(IntDir);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(Perl514Lib).lib;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(Perl514Lib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<PreBuildEvent>
<Command>"$(GendefPath)\gendef" "$(Perl514Path)\perl\bin\$(Perl514Lib).dll"
move $(Perl514Lib).def "$(IntDir)"
lib /nologo /machine:x64 "/def:$(IntDir)$(Perl514Lib).def" "/out:$(OutDir)\$(Perl514Lib).lib"
"$(Perl514Path)\perl\bin\perl.exe" generate_header
move irc.pm.h "$(IntDir)"
move xchat.pm.h "$(IntDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="perl.c" />
</ItemGroup>
<ItemGroup>
<None Include="perl.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="perl.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="perl.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{58654438-F674-42F7-88FA-73EF90AD80B1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>perl516</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(Perl516Output)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(Perl516Output)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PERL516_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(Perl516Path)\perl\lib\CORE;$(IntDir);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(Perl516Lib).lib;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(Perl516Lib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<PreBuildEvent>
<Command>"$(GendefPath)\gendef" "$(Perl516Path)\perl\bin\$(Perl516Lib).dll"
move $(Perl516Lib).def "$(IntDir)"
lib /nologo /machine:x86 "/def:$(IntDir)$(Perl516Lib).def" "/out:$(OutDir)\$(Perl516Lib).lib"
"$(Perl516Path)\perl\bin\perl.exe" generate_header
move irc.pm.h "$(IntDir)"
move xchat.pm.h "$(IntDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;PERL516_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(Perl516Path)\perl\lib\CORE;$(IntDir);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(Perl516Lib).lib;dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>perl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(Perl516Lib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
<PreBuildEvent>
<Command>"$(GendefPath)\gendef" "$(Perl516Path)\perl\bin\$(Perl516Lib).dll"
move $(Perl516Lib).def "$(IntDir)"
lib /nologo /machine:x64 "/def:$(IntDir)$(Perl516Lib).def" "/out:$(OutDir)\$(Perl516Lib).lib"
"$(Perl516Path)\perl\bin\perl.exe" generate_header
move irc.pm.h "$(IntDir)"
move xchat.pm.h "$(IntDir)"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="perl.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="perl.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="perl.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="perl.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@ -22,12 +22,15 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#ifdef ENABLE_NLS
#include <locale.h>
#endif
#ifdef WIN32
#include <windows.h>
#define _INC_DIRENT /* disable inclusion of perl's dirent.h, we use an own version for win32 */
#include "../../src/dirent/dirent-win32.h"
#else
#include <dirent.h>
#endif
#undef PACKAGE
@ -1342,7 +1345,11 @@ perl_load_file (char *filename)
if (GetLastError () == ERROR_BAD_EXE_FORMAT)
/* http://forum.xchat.org/viewtopic.php?t=3277 */
thread_mbox ("Cannot use this " PERL_DLL "\n\n"
"32-bit ActivePerl is required.");
#ifdef _WIN64
"64-bit Strawberry Perl is required.");
#else
"32-bit Strawberry Perl is required.");
#endif
else {
/* a lot of people install this old version */
lib = LoadLibraryA ("perl56.dll");

View File

@ -81,6 +81,13 @@ margin-right: 32px;
<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)
@ -998,5 +1005,137 @@ A newly allocated string or NULL for failure. You must free this string with xch
<br><br>
<h3><a class=cmd name="xchat_pluginpref_set_str">&nbsp;xchat_pluginpref_set_str()&nbsp;</a><small>(new for 2.8.10)</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.8.10)</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.8.10)</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.8.10)</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.8.10)</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.8.10)</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>

View File

@ -0,0 +1,25 @@
include "..\..\src\makeinc.mak"
DIRENTLIB = ..\..\src\common\dirent-win32.lib
TARGET = $(PYTHONOUTPUT)
all: $(TARGET)
python.def:
echo EXPORTS > python.def
echo xchat_plugin_init >> python.def
echo xchat_plugin_deinit >> python.def
echo xchat_plugin_get_info >> python.def
python.obj: python.c
$(CC) $(CFLAGS) /I.. /Dusleep=_sleep /DPATH_MAX=255 python.c $(GLIB) /I$(PYTHONPATH)\include /DPYTHON_DLL=\"$(PYTHONLIB).dll\"
$(TARGET): python.obj python.def
$(LINK) /dll /out:$(TARGET) $(LDFLAGS) python.obj /libpath:$(PYTHONPATH)\libs $(PYTHONLIB).lib $(DIRENTLIB) $(LIBS) /def:python.def
clean:
del $(TARGET)
del *.obj
del python.def
del *.lib
del *.exp

View File

@ -53,10 +53,16 @@
#include <glib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#ifdef WIN32
#include "../../src/dirent/dirent-win32.h"
#include "../../config.h"
#else
#include <unistd.h>
#include <dirent.h>
#endif
#include "xchat-plugin.h"
#include "Python.h"
@ -68,7 +74,7 @@
#ifdef WIN32
#undef WITH_THREAD /* Thread support locks up xchat on Win32. */
#define VERSION "0.8/2.4" /* Linked to python24.dll */
#define VERSION "0.8/2.7" /* Linked to python27.dll */
#else
#define VERSION "0.8"
#endif

View File

@ -0,0 +1,4 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit
xchat_plugin_get_info

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{19C52A0A-A790-409E-A28A-9745FF990F5C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>python</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(PythonOutput)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(PythonOutput)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(Glib);$(PythonPath)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
<AdditionalDependencies>"$(PythonLib).lib";$(DepLibs);dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);$(PythonPath)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(Glib);$(PythonPath)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>python.def</ModuleDefinitionFile>
<AdditionalDependencies>"$(PythonLib).lib";$(DepLibs);dirent-win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;$(OutDir);$(PythonPath)\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="python.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="python.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="python.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="python.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

22
plugins/tcl/makefile.mak Normal file
View File

@ -0,0 +1,22 @@
include "..\..\src\makeinc.mak"
TARGET = $(TCLOUTPUT)
all: $(TARGET)
tcl.def:
echo EXPORTS > tcl.def
echo xchat_plugin_init >> tcl.def
echo xchat_plugin_deinit >> tcl.def
echo xchat_plugin_get_info >> tcl.def
tclplugin.obj: tclplugin.c
$(CC) $(CFLAGS) /I.. tclplugin.c /I$(TCLPATH)\include /DTCL_DLL=\"$(TCLLIB).dll\"
$(TARGET): tclplugin.obj tcl.def
$(LINK) /dll /out:$(TARGET) $(LDFLAGS) tclplugin.obj /libpath:$(TCLPATH)\lib $(TCLLIB).lib /delayload:$(TCLLIB).dll delayimp.lib /def:tcl.def
clean:
del $(TARGET)
del *.obj
del tcl.def

4
plugins/tcl/tcl.def Normal file
View File

@ -0,0 +1,4 @@
EXPORTS
xchat_plugin_init
xchat_plugin_deinit
xchat_plugin_get_info

114
plugins/tcl/tcl.vcxproj Normal file
View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="printevents.h" />
<ClInclude Include="tclplugin.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="tclplugin.c" />
</ItemGroup>
<ItemGroup>
<None Include="tcl.def" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2773666A-8CFC-4533-A043-EAD59F16A1C7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tcl</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>WDK7</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\xchat.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(TclOutput)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(TclOutput)</TargetName>
<OutDir>$(SolutionDir)build\$(PlatformName)\bin</OutDir>
<IntDir>$(SolutionDir)build\$(PlatformName)\obj\$(ProjectName)</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TCL_EXPORTS;TCL_DLL="$(TclLib).dll";$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(TclPath)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(TclPath)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>"$(TclLib).lib";%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>tcl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(TclLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level1</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WIN64;NDEBUG;_WINDOWS;_USRDLL;TCL_EXPORTS;TCL_DLL="$(TclLib).dll";$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(TclPath)\include;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(TclPath)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>"$(TclLib).lib";%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>tcl.def</ModuleDefinitionFile>
<DelayLoadDLLs>$(TclLib).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="printevents.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="tclplugin.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="tclplugin.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="tcl.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@ -2221,7 +2221,7 @@ int xchat_plugin_init(xchat_plugin * plugin_handle, char **plugin_name, char **p
#ifdef WIN32
lib = LoadLibraryA(TCL_DLL);
if (!lib) {
xchat_print(ph, "You must have ActiveTCL installed in order to run Tcl scripts.\n" "http://aspn.activestate.com/ASPN/Tcl/\n" "Make sure Tcl's bin directory is in your PATH.\n\n");
xchat_print(ph, "You must have ActiveTCL 8.5 installed in order to run Tcl scripts.\n" "http://www.activestate.com/activetcl/downloads\n" "Make sure Tcl's bin directory is in your PATH.\n");
return 0;
}
FreeLibrary(lib);

18
plugins/upd/makefile.mak Normal file
View File

@ -0,0 +1,18 @@
include "..\..\src\makeinc.mak"
all: upd.obj upd.def
link $(LDFLAGS) $(LIBS) /dll /out:xcupd.dll /def:upd.def upd.obj
upd.def:
echo EXPORTS > upd.def
echo xchat_plugin_init >> upd.def
echo xchat_plugin_deinit >> upd.def
upd.obj: upd.c makefile.mak
cl $(CFLAGS) $(GLIB) /I.. upd.c
clean:
del *.obj
del *.dll
del *.exp
del *.lib

Some files were not shown because too many files have changed in this diff Show More