summary refs log tree commit diff stats
path: root/plugins/wmpa/wmpa.vcxproj
blob: 5698f5cdf3d6fb231b8f9cc444cf6c3fa2269f16 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?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>{E7F4DB0A-510D-41EF-B284-6E1DE1CC450D}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <RootNamespace>wmpa</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>false</WholeProgramOptimization>
    <CharacterSet>MultiByte</CharacterSet>
    <UseOfMfc>Dynamic</UseOfMfc>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>false</WholeProgramOptimization>
    <CharacterSet>MultiByte</CharacterSet>
    <UseOfMfc>Dynamic</UseOfMfc>
  </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\hexchat.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\hexchat.props" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LinkIncremental>false</LinkIncremental>
    <TargetName>hcwmpa</TargetName>
    <OutDir>$(HexChatBin)</OutDir>
    <IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <LinkIncremental>false</LinkIncremental>
    <TargetName>hcwmpa</TargetName>
    <OutDir>$(HexChatBin)</OutDir>
    <IntDir>$(HexChatObj)$(ProjectName)\</IntDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>Create</PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WMPA_EXPORTS;_AFXDLL;_AFX_NO_DAO_SUPPORT;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MultiProcessorCompilation>false</MultiProcessorCompilation>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <ModuleDefinitionFile>wmpa.def</ModuleDefinitionFile>
    </Link>
    <Midl>
      <MkTypLibCompatible>true</MkTypLibCompatible>
    </Midl>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>Create</PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;WMPA_EXPORTS;_AFXDLL;_AFX_NO_DAO_SUPPORT;_WIN32_WINNT=0x0501;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MultiProcessorCompilation>false</MultiProcessorCompilation>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <ModuleDefinitionFile>wmpa.def</ModuleDefinitionFile>
    </Link>
    <Midl>
      <MkTypLibCompatible>true</MkTypLibCompatible>
    </Midl>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClCompile Include="StdAfx.cpp" />
    <ClCompile Include="wmpa.cpp" />
    <ClCompile Include="wmpadialog.cpp" />
    <ClCompile Include="wmpcdrom.cpp" />
    <ClCompile Include="wmpcdromcollection.cpp" />
    <ClCompile Include="wmpclosedcaption.cpp" />
    <ClCompile Include="wmpcontrols.cpp" />
    <ClCompile Include="wmpdvd.cpp" />
    <ClCompile Include="wmperror.cpp" />
    <ClCompile Include="wmperroritem.cpp" />
    <ClCompile Include="wmpmedia.cpp" />
    <ClCompile Include="wmpmediacollection.cpp" />
    <ClCompile Include="wmpnetwork.cpp" />
    <ClCompile Include="wmpplayer4.cpp" />
    <ClCompile Include="wmpplayerapplication.cpp" />
    <ClCompile Include="wmpplaylist.cpp" />
    <ClCompile Include="wmpplaylistarray.cpp" />
    <ClCompile Include="wmpplaylistcollection.cpp" />
    <ClCompile Include="wmpsettings.cpp" />
    <ClCompile Include="wmpstringcollection.cpp" />
    <ClCompile Include="hexchat-plugin.cpp" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="resource.h" />
    <ClInclude Include="StdAfx.h" />
    <ClInclude Include="wmpa.h" />
    <ClInclude Include="wmpadialog.h" />
    <ClInclude Include="wmpcdrom.h" />
    <ClInclude Include="wmpcdromcollection.h" />
    <ClInclude Include="wmpclosedcaption.h" />
    <ClInclude Include="wmpcontrols.h" />
    <ClInclude Include="wmpdvd.h" />
    <ClInclude Include="wmperror.h" />
    <ClInclude Include="wmperroritem.h" />
    <ClInclude Include="wmpmedia.h" />
    <ClInclude Include="wmpmediacollection.h" />
    <ClInclude Include="wmpnetwork.h" />
    <ClInclude Include="wmpplayer4.h" />
    <ClInclude Include="wmpplayerapplication.h" />
    <ClInclude Include="wmpplaylist.h" />
    <ClInclude Include="wmpplaylistarray.h" />
    <ClInclude Include="wmpplaylistcollection.h" />
    <ClInclude Include="wmpsettings.h" />
    <ClInclude Include="wmpstringcollection.h" />
    <ClInclude Include="hexchat-plugin.h" />
  </ItemGroup>
  <ItemGroup>
    <None Include="ReadMe.txt" />
    <None Include="res\wmpa.rc2" />
    <None Include="wmpa.aps" />
    <None Include="wmpa.def" />
    <None Include="wmpa.ico" />
  </ItemGroup>
  <ItemGroup>
    <Midl Include="wmpa.odl" />
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="wmpa.rc" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
pan class="w"> 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; }