summary refs log tree commit diff stats
path: root/plugins/sysinfo/xsys-changelog
blob: 9ea20727a161b07c1704c20140de8c52756af7c0 (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
v2.2.0
	* (Thomas Cort) Report L2 cache info for Alpha CPUs
	* (Tony Vroon) Drop XMMS, port audacious features to D-Bus, make dependency mandatory
	* (Tony Vroon) Use pretty_freespace for memory & swap reporting as well as disk space
	* (Tony Vroon) Make pretty_freespace report none if total_size is 0, thanks to Emopig <andrew@nelless.net> for the report
	* (Tony Vroon) Make pretty_freespace aware of terabytes, petabytes, exabytes, zettabytes & yottabytes
	* (Tony Vroon) Remove xchatdirfs workaround

v2.1.0
	Removals & pending removal:
	* (Tony Vroon) Remove support for BMP, it is an abandoned project. Suggested upgrade path: audacious
	* (Tony Vroon) Remove /uname & /euname; the OS part of sysinfo displays similar info without requiring a process pipe
	* (Tony Vroon) Added a note that the xchatdirfs workaround is due for removal as X-Chat Gnome has fixed the bug

	Bugfixes:
	* (Tony Vroon) Actually show the vendor that we retrieve in cpuinfo
	* (Tony Vroon) Display Gentoo Linux as stable or ~arch, the baselayout version doesn't really interest anyone
	* (Tony Vroon) Match framework: Make remove_leading_whitespace actually work
	* (Tony Vroon) Match framework: Do not assume that a delimiter is always followed by a space

	Code improvements:
	* (Tony Vroon) PCI framework: We were requesting more info then we actually return to the caller
	* (Tony Vroon) Match framework: Consolidate delimiters in a single define & use 1 strpbrk instead of 2 strstr's
	* (Tony Vroon) Display the machine string instead of the pmac-generation as vendor info for PPC machines

	New features
	* (Tony Vroon) Show memory capacity in gigabytes instead of in megabytes when appropriate
	* (Tony Vroon) Cut cpu name at comma (so overly long other info such as "altivec supported" is no longer displayed)
	* (Tony Vroon) Now Playing: Report time played as well as the song length
	* (Tony Vroon) Now Playing: Support reporting as an action; configurable at runtime
	* (Tony Vroon) Check LSB release data, prefer above all others; based on a code sample submitted by Thomas Winwood

v2.0.9
	* (Tony Vroon) Protect the matching framework against spurious matches (bug reported by Harm Geerts)
	* (Tony Vroon) Unexporting unnecessary symbols for PCI framework
	* (Tony Vroon) Deal with incompatible header changes in pciutils
	* (Tony Vroon) Begin implementing hardware monitoring support, not yet activated
	* (Tony Vroon) Add support for Audacious, a BMP fork

v2.0.8
	* (Tony Vroon) Make XMMS interface actually work, thanks to a patch from Morten Cools
	* (Tony Vroon) Use percentages for df information as well
	* (Gustavo Zacarias) Add support for Sparc architecture, cache size detection on sparc64 only
	* (Gustavo Zacarias) Consolidate buffer sizes into a single define

v2.0.7
	* (Tony Vroon) Have df parser ignore pseudo-filesystems; deal with other locales more gracefully
	* (Tony Vroon) Change default formatstring not to use mIRC color codes
	* (Tony Vroon) Add fallback to ~/.xchat2 for xchat-gnome which does not report xchatdirfs properly
	* (Tony Vroon) Revert to beepctrl.h style calls as infopipe is too unreliable

v2.0.6
	* (Tony Vroon) Rewrote PCI framework, no longer depends on sysfs, kernel 2.4 and lower will work now
	* (Tony Vroon) Made percentages configurable, can be set at runtime (feature request by Halcy0n)
	* (Tony Vroon) Abstract out all pointer voodoo from xsys.c
	* (Tony Vroon) Do not return XCHAT_EAT_NONE, causes spurious "unknown command" errors
	* (Tony Vroon) Deal more gracefully with a missing soundcard or unknown linux distribution
	* (Tony Vroon) Add error handling to the matching framework

v2.0.5
	* (Tony Vroon) Added support for parisc/hppa & ia64 architectures
	* (Tony Vroon) Proper report of L2 cache as "unknown" instead of showing bits of unitialized memory
	* (Tony Vroon) Upped PCI parser yield for ppc64 architecture, has high bus number for AGP card
	* (Tony Vroon) Use percentages in memory/swap information

v2.0.4
	* (Tony Vroon) /sound uses ALSA if possible, PCI now fallback (false positives reported with PCI code)
	* (Tony Vroon) Remove 0 prefix from first ALSA card; 1: and up will be shown for extra cards
	* (Tony Vroon) Matching code rewritten and separated out from other code
	* (Tony Vroon) Use new matching framework where possible
	* (Tony Vroon) Added support for Alpha architecture, thanks to Bert (bert@ev6.net)

v2.0.3
	* (Tony Vroon) Fix buttons, XMMS -> NP
	* (Tony Vroon) PCI functions separated out from other code; fully rewritten
	* (Tony Vroon) Use new PCI framework for sound detection; ALSA is now fallback
	* (Tony Vroon) Implement /ether
	* (Tony Vroon) /video now reports video card @ AGP bridge; resolution info dropped

v2.0.2
	* (Tony Vroon) XMMS/BMP: Delete XMMS/BMP detection; it just got obsoleted by a BMP bugfix
	* (Tony Vroon) XMMS/BMP: Change to /np & /enp as commands (np -> now playing)
	* (Tony Vroon) Allow customization of now_playing with /playing
	* (Tony Vroon) Separate out the length field for now_playing
	* (Tony Vroon) Better configuration file handling
	* (Tony Vroon) Set homepage to http://dev.gentoo.org/~chainsaw/xsys
	* (Tony Vroon) Make channel buttons optional, not everyone appreciates them
	* (Tony Vroon) Fix cpuinfo parsing on x86_64, a necessary define was missing

v2.0.1
	* (Tony Vroon) XMMS/BMP: Report "stream" if song length is -1
	* (Tony Vroon) XMMS/BMP: Determine whether XMMS or BMP is playing
	* (Tony Vroon) Better errorhandling if pci.ids parsing fails; at least mention raw PCI ID of card
	* (Tony Vroon) Remove AGP from video card messages; we detect plain PCI cards too
	* (Tony Vroon) Fix Debian release detector

v2.0.0
	* (mikeshoup)  Clean up of code for 2.0.0 release
	* (Tony Vroon) Added PowerPC /proc/cpuinfo support
	* (Tony Vroon) Changed LSPCI to SYSFS

v1.9.3
	* (mikeshoup) Introduced distro function
	* (mikeshoup, Tony Vroon's suggestion) Removed bitrate from /XMMS

v1.9.2
	* 2005/01/14 (mikeshoup) Put in the userlist buttons
	* 2005/01/10 (mikeshoup) Added XMMS/BMP Support

v1.9.1
	* 2004/12/20 (mikeshoup) Added a dynamic formatting scheme
	* 2004/12/19 (mikeshoup) Changed some commands
	* 2004/12/18 (mikeshoup) Reintroducted /VIDEO

v1.9.0
	* 2004/12/17 (mikeshoup) Initial Release
keviktor@aol.com> 2012-01-20 18:02:55 +0100 update the checksum plugin to use the plugin config api' href='/git-repos/torxchat.git/commit/plugins/checksum/checksum.c?h=fix-ub&id=83b6f548adc704f7b122add1fd38b6879ba2ed8d'>83b6f548 ^
d03d6e60 ^
83b6f548 ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^
e681eafa ^
83b6f548 ^

d03d6e60 ^
e681eafa ^
d03d6e60 ^
d03d6e60 ^
83b6f548 ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^
d03d6e60 ^

83b6f548 ^

d03d6e60 ^
e681eafa ^
d03d6e60 ^
83b6f548 ^
d03d6e60 ^
83b6f548 ^


d03d6e60 ^
83b6f548 ^
d03d6e60 ^



83b6f548 ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^











83b6f548 ^
d03d6e60 ^


e681eafa ^

83b6f548 ^

d03d6e60 ^
e681eafa ^

d03d6e60 ^
83b6f548 ^

d03d6e60 ^
e681eafa ^
d03d6e60 ^

45d4fa58 ^
d03d6e60 ^











83b6f548 ^
d03d6e60 ^

e681eafa ^
83b6f548 ^

d03d6e60 ^
e681eafa ^

d03d6e60 ^
83b6f548 ^

d03d6e60 ^
e681eafa ^
d03d6e60 ^

45d4fa58 ^
d03d6e60 ^

e3be4a0e ^

d03d6e60 ^
1b0c07f8 ^
d03d6e60 ^
83b6f548 ^

1b0c07f8 ^
d03d6e60 ^
83b6f548 ^


d03d6e60 ^
e681eafa ^


d03d6e60 ^
e3be4a0e ^
45d4fa58 ^
d03d6e60 ^


e681eafa ^
d03d6e60 ^


e2acf19d ^


d03d6e60 ^
83b6f548 ^
e681eafa ^
83b6f548 ^
e681eafa ^
83b6f548 ^
d03d6e60 ^
e681eafa ^


d03d6e60 ^
e681eafa ^
d03d6e60 ^



e681eafa ^
d03d6e60 ^
e681eafa ^
d03d6e60 ^

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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
          
                                        
  





                                                                                
  

                                                                             
  






                                                                                



                   
                   


                      
                        
                 
 
            





                          









                           
                           


                                                                                                                             
 
                                                                                                                   


                                                                 
 
                                                                 

































































                                                                                    
                      
 
                                 
 
                                           
         
                                                                     
                 
                                                                                                              

                    
                 
                                                                                 
                 
         
            
         
                                                        
         

 

            
 
                                                            
 
                                          
         


                                     
         
                            



           
              
 
                                                                                   











                                                                                                                                       
                                                                                  


                                                                                                                                  

                                                                                                    

                    
                 

                                                                                                                                                                                 
                 

            
         
                                                            

         
                                











                                                                                                                                       
                                                                                  

                                                                                                                                  
                                                                                                                               

                    
                 

                                                                                                                                                                  
                 

            
         
                                                            

         
                                

 

                                                         
 
                                                 
         

                               
                                                      
         


                                    
         


                                                                                                            
         
 
                                


   
                                                                                                                             


                           


                                  
 
                                                     
                                                           
         
                                                                        
         
 


                                                                                                         
 
                                                        



                 
                            
 
                                                          

                 
/* HexChat
 * 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 <stdlib.h>
#include <malloc.h>
#include <errno.h>
#include <sys/types.h>
#include <openssl/sha.h>
#include <glib.h>

#ifdef WIN32
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef stat64
#define stat64 _stat64
#endif
#else
/* for INT_MAX */
#include <limits.h>
#define __USE_LARGEFILE64
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#endif

#include <sys/stat.h>

#include "hexchat-plugin.h"

#define BUFSIZE 32768
#define DEFAULT_LIMIT 256									/* default size is 256 MiB */

static hexchat_plugin *ph;									/* plugin handle */
static char name[] = "Checksum";
static char desc[] = "Calculate checksum for DCC file transfers";
static char version[] = "3.1";

/* 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 (hexchat_pluginpref_set_int (ph, "limit", buffer))
		{
			hexchat_printf (ph, "File size limit has successfully been set to: %d MiB\n", buffer);
		}
		else
		{
			hexchat_printf (ph, "File access error while saving!\n");
		}
	}
	else
	{
		hexchat_printf (ph, "Invalid input!\n");
	}
}

static int
get_limit ()
{
	int size = hexchat_pluginpref_get_int (ph, "limit");

	if (size <= -1 || size >= INT_MAX)
	{
		return DEFAULT_LIMIT;
	}
	else
	{
		return size;
	}
}

static void
print_limit ()
{
	hexchat_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 */
			hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
			hexchat_printf (ph, "SHA-256 checksum for %s (local):  %s\n", word[1], sum);
		}
		else
		{
			hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
			hexchat_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
	{
		hexchat_printf (ph, "File access error!\n");
	}

	return HEXCHAT_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 */
			hexchat_commandf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): %s", word[2], word[1], sum);
		}
		else
		{
			hexchat_set_context (ph, hexchat_find_context (ph, NULL, word[3]));
			hexchat_printf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): (size limit reached, no checksum calculated)", word[2], word[1]);
		}
	}
	else
	{
		hexchat_printf (ph, "File access error!\n");
	}

	return HEXCHAT_EAT_NONE;
}

