summary refs log tree commit diff stats
path: root/plugins/sysinfo/xsys.c
blob: 171282ff2176031a7624d040537e36d48436ac30 (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
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
/*
 * xsys.c - main functions for X-Sys 2
 * by mikeshoup
 * Copyright (C) 2003, 2004, 2005 Michael Shoup
 * Copyright (C) 2005, 2006, 2007 Tony Vroon
 *
 * 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 <stdlib.h>
#include <string.h>

#include "xchat-plugin.h"
#include "parse.h"
#include "match.h"
#include "xsys.h"

static xchat_plugin *ph;

static char name[] = "SysInfo";
static char desc[] = "Display info about your hardware and OS";
static char version[] = "2.2";
static char format[bsize] = "%B%1%B[%2]";
unsigned int percentages = 1;

static void load_config();
static void save_config();

static int format_cb		(char *word[], char *word_eol[], void *userdata);
static int percentages_cb	(char *word[], char *word_eol[], void *userdata);
static int sysinfo_cb		(char *word[], char *word_eol[], void *userdata);
static int xsys_cb		(char *word[], char *word_eol[], void *userdata);
static int cpuinfo_cb		(char *word[], char *word_eol[], void *userdata);
static int uptime_cb		(char *word[], char *word_eol[], void *userdata);
static int osinfo_cb		(char *word[], char *word_eol[], void *userdata);
static int sound_cb		(char *word[], char *word_eol[], void *userdata);
static int netdata_cb		(char *word[], char *word_eol[], void *userdata);
static int netstream_cb		(char *word[], char *word_eol[], void *userdata);
static int disk_cb		(char *word[], char *word_eol[], void *userdata);
static int mem_cb		(char *word[], char *word_eol[], void *userdata);
static int video_cb		(char *word[], char *word_eol[], void *userdata);
static int ether_cb		(char *word[], char *word_eol[], void *userdata);
static int distro_cb		(char *word[], char *word_eol[], void *userdata);
#if 0
static int hwmon_cb		(char *word[], char *word_eol[], void *userdata);
#endif

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, "XSYS2FORMAT",XCHAT_PRI_NORM, format_cb,    NULL, NULL);
	xchat_hook_command(ph, "PERCENTAGES",XCHAT_PRI_NORM, percentages_cb,   NULL, NULL);
	xchat_hook_command(ph, "SYSINFO",    XCHAT_PRI_NORM, sysinfo_cb,   NULL, (void *) 0);
	xchat_hook_command(ph, "ESYSINFO",   XCHAT_PRI_NORM, sysinfo_cb,   NULL, (void *) 1);
	xchat_hook_command(ph, "XSYS",       XCHAT_PRI_NORM, xsys_cb,      NULL, (void *) 0);
	xchat_hook_command(ph, "EXSYS",      XCHAT_PRI_NORM, xsys_cb,      NULL, (void *) 1);
	xchat_hook_command(ph, "CPUINFO",    XCHAT_PRI_NORM, cpuinfo_cb,   NULL, (void *) 0);
	xchat_hook_command(ph, "ECPUINFO",   XCHAT_PRI_NORM, cpuinfo_cb,   NULL, (void *) 1);
	xchat_hook_command(ph, "SYSUPTIME",  XCHAT_PRI_NORM, uptime_cb,    NULL, (void *) 0);
	xchat_hook_command(ph, "ESYSUPTIME", XCHAT_PRI_NORM, uptime_cb,    NULL, (void *) 1);
	xchat_hook_command(ph, "OSINFO",     XCHAT_PRI_NORM, osinfo_cb,    NULL, (void *) 0);
	xchat_hook_command(ph, "EOSINFO",    XCHAT_PRI_NORM, osinfo_cb,    NULL, (void *) 1);
	xchat_hook_command(ph, "SOUND",      XCHAT_PRI_NORM, sound_cb,     NULL, (void *) 0);
	xchat_hook_command(ph, "ESOUND",     XCHAT_PRI_NORM, sound_cb,     NULL, (void *) 1);
	xchat_hook_command(ph, "NETDATA",    XCHAT_PRI_NORM, netdata_cb,   NULL, (void *) 0);
	xchat_hook_command(ph, "ENETDATA",   XCHAT_PRI_NORM, netdata_cb,   NULL, (void *) 1);
	xchat_hook_command(ph, "NETSTREAM",  XCHAT_PRI_NORM, netstream_cb, NULL, (void *) 0);
	xchat_hook_command(ph, "ENETSTREAM", XCHAT_PRI_NORM, netstream_cb, NULL, (void *) 1);
	xchat_hook_command(ph, "DISKINFO",   XCHAT_PRI_NORM, disk_cb,      NULL, (void *) 0);
	xchat_hook_command(ph, "EDISKINFO",  XCHAT_PRI_NORM, disk_cb,      NULL, (void *) 1);
	xchat_hook_command(ph, "MEMINFO",    XCHAT_PRI_NORM, mem_cb,       NULL, (void *) 0);
	xchat_hook_command(ph, "EMEMINFO",   XCHAT_PRI_NORM, mem_cb,       NULL, (void *) 1);
	xchat_hook_command(ph, "VIDEO",      XCHAT_PRI_NORM, video_cb,     NULL, (void *) 0);
	xchat_hook_command(ph, "EVIDEO",     XCHAT_PRI_NORM, video_cb,     NULL, (void *) 1);
	xchat_hook_command(ph, "ETHER",      XCHAT_PRI_NORM, ether_cb,     NULL, (void *) 0);
	xchat_hook_command(ph, "EETHER",     XCHAT_PRI_NORM, ether_cb,     NULL, (void *) 1);
	xchat_hook_command(ph, "DISTRO",     XCHAT_PRI_NORM, distro_cb,    NULL, (void *) 0);
	xchat_hook_command(ph, "EDISTRO",    XCHAT_PRI_NORM, distro_cb,    NULL, (void *) 1);
#if 0
	xchat_hook_command(ph, "HWMON",      XCHAT_PRI_NORM, hwmon_cb,     NULL, (void *) 0);
	xchat_hook_command(ph, "EHWMON",     XCHAT_PRI_NORM, hwmon_cb,     NULL, (void *) 1);
#endif
	load_config();

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

static void save_config()
{
	FILE *fp;
	char buffer[bsize];
	snprintf(buffer, bsize, "%s/xsys2.conf", xchat_get_info(ph, "xchatdirfs"));
	fp = fopen(buffer, "w");
	if(fp == NULL)
	{
		printf("ERROR writing xsys2.conf");
		return;
	}
	fprintf(fp, "format: %s\n", format);
	fprintf(fp, "percentages: %i\n", percentages);
	fclose(fp);
	return;
}

static void load_config()
{
	FILE *fp;
	char buffer[bsize];
	snprintf(buffer, bsize, "%s/xsys2.conf", xchat_get_info(ph, "xchatdirfs"));
	fp = fopen(buffer, "r");
	if(fp == NULL)
		save_config();
	
	while(fgets(buffer, bsize, fp) != NULL)
	{
		find_match_char(buffer, "format", format);
		find_match_int(buffer, "percentages", &percentages);
	}
	fclose(fp);
}

static int format_cb(char *word[], char *word_eol[], void *userdata)
{
	if(*(word[2]) == '\0')
		xchat_printf(ph, "Current format string:\n%s", format);
	else
	{
		strncpy(format, word_eol[2], bsize);
		save_config();
	}
	return XCHAT_EAT_ALL;
}

static int percentages_cb(char *word[], char *word_eol[], void *userdata)
{
	if(*(word[2]) == '\0')
		if (percentages != 0)
			xchat_printf(ph, "Percentages currently enabled");
		else
			xchat_printf(ph, "Percentages currently disabled");		
	else
	{
		percentages = atoi(word[2]);
		save_config();
	}
	return XCHAT_EAT_ALL;
}

static int sysinfo_cb(char *word[], char *word_eol[], void *userdata)
{
	char sysinfo[bsize], buffer[bsize], cpu_model[bsize], cpu_cache[bsize], cpu_vendor[bsize];
	char os_host[bsize], os_user[bsize], os_kernel[bsize];
	unsigned long long mem_total, mem_free;
	unsigned int count;
	double cpu_freq;
	int giga = 0;
	sysinfo[0] = '\0';

// BEGIN OS PARSING
	if(xs_parse_os(os_user, os_host, os_kernel) != 0)
	{
		xchat_printf(ph, "ERROR in parse_os()");
		return XCHAT_EAT_ALL;
	}

	snprintf(buffer, bsize, "%s", os_kernel);
	format_output("os", buffer, format);
	strncat(sysinfo, buffer, bsize-strlen(sysinfo));

// BEGIN DISTRO PARSING
        if(xs_parse_distro(buffer) != 0)
		strncpy(buffer, "Unknown", bsize);
	format_output("distro", buffer, format);
	strcat(sysinfo, "\017 ");
	strncat(sysinfo, buffer, bsize-strlen(sysinfo));	
	
// BEGIN CPU PARSING
	if(xs_parse_cpu(cpu_model, cpu_vendor, &cpu_freq, cpu_cache, &count) != 0)
	{
		xchat_printf(ph, "ERROR in parse_cpu()");
		return XCHAT_EAT_ALL;
	}
	
	if(cpu_freq > 1000)
	{
		cpu_freq /= 1000;
		giga = 1;
	}
	
	if(giga) snprintf(buffer, bsize, "%d x %s (%s) @ %.2fGHz", count, cpu_model, cpu_vendor, cpu_freq);
	else snprintf(buffer, bsize, "%d x %s (%s) @ %.0fMHz", count, cpu_model, cpu_vendor, cpu_freq);
	format_output("cpu", buffer, format);
	strcat(sysinfo, "\017 ");
	strncat(sysinfo, buffer, bsize-strlen(sysinfo));

// BEGIN MEMORY PARSING
	if(xs_parse_meminfo(&mem_total, &mem_free, 0) == 1)
	{
		xchat_printf(ph, "ERROR in parse_meminfo!");
		return XCHAT_EAT_ALL;
	}
	snprintf(buffer, bsize, "%s", pretty_freespace("Physical", &mem_free, &mem_total));
	format_output("mem", buffer, format);	
	strcat(sysinfo, "\017 ");
	strncat(sysinfo, buffer, bsize-strlen(sysinfo));
	
// BEGIN DISK PARSING
	if(xs_parse_df(NULL, buffer))
	{
		xchat_printf(ph, "ERROR in parse_df");
		return XCHAT_EAT_ALL;
	}
	format_output("disk", buffer, format);
	strcat(sysinfo, "\017 ");
	strncat(sysinfo, buffer, bsize-strlen(buffer));
	
//BEGIN VIDEO PARSING
	if(xs_parse_video(buffer))
	{
		xchat_printf(ph, "ERROR in parse_video");
		return XCHAT_EAT_ALL;
	}
	format_output("video", buffer, format);
	strcat(sysinfo, "\017 ");
	strncat(sysinfo, buffer, bsize-strlen(buffer));
//BEGIN SOUND PARSING
	if(xs_parse_sound(buffer))
		strncpy(buffer, "Not present", bsize);
	format_output("sound", buffer, format);
	strcat(sysinfo, "\017 ");
	strncat(sysinfo, buffer, bsize-strlen(buffer));
	
	if((long)userdata)
		xchat_printf(ph, "%s", sysinfo);
	else
		xchat_commandf(ph, "say %s", sysinfo);	
	
	return XCHAT_EAT_ALL;
}

static int xsys_cb(char *word[], char *word_eol[], void *userdata)
{
	if((long)userdata)
		xchat_printf(ph, "You are using %s v%s (http://dev.gentoo.org/~chainsaw/xsys)", name, version);
	else
		xchat_commandf(ph, "me is using %s v%s (http://dev.gentoo.org/~chainsaw/xsys)", name, version);
	
	return XCHAT_EAT_ALL;
}

static int cpuinfo_cb(char *word[], char *word_eol[], void *userdata)
{
	char model[bsize], vendor[bsize], cache[bsize], buffer[bsize];
	unsigned int count;
	double freq;
	int giga = 0;
	
	if(xs_parse_cpu(model, vendor, &freq, cache, &count) != 0)
	{
		xchat_printf(ph, "ERROR in parse_cpu()");
		return XCHAT_EAT_ALL;
	}
	
	if(freq > 1000)
	{
		freq /= 1000;
		giga = 1;
	}
	
	if(giga) snprintf(buffer, bsize, "%d x %s (%s) @ %.2fGHz w/ %s L2 Cache", count, model, vendor, freq, cache);
	else snprintf(buffer, bsize, "%d x %s (%s) @ %.0fMHz w/ %s L2 Cache", count, model, vendor, freq, cache);
	
	format_output("cpu", buffer, format);
	
	if((long)userdata)
		xchat_printf(ph, "%s", buffer);
	else
		xchat_commandf(ph, "say %s", buffer);
	
	return XCHAT_EAT_ALL;
}

static int uptime_cb(char *word[], char *word_eol[], void *userdata)
{
	char buffer[bsize];
	int weeks, days, hours, minutes, seconds;
	
	if(xs_parse_uptime(&weeks, &days, &hours, &minutes, &seconds))
	{
		xchat_printf(ph, "ERROR in parse_uptime()");
		return XCHAT_EAT_ALL;
	}
	
	if( minutes != 0 || hours != 0 || days != 0 || weeks != 0 )
	{
		if( hours != 0 || days != 0 || weeks != 0 )
		{
			if( days  !=0 || weeks != 0 )
			{
                                if( weeks != 0 )
                                {
                                        snprintf( buffer, bsize, "%dw %dd %dh %dm %ds",
                                                  weeks, days, hours, minutes, seconds );
                                }
                                else
                                {
                                        snprintf( buffer, bsize, "%dd %dh %dm %ds",
                                                  days, hours, minutes, seconds );
                                }
                        }
                        else
                        {
                                snprintf( buffer, bsize, "%dh %dm %ds",
                                          hours, minutes, seconds );
                        }
                }
                else
                {
                        snprintf( buffer, bsize, "%dm %ds", minutes, seconds );
                }
        }

	format_output("uptime", buffer, format);
	
	if((long)userdata)
		xchat_printf(ph, "%s", buffer);
	else
		xchat_commandf(ph, "say %s", buffer);
	
	return XCHAT_EAT_ALL;
}

static int osinfo_cb(char *word[], char *word_eol[], void *userdata)
{
	char buffer[bsize], user[bsize], host[bsize], kernel[bsize];
	
	if(xs_parse_os(user, host, kernel) != 0)
	{
		xchat_printf(ph, "ERROR in parse_os()");
		return XCHAT_EAT_ALL;
	}

	snprintf(buffer, bsize, "%s@%s, %s", user, host, kernel);
	format_output("os", buffer, format);
	
	if((long)userdata)
		xchat_printf(ph, "%s", buffer);
	else
		xchat_commandf(ph, "say %s", buffer);
	
	return XCHAT_EAT_ALL;
}

static int sound_cb(char *word[], char *world_eol[], void *userdata)
{
	char sound[bsize];
	if(xs_parse_sound(sound) != 0)
	{
		xchat_printf(ph, "ERROR in parse_asound()!");
		return XCHAT_EAT_ALL;
	}
	
	format_output("sound", sound, format);
	
	if((long)userdata)
		xchat_printf(ph, "%s", sound);
	else
		xchat_commandf(ph, "say %s", sound);
	
	return XCHAT_EAT_ALL;
}

static int distro_cb(char *word[], char *word_eol[], void *userdata)
{
	char name[bsize];
	if(xs_parse_distro(name) != 0)
	{
		xchat_printf(ph, "ERROR in parse_distro()!");
		return XCHAT_EAT_ALL;
	}
	
	format_output("distro", name, format);
	if((long)userdata)
		xchat_printf(ph, "%s", name);
	else
		xchat_commandf(ph, "say %s", name);
	return XCHAT_EAT_ALL;
}	

static int netdata_cb(char *word[], char *word_eol[], void *userdata)
{
	char netdata[bsize];
	unsigned long long bytes_recv, bytes_sent;
	
	if(*word[2] == '\0')
	{
		xchat_printf(ph, "You must specify a network device! (eg.: /netdata eth0)");
		return XCHAT_EAT_ALL;
	}
	
	if(xs_parse_netdev(word[2], &bytes_recv, &bytes_sent) != 0)
	{
		xchat_printf(ph, "ERROR in parse_netdev");
		return XCHAT_EAT_ALL;
	}
	
	bytes_recv /= 1024;
	bytes_sent /= 1024;
	
	snprintf(netdata, bsize, "%s: %.1f MB Recieved, %.1f MB Sent", word[2], (double)bytes_recv/1024.0, (double)bytes_sent/1024.0);
	format_output("netdata", netdata, format);
	if((long)userdata)
		xchat_printf(ph, "%s", netdata);
	else
		xchat_commandf(ph, "say %s", netdata);
		
	return XCHAT_EAT_ALL;
}

static int netstream_cb(char *word[], char *word_eol[], void *userdata)
{
	char netstream[bsize], mag_r[3], mag_s[5];
	unsigned long long bytes_recv, bytes_sent, bytes_recv_p, bytes_sent_p;
	struct timespec ts = {1, 0};
	

	if(*word[2] == '\0')
	{
		xchat_printf(ph, "You must specify a network device! (eg.: /netstream eth0)");
		return XCHAT_EAT_ALL;
	}
	
	if(xs_parse_netdev(word[2], &bytes_recv, &bytes_sent) != 0)
	{
		xchat_printf(ph, "ERROR in parse_netdev");
		return XCHAT_EAT_ALL;
	}
	
	while(nanosleep(&ts, &ts) < 0);
	
	if(xs_parse_netdev(word[2], &bytes_recv_p, &bytes_sent_p) != 0)
	{
		xchat_printf(ph, "ERROR in parse_netdev");
		return XCHAT_EAT_ALL;
	}
	
	bytes_recv = (bytes_recv_p - bytes_recv);
	bytes_sent = (bytes_sent_p - bytes_sent);
	
	if(bytes_recv>1024)
	{
		bytes_recv /= 1024;
		snprintf(mag_r, 5, "KB/s");
	}
	else snprintf(mag_r, 5, "B/s");
	
	if(bytes_sent>1024)
	{
		bytes_sent /= 1024;
		snprintf(mag_s, 5, "KB/s");
	}
	else snprintf(mag_s, 5, "B/s");
	
	snprintf(netstream, bsize, "%s: Receiving %llu %s, Sending %llu %s", word[2], bytes_recv, mag_r, bytes_sent, mag_s);
	format_output("netstream", netstream, format);
	if((long)userdata)
		xchat_printf(ph, "%s", netstream);
	else
		xchat_commandf(ph, "say %s", netstream);
	
	return XCHAT_EAT_ALL;
}

static int disk_cb(char *word[], char *word_eol[], void *userdata)
{
	char string[bsize] = {0,};
	
	if(*word[2] == '\0')
	{
		if(xs_parse_df(NULL, string))
		{
			xchat_printf(ph, "ERROR in parse_df");
			return XCHAT_EAT_ALL;
		}
	}
	else
	{
		if(xs_parse_df(word[2], string))
		{
			xchat_printf(ph, "ERROR in parse_df");
			return XCHAT_EAT_ALL;
		}
	}
	
	format_output("disk", string, format);
	
	if((long)userdata)
		xchat_printf(ph, "%s", string);
	else
		xchat_commandf(ph, "say %s", string);
	
	return XCHAT_EAT_ALL;
}

static int mem_cb(char *word[], char *word_eol[], void *userdata)
{
	unsigned long long mem_total, mem_free, swap_total, swap_free;
	char string[bsize];
	
	if(xs_parse_meminfo(&mem_total, &mem_free, 0) == 1)
	{
		xchat_printf(ph, "ERROR in parse_meminfo!");
		return XCHAT_EAT_ALL;
	}
	if(xs_parse_meminfo(&swap_total, &swap_free, 1) == 1)
	{
		xchat_printf(ph, "ERROR in parse_meminfo!");
		return XCHAT_EAT_ALL;
	}

	snprintf(string, bsize, "%s - %s", pretty_freespace("Physical", &mem_free, &mem_total),
		 pretty_freespace("Swap", &swap_free, &swap_total));
	format_output("mem", string, format);
	
	if((long)userdata)
		xchat_printf(ph, "%s", string);
	else
		xchat_commandf(ph, "say %s", string);
	
	return XCHAT_EAT_ALL;
}

static int video_cb(char *word[], char *word_eol[], void *userdata)
{
	char vid_card[bsize], agp_bridge[bsize], buffer[bsize];
	int ret;
	if((ret = xs_parse_video(vid_card)) != 0)
	{
		xchat_printf(ph, "ERROR in parse_video! %d", ret);
		return XCHAT_EAT_ALL;
	}
	
	if(xs_parse_agpbridge(agp_bridge) != 0)
		snprintf(buffer, bsize, "%s", vid_card);
	else
		snprintf(buffer, bsize, "%s @ %s", vid_card, agp_bridge);
	
	format_output("video", buffer, format);
	if((long)userdata)
		xchat_printf(ph, "%s", buffer);
	else
		xchat_commandf(ph, "say %s", buffer);
	
	return XCHAT_EAT_ALL;
}

static int ether_cb(char *word[], char *word_eol[], void *userdata)
{
	char ethernet_card[bsize];
	if(xs_parse_ether(ethernet_card))
		strncpy(ethernet_card, "None found", bsize);
	format_output("ether", ethernet_card, format);
	if((long)userdata)
		xchat_printf(ph, "%s", ethernet_card);
	else
		xchat_commandf(ph, "say %s", ethernet_card);
	
	return XCHAT_EAT_ALL;
}

#if 0
static int hwmon_cb(char *word[], char *word_eol[], void *userdata)
{
	char chip[bsize], buffer[bsize];
	
	if(xs_parse_hwmon_chip(chip))
	{
		xchat_printf(ph, "ERROR No hardware monitoring support found");
		return XCHAT_EAT_ALL;
	}
	format_output("sensor", chip, format);
	strcat(chip, "\017 ");

	xs_parse_hwmon_temp(buffer, 1);
	format_output("temp1", buffer, format);
	strncat(chip, buffer, bsize);
	
	if((long)userdata)
		xchat_printf(ph, "%s", chip);
	else
		xchat_commandf(ph, "say %s", chip);
	
	return XCHAT_EAT_ALL;
}
#endif