diff options
151 files changed, 4089 insertions, 2360 deletions
| @@ -1,48 +1,59 @@ -GTK_LIBS = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0   -GTK_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/pixman-1   -SOUP_LIBS = -lsoup-2.2 -lgnutls -ltasn1 -lgcrypt -lgobject-2.0 -lxml2 -lz -lm -lglib-2.0   -SOUP_CFLAGS = -I/usr/include/libsoup-2.2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2   -PACKAGE = hardinfo-0.4.2.3 +GTK_LIBS = -lpthread -lgthread-2.0 -lrt -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   +GTK_CFLAGS = -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12   +SOUP_LIBS =  +SOUP_CFLAGS =  +PACKAGE = hardinfo-0.5c  ARCHOPTS =   LIBDIR = /usr/lib +CCFLAGS = -fPIC -pipe -Wall -g  +CFLAGS = $(GTK_CFLAGS) $(SOUP_CFLAGS) -I.  CC = gcc $(ARCHOPTS) -g  CCSLOW = gcc -O0 -g -CFLAGS = -fPIC -pipe -Wall -g $(GTK_CFLAGS) $(GLADE_CFLAGS) $(SOUP_CFLAGS) -I.  # ---------------------------------------------------------------------------- -OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o sha1.o md5.o \ -		menu.o stock.o callbacks.o expr.o report.o blowfish.o binreloc.o \ -		vendor.o socket.o fbench.o syncmanager.o -MODULES = computer.so devices.so benchmark.so  +OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o  \ +		menu.o stock.o callbacks.o expr.o report.o binreloc.o \ +		vendor.o socket.o syncmanager.o +BENCHMARK_OBJECTS = fbench.o sha1.o blowfish.o md5.o nqueens.o fftbench.o -all:	$(OBJECTS) $(MODULES) -	$(CC) $(CFLAGS) -o hardinfo -Wl,-export-dynamic $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS) \ -		$(GLADE_LIBS) $(GLADE_FLAGS) $(SOUP_LIBS) $(SOUP_FLAGS) +MODULES = computer.so devices.so benchmark.so network.so + +all:	$(OBJECTS) $(MODULES) hardinfo + +hardinfo: +	$(CC) $(CCFLAGS) -o hardinfo -Wl,-export-dynamic $(OBJECTS) $(GTK_LIBS) \ +		$(SOUP_LIBS)  md5.o: -	$(CCSLOW) $(CFLAGS) -c md5.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c md5.c -o $@  blowfish.o: -	$(CCSLOW) $(CFLAGS) -c blowfish.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c blowfish.c -o $@  sha1.o: -	$(CCSLOW) $(CFLAGS) -c sha1.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c sha1.c -o $@  fbench.o: -	$(CCSLOW) $(CFLAGS) -c fbench.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c fbench.c -o $@ + +fftbench.o: +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c fftbench.c -o $@ + +nqueens.o: +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c nqueens.c -o $@  benchmark.so:	benchmark.c  	@echo "[01;34m--- Module: $< ($@)[00m" -	$(CCSLOW) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS) \ -		$(GLADE_LIBS) $(GLADE_FLAGS) +	make $(BENCHMARK_OBJECTS) +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -o $@ -shared $< $(BENCHMARK_OBJECTS) \ +		$(GTK_FLAGS) $(GTK_LIBS)  	ln -sf ../$@ modules  %.so:	%.c  	@echo "[01;34m--- Module: $< ($@)[00m" -	$(CC) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS) \ -		$(GLADE_LIBS) $(GLADE_FLAGS) +	$(CC) $(CCFLAGS) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS)  	ln -sf ../$@ modules  clean: @@ -64,9 +75,15 @@ deb:	dist-clean  	dpkg-buildpackage -rfakeroot -k${USER}  install:	all +	@echo '[01;34m*** Cleaning up installation...[00m' +	rm -rf ${DESTDIR}${LIBDIR}/hardinfo/modules ${DESTDIR}/usr/share/hardinfo/pixmaps +  	@echo '[01;34m*** Creating directories...[00m'  	mkdir -p ${DESTDIR}/usr/bin +	mkdir -p ${DESTDIR}/usr/local  	mkdir -p ${DESTDIR}/usr/share/applications +	 +  	mkdir -p ${DESTDIR}${LIBDIR}/hardinfo/modules  	mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps @@ -77,10 +94,10 @@ install:	all  	cp hardinfo ${DESTDIR}/usr/bin/hardinfo  	@echo '[01;34m*** Installing modules...[00m' -	cp -Lr modules/*.so ${DESTDIR}${LIBDIR}/hardinfo/modules +	cp -Lvr modules/*.so ${DESTDIR}${LIBDIR}/hardinfo/modules  	@echo '[01;34m*** Installing pixmaps...[00m' -	cp -Lr pixmaps/* ${DESTDIR}/usr/share/hardinfo/pixmaps +	cp -Lvr pixmaps/* ${DESTDIR}/usr/share/hardinfo/pixmaps  	@echo '[01;34m*** Installing misc data...[00m'  	cp benchmark.conf ${DESTDIR}/usr/share/hardinfo @@ -92,4 +109,5 @@ install:	all  	@echo '[01;34m*** Done installing.[00m'  installer: -	makeinstaller +	makepackage +	 diff --git a/Makefile.in b/Makefile.in index 775ec26a..5639db69 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,41 +1,52 @@ +CCFLAGS = -fPIC -pipe -Wall -g  +CFLAGS = $(GTK_CFLAGS) $(SOUP_CFLAGS) -I.  CC = gcc $(ARCHOPTS) -g  CCSLOW = gcc -O0 -g -CFLAGS = -fPIC -pipe -Wall -g $(GTK_CFLAGS) $(GLADE_CFLAGS) $(SOUP_CFLAGS) -I.  # ---------------------------------------------------------------------------- -OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o sha1.o md5.o \ -		menu.o stock.o callbacks.o expr.o report.o blowfish.o binreloc.o \ -		vendor.o socket.o fbench.o syncmanager.o -MODULES = computer.so devices.so benchmark.so  +OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o  \ +		menu.o stock.o callbacks.o expr.o report.o binreloc.o \ +		vendor.o socket.o syncmanager.o +BENCHMARK_OBJECTS = fbench.o sha1.o blowfish.o md5.o nqueens.o fftbench.o -all:	$(OBJECTS) $(MODULES) -	$(CC) $(CFLAGS) -o hardinfo -Wl,-export-dynamic $(OBJECTS) $(GTK_LIBS) $(GTK_FLAGS) \ -		$(GLADE_LIBS) $(GLADE_FLAGS) $(SOUP_LIBS) $(SOUP_FLAGS) +MODULES = computer.so devices.so benchmark.so network.so + +all:	$(OBJECTS) $(MODULES) hardinfo + +hardinfo: +	$(CC) $(CCFLAGS) -o hardinfo -Wl,-export-dynamic $(OBJECTS) $(GTK_LIBS) \ +		$(SOUP_LIBS)  md5.o: -	$(CCSLOW) $(CFLAGS) -c md5.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c md5.c -o $@  blowfish.o: -	$(CCSLOW) $(CFLAGS) -c blowfish.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c blowfish.c -o $@  sha1.o: -	$(CCSLOW) $(CFLAGS) -c sha1.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c sha1.c -o $@  fbench.o: -	$(CCSLOW) $(CFLAGS) -c fbench.c -o $@ +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c fbench.c -o $@ + +fftbench.o: +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c fftbench.c -o $@ + +nqueens.o: +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -c nqueens.c -o $@  benchmark.so:	benchmark.c  	@echo "[01;34m--- Module: $< ($@)[00m" -	$(CCSLOW) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS) \ -		$(GLADE_LIBS) $(GLADE_FLAGS) +	make $(BENCHMARK_OBJECTS) +	$(CCSLOW) $(CCFLAGS) $(CFLAGS) -o $@ -shared $< $(BENCHMARK_OBJECTS) \ +		$(GTK_FLAGS) $(GTK_LIBS)  	ln -sf ../$@ modules  %.so:	%.c  	@echo "[01;34m--- Module: $< ($@)[00m" -	$(CC) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS) \ -		$(GLADE_LIBS) $(GLADE_FLAGS) +	$(CC) $(CCFLAGS) $(CFLAGS) -o $@ -shared $< $(GTK_FLAGS) $(GTK_LIBS)  	ln -sf ../$@ modules  clean: @@ -57,9 +68,15 @@ deb:	dist-clean  	dpkg-buildpackage -rfakeroot -k${USER}  install:	all +	@echo '[01;34m*** Cleaning up installation...[00m' +	rm -rf ${DESTDIR}${LIBDIR}/hardinfo/modules ${DESTDIR}/usr/share/hardinfo/pixmaps +  	@echo '[01;34m*** Creating directories...[00m'  	mkdir -p ${DESTDIR}/usr/bin +	mkdir -p ${DESTDIR}/usr/local  	mkdir -p ${DESTDIR}/usr/share/applications +	 +  	mkdir -p ${DESTDIR}${LIBDIR}/hardinfo/modules  	mkdir -p ${DESTDIR}/usr/share/hardinfo/pixmaps @@ -70,10 +87,10 @@ install:	all  	cp hardinfo ${DESTDIR}/usr/bin/hardinfo  	@echo '[01;34m*** Installing modules...[00m' -	cp -Lr modules/*.so ${DESTDIR}${LIBDIR}/hardinfo/modules +	cp -Lvr modules/*.so ${DESTDIR}${LIBDIR}/hardinfo/modules  	@echo '[01;34m*** Installing pixmaps...[00m' -	cp -Lr pixmaps/* ${DESTDIR}/usr/share/hardinfo/pixmaps +	cp -Lvr pixmaps/* ${DESTDIR}/usr/share/hardinfo/pixmaps  	@echo '[01;34m*** Installing misc data...[00m'  	cp benchmark.conf ${DESTDIR}/usr/share/hardinfo @@ -85,4 +102,5 @@ install:	all  	@echo '[01;34m*** Done installing.[00m'  installer: -	makeinstaller +	makepackage +	 @@ -0,0 +1,47 @@ + +- Report Generation + +    * Ability to create more detailed reports +    * Public web page to host user's reports + +- Benchmark + +    * New benchmarks +          o Video +          o FPU+CPU +          o Disk +	  o Phoronix? +    * Change current benchmarks +          o Remove CPU Fibonacci +          * Add CPU Rubik Cube solver? :P + +- More information + +    * PCMCIA/Cardbus information +    * S.M.A.R.T. +    * Show USB devices as a tree instead of a list +    * x86info integration? + +- i18n, build system + +    * GNU gettext +    * Better build system (no more symlink mess) + +- Misc + +    * Remove (R), (TM), etc from processor strings as per +      Wikipedia's Manual of Style [1] +    * Round benchmark results to two decimal places at most, +      or get rid of decimal places altogether. +    * Add preferences window +	* Proxy configuration +		* Use HTTP_PROXY variable; +		* Use GNOME settings; +		* Manual configuration. +	* Default browser +		* Auto-detect; +		* Use GNOME settings; +		* Manual configuration. + +[1] http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_(trademarks)#General_rules + diff --git a/arch/common/blowfish.h b/arch/common/blowfish.h index ceec7a96..5fea2e22 100644 --- a/arch/common/blowfish.h +++ b/arch/common/blowfish.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -18,48 +18,46 @@  #include <blowfish.h> -static void -benchmark_fish(void) +static gpointer +parallel_blowfish(unsigned int start, unsigned int end, void *data, GTimer *timer)  {      BLOWFISH_CTX ctx; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; +    unsigned int i;      unsigned long L, R; -    int i; - -    tmpsrc = src;      L = 0xBEBACAFE;      R = 0xDEADBEEF; +    for (i = start; i <= end; i++) {  +        Blowfish_Init(&ctx, (unsigned char*)data, 65536); +        Blowfish_Encrypt(&ctx, &L, &R); +        Blowfish_Decrypt(&ctx, &L, &R); +    } + +    return NULL; +} + +static void +benchmark_fish(void) +{ +    gdouble elapsed = 0; +    gchar *tmpsrc; +      gchar *bdata_path; -     +      bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) {          g_free(bdata_path);          return; -    }      -     +    } +      shell_view_set_enabled(FALSE);      shell_status_update("Performing Blowfish benchmark..."); -     -    for (i = 0; i <= 50000; i++) {  -        g_timer_start(timer); -        Blowfish_Init(&ctx, (unsigned char*)tmpsrc, srclen); -        Blowfish_Encrypt(&ctx, &L, &R); -        Blowfish_Decrypt(&ctx, &L, &R); -         -        g_timer_stop(timer); -        elapsed += g_timer_elapsed(timer, NULL); -         -        shell_status_set_percentage(i/500); -    } -     -    g_timer_destroy(timer); +    elapsed = benchmark_parallel_for(0, 50000, parallel_blowfish, tmpsrc); +      g_free(bdata_path); -     +    g_free(tmpsrc); +      bench_results[BENCHMARK_BLOWFISH] = elapsed;  } diff --git a/arch/common/md5.h b/arch/common/cryptohash.h index 95d683bd..9897bb6b 100644 --- a/arch/common/md5.h +++ b/arch/common/cryptohash.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -17,21 +17,48 @@   */  #include <md5.h> +#include <sha1.h> -static void -benchmark_md5(void) +static void inline md5_step(char *data, glong srclen)  {      struct MD5Context ctx;      guchar checksum[16]; -    int i; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; +     +    MD5Init(&ctx); +    MD5Update(&ctx, (guchar *)data, srclen); +    MD5Final(checksum, &ctx); +} -    tmpsrc = src; +static void inline sha1_step(char *data, glong srclen) +{ +    SHA1_CTX ctx; +    guchar checksum[20]; +     +    SHA1Init(&ctx); +    SHA1Update(&ctx, (guchar*)data, srclen); +    SHA1Final(checksum, &ctx); +} -    gchar *bdata_path; +static gpointer cryptohash_for(unsigned int start, unsigned int end, void *data, GTimer *timer) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        if (i % 2 == 0) { +            md5_step(data, 65536); +        } else { +            sha1_step(data, 65536); +        } +    } +     +    return NULL; +} + +static void +benchmark_cryptohash(void) +{ +    gdouble elapsed = 0; +    gchar *tmpsrc, *bdata_path;      bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { @@ -40,24 +67,12 @@ benchmark_md5(void)      }           shell_view_set_enabled(FALSE); -    shell_status_update("Generating MD5 sum for 312MiB of data..."); -     -    for (i = 0; i <= 5000; i++) {  -        g_timer_start(timer); - -        MD5Init(&ctx); -        MD5Update(&ctx, (guchar*)tmpsrc, srclen); -        MD5Final(checksum, &ctx); -         -        g_timer_stop(timer); -        elapsed += g_timer_elapsed(timer, NULL); +    shell_status_update("Running CryptoHash benchmark..."); -        shell_status_set_percentage(i/50); -    } +    elapsed = benchmark_parallel_for(0, 5000, cryptohash_for, tmpsrc); -    g_timer_destroy(timer);      g_free(bdata_path); +    g_free(tmpsrc); -    bench_results[BENCHMARK_MD5] = 312.0 / elapsed; +    bench_results[BENCHMARK_CRYPTOHASH] = 312.0 / elapsed;  } - diff --git a/arch/common/display.h b/arch/common/display.h index d7cf2ae6..075a0a24 100644 --- a/arch/common/display.h +++ b/arch/common/display.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/common/environment.h b/arch/common/environment.h new file mode 100644 index 00000000..c78c4a73 --- /dev/null +++ b/arch/common/environment.h @@ -0,0 +1,42 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +static gchar *_env = NULL; +void scan_env_var(gboolean reload) +{ +    SCAN_START(); +     +    gchar **envlist; +    gint i; +     +    g_free(_env); +     +    _env = g_strdup("[Environment Variables]\n"); +    for (i = 0, envlist = g_listenv(); envlist[i]; i++) { +      _env = h_strdup_cprintf("%s=%s\n", _env, +                              envlist[i], g_getenv(envlist[i])); +    } +    g_strfreev(envlist); +     +    SCAN_END(); +} + +gchar *callback_env_var(void) +{ +    return _env; +} diff --git a/arch/common/fft.h b/arch/common/fft.h new file mode 100644 index 00000000..62daa9fe --- /dev/null +++ b/arch/common/fft.h @@ -0,0 +1,47 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include <fftbench.h> + +static gpointer fft_for(unsigned int start, unsigned int end, void *data, GTimer *timer) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        fft_bench_start(); +    } +     +    return NULL; +} + +static void +benchmark_fft(void) +{ +    gdouble elapsed = 0; +     +    shell_view_set_enabled(FALSE); +    shell_status_update("Running FFT benchmark..."); +         +    fft_bench_init(); +    elapsed = benchmark_parallel_for(0, 4, fft_for, NULL); +    fft_bench_finish(); +     +    bench_results[BENCHMARK_FFT] = elapsed; +} + + diff --git a/arch/common/fib.h b/arch/common/fib.h index 645002fa..6a216afe 100644 --- a/arch/common/fib.h +++ b/arch/common/fib.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/common/languages.h b/arch/common/languages.h index efc100fb..45eb2b6a 100644 --- a/arch/common/languages.h +++ b/arch/common/languages.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -77,7 +77,7 @@ scan_languages(OperatingSystem * os)  					 "Revision=%s\n"  					 "Date=%s\n"  					 "Codeset=%s\n", -					 FIELD(name), FIELD(title), +					 name, FIELD(title),  					 FIELD(source), FIELD(address),  					 FIELD(email), FIELD(language),  					 FIELD(territory), FIELD(revision), diff --git a/arch/common/nqueens.h b/arch/common/nqueens.h new file mode 100644 index 00000000..2a233722 --- /dev/null +++ b/arch/common/nqueens.h @@ -0,0 +1,45 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include <nqueens.h> + +static gpointer nqueens_for(unsigned int start, unsigned int end, void *data, GTimer *timer) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        nqueens(0); +    } +     +    return NULL; +} + +static void +benchmark_nqueens(void) +{ +    gdouble elapsed = 0; +     +    shell_view_set_enabled(FALSE); +    shell_status_update("Running N-Queens benchmark..."); +         +    elapsed = benchmark_parallel_for(0, 10, nqueens_for, NULL); +     +    bench_results[BENCHMARK_NQUEENS] = elapsed; +} + + diff --git a/arch/common/printers.h b/arch/common/printers.h index 43ddda0a..2f221252 100644 --- a/arch/common/printers.h +++ b/arch/common/printers.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -16,70 +16,244 @@   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ -void -__scan_printers(void) +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +typedef struct _CUPSDest	CUPSDest; +typedef struct _CUPSOption	CUPSOption; + +struct _CUPSOption { +    char *name, *value; +}; + +struct _CUPSDest { +    char *name, *instance; +    int is_default; +    int num_options; +    CUPSOption *options;   +}; + +static int (*cups_dests_get) (CUPSDest **dests) = NULL; +static int (*cups_dests_free) (int num_dests, CUPSDest *dests) = NULL; +static gboolean cups_init = FALSE; + +static gboolean +remove_printer_devices(gpointer key, gpointer value, gpointer data)  { -    static GModule *cups = NULL; -    static int (*cupsGetPrinters) (char ***printers) = NULL; -    static char *(*cupsGetDefault) (void) = NULL; -     -    static char *libcups[] = { "libcups", -                               "libcups.so", -                               "libcups.so.1", -                               "libcups.so.2", -                               NULL }; +    return g_str_has_prefix(key, "PRN"); +} -    if (printer_list) -	g_free(printer_list); +static void +__init_cups(void) +{ +    static GModule *cups = NULL; +    const char *libcups[] = { "libcups", "libcups.so", "libcups.so.1", "libcups.so.2", NULL }; -    if (!(cupsGetPrinters && cupsGetDefault)) { +    if (!(cups_dests_get && cups_dests_free)) {          int i;          for (i = 0; libcups[i] != NULL; i++) {              cups = g_module_open(libcups[i], G_MODULE_BIND_LAZY);              if (cups) -                break; +                break;           }          if (!cups) { -	    printer_list = g_strdup("[Printers]\n" -	                            "CUPS libraries cannot be found="); +	    cups_init = FALSE;  	    return;  	} -	if (!g_module_symbol(cups, "cupsGetPrinters", (gpointer) & cupsGetPrinters) -	    || !g_module_symbol(cups, "cupsGetDefault", (gpointer) & cupsGetDefault)) { -	    printer_list = g_strdup("[Printers]\n" -                                    "No suitable CUPS library found="); +	if (!g_module_symbol(cups, "cupsGetDests", (gpointer) & cups_dests_get) +	    || !g_module_symbol(cups, "cupsFreeDests", (gpointer) & cups_dests_free)) {              g_module_close(cups); -	    return; +	    cups_init = FALSE;  	}      } +     +    cups_init = TRUE; +} -    gchar **printers; -    int noprinters, i; -    const char *default_printer; - -    noprinters = cupsGetPrinters(&printers); -    default_printer = cupsGetDefault(); +gchar *__cups_callback_ptype(gchar *strvalue) +{ +  if (strvalue) { +    unsigned value = atoi(strvalue); +    gchar *output = g_strdup("\n"); -    if (!default_printer) { -        default_printer = ""; +    if (value & 0x0004) +      output = h_strdup_cprintf("\342\232\254 Can do black and white printing=\n", output); +    if (value & 0x0008) +      output = h_strdup_cprintf("\342\232\254 Can do color printing=\n", output); +    if (value & 0x0010) +      output = h_strdup_cprintf("\342\232\254 Can do duplexing=\n", output); +    if (value & 0x0020) +      output = h_strdup_cprintf("\342\232\254 Can do staple output=\n", output); +    if (value & 0x0040) +      output = h_strdup_cprintf("\342\232\254 Can do copies=\n", output); +    if (value & 0x0080) +      output = h_strdup_cprintf("\342\232\254 Can collate copies=\n", output); +    if (value & 0x80000) +      output = h_strdup_cprintf("\342\232\254 Printer is rejecting jobs=\n", output); +    if (value & 0x1000000) +      output = h_strdup_cprintf("\342\232\254 Printer was automatically discovered and added=\n", output); + +    return output; +  } else { +    return g_strdup("Unknown"); +  } +} + +gchar *__cups_callback_state(gchar *value) +{ +  if (!value) { +    return g_strdup("Unknown"); +  } + +  if (g_str_equal(value, "3")) { +    return g_strdup("Idle"); +  } else if (g_str_equal(value, "4")) { +    return g_strdup("Printing a Job"); +  } else if (g_str_equal(value, "5")) { +    return g_strdup("Stopped"); +  } else { +    return g_strdup("Unknown"); +  } +} + +gchar *__cups_callback_state_change_time(gchar *value) +{ +  struct tm tm; +  char buf[255]; +   +  if (value) { +    strptime(value, "%s", &tm); +    strftime(buf, sizeof(buf), "%c", &tm); + +    return g_strdup(buf); +  } else { +    return g_strdup("Unknown"); +  } +} + +gchar *__cups_callback_boolean(gchar *value) +{ +  if (value) { +    return g_strdup(g_str_equal(value, "1") ? "Yes" : "No"); +  } else { +    return g_strdup("Unknown"); +  } +} + +const struct { +  char *key, *name; +  gchar *(*callback)(gchar *value); +} cups_fields[] = { +  { "Printer Information", NULL, NULL }, +  { "printer-info", "Destination Name", NULL }, +  { "printer-make-and-model", "Make and Model", NULL }, +   +  { "Capabilities", NULL, NULL }, +  { "printer-type", "#", __cups_callback_ptype }, +   +  { "Printer State", NULL, NULL }, +  { "printer-state", "State", __cups_callback_state }, +  { "printer-state-change-time", "Change Time", __cups_callback_state_change_time }, +  { "printer-state-reasons", "State Reasons" }, +   +  { "Sharing Information", NULL, NULL }, +  { "printer-is-shared", "Shared?", __cups_callback_boolean }, +  { "printer-location", "Physical Location" }, +  { "auth-info-required", "Authentication Required", __cups_callback_boolean }, +   +  { "Jobs", NULL, NULL }, +  { "job-hold-until", "Hold Until", NULL }, +  { "job-priority", "Priority", NULL }, +  { "printer-is-accepting-jobs", "Accepting Jobs", __cups_callback_boolean }, +   +  { "Media", NULL, NULL }, +  { "media", "Media", NULL }, +  { "finishings", "Finishings", NULL }, +  { "copies", "Copies", NULL }, +}; + +void +__scan_printers(void) +{ +    int num_dests, i, j; +    CUPSDest *dests; +    gchar *prn_id, *prn_moreinfo; + +    g_free(printer_list); + +    if (!cups_init) { +        __init_cups(); +         +        printer_list = g_strdup("[Printers]\n" +                                "No suitable CUPS library found="); +        return;      } -     -    if (noprinters > 0) { + +    /* remove old devices from global device table */ +    g_hash_table_foreach_remove(moreinfo, remove_printer_devices, NULL); + +    num_dests = cups_dests_get(&dests); +    if (num_dests > 0) {  	printer_list = g_strdup_printf("[Printers (CUPS)]\n"); -	for (i = 0; i < noprinters; i++) { -	    printer_list = h_strdup_cprintf("\n$PRN%d$%s=%s\n", +	for (i = 0; i < num_dests; i++) { +	    GHashTable *options; +	     +	    options = g_hash_table_new(g_str_hash, g_str_equal); +	     +	    for (j = 0; j < dests[i].num_options; j++) { +	      g_hash_table_insert(options, +	                          g_strdup(dests[i].options[j].name), +	                          g_strdup(dests[i].options[j].value)); +	    } +	 +            prn_id = g_strdup_printf("PRN%d", i); +	 +	    printer_list = h_strdup_cprintf("\n$%s$%s=%s\n",  					    printer_list, -					    i,						 -					    printers[i], -                                            g_str_equal(default_printer, printers[i]) ? -				            "<i>(Default)</i>" : ""); -	    g_free(printers[i]); +					    prn_id,						 +					    dests[i].name, +					    dests[i].is_default ? "<i>Default</i>" : ""); + +            prn_moreinfo = g_strdup(""); +            for (j = 0; j < G_N_ELEMENTS(cups_fields); j++) { +              if (!cups_fields[j].name) { +                prn_moreinfo = h_strdup_cprintf("[%s]\n", +                                                prn_moreinfo, +                                                cups_fields[j].key); +              } else { +                gchar *temp; +                 +                temp = g_hash_table_lookup(options, cups_fields[j].key); +                 +                if (cups_fields[j].callback) { +                  temp = cups_fields[j].callback(temp); +                } else { +                  if (temp) { +                    /* FIXME Do proper escaping */ +                    temp = g_strdup(strreplace(temp, "&=", ' ')); +                  } else { +                    temp = g_strdup("Unknown"); +                  } +                } +                 +                prn_moreinfo = h_strdup_cprintf("%s=%s\n", +                                                prn_moreinfo, +                                                cups_fields[j].name, +                                                temp); +                 +                g_free(temp); +              } +            } +             +            g_hash_table_insert(moreinfo, prn_id, prn_moreinfo); +            g_hash_table_destroy(options);  	} -	g_free(printers); +	cups_dests_free(num_dests, dests);      } else {  	printer_list = g_strdup("[Printers]\n"  	                        "No printers found=\n"); diff --git a/arch/common/raytrace.h b/arch/common/raytrace.h index af9f2afa..7fdc5e21 100644 --- a/arch/common/raytrace.h +++ b/arch/common/raytrace.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -18,28 +18,27 @@  void fbench();	/* fbench.c */ +static gpointer +parallel_raytrace(unsigned int start, unsigned int end, gpointer data) +{ +    unsigned int i; +     +    for (i = start; i <= end; i++) {  +        fbench(); +    } +     +    return NULL; +} +  static void  benchmark_raytrace(void)  { -    int i; -    GTimer *timer = g_timer_new();      gdouble elapsed = 0;      shell_view_set_enabled(FALSE);      shell_status_update("Performing John Walker's FBENCH..."); -    for (i = 0; i <= 1000; i++) {  -        g_timer_start(timer); -         -        fbench(); -         -        g_timer_stop(timer); -        elapsed += g_timer_elapsed(timer, NULL); -         -        shell_status_set_percentage(i/10); -    } -     -    g_timer_destroy(timer); +    elapsed = benchmark_parallel_for(0, 1000, parallel_raytrace, NULL);      bench_results[BENCHMARK_RAYTRACE] = elapsed;  } diff --git a/arch/common/sha1.h b/arch/common/sha1.h deleted file mode 100644 index 3b7f7652..00000000 --- a/arch/common/sha1.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> - * - *    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, version 2. - * - *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA - */ -#include <sha1.h> - -static void -benchmark_sha1(void) -{ -    SHA1_CTX ctx; -    guchar checksum[20]; -    int i; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; -     -    tmpsrc = src; - -    gchar *bdata_path; -     -    bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL); -    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { -        g_free(bdata_path); -        return; -    }      -     -    shell_view_set_enabled(FALSE); -    shell_status_update("Generating SHA1 sum for 312MiB of data..."); -     -    for (i = 0; i <= 5000; i++) {  -        g_timer_start(timer); - -        SHA1Init(&ctx); -        SHA1Update(&ctx, (guchar*)tmpsrc, srclen); -        SHA1Final(checksum, &ctx); -         -        g_timer_stop(timer); -        elapsed += g_timer_elapsed(timer, NULL); -         -        shell_status_set_percentage(i/50); -    } -     -    g_timer_destroy(timer); -    g_free(bdata_path); -     -    bench_results[BENCHMARK_SHA1] = 312.0 / elapsed; -} - diff --git a/arch/common/users.h b/arch/common/users.h index fd8f7834..2361a4bf 100644 --- a/arch/common/users.h +++ b/arch/common/users.h @@ -1,5 +1,4 @@ -static gchar *sys_users = NULL, -             *human_users = NULL; +static gchar *users = NULL;  static gboolean  remove_users(gpointer key, gpointer value, gpointer data) @@ -17,15 +16,13 @@ scan_users_do(void)      if (!passwd)        return; -    if (sys_users) { -      g_free(sys_users); -      g_free(human_users); +    if (users) { +      g_free(users);        g_hash_table_foreach_remove(moreinfo, remove_users, NULL);      } -    sys_users = g_strdup(""); -    human_users = g_strdup(""); +    users = g_strdup("");      while (fgets(buffer, 512, passwd)) {        gchar **tmp; @@ -44,11 +41,7 @@ scan_users_do(void)        uid = atoi(tmp[2]);        strend(tmp[4], ','); -      if (uid >= 1000 && uid <= 65530) { -        human_users = h_strdup_cprintf("$%s$%s=%s\n", human_users, key, tmp[0], tmp[4]); -      } else { -        sys_users = h_strdup_cprintf("$%s$%s=%s\n", sys_users, key, tmp[0], tmp[4]); -      }       +      users = h_strdup_cprintf("$%s$%s=%s\n", users, key, tmp[0], tmp[4]);        g_strfreev(tmp);      } diff --git a/arch/common/zlib.h b/arch/common/zlib.h deleted file mode 100644 index 96d20944..00000000 --- a/arch/common/zlib.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> - * - *    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, version 2. - * - *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA - */ - -static void -benchmark_zlib(void) -{ -    GModule *libz; -    static gulong (*compressBound) (glong srclen) = NULL; -    static gint (*compress) (gchar *dst, glong *dstlen, -                             const gchar *src, glong srclen) = NULL; - -    if (!(compress && compressBound)) { -	libz = g_module_open("libz", G_MODULE_BIND_LAZY); -	if (!libz) { -            libz = g_module_open("/usr/lib/libz.so", G_MODULE_BIND_LAZY); -            if (!libz) { -                g_warning("Cannot load ZLib: %s", g_module_error()); -                return; -            } -	} - -	if (!g_module_symbol(libz, "compress", (gpointer) & compress) -	    || !g_module_symbol(libz, "compressBound", (gpointer) & compressBound)) { -	     -            g_module_close(libz); -	    return; -	} -    } - -    shell_view_set_enabled(FALSE); - -    int i; -    GTimer *timer = g_timer_new(); -    gdouble elapsed = 0; -    gchar src[65536], *tmpsrc; -    glong srclen = 65536; -    gchar *bdata_path; -     -    bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL); -    if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { -        g_free(bdata_path); -        return; -    }      -     -    shell_status_update("Compressing 64MB with default options..."); -     -    for (i = 0; i <= 1000; i++) {  -        g_timer_start(timer); -         -        gchar *dst; -        glong dstlen = compressBound(srclen); -         -        dst = g_new0(gchar, dstlen); -        compress(dst, &dstlen, src, srclen); - -        g_timer_stop(timer); -        elapsed += g_timer_elapsed(timer, NULL); -        g_free(dst); -         -        shell_status_set_percentage(i/10); -    } -     -    g_timer_destroy(timer); -    g_free(bdata_path); -     -    bench_results[BENCHMARK_ZLIB] = 65536.0 / elapsed; -} diff --git a/arch/linux/alpha/processor.h b/arch/linux/alpha/processor.h index 081a4f7d..1e5b014c 100644 --- a/arch/linux/alpha/processor.h +++ b/arch/linux/alpha/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -18,7 +18,7 @@  struct _Processor {      gchar *model_name; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;      gchar *strmodel;  }; @@ -52,6 +52,7 @@ __scan_processors(void)      gchar *tmp = g_strconcat("Alpha ", processor->model_name, NULL);      g_free(processor->model_name);      processor->model_name = tmp; +    processor->cpu_mhz = 0.0f;      fclose(cpuinfo); diff --git a/arch/linux/alpha/resources.h b/arch/linux/alpha/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/alpha/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/armv4l/processor.h b/arch/linux/armv4l/processor.h index d66d6f25..82b6be04 100644 --- a/arch/linux/armv4l/processor.h +++ b/arch/linux/armv4l/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -19,7 +19,7 @@  struct _Processor {      gchar *model_name;      gchar *flags; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;      gchar *has_fpu;  }; @@ -53,6 +53,8 @@ __scan_processors(void)  	g_strfreev(tmp);      } +    processor->cpu_mhz = 0.0f; +      fclose(cpuinfo);      return g_slist_append(NULL, processor); diff --git a/arch/linux/armv4l/resources.h b/arch/linux/armv4l/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/armv4l/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/common/alsa.h b/arch/linux/common/alsa.h index 8f4cc2ac..5609471c 100644 --- a/arch/linux/common/alsa.h +++ b/arch/linux/common/alsa.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/common/battery.h b/arch/linux/common/battery.h index 4a38b842..7dfa5423 100644 --- a/arch/linux/common/battery.h +++ b/arch/linux/common/battery.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -18,6 +18,82 @@  #include <time.h> +const struct { +  gchar *key, *name; +} ups_fields[] = { +  { "UPS Status", NULL }, +  { "STATUS", "Status" }, +  { "TIMELEFT", "Time Left" }, +  { "LINEV", "Line Voltage" }, +  { "LOADPCT", "Load Percent" }, + +  { "UPS Battery Information", NULL }, +  { "BATTV", "Battery Voltage" }, +  { "BCHARGE", "Battery Charge" }, +  { "BATTDATE", "Battery Date" }, + +  { "UPS Information", NULL }, +  { "APCMODEL", "Model" }, +  { "FIRMWARE", "Firmware Version" }, +  { "SERIALNO", "Serial Number" }, +  { "UPSMODE", "UPS Mode" }, +  { "CABLE", "Cable" }, +  { "UPSNAME", "UPS Name" }, + +  { "UPS Nominal Values", NULL }, +  { "NOMINV", "Voltage" }, +  { "NOMBATTV", "Battery Voltage" }, +  { "NOMPOWER", "Power" } +}; + + +static void +__scan_battery_apcupsd(void) +{ +    GHashTable  *ups_data; +    FILE	*apcaccess; +    char	buffer[512], *apcaccess_path; +    int		i; + +    apcaccess_path = find_program("apcaccess"); + +    if ((apcaccess = popen(apcaccess_path, "r"))) { +      /* first line isn't important */ +      if (fgets(buffer, 512, apcaccess)) { +        /* allocate the key, value hash table */ +        ups_data = g_hash_table_new(g_str_hash, g_str_equal); + +        /* read up all the apcaccess' output, saving it in the key, value hash table */ +        while (fgets(buffer, 512, apcaccess)) { +          buffer[9] = '\0'; + +          g_hash_table_insert(ups_data, +                              g_strdup(g_strstrip(buffer)), +                              g_strdup(g_strstrip(buffer + 10))); +        } + +        /* builds the ups info string, respecting the field order as found in ups_fields */ +        for (i = 0; i < G_N_ELEMENTS(ups_fields); i++) { +          if (!ups_fields[i].name) { +            /* there's no name: make a group with the key as its name */ +            battery_list = h_strdup_cprintf("[%s]\n", battery_list, ups_fields[i].key); +          } else { +            /* there's a name: adds a line */ +            battery_list = h_strdup_cprintf("%s=%s\n", battery_list, +                                            ups_fields[i].name, +                                            g_hash_table_lookup(ups_data, ups_fields[i].key)); +          } +        } + +        g_hash_table_destroy(ups_data); +      } + +      pclose(apcaccess); +    } +     +    g_free(apcaccess_path); +} +  static void  __scan_battery_acpi(void)  { @@ -31,11 +107,6 @@ __scan_battery_acpi(void)      gchar *state = NULL, *rate = NULL;      gchar *remaining = NULL; -    if (battery_list) { -      g_free(battery_list); -    } -    battery_list = g_strdup(""); -          acpi_path = g_strdup("/proc/acpi/battery");      if (g_file_test(acpi_path, G_FILE_TEST_EXISTS)) {        GDir *acpi; @@ -209,6 +280,7 @@ __scan_battery(void)      __scan_battery_acpi();      __scan_battery_apm(); +    __scan_battery_apcupsd();      if (*battery_list == '\0') {          g_free(battery_list); diff --git a/arch/linux/common/boots.h b/arch/linux/common/boots.h index d3428ea9..8a3c11fa 100644 --- a/arch/linux/common/boots.h +++ b/arch/linux/common/boots.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -47,11 +47,10 @@ scan_boots_real(void)              }            } -          tmp = g_strsplit(buffer, " ", 5); -          computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s", +          tmp = g_strsplit(buffer, " ", 0); +          computer->os->boots = h_strdup_cprintf("\n%s %s %s %s=%s|%s",                                                  computer->os->boots, -                                                tmp[4], -                                                tmp[3]); +						tmp[4], tmp[5], tmp[6], tmp[7], tmp[3], tmp[8]);            g_strfreev(tmp);          }        } diff --git a/arch/linux/common/devmemory.h b/arch/linux/common/devmemory.h index 5eafe599..e3921cdd 100644 --- a/arch/linux/common/devmemory.h +++ b/arch/linux/common/devmemory.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/common/dmi.h b/arch/linux/common/dmi.h new file mode 100644 index 00000000..f69fdc21 --- /dev/null +++ b/arch/linux/common/dmi.h @@ -0,0 +1,160 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ +/* + * DMI support based on patch by Stewart Adam <s.adam@diffingo.com> + */ +#include <unistd.h> +#include <sys/types.h> +               +typedef struct _DMIInfo		DMIInfo; + +struct _DMIInfo { +  const gchar *name; +  const gchar *file;		/* for sysfs */ +  const gchar *param;		/* for dmidecode */ +}; + +DMIInfo dmi_info_table[] = { +  { "$BIOS",	NULL,					NULL }, +  { "Date",	"/sys/class/dmi/id/bios_date",		"bios-release-date" }, +  { "Vendor",	"/sys/class/dmi/id/bios_vendor",	"bios-vendor" }, +  { "Version",	"/sys/class/dmi/id/bios_version",	"bios-version" }, +  { "$Board",	NULL,					NULL }, +  { "Name",	"/sys/class/dmi/id/board_name",		"baseboard-product-name" }, +  { "Vendor",	"/sys/class/dmi/id/board_vendor",	"baseboard-manufacturer" }, +}; + +static gchar *dmi_info = NULL; + +gboolean dmi_get_info_dmidecode() +{ +  FILE *dmi_pipe; +  gchar buffer[256]; +  DMIInfo *info; +  gboolean dmi_failed = FALSE; +  gint i; + +  if (dmi_info) { +    g_free(dmi_info); +    dmi_info = NULL; +  } +   +  for (i = 0; i < G_N_ELEMENTS(dmi_info_table); i++) { +    info = &dmi_info_table[i]; +     +    if (*(info->name) == '$') { +      dmi_info = h_strdup_cprintf("[%s]\n", dmi_info, +                                  (info->name) + 1); +    } else { +      gchar *temp; +       +      if (!info->param) +        continue; + +      temp = g_strconcat("dmidecode -s ", info->param, NULL); +      if ((dmi_pipe = popen(temp, "r"))) { +        g_free(temp); + +        fgets(buffer, 256, dmi_pipe); +        if (pclose(dmi_pipe)) { +          dmi_failed = TRUE; +          break; +        } +         +        dmi_info = h_strdup_cprintf("%s=%s\n", +                                    dmi_info, +                                    info->name, +                                    buffer); +      } else { +        g_free(temp); +        dmi_failed = TRUE; +        break; +      } +    }                                 +  } +   +  if (dmi_failed) { +    g_free(dmi_info); +    dmi_info = NULL; +  } +   +  return !dmi_failed; +} + +gboolean dmi_get_info_sys() +{ +  FILE *dmi_file; +  gchar buffer[256]; +  DMIInfo *info; +  gboolean dmi_failed = FALSE; +  gint i; +   +  if (dmi_info) { +    g_free(dmi_info); +    dmi_info = NULL; +  } +   +  for (i = 0; i < G_N_ELEMENTS(dmi_info_table); i++) { +    info = &dmi_info_table[i]; +     +    if (*(info->name) == '$') { +      dmi_info = h_strdup_cprintf("[%s]\n", dmi_info, +                                  (info->name) + 1); +    } else { +      if (!info->file) +        continue; +         +      if ((dmi_file = fopen(info->file, "r"))) { +        fgets(buffer, 256, dmi_file); +        fclose(dmi_file); +         +        dmi_info = h_strdup_cprintf("%s=%s\n", +                                    dmi_info, +                                    info->name, +                                    buffer); +      } else { +        dmi_failed = TRUE; +        break; +      } +    }                                 +  } +   +  if (dmi_failed) { +    g_free(dmi_info); +    dmi_info = NULL; +  } +   +  return !dmi_failed; +} + +void __scan_dmi() +{ +  gboolean dmi_ok; +   +  dmi_ok = dmi_get_info_sys(); +   +  if (!dmi_ok) { +    dmi_ok = dmi_get_info_dmidecode(); +  } +   +  if (!dmi_ok) { +    dmi_info = g_strdup("[No DMI information]\n" +                        "There was an error retrieving the information.=\n" +                        "Please try running HardInfo as root.=\n"); +  } +} diff --git a/arch/linux/common/filesystem.h b/arch/linux/common/filesystem.h index d8166fc3..1eff0818 100644 --- a/arch/linux/common/filesystem.h +++ b/arch/linux/common/filesystem.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -51,10 +51,22 @@ scan_filesystems(void)  	tmp = g_strsplit(buf, " ", 0);  	if (!statfs(tmp[1], &sfs)) { +		gfloat use_ratio; +  		size = (float) sfs.f_bsize * (float) sfs.f_blocks;  		avail = (float) sfs.f_bsize * (float) sfs.f_bavail;  		used = size - avail; +		if (size == 0.0f) { +			continue; +		} + +		if (avail == 0.0f) { +			use_ratio = 100.0f; +		} else { +			use_ratio = 100.0f * (used / size); +		} +  		gchar *strsize = size_human_readable(size),  		      *stravail = size_human_readable(avail),  	  	      *strused = size_human_readable(used); @@ -81,9 +93,9 @@ scan_filesystems(void)  					  stravail);  		g_hash_table_insert(moreinfo, g_strdup_printf("FS%d", ++count), strhash); -		fs_list = h_strdup_cprintf("$FS%d$%s=%s total, %s free\n", +		fs_list = h_strdup_cprintf("$FS%d$%s=%.2f %% (%s of %s)|%s\n",  					  fs_list, -					  count, tmp[0], strsize, stravail); +					  count, tmp[0], use_ratio, stravail, strsize, tmp[1]);  		g_free(strsize);  		g_free(stravail); diff --git a/arch/linux/common/inputdevices.h b/arch/linux/common/inputdevices.h index 8d2d8427..20e4289c 100644 --- a/arch/linux/common/inputdevices.h +++ b/arch/linux/common/inputdevices.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -115,9 +115,19 @@ __scan_input_devices(void)  	    }  	    strhash = h_strdup_cprintf("Product=0x%x\n" -				      "Version=0x%x\n" -				      "Connected to=%s\n", -				      strhash, product, version, phys); +				      "Version=0x%x\n", +				      strhash, product, version); +	     +            if (phys[1] != 0) { +                 strhash = h_strdup_cprintf("Connected to=%s\n", +                                            strhash, phys); +            } + +	    if (strstr(phys,"ir")) { +		 strhash = h_strdup_cprintf("InfraRed port=yes\n", +				 	     strhash); +	    } +	      	    g_hash_table_insert(moreinfo, tmp, strhash);  	    g_free(phys); diff --git a/arch/linux/common/loadavg.h b/arch/linux/common/loadavg.h index 28132b5f..7c028679 100644 --- a/arch/linux/common/loadavg.h +++ b/arch/linux/common/loadavg.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/common/memory.h b/arch/linux/common/memory.h index def4cc1d..c87359b9 100644 --- a/arch/linux/common/memory.h +++ b/arch/linux/common/memory.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/common/modules.h b/arch/linux/common/modules.h index 6fbe13bd..7ea238b7 100644 --- a/arch/linux/common/modules.h +++ b/arch/linux/common/modules.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -29,11 +29,18 @@ remove_module_devices(gpointer key, gpointer value, gpointer data)      return g_str_has_prefix(key, "MOD");  } +static GHashTable *_module_hash_table = NULL; +  static void  scan_modules_do(void)  {      FILE *lsmod;      gchar buffer[1024]; +    gchar *lsmod_path; + +    if (!_module_hash_table) { +        _module_hash_table = g_hash_table_new(g_str_hash, g_str_equal); +    }      if (module_list) {          g_free(module_list); @@ -42,9 +49,12 @@ scan_modules_do(void)      module_list = NULL;      g_hash_table_foreach_remove(moreinfo, remove_module_devices, NULL); -    lsmod = popen("/sbin/lsmod", "r"); -    if (!lsmod) +    lsmod_path = find_program("lsmod"); +    lsmod = popen(lsmod_path, "r"); +    if (!lsmod) { +        g_free(lsmod_path);   	return; +    }      fgets(buffer, 1024, lsmod);	/* Discards the first line */ @@ -95,7 +105,15 @@ scan_modules_do(void)  	if (description && g_str_equal(description, "<none>")) {  	    g_free(description);  	    description = g_strdup(""); -	} + +            g_hash_table_insert(_module_hash_table, +                                g_strdup(modname), +                                g_strdup_printf("Kernel module (%s)", modname)); +	} else { +            g_hash_table_insert(_module_hash_table, +                                g_strdup(modname), +                                g_strdup(description)); +        }  	/* append this module to the list of modules */  	module_list = h_strdup_cprintf("$%s$%s=%s\n", @@ -119,7 +137,7 @@ scan_modules_do(void)  				    "License=%s\n",  				    NONE_IF_NULL(filename),  				    memory / 1024.0, -				    NONE_IF_NULL(modname), +				    modname,  				    NONE_IF_NULL(description),  				    NONE_IF_NULL(vermagic),  				    NONE_IF_NULL(author), @@ -146,4 +164,6 @@ scan_modules_do(void)  	g_free(filename);      }      pclose(lsmod); +     +    g_free(lsmod_path);  } diff --git a/arch/linux/common/net.h b/arch/linux/common/net.h index 527da1df..755c6936 100644 --- a/arch/linux/common/net.h +++ b/arch/linux/common/net.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -15,36 +15,146 @@   *    along with this program; if not, write to the Free Software   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ - -static gchar *network_interfaces = NULL, -             *network_icons = NULL; - -#include <sys/ioctl.h> -#include <net/if.h> -#include <netinet/in.h> -#include <linux/sockios.h> -#include <sys/socket.h> +/* + * Wireless Extension Example + * http://www.krugle.org/examples/p-OZYzuisV6gyQIaTu/iwconfig.c + */ +static gchar *network_interfaces = NULL, *network_icons = NULL;  #include <stdio.h>  #include <unistd.h> -#include <string.h> /* for strncpy */ +#include <string.h> + +#include <sys/ioctl.h>  #include <sys/types.h>  #include <sys/socket.h> +  #include <netinet/in.h> +#include <linux/sockios.h> +  #include <arpa/inet.h> +#ifdef HAS_LINUX_WE +#include <linux/if.h> +#include <linux/wireless.h> +#else +#include <net/if.h> +#endif	/* HAS_LINUX_WE */  typedef struct _NetInfo NetInfo;  struct _NetInfo { -    char name[16];  -    int  mtu; +    char name[16]; +    int mtu;      unsigned char mac[8];      char ip[16];      char mask[16];      char broadcast[16]; + +#ifdef HAS_LINUX_WE +    char wi_essid[IW_ESSID_MAX_SIZE + 1];    +    int  wi_rate; +    int  wi_mode, wi_status; +    gboolean wi_has_txpower; +    struct iw_param wi_txpower; +    int	 wi_quality_level, wi_signal_level, wi_noise_level; +    gboolean is_wireless; +#endif  }; -void get_net_info(char *if_name, NetInfo *netinfo) +#ifdef HAS_LINUX_WE +const gchar *wi_operation_modes[] = { "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Unknown" }; + +void get_wireless_info(int fd, NetInfo *netinfo) +{ +  FILE *wrls; +  char wbuf[256]; +  struct iwreq wi_req; +  int r, trash; + +  netinfo->is_wireless = FALSE; +   +  if ((wrls = fopen("/proc/net/wireless", "r"))) { +      while (fgets(wbuf, 256, wrls)) { +          if (strchr(wbuf, ':') && strstr(wbuf, netinfo->name)) { +              gchar *buf1 = wbuf; +               +              netinfo->is_wireless = TRUE; +               +              buf1 = strchr(buf1, ':') + 1; +               +              if (strstr(buf1, ".")) { +                  sscanf(buf1, "%d %d. %d %d %d %d %d %d %d %d", +                         &(netinfo->wi_status), +                         &(netinfo->wi_quality_level), +                         &(netinfo->wi_signal_level), +                         &(netinfo->wi_noise_level), +                         &trash, &trash, &trash, &trash, &trash, &trash); +              } else { +                  sscanf(buf1, "%d %d %d %d %d %d %d %d %d %d", +                         &(netinfo->wi_status), +                         &(netinfo->wi_quality_level), +                         &(netinfo->wi_signal_level), +                         &(netinfo->wi_noise_level), +                         &trash, &trash, &trash, &trash, &trash, +                         &trash); +              } +               +              break; +          } +      } +      fclose(wrls); +  } + +  if (!netinfo->is_wireless) +    return; +   +  strncpy(wi_req.ifr_name, netinfo->name, 16); +   +  /* obtain essid */ +  wi_req.u.essid.pointer = netinfo->wi_essid; +  wi_req.u.essid.length  = IW_ESSID_MAX_SIZE + 1; +  wi_req.u.essid.flags   = 0; +   +  if ((r = ioctl(fd, SIOCGIWESSID, &wi_req) < 0)) { +    strcpy(netinfo->wi_essid, ""); +  } else { +    netinfo->wi_essid[wi_req.u.essid.length] = '\0'; +  } + +  /* obtain bit rate */ +  if ((r = ioctl(fd, SIOCGIWRATE, &wi_req) < 0)) { +    netinfo->wi_rate = 0; +  } else { +    netinfo->wi_rate = wi_req.u.bitrate.value; +  } +   +  /* obtain operation mode */ +  if ((r = ioctl(fd, SIOCGIWMODE, &wi_req) < 0)) { +    netinfo->wi_mode = 0; +  } else { +    if (wi_req.u.mode >= 0 && wi_req.u.mode < 6) { +      netinfo->wi_mode = wi_req.u.mode; +    } else { +      netinfo->wi_mode = 6; +    } +  } +   +#if WIRELESS_EXT >= 10 +  /* obtain txpower */ +  if ((r = ioctl(fd, SIOCGIWTXPOW, &wi_req) < 0)) { +    netinfo->wi_has_txpower = FALSE; +  } else { +    netinfo->wi_has_txpower = TRUE; +           +    memcpy(&netinfo->wi_txpower, &wi_req.u.txpower, sizeof(struct iw_param)); +  } +#else +  netinfo->wi_has_txpower = FALSE; +#endif	/* WIRELESS_EXT >= 10 */ +} +#endif /* HAS_LINUX_WE */ + +void get_net_info(char *if_name, NetInfo * netinfo)  {      struct ifreq ifr;      int fd; @@ -58,44 +168,55 @@ void get_net_info(char *if_name, NetInfo *netinfo)      /* MTU */      strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) { -        netinfo->mtu = 0; +	netinfo->mtu = 0;      } else { -        netinfo->mtu = ifr.ifr_mtu; +	netinfo->mtu = ifr.ifr_mtu;      }      /* HW Address */      strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { -        memset(netinfo->mac, 0, 8); +	memset(netinfo->mac, 0, 8);      } else { -        memcpy(netinfo->mac, ifr.ifr_ifru.ifru_hwaddr.sa_data, 8); +	memcpy(netinfo->mac, ifr.ifr_ifru.ifru_hwaddr.sa_data, 8);      } -     +      /* IP Address */      strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { -        netinfo->ip[0] = 0; +	netinfo->ip[0] = 0;      } else { -        sprintf(netinfo->ip, "%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));  +	sprintf(netinfo->ip, "%s", +		inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)-> +			  sin_addr));      } -     +      /* Mask Address */      strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0) { -        netinfo->mask[0] = 0; +	netinfo->mask[0] = 0;      } else { -        sprintf(netinfo->mask, "%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); +	sprintf(netinfo->mask, "%s", +		inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)-> +			  sin_addr));      }      /* Broadcast Address */      strcpy(ifr.ifr_name, if_name);      if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0) { -        netinfo->broadcast[0] = 0; +	netinfo->broadcast[0] = 0;      } else { -        sprintf(netinfo->broadcast, "%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); +	sprintf(netinfo->broadcast, "%s", +		inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)-> +			  sin_addr));      } +#ifdef HAS_LINUX_WE +    get_wireless_info(fd, netinfo); +#endif +      shutdown(fd, 0); +    close(fd);  }  static struct { @@ -103,33 +224,46 @@ static struct {      char *label;      char *icon;  } netdev2type[] = { -    { "eth",	"Ethernet",				  "network" }, -    { "lo",	"Loopback",				  "network-generic" }, -    { "ppp",	"Point-to-Point",			  "modem" }, -    { "ath",	"Wireless",				  "wireless" }, -    { "wlan",	"Wireless",				  "wireless" }, -    { "tun",    "Virtual Point-to-Point (TUN)",		  "network-generic" }, -    { "tap",    "Ethernet (TAP)",			  "network-generic" }, -    { "plip",   "Parallel Line Internet Protocol",	  "network" }, -    { "irlan",  "Infrared",				  "network-generic" }, -    { "slip",   "Serial Line Internet Protocol",	  "network-generic" }, -    { "isdn",	"Integrated Services Digital Network",	  "modem" }, -    { "sit",	"IPv6-over-IPv4 Tunnel",		  "network-generic" }, +    { "eth", "Ethernet", "network-interface" }, +    { "lo", "Loopback", "network" }, +    { "ppp", "Point-to-Point", "modem" }, +    { "ath", "Wireless", "wireless" }, +    { "wlan", "Wireless", "wireless" }, +    { "ra", "Wireless", "wireless" }, +    { "wl", "Wireless", "wireless" }, +    { "tun", "Virtual Point-to-Point (TUN)", "network" }, +    { "tap", "Ethernet (TAP)", "network" }, +    { "plip", "Parallel Line Internet Protocol", "network" }, +    { "irlan", "Infrared", "network" }, +    { "slip", "Serial Line Internet Protocol", "network" }, +    { "isdn", "Integrated Services Digital Network", "modem" }, +    { "sit", "IPv6-over-IPv4 Tunnel", "network" },      { "vmnet8", "VMWare Virtual Network Interface (NAT)", "computer" }, -    { "vmnet",  "VMWare Virtual Network Interface",	  "computer"}, -    { NULL,	"Unknown",				  "network-generic" }, +    { "vmnet", "VMWare Virtual Network Interface", "computer" }, +    { "pan", "Personal Area Network (PAN)", "bluetooth" }, +    { "bnep", "Bluetooth", "bluetooth" }, +    { "br", "Bridge Interface", "network" }, +    { NULL, "Unknown", "network" },  }; -static void -net_get_iface_type(gchar *name, gchar **type, gchar **icon) +static void net_get_iface_type(gchar * name, gchar ** type, gchar ** icon, NetInfo *ni)  {      int i; -     + +#ifdef HAS_LINUX_WE +    if (ni->is_wireless) { +        *type = "Wireless"; +        *icon = "wireless"; +         +        return; +    } +#endif +      for (i = 0; netdev2type[i].type; i++) { -        if (g_str_has_prefix(name, netdev2type[i].type)) -            break; +	if (g_str_has_prefix(name, netdev2type[i].type)) +	    break;      } -     +      *type = netdev2type[i].label;      *icon = netdev2type[i].icon;  } @@ -140,49 +274,51 @@ remove_net_devices(gpointer key, gpointer value, gpointer data)      return g_str_has_prefix(key, "NET");  } -static void -scan_net_interfaces_24(void) +static void scan_net_interfaces_24(void)  {      FILE *proc_net;      NetInfo ni;      gchar buffer[256];      gchar *devid, *detailed; -    gulong recv_bytes; -    gulong recv_errors; -    gulong recv_packets; -     -    gulong trans_bytes; -    gulong trans_errors; -    gulong trans_packets; -     +    gdouble recv_bytes; +    gdouble recv_errors; +    gdouble recv_packets; + +    gdouble trans_bytes; +    gdouble trans_errors; +    gdouble trans_packets; +      if (!g_file_test("/proc/net/dev", G_FILE_TEST_EXISTS)) { -        if (network_interfaces) { -            g_free(network_interfaces); -            network_interfaces = g_strdup("[Network Interfaces]\n" -                                          "None found=\n"); -        } +	if (network_interfaces) { +	    g_free(network_interfaces); +	    network_interfaces = g_strdup("[Network Interfaces]\n" +					  "None found=\n"); +	}  	return;      }      if (network_interfaces) { -        g_free(network_interfaces); +	g_free(network_interfaces);      } -     +      if (network_icons) { -        g_free(network_icons); +	g_free(network_icons);      } -     +      network_interfaces = g_strdup("[Network Interfaces]\n");      network_icons = g_strdup("");      proc_net = fopen("/proc/net/dev", "r"); +    if (!proc_net) +        return; +      while (fgets(buffer, 256, proc_net)) {  	if (strchr(buffer, ':')) {  	    gint trash;  	    gchar ifacename[16];  	    gchar *buf = buffer; -	    gchar *iface_type, *iface_icon, *ip; +	    gchar *iface_type, *iface_icon;  	    gint i;  	    buf = g_strstrip(buf); @@ -196,71 +332,107 @@ scan_net_interfaces_24(void)  	    buf = strchr(buf, ':') + 1;  	    /* iface: bytes packets errs drop fifo frame compressed multicast */ -	    sscanf(buf, "%ld %ld %ld %d %d %d %d %d %ld %ld %ld", +	    sscanf(buf, "%lf %lf %lf %d %d %d %d %d %lf %lf %lf",  		   &recv_bytes, &recv_packets,  		   &recv_errors, &trash, &trash, &trash, &trash, -		   &trash, &trans_bytes, &trans_packets, -		   &trans_errors); +		   &trash, &trans_bytes, &trans_packets, &trans_errors); -            gfloat recv_mb = recv_bytes / 1048576.0; -            gfloat trans_mb = trans_bytes / 1048576.0; -             -            get_net_info(ifacename, &ni); +	    gdouble recv_mb = recv_bytes / 1048576.0; +	    gdouble trans_mb = trans_bytes / 1048576.0; + +	    get_net_info(ifacename, &ni); + +	    devid = g_strdup_printf("NET%s", ifacename); + +	    network_interfaces = +		h_strdup_cprintf +		("$%s$%s=%s|%.2lfMiB|%.2lfMiB\n", +		 network_interfaces, devid, ifacename, ni.ip[0] ? ni.ip : "", +		 trans_mb, recv_mb); +	    net_get_iface_type(ifacename, &iface_type, &iface_icon, &ni); -            devid = g_strdup_printf("NET%s", ifacename); -             -            ip = g_strdup_printf(" (%s)", ni.ip); -	    network_interfaces = h_strdup_cprintf("$%s$%s=Sent %.2fMiB, received %.2fMiB%s\n", -                                                  network_interfaces, -                                                  devid, -                                                  ifacename, -                                                  trans_mb, -                                                  recv_mb, -						  ni.ip[0] ? ip: ""); -            g_free(ip); -             -            net_get_iface_type(ifacename, &iface_type, &iface_icon);  	    network_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", -	                                    network_icons, devid, -	                                    ifacename, iface_icon); +					     network_icons, devid, +					     ifacename, iface_icon); + +	    detailed = g_strdup_printf("[Network Adapter Properties]\n" +				       "Interface Type=%s\n" +				       "Hardware Address (MAC)=%02x:%02x:%02x:%02x:%02x:%02x\n" +				       "MTU=%d\n" +				       "[Transfer Details]\n" +				       "Bytes Received=%.0lf (%.2fMiB)\n" +				       "Bytes Sent=%.0lf (%.2fMiB)\n", +				       iface_type, +				       ni.mac[0], ni.mac[1], +				       ni.mac[2], ni.mac[3], +				       ni.mac[4], ni.mac[5], +				       ni.mtu, +				       recv_bytes, recv_mb, +				       trans_bytes, trans_mb); -            detailed = g_strdup_printf("[Network Adapter Properties]\n" -                                        "Interface Type=%s\n" -                                        "Hardware Address (MAC)=%02x:%02x:%02x:%02x:%02x:%02x\n" -                                        "MTU=%d\n" -                                        "[Transfer Details]\n" -                                        "Bytes Received=%ld (%.2fMiB)\n" -                                        "Bytes Sent=%ld (%.2fMiB)\n", -                                        iface_type, -                                        ni.mac[0], ni.mac[1], -                                        ni.mac[2], ni.mac[3], -                                        ni.mac[4], ni.mac[5], -                                        ni.mtu, -                                        recv_bytes, recv_mb, -                                        trans_bytes, trans_mb); -                                         -            if (ni.ip[0] || ni.mask[0] || ni.broadcast[0]) { -                 detailed = h_strdup_cprintf("\n[Internet Protocol (IPv4)]\n" -                                            "IP Address=%s\n" -                                            "Mask=%s\n" -                                            "Broadcast Address=%s\n", -                                            detailed, -                                            ni.ip[0]        ? ni.ip        : "Not set", -                                            ni.mask[0]      ? ni.mask      : "Not set", -                                            ni.broadcast[0] ? ni.broadcast : "Not set"); -            } +#ifdef HAS_LINUX_WE +            if (ni.is_wireless) { +              gchar *txpower; -            g_hash_table_insert(moreinfo, devid, detailed); +              if (ni.wi_has_txpower) { +                gint mw, dbm; +               +                if (ni.wi_txpower.flags & IW_TXPOW_MWATT) { +                  mw = ni.wi_txpower.value; +                  dbm = (int) ceil(10.0 * log10((double) ni.wi_txpower.value)); +                } else { +                  dbm = ni.wi_txpower.value; +                  mw = (int) floor(pow(10.0, ((double) dbm / 10.0))); +                } +                 +                txpower = g_strdup_printf("%ddBm (%dmW)", dbm, mw); +              } else { +                txpower = g_strdup("Unknown"); +              } +             +              detailed = h_strdup_cprintf("\n[Wireless Properties]\n" +                                          "Network Name (SSID)=%s\n" +                                          "Bit Rate=%dMb/s\n" +                                          "Transmission Power=%s\n" +                                          "Mode=%s\n" +                                          "Status=%d\n" +                                          "Link Quality=%d\n" +                                          "Signal / Noise=%d / %d\n", +                                          detailed, +                                          ni.wi_essid, +                                          ni.wi_rate / 1000000, +                                          txpower, +                                          wi_operation_modes[ni.wi_mode], +                                          ni.wi_status, +                                          ni.wi_quality_level, +                                          ni.wi_signal_level, +                                          ni.wi_noise_level); + +              g_free(txpower); +            } +#endif + +	    if (ni.ip[0] || ni.mask[0] || ni.broadcast[0]) { +		detailed = +		    h_strdup_cprintf("\n[Internet Protocol (IPv4)]\n" +				     "IP Address=%s\n" "Mask=%s\n" +				     "Broadcast Address=%s\n", detailed, +				     ni.ip[0] ? ni.ip : "Not set", +				     ni.mask[0] ? ni.mask : "Not set", +				     ni.broadcast[0] ? ni. +				     broadcast : "Not set"); +	    } + +	    g_hash_table_insert(moreinfo, devid, detailed);  	}      }      fclose(proc_net);  } -static void -scan_net_interfaces(void) +static void scan_net_interfaces(void)  {      /* FIXME: See if we're running Linux 2.6 and if /sys is mounted, then use -              that instead of /proc/net/dev */ +       that instead of /proc/net/dev */      /* remove old devices from global device table */      g_hash_table_foreach_remove(moreinfo, remove_net_devices, NULL); diff --git a/arch/linux/common/os.h b/arch/linux/common/os.h index e4f35e95..01853123 100644 --- a/arch/linux/common/os.h +++ b/arch/linux/common/os.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -17,6 +17,34 @@   */  static gchar * +get_default_gcc_version(void) +{ +    char *buf; +     +    if (g_spawn_command_line_sync("gcc -v", +                                   NULL, +                                   &buf, +                                   NULL, +                                   NULL)) { +        char *return_value; +         +        if (!(return_value = strstr(buf, "gcc version "))) { +            goto err; +        } +         +        return_value += sizeof("gcc version"); +        return_value = g_strdup_printf("GNU C Compiler version %s", return_value); +         +        g_free(buf); +         +        return return_value; +    } + +err: +    return g_strdup("Unknown"); +} + +static gchar *  get_libc_version(void)  {      FILE *libc; @@ -66,27 +94,23 @@ detect_desktop_environment(OperatingSystem * os)  {      const gchar *tmp = g_getenv("GNOME_DESKTOP_SESSION_ID");      FILE *version; -    int maj, min; +    char vers[16];      if (tmp) {  	/* FIXME: this might not be true, as the gnome-panel in path  	   may not be the one that's running.  	   see where the user's running panel is and run *that* to  	   obtain the version. */ -	version = popen("gnome-panel --version", "r"); +	version = popen("gnome-about --gnome-version", "r");  	if (version) { -	    char gnome[10]; -	     -	    fscanf(version, "%s gnome-panel %d.%d", gnome, &maj, &min); +	    fscanf(version, "Version: %s", vers);  	    if (pclose(version))  	        goto unknown;  	} else {  	    goto unknown;  	} -	os->desktop = -	    g_strdup_printf("GNOME %d.%d (session name: %s)", maj, min, -			    tmp); +	os->desktop = g_strdup_printf("GNOME %s", vers);      } else if (g_getenv("KDE_FULL_SESSION")) {  	version = popen("kcontrol --version", "r");  	if (version) { @@ -94,14 +118,14 @@ detect_desktop_environment(OperatingSystem * os)  	    fgets(buf, 32, version); -	    fscanf(version, "KDE: %d.%d", &maj, &min); +	    fscanf(version, "KDE: %s", vers);  	    if (pclose(version))  	        goto unknown;  	} else {  	    goto unknown;  	} -	os->desktop = g_strdup_printf("KDE %d.%d", maj, min); +	os->desktop = g_strdup_printf("KDE %s", vers);      } else {        unknown:  	if (!g_getenv("DISPLAY")) { @@ -147,11 +171,13 @@ computer_get_os(void)  	gchar buffer[128];  	release = popen("lsb_release -d", "r"); -	fgets(buffer, 128, release); -	pclose(release); +	if (release) { +            fgets(buffer, 128, release); +            pclose(release); -	os->distro = buffer; -	os->distro = g_strdup(os->distro + strlen("Description:\t")); +            os->distro = buffer; +            os->distro = g_strdup(os->distro + strlen("Description:\t")); +        }      }      for (i = 0;; i++) { @@ -210,6 +236,7 @@ computer_get_os(void)      os->username = g_strdup_printf("%s (%s)",  				   g_get_user_name(), g_get_real_name());      os->libc = get_libc_version(); +    os->gcc  = get_default_gcc_version();      scan_languages(os);      detect_desktop_environment(os); diff --git a/arch/linux/common/pci.h b/arch/linux/common/pci.h index 388ce9aa..a1ea1021 100644 --- a/arch/linux/common/pci.h +++ b/arch/linux/common/pci.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -16,25 +16,47 @@   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ +/* + * TODO: This thing must be rewritten. We really should have a struct with all the + *       PCI stuff we'll present to the user, and hash them by the PCI ID + *       (domain:bus:device.function). + *       This way we'll have ways to better organize the output, instead of relying + *       on the order the information appears on lspci's output. + *       Also, the "Resources" thing might be better implemented (and we won't need + *       copies of information scattered everywhere like we do today). + */ + +GHashTable *_pci_devices = NULL; +  void  __scan_pci(void)  {      FILE *lspci;      gchar buffer[256], *buf, *strhash = NULL, *strdevice = NULL; -    gchar *category = NULL, *name = NULL, *icon; +    gchar *category = NULL, *name = NULL, *icon, *lspci_path, *command_line;      gint n = 0, x = 0; +     +    if ((lspci_path = find_program("lspci")) == NULL) { +      goto pci_error; +    } else { +      command_line = g_strdup_printf("%s -v", lspci_path); +    } +     +    if (!_pci_devices) { +      _pci_devices = g_hash_table_new(g_str_hash, g_str_equal); +    }      buf = g_build_filename(g_get_home_dir(), ".hardinfo", "pci.ids", NULL);      if (!g_file_test(buf, G_FILE_TEST_EXISTS)) {        DEBUG("using system-provided PCI IDs");        g_free(buf); -      if (!(lspci = popen(LSPCI, "r"))) { +      if (!(lspci = popen(command_line, "r"))) {          goto pci_error;        }      } else {        gchar *tmp; -      tmp = g_strdup_printf("%s -i '%s'", LSPCI, buf); +      tmp = g_strdup_printf("%s -i '%s'", command_line, buf);        g_free(buf);        buf = tmp; @@ -83,10 +105,21 @@ __scan_pci(void)  		strdevice = h_strdup_cprintf("Latency=%d\n", strdevice, latency);  	    strdevice = h_strdup_cprintf("Bus Master=%s\n", strdevice, bus_master ? "Yes" : "No"); +	} else if (!strncmp(buf, "Kernel modules", 14)) { +	    WALK_UNTIL(' '); +	    WALK_UNTIL(':'); +	    buf++; +	     +	    strdevice = h_strdup_cprintf("Kernel modules=%s\n", strdevice, buf);  	} else if (!strncmp(buf, "Subsystem", 9)) {  	    WALK_UNTIL(' ');  	    buf++; -	    strdevice = h_strdup_cprintf("OEM Vendor=%s\n", strdevice, buf); +	    const gchar *oem_vendor_url = vendor_get_url(buf); +            if (oem_vendor_url)  +                strdevice = h_strdup_cprintf("OEM Vendor=%s (%s)\n", +                                            strdevice, +                                            vendor_get_name(buf), +                                            oem_vendor_url);  	} else if (!strncmp(buf, "Capabilities", 12)  		   && !strstr(buf, "only to root") &&   		      !strstr(buf, "access denied")) { @@ -114,7 +147,7 @@ __scan_pci(void)  					prefetch ? "prefetchable" :  					"non-prefetchable"); -	} else if (!strncmp(buf, "I/O", 3)) { +	} else if (!strncmp(buf, "I/O ports at", 12)) {  	    guint io_addr, io_size;  	    sscanf(buf, "I/O ports at %x [size=%d]", &io_addr, &io_size); @@ -122,7 +155,7 @@ __scan_pci(void)  	    strdevice =  		h_strdup_cprintf("I/O ports at#%d=0x%x - 0x%x\n",  				strdevice, ++x, io_addr, -				io_addr + io_size); +				io_addr + io_size - 1);  	} else if ((buf[0] >= '0' && buf[0] <= '9') && (buf[4] == ':' || buf[2] == ':')) {  	    gint bus, device, function, domain;  	    gpointer start, end; @@ -164,6 +197,9 @@ __scan_pci(void)              else icon = "pci";  	    name = g_strdup(buf); +            g_hash_table_insert(_pci_devices, +                                g_strdup_printf("0000:%02x:%02x.%x", bus, device, function), +                                name);  	    strhash = g_strdup_printf("PCI%d", n);  	    strdevice = g_strdup_printf("[Device Information]\n" @@ -182,6 +218,9 @@ __scan_pci(void)                                              url);              } +            g_hash_table_insert(_pci_devices, +                                g_strdup_printf("0000:%02x:%02x.%x", bus, device, function), +                                g_strdup(name));  	    pci_list = h_strdup_cprintf("$PCI%d$%s=%s\n", pci_list, n, category, name); @@ -199,4 +238,7 @@ pci_error:          g_free(category);          g_free(name);      } +     +    g_free(lspci_path); +    g_free(command_line);  } diff --git a/arch/linux/common/resources.h b/arch/linux/common/resources.h new file mode 100644 index 00000000..20db65e9 --- /dev/null +++ b/arch/linux/common/resources.h @@ -0,0 +1,103 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +gchar *_resources = NULL; + +#if GLIB_CHECK_VERSION(2,14,0) +static GRegex *_regex_pci = NULL, +              *_regex_module = NULL; + +static gchar *_resource_obtain_name(gchar *name) +{ +    gchar *temp; + +    if (!_regex_pci && !_regex_module) { +      _regex_pci = g_regex_new("^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:" +                               "[0-9a-fA-F]{2}\\.[0-9a-fA-F]{1}$", +                               0, 0, NULL); +      _regex_module = g_regex_new("^[0-9a-zA-Z\\_\\-]+$", 0, 0, NULL); +    } +     +    name = g_strstrip(name); +     +    if (g_regex_match(_regex_pci, name, 0, NULL)) { +      temp = module_call_method_param("devices::getPCIDeviceDescription", name); +      if (temp) { +          return temp; +      } +    } else if (g_regex_match(_regex_module, name, 0, NULL)) { +      temp = module_call_method_param("computer::getKernelModuleDescription", name); +      if (temp) { +          return temp; +      } +    } +     +    return g_strdup(name); +} +#else +static gchar *_resource_obtain_name(gchar *name) +{ +    return g_strdup(name); +} +#endif + +void scan_device_resources(gboolean reload) +{ +    SCAN_START(); +    FILE *io; +    gchar buffer[256]; +    gint i; + +    struct { +      gchar *file; +      gchar *description; +    } resources[] = { +      { "/proc/ioports", "[I/O Ports]\n" }, +      { "/proc/iomem", "[Memory]\n" }, +      { "/proc/dma", "[DMA]\n" } +    }; +     +    g_free(_resources); +    _resources = g_strdup(""); +     +    for (i = 0; i < G_N_ELEMENTS(resources); i++) { +      if ((io = fopen(resources[i].file, "r"))) { +        _resources = h_strconcat(_resources, resources[i].description, NULL); + +        while (fgets(buffer, 256, io)) { +          gchar **temp = g_strsplit(buffer, ":", 2); +          gchar *name = _resource_obtain_name(temp[1]); + +          _resources = h_strdup_cprintf("<tt>%s</tt>=%s\n", _resources, +                                        temp[0], name); + +          g_strfreev(temp); +          g_free(name); +        } + +        fclose(io); +      } +    } +     +    SCAN_END(); +} + +gchar *callback_device_resources(void) +{ +    return _resources; +} diff --git a/arch/linux/common/samba.h b/arch/linux/common/samba.h index 7c7d8bb7..65cdc890 100644 --- a/arch/linux/common/samba.h +++ b/arch/linux/common/samba.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/common/sensors.h b/arch/linux/common/sensors.h index 1c4fd69f..17637764 100644 --- a/arch/linux/common/sensors.h +++ b/arch/linux/common/sensors.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -31,9 +31,16 @@ static void read_sensor_labels(gchar * driver)  					  g_free, g_free);      sensor_compute = g_hash_table_new(g_str_hash, g_str_equal); -    conf = fopen("/etc/sensors.conf", "r"); -    if (!conf) -	return; +    /* Try to open lm-sensors config file sensors3.conf */ +    conf = fopen("/etc/sensors3.conf", "r"); + +    /* If it fails, try to open sensors.conf */ +    if (!conf) conf = fopen("/etc/sensors.conf", "r"); + +    if (!conf) { +        /* Cannot open config file. */ +        return; +    }      while (fgets(buf, 256, conf)) {  	line = buf; @@ -100,7 +107,7 @@ static void read_sensor_labels(gchar * driver)  		for (i = 1; chips[i]; i++) {  		    strend(chips[i], '*'); -		    if (g_str_has_prefix(driver, chips[i] + 1)) { +                     if (g_str_has_prefix(chips[i] + 1, driver)) {  			lock = TRUE;  			break;  		    } diff --git a/arch/linux/common/storage.h b/arch/linux/common/storage.h index 71c206cd..5208f028 100644 --- a/arch/linux/common/storage.h +++ b/arch/linux/common/storage.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -36,6 +36,7 @@ __scan_scsi_devices(void)      gint scsi_id;      gint scsi_lun;      gchar *vendor = NULL, *revision = NULL, *model = NULL; +    gchar *scsi_storage_list;      /* remove old devices from global device table */      g_hash_table_foreach_remove(moreinfo, remove_scsi_devices, NULL); @@ -43,7 +44,7 @@ __scan_scsi_devices(void)      if (!g_file_test("/proc/scsi/scsi", G_FILE_TEST_EXISTS))  	return; -    storage_list = g_strconcat(storage_list, "\n[SCSI Disks]\n", NULL); +    scsi_storage_list = g_strdup("\n[SCSI Disks]\n");      proc_scsi = fopen("/proc/scsi/scsi", "r");      while (fgets(buffer, 256, proc_scsi)) { @@ -55,29 +56,13 @@ __scan_scsi_devices(void)  	    n++;  	} else if (!strncmp(buf, "Vendor: ", 8)) { -	    char *p; -	    char *rev = strstr(buf, "Rev: "); - -	    model = strstr(buf, "Model: "); - -	    if (model == NULL) { -		model = buf + strlen(buf); -	    } -	    p = model; -	    while (*(--p) == ' '); -	    *(++p) = 0; -	    vendor = g_strdup(buf + 8); - -	    if (rev != NULL) { -		revision = g_strdup(rev + 5); -	    } else { -		rev = model + strlen(model); -	    } -	    p = rev; -	    while (*(--p) == ' '); -	    *(++p) = 0; -	    model = g_strdup_printf("%s %s", vendor, model + 7); - +	    buf[17] = '\0'; +	    buf[41] = '\0'; +	    buf[53] = '\0'; +	     +	    vendor   = g_strdup(g_strstrip(buf + 8)); +	    model    = g_strdup_printf("%s %s", vendor, g_strstrip(buf + 24)); +	    revision = g_strdup(g_strstrip(buf + 46));  	} else if (!strncmp(buf, "Type:   ", 8)) {  	    char *p;  	    gchar *type = NULL, *icon = NULL; @@ -98,43 +83,59 @@ __scan_scsi_devices(void)                      { "Direct-Access", "Disk", "hdd"},                      { "Sequential-Access", "Tape", "tape"},                      { "Printer", "Printer", "lpr"}, -                    { "WORM", "CD-ROM", "cd"}, -                    { "CD-ROM", "CD-ROM", "cd"}, +                    { "WORM", "CD-ROM", "cdrom"}, +                    { "CD-ROM", "CD-ROM", "cdrom"},                      { "Scanner", "Scanner", "scanner"}, +                    { "Flash Disk", "USB Flash Disk", "usbfldisk" },                      { NULL, "Generic", "scsi"}                   };                  int i; - -                for (i = 0; type2icon[i].type != NULL; i++) -                    if (g_str_equal(buf + 8, type2icon[i].type)) -                        break; - -                type = type2icon[i].label; -                icon = type2icon[i].icon; +                 +                if (strstr(model, "Flash Disk")) { +                  type = "Flash Disk"; +                  icon = "usbfldisk"; +                } else { +                  for (i = 0; type2icon[i].type != NULL; i++) +                      if (g_str_equal(buf + 8, type2icon[i].type)) +                          break; +                           +                  type = type2icon[i].label; +                  icon = type2icon[i].icon; +                }  	    }  	    gchar *devid = g_strdup_printf("SCSI%d", n); -	    storage_list = h_strdup_cprintf("$%s$%s=\n", storage_list, devid, model); +	    scsi_storage_list = h_strdup_cprintf("$%s$%s=\n", scsi_storage_list, devid, model);  	    storage_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", storage_icons, devid, model, icon); - +	      	    gchar *strhash = g_strdup_printf("[Device Information]\n" -					     "Model=%s\n" -					     "Vendor=%s (%s)\n" -					     "Type=%s\n" -					     "Revision=%s\n" -					     "[SCSI Controller]\n" -					     "Controller=scsi%d\n" -					     "Channel=%d\n" -					     "ID=%d\n" "LUN=%d\n", -					     model, -					     vendor_get_name(model), -					     vendor_get_url(model), -					     type, -					     revision, -					     scsi_controller, -					     scsi_channel, -					     scsi_id, -					     scsi_lun); +					     "Model=%s\n", model); +	     +	    const gchar *url = vendor_get_url(model); +	    if (url) { +	      strhash = h_strdup_cprintf("Vendor=%s (%s)\n", +                                         strhash, +                                         vendor_get_name(model), +                                         url); +	    } else { +	      strhash = h_strdup_cprintf("Vendor=%s\n", +                                         strhash, +                                         vendor_get_name(model)); +	    } + +            strhash = h_strdup_cprintf("Type=%s\n" +	    			       "Revision=%s\n" +				       "[SCSI Controller]\n" +                                       "Controller=scsi%d\n" +                                       "Channel=%d\n" +                                       "ID=%d\n" "LUN=%d\n", +                                       strhash, +                                       type, +                                       revision, +                                       scsi_controller, +                                       scsi_channel, +                                       scsi_id, +                                       scsi_lun);  	    g_hash_table_insert(moreinfo, devid, strhash);  	    g_free(model); @@ -143,6 +144,11 @@ __scan_scsi_devices(void)  	}      }      fclose(proc_scsi); +     +    if (n) { +      storage_list = h_strconcat(storage_list, scsi_storage_list, NULL); +      g_free(scsi_storage_list); +    }  }  static gboolean @@ -158,12 +164,12 @@ __scan_ide_devices(void)      gchar *device, iface, *model, *media, *pgeometry = NULL, *lgeometry =  	NULL;      gint n = 0, i = 0, cache, nn = 0; -    gchar *capab = NULL, *speed = NULL, *driver = NULL; +    gchar *capab = NULL, *speed = NULL, *driver = NULL, *ide_storage_list;      /* remove old devices from global device table */      g_hash_table_foreach_remove(moreinfo, remove_ide_devices, NULL); - -    storage_list = g_strconcat(storage_list, "\n[IDE Disks]\n", NULL); +     +    ide_storage_list = g_strdup("\n[IDE Disks]\n");      iface = 'a';      for (i = 0; i <= 16; i++) { @@ -285,24 +291,36 @@ __scan_ide_devices(void)  	    gchar *devid = g_strdup_printf("IDE%d", n); -	    storage_list = h_strdup_cprintf("$%s$%s=\n", storage_list, +	    ide_storage_list = h_strdup_cprintf("$%s$%s=\n", ide_storage_list,  					 devid, model);  	    storage_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", storage_icons, devid,  	                                  model, g_str_equal(media, "cdrom") ? \  	                                         "cdrom" : "hdd"); - +	      	    gchar *strhash = g_strdup_printf("[Device Information]\n" -					     "Model=%s\n" -					     "Vendor=%s (%s)\n" -					     "Device Name=hd%c\n" -					     "Media=%s\n" -					     "Cache=%dkb\n", -					     model, -					     vendor_get_name(model), -					     vendor_get_url(model), -					     iface, -					     media, -					     cache); +		                             "Model=%s\n", +					     model); +	     +	    const gchar *url = vendor_get_url(model); +	     +	    if (url) { +	      strhash = h_strdup_cprintf("Vendor=%s (%s)\n", +                                         strhash, +                                         vendor_get_name(model), +                                         url); +	    } else { +	      strhash = h_strdup_cprintf("Vendor=%s\n", +                                         strhash, +                                         vendor_get_name(model)); +	    } +	     +            strhash = h_strdup_cprintf("Device Name=hd%c\n" +                                       "Media=%s\n" +                                       "Cache=%dkb\n", +                                       strhash, +                                       iface, +                                       media, +                                       cache);              if (driver) {                  strhash = h_strdup_cprintf("%s\n", strhash, driver); @@ -345,4 +363,9 @@ __scan_ide_devices(void)  	iface++;      } +     +    if (n) { +      storage_list = h_strconcat(storage_list, ide_storage_list, NULL); +      g_free(ide_storage_list); +    }  } diff --git a/arch/linux/common/uptime.h b/arch/linux/common/uptime.h index 9225c85c..b2412cd2 100644 --- a/arch/linux/common/uptime.h +++ b/arch/linux/common/uptime.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/common/usb.h b/arch/linux/common/usb.h index f2592648..cb939ff8 100644 --- a/arch/linux/common/usb.h +++ b/arch/linux/common/usb.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -15,7 +15,10 @@   *    along with this program; if not, write to the Free Software   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ - +/* + * FIXME: + * - listing with sysfs does not generate device hierarchy + */  static gboolean  remove_usb_devices(gpointer key, gpointer value, gpointer data)  { @@ -23,8 +26,106 @@ remove_usb_devices(gpointer key, gpointer value, gpointer data)  }  static gchar *usb_list = NULL; -void -__scan_usb(void) + +void __scan_usb_sysfs_add_device(gchar * endpoint, int n) +{ +    gchar *manufacturer, *product, *mxpwr, *tmp, *strhash; +    gint bus, classid, vendor, prodid; +    gfloat version, speed; + +    classid = h_sysfs_read_int(endpoint, "bDeviceClass"); +    vendor = h_sysfs_read_int(endpoint, "idVendor"); +    prodid = h_sysfs_read_int(endpoint, "idProduct"); +    bus = h_sysfs_read_int(endpoint, "busnum"); +    speed = h_sysfs_read_float(endpoint, "speed"); +    version = h_sysfs_read_float(endpoint, "version"); +     +    if (!(mxpwr = h_sysfs_read_string(endpoint, "bMaxPower"))) { +    	mxpwr = g_strdup("0 mA"); +    } + +    if (!(manufacturer = h_sysfs_read_string(endpoint, "manufacturer"))) { +    	manufacturer = g_strdup("Unknown"); +    } + +    if (!(product = h_sysfs_read_string(endpoint, "product"))) { +	if (classid == 9) { +	    product = g_strdup_printf("USB %.2f Hub", version); +	} else { +	    product = g_strdup_printf("Unknown USB %.2f Device (class %d)", version, classid); +	} +    } + +    const gchar *url = vendor_get_url(manufacturer); +    if (url) { +	tmp = g_strdup_printf("%s (%s)", vendor_get_name(manufacturer), url); +	 +	g_free(manufacturer); +	manufacturer = tmp;	     +    } + +    tmp = g_strdup_printf("USB%d", n); +    usb_list = h_strdup_cprintf("$%s$%s=\n", usb_list, tmp, product); + +    strhash = g_strdup_printf("[Device Information]\n" +			      "Product=%s\n" +			      "Manufacturer=%s\n" +			      "Speed=%.2fMbit/s\n" +			      "Max Current=%s\n" +			      "[Misc]\n" +			      "USB Version=%.2f\n" +			      "Class=0x%x\n" +			      "Vendor=0x%x\n" +			      "Product ID=0x%x\n" +			      "Bus=%d\n", +			      product, +			      manufacturer, +			      speed, +			      mxpwr, +			      version, classid, vendor, prodid, bus); + +    g_hash_table_insert(moreinfo, tmp, strhash); +     +    g_free(manufacturer); +    g_free(product); +    g_free(mxpwr); +} + +void __scan_usb_sysfs(void) +{ +    GDir *sysfs; +    gchar *filename; +    const gchar *sysfs_path = "/sys/class/usb_endpoint"; +    gint usb_device_number = 0; + +    if (!(sysfs = g_dir_open(sysfs_path, 0, NULL))) { +	return; +    } + +    if (usb_list) { +	g_hash_table_foreach_remove(moreinfo, remove_usb_devices, NULL); +	g_free(usb_list); +    } +    usb_list = g_strdup("[USB Devices]\n"); + +    while ((filename = (gchar *) g_dir_read_name(sysfs))) { +	gchar *endpoint = +	    g_build_filename(sysfs_path, filename, "device", NULL); +	gchar *temp; + +	temp = g_build_filename(endpoint, "idVendor", NULL); +	if (g_file_test(temp, G_FILE_TEST_EXISTS)) { +	    __scan_usb_sysfs_add_device(endpoint, ++usb_device_number); +	} + +	g_free(temp); +	g_free(endpoint); +    } + +    g_dir_close(sysfs); +} + +int __scan_usb_procfs(void)  {      FILE *dev;      gchar buffer[128]; @@ -36,13 +137,13 @@ __scan_usb(void)      dev = fopen("/proc/bus/usb/devices", "r");      if (!dev) -	return; +	return 0;      if (usb_list) {  	g_hash_table_foreach_remove(moreinfo, remove_usb_devices, NULL);  	g_free(usb_list);      } -    usb_list = g_strdup(""); +    usb_list = g_strdup("[USB Devices]\n");      while (fgets(buffer, 128, dev)) {  	tmp = buffer; @@ -73,52 +174,60 @@ __scan_usb(void)  	    mxpwr = strstr(buffer, "MxPwr=") + 6;  	    tmp = g_strdup_printf("USB%d", ++n); -	     +  	    if (*product == '\0') { -	        g_free(product); -	        if (classid == 9) { -                    product = g_strdup_printf("USB %.2f Hub", ver); -                } else { -  	            product = g_strdup_printf("Unknown USB %.2f Device (class %d)", -                                              ver, classid); -                } +		g_free(product); +		if (classid == 9) { +		    product = g_strdup_printf("USB %.2f Hub", ver); +		} else { +		    product = +			g_strdup_printf +			("Unknown USB %.2f Device (class %d)", ver, +			 classid); +		}  	    } -	     +  	    if (classid == 9) {	/* hub */ -    	        usb_list = h_strdup_cprintf("[%s#%d]\n", -		      		           usb_list, product, n); -            } else { /* everything else */ -    	        usb_list = h_strdup_cprintf("$%s$%s=\n", -		      		           usb_list, tmp, product); - -                const gchar *url = vendor_get_url(manuf); -                if (url) { -                    gchar *tmp = g_strdup_printf("%s (%s)", manuf, url); -                    g_free(manuf); -                    manuf = tmp; -                } - -                gchar *strhash = g_strdup_printf("[Device Information]\n" -                                                 "Product=%s\n" -                                                 "Manufacturer=%s\n" -                                                 "[Port #%d]\n" -                                                 "Speed=%.2fMbit/s\n" -                                                 "Max Current=%s\n" -                                                 "[Misc]\n" -                                                 "USB Version=%.2f\n" -                                                 "Revision=%.2f\n" -                                                 "Class=0x%x\n" -                                                 "Vendor=0x%x\n" -                                                 "Product ID=0x%x\n" -                                                 "Bus=%d\n" "Level=%d\n", -                                                 product, manuf, -                                                 port, speed, mxpwr, -                                                 ver, rev, classid, -                                                 vendor, prodid, bus, level); - -                g_hash_table_insert(moreinfo, tmp, strhash); -            } +		usb_list = h_strdup_cprintf("[%s#%d]\n", +					    usb_list, product, n); +	    } else {		/* everything else */ +		usb_list = h_strdup_cprintf("$%s$%s=\n", +					    usb_list, tmp, product); + +		const gchar *url = vendor_get_url(manuf); +		if (url) { +		    gchar *tmp = +			g_strdup_printf("%s (%s)", vendor_get_name(manuf), +					url); +		    g_free(manuf); +		    manuf = tmp; +		} + +		gchar *strhash = g_strdup_printf("[Device Information]\n" +						 "Product=%s\n", +						 product); +		if (manuf && strlen(manuf)) +		    strhash = h_strdup_cprintf("Manufacturer=%s\n", +					       strhash, manuf); + +		strhash = h_strdup_cprintf("[Port #%d]\n" +					   "Speed=%.2fMbit/s\n" +					   "Max Current=%s\n" +					   "[Misc]\n" +					   "USB Version=%.2f\n" +					   "Revision=%.2f\n" +					   "Class=0x%x\n" +					   "Vendor=0x%x\n" +					   "Product ID=0x%x\n" +					   "Bus=%d\n" "Level=%d\n", +					   strhash, +					   port, speed, mxpwr, +					   ver, rev, classid, +					   vendor, prodid, bus, level); + +		g_hash_table_insert(moreinfo, tmp, strhash); +	    }  	    g_free(manuf);  	    g_free(product); @@ -128,4 +237,12 @@ __scan_usb(void)      }      fclose(dev); + +    return n; +} + +void __scan_usb(void) +{ +    if (!__scan_usb_procfs()) +	__scan_usb_sysfs();  } diff --git a/arch/linux/ia64/processor.h b/arch/linux/ia64/processor.h index bc1d7f08..d3d41519 100644 --- a/arch/linux/ia64/processor.h +++ b/arch/linux/ia64/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -19,7 +19,7 @@  struct _Processor {      gchar *model_name;      gchar *vendor_id; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;      gchar *strmodel;  }; @@ -50,6 +50,8 @@ __scan_processors(void)  	}  	g_strfreev(tmp);      } + +    processor->cpu_mhz = 0.0f;      fclose(cpuinfo); diff --git a/arch/linux/ia64/resources.h b/arch/linux/ia64/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/ia64/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/m68k/processor.h b/arch/linux/m68k/processor.h index 0fb59d24..6fbd8293 100644 --- a/arch/linux/m68k/processor.h +++ b/arch/linux/m68k/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/m68k/resources.h b/arch/linux/m68k/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/m68k/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/mips/processor.h b/arch/linux/mips/processor.h index 1aa7794d..cd10bd7a 100644 --- a/arch/linux/mips/processor.h +++ b/arch/linux/mips/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/mips/resources.h b/arch/linux/mips/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/mips/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/parisc/processor.h b/arch/linux/parisc/processor.h index 357f4d83..1712e523 100644 --- a/arch/linux/parisc/processor.h +++ b/arch/linux/parisc/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/parisc/resources.h b/arch/linux/parisc/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/parisc/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/ppc/processor.h b/arch/linux/ppc/processor.h index 6aa0f4ef..863b2eb7 100644 --- a/arch/linux/ppc/processor.h +++ b/arch/linux/ppc/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/arch/linux/ppc/resources.h b/arch/linux/ppc/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/ppc/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/s390/processor.h b/arch/linux/s390/processor.h index ee72b029..25dab8ca 100644 --- a/arch/linux/s390/processor.h +++ b/arch/linux/s390/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -19,7 +19,7 @@  struct _Processor {      gchar *vendor_id, *model_name;      gint cache_size; -    gfloat bogomips; +    gfloat bogomips, cpu_mhz;  };  static GSList * @@ -48,6 +48,8 @@ __scan_processors(void)  	}  	g_strfreev(tmp);      } + +    processor->cpu_mhz = 0.0f;      processor->model_name = g_strconcat("S390 ", processor->vendor_id, NULL);      g_free(processor->vendor_id); diff --git a/arch/linux/s390/resources.h b/arch/linux/s390/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/s390/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/sh/alsa.h b/arch/linux/sh/alsa.h new file mode 120000 index 00000000..0216845a --- /dev/null +++ b/arch/linux/sh/alsa.h @@ -0,0 +1 @@ +../../linux/common/alsa.h
\ No newline at end of file diff --git a/arch/linux/sh/battery.h b/arch/linux/sh/battery.h new file mode 120000 index 00000000..e4c794f2 --- /dev/null +++ b/arch/linux/sh/battery.h @@ -0,0 +1 @@ +../../linux/common/battery.h
\ No newline at end of file diff --git a/arch/linux/sh/boots.h b/arch/linux/sh/boots.h new file mode 120000 index 00000000..e7ef0408 --- /dev/null +++ b/arch/linux/sh/boots.h @@ -0,0 +1 @@ +../../linux/common/boots.h
\ No newline at end of file diff --git a/arch/linux/sh/devmemory.h b/arch/linux/sh/devmemory.h new file mode 120000 index 00000000..5b1b866f --- /dev/null +++ b/arch/linux/sh/devmemory.h @@ -0,0 +1 @@ +../../linux/common/devmemory.h
\ No newline at end of file diff --git a/arch/linux/sh/filesystem.h b/arch/linux/sh/filesystem.h new file mode 120000 index 00000000..6b325b40 --- /dev/null +++ b/arch/linux/sh/filesystem.h @@ -0,0 +1 @@ +../../linux/common/filesystem.h
\ No newline at end of file diff --git a/arch/linux/sh/inputdevices.h b/arch/linux/sh/inputdevices.h new file mode 120000 index 00000000..b9226a29 --- /dev/null +++ b/arch/linux/sh/inputdevices.h @@ -0,0 +1 @@ +../../linux/common/inputdevices.h
\ No newline at end of file diff --git a/arch/linux/sh/loadavg.h b/arch/linux/sh/loadavg.h new file mode 120000 index 00000000..daaed6d5 --- /dev/null +++ b/arch/linux/sh/loadavg.h @@ -0,0 +1 @@ +../../linux/common/loadavg.h
\ No newline at end of file diff --git a/arch/linux/sh/memory.h b/arch/linux/sh/memory.h new file mode 120000 index 00000000..5ffc013e --- /dev/null +++ b/arch/linux/sh/memory.h @@ -0,0 +1 @@ +../../linux/common/memory.h
\ No newline at end of file diff --git a/arch/linux/sh/modules.h b/arch/linux/sh/modules.h new file mode 120000 index 00000000..8ce5a808 --- /dev/null +++ b/arch/linux/sh/modules.h @@ -0,0 +1 @@ +../../linux/common/modules.h
\ No newline at end of file diff --git a/arch/linux/sh/net.h b/arch/linux/sh/net.h new file mode 120000 index 00000000..72d77b26 --- /dev/null +++ b/arch/linux/sh/net.h @@ -0,0 +1 @@ +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/sh/nfs.h b/arch/linux/sh/nfs.h new file mode 120000 index 00000000..3d1048da --- /dev/null +++ b/arch/linux/sh/nfs.h @@ -0,0 +1 @@ +../../linux/common/nfs.h
\ No newline at end of file diff --git a/arch/linux/sh/os.h b/arch/linux/sh/os.h new file mode 120000 index 00000000..ef547be5 --- /dev/null +++ b/arch/linux/sh/os.h @@ -0,0 +1 @@ +../../linux/common/os.h
\ No newline at end of file diff --git a/arch/linux/sh/pci.h b/arch/linux/sh/pci.h new file mode 120000 index 00000000..63760048 --- /dev/null +++ b/arch/linux/sh/pci.h @@ -0,0 +1 @@ +../../linux/common/pci.h
\ No newline at end of file diff --git a/arch/linux/sh/processor.h b/arch/linux/sh/processor.h new file mode 100644 index 00000000..de33ee91 --- /dev/null +++ b/arch/linux/sh/processor.h @@ -0,0 +1,78 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +struct _Processor { +    gchar *model_name; +    gchar *vendor_id; +    gfloat bogomips, cpu_mhz; +}; + +static GSList * +__scan_processors(void) +{ +    Processor *processor; +    FILE *cpuinfo; +    gchar buffer[128]; + +    cpuinfo = fopen("/proc/cpuinfo", "r"); +    if (!cpuinfo) +	return NULL; + +    processor = g_new0(Processor, 1); +    while (fgets(buffer, 128, cpuinfo)) { +	gchar **tmp = g_strsplit(buffer, ":", 2); + +	if (tmp[0] && tmp[1]) { +	    tmp[0] = g_strstrip(tmp[0]); +	    tmp[1] = g_strstrip(tmp[1]); + +	    get_str("machine", processor->model_name); +	    get_str("cpu type", processor->vendor_id); +	    get_float("bogomips", processor->bogomips); +	    processor->cpu_mhz = processor->bogomips; +	} +	g_strfreev(tmp); +    } + +    fclose(cpuinfo); + +    return g_slist_append(NULL, processor); +} + +static gchar * +processor_get_info(GSList *processors) +{ +        Processor *processor = (Processor *)processors->data; +         +	return g_strdup_printf("[Processor]\n" +	                       "System Type=%s\n" +	                       "CPU Model=%s\n" +                               "Frequency=%.2fMHz\n" +			       "BogoMIPS=%.2f\n" +			       "Byte Order=%s\n", +			       processor->model_name, +			       processor->vendor_id, +			       processor->cpu_mhz, +			       processor->bogomips, +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +                               "Little Endian" +#else +                               "Big Endian" +#endif +			       ); +} diff --git a/arch/linux/sh/resources.h b/arch/linux/sh/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/sh/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/sh/samba.h b/arch/linux/sh/samba.h new file mode 120000 index 00000000..9227f722 --- /dev/null +++ b/arch/linux/sh/samba.h @@ -0,0 +1 @@ +../../linux/common/samba.h
\ No newline at end of file diff --git a/arch/linux/sh/sensors.h b/arch/linux/sh/sensors.h new file mode 120000 index 00000000..35e5f37a --- /dev/null +++ b/arch/linux/sh/sensors.h @@ -0,0 +1 @@ +../../linux/common/sensors.h
\ No newline at end of file diff --git a/arch/linux/sh/storage.h b/arch/linux/sh/storage.h new file mode 120000 index 00000000..55b68de3 --- /dev/null +++ b/arch/linux/sh/storage.h @@ -0,0 +1 @@ +../../linux/common/storage.h
\ No newline at end of file diff --git a/arch/linux/sh/uptime.h b/arch/linux/sh/uptime.h new file mode 120000 index 00000000..78c026ff --- /dev/null +++ b/arch/linux/sh/uptime.h @@ -0,0 +1 @@ +../../linux/common/uptime.h
\ No newline at end of file diff --git a/arch/linux/sh/usb.h b/arch/linux/sh/usb.h new file mode 120000 index 00000000..8b8fbb5d --- /dev/null +++ b/arch/linux/sh/usb.h @@ -0,0 +1 @@ +../../linux/common/usb.h
\ No newline at end of file diff --git a/arch/linux/sparc/processor.h b/arch/linux/sparc/processor.h index 04e38c33..0272c963 100644 --- a/arch/linux/sparc/processor.h +++ b/arch/linux/sparc/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -19,6 +19,7 @@  struct _Processor {      gchar *model_name;      gchar *has_fpu; +    gfloat cpu_mhz;  };  static GSList * @@ -48,6 +49,8 @@ __scan_processors(void)      fclose(cpuinfo); +    processor->cpu_mhz = 0.0f; +      return g_slist_append(NULL, processor);  } diff --git a/arch/linux/sparc/resources.h b/arch/linux/sparc/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/sparc/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/arch/linux/x86/boots.h b/arch/linux/x86/boots.h index 97384500..e7ef0408 120000 --- a/arch/linux/x86/boots.h +++ b/arch/linux/x86/boots.h @@ -1 +1 @@ -../../../arch/linux/common/boots.h
\ No newline at end of file +../../linux/common/boots.h
\ No newline at end of file diff --git a/arch/linux/x86/dmi.h b/arch/linux/x86/dmi.h new file mode 120000 index 00000000..1a285fbd --- /dev/null +++ b/arch/linux/x86/dmi.h @@ -0,0 +1 @@ +../../../arch/linux/common/dmi.h
\ No newline at end of file diff --git a/arch/linux/x86/net.h b/arch/linux/x86/net.h index 488b5ae3..72d77b26 120000 --- a/arch/linux/x86/net.h +++ b/arch/linux/x86/net.h @@ -1 +1 @@ -../../../arch/linux/common/net.h
\ No newline at end of file +../../linux/common/net.h
\ No newline at end of file diff --git a/arch/linux/x86/processor.h b/arch/linux/x86/processor.h index fd8711af..97fa4555 100644 --- a/arch/linux/x86/processor.h +++ b/arch/linux/x86/processor.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -16,6 +16,17 @@   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ +typedef struct _ProcessorCache	ProcessorCache; + +struct _ProcessorCache { +  gint level; +  gint number_of_sets; +  gint physical_line_partition; +  gint size; +  gchar *type; +  gint ways_of_associativity; +}; +  struct _Processor {      gchar *model_name;      gchar *vendor_id; @@ -30,6 +41,8 @@ struct _Processor {      gchar *strmodel;      gint id; +     +    GSList *cache;  };  /* @@ -148,12 +161,91 @@ static void get_processor_strfamily(Processor * processor)      }  } +static gchar *__cache_get_info_as_string(Processor *processor) +{ +    gchar *result = g_strdup(""); +    GSList *cache_list; +    ProcessorCache *cache; +     +    if (!processor->cache) { +        return g_strdup("Cache information not available=\n"); +    } +     +    for (cache_list = processor->cache; cache_list; cache_list = cache_list->next) { +        cache = (ProcessorCache *)cache_list->data; +         +        result = h_strdup_cprintf("Level %d (%s)=%d-way set-associative, %d sets, %dKB size\n", +                                  result, +                                  cache->level, +                                  cache->type, +                                  cache->ways_of_associativity, +                                  cache->number_of_sets, +                                  cache->size); +    } +     +    return result; +} + +static void __cache_obtain_info(Processor *processor, gint processor_number) +{ +    ProcessorCache *cache; +    gchar *endpoint, *entry, *index; +    gint i; +     +    endpoint = g_strdup_printf("/sys/devices/system/cpu/cpu%d/cache", processor_number); +     +    for (i = 0; ; i++) { +      cache = g_new0(ProcessorCache, 1); +       +      index = g_strdup_printf("index%d/", i); + +      entry = g_strconcat(index, "type", NULL); +      cache->type = h_sysfs_read_string(endpoint, entry); +      g_free(entry); +       +      if (!cache->type) { +        g_free(cache); +        g_free(index); +        goto fail; +      } + +      entry = g_strconcat(index, "level", NULL); +      cache->level = h_sysfs_read_int(endpoint, entry); +      g_free(entry); + +      entry = g_strconcat(index, "number_of_sets", NULL); +      cache->number_of_sets = h_sysfs_read_int(endpoint, entry); +      g_free(entry); + +      entry = g_strconcat(index, "physical_line_partition", NULL); +      cache->physical_line_partition = h_sysfs_read_int(endpoint, entry); +      g_free(entry); + +      entry = g_strconcat(index, "size", NULL); +      cache->size = h_sysfs_read_int(endpoint, entry); +      g_free(entry); + + +      entry = g_strconcat(index, "ways_of_associativity", NULL); +      cache->ways_of_associativity = h_sysfs_read_int(endpoint, entry); +      g_free(entry); +       +      g_free(index); + +      processor->cache = g_slist_append(processor->cache, cache); +    } + +fail:     +    g_free(endpoint); +} +  static GSList *__scan_processors(void)  {      GSList *procs = NULL;      Processor *processor = NULL;      FILE *cpuinfo;      gchar buffer[256]; +    gint processor_number = 0;      cpuinfo = fopen("/proc/cpuinfo", "r");      if (!cpuinfo) @@ -169,6 +261,8 @@ static GSList *__scan_processors(void)  	    }  	    processor = g_new0(Processor, 1); +	     +	    __cache_obtain_info(processor, processor_number++);  	}  	if (tmp[0] && tmp[1]) { @@ -208,6 +302,12 @@ static GSList *__scan_processors(void)      return procs;  } +/* + * Sources:  + * - Linux' cpufeature.h + * - http://gentoo-wiki.com/Cpuinfo + * - Intel IA-32 Architecture Software Development Manual + */  static struct {      char *name, *meaning;  } flag_meaning[] = { @@ -254,6 +354,68 @@ static struct {  	{ "tm",		"Thermal Monitor"				},  	{ "pbe",	"Pending Break Enable"				},  	{ "pb",		"Pending Break Enable"				}, +	{ "pn",		"Processor serial number"			}, +	{ "ds",		"Debug Store"					}, +	{ "xmm2",	"Streaming SIMD Extensions-2"			}, +	{ "xmm3",	"Streaming SIMD Extensions-3"			}, +	{ "selfsnoop",	"CPU self snoop"				}, +	{ "rdtscp",	"RDTSCP"					}, +	{ "recovery",	"CPU in recovery mode"				}, +	{ "longrun",	"Longrun power control"				}, +	{ "lrti",	"LongRun table interface"			}, +	{ "cxmmx",	"Cyrix MMX extensions"				}, +	{ "k6_mtrr",	"AMD K6 nonstandard MTRRs"			}, +	{ "cyrix_arr",	"Cyrix ARRs (= MTRRs)"				}, +	{ "centaur_mcr","Centaur MCRs (= MTRRs)"			}, +	{ "constant_tsc","TSC ticks at a constant rate"			}, +	{ "up",		"smp kernel running on up"			}, +	{ "fxsave_leak","FXSAVE leaks FOP/FIP/FOP"			}, +	{ "arch_perfmon","Intel Architectural PerfMon"			}, +	{ "pebs",	"Precise-Event Based Sampling"			}, +	{ "bts",	"Branch Trace Store"				}, +	{ "sync_rdtsc",	"RDTSC synchronizes the CPU"			}, +	{ "rep_good",	"rep microcode works well on this CPU"		}, +	{ "mwait",	"Monitor/Mwait support"				}, +	{ "ds_cpl",	"CPL Qualified Debug Store"			}, +	{ "est",	"Enhanced SpeedStep"				}, +	{ "tm2",	"Thermal Monitor 2"				}, +	{ "cid",	"Context ID"					}, +	{ "xtpr",	"Send Task Priority Messages"			}, +	{ "xstore",	"on-CPU RNG present (xstore insn)"		}, +	{ "xstore_en",	"on-CPU RNG enabled"				}, +	{ "xcrypt",	"on-CPU crypto (xcrypt insn)"			}, +	{ "xcrypt_en",	"on-CPU crypto enabled"				}, +	{ "ace2",	"Advanced Cryptography Engine v2"		}, +	{ "ace2_en",	"ACE v2 enabled"				}, +	{ "phe",	"PadLock Hash Engine"				}, +	{ "phe_en",	"PHE enabled"					}, +	{ "pmm",	"PadLock Montgomery Multiplier"			}, +	{ "pmm_en",	"PMM enabled"					}, +	{ "lahf_lm",	"LAHF/SAHF in long mode"			}, +	{ "cmp_legacy",	"HyperThreading not valid"			}, +	{ "lm",		"LAHF/SAHF in long mode"			}, +	{ "ds_cpl",	"CPL Qualified Debug Store"			}, +	{ "vmx",	"Virtualization support (Intel)"		}, +	{ "svm",	"Virtualization support (AMD)"			}, +	{ "est",	"Enhanced SpeedStep"				}, +	{ "tm2",	"Thermal Monitor 2"				}, +	{ "ssse3",	"Supplemental Streaming SIMD Extension 3"	}, +	{ "cx16",	"CMPXCHG16B instruction"			}, +	{ "xptr",	"Send Task Priority Messages"			}, +	{ "pebs",	"Precise Event Based Sampling"			}, +	{ "bts",	"Branch Trace Store"				}, +	{ "ida",	"Intel Dynamic Acceleration"			}, +	{ "arch_perfmon","Intel Architectural PerfMon"			}, +	{ "pni",	"Streaming SIMD Extension 3 (Prescott New Instruction)"	}, +	{ "rep_good",	"rep microcode works well on this CPU"		}, +	{ "ts",		"Thermal Sensor"				}, +	{ "sse3",	"Streaming SIMD Extension 3"			}, +	{ "sse4",	"Streaming SIMD Extension 4"			}, +	{ "tni",	"Tejas New Instruction"				}, +	{ "nni",	"Nehalem New Instruction"			}, +	{ "tpr",	"Task Priority Register"			}, +	{ "vid",	"Voltage Identifier"				}, +	{ "fid", 	"Frequency Identifier"				},  	{ NULL,		NULL						},  }; @@ -289,9 +451,11 @@ gchar *processor_get_capabilities_from_flags(gchar * strflags)  static gchar *processor_get_detailed_info(Processor * processor)  { -    gchar *tmp, *ret; +    gchar *tmp, *ret, *cache_info;      tmp = processor_get_capabilities_from_flags(processor->flags); +    cache_info = __cache_get_info_as_string(processor); +          ret = g_strdup_printf("[Processor]\n"  			  "Name=%s\n"  			  "Family, model, stepping=%d, %d, %d (%s)\n" @@ -307,6 +471,8 @@ static gchar *processor_get_detailed_info(Processor * processor)  			  "F00F Bug=%s\n"  			  "Coma Bug=%s\n"  			  "Has FPU=%s\n" +			  "[Cache]\n" +			  "%s\n"  			  "[Capabilities]\n"  			  "%s",  			  processor->model_name, @@ -322,15 +488,17 @@ static gchar *processor_get_detailed_info(Processor * processor)  #else  			  "Big Endian",  #endif -			  processor->bug_fdiv ? processor->bug_fdiv : "yes", -			  processor->bug_hlt  ? processor->bug_hlt  : "yes", -			  processor->bug_f00f ? processor->bug_f00f : "yes", -			  processor->bug_coma ? processor->bug_coma : "yes", +			  processor->bug_fdiv ? processor->bug_fdiv : "no", +			  processor->bug_hlt  ? processor->bug_hlt  : "no", +			  processor->bug_f00f ? processor->bug_f00f : "no", +			  processor->bug_coma ? processor->bug_coma : "no",  			  processor->has_fpu  ? processor->has_fpu  : "no", +			  cache_info,  			  tmp);      g_free(tmp); +    g_free(cache_info); +          return ret; -  }  static gchar *processor_get_info(GSList * processors) diff --git a/arch/linux/x86/resources.h b/arch/linux/x86/resources.h new file mode 120000 index 00000000..20a4815d --- /dev/null +++ b/arch/linux/x86/resources.h @@ -0,0 +1 @@ +../../../arch/linux/common/resources.h
\ No newline at end of file diff --git a/autopackage/default.apspec b/autopackage/default.apspec index f12960c1..a1c0bbbe 100644 --- a/autopackage/default.apspec +++ b/autopackage/default.apspec @@ -2,12 +2,12 @@  # Generated by mkapspec 0.2  [Meta]  ShortName: hardinfo -SoftwareVersion: 0.4.2.1 +SoftwareVersion: 0.4.3-beta2  DisplayName: HardInfo $SOFTWAREVERSION  RootName: @tia.mat.br/hardinfo:$SOFTWAREVERSION  Summary: System profiler and benchmark tool -Maintainer: Leandro A. F. Pereira <leandro@linuxmag.com.br> -Packager: Leandro A. F. Pereira <leandro@linuxmag.com.br> +Maintainer: Leandro A. F. Pereira <leandro@hardinfo.org> +Packager: Leandro A. F. Pereira <leandro@hardinfo.org>  PackageVersion: 1  CPUArchitectures: x86  AutopackageTarget: 1.2 @@ -20,6 +20,7 @@ License: GPL  # need to pass arguments to configure, just add them to prepareBuild:  # prepareBuild --enable-foo --disable-bar  export APBUILD_INCLUDE="/usr/local/gtk-headers/2.6" +export CC="apgcc"  prepareBuild  [BuildUnprepare] @@ -30,6 +31,8 @@ unprepareBuild  [Prepare]  require '@gtk.org/gtk' 2.6 +require '@gtk.org/glib' 2.6 +require '@gnome.org/libsoup' 8.0  [Imports]  # This command will tell makeinstaller what to include in the package. @@ -45,6 +48,7 @@ installData share/*  copyFile lib/hardinfo/modules/benchmark.so $PREFIX/lib/hardinfo/modules/benchmark.so  copyFile lib/hardinfo/modules/computer.so $PREFIX/lib/hardinfo/modules/computer.so  copyFile lib/hardinfo/modules/devices.so $PREFIX/lib/hardinfo/modules/devices.so +copyFile lib/hardinfo/modules/network.so $PREFIX/lib/hardinfo/modules/network.so  installMenuItem "System" share/applications/hardinfo.desktop  [Uninstall] diff --git a/benchmark.c b/benchmark.c index 3c6f0f1f..8bbfe11a 100644 --- a/benchmark.c +++ b/benchmark.c @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -26,53 +26,145 @@  #include <sys/resource.h>  enum { -    BENCHMARK_ZLIB, -    BENCHMARK_FIB, -    BENCHMARK_MD5, -    BENCHMARK_SHA1,      BENCHMARK_BLOWFISH, +    BENCHMARK_CRYPTOHASH, +    BENCHMARK_FIB, +    BENCHMARK_NQUEENS, +    BENCHMARK_FFT,      BENCHMARK_RAYTRACE,      BENCHMARK_N_ENTRIES  } Entries; -void scan_zlib(gboolean reload); +void scan_fft(gboolean reload);  void scan_raytr(gboolean reload);  void scan_bfsh(gboolean reload); -void scan_md5(gboolean reload); +void scan_cryptohash(gboolean reload);  void scan_fib(gboolean reload); -void scan_sha1(gboolean reload); +void scan_nqueens(gboolean reload); -gchar *callback_zlib(); +gchar *callback_fft();  gchar *callback_raytr();  gchar *callback_bfsh(); -gchar *callback_md5();  gchar *callback_fib(); -gchar *callback_sha1(); +gchar *callback_cryptohash(); +gchar *callback_nqueens();  static ModuleEntry entries[] = { -    {"CPU ZLib", "compress.png", callback_zlib, scan_zlib}, -    {"CPU Fibonacci", "module.png", callback_fib, scan_fib}, -    {"CPU MD5", "module.png", callback_md5, scan_md5}, -    {"CPU SHA1", "module.png", callback_sha1, scan_sha1},      {"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh}, +    {"CPU CryptoHash", "cryptohash.png", callback_cryptohash, scan_cryptohash}, +    {"CPU Fibonacci", "nautilus.png", callback_fib, scan_fib}, +    {"CPU N-Queens", "nqueens.png", callback_nqueens, scan_nqueens}, +    {"FPU FFT", "fft.png", callback_fft, scan_fft},      {"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr},      {NULL}  }; +typedef struct _ParallelBenchTask ParallelBenchTask; + +struct _ParallelBenchTask { +    guint	start, end; +    gpointer	data, callback; +}; + +gpointer benchmark_parallel_for_dispatcher(gpointer data) +{ +    ParallelBenchTask 	*pbt = (ParallelBenchTask *)data; +    gpointer 		(*callback)(unsigned int start, unsigned int end, void *data); +    gpointer		return_value; +     +    if ((callback = pbt->callback)) { +        DEBUG("this is thread %p; items %d -> %d, data %p", g_thread_self(), +              pbt->start, pbt->end, pbt->data); +        return_value = callback(pbt->start, pbt->end, pbt->data); +        DEBUG("this is thread %p; return value is %p", g_thread_self(), return_value); +    } else { +        DEBUG("this is thread %p; callback is NULL and it should't be!", g_thread_self()); +    } +     +    g_free(pbt); +     +    return return_value; +} + +gdouble benchmark_parallel_for(guint start, guint end, +                               gpointer callback, gpointer callback_data) { +    gchar	*temp; +    guint	n_cores, iter_per_core, iter; +    gdouble	elapsed_time; +    GSList	*threads = NULL, *t; +    GTimer	*timer; +     +    timer = g_timer_new(); +     +    temp = module_call_method("devices::getProcessorCount"); +    n_cores = temp ? atoi(temp) : 1; +    g_free(temp); +     +    while (1) { +        iter_per_core = (end - start) / n_cores; +         +        if (iter_per_core == 0) { +          DEBUG("not enough items per core; disabling one"); +          n_cores--; +        } else { +          break; +        } +    } +     +    DEBUG("processor has %d cores; processing %d elements (%d per core)", +          n_cores, (end - start), iter_per_core); +     +    g_timer_start(timer); +    for (iter = start; iter < end; iter += iter_per_core) { +        ParallelBenchTask *pbt = g_new0(ParallelBenchTask, 1); +        GThread *thread; +         +        DEBUG("launching thread %d", 1 + (iter / iter_per_core)); +         +        pbt->start    = iter == 0 ? 0 : iter + 1; +        pbt->end      = iter + iter_per_core - 1; +        pbt->data     = callback_data; +        pbt->callback = callback; +         +        if (pbt->end > end) +            pbt->end = end; +         +        thread = g_thread_create((GThreadFunc) benchmark_parallel_for_dispatcher, +                                 pbt, TRUE, NULL); +        threads = g_slist_append(threads, thread); +         +        DEBUG("thread %d launched as context %p", 1 + (iter / iter_per_core), threads->data); +    } +     +    DEBUG("waiting for all threads to finish"); +    for (t = threads; t; t = t->next) { +        DEBUG("waiting for thread with context %p", t->data); +        g_thread_join((GThread *)t->data); +    } +     +    g_timer_stop(timer); +    elapsed_time = g_timer_elapsed(timer, NULL); +     +    g_slist_free(threads); +    g_timer_destroy(timer); +     +    DEBUG("finishing; all threads took %f seconds to finish", elapsed_time); +     +    return elapsed_time; +} +  static gchar *__benchmark_include_results(gdouble result,  					  const gchar * benchmark,  					  ShellOrderType order_type)  {      GKeyFile *conf;      gchar **machines; -    gchar *path, *results = g_strdup(""); +    gchar *path, *results = g_strdup(""), *return_value, *processor_frequency;      int i;      conf = g_key_file_new(); -    path = -	g_build_filename(g_get_home_dir(), ".hardinfo", "benchmark.conf", -			 NULL); +    path = g_build_filename(g_get_home_dir(), ".hardinfo", "benchmark.conf", NULL);      if (!g_file_test(path, G_FILE_TEST_EXISTS)) {  	DEBUG("local benchmark.conf not found, trying system-wide");  	g_free(path); @@ -95,17 +187,24 @@ static gchar *__benchmark_include_results(gdouble result,      g_free(path);      g_key_file_free(conf); -    DEBUG("results = %s", results); - -    return g_strdup_printf("[$ShellParam$]\n" -			   "Zebra=1\n" -			   "OrderType=%d\n" -			   "ViewType=3\n" -			   "[%s]\n" -			   "<i>This Machine</i>=%.3f\n" -			   "%s", order_type, benchmark, result, results); +    processor_frequency = module_call_method("devices::getProcessorFrequency"); +    return_value = g_strdup_printf("[$ShellParam$]\n" +			   	   "Zebra=1\n" +			   	   "OrderType=%d\n" +	   			   "ViewType=3\n" +	   			   "ColumnTitle$Extra1=CPU Clock\n" +			   	   "ColumnTitle$Progress=Results\n" +			   	   "ColumnTitle$TextValue=CPU\n" +			   	   "ShowColumnHeaders=true\n" +	   			   "[%s]\n" +		   		   "<big><b>This Machine</b></big>=%.3f|%s MHz\n" +			   	   "%s", order_type, benchmark, result, processor_frequency, results); +    g_free(processor_frequency); +    return return_value;  } + +  static gchar *benchmark_include_results_reverse(gdouble result,  						const gchar * benchmark)  { @@ -123,16 +222,22 @@ static gchar *benchmark_include_results(gdouble result,  static gdouble bench_results[BENCHMARK_N_ENTRIES];  #include <arch/common/fib.h> -#include <arch/common/zlib.h> -#include <arch/common/md5.h> -#include <arch/common/sha1.h> +#include <arch/common/cryptohash.h>  #include <arch/common/blowfish.h>  #include <arch/common/raytrace.h> +#include <arch/common/nqueens.h> +#include <arch/common/fft.h> + +gchar *callback_fft() +{ +    return benchmark_include_results(bench_results[BENCHMARK_FFT], +				     "FPU FFT"); +} -gchar *callback_zlib() +gchar *callback_nqueens()  { -    return benchmark_include_results_reverse(bench_results[BENCHMARK_ZLIB], -					     "CPU ZLib"); +    return benchmark_include_results_reverse(bench_results[BENCHMARK_NQUEENS], +					     "CPU N-Queens");  }  gchar *callback_raytr() @@ -147,10 +252,10 @@ gchar *callback_bfsh()  				     "CPU Blowfish");  } -gchar *callback_md5() +gchar *callback_cryptohash()  { -    return benchmark_include_results_reverse(bench_results[BENCHMARK_MD5], -					     "CPU MD5"); +    return benchmark_include_results_reverse(bench_results[BENCHMARK_CRYPTOHASH], +					     "CPU Cryptohash");  }  gchar *callback_fib() @@ -159,12 +264,6 @@ gchar *callback_fib()  				     "CPU Fibonacci");  } -gchar *callback_sha1() -{ -    return benchmark_include_results_reverse(bench_results[BENCHMARK_SHA1], -					     "CPU SHA1"); -} -  #define RUN_WITH_HIGH_PRIORITY(fn)			\    do {							\      int old_priority = getpriority(PRIO_PROCESS, 0);	\ @@ -173,10 +272,17 @@ gchar *callback_sha1()      setpriority(PRIO_PROCESS, 0, old_priority);		\    } while (0); -void scan_zlib(gboolean reload) +void scan_fft(gboolean reload) +{ +    SCAN_START(); +    RUN_WITH_HIGH_PRIORITY(benchmark_fft); +    SCAN_END(); +} + +void scan_nqueens(gboolean reload)  {      SCAN_START(); -    RUN_WITH_HIGH_PRIORITY(benchmark_zlib); +    RUN_WITH_HIGH_PRIORITY(benchmark_nqueens);      SCAN_END();  } @@ -194,10 +300,10 @@ void scan_bfsh(gboolean reload)      SCAN_END();  } -void scan_md5(gboolean reload) +void scan_cryptohash(gboolean reload)  {      SCAN_START(); -    RUN_WITH_HIGH_PRIORITY(benchmark_md5); +    RUN_WITH_HIGH_PRIORITY(benchmark_cryptohash);      SCAN_END();  } @@ -208,26 +314,16 @@ void scan_fib(gboolean reload)      SCAN_END();  } -void scan_sha1(gboolean reload) -{ -    SCAN_START(); -    RUN_WITH_HIGH_PRIORITY(benchmark_sha1); -    SCAN_END(); -} -  const gchar *hi_note_func(gint entry)  {      switch (entry) { -    case BENCHMARK_ZLIB: -	return "Results in KiB/second. Higher is better."; - -    case BENCHMARK_MD5: -    case BENCHMARK_SHA1: +    case BENCHMARK_CRYPTOHASH:  	return "Results in MiB/second. Higher is better.";      case BENCHMARK_RAYTRACE:      case BENCHMARK_BLOWFISH:      case BENCHMARK_FIB: +    case BENCHMARK_NQUEENS:  	return "Results in seconds. Lower is better.";      } @@ -268,26 +364,31 @@ static gchar *get_benchmark_results()      gint i = G_N_ELEMENTS(entries) - 1;      gchar *machine = module_call_method("devices::getProcessorName"); -    gchar *param = g_strdup_printf("[param]\n" -				   "machine=%s\n" "nbenchmarks=%d\n", -				   machine, i); -    gchar *result = param; - +    gchar *machineclock = module_call_method("devices::getProcessorFrequency"); +    gchar *machineram = module_call_method("devices::getMemoryTotal"); +    gchar *result = g_strdup_printf("[param]\n" +				    "machine=%s\n" +				    "machineclock=%s\n" +				    "machineram=%s\n" +				    "nbenchmarks=%d\n", +				    machine, +				    machineclock, +				    machineram, i);      for (; i >= 0; i--) {  	if ((scan_callback = entries[i].scan_callback)) {  	    scan_callback(FALSE); -	    result = g_strdup_printf("%s\n" -				     "[bench%d]\n" -				     "name=%s\n" -				     "value=%f\n", -				     result, -				     i, entries[i].name, bench_results[i]); +	    result = h_strdup_cprintf("[bench%d]\n" +				      "name=%s\n" +				      "value=%f\n", +				      result, +				      i, entries[i].name, bench_results[i]);  	}      }      g_free(machine); -    g_free(param); +    g_free(machineclock); +    g_free(machineram);      return result;  } @@ -310,3 +411,10 @@ void hi_module_init(void)      sync_manager_add_entry(&se[0]);      sync_manager_add_entry(&se[1]);  } + +gchar **hi_module_get_dependencies(void) +{ +    static gchar *deps[] = { "devices.so", NULL }; + +    return deps; +} @@ -54,434 +54,440 @@ have time to provide unpaid support for everyone who uses this code.                                               -- Paul Kocher
  */  
 -    
 +    
  #include "blowfish.h"
  #define N               16
 -
static const unsigned long ORIG_P[16 + 2] = -    { 
0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, 
0xA4093822L, -0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, 
0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL, 
0xC0AC29B7L, -0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, 
0x9216D5D9L, 0x8979FB1BL 
 +static const unsigned long ORIG_P[16 + 2] = +    { 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, 0xA4093822L, +    0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, 0x452821E6L, 0x38D01377L, +	0xBE5466CFL, 0x34E90C6CL, 0xC0AC29B7L, +    0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, 0x9216D5D9L, 0x8979FB1BL 
  }; -
static const unsigned long ORIG_S[4][256] = { 
 -	{0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L, 
0xB8E1AFEDL, -	 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L, 
0x24A19947L, 0xB3916CF7L, -	 0x0801F2E2L, 0x858EFC16L, 
0x636920D8L, 0x71574E69L, 0xA458FEA3L, -	 0xF4933D7EL, 
0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL, -	 
0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L, 
0xC5D1B023L, -	 0x286085F0L, 0xCA417918L, 0xB8DB38EFL, 
0x8E79DCB0L, 0x603A180EL, -	 0x6C9E0E8BL, 0xB01E8A3EL, 
0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, -	 0x55605C60L, 
0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L, -	 
0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL, 
0xA15486AFL, -	 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL, 
0x2BA9C55DL, 0x741831F6L, -	 0xCE5C3E16L, 0x9B87931EL, 
0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, -	 0x28958677L, 
0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L, -	 
0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L, 
0xEF845D5DL, -	 0xE98575B1L, 0xDC262302L, 0xEB651B88L, 
0x23893E81L, 0xD396ACC5L, -	 0x0F6D6FF3L, 0x83F44239L, 
0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, -	 0x9E1F9B5EL, 
0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L, -	 
0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L, 
0x6EEF0B6CL, -	 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L, 
0xA1F1651DL, 0x39AF0176L, -	 0x66CA593EL, 0x82430E88L, 
0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, -	 0x3B8B5EBEL, 
0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L, -	 
0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL, 
0x37D0D724L, -	 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL, 
0x075372C9L, 0x80991B7BL, -	 0x25D479D8L, 0xF6E8DEF7L, 
0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, -	 0x04C006BAL, 
0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L, -	 
0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL, 
0x6DFC511FL, -	 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L, 
0xBEE3D004L, 0xDE334AFDL, -	 0x660F2807L, 0x192E4BB3L, 
0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, -	 0xB9D3FBDBL, 
0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L, -	 
0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L, 
0x3C7516DFL, -	 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL, 
0x323DB5FAL, 0xFD238760L, -	 0x53317B48L, 0x3E00DF82L, 
0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, -	 0xDF1769DBL, 
0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L, -	 
0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L, 
0x10FA3D98L, -	 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL, 
0x9A53E479L, 0xB6F84565L, -	 0xD28E49BCL, 0x4BFB9790L, 
0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, -	 0xCEE4C6E8L, 
0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L, -	 
0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L, 
0xD08ED1D0L, -	 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L, 
0x8FF6E2FBL, 0xF2122B64L, -	 0x8888B812L, 0x900DF01CL, 
0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, -	 0xB3A8C1ADL, 
0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L, -	 
0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L, 
0xB4A84FE0L, -	 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L, 
0x165FA266L, 0x80957705L, -	 0x93CC7314L, 0x211A1477L, 
0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, -	 0xFB9D35CFL, 
0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L, -	 
0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL, 
0x2464369BL, -	 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL, 
0x78C14389L, 0xD95A537FL, -	 0x207D5BA2L, 0x02E5B9C5L, 
0x83260376L, 0x6295CFA9L, 0x11C81968L, -	 0x4E734A41L, 
0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L, -	 
0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L, 
0x08BA6FB5L, -	 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L, 
0xB6636521L, 0xE7B9F9B6L, -	 0xFF34052EL, 0xC5855664L, 
0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, -	 0x6E85076AL}, 
{0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, -			 0xC4192623L, 
0xAD6EA6B0L, 0x49A7DF7DL, -			 0x9CEE60B8L, 0x8FEDB266L, 
0xECAA8C71L, -			 0x699A17FFL, 0x5664526CL, 0xC2B19EE1L, -			 
0x193602A5L, 0x75094C29L, 0xA0591340L, -			 0xE4183A3EL, 
0x3F54989AL, 0x5B429D65L, -			 0x6B8FE4D6L, 0x99F73FD6L, 
0xA1D29C07L, -			 0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L, -			 
0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, -			 0x021ECC5EL, 
0x09686B3FL, 0x3EBAEFC9L, -			 0x3C971814L, 0x6B6A70A1L, 
0x687F3584L, -			 0x52A0E286L, 0xB79C5305L, 0xAA500737L, -			 
0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, -			 0x5716F2B8L, 
0xB03ADA37L, 0xF0500C0DL, -			 0xF01C1F04L, 0x0200B3FFL, 
0xAE0CF51AL, -			 0x3CB574B2L, 0x25837A58L, 0xDC0921BDL, -			 
0xD19113F9L, 0x7CA92FF6L, 0x94324773L, -			 0x22F54701L, 
0x3AE5E581L, 0x37C2DADCL, -			 0xC8B57634L, 0x9AF3DDA7L, 
0xA9446146L, -			 0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L, -			 
0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, -			 0x183EB331L, 
0x4E548B38L, 0x4F6DB908L, -			 0x6F420D03L, 0xF60A04BFL, 
0x2CB81290L, -			 0x24977C79L, 0x5679B072L, 0xBCAF89AFL, -			 
0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, -			 0xDCCF3F2EL, 
0x5512721FL, 0x2E6B7124L, -			 0x501ADDE6L, 0x9F84CD87L, 
0x7A584718L, -			 0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL, -			 
0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, -			 0xC464C3D2L, 
0xEF1C1847L, 0x3215D908L, -			 0xDD433B37L, 0x24C2BA16L, 
0x12A14D43L, -			 0x2A65C451L, 0x50940002L, 0x133AE4DDL, -			 
0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, -			 0x5F11199BL, 
0x043556F1L, 0xD7A3C76BL, -			 0x3C11183BL, 0x5924A509L, 
0xF28FE6EDL, -			 0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL, -			 
0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, -			 0x5A3E2AB3L, 
0x771FE71CL, 0x4E3D06FAL, -			 0x2965DCB9L, 0x99E71D0FL, 
0x803E89D6L, -			 0x5266C825L, 0x2E4CC978L, 0x9C10B36AL, -			 
0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, -			 0x1E0A2DF4L, 
0xF2F74EA7L, 0x361D2B3DL, -			 0x1939260FL, 0x19C27960L, 
0x5223A708L, -			 0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L, -			 
0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, -			 0x018CFF28L, 
0xC332DDEFL, 0xBE6C5AA5L, -			 0x65582185L, 0x68AB9802L, 
0xEECEA50FL, -			 0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L, -			 
0x1521B628L, 0x29076170L, 0xECDD4775L, -			 0x619F1510L, 
0x13CCA830L, 0xEB61BD96L, -			 0x0334FE1EL, 0xAA0363CFL, 
0xB5735C90L, -			 0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L, -			 
0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, -			 0xB2F3846EL, 
0x648B1EAFL, 0x19BDF0CAL, -			 0xA02369B9L, 0x655ABB50L, 
0x40685A32L, -			 0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L, -			 
0x9B540B19L, 0x875FA099L, 0x95F7997EL, -			 0x623D7DA8L, 
0xF837889AL, 0x97E32D77L, -			 0x11ED935FL, 0x16681281L, 
0x0E358829L, -			 0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L, -			 
0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, -			 0x1AC24696L, 
0xCDB30AEBL, 0x532E3054L, -			 0x8FD948E4L, 0x6DBC3128L, 
0x58EBF2EFL, -			 0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L, -			 
0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, -			 0x203E13E0L, 
0x45EEE2B6L, 0xA3AAABEAL, -			 0xDB6C4F15L, 0xFACB4FD0L, 
0xC742F442L, -			 0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L, -			 
0xD81E799EL, 0x86854DC7L, 0xE44B476AL, -			 0x3D816250L, 
0xCF62A1F2L, 0x5B8D2646L, -			 0xFC8883A0L, 0xC1C7B6A3L, 
0x7F1524C3L, -			 0x69CB7492L, 0x47848A0BL, 0x5692B285L, -			 
0x095BBF00L, 0xAD19489DL, 0x1462B174L, -			 0x23820E00L, 
0x58428D2AL, 0x0C55F5EAL, -			 0x1DADF43EL, 0x233F7061L, 
0x3372F092L, -			 0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL, -			 
0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, -			 0xCE77326EL, 
0xA6078084L, 0x19F8509EL, -			 0xE8EFD855L, 0x61D99735L, 
0xA969A7AAL, -			 0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL, -			 
0x9E447A2EL, 0xC3453484L, 0xFDD56705L, -			 0x0E1E9EC9L, 
0xDB73DBD3L, 0x105588CDL, -			 0x675FDA79L, 0xE3674340L, 
0xC5C43465L, -			 0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L, -			 
0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, -			 0xDB83ADF7L}, 
{0xE93D5A68L, 0x948140F7L, -					 0xF64C261CL, 0x94692934L, -					 
0x411520F7L, 0x7602D4F7L, -					 0xBCF46B2EL, 0xD4A20068L, -					 
0xD4082471L, 0x3320F46AL, -					 0x43B7D4B7L, 0x500061AFL, -					 
0x1E39F62EL, 0x97244546L, -					 0x14214F74L, 0xBF8B8840L, -					 
0x4D95FC1DL, 0x96B591AFL, -					 0x70F4DDD3L, 0x66A02F45L, -					 
0xBFBC09ECL, 0x03BD9785L, -					 0x7FAC6DD0L, 0x31CB8504L, -					 
0x96EB27B3L, 0x55FD3941L, -					 0xDA2547E6L, 0xABCA0A9AL, -					 
0x28507825L, 0x530429F4L, -					 0x0A2C86DAL, 0xE9B66DFBL, -					 
0x68DC1462L, 0xD7486900L, -					 0x680EC0A4L, 0x27A18DEEL, -					 
0x4F3FFEA2L, 0xE887AD8CL, -					 0xB58CE006L, 0x7AF4D6B6L, -					 
0xAACE1E7CL, 0xD3375FECL, -					 0xCE78A399L, 0x406B2A42L, -					 
0x20FE9E35L, 0xD9F385B9L, -					 0xEE39D7ABL, 0x3B124E8BL, -					 
0x1DC9FAF7L, 0x4B6D1856L, -					 0x26A36631L, 0xEAE397B2L, -					 
0x3A6EFA74L, 0xDD5B4332L, -					 0x6841E7F7L, 0xCA7820FBL, -					 
0xFB0AF54EL, 0xD8FEB397L, -					 0x454056ACL, 0xBA489527L, -					 
0x55533A3AL, 0x20838D87L, -					 0xFE6BA9B7L, 0xD096954BL, -					 
0x55A867BCL, 0xA1159A58L, -					 0xCCA92963L, 0x99E1DB33L, -					 
0xA62A4A56L, 0x3F3125F9L, -					 0x5EF47E1CL, 0x9029317CL, -					 
0xFDF8E802L, 0x04272F70L, -					 0x80BB155CL, 0x05282CE3L, -					 
0x95C11548L, 0xE4C66D22L, -					 0x48C1133FL, 0xC70F86DCL, -					 
0x07F9C9EEL, 0x41041F0FL, -					 0x404779A4L, 0x5D886E17L, -					 
0x325F51EBL, 0xD59BC0D1L, -					 0xF2BCC18FL, 0x41113564L, -					 
0x257B7834L, 0x602A9C60L, -					 0xDFF8E8A3L, 0x1F636C1BL, -					 
0x0E12B4C2L, 0x02E1329EL, -					 0xAF664FD1L, 0xCAD18115L, -					 
0x6B2395E0L, 0x333E92E1L, -					 0x3B240B62L, 0xEEBEB922L, -					 
0x85B2A20EL, 0xE6BA0D99L, -					 0xDE720C8CL, 0x2DA2F728L, -					 
0xD0127845L, 0x95B794FDL, -					 0x647D0862L, 0xE7CCF5F0L, -					 
0x5449A36FL, 0x877D48FAL, -					 0xC39DFD27L, 0xF33E8D1EL, -					 
0x0A476341L, 0x992EFF74L, -					 0x3A6F6EABL, 0xF4F8FD37L, -					 
0xA812DC60L, 0xA1EBDDF8L, -					 0x991BE14CL, 0xDB6E6B0DL, -					 
0xC67B5510L, 0x6D672C37L, -					 0x2765D43BL, 0xDCD0E804L, -					 
0xF1290DC7L, 0xCC00FFA3L, -					 0xB5390F92L, 0x690FED0BL, -					 
0x667B9FFBL, 0xCEDB7D9CL, -					 0xA091CF0BL, 0xD9155EA3L, -					 
0xBB132F88L, 0x515BAD24L, -					 0x7B9479BFL, 0x763BD6EBL, -					 
0x37392EB3L, 0xCC115979L, -					 0x8026E297L, 0xF42E312DL, -					 
0x6842ADA7L, 0xC66A2B3BL, -					 0x12754CCCL, 0x782EF11CL, -					 
0x6A124237L, 0xB79251E7L, -					 0x06A1BBE6L, 0x4BFB6350L, -					 
0x1A6B1018L, 0x11CAEDFAL, -					 0x3D25BDD8L, 0xE2E1C3C9L, -					 
0x44421659L, 0x0A121386L, -					 0xD90CEC6EL, 0xD5ABEA2AL, -					 
0x64AF674EL, 0xDA86A85FL, -					 0xBEBFE988L, 0x64E4C3FEL, -					 
0x9DBC8057L, 0xF0F7C086L, -					 0x60787BF8L, 0x6003604DL, -					 
0xD1FD8346L, 0xF6381FB0L, -					 0x7745AE04L, 0xD736FCCCL, -					 
0x83426B33L, 0xF01EAB71L, -					 0xB0804187L, 0x3C005E5FL, -					 
0x77A057BEL, 0xBDE8AE24L, -					 0x55464299L, 0xBF582E61L, -					 
0x4E58F48FL, 0xF2DDFDA2L, -					 0xF474EF38L, 0x8789BDC2L, -					 
0x5366F9C3L, 0xC8B38E74L, -					 0xB475F255L, 0x46FCD9B9L, -					 
0x7AEB2661L, 0x8B1DDF84L, -					 0x846A0E79L, 0x915F95E2L, -					 
0x466E598EL, 0x20B45770L, -					 0x8CD55591L, 0xC902DE4CL, -					 
0xB90BACE1L, 0xBB8205D0L, -					 0x11A86248L, 0x7574A99EL, -					 
0xB77F19B6L, 0xE0A9DC09L, -					 0x662D09A1L, 0xC4324633L, -					 
0xE85A1F02L, 0x09F0BE8CL, -					 0x4A99A025L, 0x1D6EFE10L, -					 
0x1AB93D1DL, 0x0BA5A4DFL, -					 0xA186F20FL, 0x2868F169L, -					 
0xDCB7DA83L, 0x573906FEL, -					 0xA1E2CE9BL, 0x4FCD7F52L, -					 
0x50115E01L, 0xA70683FAL, -					 0xA002B5C4L, 0x0DE6D027L, -					 
0x9AF88C27L, 0x773F8641L, -					 0xC3604C06L, 0x61A806B5L, -					 
0xF0177A28L, 0xC0F586E0L, -					 0x006058AAL, 0x30DC7D62L, -					 
0x11E69ED7L, 0x2338EA63L, -					 0x53C2DD94L, 0xC2C21634L, -					 
0xBBCBEE56L, 0x90BCB6DEL, -					 0xEBFC7DA1L, 0xCE591D76L, -					 
0x6F05E409L, 0x4B7C0188L, -					 0x39720A3DL, 0x7C927C24L, -					 
0x86E3725FL, 0x724D9DB9L, -					 0x1AC15BB4L, 0xD39EB8FCL, -					 
0xED545578L, 0x08FCA5B5L, -					 0xD83D7CD3L, 0x4DAD0FC4L, -					 
0x1E50EF5EL, 0xB161E6F8L, -					 0xA28514D9L, 0x6C51133CL, -					 
0x6FD5C7E7L, 0x56E14EC4L, -					 0x362ABFCEL, 0xDDC6C837L, -					 
0xD79A3234L, 0x92638212L, -					 0x670EFA8EL, 0x406000E0L}, -    
{0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL, 
0x5CB0679EL, -      0x4FA33742L, 0xD3822740L, 0x99BC9BBEL, 
0xD5118E9DL, 0xBF0F7315L, -      0xD62D1C7EL, 0xC700C47BL, 
0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, -      0x6A366EB4L, 
0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L, -      
0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L, 
0x2939BBDBL, -      0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L, 
0xA1FAD5F0L, 0x6A2D519AL, -      0x63EF8CE2L, 0x9A86EE22L, 
0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, -      0x9CF2D0A4L, 
0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L, -      
0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L, 
0xC72FEFD3L, -      0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L, 
0x80E4A915L, 0x87B08601L, -      0x9B09E6ADL, 0x3B3EE593L, 
0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, -      0x022B8B51L, 
0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L, -      
0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL, 
0xE029AC71L, -      0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL, 
0xE8D3C48DL, 0x283B57CCL, -      0xF8D56629L, 0x79132E28L, 
0x785F0191L, 0xED756055L, 0xF7960E44L, -      0xE3D35E8CL, 
0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL, -      
0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL, 
0x1B3F6D9BL, -      0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L, 
0x7533D928L, 0xB155FDF5L, -      0x03563482L, 0x8ABA3CBBL, 
0x28517711L, 0xC20AD9F8L, 0xABCC5167L, -      0xCCAD925FL, 
0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L, -      
0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L, 
0xA8B6E37EL, -      0xC3293D46L, 0x48DE5369L, 0x6413E680L, 
0xA2AE0810L, 0xDD6DB224L, -      0x69852DFDL, 0x09072166L, 
0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, -      0x1C20C8AEL, 
0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL, -      
0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L, 
0x72EACEA8L, -      0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L, 
0xD29BE463L, 0x542F5D9EL, -      0xAEC2771BL, 0xF64E6370L, 
0x740E0D8DL, 0xE75B1357L, 0xF8721671L, -      0xAF537D5DL, 
0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L, -      
0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L, 
0x6F3F3B82L, -      0x3520AB82L, 0x011A1D4BL, 0x277227F8L, 
0x611560B1L, 0xE7933FDCL, -      0xBB3A792BL, 0x344525BDL, 
0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, -      0xA01FBAC9L, 
0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L, -      
0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L, 
0x0339C32AL, -      0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL, 
0xF79E59B7L, 0x43F5BB3AL, -      0xF2D519FFL, 0x27D9459CL, 
0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, -      0x9B941525L, 
0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L, -      
0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L, 
0xE0EC6E0EL, -      0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L, 
0x9F1F9532L, 0xE0D392DFL, -      0xD3A0342BL, 0x8971F21EL, 
0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, -      0xC37632D8L, 
0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL, -      
0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL, 
0x1618B166L, -      0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L, 
0xF523F357L, 0xA6327623L, -      0x93A83531L, 0x56CCCD02L, 
0xACF08162L, 0x5A75EBB5L, 0x6E163697L, -      0x88D273CCL, 
0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L, -      
0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, 
0xC9AA53FDL, -      0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, 
0x71126905L, 0xB2040222L, -      0xB6CBCF7CL, 0xCD769C2BL, 
0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, -      0x2547ADF0L, 
0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, -      
0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, 
0x1948C25CL, -      0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, 
0x90D4F869L, 0xA65CDEA0L, -      0x3F09252DL, 0xC208E69FL, 
0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, -      0x3AC372E6L} 
 + +static const unsigned long ORIG_S[4][256] = { 
 +	{0xD1310BA6L, 0x98DFB5ACL, 0x2FFD72DBL, 0xD01ADFB7L, 0xB8E1AFEDL, +	 0x6A267E96L, 0xBA7C9045L, 0xF12C7F99L, 0x24A19947L, 0xB3916CF7L, +	 0x0801F2E2L, 0x858EFC16L, 0x636920D8L, 0x71574E69L, 0xA458FEA3L, +	 0xF4933D7EL, 0x0D95748FL, 0x728EB658L, 0x718BCD58L, 0x82154AEEL, +	 0x7B54A41DL, 0xC25A59B5L, 0x9C30D539L, 0x2AF26013L, 0xC5D1B023L, +	 0x286085F0L, 0xCA417918L, 0xB8DB38EFL, 0x8E79DCB0L, 0x603A180EL, +	 0x6C9E0E8BL, 0xB01E8A3EL, 0xD71577C1L, 0xBD314B27L, 0x78AF2FDAL, +	 0x55605C60L, 0xE65525F3L, 0xAA55AB94L, 0x57489862L, 0x63E81440L, +	 0x55CA396AL, 0x2AAB10B6L, 0xB4CC5C34L, 0x1141E8CEL, 0xA15486AFL, +	 0x7C72E993L, 0xB3EE1411L, 0x636FBC2AL, 0x2BA9C55DL, 0x741831F6L, +	 0xCE5C3E16L, 0x9B87931EL, 0xAFD6BA33L, 0x6C24CF5CL, 0x7A325381L, +	 0x28958677L, 0x3B8F4898L, 0x6B4BB9AFL, 0xC4BFE81BL, 0x66282193L, +	 0x61D809CCL, 0xFB21A991L, 0x487CAC60L, 0x5DEC8032L, 0xEF845D5DL, +	 0xE98575B1L, 0xDC262302L, 0xEB651B88L, 0x23893E81L, 0xD396ACC5L, +	 0x0F6D6FF3L, 0x83F44239L, 0x2E0B4482L, 0xA4842004L, 0x69C8F04AL, +	 0x9E1F9B5EL, 0x21C66842L, 0xF6E96C9AL, 0x670C9C61L, 0xABD388F0L, +	 0x6A51A0D2L, 0xD8542F68L, 0x960FA728L, 0xAB5133A3L, 0x6EEF0B6CL, +	 0x137A3BE4L, 0xBA3BF050L, 0x7EFB2A98L, 0xA1F1651DL, 0x39AF0176L, +	 0x66CA593EL, 0x82430E88L, 0x8CEE8619L, 0x456F9FB4L, 0x7D84A5C3L, +	 0x3B8B5EBEL, 0xE06F75D8L, 0x85C12073L, 0x401A449FL, 0x56C16AA6L, +	 0x4ED3AA62L, 0x363F7706L, 0x1BFEDF72L, 0x429B023DL, 0x37D0D724L, +	 0xD00A1248L, 0xDB0FEAD3L, 0x49F1C09BL, 0x075372C9L, 0x80991B7BL, +	 0x25D479D8L, 0xF6E8DEF7L, 0xE3FE501AL, 0xB6794C3BL, 0x976CE0BDL, +	 0x04C006BAL, 0xC1A94FB6L, 0x409F60C4L, 0x5E5C9EC2L, 0x196A2463L, +	 0x68FB6FAFL, 0x3E6C53B5L, 0x1339B2EBL, 0x3B52EC6FL, 0x6DFC511FL, +	 0x9B30952CL, 0xCC814544L, 0xAF5EBD09L, 0xBEE3D004L, 0xDE334AFDL, +	 0x660F2807L, 0x192E4BB3L, 0xC0CBA857L, 0x45C8740FL, 0xD20B5F39L, +	 0xB9D3FBDBL, 0x5579C0BDL, 0x1A60320AL, 0xD6A100C6L, 0x402C7279L, +	 0x679F25FEL, 0xFB1FA3CCL, 0x8EA5E9F8L, 0xDB3222F8L, 0x3C7516DFL, +	 0xFD616B15L, 0x2F501EC8L, 0xAD0552ABL, 0x323DB5FAL, 0xFD238760L, +	 0x53317B48L, 0x3E00DF82L, 0x9E5C57BBL, 0xCA6F8CA0L, 0x1A87562EL, +	 0xDF1769DBL, 0xD542A8F6L, 0x287EFFC3L, 0xAC6732C6L, 0x8C4F5573L, +	 0x695B27B0L, 0xBBCA58C8L, 0xE1FFA35DL, 0xB8F011A0L, 0x10FA3D98L, +	 0xFD2183B8L, 0x4AFCB56CL, 0x2DD1D35BL, 0x9A53E479L, 0xB6F84565L, +	 0xD28E49BCL, 0x4BFB9790L, 0xE1DDF2DAL, 0xA4CB7E33L, 0x62FB1341L, +	 0xCEE4C6E8L, 0xEF20CADAL, 0x36774C01L, 0xD07E9EFEL, 0x2BF11FB4L, +	 0x95DBDA4DL, 0xAE909198L, 0xEAAD8E71L, 0x6B93D5A0L, 0xD08ED1D0L, +	 0xAFC725E0L, 0x8E3C5B2FL, 0x8E7594B7L, 0x8FF6E2FBL, 0xF2122B64L, +	 0x8888B812L, 0x900DF01CL, 0x4FAD5EA0L, 0x688FC31CL, 0xD1CFF191L, +	 0xB3A8C1ADL, 0x2F2F2218L, 0xBE0E1777L, 0xEA752DFEL, 0x8B021FA1L, +	 0xE5A0CC0FL, 0xB56F74E8L, 0x18ACF3D6L, 0xCE89E299L, 0xB4A84FE0L, +	 0xFD13E0B7L, 0x7CC43B81L, 0xD2ADA8D9L, 0x165FA266L, 0x80957705L, +	 0x93CC7314L, 0x211A1477L, 0xE6AD2065L, 0x77B5FA86L, 0xC75442F5L, +	 0xFB9D35CFL, 0xEBCDAF0CL, 0x7B3E89A0L, 0xD6411BD3L, 0xAE1E7E49L, +	 0x00250E2DL, 0x2071B35EL, 0x226800BBL, 0x57B8E0AFL, 0x2464369BL, +	 0xF009B91EL, 0x5563911DL, 0x59DFA6AAL, 0x78C14389L, 0xD95A537FL, +	 0x207D5BA2L, 0x02E5B9C5L, 0x83260376L, 0x6295CFA9L, 0x11C81968L, +	 0x4E734A41L, 0xB3472DCAL, 0x7B14A94AL, 0x1B510052L, 0x9A532915L, +	 0xD60F573FL, 0xBC9BC6E4L, 0x2B60A476L, 0x81E67400L, 0x08BA6FB5L, +	 0x571BE91FL, 0xF296EC6BL, 0x2A0DD915L, 0xB6636521L, 0xE7B9F9B6L, +	 0xFF34052EL, 0xC5855664L, 0x53B02D5DL, 0xA99F8FA1L, 0x08BA4799L, +	 0x6E85076AL}, {0x4B7A70E9L, 0xB5B32944L, 0xDB75092EL, +			0xC4192623L, 0xAD6EA6B0L, 0x49A7DF7DL, +			0x9CEE60B8L, 0x8FEDB266L, 0xECAA8C71L, +			0x699A17FFL, 0x5664526CL, 0xC2B19EE1L, +			0x193602A5L, 0x75094C29L, 0xA0591340L, +			0xE4183A3EL, 0x3F54989AL, 0x5B429D65L, +			0x6B8FE4D6L, 0x99F73FD6L, 0xA1D29C07L, +			0xEFE830F5L, 0x4D2D38E6L, 0xF0255DC1L, +			0x4CDD2086L, 0x8470EB26L, 0x6382E9C6L, +			0x021ECC5EL, 0x09686B3FL, 0x3EBAEFC9L, +			0x3C971814L, 0x6B6A70A1L, 0x687F3584L, +			0x52A0E286L, 0xB79C5305L, 0xAA500737L, +			0x3E07841CL, 0x7FDEAE5CL, 0x8E7D44ECL, +			0x5716F2B8L, 0xB03ADA37L, 0xF0500C0DL, +			0xF01C1F04L, 0x0200B3FFL, 0xAE0CF51AL, +			0x3CB574B2L, 0x25837A58L, 0xDC0921BDL, +			0xD19113F9L, 0x7CA92FF6L, 0x94324773L, +			0x22F54701L, 0x3AE5E581L, 0x37C2DADCL, +			0xC8B57634L, 0x9AF3DDA7L, 0xA9446146L, +			0x0FD0030EL, 0xECC8C73EL, 0xA4751E41L, +			0xE238CD99L, 0x3BEA0E2FL, 0x3280BBA1L, +			0x183EB331L, 0x4E548B38L, 0x4F6DB908L, +			0x6F420D03L, 0xF60A04BFL, 0x2CB81290L, +			0x24977C79L, 0x5679B072L, 0xBCAF89AFL, +			0xDE9A771FL, 0xD9930810L, 0xB38BAE12L, +			0xDCCF3F2EL, 0x5512721FL, 0x2E6B7124L, +			0x501ADDE6L, 0x9F84CD87L, 0x7A584718L, +			0x7408DA17L, 0xBC9F9ABCL, 0xE94B7D8CL, +			0xEC7AEC3AL, 0xDB851DFAL, 0x63094366L, +			0xC464C3D2L, 0xEF1C1847L, 0x3215D908L, +			0xDD433B37L, 0x24C2BA16L, 0x12A14D43L, +			0x2A65C451L, 0x50940002L, 0x133AE4DDL, +			0x71DFF89EL, 0x10314E55L, 0x81AC77D6L, +			0x5F11199BL, 0x043556F1L, 0xD7A3C76BL, +			0x3C11183BL, 0x5924A509L, 0xF28FE6EDL, +			0x97F1FBFAL, 0x9EBABF2CL, 0x1E153C6EL, +			0x86E34570L, 0xEAE96FB1L, 0x860E5E0AL, +			0x5A3E2AB3L, 0x771FE71CL, 0x4E3D06FAL, +			0x2965DCB9L, 0x99E71D0FL, 0x803E89D6L, +			0x5266C825L, 0x2E4CC978L, 0x9C10B36AL, +			0xC6150EBAL, 0x94E2EA78L, 0xA5FC3C53L, +			0x1E0A2DF4L, 0xF2F74EA7L, 0x361D2B3DL, +			0x1939260FL, 0x19C27960L, 0x5223A708L, +			0xF71312B6L, 0xEBADFE6EL, 0xEAC31F66L, +			0xE3BC4595L, 0xA67BC883L, 0xB17F37D1L, +			0x018CFF28L, 0xC332DDEFL, 0xBE6C5AA5L, +			0x65582185L, 0x68AB9802L, 0xEECEA50FL, +			0xDB2F953BL, 0x2AEF7DADL, 0x5B6E2F84L, +			0x1521B628L, 0x29076170L, 0xECDD4775L, +			0x619F1510L, 0x13CCA830L, 0xEB61BD96L, +			0x0334FE1EL, 0xAA0363CFL, 0xB5735C90L, +			0x4C70A239L, 0xD59E9E0BL, 0xCBAADE14L, +			0xEECC86BCL, 0x60622CA7L, 0x9CAB5CABL, +			0xB2F3846EL, 0x648B1EAFL, 0x19BDF0CAL, +			0xA02369B9L, 0x655ABB50L, 0x40685A32L, +			0x3C2AB4B3L, 0x319EE9D5L, 0xC021B8F7L, +			0x9B540B19L, 0x875FA099L, 0x95F7997EL, +			0x623D7DA8L, 0xF837889AL, 0x97E32D77L, +			0x11ED935FL, 0x16681281L, 0x0E358829L, +			0xC7E61FD6L, 0x96DEDFA1L, 0x7858BA99L, +			0x57F584A5L, 0x1B227263L, 0x9B83C3FFL, +			0x1AC24696L, 0xCDB30AEBL, 0x532E3054L, +			0x8FD948E4L, 0x6DBC3128L, 0x58EBF2EFL, +			0x34C6FFEAL, 0xFE28ED61L, 0xEE7C3C73L, +			0x5D4A14D9L, 0xE864B7E3L, 0x42105D14L, +			0x203E13E0L, 0x45EEE2B6L, 0xA3AAABEAL, +			0xDB6C4F15L, 0xFACB4FD0L, 0xC742F442L, +			0xEF6ABBB5L, 0x654F3B1DL, 0x41CD2105L, +			0xD81E799EL, 0x86854DC7L, 0xE44B476AL, +			0x3D816250L, 0xCF62A1F2L, 0x5B8D2646L, +			0xFC8883A0L, 0xC1C7B6A3L, 0x7F1524C3L, +			0x69CB7492L, 0x47848A0BL, 0x5692B285L, +			0x095BBF00L, 0xAD19489DL, 0x1462B174L, +			0x23820E00L, 0x58428D2AL, 0x0C55F5EAL, +			0x1DADF43EL, 0x233F7061L, 0x3372F092L, +			0x8D937E41L, 0xD65FECF1L, 0x6C223BDBL, +			0x7CDE3759L, 0xCBEE7460L, 0x4085F2A7L, +			0xCE77326EL, 0xA6078084L, 0x19F8509EL, +			0xE8EFD855L, 0x61D99735L, 0xA969A7AAL, +			0xC50C06C2L, 0x5A04ABFCL, 0x800BCADCL, +			0x9E447A2EL, 0xC3453484L, 0xFDD56705L, +			0x0E1E9EC9L, 0xDB73DBD3L, 0x105588CDL, +			0x675FDA79L, 0xE3674340L, 0xC5C43465L, +			0x713E38D8L, 0x3D28F89EL, 0xF16DFF20L, +			0x153E21E7L, 0x8FB03D4AL, 0xE6E39F2BL, +			0xDB83ADF7L}, {0xE93D5A68L, 0x948140F7L, +				       0xF64C261CL, 0x94692934L, +				       0x411520F7L, 0x7602D4F7L, +				       0xBCF46B2EL, 0xD4A20068L, +				       0xD4082471L, 0x3320F46AL, +				       0x43B7D4B7L, 0x500061AFL, +				       0x1E39F62EL, 0x97244546L, +				       0x14214F74L, 0xBF8B8840L, +				       0x4D95FC1DL, 0x96B591AFL, +				       0x70F4DDD3L, 0x66A02F45L, +				       0xBFBC09ECL, 0x03BD9785L, +				       0x7FAC6DD0L, 0x31CB8504L, +				       0x96EB27B3L, 0x55FD3941L, +				       0xDA2547E6L, 0xABCA0A9AL, +				       0x28507825L, 0x530429F4L, +				       0x0A2C86DAL, 0xE9B66DFBL, +				       0x68DC1462L, 0xD7486900L, +				       0x680EC0A4L, 0x27A18DEEL, +				       0x4F3FFEA2L, 0xE887AD8CL, +				       0xB58CE006L, 0x7AF4D6B6L, +				       0xAACE1E7CL, 0xD3375FECL, +				       0xCE78A399L, 0x406B2A42L, +				       0x20FE9E35L, 0xD9F385B9L, +				       0xEE39D7ABL, 0x3B124E8BL, +				       0x1DC9FAF7L, 0x4B6D1856L, +				       0x26A36631L, 0xEAE397B2L, +				       0x3A6EFA74L, 0xDD5B4332L, +				       0x6841E7F7L, 0xCA7820FBL, +				       0xFB0AF54EL, 0xD8FEB397L, +				       0x454056ACL, 0xBA489527L, +				       0x55533A3AL, 0x20838D87L, +				       0xFE6BA9B7L, 0xD096954BL, +				       0x55A867BCL, 0xA1159A58L, +				       0xCCA92963L, 0x99E1DB33L, +				       0xA62A4A56L, 0x3F3125F9L, +				       0x5EF47E1CL, 0x9029317CL, +				       0xFDF8E802L, 0x04272F70L, +				       0x80BB155CL, 0x05282CE3L, +				       0x95C11548L, 0xE4C66D22L, +				       0x48C1133FL, 0xC70F86DCL, +				       0x07F9C9EEL, 0x41041F0FL, +				       0x404779A4L, 0x5D886E17L, +				       0x325F51EBL, 0xD59BC0D1L, +				       0xF2BCC18FL, 0x41113564L, +				       0x257B7834L, 0x602A9C60L, +				       0xDFF8E8A3L, 0x1F636C1BL, +				       0x0E12B4C2L, 0x02E1329EL, +				       0xAF664FD1L, 0xCAD18115L, +				       0x6B2395E0L, 0x333E92E1L, +				       0x3B240B62L, 0xEEBEB922L, +				       0x85B2A20EL, 0xE6BA0D99L, +				       0xDE720C8CL, 0x2DA2F728L, +				       0xD0127845L, 0x95B794FDL, +				       0x647D0862L, 0xE7CCF5F0L, +				       0x5449A36FL, 0x877D48FAL, +				       0xC39DFD27L, 0xF33E8D1EL, +				       0x0A476341L, 0x992EFF74L, +				       0x3A6F6EABL, 0xF4F8FD37L, +				       0xA812DC60L, 0xA1EBDDF8L, +				       0x991BE14CL, 0xDB6E6B0DL, +				       0xC67B5510L, 0x6D672C37L, +				       0x2765D43BL, 0xDCD0E804L, +				       0xF1290DC7L, 0xCC00FFA3L, +				       0xB5390F92L, 0x690FED0BL, +				       0x667B9FFBL, 0xCEDB7D9CL, +				       0xA091CF0BL, 0xD9155EA3L, +				       0xBB132F88L, 0x515BAD24L, +				       0x7B9479BFL, 0x763BD6EBL, +				       0x37392EB3L, 0xCC115979L, +				       0x8026E297L, 0xF42E312DL, +				       0x6842ADA7L, 0xC66A2B3BL, +				       0x12754CCCL, 0x782EF11CL, +				       0x6A124237L, 0xB79251E7L, +				       0x06A1BBE6L, 0x4BFB6350L, +				       0x1A6B1018L, 0x11CAEDFAL, +				       0x3D25BDD8L, 0xE2E1C3C9L, +				       0x44421659L, 0x0A121386L, +				       0xD90CEC6EL, 0xD5ABEA2AL, +				       0x64AF674EL, 0xDA86A85FL, +				       0xBEBFE988L, 0x64E4C3FEL, +				       0x9DBC8057L, 0xF0F7C086L, +				       0x60787BF8L, 0x6003604DL, +				       0xD1FD8346L, 0xF6381FB0L, +				       0x7745AE04L, 0xD736FCCCL, +				       0x83426B33L, 0xF01EAB71L, +				       0xB0804187L, 0x3C005E5FL, +				       0x77A057BEL, 0xBDE8AE24L, +				       0x55464299L, 0xBF582E61L, +				       0x4E58F48FL, 0xF2DDFDA2L, +				       0xF474EF38L, 0x8789BDC2L, +				       0x5366F9C3L, 0xC8B38E74L, +				       0xB475F255L, 0x46FCD9B9L, +				       0x7AEB2661L, 0x8B1DDF84L, +				       0x846A0E79L, 0x915F95E2L, +				       0x466E598EL, 0x20B45770L, +				       0x8CD55591L, 0xC902DE4CL, +				       0xB90BACE1L, 0xBB8205D0L, +				       0x11A86248L, 0x7574A99EL, +				       0xB77F19B6L, 0xE0A9DC09L, +				       0x662D09A1L, 0xC4324633L, +				       0xE85A1F02L, 0x09F0BE8CL, +				       0x4A99A025L, 0x1D6EFE10L, +				       0x1AB93D1DL, 0x0BA5A4DFL, +				       0xA186F20FL, 0x2868F169L, +				       0xDCB7DA83L, 0x573906FEL, +				       0xA1E2CE9BL, 0x4FCD7F52L, +				       0x50115E01L, 0xA70683FAL, +				       0xA002B5C4L, 0x0DE6D027L, +				       0x9AF88C27L, 0x773F8641L, +				       0xC3604C06L, 0x61A806B5L, +				       0xF0177A28L, 0xC0F586E0L, +				       0x006058AAL, 0x30DC7D62L, +				       0x11E69ED7L, 0x2338EA63L, +				       0x53C2DD94L, 0xC2C21634L, +				       0xBBCBEE56L, 0x90BCB6DEL, +				       0xEBFC7DA1L, 0xCE591D76L, +				       0x6F05E409L, 0x4B7C0188L, +				       0x39720A3DL, 0x7C927C24L, +				       0x86E3725FL, 0x724D9DB9L, +				       0x1AC15BB4L, 0xD39EB8FCL, +				       0xED545578L, 0x08FCA5B5L, +				       0xD83D7CD3L, 0x4DAD0FC4L, +				       0x1E50EF5EL, 0xB161E6F8L, +				       0xA28514D9L, 0x6C51133CL, +				       0x6FD5C7E7L, 0x56E14EC4L, +				       0x362ABFCEL, 0xDDC6C837L, +				       0xD79A3234L, 0x92638212L, +				       0x670EFA8EL, 0x406000E0L}, +{0x3A39CE37L, 0xD3FAF5CFL, 0xABC27737L, 0x5AC52D1BL, 0x5CB0679EL, + 0x4FA33742L, 0xD3822740L, 0x99BC9BBEL, 0xD5118E9DL, 0xBF0F7315L, + 0xD62D1C7EL, 0xC700C47BL, 0xB78C1B6BL, 0x21A19045L, 0xB26EB1BEL, + 0x6A366EB4L, 0x5748AB2FL, 0xBC946E79L, 0xC6A376D2L, 0x6549C2C8L, + 0x530FF8EEL, 0x468DDE7DL, 0xD5730A1DL, 0x4CD04DC6L, 0x2939BBDBL, + 0xA9BA4650L, 0xAC9526E8L, 0xBE5EE304L, 0xA1FAD5F0L, 0x6A2D519AL, + 0x63EF8CE2L, 0x9A86EE22L, 0xC089C2B8L, 0x43242EF6L, 0xA51E03AAL, + 0x9CF2D0A4L, 0x83C061BAL, 0x9BE96A4DL, 0x8FE51550L, 0xBA645BD6L, + 0x2826A2F9L, 0xA73A3AE1L, 0x4BA99586L, 0xEF5562E9L, 0xC72FEFD3L, + 0xF752F7DAL, 0x3F046F69L, 0x77FA0A59L, 0x80E4A915L, 0x87B08601L, + 0x9B09E6ADL, 0x3B3EE593L, 0xE990FD5AL, 0x9E34D797L, 0x2CF0B7D9L, + 0x022B8B51L, 0x96D5AC3AL, 0x017DA67DL, 0xD1CF3ED6L, 0x7C7D2D28L, + 0x1F9F25CFL, 0xADF2B89BL, 0x5AD6B472L, 0x5A88F54CL, 0xE029AC71L, + 0xE019A5E6L, 0x47B0ACFDL, 0xED93FA9BL, 0xE8D3C48DL, 0x283B57CCL, + 0xF8D56629L, 0x79132E28L, 0x785F0191L, 0xED756055L, 0xF7960E44L, + 0xE3D35E8CL, 0x15056DD4L, 0x88F46DBAL, 0x03A16125L, 0x0564F0BDL, + 0xC3EB9E15L, 0x3C9057A2L, 0x97271AECL, 0xA93A072AL, 0x1B3F6D9BL, + 0x1E6321F5L, 0xF59C66FBL, 0x26DCF319L, 0x7533D928L, 0xB155FDF5L, + 0x03563482L, 0x8ABA3CBBL, 0x28517711L, 0xC20AD9F8L, 0xABCC5167L, + 0xCCAD925FL, 0x4DE81751L, 0x3830DC8EL, 0x379D5862L, 0x9320F991L, + 0xEA7A90C2L, 0xFB3E7BCEL, 0x5121CE64L, 0x774FBE32L, 0xA8B6E37EL, + 0xC3293D46L, 0x48DE5369L, 0x6413E680L, 0xA2AE0810L, 0xDD6DB224L, + 0x69852DFDL, 0x09072166L, 0xB39A460AL, 0x6445C0DDL, 0x586CDECFL, + 0x1C20C8AEL, 0x5BBEF7DDL, 0x1B588D40L, 0xCCD2017FL, 0x6BB4E3BBL, + 0xDDA26A7EL, 0x3A59FF45L, 0x3E350A44L, 0xBCB4CDD5L, 0x72EACEA8L, + 0xFA6484BBL, 0x8D6612AEL, 0xBF3C6F47L, 0xD29BE463L, 0x542F5D9EL, + 0xAEC2771BL, 0xF64E6370L, 0x740E0D8DL, 0xE75B1357L, 0xF8721671L, + 0xAF537D5DL, 0x4040CB08L, 0x4EB4E2CCL, 0x34D2466AL, 0x0115AF84L, + 0xE1B00428L, 0x95983A1DL, 0x06B89FB4L, 0xCE6EA048L, 0x6F3F3B82L, + 0x3520AB82L, 0x011A1D4BL, 0x277227F8L, 0x611560B1L, 0xE7933FDCL, + 0xBB3A792BL, 0x344525BDL, 0xA08839E1L, 0x51CE794BL, 0x2F32C9B7L, + 0xA01FBAC9L, 0xE01CC87EL, 0xBCC7D1F6L, 0xCF0111C3L, 0xA1E8AAC7L, + 0x1A908749L, 0xD44FBD9AL, 0xD0DADECBL, 0xD50ADA38L, 0x0339C32AL, + 0xC6913667L, 0x8DF9317CL, 0xE0B12B4FL, 0xF79E59B7L, 0x43F5BB3AL, + 0xF2D519FFL, 0x27D9459CL, 0xBF97222CL, 0x15E6FC2AL, 0x0F91FC71L, + 0x9B941525L, 0xFAE59361L, 0xCEB69CEBL, 0xC2A86459L, 0x12BAA8D1L, + 0xB6C1075EL, 0xE3056A0CL, 0x10D25065L, 0xCB03A442L, 0xE0EC6E0EL, + 0x1698DB3BL, 0x4C98A0BEL, 0x3278E964L, 0x9F1F9532L, 0xE0D392DFL, + 0xD3A0342BL, 0x8971F21EL, 0x1B0A7441L, 0x4BA3348CL, 0xC5BE7120L, + 0xC37632D8L, 0xDF359F8DL, 0x9B992F2EL, 0xE60B6F47L, 0x0FE3F11DL, + 0xE54CDA54L, 0x1EDAD891L, 0xCE6279CFL, 0xCD3E7E6FL, 0x1618B166L, + 0xFD2C1D05L, 0x848FD2C5L, 0xF6FB2299L, 0xF523F357L, 0xA6327623L, + 0x93A83531L, 0x56CCCD02L, 0xACF08162L, 0x5A75EBB5L, 0x6E163697L, + 0x88D273CCL, 0xDE966292L, 0x81B949D0L, 0x4C50901BL, 0x71C65614L, + 0xE6C6C7BDL, 0x327A140AL, 0x45E1D006L, 0xC3F27B9AL, 0xC9AA53FDL, + 0x62A80F00L, 0xBB25BFE2L, 0x35BDD2F6L, 0x71126905L, 0xB2040222L, + 0xB6CBCF7CL, 0xCD769C2BL, 0x53113EC0L, 0x1640E3D3L, 0x38ABBD60L, + 0x2547ADF0L, 0xBA38209CL, 0xF746CE76L, 0x77AFA1C5L, 0x20756060L, + 0x85CBFE4EL, 0x8AE88DD8L, 0x7AAAF9B0L, 0x4CF9AA7EL, 0x1948C25CL, + 0x02FB8A8CL, 0x01C36AE4L, 0xD6EBE1F9L, 0x90D4F869L, 0xA65CDEA0L, + 0x3F09252DL, 0xC208E69FL, 0xB74E6132L, 0xCE77E25BL, 0x578FDFE3L, + 0x3AC372E6L} 
  }; -
static unsigned long F(BLOWFISH_CTX * ctx, unsigned long x) + +static unsigned long F(BLOWFISH_CTX * ctx, unsigned long x)  { -    
unsigned short a, b, c, d; -    
unsigned long y; -    
d = (unsigned short) (x & 0xFF); -    
x >>= 8; -    
c = (unsigned short) (x & 0xFF); -    
x >>= 8; -    
b = (unsigned short) (x & 0xFF); -    
x >>= 8; -    
a = (unsigned short) (x & 0xFF); -    
y = ctx->S[0][a] + ctx->S[1][b]; -    
y = y ^ ctx->S[2][c]; -    
y = y + ctx->S[3][d]; -    
return y; -
} -
void Blowfish_Encrypt(BLOWFISH_CTX * ctx, unsigned long *xl, -			 unsigned long *xr) +    unsigned short a, b, c, d; +    unsigned long y; +    d = (unsigned short) (x & 0xFF); +    x >>= 8; +    c = (unsigned short) (x & 0xFF); +    x >>= 8; +    b = (unsigned short) (x & 0xFF); +    x >>= 8; +    a = (unsigned short) (x & 0xFF); +    y = ctx->S[0][a] + ctx->S[1][b]; +    y = y ^ ctx->S[2][c]; +    y = y + ctx->S[3][d]; +    return y; +} + +void Blowfish_Encrypt(BLOWFISH_CTX * ctx, unsigned long *xl, +		      unsigned long *xr)  { -    
unsigned long Xl; -    
unsigned long Xr; -    
unsigned long temp; -    
short i; -    
Xl = *xl; -    
Xr = *xr; -    
for (i = 0; i < N; ++i) { -	
Xl = Xl ^ ctx->P[i]; -	
Xr = F(ctx, Xl) ^ Xr; -	
temp = Xl; -	
Xl = Xr; -	
Xr = temp; -    
} -    
temp = Xl; -    
Xl = Xr; -    
Xr = temp; -    
Xr = Xr ^ ctx->P[N]; -    
Xl = Xl ^ ctx->P[N + 1]; -    
*xl = Xl; -    
*xr = Xr; -
} -
void Blowfish_Decrypt(BLOWFISH_CTX * ctx, unsigned long *xl, -			 unsigned long *xr) +    unsigned long Xl; +    unsigned long Xr; +    unsigned long temp; +    short i; +    Xl = *xl; +    Xr = *xr; +    for (i = 0; i < N; ++i) { +	Xl = Xl ^ ctx->P[i]; +	Xr = F(ctx, Xl) ^ Xr; +	temp = Xl; +	Xl = Xr; +	Xr = temp; +    } +    temp = Xl; +    Xl = Xr; +    Xr = temp; +    Xr = Xr ^ ctx->P[N]; +    Xl = Xl ^ ctx->P[N + 1]; +    *xl = Xl; +    *xr = Xr; +} + +void Blowfish_Decrypt(BLOWFISH_CTX * ctx, unsigned long *xl, +		      unsigned long *xr)  { -    
unsigned long Xl; -    
unsigned long Xr; -    
unsigned long temp; -    
short i; -    
Xl = *xl; -    
Xr = *xr; -    
for (i = N + 1; i > 1; --i) { -	
Xl = Xl ^ ctx->P[i]; -	
Xr = F(ctx, Xl) ^ Xr; -	
 +    unsigned long Xl; +    unsigned long Xr; +    unsigned long temp; +    short i; +    Xl = *xl; +    Xr = *xr; +    for (i = N + 1; i > 1; --i) { +	Xl = Xl ^ ctx->P[i]; +	Xr = F(ctx, Xl) ^ Xr; +	
  	    /* Exchange Xl and Xr */ 
  	    temp = Xl; -	
Xl = Xr; -	
Xr = temp; -    
} -    
 +	Xl = Xr; +	Xr = temp; +    } +    
  	/* Exchange Xl and Xr */ 
  	temp = Xl; -    
Xl = Xr; -    
Xr = temp; -    
Xr = Xr ^ ctx->P[1]; -    
Xl = Xl ^ ctx->P[0]; -    
*xl = Xl; -    
*xr = Xr; -
} -
void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char *key, int keyLen) +    Xl = Xr; +    Xr = temp; +    Xr = Xr ^ ctx->P[1]; +    Xl = Xl ^ ctx->P[0]; +    *xl = Xl; +    *xr = Xr; +} + +void Blowfish_Init(BLOWFISH_CTX * ctx, unsigned char *key, int keyLen)  { -    
int i, j, k; -    
unsigned long data, datal, datar; -    
for (i = 0; i < 4; i++) { -	
for (j = 0; j < 256; j++) -	    
ctx->S[i][j] = ORIG_S[i][j]; -    
} -    
j = 0; -    
for (i = 0; i < N + 2; ++i) { -	
data = 0x00000000; -	
for (k = 0; k < 4; ++k) { -	    
data = (data << 8) | key[j]; -	    
j = j + 1; -	    
if (j >= keyLen) -		
j = 0; -	
} -	
ctx->P[i] = ORIG_P[i] ^ data; -    
} -    
datal = 0x00000000; -    
datar = 0x00000000; -    
for (i = 0; i < N + 2; i += 2) { -	
Blowfish_Encrypt(ctx, &datal, &datar); -	
ctx->P[i] = datal; -	
ctx->P[i + 1] = datar; -    
} -    
for (i = 0; i < 4; ++i) { -	
for (j = 0; j < 256; j += 2) { -	    
Blowfish_Encrypt(ctx, &datal, &datar); -	    
ctx->S[i][j] = datal; -	    
ctx->S[i][j + 1] = datar; -	
} -    
} -
} +    int i, j, k; +    unsigned long data, datal, datar; +    for (i = 0; i < 4; i++) { +	for (j = 0; j < 256; j++) +	    ctx->S[i][j] = ORIG_S[i][j]; +    } +    j = 0; +    for (i = 0; i < N + 2; ++i) { +	data = 0x00000000; +	for (k = 0; k < 4; ++k) { +	    data = (data << 8) | key[j]; +	    j = j + 1; +	    if (j >= keyLen) +		j = 0; +	} +	ctx->P[i] = ORIG_P[i] ^ data; +    } +    datal = 0x00000000; +    datar = 0x00000000; +    for (i = 0; i < N + 2; i += 2) { +	Blowfish_Encrypt(ctx, &datal, &datar); +	ctx->P[i] = datal; +	ctx->P[i + 1] = datar; +    } +    for (i = 0; i < 4; ++i) { +	for (j = 0; j < 256; j += 2) { +	    Blowfish_Encrypt(ctx, &datal, &datar); +	    ctx->S[i][j] = datal; +	    ctx->S[i][j + 1] = datar; +	} +    } +} -
 +
 diff --git a/callbacks.c b/callbacks.c index 32db0791..40ee07bc 100644 --- a/callbacks.c +++ b/callbacks.c @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2009 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -195,20 +195,25 @@ void cb_about()  	"",  	"Contributors:",  	"Agney Lopes Roth Ferraz", -	"SCSI support by Pascal F. Martin", +	"Andrey Esin",  	"",  	"Based on work by:",  	"MD5 implementation by Colin Plumb (see md5.c for details)", -	"SHA1 implementation by Steve Raid (see sha1.c for details)", +	"SHA1 implementation by Steve Reid (see sha1.c for details)",  	"Blowfish implementation by Paul Kocher (see blowfich.c for details)",  	"Raytracing benchmark by John Walker (see fbench.c for details)", +	"FFT benchmark by Scott Robert Ladd (see fftbench.c for details)",  	"Some code partly based on x86cpucaps by Osamu Kayasono",  	"Vendor list based on GtkSysInfo by Pissens Sebastien", +	"DMI support based on code by Stewart Adam", +	"SCSI support based on code by Pascal F. Martin",  	NULL      };      const gchar *artists[] = { -	"The GNOME Project", +	"Jakub Szypulka",  	"Tango Project", +	"The GNOME Project", +	"VMWare, Inc. (USB icon from VMWare Workstation 6)",  	NULL      }; @@ -216,7 +221,7 @@ void cb_about()      gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about), "HardInfo");      gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about), VERSION);      gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about), -				   "Copyright \302\251 2003-2007 " +				   "Copyright \302\251 2003-2009 "  				   "Leandro A. F. Pereira");      gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about),  				  "System information and benchmark tool"); diff --git a/callbacks.h b/callbacks.h index 0387df05..88165f97 100644 --- a/callbacks.h +++ b/callbacks.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -31,19 +31,6 @@  #include <vendor.h> -enum { -    COMPUTER_SUMMARY, -    COMPUTER_OPERATING_SYSTEM, -    COMPUTER_KERNEL_MODULES, -    COMPUTER_BOOTS, -    COMPUTER_LANGUAGE, -    COMPUTER_FILESYSTEMS, -    COMPUTER_SHARES, -    COMPUTER_DISPLAY, -    COMPUTER_NETWORK, -    COMPUTER_USERS, -} Entries; -  /* Callbacks */  gchar *callback_summary();  gchar *callback_os(); @@ -51,10 +38,10 @@ gchar *callback_modules();  gchar *callback_boots();  gchar *callback_locales();  gchar *callback_fs(); -gchar *callback_shares();  gchar *callback_display();  gchar *callback_network();  gchar *callback_users(); +gchar *callback_env_var();  /* Scan callbacks */  void scan_summary(gboolean reload); @@ -63,10 +50,10 @@ void scan_modules(gboolean reload);  void scan_boots(gboolean reload);  void scan_locales(gboolean reload);  void scan_fs(gboolean reload); -void scan_shares(gboolean reload);  void scan_display(gboolean reload);  void scan_network(gboolean reload);  void scan_users(gboolean reload); +void scan_env_var(gboolean reload);  static ModuleEntry entries[] = {      {"Summary", "summary.png", callback_summary, scan_summary}, @@ -75,9 +62,8 @@ static ModuleEntry entries[] = {      {"Boots", "boot.png", callback_boots, scan_boots},      {"Languages", "language.png", callback_locales, scan_locales},      {"Filesystems", "dev_removable.png", callback_fs, scan_fs}, -    {"Shared Directories", "shares.png", callback_shares, scan_shares},      {"Display", "monitor.png", callback_display, scan_display}, -    {"Network Interfaces", "network.png", callback_network, scan_network}, +    {"Environment Variables", "environment.png", callback_env_var, scan_env_var},      {"Users", "users.png", callback_users, scan_users},      {NULL},  }; @@ -97,11 +83,9 @@ static Computer *computer = NULL;  #include <arch/this/uptime.h>  #include <arch/this/os.h>  #include <arch/this/filesystem.h> -#include <arch/this/samba.h> -#include <arch/this/nfs.h> -#include <arch/this/net.h>  #include <arch/common/users.h>  #include <arch/this/boots.h> +#include <arch/common/environment.h>  gchar *hi_more_info(gchar * entry)  { @@ -140,7 +124,7 @@ gchar *hi_get_field(gchar * field)  void scan_summary(gboolean reload)  {      SCAN_START(); -    module_entry_scan_all_except(entries, COMPUTER_SUMMARY); +    module_entry_scan_all_except(entries, 0);      computer->alsa = computer_get_alsainfo();      SCAN_END();  } @@ -181,14 +165,6 @@ void scan_fs(gboolean reload)      SCAN_END();  } -void scan_shares(gboolean reload) -{ -    SCAN_START(); -    scan_samba_shared_directories(); -    scan_nfs_shared_directories(); -    SCAN_END(); -} -  void scan_display(gboolean reload)  {      SCAN_START(); @@ -196,13 +172,6 @@ void scan_display(gboolean reload)      SCAN_END();  } -void scan_network(gboolean reload) -{ -    SCAN_START(); -    scan_net_interfaces(); -    SCAN_END(); -} -  void scan_users(gboolean reload)  {      SCAN_START(); @@ -267,6 +236,7 @@ gchar *callback_os()  			   "Kernel=%s\n"  			   "Compiled=%s\n"  			   "C Library=%s\n" +			   "Default C Compiler=%s\n"  			   "Distribution=%s\n"  			   "[Current Session]\n"  			   "Computer Name=%s\n" @@ -280,6 +250,7 @@ gchar *callback_os()  			   computer->os->kernel,  			   computer->os->compiled_date,  			   computer->os->libc, +			   computer->os->gcc,  			   computer->os->distro,  			   computer->os->hostname,  			   computer->os->username, @@ -291,18 +262,30 @@ gchar *callback_modules()  {      return g_strdup_printf("[Loaded Modules]\n"  			   "%s" -			   "[$ShellParam$]\n" "ViewType=1", module_list); +			   "[$ShellParam$]\n" +			   "ViewType=1\n" +			   "ColumnTitle$TextValue=Name\n" +			   "ColumnTitle$Value=Description\n" +			   "ShowColumnHeaders=true\n", module_list);  }  gchar *callback_boots()  { -    return g_strdup(computer->os->boots); +    return g_strdup_printf("[$ShellParam$]\n" +			   "ColumnTitle$TextValue=Date & Time\n" +			   "ColumnTitle$Value=Kernel Version\n" +			   "ShowColumnHeaders=true\n" +			   "\n" +			   "%s", computer->os->boots);  }  gchar *callback_locales()  {      return g_strdup_printf("[$ShellParam$]\n"  			   "ViewType=1\n" +			   "ColumnTitle$TextValue=Language Code\n" +			   "ColumnTitle$Value=Name\n" +			   "ShowColumnHeaders=true\n"  			   "[Available Languages]\n"  			   "%s", computer->os->languages);  } @@ -310,19 +293,17 @@ gchar *callback_locales()  gchar *callback_fs()  {      return g_strdup_printf("[$ShellParam$]\n" -			   "ViewType=1\n" +			   "ViewType=4\n"  			   "ReloadInterval=5000\n" +			   "Zebra=1\n" +			   "NormalizePercentage=false\n" +			   "ColumnTitle$Extra1=Mount Point\n" +			   "ColumnTitle$Progress=Usage\n" +			   "ColumnTitle$TextValue=Device\n" +			   "ShowColumnHeaders=true\n"  			   "[Mounted File Systems]\n%s\n", fs_list);  } -gchar *callback_shares() -{ -    return g_strdup_printf("[SAMBA]\n" -			   "%s\n" -			   "[NFS]\n" -			   "%s", smb_shares_list, nfs_shares_list); -} -  gchar *callback_display()  {      return g_strdup_printf("[Display]\n" @@ -350,24 +331,13 @@ gchar *callback_display()  			   computer->display->dri ? "Yes" : "No");  } -gchar *callback_network() -{ -    return g_strdup_printf("%s\n" -			   "[$ShellParam$]\n" -			   "ReloadInterval=3000\n" -			   "ViewType=1\n" -			   "%s", network_interfaces, network_icons); -} -  gchar *callback_users()  {      return g_strdup_printf("[$ShellParam$]\n"  			   "ReloadInterval=10000\n"  			   "ViewType=1\n" -			   "[Human Users]\n" -			   "%s\n" -			   "[System Users]\n" -			   "%s\n", human_users, sys_users); +			   "[Users]\n" +			   "%s\n", users);  }  gchar *get_os_kernel(void) @@ -376,10 +346,27 @@ gchar *get_os_kernel(void)      return computer->os->kernel;  } +gchar *get_kernel_module_description(gchar *module) +{ +    gchar *description; +     +    if (!_module_hash_table) { +        scan_modules(FALSE); +    } +     +    description = g_hash_table_lookup(_module_hash_table, module); +    if (!description) { +        return g_strdup(module); +    } +     +    return g_strdup(description); +} +  ShellModuleMethod *hi_exported_methods(void)  {      static ShellModuleMethod m[] = {  	{"getOSKernel", get_os_kernel}, +	{"getKernelModuleDescription", get_kernel_module_description},  	{NULL}      }; @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -26,15 +26,23 @@ static struct {      { DB_PREFIX "debian_version",	"deb"  },      { DB_PREFIX "slackware-version",	"slk"  },      { DB_PREFIX "mandrake-release",	"mdk"  }, +    { DB_PREFIX "mandriva-release",     "mdv"  }, +    { DB_PREFIX "fedora-release",       "fdra" }, +    { DB_PREFIX "coas",                 "coas" }, +    { DB_PREFIX "environment.corel",    "corel"},      { DB_PREFIX "gentoo-release",	"gnt"  },      { DB_PREFIX "conectiva-release",	"cnc"  },      { DB_PREFIX "versão-conectiva",	"cnc"  },      { DB_PREFIX "turbolinux-release",	"tl"   },      { DB_PREFIX "yellowdog-release",	"yd"   }, +    { DB_PREFIX "sabayon-release",      "sbn"  }, +    { DB_PREFIX "arch-release",         "arch" }, +    { DB_PREFIX "enlisy-release",       "enlsy"},      { DB_PREFIX "SuSE-release",		"suse" },      { DB_PREFIX "sun-release",		"sun"  },      { DB_PREFIX "zenwalk-version",	"zen"  },      { DB_PREFIX "puppyversion",		"ppy"  }, +    { DB_PREFIX "distro-release",	"fl"   },      /*       * RedHat must be the *last* one to be checked, since       * some distros (like Mandrake) includes a redhat-relase @@ -127,6 +135,7 @@ struct _Processor {  struct _OperatingSystem {      gchar *kernel;      gchar *libc; +    gchar *gcc;      gchar *distrocode, *distro;      gchar *hostname;      gchar *language; @@ -1,16 +1,15 @@  #ifndef __CONFIG_H__  #define __CONFIG_H__ -#define VERSION "0.4.2.3" -#define LSPCI "/usr/bin/lspci -v" +#define VERSION "0.5c"  #define ARCH_i386  #define ARCH     "ARCH_i386"  #define PLATFORM "Linux" -#define KERNEL   "2.6.24-1-686" +#define KERNEL   "2.6.26-1-686"  #define HOSTNAME "comanche"  #define PREFIX "/usr/share/hardinfo/"  #define LIBPREFIX "/usr/lib/hardinfo/" -#define HAS_LIBSOUP +#define HAS_LINUX_WE  #define DEBUG(...)  #define ENABLE_BINRELOC 1  #define RELEASE 1 @@ -1,7 +1,7 @@  #!/usr/bin/env bash  #  # ToscoConf 0.04 -# Copyright (c) 2003-2004 Leandro Pereira <leandro@linuxmag.com.br> +# Copyright (c) 2003-2004 Leandro Pereira <leandro@hardinfo.org>  # All rights reserved.  #  # This script is in the Tosco Public License. It may be copied and/or @@ -24,7 +24,7 @@ PACKAGE=`basename ${PWD} | cut -d"-" -f1`;  VERSION=`basename ${PWD} | cut -d"-" -f2`;  if [ "$PACKAGE" == "$VERSION" ]; then -	VERSION=$(printf "SVN_%d" $(LC_ALL=C svn -R info|grep Revision|cut -d: -f2|sort -n|tail -n1)) +	VERSION=$(date +"%F.%H:%M:%S")  	RELEASE=0  else  	RELEASE=1 @@ -55,7 +55,8 @@ case $PROC in  		ARCH="ARCH_PPC" ;;  	x86_64)  		ln -sf linux/x86_64 arch/this -		ARCH="ARCH_x86_64" ;; +		ARCH="ARCH_x86_64" +		LIBDIR="/usr/lib64" ;;  	mips*)  		ln -sf linux/mips arch/this  		ARCH="ARCH_MIPS" ;; @@ -80,11 +81,15 @@ case $PROC in  	m68k)  		ln -sf linux/m68k arch/this  		ARCH="ARCH_m68k" ;; +	sh*) +		ln -sf linux/sh arch/this +		ARCH="ARCH_sh" ;; +  esac  if [ "x$ARCH" == "x" ]; then  	echo "Your architecture is not supported yet. Please send the" -	echo "output of the following commands to leandro@linuxmag.com.br:" +	echo "output of the following commands to leandro@hardinfo.org:"  	echo ""  	echo "  $ cat /proc/cpuinfo"  	echo "  $ uname -a" @@ -99,24 +104,6 @@ echo ""  # --------------------------------------------------------------------------- -echo -n "Checking for lspci... " -LSPCIPATH="/sbin/lspci /usr/sbin/lspci /bin/lspci /usr/bin/lspci `which lspci 2>/dev/null`" -for i in $LSPCIPATH; do -	if [ -x "$i" ]; then -		LSPCI=$i -		break -	fi -done - -if [ -e "$LSPCI" ]; then -	echo $LSPCI -else -	echo "lspci cannot be found" -	exit -fi - -# --------------------------------------------------------------------------- -  GTK2=-1  MIN_VERSION="2.6.0"  echo -n "Checking for GTK version >= ${MIN_VERSION}... " @@ -148,16 +135,16 @@ fi  # ---------------------------------------------------------------------------  SOUP=-1 -MIN_VERSION="2.2.7" +MIN_VERSION="2.24"  echo -n "Checking for libsoup version >= ${MIN_VERSION}... "  for i in `which pkg-config`; do -	$i --errors-to-stdout libsoup-2.2 \ +	$i --errors-to-stdout libsoup-2.4 \  		--atleast-version=$MIN_VERSION > /dev/null  	case $? in  		0) -			SOUP_FLAGS=`pkg-config libsoup-2.2 --cflags --static` -			SOUP_LIBS=`pkg-config libsoup-2.2 --libs --static` -			echo "found `pkg-config libsoup-2.2 --modversion`" +			SOUP_FLAGS=`pkg-config libsoup-2.4 --cflags --static` +			SOUP_LIBS=`pkg-config libsoup-2.4 --libs --static` +			echo "found `pkg-config libsoup-2.4 --modversion`"  			SOUP=1  			break ;;  		*) @@ -173,13 +160,29 @@ fi  # -------------------------------------------------------------------------- +echo -n "Checking for Linux Wireless Extensions (CONFIG_NET_RADIO)... " +if [ -e /proc/net/wireless ]; then +	echo "found." +	LINUX_WE=1 +else +	echo "not found." +	LINUX_WE=-1 +fi + +# -------------------------------------------------------------------------- + +if [ $LINUX_WE -eq -1 ]; then +	echo "Disabling Linux Wireless Extensions support." +fi + +# -------------------------------------------------------------------------- +  echo -e "\nWriting config.h..."  rm -f config.h  echo -e "#ifndef __CONFIG_H__\n#define __CONFIG_H__\n" > config.h  echo "#define VERSION \"$VERSION\"" >> config.h -echo "#define LSPCI \"$LSPCI -v\"" >> config.h  echo "#define $ARCH" >> config.h  echo "#define ARCH     \"$ARCH\"" >> config.h @@ -194,6 +197,10 @@ if [ "$SOUP" == "1" ]; then  	echo "#define HAS_LIBSOUP" >> config.h  fi +if [ "$LINUX_WE" == "1" ]; then +	echo "#define HAS_LINUX_WE" >> config.h +fi +  if [ "$RELEASE" == "1" ]; then  	echo "#define DEBUG(...)" >> config.h  else @@ -209,7 +216,7 @@ echo -e "\n#endif	/* __CONFIG_H__ */" >> config.h  echo "Writing Makefile..."  rm -f Makefile -echo "GTK_LIBS = ${GTK_LIBS}" > Makefile +echo "GTK_LIBS = -lpthread -lgthread-2.0 -lrt ${GTK_LIBS}" > Makefile  echo "GTK_CFLAGS = ${GTK_FLAGS}" >> Makefile  echo "SOUP_LIBS = ${SOUP_LIBS}" >> Makefile  echo "SOUP_CFLAGS = ${SOUP_FLAGS}" >> Makefile @@ -235,6 +242,6 @@ else  	cat << EOF  If you get errors, probably you don't have the right libraries,  includes or utilities. However, if you're sure this is a bug in my -code, please send a patch (use "diff -u") to <leandro@linuxmag.com.br>. +code, please send a patch (use "diff -u") to <leandro@hardinfo.org>.  EOF  fi diff --git a/debian/changelog b/debian/changelog index f4ea2b07..3c82e108 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +hardinfo (0.5c-1) unstable; urgency=low + +  * New upstream version.  +     (Closes: #517591, #511237, #457703, #519256, #449250, #457820, #497758)  + + -- Agney Lopes Roth Ferraz <agney@debian.org>  Sat, 28 Mar 2009 22:55:02 -0300 +  hardinfo (0.4.2.3-5) unstable; urgency=low    * Fixed location on menu. (Closes: #487569)  diff --git a/debian/compat b/debian/compat index b8626c4c..7ed6ff82 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -4 +5 diff --git a/debian/control b/debian/control index 2dff59c7..6f0c4e7c 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: x11  Priority: optional  Maintainer: Agney Lopes Roth Ferraz <agney@debian.org>  Build-Depends: debhelper (>> 4.0.0), libgtk2.0-dev, pciutils (>=1:2.1.11-10), libsoup2.2-dev -Standards-Version: 3.7.3.0 +Standards-Version: 3.8.1.0  Package: hardinfo  Architecture: any  diff --git a/debian/copyright b/debian/copyright index 2e4c40d9..55aad79c 100644 --- a/debian/copyright +++ b/debian/copyright @@ -8,6 +8,6 @@ Upstream Author: Leandro Pereira <leandro@linuxmag.com.br>  Copyright (c) 2003, Leandro Pereira.  You are free to distribute and/or modify this software under the terms of -the GNU General Public License. +the GNU General Public License version 2.  On Debian systems, the complete text of the GNU General Public License can -be found in /usr/share/common-licenses/GPL file. +be found in /usr/share/common-licenses/GPL-2 file. diff --git a/debian/hardinfo.desktop b/debian/hardinfo.desktop index 97709a0f..5a34c247 100644 --- a/debian/hardinfo.desktop +++ b/debian/hardinfo.desktop @@ -1,9 +1,10 @@  [Desktop Entry]  Name=System Profiler and Benchmark  Name[pt_BR]=Informações e Testes do Sistema -Exec=/usr/bin/hardinfo +Exec=hardinfo  Icon=/usr/share/hardinfo/pixmaps/logo.png  Terminal=false  Type=Application  StartupNotify=true -Categories=Settings;HardwareSettings; +Categories=System; + diff --git a/debian/preinst b/debian/preinst deleted file mode 100644 index f7df1741..00000000 --- a/debian/preinst +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sh -# preinst script for hardinfo -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -#        * <new-preinst> `install' -#        * <new-preinst> `install' <old-version> -#        * <new-preinst> `upgrade' <old-version> -#        * <old-preinst> `abort-upgrade' <new-version> -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in -    install|upgrade) -#        if [ "$1" = "upgrade" ] -#        then -#            start-stop-daemon --stop --quiet --oknodo  \ -#                --pidfile /var/run/hardinfo.pid  \ -#                --exec /usr/sbin/hardinfo 2>/dev/null || true -#        fi -    ;; - -    abort-upgrade) -    ;; - -    *) -        echo "preinst called with unknown argument \`$1'" >&2 -        exit 1 -    ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 - - diff --git a/debian/prerm b/debian/prerm deleted file mode 100644 index 2a27c8cd..00000000 --- a/debian/prerm +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh -# prerm script for hardinfo -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -#        * <prerm> `remove' -#        * <old-prerm> `upgrade' <new-version> -#        * <new-prerm> `failed-upgrade' <old-version> -#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version> -#        * <deconfigured's-prerm> `deconfigure' `in-favour' -#          <package-being-installed> <version> `removing' -#          <conflicting-package> <version> -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in -    remove|upgrade|deconfigure) -#       install-info --quiet --remove /usr/info/hardinfo.info.gz -        ;; -    failed-upgrade) -        ;; -    *) -        echo "prerm called with unknown argument \`$1'" >&2 -        exit 1 -    ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 - - @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -16,6 +16,14 @@   *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA   */ +#ifndef __USE_XOPEN +#define __USE_XOPEN +#endif /* __USE_XOPEN */ + +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE +#endif /* _XOPEN_SOURCE */ +  #include <gtk/gtk.h>  #include <config.h>  #include <string.h> @@ -28,18 +36,6 @@  #include <expr.h>  #include <socket.h> -enum { -    DEVICES_PROCESSORS, -    DEVICES_MEMORY, -    DEVICES_PCI, -    DEVICES_USB, -    DEVICES_PRINTERS, -    DEVICES_BATTERY, -    DEVICES_SENSORS, -    DEVICES_INPUT, -    DEVICES_STORAGE, -} Entries; -  gchar *callback_processors();  gchar *callback_memory();  gchar *callback_battery(); @@ -49,6 +45,10 @@ gchar *callback_printers();  gchar *callback_storage();  gchar *callback_input();  gchar *callback_usb(); +#if defined(ARCH_i386) || defined(ARCH_x86_64) +gchar *callback_dmi(); +#endif +gchar *callback_device_resources();  void scan_processors(gboolean reload);  void scan_memory(gboolean reload); @@ -59,6 +59,10 @@ void scan_printers(gboolean reload);  void scan_storage(gboolean reload);  void scan_input(gboolean reload);  void scan_usb(gboolean reload); +#if defined(ARCH_i386) || defined(ARCH_x86_64) +void scan_dmi(gboolean reload); +#endif +void scan_device_resources(gboolean reload);  static ModuleEntry entries[] = {      {"Processor", "processor.png", callback_processors, scan_processors}, @@ -70,6 +74,10 @@ static ModuleEntry entries[] = {      {"Sensors", "therm.png", callback_sensors, scan_sensors},      {"Input Devices", "inputdevices.png", callback_input, scan_input},      {"Storage", "hdd.png", callback_storage, scan_storage}, +#if defined(ARCH_i386) || defined(ARCH_x86_64) +    {"DMI", "computer.png", callback_dmi, scan_dmi}, +#endif	/* x86 or x86_64 */ +    {"Resources", "resources.png", callback_device_resources, scan_device_resources},      {NULL}  }; @@ -123,6 +131,11 @@ typedef struct _Processor Processor;  #include <arch/this/battery.h>  #include <arch/this/sensors.h>  #include <arch/this/devmemory.h> +#include <arch/this/resources.h> + +#if defined(ARCH_i386) || defined(ARCH_x86_64) +#include <arch/this/dmi.h> +#endif	/* x86 or x86_64 */  gchar *get_processor_name(void)  { @@ -160,13 +173,59 @@ gchar *get_input_devices(void)      return input_list;  } +gchar *get_processor_count(void) +{ +    scan_processors(FALSE); + +    return g_strdup_printf("%d", g_slist_length(processors)); +} + +gchar *get_processor_frequency(void) +{ +    Processor *p; + +    scan_processors(FALSE); + +    p = (Processor *)processors->data; +    if (p->cpu_mhz == 0.0f) { +        return g_strdup("Unknown"); +    } else { +        return g_strdup_printf("%.0f", p->cpu_mhz); +    } +} + +gchar *get_pci_device_description(gchar *pci_id) +{ +    gchar *description; +     +    if (!_pci_devices) { +        scan_pci(FALSE); +    } +     +    if ((description = g_hash_table_lookup(_pci_devices, pci_id))) { +        return g_strdup(description); +    } +     +    return NULL; +} + +gchar *get_memory_total(void) +{ +    /* FIXME */ +    return g_strdup("0.0"); +} +  ShellModuleMethod *hi_exported_methods(void)  {      static ShellModuleMethod m[] = { +        {"getProcessorCount", get_processor_count},  	{"getProcessorName", get_processor_name}, +	{"getProcessorFrequency", get_processor_frequency}, +	{"getMemoryTotal", get_memory_total},  	{"getStorageDevices", get_storage_devices},  	{"getPrinters", get_printers},  	{"getInputDevices", get_input_devices}, +	{"getPCIDeviceDescription", get_pci_device_description},  	{NULL}      }; @@ -176,7 +235,7 @@ ShellModuleMethod *hi_exported_methods(void)  gchar *hi_more_info(gchar * entry)  {      gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); - +          if (info)  	return g_strdup(info); @@ -193,6 +252,15 @@ gchar *hi_get_field(gchar * field)      return g_strdup(field);  } +#if defined(ARCH_i386) || defined(ARCH_x86_64) +void scan_dmi(gboolean reload) +{ +    SCAN_START(); +    __scan_dmi(); +    SCAN_END(); +} +#endif +  void scan_processors(gboolean reload)  {      SCAN_START(); @@ -266,6 +334,13 @@ gchar *callback_processors()      return processor_get_info(processors);  } +#if defined(ARCH_i386) || defined(ARCH_x86_64) +gchar *callback_dmi() +{ +    return dmi_info; +} +#endif +  gchar *callback_memory()  {      return g_strdup_printf("[Memory]\n" @@ -301,6 +376,7 @@ gchar *callback_printers()  {      return g_strdup_printf("%s\n"  			   "[$ShellParam$]\n" +                           "ViewType=1\n"  			   "ReloadInterval=5000", printer_list);  } @@ -342,7 +418,7 @@ gchar *hi_module_get_name(void)  guchar hi_module_get_weight(void)  { -    return 160; +    return 85;  }  void hi_module_init(void) @@ -362,6 +438,7 @@ void hi_module_init(void)      moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);      __init_memory_labels(); +    __init_cups();  }  ModuleAbout *hi_module_get_about(void) @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -25,7 +25,9 @@  #include <stdio.h>  #include <ctype.h>  #include <math.h> -#include <expr.h> + +#include "expr.h" +#include "config.h"  static MathToken *new_operator(gchar op)  { @@ -90,8 +92,9 @@ GSList *math_infix_to_postfix(GSList * infix)  	    stack[++t_sp] = t;  	} else if (t->type == TOKEN_OPERATOR && t->val.op == ')') {  	    for (top = stack[t_sp]; t_sp != 0 && top->val.op != '('; -		 top = stack[t_sp]) -		postfix = g_slist_append(postfix, stack[t_sp--]); +		 top = stack[t_sp]) { +                postfix = g_slist_append(postfix, stack[t_sp--]); +            }  	    t_sp--;  	} else if (t->type != TOKEN_OPERATOR) {  	    postfix = g_slist_append(postfix, t); @@ -107,7 +110,7 @@ GSList *math_infix_to_postfix(GSList * infix)      while (t_sp)  	postfix = g_slist_append(postfix, stack[t_sp--]); - +	      return postfix;  } @@ -149,11 +152,11 @@ gfloat math_postfix_eval(GSList * postfix, gfloat at_value)  	    op2 = stack[sp--];  	    op1 = stack[sp]; - +	      	    stack[sp] = __result(op1, op2, t->val.op);  	}      } - +          return stack[sp];  } @@ -161,17 +164,25 @@ GSList *math_string_to_infix(gchar * string)  {      GSList *infix = NULL;      gchar *expr = string; - +          for (; *expr; expr++) {  	if (strchr("+-/*^()", *expr)) {  	    infix = g_slist_append(infix, new_operator(*expr));  	} else if (strchr("@", *expr)) {  	    infix = g_slist_append(infix, new_variable(*expr));  	} else if (strchr("-.1234567890", *expr)) { -	    gfloat value; - -	    expr += sscanf(expr, "%f", &value); -	    infix = g_slist_append(infix, new_value(value)); +	    gchar value[32], *v = value; +	    gfloat floatval; +	     +	    do { +	      *v++ = *expr++; +	    } while (*expr && strchr("-.1234567890", *expr)); +	    expr--; +	    *v = '\0'; +	     +	    sscanf(value, "%f", &floatval); + +	    infix = g_slist_append(infix, new_value(floatval));  	} else if (!isspace(*expr)) {  	    g_print("Invalid token: [%c][%d]\n", *expr, *expr);  	    math_infix_free(infix, TRUE); @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/fftbench.c b/fftbench.c new file mode 100644 index 00000000..597c5693 --- /dev/null +++ b/fftbench.c @@ -0,0 +1,201 @@ +/* +    fftbench.c + +    Written by Scott Robert Ladd (scott@coyotegulch.com) +    No rights reserved. This is public domain software, for use by anyone. + +    A number-crunching benchmark using LUP-decomposition to solve a large +    linear equation. + +    The code herein is design for the purpose of testing computational +    performance; error handling is minimal. +     +    In fact, this is a weak implementation of the FFT; unfortunately, all +    of my really nifty FFTs are in commercial code, and I haven't had time +    to write a new FFT routine for this benchmark. I may add a Hartley +    transform to the seat, too. + +    Actual benchmark results can be found at: +            http://www.coyotegulch.com + +    Please do not use this information or algorithm in any way that might +    upset the balance of the universe or otherwise cause a disturbance in +    the space-time continuum. +*/ + +#include <time.h> +#include <string.h> +#include <stdlib.h> +#include <math.h> +#include <stdbool.h> +#include <stdio.h> + +// embedded random number generator; ala Park and Miller +static long seed = 1325; +static const long IA = 16807; +static const long IM = 2147483647; +static const double AM = 4.65661287525E-10; +static const long IQ = 127773; +static const long IR = 2836; +static const long MASK = 123459876; + +static double random_double() +{ +    long k; +    double result; + +    seed ^= MASK; +    k = seed / IQ; +    seed = IA * (seed - k * IQ) - IR * k; + +    if (seed < 0) +	seed += IM; + +    result = AM * seed; +    seed ^= MASK; + +    return result; +} + +static const int N = 800; +static const int NM1 = 799;	// N - 1 +static const int NP1 = 801;	// N + 1 + +static int *lup_decompose(double **a) +{ +    int i, j, k, k2, t; +    double p, temp; + +    int *perm = (int *) malloc(sizeof(double) * N); + +    for (i = 0; i < N; ++i) +	perm[i] = i; + +    for (k = 0; k < NM1; ++k) { +	p = 0.0; + +	for (i = k; i < N; ++i) { +	    temp = fabs(a[i][k]); + +	    if (temp > p) { +		p = temp; +		k2 = i; +	    } +	} + +	// check for invalid a +	if (p == 0.0) +	    return NULL; + +	// exchange rows +	t = perm[k]; +	perm[k] = perm[k2]; +	perm[k2] = t; + +	for (i = 0; i < N; ++i) { +	    temp = a[k][i]; +	    a[k][i] = a[k2][i]; +	    a[k2][i] = temp; +	} + +	for (i = k + 1; i < N; ++i) { +	    a[i][k] /= a[k][k]; + +	    for (j = k + 1; j < N; ++j) +		a[i][j] -= a[i][k] * a[k][j]; +	} +    } + +    return perm; +} + +static double *lup_solve(double **a, int *perm, double *b) +{ +    int i, j, j2; +    double sum, u; + +    double *y = (double *) malloc(sizeof(double) * N); +    double *x = (double *) malloc(sizeof(double) * N); + +    for (i = 0; i < N; ++i) { +	y[i] = 0.0; +	x[i] = 0.0; +    } + +    for (i = 0; i < N; ++i) { +	sum = 0.0; +	j2 = 0; + +	for (j = 1; j <= i; ++j) { +	    sum += a[i][j2] * y[j2]; +	    ++j2; +	} + +	y[i] = b[perm[i]] - sum; +    } + +    i = NM1; + +    while (1) { +	sum = 0.0; +	u = a[i][i]; + +	for (j = i + 1; j < N; ++j) +	    sum += a[i][j] * x[j]; + +	x[i] = (y[i] - sum) / u; + +	if (i == 0) +	    break; + +	--i; +    } + +    free(y); + +    return x; +} + +static double **a, *b, *r; +static int *p; + +void fft_bench_init(void) +{ +    int i, j; + +    // generate test data             +    a = (double **) malloc(sizeof(double *) * N); + +    for (i = 0; i < N; ++i) { +	a[i] = (double *) malloc(sizeof(double) * N); + +	for (j = 0; j < N; ++j) +	    a[i][j] = random_double(); +    } + +    b = (double *) malloc(sizeof(double) * N); + +    for (i = 0; i < N; ++i) +	b[i] = random_double(); + +} + +void fft_bench_start(void) +{ +    p = lup_decompose(a); +    r = lup_solve(a, p, b); +} + +void fft_bench_finish(void) +{ +    int i; +     +    // clean up +    for (i = 0; i < N; ++i) +	free(a[i]); + +    free(a); +    free(b); +    free(p); +    free(r); +} diff --git a/fftbench.h b/fftbench.h new file mode 100644 index 00000000..055226e0 --- /dev/null +++ b/fftbench.h @@ -0,0 +1,8 @@ +#ifndef __FFTBENCH_H__  +#define __FFTBENCH_H__ + +void fft_bench_init(void); +void fft_bench_start(void); +void fft_bench_finish(void); + +#endif /* __FFTBENCH_H__ */
\ No newline at end of file @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -34,11 +34,9 @@ int main(int argc, char **argv)      DEBUG("HardInfo version " VERSION ". Debug version."); -#ifdef HAS_LIBSOUP      DEBUG("g_thread_init()");      if (!g_thread_supported())  	g_thread_init(NULL); -#endif				/* HAS_LIBSOUP */      /* parse all command line parameters */      parameters_init(&argc, &argv, ¶ms); @@ -47,7 +45,7 @@ int main(int argc, char **argv)      if (params.show_version) {  	g_print("HardInfo version " VERSION "\n");  	g_print -	    ("Copyright (C) 2003-2007 Leandro A. F. Pereira. See COPYING for details.\n\n"); +	    ("Copyright (C) 2003-2008 Leandro A. F. Pereira. See COPYING for details.\n\n");  	g_print("Compile-time options:\n"  		"  Release version:   %s (%s)\n" @@ -120,6 +118,7 @@ int main(int argc, char **argv)  	shell_init(modules);  	DEBUG("entering gtk+ main loop"); +  	gtk_main();      } else if (params.create_report) {  	/* generate report */ diff --git a/hardinfo.desktop b/hardinfo.desktop index 35c58bcd..523432f1 100644 --- a/hardinfo.desktop +++ b/hardinfo.desktop @@ -1,5 +1,4 @@  [Desktop Entry] -Encoding=UTF-8  Name=System Profiler and Benchmark  Name[pt_BR]=Informações e Testes do Sistema  Exec=hardinfo @@ -7,4 +6,4 @@ Icon=/usr/share/hardinfo/pixmaps/logo.png  Terminal=false  Type=Application  StartupNotify=true -Categories=System +Categories=System;
\ No newline at end of file @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -39,6 +39,7 @@ struct _ProgramParameters {    gchar  **use_modules;    gchar   *path_lib;    gchar   *path_data; +  gchar   *argv0;  };  struct _FileTypes { @@ -64,7 +65,7 @@ struct _ModuleAbout {  /* String utility functions */  inline void  remove_quotes(gchar *str); -inline void  strend(gchar *str, gchar chr); +inline char *strend(gchar *str, gchar chr);  inline void  remove_linefeed(gchar *str);  gchar       *strreplace(gchar *string, gchar *replace, gchar new_char); @@ -88,6 +89,8 @@ gpointer __idle_free(gpointer ptr, gchar *f, gint l);  #define  idle_free(p) __idle_free(p, __FILE__, __LINE__)  #endif	/* RELEASE == 1 */ + +gchar	     *find_program(gchar *program_name);  inline gchar *size_human_readable(gfloat size);  void          nonblock_sleep(guint msec);  void          open_url(gchar *url); @@ -118,7 +121,12 @@ extern   ProgramParameters params;  /* Module stuff */  gchar		*module_call_method(gchar *method); +gchar           *module_call_method_param(gchar * method, gchar * parameter); +/* Sysfs stuff */ +gfloat		h_sysfs_read_float(gchar *endpoint, gchar *entry); +gint		h_sysfs_read_int(gchar *endpoint, gchar *entry); +gchar	       *h_sysfs_read_string(gchar *endpoint, gchar *entry);  #define SCAN_START()  static gboolean scanned = FALSE; if (reload) scanned = FALSE; if (scanned) return;  #define SCAN_END()    scanned = TRUE; diff --git a/iconcache.c b/iconcache.c index ed7ce209..c927ca5e 100644 --- a/iconcache.c +++ b/iconcache.c @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/iconcache.h b/iconcache.h index df1c0629..97f59a82 100644 --- a/iconcache.h +++ b/iconcache.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/loadgraph.c b/loadgraph.c index 3a535f5b..c8503072 100644 --- a/loadgraph.c +++ b/loadgraph.c @@ -6,7 +6,7 @@   *   - fixes autoscaling   *   - add color   * - * Copyright (C) 2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * Copyright (C) 2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   * The Simple Load Graph is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public @@ -37,12 +37,12 @@ LoadGraph *load_graph_new(gint size)      lg->suffix = g_strdup("");      lg->area = gtk_drawing_area_new(); -    lg->size = size; -    lg->data = g_new0(gint, size); +    lg->size = (size * 3) / 2; +    lg->data = g_new0(gint, lg->size);      lg->scale = 1.0; -    lg->width = size * 4; +    lg->width = size * 6;      lg->height = size * 2;      lg->max_value = 1; @@ -103,7 +103,7 @@ void load_graph_set_color(LoadGraph * lg, LoadGraphColor color)      lg->color = color;      gdk_rgb_gc_set_foreground(lg->trace, lg->color);      gdk_rgb_gc_set_foreground(lg->fill, lg->color - 0x303030); -    gdk_rgb_gc_set_foreground(lg->grid, lg->color - 0x404040); +    gdk_rgb_gc_set_foreground(lg->grid, lg->color - 0xcdcdcd);  }  void load_graph_destroy(LoadGraph * lg) @@ -125,7 +125,7 @@ static gboolean _expose(GtkWidget * widget, GdkEventExpose * event,      GdkDrawable *draw = GDK_DRAWABLE(lg->buf);      gdk_draw_drawable(lg->area->window, -		      lg->area->style->white_gc, +		      lg->area->style->black_gc,  		      draw, 0, 0, 0, 0, lg->width, lg->height);      return FALSE;  } @@ -148,6 +148,8 @@ void load_graph_configure_expose(LoadGraph * lg)      gdk_gc_set_line_attributes(lg->grid,  			       1, GDK_LINE_ON_OFF_DASH,  			       GDK_CAP_NOT_LAST, GDK_JOIN_ROUND); +    gdk_gc_set_dashes(lg->grid, 0, (gint8*)"\2\2", 2); +      #if 0				/* old-style grid */      gdk_rgb_gc_set_foreground(lg->grid, 0x707070);  #endif diff --git a/loadgraph.h b/loadgraph.h index 8adfe6b9..3a53f793 100644 --- a/loadgraph.h +++ b/loadgraph.h @@ -1,6 +1,6 @@  /*   * Simple Load Graph - * Copyright (C) 2006 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * Copyright (C) 2006 Leandro A. F. Pereira <leandro@hardinfo.org>   *   * The Simple Load Graph is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public @@ -47,6 +47,16 @@ static GtkActionEntry entries[] = {       NULL,       G_CALLBACK(cb_sync_manager)}, +    {"OpenAction", GTK_STOCK_OPEN, +     "_Open...", NULL, +     NULL, +     G_CALLBACK(cb_sync_manager)}, +      +    {"ConnectToAction", GTK_STOCK_CONNECT, +     "_Connect to...", NULL, +     NULL, +     G_CALLBACK(cb_sync_manager)}, +      {"CopyAction", GTK_STOCK_COPY,       "_Copy to Clipboard", "<control>C",       NULL, @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/modules/placeholder b/modules/placeholder new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/modules/placeholder diff --git a/network.c b/network.c new file mode 100644 index 00000000..52029598 --- /dev/null +++ b/network.c @@ -0,0 +1,403 @@ +/* + *    HardInfo - Displays System Information + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org> + * + *    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, version 2. + * + *    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA + */ + +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#include <gtk/gtk.h> +#include <config.h> +#include <time.h> +#include <string.h> +#include <sys/utsname.h> +#include <sys/stat.h> + +#include <hardinfo.h> +#include <iconcache.h> +#include <shell.h> + +#include <vendor.h> + +static GHashTable *moreinfo = NULL; + +/* Callbacks */ +gchar *callback_network(); +gchar *callback_route(); +gchar *callback_dns(); +gchar *callback_connections(); +gchar *callback_shares(); +gchar *callback_arp(); +gchar *callback_statistics(); + +/* Scan callbacks */ +void scan_network(gboolean reload); +void scan_route(gboolean reload); +void scan_dns(gboolean reload); +void scan_connections(gboolean reload); +void scan_shares(gboolean reload); +void scan_arp(gboolean reload); +void scan_statistics(gboolean reload); + +static ModuleEntry entries[] = { +    {"Interfaces", "network-interface.png", callback_network, scan_network}, +    {"IP Connections", "network-connections.png", callback_connections, scan_connections}, +    {"Routing Table", "network.png", callback_route, scan_route}, +    {"ARP Table", "module.png", callback_arp, scan_arp}, +    {"DNS Servers", "dns.png", callback_dns, scan_dns}, +    {"Statistics", "network-statistics.png", callback_statistics, scan_statistics}, +    {"Shared Directories", "shares.png", callback_shares, scan_shares}, +    {NULL}, +}; + +#include <arch/this/samba.h> +#include <arch/this/nfs.h> +#include <arch/this/net.h> + +void scan_shares(gboolean reload) +{ +    SCAN_START(); +    scan_samba_shared_directories(); +    scan_nfs_shared_directories(); +    SCAN_END(); +} + +static gchar *__statistics = NULL; +void scan_statistics(gboolean reload) +{ +    FILE *netstat; +    gchar buffer[256]; +    gchar *netstat_path; +     +    SCAN_START(); +     +    g_free(__statistics); +    __statistics = g_strdup(""); +     +    if ((netstat_path = find_program("netstat"))) { +      gchar *command_line = g_strdup_printf("%s -s", netstat_path); +       +      if ((netstat = popen(command_line, "r"))) { +        while (fgets(buffer, 256, netstat)) { +          if (!isspace(buffer[0]) && strchr(buffer, ':')) { +            gchar *tmp; +             +            tmp = g_ascii_strup(strend(buffer, ':'), -1); +             +            __statistics = h_strdup_cprintf("[%s]\n", +                                            __statistics, +                                            tmp); +             +            g_free(tmp); +          } else if (isdigit(buffer[4])) { +            gchar *tmp1 = buffer + 4, +                  *tmp2 = tmp1; +             +            while (*tmp2 && !isspace(*tmp2)) tmp2++; +            *tmp2 = 0; +            tmp2++; +             +            *tmp2 = toupper(*tmp2); +             +            __statistics = h_strdup_cprintf("%s=%s\n", +                                            __statistics, +                                            g_strstrip(tmp1), +                                            g_strstrip(tmp2)); +          } +        } + +        pclose(netstat); +      } +       +      g_free(command_line); +      g_free(netstat_path); +    } +     +    SCAN_END(); +} + +static gchar *__nameservers = NULL; +void scan_dns(gboolean reload) +{ +    FILE *resolv; +    gchar buffer[256]; +     +    SCAN_START(); +     +    g_free(__nameservers); +    __nameservers = g_strdup(""); +     +    if ((resolv = fopen("/etc/resolv.conf", "r"))) { +      while (fgets(buffer, 256, resolv)) { +        if (g_str_has_prefix(buffer, "nameserver")) { +          __nameservers = h_strdup_cprintf("%s=\n", +                                           __nameservers, +                                           g_strstrip(buffer + sizeof("nameserver"))); +        }  +      } +      fclose(resolv); +    } +     +    SCAN_END(); +} + +void scan_network(gboolean reload) +{ +    SCAN_START(); +    scan_net_interfaces(); +    SCAN_END(); +} + +static gchar *__routing_table = NULL; +void scan_route(gboolean reload) +{ +    FILE *route; +    gchar buffer[256]; +    gchar *route_path; +     +    SCAN_START(); + +    g_free(__routing_table); +    __routing_table = g_strdup(""); +     +    if ((route_path = find_program("route"))) { +      gchar *command_line = g_strdup_printf("%s -n", route_path); +       +      if ((route = popen(command_line, "r"))) { +        /* eat first two lines */ +        fgets(buffer, 256, route); +        fgets(buffer, 256, route); + +        while (fgets(buffer, 256, route)) { +          buffer[15] = '\0'; +          buffer[31] = '\0'; +          buffer[47] = '\0'; +          buffer[53] = '\0'; +           +          __routing_table = h_strdup_cprintf("%s / %s=%s|%s|%s\n", +                                             __routing_table, +                                             g_strstrip(buffer), g_strstrip(buffer + 16), +                                             g_strstrip(buffer + 72), +                                             g_strstrip(buffer + 48), +                                             g_strstrip(buffer + 32)); +        } +         +        pclose(route); +      } +       +      g_free(command_line); +      g_free(route_path); +    } +     +    SCAN_END(); +} + +static gchar *__arp_table = NULL; +void scan_arp(gboolean reload) +{ +    FILE *arp; +    gchar buffer[256]; +     +    SCAN_START(); + +    g_free(__arp_table); +    __arp_table = g_strdup(""); +     +    if ((arp = fopen("/proc/net/arp", "r"))) { +      /* eat first line */ +      fgets(buffer, 256, arp); + +      while (fgets(buffer, 256, arp)) { +        buffer[15] = '\0'; +        buffer[58] = '\0'; +         +        __arp_table = h_strdup_cprintf("%s=%s|%s\n", +                                       __arp_table, +                                       g_strstrip(buffer), +                                       g_strstrip(buffer + 72), +                                       g_strstrip(buffer + 41)); +      } +       +      pclose(arp); +    } +     +    SCAN_END(); +} + +static gchar *__connections = NULL; +void scan_connections(gboolean reload) +{ +    FILE *netstat; +    gchar buffer[256]; +    gchar *netstat_path; +     +    SCAN_START(); + +    g_free(__connections); +    __connections = g_strdup(""); +     +    if ((netstat_path = find_program("netstat"))) { +      gchar *command_line = g_strdup_printf("%s -an", netstat_path); +       +      if ((netstat = popen("netstat -an", "r"))) { +        while (fgets(buffer, 256, netstat)) { +          buffer[6] = '\0'; +          buffer[43] = '\0'; +          buffer[67] = '\0'; + +          if (g_str_has_prefix(buffer, "tcp") || g_str_has_prefix(buffer, "udp")) { +            __connections = h_strdup_cprintf("%s=%s|%s|%s\n", +                                             __connections, +                                             g_strstrip(buffer + 20),	/* local address */ +                                             g_strstrip(buffer),		/* protocol */ +                                             g_strstrip(buffer + 44),	/* foreign address */ +                                             g_strstrip(buffer + 68));	/* state */ +          } +        } +         +        pclose(netstat); +      } +       +      g_free(command_line); +      g_free(netstat_path); +    } +     +    SCAN_END(); +} + +gchar *callback_arp() +{ +    return g_strdup_printf("[ARP Table]\n" +                           "%s\n" +                           "[$ShellParam$]\n" +                           "ReloadInterval=3000\n" +                           "ColumnTitle$TextValue=IP Address\n" +                           "ColumnTitle$Value=Interface\n" +                           "ColumnTitle$Extra1=MAC Address\n" +                           "ShowColumnHeaders=true\n", +                           __arp_table); +} + +gchar *callback_shares() +{ +    return g_strdup_printf("[SAMBA]\n" +			   "%s\n" +			   "[NFS]\n" +			   "%s", smb_shares_list, nfs_shares_list); +} + +gchar *callback_dns() +{ +    return g_strdup_printf("[Name servers]\n" +                           "%s\n", __nameservers); +} + +gchar *callback_connections() +{ +    return g_strdup_printf("[Connections]\n" +                           "%s\n" +                           "[$ShellParam$]\n" +                           "ReloadInterval=3000\n" +                           "ColumnTitle$TextValue=Local Address\n" +                           "ColumnTitle$Value=Protocol\n" +                           "ColumnTitle$Extra1=Foreign Address\n" +                           "ColumnTitle$Extra2=State\n" +                           "ShowColumnHeaders=true\n", +                           __connections); +} + +gchar *callback_network() +{ +    return g_strdup_printf("%s\n" +                           "[$ShellParam$]\n" +			   "ReloadInterval=3000\n" +			   "ViewType=1\n" +			   "ColumnTitle$TextValue=Device\n" +			   "ColumnTitle$Value=IP Address\n" +			   "ColumnTitle$Extra1=Sent\n" +			   "ColumnTitle$Extra2=Received\n" +			   "ShowColumnHeaders=true\n" +			   "%s", +			   network_interfaces, +			   network_icons); +} + +gchar *callback_route() +{ +    return g_strdup_printf("[IP routing table]\n" +                           "%s\n" +                           "[$ShellParam$]\n" +                           "ViewType=0\n" +                           "ReloadInterval=3000\n" +                           "ColumnTitle$TextValue=Destination / Gateway\n" +                           "ColumnTitle$Value=Interface\n" +                           "ColumnTitle$Extra1=Flags\n" +                           "ColumnTitle$Extra2=Mask\n" +                           "ShowColumnHeaders=true\n", +                           __routing_table); +} + +gchar *callback_statistics() +{ +    return g_strdup_printf("%s\n" +                           "[$ShellParam$]\n" +                           "ReloadInterval=3000\n", +                            __statistics); +} + +gchar *hi_more_info(gchar * entry) +{ +    gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); + +    if (info) +	return g_strdup(info); + +    return g_strdup_printf("[%s]", entry); +} + +ModuleEntry *hi_module_get_entries(void) +{ +    return entries; +} + +gchar *hi_module_get_name(void) +{ +    return g_strdup("Network"); +} + +guchar hi_module_get_weight(void) +{ +    return 160; +} + +void hi_module_init(void) +{ +    moreinfo = +	g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); +} + +ModuleAbout *hi_module_get_about(void) +{ +    static ModuleAbout ma[] = { +	{ +	 .author = "Leandro A. F. Pereira", +	 .description = "Gathers information about this computer's network connection", +	 .version = VERSION, +	 .license = "GNU GPL version 2"} +    }; + +    return ma; +} diff --git a/nqueens.c b/nqueens.c new file mode 100644 index 00000000..838731c4 --- /dev/null +++ b/nqueens.c @@ -0,0 +1,37 @@ +/* + * N-Queens Problem Solver + * Found somewhere on the Internet; can't remember where. Possibly Wikipedia. + */ +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> + +#define QUEENS 11 + +int row[QUEENS]; + +bool safe(int x, int y) +{ +    int i; +    for (i = 1; i <= y; i++) +	if (row[y - i] == x || row[y - i] == x - i || row[y - i] == x + i) +	    return false; +    return true; +} + +int nqueens(int y) +{ +    int x; +     +    for (x = 0; x < QUEENS; x++) { +	if (safe((row[y - 1] = x), y - 1)) { +	    if (y < QUEENS) { +		nqueens(y + 1); +	    } else { +	        break; +            } +        } +    } +     +    return 0; +} diff --git a/nqueens.h b/nqueens.h new file mode 100644 index 00000000..a4be93f0 --- /dev/null +++ b/nqueens.h @@ -0,0 +1,13 @@ +/* + * N-Queens Problem Solver + * Found somewhere on the Internet; can't remember where. Possibly Wikipedia. + */ +#ifndef __NQUEENS_H__  +#define __NQUEENS_H__ + +int nqueens(int y); + + +#endif /* __NQUEENS_H__ */ + + diff --git a/pixmaps/benchmark.png b/pixmaps/benchmark.pngBinary files differ index 1be159b7..927681cf 100644 --- a/pixmaps/benchmark.png +++ b/pixmaps/benchmark.png diff --git a/pixmaps/bluetooth.png b/pixmaps/bluetooth.pngBinary files differ new file mode 100644 index 00000000..7f002131 --- /dev/null +++ b/pixmaps/bluetooth.png diff --git a/pixmaps/cryptohash.png b/pixmaps/cryptohash.pngBinary files differ new file mode 100644 index 00000000..e2eb5d29 --- /dev/null +++ b/pixmaps/cryptohash.png diff --git a/pixmaps/dns.png b/pixmaps/dns.pngBinary files differ new file mode 100644 index 00000000..d4bfb82b --- /dev/null +++ b/pixmaps/dns.png diff --git a/pixmaps/gnome-terminal.png b/pixmaps/environment.pngBinary files differ index ceb0fb99..ceb0fb99 100644 --- a/pixmaps/gnome-terminal.png +++ b/pixmaps/environment.png diff --git a/pixmaps/fft.png b/pixmaps/fft.pngBinary files differ new file mode 100644 index 00000000..3a44038c --- /dev/null +++ b/pixmaps/fft.png diff --git a/pixmaps/language.png b/pixmaps/language.pngBinary files differ index ed0480b1..495a94bc 100644 --- a/pixmaps/language.png +++ b/pixmaps/language.png diff --git a/pixmaps/logo.png b/pixmaps/logo.pngBinary files differ index ed4f8ef5..48d49419 100644 --- a/pixmaps/logo.png +++ b/pixmaps/logo.png diff --git a/pixmaps/logo.svg b/pixmaps/logo.svg deleted file mode 100644 index 159b96ed..00000000 --- a/pixmaps/logo.svg +++ /dev/null @@ -1,771 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg -   xmlns:dc="http://purl.org/dc/elements/1.1/" -   xmlns:cc="http://web.resource.org/cc/" -   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" -   xmlns:svg="http://www.w3.org/2000/svg" -   xmlns="http://www.w3.org/2000/svg" -   xmlns:xlink="http://www.w3.org/1999/xlink" -   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" -   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" -   width="32" -   height="32" -   id="svg2327" -   sodipodi:version="0.32" -   inkscape:version="0.44" -   sodipodi:docbase="/home/leandro/Work/hardinfo/trunk/hardinfo2/pixmaps" -   sodipodi:docname="logo.svg" -   version="1.0" -   inkscape:export-filename="/home/leandro/Work/hardinfo/trunk/hardinfo2/pixmaps/logo.png" -   inkscape:export-xdpi="137.46988" -   inkscape:export-ydpi="137.46988"> -  <defs -     id="defs3"> -    <linearGradient -       id="linearGradient2752"> -      <stop -         id="stop2754" -         offset="0" -         style="stop-color:#9d9d9d;stop-opacity:1;" /> -      <stop -         id="stop2756" -         offset="1.0000000" -         style="stop-color:#b9b9b9;stop-opacity:1.0000000;" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2711"> -      <stop -         id="stop2713" -         offset="0.0000000" -         style="stop-color:#909090;stop-opacity:1.0000000;" /> -      <stop -         id="stop2715" -         offset="1.0000000" -         style="stop-color:#bebebe;stop-opacity:0.0000000;" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2701"> -      <stop -         id="stop2703" -         offset="0.0000000" -         style="stop-color:#585956;stop-opacity:1.0000000;" /> -      <stop -         id="stop2705" -         offset="1.0000000" -         style="stop-color:#bbbeb8;stop-opacity:1.0000000;" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2683" -       inkscape:collect="always"> -      <stop -         id="stop2685" -         offset="0" -         style="stop-color:#000000;stop-opacity:1;" /> -      <stop -         id="stop2687" -         offset="1" -         style="stop-color:#000000;stop-opacity:0;" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2675"> -      <stop -         id="stop2677" -         offset="0.0000000" -         style="stop-color:#5b5b97;stop-opacity:1.0000000;" /> -      <stop -         id="stop2679" -         offset="1.0000000" -         style="stop-color:#1b1b43;stop-opacity:1.0000000;" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2667"> -      <stop -         id="stop2669" -         offset="0.0000000" -         style="stop-color:#ffffff;stop-opacity:1.0000000;" /> -      <stop -         id="stop2671" -         offset="1.0000000" -         style="stop-color:#fcfcff;stop-opacity:0.0000000;" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2635" -       inkscape:collect="always"> -      <stop -         id="stop2637" -         offset="0" -         style="stop-color:#f9fff5;stop-opacity:1;" /> -      <stop -         id="stop2639" -         offset="1" -         style="stop-color:#f9fff5;stop-opacity:0;" /> -    </linearGradient> -    <linearGradient -       inkscape:collect="always" -       id="linearGradient2454"> -      <stop -         style="stop-color:#000000;stop-opacity:1;" -         offset="0" -         id="stop2456" /> -      <stop -         style="stop-color:#000000;stop-opacity:0;" -         offset="1" -         id="stop2458" /> -    </linearGradient> -    <linearGradient -       inkscape:collect="always" -       id="linearGradient2415"> -      <stop -         style="stop-color:#ffffff;stop-opacity:1;" -         offset="0" -         id="stop2417" /> -      <stop -         style="stop-color:#ffffff;stop-opacity:0;" -         offset="1" -         id="stop2419" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2253"> -      <stop -         style="stop-color:#8f8f8f;stop-opacity:1.0000000;" -         offset="0.0000000" -         id="stop2255" /> -      <stop -         style="stop-color:#494949;stop-opacity:1.0000000;" -         offset="1.0000000" -         id="stop2257" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2245"> -      <stop -         style="stop-color:#dde1d9;stop-opacity:1.0000000;" -         offset="0.0000000" -         id="stop2247" /> -      <stop -         style="stop-color:#cacdc6;stop-opacity:1.0000000;" -         offset="1.0000000" -         id="stop2249" /> -    </linearGradient> -    <radialGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2454" -       id="radialGradient2119" -       gradientUnits="userSpaceOnUse" -       gradientTransform="scale(1.925808,0.519262)" -       cx="12.57571" -       cy="67.501709" -       fx="12.57571" -       fy="67.501709" -       r="8.7662792" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2245" -       id="linearGradient3151" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.754296,0,0,0.650713,-0.158607,-3.549207)" -       x1="18.316999" -       y1="48.643234" -       x2="18.176752" -       y2="52.536461" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2253" -       id="linearGradient3153" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.737296,0,0,0.665717,-0.158607,-3.549207)" -       x1="10.390738" -       y1="5.3817744" -       x2="32.536823" -       y2="31.246054" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2752" -       id="linearGradient3155" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1.540139,0,0,0.264783,-0.187732,2.141243)" -       x1="8.1134243" -       y1="88.509071" -       x2="8.1134233" -       y2="100.20015" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2752" -       id="linearGradient3157" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1.540139,0,0,0.264783,-0.187732,2.141243)" -       x1="8.1134243" -       y1="88.509071" -       x2="8.1134233" -       y2="100.20015" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2752" -       id="linearGradient3159" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1.540139,0,0,0.264783,-0.187732,2.141243)" -       x1="8.1134243" -       y1="88.509071" -       x2="8.1134233" -       y2="100.20015" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2635" -       id="linearGradient3161" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1.409488,0,0,0.31705,0.718141,-1.635309)" -       x1="13.62871" -       y1="101.2846" -       x2="8.6485014" -       y2="74.098007" /> -    <linearGradient -       y2="3.8451097" -       x2="35.520542" -       y1="3.9384086" -       x1="34.300991" -       gradientUnits="userSpaceOnUse" -       id="linearGradient3006" -       xlink:href="#linearGradient2711" -       inkscape:collect="always" /> -    <linearGradient -       y2="3.8451097" -       x2="35.520542" -       y1="3.9384086" -       x1="34.300991" -       gradientUnits="userSpaceOnUse" -       id="linearGradient3002" -       xlink:href="#linearGradient2711" -       inkscape:collect="always" /> -    <linearGradient -       y2="3.8451097" -       x2="35.520542" -       y1="3.9384086" -       x1="34.300991" -       gradientUnits="userSpaceOnUse" -       id="linearGradient2998" -       xlink:href="#linearGradient2711" -       inkscape:collect="always" /> -    <radialGradient -       r="8.7662792" -       fy="67.501709" -       fx="12.57571" -       cy="67.501709" -       cx="12.57571" -       gradientTransform="scale(1.925808,0.519262)" -       gradientUnits="userSpaceOnUse" -       id="radialGradient2013" -       xlink:href="#linearGradient2454" -       inkscape:collect="always" /> -    <linearGradient -       inkscape:collect="always" -       id="linearGradient2321"> -      <stop -         style="stop-color:#7b7f7a;stop-opacity:1;" -         offset="0" -         id="stop2323" /> -      <stop -         style="stop-color:#7b7f7a;stop-opacity:0;" -         offset="1" -         id="stop2325" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2329"> -      <stop -         style="stop-color:#ffffff;stop-opacity:1.0000000;" -         offset="0.0000000" -         id="stop2331" /> -      <stop -         style="stop-color:#ffffff;stop-opacity:0.0000000;" -         offset="1.0000000" -         id="stop2333" /> -    </linearGradient> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2667" -       id="linearGradient3407" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.825985,0,0,0.597304,3.484242,-1.538064)" -       x1="11.492236" -       y1="1.6537577" -       x2="17.199417" -       y2="26.729263" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2415" -       id="linearGradient3410" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.735452,0,0,0.59631,3.472291,0.397507)" -       x1="17.698339" -       y1="13.004725" -       x2="34.974548" -       y2="55.200756" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2683" -       id="linearGradient3413" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(3.803441,0,0,0.116853,3.71313,-1.108211)" -       x1="3.7069976" -       y1="171.29134" -       x2="3.7069974" -       y2="162.45061" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2675" -       id="linearGradient3416" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.777649,0,0,0.664731,3.629634,-1.713604)" -       x1="19.150396" -       y1="32.622238" -       x2="16.315819" -       y2="8.8666229" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2245" -       id="linearGradient3419" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.770539,0,0,0.610387,1.337506,-1.56896)" -       x1="8.6116238" -       y1="7.2293582" -       x2="34.784473" -       y2="33.339787" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2253" -       id="linearGradient3421" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(0.753173,0,0,0.624463,2.445717,-0.669394)" -       x1="10.390738" -       y1="5.3817744" -       x2="32.536823" -       y2="31.246054" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2701" -       id="linearGradient3424" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1.210897,0,0,0.852618,1.322911,-29.79883)" -       x1="12.206709" -       y1="53.535141" -       x2="12.127711" -       y2="64.892525" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2329" -       id="linearGradient3430" -       gradientUnits="userSpaceOnUse" -       x1="-35.122688" -       y1="34.242237" -       x2="-35.074745" -       y2="30.962345" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2321" -       id="linearGradient3432" -       gradientUnits="userSpaceOnUse" -       x1="-35.658386" -       y1="33.416473" -       x2="-35.658386" -       y2="28.205938" /> -    <linearGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2711" -       id="linearGradient3436" -       gradientUnits="userSpaceOnUse" -       x1="34.300991" -       y1="3.9384086" -       x2="35.520542" -       y2="3.8451097" /> -    <radialGradient -       r="8.753643" -       fy="16.855663" -       fx="-19.515638" -       cy="16.855663" -       cx="-19.515638" -       gradientTransform="matrix(2.828299,0,0,4.35457,72.19634,-62.10365)" -       gradientUnits="userSpaceOnUse" -       id="radialGradient2953" -       xlink:href="#linearGradient2431" -       inkscape:collect="always" /> -    <radialGradient -       r="22.376116" -       fy="28.458725" -       fx="26.544321" -       cy="28.458725" -       cx="26.544321" -       gradientTransform="matrix(1.238342,5.954846e-3,-6.507762e-3,1.351272,-6.992513,-9.744842)" -       gradientUnits="userSpaceOnUse" -       id="radialGradient2062" -       xlink:href="#linearGradient2933" -       inkscape:collect="always" /> -    <linearGradient -       id="linearGradient2431"> -      <stop -         style="stop-color:#ffffff;stop-opacity:1;" -         offset="0" -         id="stop2433" /> -      <stop -         style="stop-color:#b8b8b8;stop-opacity:1;" -         offset="1" -         id="stop2435" /> -    </linearGradient> -    <linearGradient -       inkscape:collect="always" -       id="linearGradient21644"> -      <stop -         style="stop-color:#000000;stop-opacity:1;" -         offset="0" -         id="stop21646" /> -      <stop -         style="stop-color:#000000;stop-opacity:0;" -         offset="1" -         id="stop21648" /> -    </linearGradient> -    <linearGradient -       id="linearGradient2933"> -      <stop -         id="stop2935" -         offset="0" -         style="stop-color:#9cbcde;stop-opacity:1" /> -      <stop -         id="stop2937" -         offset="1" -         style="stop-color:#204a87" /> -    </linearGradient> -    <radialGradient -       inkscape:collect="always" -       xlink:href="#linearGradient21644" -       id="radialGradient1887" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1,0,0,0.595238,0,14.875)" -       cx="25.125" -       cy="36.75" -       fx="25.125" -       fy="36.75" -       r="15.75" /> -    <radialGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2431" -       id="radialGradient1996" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(2.828299,0,0,4.35457,111.3213,-64.97613)" -       cx="-19.515638" -       cy="16.855663" -       fx="-19.515638" -       fy="16.855663" -       r="8.753643" /> -    <radialGradient -       inkscape:collect="always" -       xlink:href="#linearGradient21644" -       id="radialGradient2012" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1,0,0,0.595238,0,14.875)" -       cx="25.125" -       cy="36.75" -       fx="25.125" -       fy="36.75" -       r="15.75" /> -    <radialGradient -       inkscape:collect="always" -       xlink:href="#linearGradient2933" -       id="radialGradient2014" -       gradientUnits="userSpaceOnUse" -       gradientTransform="matrix(1.238342,5.954846e-3,-6.507762e-3,1.351272,-6.992513,-9.744842)" -       cx="26.544321" -       cy="28.458725" -       fx="26.544321" -       fy="28.458725" -       r="22.376116" /> -  </defs> -  <sodipodi:namedview -     id="base" -     pagecolor="#ffffff" -     bordercolor="#666" -     borderopacity="1" -     inkscape:pageopacity="0.0" -     inkscape:pageshadow="2" -     inkscape:zoom="8" -     inkscape:cx="37.875488" -     inkscape:cy="18.167741" -     inkscape:current-layer="layer1" -     showgrid="false" -     inkscape:grid-bbox="true" -     inkscape:document-units="px" -     inkscape:window-width="1034" -     inkscape:window-height="622" -     inkscape:window-x="236" -     inkscape:window-y="25" -     inkscape:showpageshadow="false" -     width="32px" -     height="32px" -     showborder="false" /> -  <metadata -     id="metadata4"> -    <rdf:RDF> -      <cc:Work -         rdf:about=""> -        <dc:format>image/svg+xml</dc:format> -        <dc:type -           rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> -        <dc:title>Computer</dc:title> -        <dc:date>2005-03-08</dc:date> -        <dc:creator> -          <cc:Agent> -            <dc:title>Jakub Steiner</dc:title> -          </cc:Agent> -        </dc:creator> -        <dc:subject> -          <rdf:Bag> -            <rdf:li>workstation</rdf:li> -            <rdf:li>computer</rdf:li> -            <rdf:li>node</rdf:li> -            <rdf:li>client</rdf:li> -          </rdf:Bag> -        </dc:subject> -        <cc:license -           rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" /> -        <dc:source>http://jimmac.musichall.cz/</dc:source> -      </cc:Work> -      <cc:License -         rdf:about="http://creativecommons.org/licenses/by-sa/2.0/"> -        <cc:permits -           rdf:resource="http://web.resource.org/cc/Reproduction" /> -        <cc:permits -           rdf:resource="http://web.resource.org/cc/Distribution" /> -        <cc:requires -           rdf:resource="http://web.resource.org/cc/Notice" /> -        <cc:requires -           rdf:resource="http://web.resource.org/cc/Attribution" /> -        <cc:permits -           rdf:resource="http://web.resource.org/cc/DerivativeWorks" /> -        <cc:requires -           rdf:resource="http://web.resource.org/cc/ShareAlike" /> -      </cc:License> -    </rdf:RDF> -  </metadata> -  <g -     id="layer1" -     inkscape:label="Layer 1" -     inkscape:groupmode="layer"> -    <path -       transform="matrix(0.842932,0,0,0.860842,-4.144223,-2.66695)" -       d="M 41.10058 35.051105 A 16.882174 4.552 0 1 1  7.3362331,35.051105 A 16.882174 4.552 0 1 1  41.10058 35.051105 z" -       sodipodi:ry="4.552" -       sodipodi:rx="16.882174" -       sodipodi:cy="35.051105" -       sodipodi:cx="24.218407" -       id="path2657" -       style="color:black;fill:url(#radialGradient2119);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:0.70063692;visibility:visible;display:inline;overflow:visible" -       sodipodi:type="arc" /> -    <path -       sodipodi:type="arc" -       style="opacity:0.50857143;color:black;fill:url(#radialGradient2013);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:0.70063692;visibility:visible;display:inline;overflow:visible" -       id="path2452" -       sodipodi:cx="24.218407" -       sodipodi:cy="35.051105" -       sodipodi:rx="16.882174" -       sodipodi:ry="4.552" -       d="M 41.10058 35.051105 A 16.882174 4.552 0 1 1  7.3362331,35.051105 A 16.882174 4.552 0 1 1  41.10058 35.051105 z" -       transform="matrix(0.700168,0,0,1.245259,-0.630378,-20.73743)" /> -    <path -       sodipodi:type="arc" -       style="color:black;fill:#adb0aa;fill-opacity:1;fill-rule:evenodd;stroke:#4b4d4a;stroke-width:1.46916819;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       id="path2407" -       sodipodi:cx="-35.658386" -       sodipodi:cy="29.716238" -       sodipodi:rx="9.3944187" -       sodipodi:ry="3.939595" -       d="M -26.263968 29.716238 A 9.3944187 3.939595 0 1 1  -45.052805,29.716238 A 9.3944187 3.939595 0 1 1  -26.263968 29.716238 z" -       transform="matrix(0.694942,0,0,0.666667,40.76488,2.385605)" /> -    <path -       transform="matrix(0.638173,0,0,0.52797,38.69372,6.192003)" -       d="M -26.263968 29.716238 A 9.3944187 3.939595 0 1 1  -45.052805,29.716238 A 9.3944187 3.939595 0 1 1  -26.263968 29.716238 z" -       sodipodi:ry="3.939595" -       sodipodi:rx="9.3944187" -       sodipodi:cy="29.716238" -       sodipodi:cx="-35.658386" -       id="path1825" -       style="color:black;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3432);stroke-width:1.72276604;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       sodipodi:type="arc" /> -    <path -       sodipodi:type="arc" -       style="color:black;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3430);stroke-width:1.67341197;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       id="path2983" -       sodipodi:cx="-35.658386" -       sodipodi:cy="29.716238" -       sodipodi:rx="9.3944187" -       sodipodi:ry="3.939595" -       d="M -26.263968 29.716238 A 9.3944187 3.939595 0 1 1  -45.052805,29.716238 A 9.3944187 3.939595 0 1 1  -26.263968 29.716238 z" -       transform="matrix(0.628221,0,0,0.568437,38.54718,4.306169)" /> -    <rect -       y="17.750319" -       x="12.971182" -       height="4.2433615" -       width="6.0264516" -       id="rect2699" -       style="color:black;fill:url(#linearGradient3424);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.60872948;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /> -    <path -       sodipodi:nodetypes="ccccccccccccccccc" -       style="fill:#d0d0d0;fill-opacity:1;fill-rule:evenodd;stroke:#979797;stroke-width:0.4000003;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1" -       d="M 17.126296,19.177505 L 17.083349,19.844172 C 17.083349,19.844172 20.054664,22.243617 23.267708,22.645845 C 24.874229,22.846958 26.5342,23.11412 27.905977,23.437512 C 29.277754,23.760904 30.37172,24.183916 30.740474,24.541679 C 30.953774,24.74862 31.050423,24.924105 31.08405,25.062513 C 31.117678,25.20092 31.110311,25.299056 31.01963,25.437513 C 30.838269,25.714426 30.277605,26.082614 29.323226,26.375013 C 27.414468,26.95981 24.018129,27.333347 19.31659,27.333347 L 19.31659,28.000014 C 24.055181,28.000014 27.468719,27.648233 29.516487,27.020847 C 30.540371,26.707153 31.251503,26.343722 31.599413,25.812513 C 31.773369,25.546909 31.844947,25.220213 31.771201,24.916679 C 31.697456,24.613145 31.506954,24.326975 31.234364,24.062512 C 30.631341,23.477465 29.491174,23.124885 28.077765,22.791678 C 26.664356,22.458471 24.974773,22.182125 23.353601,21.979178 C 20.111261,21.573283 17.126296,19.177505 17.126296,19.177505 z " -       id="path2411" /> -    <path -       style="color:black;fill:url(#linearGradient3419);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3421);stroke-width:1.0000006;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       d="M 4.5468197,0.5000001 L 27.453174,0.5000001 C 28.074688,0.5000001 28.560804,0.9024013 28.589859,1.4666116 L 29.498282,19.106685 C 29.537979,19.877537 28.883783,20.499998 28.120482,20.499998 L 3.8795124,20.499998 C 3.116211,20.499998 2.4620149,19.877537 2.5017119,19.106685 L 3.4101343,1.4666116 C 3.4376069,0.9331395 3.7835182,0.5000001 4.5468197,0.5000001 z " -       id="rect2404" -       sodipodi:nodetypes="cssssssss" /> -    <path -       sodipodi:nodetypes="ccccc" -       id="path2377" -       d="M 6.0727205,2.2499997 L 5.2499969,17.749996 L 26.212503,17.749996 L 25.328301,2.3156892 L 6.0727205,2.2499997 z " -       style="fill:url(#linearGradient3416);fill-opacity:1;fill-rule:evenodd;stroke:#000079;stroke-width:0.50000036;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> -    <path -       sodipodi:nodetypes="cc" -       style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:url(#linearGradient3413);stroke-width:0.99618173;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.24840764" -       d="M 4.4980854,18.501907 L 28.117082,18.501907" -       id="path2393" /> -    <path -       sodipodi:nodetypes="cssssssss" -       id="path2397" -       d="M 4.7430574,1.5249746 L 27.207154,1.4999972 C 27.39545,1.4997879 27.578376,1.6567607 27.59351,1.9311672 L 28.497431,18.319972 C 28.535954,19.018408 28.139187,19.499992 27.436553,19.499992 L 4.5221432,19.499992 C 3.8195091,19.499992 3.4648201,19.018441 3.5027474,18.319972 L 4.3815789,2.1353932 C 4.4072623,1.6624066 4.4920129,1.5252537 4.7430574,1.5249746 z " -       style="color:black;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3410);stroke-width:0.99999988;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:0.70063692;visibility:visible;display:inline;overflow:visible" /> -    <path -       sodipodi:nodetypes="ccccc" -       style="opacity:0.53142856;fill:url(#linearGradient3407);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" -       d="M 6.2315651,2.5138621 L 5.6965455,14.427421 C 13.059641,12.827001 15.977526,7.4326186 25.132577,5.662917 L 25.024928,2.5579048 L 6.2315651,2.5138621 z " -       id="path2443" /> -    <path -       id="text2735" -       d="M 15.000002,18.128436 L 15.187812,18.128436 C 15.243656,18.128437 15.286469,18.140879 15.316252,18.165763 C 15.346232,18.190452 15.361221,18.225721 15.361222,18.271572 C 15.361221,18.317619 15.346232,18.353084 15.316252,18.377969 C 15.286469,18.402658 15.243656,18.415002 15.187812,18.415002 L 15.113158,18.415002 L 15.113158,18.567249 L 15.000002,18.567249 L 15.000002,18.128436 M 15.113158,18.210438 L 15.113158,18.333 L 15.175762,18.333 C 15.197707,18.333 15.214656,18.327709 15.226609,18.317129 C 15.238561,18.306352 15.244538,18.291167 15.244538,18.271572 C 15.244538,18.251978 15.238561,18.236891 15.226609,18.226309 C 15.214656,18.215729 15.197707,18.210438 15.175762,18.210438 L 15.113158,18.210438 M 15.641321,18.202502 C 15.606835,18.202503 15.580089,18.215239 15.561082,18.240711 C 15.542076,18.266184 15.532573,18.302041 15.532573,18.348284 C 15.532573,18.39433 15.542076,18.43009 15.561082,18.455562 C 15.580089,18.481035 15.606835,18.493771 15.641321,18.493771 C 15.676003,18.493771 15.702847,18.481035 15.721854,18.455562 C 15.74086,18.43009 15.750363,18.39433 15.750363,18.348284 C 15.750363,18.302041 15.74086,18.266184 15.721854,18.240711 C 15.702847,18.215239 15.676003,18.202503 15.641321,18.202502 M 15.641321,18.1205 C 15.71186,18.120501 15.767116,18.140683 15.807089,18.181047 C 15.847061,18.221411 15.867047,18.277157 15.867047,18.348284 C 15.867047,18.419215 15.847061,18.474862 15.807089,18.515226 C 15.767116,18.555591 15.71186,18.575773 15.641321,18.575773 C 15.570978,18.575773 15.515722,18.555591 15.475554,18.515226 C 15.435582,18.474862 15.415596,18.419215 15.415596,18.348284 C 15.415596,18.277157 15.435582,18.221411 15.475554,18.181047 C 15.515722,18.140683 15.570978,18.120501 15.641321,18.1205 M 15.952282,18.128436 L 16.078665,18.128436 L 16.23826,18.429404 L 16.23826,18.128436 L 16.345539,18.128436 L 16.345539,18.567249 L 16.219155,18.567249 L 16.059561,18.266281 L 16.059561,18.567249 L 15.952282,18.567249 L 15.952282,18.128436 M 16.394328,18.128436 L 16.518066,18.128436 L 16.617996,18.284798 L 16.717927,18.128436 L 16.841959,18.128436 L 16.674722,18.382378 L 16.674722,18.567249 L 16.561565,18.567249 L 16.561565,18.382378 L 16.394328,18.128436" -       style="font-size:0.9029026px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;writing-mode:lr-tb;text-anchor:start;fill:#4a4a4a;fill-opacity:1;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" /> -    <path -       sodipodi:type="arc" -       style="color:black;fill:url(#linearGradient2998);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       id="path2996" -       sodipodi:cx="34.780815" -       sodipodi:cy="3.9384086" -       sodipodi:rx="0.83968931" -       sodipodi:ry="0.83968931" -       d="M 35.620504 3.9384086 A 0.83968931 0.83968931 0 1 1  33.941126,3.9384086 A 0.83968931 0.83968931 0 1 1  35.620504 3.9384086 z" -       transform="matrix(1.191851,0,0,0.590943,-14.20356,3.172623)" /> -    <path -       sodipodi:type="arc" -       style="color:black;fill:url(#linearGradient3002);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       id="path3000" -       sodipodi:cx="34.780815" -       sodipodi:cy="3.9384086" -       sodipodi:rx="0.83968931" -       sodipodi:ry="0.83968931" -       d="M 35.620504 3.9384086 A 0.83968931 0.83968931 0 1 1  33.941126,3.9384086 A 0.83968931 0.83968931 0 1 1  35.620504 3.9384086 z" -       transform="matrix(1.191851,0,0,0.590943,-14.07856,5.172623)" /> -    <path -       sodipodi:type="arc" -       style="color:black;fill:url(#linearGradient3006);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       id="path3004" -       sodipodi:cx="34.780815" -       sodipodi:cy="3.9384086" -       sodipodi:rx="0.83968931" -       sodipodi:ry="0.83968931" -       d="M 35.620504 3.9384086 A 0.83968931 0.83968931 0 1 1  33.941126,3.9384086 A 0.83968931 0.83968931 0 1 1  35.620504 3.9384086 z" -       transform="matrix(1.191851,0,0,0.590943,-13.98481,7.172623)" /> -    <g -       id="g3140" -       transform="matrix(1.07411,0,0,1,-7.474908e-2,0)"> -      <path -         style="color:black;fill:url(#linearGradient3151);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3153);stroke-width:0.96488512;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -         d="M 4.1555474,23.519597 L 24.852756,23.519597 C 25.599965,23.519597 25.505238,23.719163 25.581927,23.970171 L 27.474336,30.164233 C 27.551025,30.415242 27.492376,30.614807 26.745165,30.614807 L 2.2631378,30.614807 C 1.515927,30.614807 1.457278,30.415242 1.5339666,30.164233 L 3.4263762,23.970171 C 3.5030648,23.719162 3.4083366,23.519597 4.1555474,23.519597 z " -         id="path2409" -         sodipodi:nodetypes="cssssssss" /> -      <path -         style="fill:#7a7d77;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" -         d="M 4.1084868,24.998609 L 2.9283249,28.967343 L 6.5868268,28.967343 L 6.9408752,27.393536 L 16.854234,27.393536 L 17.2212,29 L 21.338848,29 L 20.217696,24.998609 L 4.1084868,24.998609 z " -         id="path2611" -         sodipodi:nodetypes="ccccccccc" /> -      <path -         style="fill:#777874;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" -         d="M 7.2359158,27.667242 L 6.9408752,28.967344 L 16.795227,28.967344 L 16.500186,27.598815 L 7.2359158,27.667242 z " -         id="path2613" /> -      <path -         id="path2619" -         d="M 24.938342,24.99861 L 26.059498,28.898918 L 22.400995,28.830491 L 21.397857,25.067036 L 24.938342,24.99861 z " -         style="color:black;fill:#777a75;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /> -      <g -         transform="matrix(0.99867,0,0,0.940591,3.681797e-2,1.004505)" -         id="g2197"> -        <path -           id="path2615" -           d="M 24.878007,25.565138 L 25.997768,28.64651 L 22.343815,28.59245 L 21.341925,25.619197 L 24.878007,25.565138 z " -           style="color:black;fill:url(#linearGradient3155);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /> -        <path -           style="fill:url(#linearGradient3157);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" -           d="M 4.0740554,25.511079 L 2.8953613,28.64651 L 6.5493134,28.64651 L 6.9029215,27.403149 L 16.803952,27.403149 L 17.170462,28.672308 L 21.282989,28.672308 L 20.163231,25.511079 L 4.0740554,25.511079 z " -           id="path2617" -           sodipodi:nodetypes="ccccccccc" /> -        <path -           style="color:black;fill:url(#linearGradient3159);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.25pt;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -           d="M 7.1975952,27.673445 L 6.9029215,28.700569 L 16.745018,28.700569 L 16.450344,27.619386 L 7.1975952,27.673445 z " -           id="path2621" /> -      </g> -      <path -         sodipodi:nodetypes="ccccc" -         id="path2631" -         d="M 4.0897989,24.249996 L 25.016002,24.249996 L 26.750007,29.750003 L 2.2500001,29.750003 L 4.0897989,24.249996 z " -         style="color:black;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3161);stroke-width:0.48244256;stroke-linecap:butt;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" /> -    </g> -    <path -       sodipodi:type="arc" -       style="color:black;fill:url(#linearGradient3436);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -       id="path3434" -       sodipodi:cx="34.780815" -       sodipodi:cy="3.9384086" -       sodipodi:rx="0.83968931" -       sodipodi:ry="0.83968931" -       d="M 35.620504 3.9384086 A 0.83968931 0.83968931 0 1 1  33.941126,3.9384086 A 0.83968931 0.83968931 0 1 1  35.620504 3.9384086 z" -       transform="matrix(1.191851,0,0,0.590943,-14.45356,1.172623)" /> -    <g -       id="g2005" -       transform="matrix(0.470834,0,0,0.470834,-17.64221,12.13147)"> -      <path -         transform="matrix(0.773935,0,0,0.397914,36.00038,9.77376)" -         d="M 40.875 36.75 A 15.75 9.375 0 1 1  9.375,36.75 A 15.75 9.375 0 1 1  40.875 36.75 z" -         sodipodi:ry="9.375" -         sodipodi:rx="15.75" -         sodipodi:cy="36.75" -         sodipodi:cx="25.125" -         id="path21642" -         style="opacity:0.63068183;color:black;fill:url(#radialGradient2012);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible" -         sodipodi:type="arc" /> -      <path -         transform="matrix(0.664228,0,0,0.641487,39.24394,-2.658954)" -         d="M 45.785164 23.825787 A 21.876116 21.876116 0 1 1  2.0329323,23.825787 A 21.876116 21.876116 0 1 1  45.785164 23.825787 z" -         sodipodi:ry="21.876116" -         sodipodi:rx="21.876116" -         sodipodi:cy="23.825787" -         sodipodi:cx="23.909048" -         id="path2093" -         style="fill:url(#radialGradient2014);fill-opacity:1;stroke:#204a87;stroke-width:1.43783867" -         sodipodi:type="arc" /> -      <path -         sodipodi:type="arc" -         style="opacity:0.96022728;fill:none;fill-opacity:1;stroke:white;stroke-width:3.43368769;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" -         id="path2209" -         sodipodi:cx="23.909048" -         sodipodi:cy="23.825787" -         sodipodi:rx="21.876116" -         sodipodi:ry="21.876116" -         d="M 45.785164 23.825787 A 21.876116 21.876116 0 1 1  2.0329323,23.825787 A 21.876116 21.876116 0 1 1  45.785164 23.825787 z" -         transform="matrix(0.594256,0,0,0.570906,40.91689,-0.974785)" /> -      <text -         id="text2001" -         y="21.797297" -         x="50.589512" -         style="font-size:25.51218796px;font-style:normal;font-weight:normal;fill:#f2f2f2;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Alianna" -         xml:space="preserve"><tspan -           style="fill:#f2f2f2;font-family:Arial Black" -           y="21.797297" -           x="50.589512" -           id="tspan2003" -           sodipodi:role="line">i</tspan></text> -    </g> -  </g> -</svg> diff --git a/pixmaps/logo.xcf b/pixmaps/logo.xcfBinary files differ new file mode 100644 index 00000000..e4295251 --- /dev/null +++ b/pixmaps/logo.xcf diff --git a/pixmaps/nautilus.png b/pixmaps/nautilus.pngBinary files differ new file mode 100644 index 00000000..945d4d74 --- /dev/null +++ b/pixmaps/nautilus.png diff --git a/pixmaps/network-connections.png b/pixmaps/network-connections.pngBinary files differ new file mode 100644 index 00000000..883a003b --- /dev/null +++ b/pixmaps/network-connections.png diff --git a/pixmaps/network-generic.png b/pixmaps/network-generic.pngBinary files differ deleted file mode 100644 index caebd989..00000000 --- a/pixmaps/network-generic.png +++ /dev/null diff --git a/pixmaps/network-interface.png b/pixmaps/network-interface.pngBinary files differ new file mode 100644 index 00000000..51c8b16f --- /dev/null +++ b/pixmaps/network-interface.png diff --git a/pixmaps/network-statistics.png b/pixmaps/network-statistics.pngBinary files differ new file mode 100644 index 00000000..18a118a2 --- /dev/null +++ b/pixmaps/network-statistics.png diff --git a/pixmaps/network.png b/pixmaps/network.pngBinary files differ index 51c8b16f..caebd989 100644 --- a/pixmaps/network.png +++ b/pixmaps/network.png diff --git a/pixmaps/nqueens.png b/pixmaps/nqueens.pngBinary files differ new file mode 100644 index 00000000..17499732 --- /dev/null +++ b/pixmaps/nqueens.png diff --git a/pixmaps/report-large.png b/pixmaps/report-large.pngBinary files differ index 1cc693f5..694c9211 100644 --- a/pixmaps/report-large.png +++ b/pixmaps/report-large.png diff --git a/pixmaps/report.png b/pixmaps/report.pngBinary files differ index 48bd5d01..dc566f59 100644 --- a/pixmaps/report.png +++ b/pixmaps/report.png diff --git a/pixmaps/resources.png b/pixmaps/resources.pngBinary files differ new file mode 100644 index 00000000..308acb27 --- /dev/null +++ b/pixmaps/resources.png diff --git a/pixmaps/summary.png b/pixmaps/summary.pngBinary files differ index 0abb49f3..b66871a9 100644 --- a/pixmaps/summary.png +++ b/pixmaps/summary.png diff --git a/pixmaps/therm.png b/pixmaps/therm.pngBinary files differ index 3dac3913..73f80da6 100644 --- a/pixmaps/therm.png +++ b/pixmaps/therm.png diff --git a/pixmaps/usb.png b/pixmaps/usb.pngBinary files differ index 7c7c6746..af28b288 100644 --- a/pixmaps/usb.png +++ b/pixmaps/usb.png diff --git a/pixmaps/usbfldisk.png b/pixmaps/usbfldisk.pngBinary files differ new file mode 100644 index 00000000..c6a2d0c6 --- /dev/null +++ b/pixmaps/usbfldisk.png @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2008 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -64,8 +64,31 @@ void report_key_value(ReportContext * ctx, gchar * key, gchar * value)      ctx->keyvalue(ctx, key, value);  } +gint report_get_visible_columns(ReportContext *ctx) +{ +    gint columns; +     +    /* Column count starts at two, since we always have at least +       two columns visible. */ +    columns = 2; + +    /* Either the Progress column or the Value column is available at +       the same time. So we don't count them. */ + +    if (ctx->columns & REPORT_COL_EXTRA1) +      columns++; +     +    if (ctx->columns & REPORT_COL_EXTRA2) +      columns++; +     +    return columns; +} +  void report_context_configure(ReportContext * ctx, GKeyFile * keyfile)  { +    gchar **keys; +    const gchar *group = "$ShellParam$"; +          /* FIXME: sometime in the future we'll save images in the report. this         flag will be set if we should support that. @@ -73,10 +96,50 @@ void report_context_configure(ReportContext * ctx, GKeyFile * keyfile)         http://en.wikipedia.org/wiki/Data:_URI_scheme */      ctx->is_image_enabled = (g_key_file_get_boolean(keyfile, -						    "$ShellParam$", +						    group,  						    "ViewType", -						    NULL) == -			     SHELL_VIEW_PROGRESS); +						    NULL) == SHELL_VIEW_PROGRESS); + +     +    keys = g_key_file_get_keys(keyfile, group, NULL, NULL); +    if (keys) { +      gint i = 0; +       +      for (; keys[i]; i++) { +        gchar *key = keys[i]; +         +        if (g_str_equal(key, "ShowColumnHeaders")) { +          ctx->show_column_headers = g_key_file_get_boolean(keyfile, group, key, NULL); +        } else if (g_str_has_prefix(key, "ColumnTitle")) { +          gchar *value, *title = strchr(key, '$') + 1; +           +          value = g_key_file_get_value(keyfile, group, key, NULL); +          if (g_str_equal(title, "Extra1")) { +                  ctx->columns |= REPORT_COL_EXTRA1; +          } else if (g_str_equal(title, "Extra2")) { +                  ctx->columns |= REPORT_COL_EXTRA2; +          } else if (g_str_equal(title, "Value")) { +                  ctx->columns |= REPORT_COL_VALUE; +          } else if (g_str_equal(title, "TextValue")) { +                  ctx->columns |= REPORT_COL_TEXTVALUE; +          } else if (g_str_equal(title, "Progress")) { +                  ctx->columns |= REPORT_COL_PROGRESS; +          } +           +          g_hash_table_replace(ctx->column_titles, title, g_strdup(value)); +           +          g_free(value); +        } else if (g_str_equal(key, "ViewType")) { +          if (g_key_file_get_integer(keyfile, group, "ViewType", NULL) == SHELL_VIEW_PROGRESS) { +            ctx->columns &= ~REPORT_COL_VALUE; +            ctx->columns |= REPORT_COL_PROGRESS; +          }      +        } +      } + +      g_strfreev(keys);     +    } +      }  void report_table(ReportContext * ctx, gchar * text) @@ -85,8 +148,20 @@ void report_table(ReportContext * ctx, gchar * text)      gchar **groups;      gint i; +    /* make only "Value" column visible ("Key" column is always visible) */ +    ctx->columns = REPORT_COL_VALUE; +    ctx->show_column_headers = FALSE; + +    /**/      g_key_file_load_from_data(key_file, text, strlen(text), 0, NULL);      groups = g_key_file_get_groups(key_file, NULL); +     +    for (i = 0; groups[i]; i++) { +	if (groups[i][0] == '$') { +	    report_context_configure(ctx, key_file); +	    break; +	} +    }      for (i = 0; groups[i]; i++) {  	gchar *group, *tmpgroup; @@ -94,7 +169,6 @@ void report_table(ReportContext * ctx, gchar * text)  	gint j;  	if (groups[i][0] == '$') { -	    report_context_configure(ctx, key_file);  	    continue;  	} @@ -115,11 +189,9 @@ void report_table(ReportContext * ctx, gchar * text)  		gchar *key = keys[j];  		gchar *value; -		value = -		    g_key_file_get_value(key_file, tmpgroup, key, NULL); +		value = g_key_file_get_value(key_file, tmpgroup, key, NULL); -		if (g_utf8_validate(key, -1, NULL) -		    && g_utf8_validate(value, -1, NULL)) { +		if (g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) {  		    strend(key, '#');  		    if (g_str_equal(value, "...")) { @@ -128,7 +200,7 @@ void report_table(ReportContext * ctx, gchar * text)  			    value = g_strdup("...");  			}  		    } - +		      		    if (*key == '$') {  			report_key_value(ctx, strchr(key + 1, '$') + 1,  					 value); @@ -168,45 +240,80 @@ static void report_html_header(ReportContext * ctx)  	 "    .sstitle{ font: bold 80%% serif; color: #000000; background: #efefef }\n"  	 "    .field  { font: 80%% sans-serif; color: #000000; padding: 2px; padding-left: 50px }\n"  	 "    .value  { font: 80%% sans-serif; color: #505050 }\n" -	 "</style>\n" "</head><body>\n" "<table width=\"100%%\"><tbody>", +	 "</style>\n" "</head><body>\n",  	 VERSION);  }  static void report_html_footer(ReportContext * ctx)  {      ctx->output = h_strconcat(ctx->output, -			      "</tbody></table></body></html>", NULL); +			      "</table></html>", NULL);  }  static void report_html_title(ReportContext * ctx, gchar * text)  { -    ctx->output = h_strdup_cprintf("<tr><td colspan=\"2\" class=\"titl" -				  "e\">%s</td></tr>\n", ctx->output, text); +    if (!ctx->first_table) { +      ctx->output = h_strdup_cprintf("</table>", ctx->output); +    } + +    ctx->output = h_strdup_cprintf("<h1 class=\"title\">%s</h1>", ctx->output, text);  }  static void report_html_subtitle(ReportContext * ctx, gchar * text)  { -    ctx->output = h_strdup_cprintf("<tr><td colspan=\"2\" class=\"stit" +    gint columns = report_get_visible_columns(ctx); + +    if (!ctx->first_table) { +      ctx->output = h_strdup_cprintf("</table>", ctx->output); +    } else { +      ctx->first_table = FALSE; +    } + +    ctx->output = h_strdup_cprintf("<table><tr><td colspan=\"%d\" class=\"stit"  				  "le\">%s</td></tr>\n",  				  ctx->output, +				  columns,  				  text);  }  static void report_html_subsubtitle(ReportContext * ctx, gchar * text)  { -    ctx->output = h_strdup_cprintf("<tr><td colspan=\"2\" class=\"ssti" +    gint columns = report_get_visible_columns(ctx); + +    ctx->output = h_strdup_cprintf("<tr><td colspan=\"%d\" class=\"ssti"  				  "tle\">%s</td></tr>\n",  				  ctx->output, +				  columns,  				  text);  }  static void  report_html_key_value(ReportContext * ctx, gchar * key, gchar * value)  { -    ctx->output = h_strdup_cprintf("<tr><td class=\"field\">%s</td>" -				  "<td class=\"value\">%s</td></tr>\n", -				  ctx->output, -				  key, value); +    gint columns = report_get_visible_columns(ctx); +    gchar **values; +    gint i; +     +    if (columns == 2) { +      ctx->output = h_strdup_cprintf("<tr><td class=\"field\">%s</td>" +                                    "<td class=\"value\">%s</td></tr>\n", +                                    ctx->output, +                                    key, value); +    } else { +      values = g_strsplit(value, "|", columns); +       +      ctx->output = h_strdup_cprintf("\n<tr>\n<td class=\"field\">%s</td>", ctx->output, key); +       +      for (i = columns - 2; i >= 0; i--) { +        ctx->output = h_strdup_cprintf("<td class=\"value\">%s</td>", +                                       ctx->output, +                                       values[i]); +      } + +      ctx->output = h_strdup_cprintf("</tr>\n", ctx->output); +       +      g_strfreev(values); +    }  }  static void report_text_header(ReportContext * ctx) @@ -255,11 +362,30 @@ static void report_text_subsubtitle(ReportContext * ctx, gchar * text)  static void  report_text_key_value(ReportContext * ctx, gchar * key, gchar * value)  { -    if (strlen(value)) -	ctx->output = -	    h_strdup_cprintf("%s\t\t: %s\n", ctx->output, key, value); -    else -	ctx->output = h_strdup_cprintf("%s\n", ctx->output, key); +    gint columns = report_get_visible_columns(ctx); +    gchar **values; +    gint i; +     +    if (columns == 2) { +      if (strlen(value)) +          ctx->output = h_strdup_cprintf("%s\t\t: %s\n", ctx->output, key, value); +      else +          ctx->output = h_strdup_cprintf("%s\n", ctx->output, key); +    } else { +      values = g_strsplit(value, "|", columns); +       +      ctx->output = h_strdup_cprintf("%s\t", ctx->output, key); +       +      for (i = columns - 2; i >= 0; i--) { +        ctx->output = h_strdup_cprintf("%s\t", +                                       ctx->output, +                                       values[i]); +      } + +      ctx->output = h_strdup_cprintf("\n", ctx->output); +       +      g_strfreev(values); +    }  }  static GSList *report_create_module_list_from_dialog(ReportDialog * rd) @@ -394,6 +520,9 @@ ReportContext *report_context_html_new()      ctx->output = g_strdup("");      ctx->format = REPORT_FORMAT_HTML; +    ctx->column_titles = g_hash_table_new(g_str_hash, g_str_equal); +    ctx->first_table = TRUE; +      return ctx;  } @@ -411,12 +540,16 @@ ReportContext *report_context_text_new()      ctx->output = g_strdup("");      ctx->format = REPORT_FORMAT_TEXT; +     +    ctx->column_titles = g_hash_table_new(g_str_hash, g_str_equal); +    ctx->first_table = TRUE;      return ctx;  }  void report_context_free(ReportContext * ctx)  { +    g_hash_table_destroy(ctx->column_titles);      g_free(ctx->output);      g_free(ctx);  } @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -27,6 +27,14 @@ typedef enum {      N_REPORT_FORMAT  } ReportFormat; +typedef enum { +    REPORT_COL_PROGRESS = 1<<0, +    REPORT_COL_VALUE    = 1<<1, +    REPORT_COL_EXTRA1   = 1<<2, +    REPORT_COL_EXTRA2   = 1<<3, +    REPORT_COL_TEXTVALUE= 1<<4 +} ReportColumn; +  typedef struct _ReportDialog	ReportDialog;  typedef struct _ReportContext	ReportContext; @@ -34,16 +42,21 @@ struct _ReportContext {    ShellModuleEntry	*entry;    gchar			*output; -  void (*header)      (ReportContext *ctx); -  void (*footer)      (ReportContext *ctx); -  void (*title)       (ReportContext *ctx, gchar *text); -  void (*subtitle)    (ReportContext *ctx, gchar *text); -  void (*subsubtitle) (ReportContext *ctx, gchar *text); -  void (*keyvalue)    (ReportContext *ctx, gchar *key, gchar *value); +  void (*header)      	(ReportContext *ctx); +  void (*footer)      	(ReportContext *ctx); +  void (*title)      	(ReportContext *ctx, gchar *text); +  void (*subtitle)    	(ReportContext *ctx, gchar *text); +  void (*subsubtitle)	(ReportContext *ctx, gchar *text); +  void (*keyvalue)   	(ReportContext *ctx, gchar *key, gchar *value);    ReportFormat		format;    gboolean		is_image_enabled; +  gboolean		first_table; + +  gboolean		show_column_headers; +  guint			columns; +  GHashTable		*column_titles;  };  struct _ReportDialog { @@ -231,11 +231,6 @@ void SHA1Final(guchar digest[20], SHA1_CTX * context)  #ifdef SHA1_TEST  static char *b32_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; -void g_assert(int a) -{ -    /* Bah, who needs testing anyway... ;) */ -} -  static void base32_encode_exactly(guchar * buf, gint len,  				  guchar * encbuf, gint enclen)  { @@ -313,7 +308,7 @@ int main(int argc, char **argv)      }      SHA1Final(digest, &context);      fclose(file); -/* +      for (i = 0; i < 5; i++) {          for (j = 0; j < 4; j++) {              printf("%02X", digest[i*4+j]); @@ -321,7 +316,6 @@ int main(int argc, char **argv)          putchar(' ');      }      putchar('\n'); -*/      {  	guchar tmp[33]; @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -197,7 +197,7 @@ void shell_action_set_active(const gchar * action_name, gboolean setting)  void shell_status_pulse(void)  {      if (params.gui_running) { -	if (shell->_pulses++ == 20) { +	if (shell->_pulses++ == 5) {  	    /* we're pulsing for some time, disable the interface and change the cursor  	       to a hourglass */  	    shell_view_set_enabled(FALSE); @@ -252,7 +252,7 @@ void shell_view_set_enabled(gboolean setting)      shell_action_set_enabled("RefreshAction", setting);      shell_action_set_enabled("CopyAction", setting);      shell_action_set_enabled("ReportAction", setting); -    shell_action_set_enabled("SyncManagerAction", setting); +    shell_action_set_enabled("SyncManagerAction", setting && sync_manager_count_entries() > 0);      shell_action_set_enabled("SaveGraphAction",  			     setting ? shell->view_type ==  			     SHELL_VIEW_PROGRESS : FALSE); @@ -355,7 +355,7 @@ static void create_window(void)      gtk_window_set_icon(GTK_WINDOW(shell->window),  			icon_cache_get_pixbuf("logo.png"));      gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); -    gtk_widget_set_size_request(shell->window, 600, 400); +    gtk_window_set_default_size(GTK_WINDOW(shell->window), 800, 600);      g_signal_connect(G_OBJECT(shell->window), "destroy", destroy_me, NULL);      vbox = gtk_vbox_new(FALSE, 0); @@ -485,6 +485,10 @@ static void add_modules_to_gui(gpointer data, gpointer user_data)      ShellModule *module = (ShellModule *) data;      GtkTreeStore *store = GTK_TREE_STORE(shelltree->model);      GtkTreeIter parent; +     +    if (!module) { +        return; +    }      gtk_tree_store_append(store, &parent, NULL);      gtk_tree_store_set(store, &parent, TREE_COL_NAME, module->name, @@ -604,9 +608,11 @@ static gboolean update_field(gpointer data)      fu = (ShellFieldUpdate *) data;      g_return_val_if_fail(fu != NULL, FALSE); +    DEBUG("update_field [%s]", fu->field_name); +          iter = g_hash_table_lookup(update_tbl, fu->field_name);      g_return_val_if_fail(iter != NULL, FALSE); - +          /* if the entry is still selected, update it */      if (iter && fu->entry->selected && fu->entry->fieldfunc) {  	GtkTreeStore *store = GTK_TREE_STORE(shell->info->model); @@ -639,8 +645,6 @@ static gboolean update_field(gpointer data)  	update_sfusrc = NULL;      } -    DEBUG("destroying ShellFieldUpdate for field %s", fu->field_name); -      /* otherwise, cleanup and destroy the timeout */      g_free(fu->field_name);      g_free(fu); @@ -648,6 +652,11 @@ static gboolean update_field(gpointer data)      return FALSE;  } +#define RANGE_SET_VALUE(tree,scrollbar,value) \ +  	  gtk_range_set_value(GTK_RANGE \ +	  		    (GTK_SCROLLED_WINDOW(shell->tree->scroll)-> \ +			     scrollbar), value); +  static gboolean reload_section(gpointer data)  {      ShellModuleEntry *entry = (ShellModuleEntry *) data; @@ -657,10 +666,14 @@ static gboolean reload_section(gpointer data)  	GtkTreePath *path = NULL;  	GtkTreeIter iter; +	/* avoid drawing the window while we reload */ +	gdk_window_freeze_updates(shell->window->window); +	  	/* gets the current selected path */  	if (gtk_tree_selection_get_selected -	    (shell->info->selection, &shell->info->model, &iter)) +	    (shell->info->selection, &shell->info->model, &iter)) {  	    path = gtk_tree_model_get_path(shell->info->model, &iter); +        }  	/* update the information, clear the treeview and populate it again */  	module_entry_reload(entry); @@ -670,8 +683,13 @@ static gboolean reload_section(gpointer data)  	/* if there was a selection, reselect it */  	if (path) {  	    gtk_tree_selection_select_path(shell->info->selection, path); +            gtk_tree_view_set_cursor(GTK_TREE_VIEW(shell->info->view), path, NULL, +                                     FALSE);  	    gtk_tree_path_free(path);  	} +	 +	/* make the window drawable again */ +	gdk_window_thaw_updates(shell->window->window);      }      /* destroy the timeout: it'll be set up again */ @@ -714,34 +732,40 @@ info_tree_compare_val_func(GtkTreeModel * model,      return ret;  } -static void set_view_type(ShellViewType viewtype) +static void set_view_type(ShellViewType viewtype, gboolean reload)  { +    if (viewtype < SHELL_VIEW_NORMAL || viewtype >= SHELL_VIEW_N_VIEWS) +	viewtype = SHELL_VIEW_NORMAL; + +    shell->normalize_percentage = TRUE; +    shell->view_type = viewtype; +      /* reset to the default model */      gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view),  			    shell->info->model);      /* reset to the default view columns */ -    gtk_tree_view_column_set_visible(shell->info->col_progress, FALSE); -    gtk_tree_view_column_set_visible(shell->info->col_value, TRUE); - +    if (!reload) { +      gtk_tree_view_column_set_visible(shell->info->col_extra1, FALSE); +      gtk_tree_view_column_set_visible(shell->info->col_extra2, FALSE); +      gtk_tree_view_column_set_visible(shell->info->col_progress, FALSE); +      gtk_tree_view_column_set_visible(shell->info->col_value, TRUE); +    } +          /* turn off the rules hint */      gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(shell->info->view), FALSE);      /* turn off the save graphic action */      shell_action_set_enabled("SaveGraphAction", FALSE); -    if (viewtype == shell->view_type) -	return; - -    if (viewtype < SHELL_VIEW_NORMAL || viewtype >= SHELL_VIEW_N_VIEWS) -	viewtype = SHELL_VIEW_NORMAL; - -    shell->view_type = viewtype; -      switch (viewtype) {      default:      case SHELL_VIEW_NORMAL:  	gtk_widget_hide(shell->notebook); +	 +	if (!reload) { +          gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), FALSE); +        }  	break;      case SHELL_VIEW_DUAL:  	gtk_notebook_set_page(GTK_NOTEBOOK(shell->notebook), 0); @@ -756,20 +780,30 @@ static void set_view_type(ShellViewType viewtype)  			       shell->hpaned->allocation.height -  			       shell->loadgraph->height - 16);  	break; +    case SHELL_VIEW_PROGRESS_DUAL: +	gtk_notebook_set_page(GTK_NOTEBOOK(shell->notebook), 0); +	gtk_widget_show(shell->notebook); +	/* fallthrough */      case SHELL_VIEW_PROGRESS:  	shell_action_set_enabled("SaveGraphAction", TRUE); -	gtk_tree_view_column_set_visible(shell->info->col_progress, TRUE); -	gtk_tree_view_column_set_visible(shell->info->col_value, FALSE); -	gtk_widget_hide(shell->notebook); +	 +	if (!reload) { +  	  gtk_tree_view_column_set_visible(shell->info->col_progress, TRUE); +  	  gtk_tree_view_column_set_visible(shell->info->col_value, FALSE); +        } +         +	if (viewtype == SHELL_VIEW_PROGRESS) +		gtk_widget_hide(shell->notebook);  	break;      }  }  static void  group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, -		     gchar * group, gchar ** keys) +		     gchar * group, gchar ** keys, gboolean reload)  {      if (g_str_equal(group, "$ShellParam$")) { +        gboolean headers_visible = FALSE;  	gint i;  	for (i = 0; keys[i]; i++) { @@ -790,6 +824,8 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry,  		sfutbl->sfu = fu;  		update_sfusrc = g_slist_prepend(update_sfusrc, sfutbl); +	    } else if (g_str_equal(key, "NormalizePercentage")) { +		shell->normalize_percentage = g_key_file_get_boolean(key_file, group, key, NULL);  	    } else if (g_str_equal(key, "LoadGraphSuffix")) {  		gchar *suffix =  		    g_key_file_get_value(key_file, group, key, NULL); @@ -807,13 +843,37 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry,  		ms = g_key_file_get_integer(key_file, group, key, NULL);  		g_timeout_add(ms, rescan_section, entry); +	    } else if (g_str_equal(key, "ShowColumnHeaders")) { +		headers_visible = g_key_file_get_boolean(key_file, group, key, NULL); +	    } else if (g_str_has_prefix(key, "ColumnTitle")) { +                GtkTreeViewColumn *column; +		gchar *value, *title = strchr(key, '$') + 1; + +                value = g_key_file_get_value(key_file, group, key, NULL); + +                if (g_str_equal(title, "Extra1")) { +			column = shell->info->col_extra1; +                } else if (g_str_equal(title, "Extra2")) { +			column = shell->info->col_extra2; +                } else if (g_str_equal(title, "Value")) { +			column = shell->info->col_value; +                } else if (g_str_equal(title, "TextValue")) { +			column = shell->info->col_textvalue; +                } else if (g_str_equal(title, "Progress")) { +			column = shell->info->col_progress; +                } + +                gtk_tree_view_column_set_title(column, value); +                gtk_tree_view_column_set_visible(column, TRUE); + +                g_free(value);  	    } else if (g_str_equal(key, "OrderType")) {  		shell->_order_type = g_key_file_get_integer(key_file,  							    group,  							    key, NULL);  	    } else if (g_str_equal(key, "ViewType")) {  		set_view_type(g_key_file_get_integer(key_file, group, -						     key, NULL)); +						     key, NULL), reload);  	    } else if (g_str_has_prefix(key, "Icon")) {  		GtkTreeIter *iter = g_hash_table_lookup(update_tbl,  							strchr(key, @@ -837,6 +897,8 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry,  					     (key_file, group, key, NULL));  	    }  	} + +        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), headers_visible);      } else {  	g_warning("Unknown parameter group: ``%s''", group);      } @@ -870,16 +932,29 @@ group_handle_normal(GKeyFile * key_file, ShellModuleEntry * entry,  	    value = entry->fieldfunc(key);  	} -	if ((key && value) && -	    g_utf8_validate(key, -1, NULL) -	    && g_utf8_validate(value, -1, NULL)) { +	if ((key && value) && g_utf8_validate(key, -1, NULL) && g_utf8_validate(value, -1, NULL)) {  	    if (ngroups == 1) {  		gtk_tree_store_append(store, &child, NULL);  	    } else {  		gtk_tree_store_append(store, &child, &parent);  	    } -	    gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, value, -			       -1); +	     +	    /* FIXME: use g_key_file_get_string_list? */ +	    if (strchr(value, '|')) { +		gchar **columns = g_strsplit(value, "|", 0); + +		gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, columns[0], -1); +		if (columns[1]) { +			gtk_tree_store_set(store, &child, INFO_TREE_COL_EXTRA1, columns[1], -1); +			if (columns[2]) { +				gtk_tree_store_set(store, &child, INFO_TREE_COL_EXTRA2, columns[2], -1); +			} +		} + +		g_strfreev(columns); +	    } else { +	    	gtk_tree_store_set(store, &child, INFO_TREE_COL_VALUE, value, -1); +	    }  	    strend(key, '#'); @@ -942,27 +1017,30 @@ static void update_progress()      GtkTreeStore *store = GTK_TREE_STORE(model);      GtkTreeIter iter, fiter;      gchar *tmp; -    gdouble maxv = 0, maxp = 0, cur; +    gdouble maxv = 0, maxp = 0, cur, floatval;      gtk_tree_model_get_iter_first(model, &fiter);      /* finds the maximum value */ -    iter = fiter; -    do { -	gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -1); - -	cur = atof(tmp); -	maxv = MAX(maxv, cur); - -	g_free(tmp); -    } while (gtk_tree_model_iter_next(model, &iter)); +    if (shell->normalize_percentage) { +	iter = fiter; +	do { +		gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -1); +	 +		cur = atof(tmp); +		maxv = MAX(maxv, cur); +	 +		g_free(tmp); +	} while (gtk_tree_model_iter_next(model, &iter)); +    } else { +	maxv = 100.0f; +    }      /* calculates the relative percentage and finds the maximum percentage */      if (shell->_order_type == SHELL_ORDER_ASCENDING) {  	iter = fiter;  	do { -	    gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -			       -1); +	    gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -1);  	    cur = 100 - 100 * atof(tmp) / maxv;  	    maxp = MAX(cur, maxp); @@ -976,14 +1054,29 @@ static void update_progress()      /* fix the maximum relative percentage */      iter = fiter;      do { +        char *strval; +          	gtk_tree_model_get(model, &iter, INFO_TREE_COL_VALUE, &tmp, -1); +	floatval = atof(tmp); +	strval = g_strdup(tmp); +	g_free(tmp); +	 +	cur = 100 * floatval / maxv; -	cur = 100 * atof(tmp) / maxv;  	if (shell->_order_type == SHELL_ORDER_ASCENDING)  	    cur = 100 - cur + maxp; - -	gtk_tree_store_set(store, &iter, INFO_TREE_COL_PROGRESS, cur, -1); -	g_free(tmp); +	     +        if (strchr(strval, ' ')) { +            tmp = g_strdup_printf("%.2f%s", floatval, strchr(strval, ' ')); +        } else { +            tmp = g_strdup_printf("%.2f", floatval); +        } + +        tmp = strreplace(tmp, ",", '.'); +	gtk_tree_store_set(store, &iter, INFO_TREE_COL_PROGRESS, cur, +                                         INFO_TREE_COL_VALUE, tmp, -1); +        g_free(tmp); +        g_free(strval);      } while (gtk_tree_model_iter_next(model, &iter));      /* now sort everything up. that wasn't as hard as i thought :) */ @@ -1020,17 +1113,24 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)      GKeyFile *key_file = g_key_file_new();      GtkTreeStore *store;      gchar *key_data, **groups; +    gboolean has_shell_param = FALSE;      gint i;      gsize ngroups;      module_entry_scan(entry);      key_data = module_entry_function(entry); +    /* */ +    gdk_window_freeze_updates(shell->info->view->window); + +    g_object_ref(shell->info->model); +    gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), NULL); +      /* reset the view type to normal */ -    set_view_type(SHELL_VIEW_NORMAL); +    set_view_type(SHELL_VIEW_NORMAL, reload); -    /* recreate the iter hash table */      if (!reload) { +        /* recreate the iter hash table */          h_hash_table_remove_all(update_tbl);      } @@ -1052,6 +1152,7 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)      }      store = GTK_TREE_STORE(shell->info->model); +      gtk_tree_store_clear(store);      g_key_file_load_from_data(key_file, key_data, strlen(key_data), 0, @@ -1067,21 +1168,41 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload)  	gchar **keys = g_key_file_get_keys(key_file, group, NULL, NULL);  	if (*group == '$') { -	    group_handle_special(key_file, entry, group, keys); +	    group_handle_special(key_file, entry, group, keys, reload); +	    has_shell_param = TRUE;  	} else {  	    group_handle_normal(key_file, entry, group, keys, ngroups);  	}  	g_strfreev(keys);      } - +     +    /* */ +    if (!has_shell_param) { +        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info->view), FALSE); +    } +     +    /* */ +    g_object_unref(shell->info->model); +    gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info->view), shell->info->model);      gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info->view)); -    if (shell->view_type == SHELL_VIEW_PROGRESS) { +    gdk_window_thaw_updates(shell->info->view->window); +    shell_set_note_from_entry(entry); + +    if (shell->view_type == SHELL_VIEW_PROGRESS || shell->view_type == SHELL_VIEW_PROGRESS_DUAL) {  	update_progress();      } -    shell_set_note_from_entry(entry); +#if GTK_CHECK_VERSION(2,12,0) +    if (ngroups == 1) { +        gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(shell->info->view), +                                         FALSE); +    } else { +        gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(shell->info->view), +                                         TRUE); +    } +#endif      g_strfreev(groups);      g_key_file_free(key_file); @@ -1169,18 +1290,11 @@ static void module_selected(gpointer data)  	gtk_tree_view_columns_autosize(GTK_TREE_VIEW(shell->info->view));  	/* urgh. why don't GTK do this when the model is cleared? */ -#define RANGE_SET_VALUE(tree,scrollbar,value) \ -  	  gtk_range_set_value(GTK_RANGE \ -	  		    (GTK_SCROLLED_WINDOW(shell->tree->scroll)-> \ -			     scrollbar), value); -          RANGE_SET_VALUE(info, vscrollbar, 0.0);          RANGE_SET_VALUE(info, hscrollbar, 0.0);          RANGE_SET_VALUE(moreinfo, vscrollbar, 0.0);          RANGE_SET_VALUE(moreinfo, hscrollbar, 0.0); -#undef RANGE_SET_VALUE -  	shell_status_update("Done.");  	shell_status_set_enabled(FALSE); @@ -1197,7 +1311,7 @@ static void module_selected(gpointer data)  	shell_action_set_enabled("CopyAction", FALSE);  	gtk_tree_store_clear(GTK_TREE_STORE(shell->info->model)); -	set_view_type(SHELL_VIEW_NORMAL); +	set_view_type(SHELL_VIEW_NORMAL, FALSE);      }      current = entry; @@ -1236,17 +1350,34 @@ static ShellInfoTree *info_tree_new(gboolean extra)  					(scroll), GTK_SHADOW_IN);      gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),  				   GTK_POLICY_AUTOMATIC, -				   GTK_POLICY_AUTOMATIC); +				   GTK_POLICY_ALWAYS);      store =  	gtk_tree_store_new(INFO_TREE_NCOL, G_TYPE_STRING, G_TYPE_STRING, -			   G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_FLOAT); +			   G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_FLOAT, +                           G_TYPE_STRING, G_TYPE_STRING);      model = GTK_TREE_MODEL(store);      treeview = gtk_tree_view_new_with_model(model);      gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); +    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview), TRUE); -    column = gtk_tree_view_column_new(); +    info->col_progress = column = gtk_tree_view_column_new(); +    gtk_tree_view_column_set_visible(column, FALSE); +    gtk_tree_view_column_set_min_width(column, 240); +    gtk_tree_view_column_set_clickable(column, TRUE); +    gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + +    cr_progress = gtk_cell_renderer_progress_new(); +    gtk_tree_view_column_pack_start(column, cr_progress, TRUE); +    gtk_tree_view_column_add_attribute(column, cr_progress, "value", +				       INFO_TREE_COL_PROGRESS); +    gtk_tree_view_column_add_attribute(column, cr_progress, "text", +				       INFO_TREE_COL_VALUE); +    gtk_tree_view_column_set_visible(column, FALSE); + +    info->col_textvalue = column = gtk_tree_view_column_new();      gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); +    gtk_tree_view_column_set_clickable(column, TRUE);      cr_pbuf = gtk_cell_renderer_pixbuf_new();      gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE); @@ -1254,28 +1385,38 @@ static ShellInfoTree *info_tree_new(gboolean extra)  				       INFO_TREE_COL_PBUF);      cr_text = gtk_cell_renderer_text_new(); -    gtk_tree_view_column_pack_start(column, cr_text, FALSE); +    gtk_tree_view_column_pack_start(column, cr_text, TRUE);      gtk_tree_view_column_add_attribute(column, cr_text, "markup",  				       INFO_TREE_COL_NAME); -    info->col_value = column = gtk_tree_view_column_new(); +    info->col_extra1 = column = gtk_tree_view_column_new(); +    gtk_tree_view_column_set_visible(column, FALSE);      gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); +    gtk_tree_view_column_set_clickable(column, TRUE);      cr_text = gtk_cell_renderer_text_new();      gtk_tree_view_column_pack_start(column, cr_text, FALSE);      gtk_tree_view_column_add_attribute(column, cr_text, "markup", -				       INFO_TREE_COL_VALUE); +				       INFO_TREE_COL_EXTRA1); -    info->col_progress = column = gtk_tree_view_column_new(); +    info->col_extra2 = column = gtk_tree_view_column_new(); +    gtk_tree_view_column_set_visible(column, FALSE);      gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); +    gtk_tree_view_column_set_clickable(column, TRUE); -    cr_progress = gtk_cell_renderer_progress_new(); -    gtk_tree_view_column_pack_start(column, cr_progress, TRUE); -    gtk_tree_view_column_add_attribute(column, cr_progress, "value", -				       INFO_TREE_COL_PROGRESS); -    gtk_tree_view_column_add_attribute(column, cr_progress, "text", +    cr_text = gtk_cell_renderer_text_new(); +    gtk_tree_view_column_pack_start(column, cr_text, FALSE); +    gtk_tree_view_column_add_attribute(column, cr_text, "markup", +				       INFO_TREE_COL_EXTRA2); + +    info->col_value = column = gtk_tree_view_column_new(); +    gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); +    gtk_tree_view_column_set_clickable(column, TRUE); + +    cr_text = gtk_cell_renderer_text_new(); +    gtk_tree_view_column_pack_start(column, cr_text, FALSE); +    gtk_tree_view_column_add_attribute(column, cr_text, "markup",  				       INFO_TREE_COL_VALUE); -    gtk_tree_view_column_set_visible(column, FALSE);      sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); @@ -1311,7 +1452,7 @@ static ShellTree *tree_new()      gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW  					(scroll), GTK_SHADOW_IN);      gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), -				   GTK_POLICY_AUTOMATIC, +				   GTK_POLICY_NEVER,  				   GTK_POLICY_AUTOMATIC);      store = gtk_tree_store_new(TREE_NCOL, GDK_TYPE_PIXBUF, G_TYPE_STRING, @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -48,6 +48,7 @@ typedef enum {      SHELL_VIEW_DUAL,      SHELL_VIEW_LOAD_GRAPH,      SHELL_VIEW_PROGRESS, +    SHELL_VIEW_PROGRESS_DUAL,      SHELL_VIEW_N_VIEWS  } ShellViewType; @@ -65,6 +66,8 @@ typedef enum {      INFO_TREE_COL_DATA,      INFO_TREE_COL_PBUF,      INFO_TREE_COL_PROGRESS, +    INFO_TREE_COL_EXTRA1, +    INFO_TREE_COL_EXTRA2,      INFO_TREE_NCOL  } ShellInfoTreeColumns; @@ -84,6 +87,7 @@ struct _Shell {      GtkUIManager	*ui_manager;      ShellViewType	 view_type; +    gboolean		 normalize_percentage;      gint		_pulses;      ShellOrderType	_order_type; @@ -104,7 +108,7 @@ struct _ShellInfoTree {      GtkTreeModel        *model;      GtkTreeSelection	*selection; -    GtkTreeViewColumn	 *col_progress, *col_value; +    GtkTreeViewColumn	 *col_progress, *col_value, *col_extra1, *col_extra2, *col_textvalue;  };  struct _ShellNote { @@ -124,7 +128,7 @@ struct _ShellModule {  struct _ShellModuleMethod {      gchar	*name; -    gchar	*(*function) (void); +    gpointer	function;  };  struct _ShellModuleEntry { @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -99,7 +99,11 @@ int sock_read(Socket * s, gchar * buffer, gint size)  	gint n;  	n = read(s->sock, buffer, size); -	buffer[n] = '\0'; +	if (n > 0) { +            buffer[n] = '\0'; +        } else { +            return 0; +        }  	return n;      } @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 diff --git a/syncmanager.c b/syncmanager.c index f4949644..12b0465e 100644 --- a/syncmanager.c +++ b/syncmanager.c @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -23,8 +23,6 @@  #ifdef HAS_LIBSOUP  #include <libsoup/soup.h> -#include <libsoup/soup-xmlrpc-message.h> -#include <libsoup/soup-xmlrpc-response.h>  #include <stdarg.h>  #include <string.h> @@ -140,11 +138,10 @@ void sync_manager_show(void)  }  #ifdef HAS_LIBSOUP -static SoupXmlrpcValue *_soup_get_xmlrpc_value(SoupMessage * msg, -					       SyncNetAction * sna) +static gint _soup_get_xmlrpc_value_int(SoupMessage * msg, +				       SyncNetAction * sna)  { -    SoupXmlrpcResponse *response = NULL; -    SoupXmlrpcValue *value = NULL; +    gint int_value = -1;      sna->error = NULL; @@ -154,37 +151,11 @@ static SoupXmlrpcValue *_soup_get_xmlrpc_value(SoupMessage * msg,  	goto bad;      } -    response = -	soup_xmlrpc_message_parse_response(SOUP_XMLRPC_MESSAGE(msg)); -    if (!response) { +    if (!soup_xmlrpc_extract_method_response(msg->response_body->data, +					     msg->response_body->length, +					     NULL, +					     G_TYPE_INT, &int_value)) {  	SNA_ERROR(2, "Could not parse XML-RPC response"); -	goto bad; -    } - -    value = soup_xmlrpc_response_get_value(response); -    if (!value) { -	SNA_ERROR(3, "No response value in XML-RPC response"); -    } - -    /*g_object_unref(response); */ -  bad: -    return value; -} - -static long _soup_get_xmlrpc_value_int(SoupMessage * msg, -				       SyncNetAction * sna) -{ -    SoupXmlrpcValue *value; -    long int_value = -1; - -    value = _soup_get_xmlrpc_value(msg, sna); -    if (!value) { -	SNA_ERROR(4, "Could not extract result from XML-RPC response"); -	goto bad; -    } - -    if (!soup_xmlrpc_value_get_int(value, &int_value)) { -	SNA_ERROR(4, "Could not extract result from XML-RPC response");      }    bad: @@ -194,17 +165,21 @@ static long _soup_get_xmlrpc_value_int(SoupMessage * msg,  static gchar *_soup_get_xmlrpc_value_string(SoupMessage * msg,  					    SyncNetAction * sna)  { -    SoupXmlrpcValue *value;      gchar *string = NULL; -    value = _soup_get_xmlrpc_value(msg, sna); -    if (!value) { -	SNA_ERROR(4, "Could not extract result from XML-RPC response"); +    sna->error = NULL; + +    if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) { +	SNA_ERROR(1, "%s (error #%d)", msg->reason_phrase, +		  msg->status_code);  	goto bad;      } -    if (!soup_xmlrpc_value_get_string(value, &string)) { -	SNA_ERROR(4, "Could not extract result from XML-RPC response"); +    if (!soup_xmlrpc_extract_method_response(msg->response_body->data, +					     msg->response_body->length, +					     NULL, +					     G_TYPE_STRING, &string)) { +	SNA_ERROR(2, "Could not parse XML-RPC response");      }    bad: @@ -212,23 +187,20 @@ static gchar *_soup_get_xmlrpc_value_string(SoupMessage * msg,  }  static gboolean _soup_xmlrpc_call(gchar * method, SyncNetAction * sna, -				  SoupMessageCallbackFn callback) +				  SoupSessionCallback callback)  { -    SoupXmlrpcMessage *msg; +    SoupMessage *msg;      sna->error = NULL; -    msg = soup_xmlrpc_message_new(XMLRPC_SERVER_URI); +    msg = soup_xmlrpc_request_new(XMLRPC_SERVER_URI, method, +				  G_TYPE_INVALID);      if (!msg)  	return FALSE;      DEBUG("calling xmlrpc method %s", method); -    soup_xmlrpc_message_start_call(msg, method); -    soup_xmlrpc_message_end_call(msg); - -    soup_xmlrpc_message_persist(msg); -    soup_session_queue_message(session, SOUP_MESSAGE(msg), callback, sna); +    soup_session_queue_message(session, msg, callback, sna);      g_main_run(loop);      return TRUE; @@ -236,49 +208,51 @@ static gboolean _soup_xmlrpc_call(gchar * method, SyncNetAction * sna,  static gboolean _soup_xmlrpc_call_with_parameters(gchar * method,  						  SyncNetAction * sna, -						  SoupMessageCallbackFn +						  SoupSessionCallback  						  callback, ...)  { -    SoupXmlrpcMessage *msg; -    gchar *argument; +    SoupMessage *msg; +    GValueArray *parameters; +    gchar *argument, *body;      va_list ap;      sna->error = NULL; -    msg = soup_xmlrpc_message_new(XMLRPC_SERVER_URI); -    if (!msg) -	return FALSE; +    msg = soup_message_new("POST", XMLRPC_SERVER_URI);      DEBUG("calling xmlrpc method %s", method); -    soup_xmlrpc_message_start_call(msg, method); +    if (!msg) +	return FALSE; +    parameters = g_value_array_new(1);      va_start(ap, callback);      while ((argument = va_arg(ap, gchar *))) { -	soup_xmlrpc_message_start_param(msg); -	soup_xmlrpc_message_write_string(msg, argument); -	soup_xmlrpc_message_end_param(msg); - +	soup_value_array_append(parameters, G_TYPE_STRING, argument);  	DEBUG("with parameter: %s", argument);      }      va_end(ap); -    soup_xmlrpc_message_end_call(msg); -    soup_xmlrpc_message_persist(msg); +    body = soup_xmlrpc_build_method_call(method, parameters->values, +					 parameters->n_values); +    g_value_array_free(parameters); +    soup_message_set_request(msg, "text/xml", +			     SOUP_MEMORY_TAKE, body, strlen (body)); -    soup_session_queue_message(session, SOUP_MESSAGE(msg), callback, sna); +    soup_session_queue_message(session, msg, callback, sna);      g_main_run(loop);      return TRUE;  } -static void _action_check_api_version_got_response(SoupMessage * msg, +static void _action_check_api_version_got_response(SoupSession * session, +						   SoupMessage * msg,  						   gpointer user_data)  {      SyncNetAction *sna = (SyncNetAction *) user_data; -    long version = _soup_get_xmlrpc_value_int(msg, sna); +    gint version = _soup_get_xmlrpc_value_int(msg, sna);      if (version != XMLRPC_SERVER_API_VERSION) { -	SNA_ERROR(5, "Server says it supports API version %ld, but " +	SNA_ERROR(5, "Server says it supports API version %d, but "  		  "this version of HardInfo only supports API "  		  "version %d.", version, XMLRPC_SERVER_API_VERSION);      } @@ -298,7 +272,8 @@ static gboolean _action_check_api_version(SyncDialog * sd,      return sna->error ? FALSE : TRUE;  } -static void _action_call_function_got_response(SoupMessage * msg, +static void _action_call_function_got_response(SoupSession * session, +					       SoupMessage * msg,  					       gpointer user_data)  {      SyncNetAction *sna = (SyncNetAction *) user_data; @@ -312,19 +287,7 @@ static void _action_call_function_got_response(SoupMessage * msg,  	DEBUG("saving to %s", filename); -#ifdef g_file_set_contents  	g_file_set_contents(filename, string, -1, NULL); -#else -	{ -	    FILE *f; - -	    f = fopen(filename, "w+"); -	    if (f) { -		fwrite(string, 1, strlen(string), f); -		fclose(f); -	    } -	} -#endif  	g_free(filename);      } @@ -346,7 +309,7 @@ static gboolean _action_call_function(SyncDialog * sd, gpointer user_data)  	if (sna->entry->get_data)  	    str_data = sna->entry->get_data(); -	if (!_soup_xmlrpc_call_with_parameters("sync.callFunction", sna, +	if (!_soup_xmlrpc_call_with_parameters("sync.callFunctionEx", sna,  					       _action_call_function_got_response,  					       VERSION, ARCH,  					       sna->entry->name, @@ -385,11 +348,9 @@ static SyncNetAction *sync_manager_get_selected_actions(gint * n)      gint i;      GSList *entry;      SyncNetAction *actions; -    SyncNetAction action_check_api = -	{ "Contacting HardInfo Central Database", -	_action_check_api_version -    }, action_clean_up = { -    "Cleaning up", NULL}; +    SyncNetAction +      action_check_api = { "Contacting HardInfo Central Database", _action_check_api_version }, +      action_clean_up = { "Cleaning up", NULL};      actions = g_new0(SyncNetAction, 2 + g_slist_length(entries)); @@ -411,7 +372,7 @@ static SyncNetAction *sync_manager_get_selected_actions(gint * n)      return actions;  } -static SoupUri *sync_manager_get_proxy(void) +static SoupURI *sync_manager_get_proxy(void)  {      const gchar *conf; @@ -430,7 +391,7 @@ static void sync_dialog_start_sync(SyncDialog * sd)      SyncNetAction *actions;      if (!session) { -	SoupUri *proxy = sync_manager_get_proxy(); +	SoupURI *proxy = sync_manager_get_proxy();  	session =  	    soup_session_async_new_with_options(SOUP_SESSION_TIMEOUT, 10, diff --git a/syncmanager.h b/syncmanager.h index 93e238d7..360c012a 100644 --- a/syncmanager.h +++ b/syncmanager.h @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -3,7 +3,10 @@  char *uidefs_str = "<ui>" \  "	<menubar>" \ -"		<menu name=\"InformationMenu\" action=\"InformationMenuAction\">" \ +"	<menu name=\"InformationMenu\" action=\"InformationMenuAction\">" \ +/*"		<menuitem name=\"Open\" action=\"OpenAction\" />" \ +"		<menuitem name=\"ConnectTo\" action=\"ConnectToAction\" />" \ +"		<separator/>" \*/  "		<menuitem name=\"Report\" action=\"ReportAction\" />" \  /*"		<separator/>" \ */  "		<menuitem name=\"Copy\" action=\"CopyAction\" />" \ @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 @@ -45,6 +45,43 @@  #define MiB 1048576  #define GiB 1073741824 +gchar *find_program(gchar *program_name) +{ +    int i; +    char *temp; +    static GHashTable *cache = NULL; +    const char *path[] = { "/bin", "/sbin", +		           "/usr/bin", "/usr/sbin", +		           "/usr/local/bin", "/usr/local/sbin", +		           NULL }; +     +    /* we don't need to call stat() every time: cache the results */ +    if (!cache) { +    	cache = g_hash_table_new(g_str_hash, g_str_equal); +    } else if ((temp = g_hash_table_lookup(cache, program_name))) { +    	return g_strdup(temp); +    } +     +    for (i = 0; path[i]; i++) { +    	temp = g_build_filename(path[i], program_name, NULL); +    	 +    	if (g_file_test(temp, G_FILE_TEST_IS_EXECUTABLE)) { +    		g_hash_table_insert(cache, program_name, g_strdup(temp)); +		return temp; +    	} +    	 +    	g_free(temp); +    } +     +    /* our search has failed; use GLib's search (which uses $PATH env var) */ +    if ((temp = g_find_program_in_path(program_name))) { +    	g_hash_table_insert(cache, program_name, g_strdup(temp)); +    	return temp; +    } + +    return NULL; +} +  gchar *seconds_to_string(unsigned int seconds)  {      unsigned int hours, minutes, days; @@ -86,14 +123,16 @@ inline gchar *size_human_readable(gfloat size)      return g_strdup_printf("%.1f GiB", size / GiB);  } -inline void strend(gchar * str, gchar chr) +inline char *strend(gchar * str, gchar chr)  {      if (!str) -	return; +	return NULL;      char *p;      if ((p = strchr(str, chr)))  	*p = 0; + +    return str;  }  inline void remove_quotes(gchar * str) @@ -116,9 +155,11 @@ void widget_set_cursor(GtkWidget * widget, GdkCursorType cursor_type)  {      GdkCursor *cursor; -    cursor = gdk_cursor_new(cursor_type); -    gdk_window_set_cursor(GDK_WINDOW(widget->window), cursor); -    gdk_cursor_unref(cursor); +    if ((cursor = gdk_cursor_new(cursor_type))) { +        gdk_window_set_cursor(GDK_WINDOW(widget->window), cursor); +        gdk_display_flush(gtk_widget_get_display(widget)); +        gdk_cursor_unref(cursor); +    }      while (gtk_events_pending())  	gtk_main_iteration(); @@ -387,6 +428,7 @@ void parameters_init(int *argc, char ***argv, ProgramParameters * param)      param->list_modules = list_modules;      param->use_modules = use_modules;      param->autoload_deps = autoload_deps; +    param->argv0 = *(argv)[0];      if (report_format && g_str_equal(report_format, "html"))  	param->report_format = REPORT_FORMAT_HTML; @@ -419,10 +461,15 @@ void open_url(gchar * url)  	"opera", "konqueror", "netscape", "links -g",  	NULL      }; -    gint i; - -    for (i = 0; browsers[i]; i++) { -	gchar *cmdline = g_strdup_printf("%s '%s'", browsers[i], url); +    gint i = 0; +    gchar *browser = (gchar *)g_getenv("BROWSER"); +     +    if (!browser || *browser == '\0') { +    	browser = (gchar *)browsers[i++]; +    } +     +    do { +	gchar *cmdline = g_strdup_printf("%s '%s'", browser, url);  	if (g_spawn_command_line_async(cmdline, NULL)) {  	    g_free(cmdline); @@ -430,7 +477,9 @@ void open_url(gchar * url)  	}  	g_free(cmdline); -    } +    	 +    	browser = (gchar *)browsers[i++]; +    } while (browser);      g_warning("Couldn't find a Web browser to open URL %s.", url);  } @@ -459,9 +508,9 @@ static void module_register_methods(ShellModule * module)      if (g_module_symbol  	(module->dll, "hi_exported_methods", (gpointer) & get_methods)) { -	ShellModuleMethod *methods = get_methods(); - -	while (TRUE) { +	ShellModuleMethod *methods; +	 +	for (methods = get_methods(); methods->name; methods++) {  	    ShellModuleMethod method = *methods;  	    gchar *name = g_path_get_basename(g_module_name(module->dll)); @@ -471,9 +520,6 @@ static void module_register_methods(ShellModule * module)  	    g_hash_table_insert(__module_methods, method_name,  				method.function);  	    g_free(name); - -	    if (!(*(++methods)).name) -		break;  	}      } @@ -492,6 +538,20 @@ gchar *module_call_method(gchar * method)  	g_strdup_printf("{Unknown method: \"%s\"}", method);  } +/* FIXME: varargs? */ +gchar *module_call_method_param(gchar * method, gchar * parameter) +{ +    gchar *(*function) (gchar *param); + +    if (__module_methods == NULL) { +	return NULL; +    } + +    function = g_hash_table_lookup(__module_methods, method); +    return function ? g_strdup(function(parameter)) : +	g_strdup_printf("{Unknown method: \"%s\"}", method); +} +  static ShellModule *module_load(gchar * filename)  {      ShellModule *module; @@ -618,7 +678,7 @@ static void module_entry_free(gpointer data, gpointer user_data)      }  } -static void module_free(ShellModule * module) +void module_free(ShellModule * module)  {      g_free(module->name);      g_object_unref(module->icon); @@ -705,8 +765,8 @@ static GSList *modules_check_deps(GSList * modules)  				modules = g_slist_prepend(modules, mod);  			    modules = modules_check_deps(modules);	/* re-check dependencies */  			} else { -			    modules = g_slist_remove(modules, module); -			    module_free(module); +			    g_error("HardInfo cannot run without loading the additional module."); +			    exit(1);  			}  			gtk_widget_destroy(dialog); @@ -896,8 +956,6 @@ void tree_view_save_image(gchar * filename)  static gboolean __idle_free_do(gpointer ptr)  { -    DEBUG("bla %p", ptr); -      if (ptr) {  	g_free(ptr);      } @@ -1048,3 +1106,55 @@ h_hash_table_remove_all(GHashTable *hash_table)  				h_hash_table_remove_all_true,  				NULL);  } + +gfloat +h_sysfs_read_float(gchar *endpoint, gchar *entry) +{ +	gchar *tmp, *buffer; +	gfloat return_value = 0.0f; +	 +	tmp = g_build_filename(endpoint, entry, NULL); +	if (g_file_get_contents(tmp, &buffer, NULL, NULL)) +		return_value = atof(buffer); +	 +	g_free(tmp); +	g_free(buffer); +	 +	return return_value; +} + +gint +h_sysfs_read_int(gchar *endpoint, gchar *entry) +{ +	gchar *tmp, *buffer; +	gint return_value = 0.0f; +	 +	tmp = g_build_filename(endpoint, entry, NULL); +	if (g_file_get_contents(tmp, &buffer, NULL, NULL)) +		return_value = atoi(buffer); +	 +	g_free(tmp); +	g_free(buffer); +	 +	return return_value; +} + +gchar * +h_sysfs_read_string(gchar *endpoint, gchar *entry) +{ +	gchar *tmp, *return_value; +	 +	tmp = g_build_filename(endpoint, entry, NULL); +	if (!g_file_get_contents(tmp, &return_value, NULL, NULL)) { +		g_free(return_value); +		 +		return_value = NULL; +	} else { +		return_value = g_strstrip(return_value); +	} +	 +	g_free(tmp); +	 +	return return_value; +} + @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    List of vendors based on GtkSysInfo (c) Pissens Sebastien.   * @@ -49,6 +49,7 @@ static const Vendor vendors[] = {      {"Atheros", "Atheros Communications", "www.atheros.com"},      {"MATSHITA", "Panasonic", "www.panasonic.com"},      {"Silicon Image", "Silicon Image, Inc.", "www.siliconimage.com"}, +    {"Silicon Integrated Image", "Silicon Image, Inc.", "www.siliconimage.com"},      {"KYE", "KYE Systems Corp.", "www.genius-kye.com"},      {"Broadcom", "Broadcom Corp.", "www.broadcom.com"},      {"Apple", "Apple Computer, Inc.", "www.apple.com"}, @@ -58,6 +59,22 @@ static const Vendor vendors[] = {      {"FUJITSU", "Fujitsu", "www.fujitsu.com"},      {"CDU", "Sony", "www.sony.com"},      {"SanDisk", "SanDisk", "www.sandisk.com"}, +    {"ExcelStor", "ExcelStor Technology", "www.excelstor.com"}, +    {"D-Link", "D-Link", "www.dlink.com.tw"}, +    {"Giga-byte", "Gigabyte", "www.gigabyte.com.tw"}, +    {"C-Media", "C-Media Electronics", "www.cmedia.com.tw"}, +    {"Avermedia", "AVerMedia Technologies", "www.aver.com"}, +    {"Philips", "Philips", "www.philips.com"}, +    {"RaLink", "Ralink Technology", "www.ralinktech.com"}, +    {"Siemens", "Siemens AG", "www.siemens.com"}, +    {"HP", "Hewlett-Packard", "www.hp.com"}, +    {"Hewlett-Packard", "Hewlett-Packard", "www.hp.com"}, +    {"TEAC", "TEAC America Inc.", "www.teac.com"}, +    {"Microsoft", "Microsoft Corp.", "www.microsoft.com"}, +    {"Memorex", "Memorex Products, Inc.", "www.memorex.com"}, +    {"eMPIA", "eMPIA Technology, Inc.", "www.empiatech.com.tw"}, +    {"Canon", "Canon Inc.", "www.canon.com"}, +    {"A4Tech", "A4tech Co., Ltd.", "www.a4tech.com"},      {NULL, NULL, NULL},  }; @@ -1,6 +1,6 @@  /*   *    HardInfo - Displays System Information - *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + *    Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org>   *   *    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 | 