static int
checksum (char *word[], char *word_eol[], void *userdata)
{
	if (!g_ascii_strcasecmp ("GET", word[2]))
	{
		print_limit ();
	}
	else if (!g_ascii_strcasecmp ("SET", word[2]))
	{
		set_limit (word[3]);
	}
	else
	{
		hexchat_printf (ph, "Usage: /CHECKSUM GET|INC|DEC\n");
		hexchat_printf (ph, "  GET - print the maximum file size (in MiB) to be hashed\n");
		hexchat_printf (ph, "  SET <filesize> - set the maximum file size (in MiB) to be hashed\n");
	}

	return HEXCHAT_EAT_NONE;
}

int
hexchat_plugin_init (hexchat_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 (hexchat_pluginpref_get_int (ph, "limit") == -1)
	{
		hexchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT);
	}

	hexchat_hook_command (ph, "CHECKSUM", HEXCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", 0);
	hexchat_hook_print (ph, "DCC RECV Complete", HEXCHAT_PRI_NORM, dccrecv_cb, NULL);
	hexchat_hook_print (ph, "DCC Offer", HEXCHAT_PRI_NORM, dccoffer_cb, NULL);

	hexchat_printf (ph, "%s plugin loaded\n", name);
	return 1;
}

int
hexchat_plugin_deinit (void)
{
	hexchat_printf (ph, "%s plugin unloaded\n", name);
	return 1;
}