--- acpitool-0.5.1.orig/debian/copyright
+++ acpitool-0.5.1/debian/copyright
@@ -0,0 +1,64 @@
+Author: David Leemans <davidleemans@tiscali.be>
+Download: http://freeunix.dyndns.org:8088/site2/acpitool.shtml
+
+Files: *
+Copyright: (C) 2004-2008 David Leemans <davidleemans@tiscali.be>
+License: GPL-2+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ can be found in /usr/share/common-licenses/GPL-2 file.
+
+Files: src/asus.*
+Copyright:
+ (C) 2004-2008 David Leemans <davidleemans@tiscali.be>
+ (C) 2006 Nicolas Weyland <ufoalien@weyland.ch>
+License: GPL-2+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ can be found in /usr/share/common-licenses/GPL-2 file.
+
+Files: debian/*
+Copyright: (C) 2008-2009 Daniel Baumann <daniel@debian.org>
+License: GPL-2+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ .
+ On Debian systems, the complete text of the GNU General Public License
+ can be found in /usr/share/common-licenses/GPL-2 file.
--- acpitool-0.5.1.orig/debian/acpitool.docs
+++ acpitool-0.5.1/debian/acpitool.docs
@@ -0,0 +1,2 @@
+AUTHORS
+TODO
--- acpitool-0.5.1.orig/debian/changelog
+++ acpitool-0.5.1/debian/changelog
@@ -0,0 +1,227 @@
+acpitool (0.5.1-3.4.201403111655) ucs4-0-0-0; urgency=low
+
+  * UCS auto build. No patches were applied to the original source package
+
+ -- Univention builddaemon <buildd@univention.de>  Tue, 11 Mar 2014 16:55:39 +0100
+
+acpitool (0.5.1-3) unstable; urgency=low
+
+  * Added patch to allow an unlimited number of wakeup entries.
+    Thanks to Carlos Alberto Lopez Perez <clopez@igalia.com> (Closes: #653281)
+  * Added patch to make acpitool cope with kernel 3.0+. (Closes: #635537)
+  * Bumped Standards-Version to 3.9.2, no changes needed.
+
+ -- Michael Meskes <meskes@debian.org>  Fri, 13 Jan 2012 13:28:41 +0100
+
+acpitool (0.5.1-2) unstable; urgency=low
+
+  * Fixed segfault in reading battery info. (Closes: #542114)
+
+ -- Michael Meskes <meskes@debian.org>  Sun, 25 Apr 2010 17:46:23 +0200
+
+acpitool (0.5.1-1) unstable; urgency=low
+
+  * New Upstream version, closes: #569693
+  * Added watch file.
+  * Bumped Standards-Version to 3.8.4, no changes needed.
+  * Created patches to correctly read battery and ac_adapter
+    information. (Closes: #542114, #567786)
+  * Updated build dependeny on quilt to correct version.
+
+ -- Michael Meskes <meskes@debian.org>  Sun, 28 Mar 2010 14:56:28 +0200
+
+acpitool (0.5-7) unstable; urgency=low
+
+  * New maintainer, closes: #543829
+  * Added README.source file.
+
+ -- Michael Meskes <meskes@debian.org>  Mon, 14 Sep 2009 10:17:48 +0200
+
+acpitool (0.5-6) unstable; urgency=low
+
+  * Minimizing rules.
+  * Sorting depends.
+  * Updating package to standards 3.8.3.
+  * Removing vcs fields.
+  * Orphaning package.
+
+ -- Daniel Baumann <daniel@debian.org>  Thu, 27 Aug 2009 06:49:15 +0200
+
+acpitool (0.5-5) unstable; urgency=low
+
+  * Updating section of the debug package.
+  * Sorting autotools foo in rules file.
+
+ -- Daniel Baumann <daniel@debian.org>  Thu, 16 Jul 2009 23:42:07 +0200
+
+acpitool (0.5-4) unstable; urgency=low
+
+  * Updating standards version to 3.8.2.
+  * Updating 2.6.29 patch from Evgeni Golov <evgeni@debian.org> (Closes:
+    #536014).
+
+ -- Daniel Baumann <daniel@debian.org>  Tue, 07 Jul 2009 00:45:51 +0200
+
+acpitool (0.5-3) unstable; urgency=low
+
+  * Replacing obsolete dh_clean -k with dh_prep.
+  * Prefixing debhelper files with package name.
+  * Updating to standards 3.8.1.
+  * Updating year in copyright file.
+  * Passing flags directly to configure.
+  * Tidy rules file.
+  * Using quilt rather than dpatch.
+  * Adding patch from Evgeni Golov <evgeni@debian.org> to use /sys
+    rather than /proc (Closes: #463111, #525951).
+  * Using correct rfc-2822 date formats in changelog.
+
+ -- Daniel Baumann <daniel@debian.org>  Sat, 30 May 2009 17:36:36 +0200
+
+acpitool (0.5-2) unstable; urgency=low
+
+  * Adding debug package.
+
+ -- Daniel Baumann <daniel@debian.org>  Sat, 20 Sep 2008 16:21:00 +0200
+
+acpitool (0.5-1) unstable; urgency=low
+
+  * New maintainer, Nicolas Weyland is mia.
+  * Acknowledging previous NMUs (Closes: #376793).
+  * New upstream release:
+    - works with current kernels (Closes: #443016, #463111).
+  * Redone debian packaging from scratch:
+   - removed watch file (Closes: #450030).
+
+ -- Daniel Baumann <daniel@debian.org>  Sat, 20 Sep 2008 15:24:00 +0200
+
+acpitool (0.4.7-1.4) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Recommend acpid only on supported archs [amd64 i386 ia64]. Thanks Robert
+    Lemmen. (Closes: #436637).
+
+ -- Amaya Rodrigo Sastre <amaya@debian.org>  Sun, 30 Mar 2008 21:41:08 +0200
+
+acpitool (0.4.7-1.3) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTBFS with new GCC 4.3 (Closes: #417069).
+
+ -- Luk Claes <luk@debian.org>  Tue, 25 Mar 2008 22:22:33 +0000
+
+acpitool (0.4.7-1.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTBFS with recent GCC 4.3 (Closes: #417069).
+
+ -- Luk Claes <luk@debian.org>  Fri, 14 Mar 2008 21:34:50 +0000
+
+acpitool (0.4.7-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTBFS with GCC 4.3 (Closes: #417069).
+
+ -- Luk Claes <luk@debian.org>  Sat, 08 Mar 2008 15:25:44 +0000
+
+acpitool (0.4.7-1) unstable; urgency=low
+
+  * New upstream release
+
+   - fixed output for "acpitool --cpu"
+
+   - code cleanup
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Tue, 06 Feb 2007 22:30:57 +0100
+
+acpitool (0.4.6-1) unstable; urgency=low
+
+  * New upstream release:
+
+   - fixes acpitool -c output (closes #365969)
+
+   - fixes smp-bug (closes #376793)
+
+  * Fixed the copyright in debian/copyright
+
+  * Updated the policy-version to 3.7.2
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Wed, 20 Dec 2006 17:27:08 +0200
+
+acpitool (0.4.5-0.1) unstable; urgency=low
+
+  * Non-maintainer upload
+  * New upstream release
+    Fixed output of the "-c" parameter (Closes: #365969)
+  * Added 02-smp.dpatch (Closes: #376793)
+    Thanks to Chris Hanson for providing the patch.
+  * Fixed the homepage in debian/copyright
+  * Added the homepage to debian/control
+  * Bumped policy-version to 3.7.2
+
+ -- Mario Iseli <admin@marioiseli.com>  Wed, 08 Aug 2006 22:54:22 +0200
+
+acpitool (0.4.4-1) unstable; urgency=low
+
+  * New upstream release
+
+  * Updated copyright information  (closes #342241)
+
+  * Upstream fixes #342020 (closes #342020)
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Sun, 05 Feb 2006 18:39:54 +0100
+
+acpitool (0.4.3-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Sun, 05 Feb 2006 04:45:24 +0100
+
+acpitool (0.4.2-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Sat, 21 Jan 2006 13:15:29 +0100
+
+acpitool (0.4.1-1) unstable; urgency=low
+
+  * New upstream release
+
+  * Removed /patches/01-acpitool.dpatch (fixed by upstream author)
+
+  * Added /patches/01-asus.dpatch (corrects copyright in src/asus.cpp)
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Tue, 10 Jan 2006 21:49:25 +0100
+
+acpitool (0.4.0-2) unstable; urgency=low
+
+  * Added /patches/01-acpitool.dpatch (closes #342020)
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Wed, 07 Dec 2005 19:49:00 +0200
+
+acpitool (0.4.0-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Mon, 28 Nov 2005 22:33:35 +0100
+
+acpitool (0.3.0-2) unstable; urgency=low
+
+  * deleted debian/dirs, README.Debian and unused build-depends
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Thu, 03 Nov 2005 23:32:42 +0200
+
+acpitool (0.3.0-1) unstable; urgency=low
+
+  * New upstream release
+
+  * acpid is now a recommended package for acpitool (closes: #334788)
+
+  * The NEWS file isn't in the debian package anymore
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Mon, 24 Oct 2005 17:12:35 +0200
+
+acpitool (0.2.7-1) unstable; urgency=low
+
+  * Initial release (closes: #329287)
+
+ -- Nicolas Weyland <ufoalien@weyland.ch>  Wed, 21 Sep 2005 14:59:12 +0200
--- acpitool-0.5.1.orig/debian/compat
+++ acpitool-0.5.1/debian/compat
@@ -0,0 +1 @@
+7
--- acpitool-0.5.1.orig/debian/rules
+++ acpitool-0.5.1/debian/rules
@@ -0,0 +1,21 @@
+#!/usr/bin/make -f
+
+%:
+	dh ${@} --with quilt
+
+override_dh_auto_clean:
+	dh_auto_clean
+
+	rm -f config.guess config.sub
+
+override_dh_auto_configure:
+	cp -f /usr/share/misc/config.guess .
+	cp -f /usr/share/misc/config.sub .
+
+	dh_auto_configure
+
+override_dh_auto_install:
+	$(MAKE) DESTDIR=$(CURDIR)/debian/acpitool install
+
+override_dh_strip:
+	dh_strip --dbg-package=acpitool-dbg
--- acpitool-0.5.1.orig/debian/README.source
+++ acpitool-0.5.1/debian/README.source
@@ -0,0 +1,57 @@
+This package uses quilt to manage all modifications to the upstream
+source.  Changes are stored in the source package as diffs in
+debian/patches and applied during the build.
+
+To configure quilt to use debian/patches instead of patches, you want
+either to export QUILT_PATCHES=debian/patches in your environment
+or use this snippet in your ~/.quiltrc:
+
+    for where in ./ ../ ../../ ../../../ ../../../../ ../../../../../; do
+        if [ -e ${where}debian/rules -a -d ${where}debian/patches ]; then
+                export QUILT_PATCHES=debian/patches
+        fi
+    done
+
+To get the fully patched source after unpacking the source package, cd to
+the root level of the source package and run:
+
+    quilt push -a
+
+The last patch listed in debian/patches/series will become the current
+patch.
+
+To add a new set of changes, first run quilt push -a, and then run:
+
+    quilt new <patch>
+
+where <patch> is a descriptive name for the patch, used as the filename in
+debian/patches.  Then, for every file that will be modified by this patch,
+run:
+
+    quilt add <file>
+
+before editing those files.  You must tell quilt with quilt add what files
+will be part of the patch before making changes or quilt will not work
+properly.  After editing the files, run:
+
+    quilt refresh
+
+to save the results as a patch.
+
+Alternately, if you already have an external patch and you just want to
+add it to the build system, run quilt push -a and then:
+
+    quilt import -P <patch> /path/to/patch
+    quilt push -a
+
+(add -p 0 to quilt import if needed). <patch> as above is the filename to
+use in debian/patches.  The last quilt push -a will apply the patch to
+make sure it works properly.
+
+To remove an existing patch from the list of patches that will be applied,
+run:
+
+    quilt delete <patch>
+
+You may need to run quilt pop -a to unapply patches first before running
+this command.
--- acpitool-0.5.1.orig/debian/control
+++ acpitool-0.5.1/debian/control
@@ -0,0 +1,37 @@
+Source: acpitool
+Section: utils
+Priority: optional
+Maintainer: Debian Acpi Team <pkg-acpi-devel@lists.alioth.debian.org>
+Uploaders: Michael Meskes <meskes@debian.org>
+Build-Depends: debhelper (>= 7.0.50~), autotools-dev, quilt (>= 0.46-7~)
+Standards-Version: 3.9.2
+Homepage: http://freeunix.dyndns.org:8088/site2/acpitool.shtml
+
+Package: acpitool
+Architecture: any
+Depends: ${misc:Depends}, ${shlibs:Depends}
+Recommends: acpid [amd64 i386 ia64]
+Description: command line ACPI client
+ AcpiTool is a Linux ACPI client. It's a small command line application,
+ intended to be a replacement for the apm tool. The primary target audience are
+ laptop users, since these people are most interested in things like battery
+ status, thermal status and the ability to suspend (sleep mode). The program
+ simply accesses the /proc/acpi or /sysfs entries to get or set ACPI values.
+ It also supports various extensions for Toshiba, Asus, and IBM Thinkpad
+ laptops.
+
+Package: acpitool-dbg
+Section: debug
+Priority: extra
+Architecture: any
+Depends: ${misc:Depends}, acpitool (= ${binary:Version})
+Description: command line ACPI client (debug)
+ AcpiTool is a Linux ACPI client. It's a small command line application,
+ intended to be a replacement for the apm tool. The primary target audience are
+ laptop users, since these people are most interested in things like battery
+ status, thermal status and the ability to suspend (sleep mode). The program
+ simply accesses the /proc/acpi or /sysfs entries to get or set ACPI values.
+ It also supports various extensions for Toshiba, Asus, and IBM Thinkpad
+ laptops.
+ .
+ This package contains the debugging symbols.
--- acpitool-0.5.1.orig/debian/watch
+++ acpitool-0.5.1/debian/watch
@@ -0,0 +1,3 @@
+version=3
+http://freeunix.dyndns.org:8088/site2/acpitool.shtml ../ftp_site/pub/unix/acpitool/acpitool-(.*).tar.gz
+#http://sf.net/acpitool/acpitool-(\d\.\d\.\d.*)\.tar\.gz
--- acpitool-0.5.1.orig/debian/source/format
+++ acpitool-0.5.1/debian/source/format
@@ -0,0 +1 @@
+1.0
--- acpitool-0.5.1.orig/debian/patches/ac_adapter.patch
+++ acpitool-0.5.1/debian/patches/ac_adapter.patch
@@ -0,0 +1,73 @@
+Author: Michael Meskes <meskes@debian.org>
+Description: Fix reading of ac_adapter information.
+
+--- acpitool-0.5.1/src/ac_adapter.cpp	2009-08-13 21:26:02.000000000 +0200
++++ acpitool-0.5.1.fixed/src/ac_adapter.cpp	2010-03-09 12:26:22.000000000 +0100
+@@ -149,7 +149,7 @@
+ int Do_AC_Info_Sys()
+ {
+     ifstream file_in;
+-    char filename[2][65], str[100], temp[100];
++    char filename[2][65], str[100], temp[100], attr[100];
+     int ac_count = 0, start = 0, findex = 0;
+     DIR *ac_dir;
+     char *name, *dirname;
+@@ -206,31 +206,40 @@
+ 
+     if(ac_count>0)
+     {
+-    	for(int i=0; i<ac_count; i++)            /* I don't expect to find > 1, but you never know */
++    	for(int i=0, t=0; i<ac_count; i++)            /* I don't expect to find > 1, but you never know */
+     	{
+     	    FILE *power_fp = fopen(filename[i], "r");
+     	    if(power_fp)                   
+     	    {
+-		for(int t=0; t<5; t++) 
+-		    fgets(str, 100, power_fp);              /* just skip the first 5 lines */
+-
+-		memset(str, '\0', 100);
+-		fgets(str, 100, power_fp);  
++		// see linux-2.6/drivers/power/power_supply_sysfs.c
++		// there can be different number of lines, so read up to 40 lines
++		for(; t<40; t++)
++		{
++		    memset(str, '\0', 100);
++		    fgets(str, 100, power_fp);  
+ 		
+-		if (strlen(str)!=0)
+-    		{
+-    		    memset(temp, '\0', 100);
+-    		    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
++		    if (strlen(str)!=0)
++    		    {
++    			memset(temp, '\0', 100);
++			memset(attr, '\0', 100);
++			sscanf(str, "%[^=]s %*s %[^\n]", attr);
++    			sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+     		    
+-    		    /* keep this for debugging */
+-    		    /* printf(" from Do_AC_SYS: temp = %s \n", temp);*/
+-    		    
+-    		    if(strncmp(temp,"1",1)==0)
+-    			printf("  AC adapter     : online \n");
+-    		    else
+-    			printf("  AC adapter     : off-line \n");
++    			/* keep this for debugging */
++    			/* printf(" from Do_AC_SYS: temp = %s \n", temp);*/
++    		   
++			if (strcmp(attr, "POWER_SUPPLY_ONLINE") == 0)
++			{
++    			    if(strncmp(temp,"1",1)==0)
++    				printf("  AC adapter     : online \n");
++    			    else
++    				printf("  AC adapter     : off-line \n");
++
++			    break;
++			}
++		    }
+     		}
+-    		else
++    		if (t == 40) 
+     		    printf("  AC adapter     : <info not available> \n");
+     	    }	    	
+     	    else
--- acpitool-0.5.1.orig/debian/patches/wakeup.patch
+++ acpitool-0.5.1/debian/patches/wakeup.patch
@@ -0,0 +1,70 @@
+From 3a87a4132667f78fc85c54ad89992bbdd02d1e55 Mon Sep 17 00:00:00 2001
+From: Carlos Alberto Lopez Perez <clopez@igalia.com>
+Date: Thu, 6 Oct 2011 03:12:55 +0200
+Subject: [PATCH] Use dynamic structures instead of predefined ones
+
+ * The file /proc/acpi/wakeup can have much more than 25 entries.
+   In my computer (Dell E6420) I have 27 entries.
+   So instead of using an array of [x] entries better use dynamic
+   vectors and push the new entries when a new line from the file
+   is read.
+
+ * The name of the device is not ever 4 characters. For example I
+   have a device called "LID" which is 3 characters long.
+   Instead of using a fixed size for the device we split the line
+   on the first tab (\t) and use the first part.
+---
+ src/acpitool.cpp |   23 +++++++++++------------
+ 1 files changed, 11 insertions(+), 12 deletions(-)
+
+diff --git a/src/acpitool.cpp b/src/acpitool.cpp
+index 2a610a5..71e01d7 100644
+--- a/src/acpitool.cpp
++++ b/src/acpitool.cpp
+@@ -460,16 +460,14 @@ int Show_WakeUp_Devices(int verbose)
+ 
+ int Toggle_WakeUp_Device(const int Device, int verbose)
+ {
+-    ifstream file_in;
+     ofstream file_out;
+-    char *filename, str[50];
+-    int index = 1;
+-    char Name[25][5];            // 25 should be enough I guess, I have only 9 so far //
+-    
++    char *filename; string str;
++    int index = 1; int charindex = 0;
++    std::vector <std::string> Name(index); // Never is enough, use dynamic structures //
+     filename = "/proc/acpi/wakeup";
+     
+-    file_in.open(filename);
+-    if (!file_in)        
++    ifstream file_in(filename, ifstream::in);
++    if (!file_in.good()) // if opening is not successful
+     {
+     	if(!verbose)        
+     	{
+@@ -484,14 +482,15 @@ int Toggle_WakeUp_Device(const int Device, int verbose)
+     	}	
+     }
+     
+-    file_in.getline(str, 50);             // first line are just headers //
++    getline(file_in, str);                // first line are just headers //
+     while(!file_in.eof())                 // count all devices and store their names//
+     {
+-        file_in.getline(str, 50);
+-        if(strlen(str)!=0)                // avoid empty last line //
++        getline(file_in, str);
++        if( str.length() != 0 )           // avoid empty last line //
+         {
+-	    memset(Name[index], '\0', 5);
+-	    strncpy(Name[index], str, 4);
++	    charindex = 0; // reset to zero
++	    while ( (str[++charindex]!='\t')  ); // stop on first tab and get the array index
++	    Name.push_back(str.substr(0,charindex)); // Push the name into the vector
+ 	    index++;
+ 	}
+     }	
+-- 
+1.7.5.4
+
+
--- acpitool-0.5.1.orig/debian/patches/kernel3.patch
+++ acpitool-0.5.1/debian/patches/kernel3.patch
@@ -0,0 +1,12 @@
+--- acpitool-0.5.1/src/acpitool.cpp      2009-08-13 14:37:48.000000000 -0500
++++ acpitool-0.5.1/src/acpitool.cpp       2011-07-28 08:40:37.000000000 -0500
+@@ -205,8 +205,7 @@
+ 	Kernel_24 = 1;           
+ 	Kernel_26 = 0;
+     }
+-        
+-    if(strncmp(str,"2.6",3)==0)
++    else
+     {
+ 	Kernel_24 = 0;           
+ 	Kernel_26 = 1;
--- acpitool-0.5.1.orig/debian/patches/battery.patch
+++ acpitool-0.5.1/debian/patches/battery.patch
@@ -0,0 +1,484 @@
+Author: Evgeni Golov <evgeni@debian.org>, Michael Meskes <meskes@debian.org>
+Description: Fix reading of battery information.
+
+--- acpitool-0.5.1/src/acpitool.h	2008-10-16 17:38:12.000000000 +0200
++++ acpitool-0.5.1.fixed/src/acpitool.h	2010-03-28 11:35:12.000000000 +0200
+@@ -39,6 +39,9 @@
+     char Serial[13];
+     char Bat_Type[13];
+     char Voltage_Now[13];
++    char Charge_Now[13];
++    char Charge_Full[13];
++    char Charge_Full_Design[13];
+ };
+ 
+ 
+--- acpitool-0.5.1/src/battery.cpp	2009-08-13 21:42:43.000000000 +0200
++++ acpitool-0.5.1.fixed/src/battery.cpp	2010-03-28 13:46:40.000000000 +0200
+@@ -107,6 +107,9 @@
+ 	    memset(Batt_Info[i]->Serial, '\0', 13);
+ 	    memset(Batt_Info[i]->Bat_Type, '\0', 13); 
+ 	    memset(Batt_Info[i]->Voltage_Now, '\0', 13); 
++	    memset(Batt_Info[i]->Charge_Now, '\0', 13);
++	    memset(Batt_Info[i]->Charge_Full, '\0', 13);
++	    memset(Batt_Info[i]->Charge_Full_Design, '\0', 13);
+ 	    
+ 	    // initialize all struct members to blanks --> avoid rubbish in output //
+ 			
+@@ -139,7 +142,12 @@
+ 		case 1 : 
+ 		{	
+ 	    	    Present_Batteries++;
+-		    Remaining_Percentage = float(atoi(Batt_Info[i]->Remaining_Cap)) / float(atoi(Batt_Info[i]->LastFull_Cap)) * 100.0;
++
++		    if (strcmp(Batt_Info[i]->Charge_Now,"")!=0 &&
++			strcmp(Batt_Info[i]->Charge_Now,"unknown")!=0)
++		    	Remaining_Percentage = float(atoi(Batt_Info[i]->Charge_Now)) / float(atoi(Batt_Info[i]->Charge_Full)) * 100.0;
++		    else
++			Remaining_Percentage = float(atoi(Batt_Info[i]->Remaining_Cap)) / float(atoi(Batt_Info[i]->LastFull_Cap)) * 100.0;
+ 		    
+ 		    /* from Alan Pope : some broken Dell batteries report a remaining capacity bigger
+ 		       than their last full capacity or their design capacity. This led acpitool to report
+@@ -153,19 +161,24 @@
+             	    else
+             		Precision = 4;
+             	    
+-		    if( strncmp(Batt_Info[i]->Charging_State,"char",4)==0 ) 
++		    if(strncasecmp(Batt_Info[i]->Charging_State,"char",4)==0)
+ 		    {
+ 			Is_Charging = 1;
+ 		    }
+ 		    else
+ 		    {
+-			if(strncmp(Batt_Info[i]->Charging_State,"disch",5)==0) Is_Discharging = 1;
++			if(strncasecmp(Batt_Info[i]->Charging_State,"disch",5)==0) Is_Discharging = 1;
+ 		    }
+ 		    		    
+ 	    	    if(Show_Time)      // calculate remaining or charging time only if present battery rate != 0 //
+ 	    	    {
+-			if(Is_Charging)
+-			  Remaining_Time = (float(atoi(Batt_Info[i]->LastFull_Cap)) - float(atoi(Batt_Info[i]->Remaining_Cap))) / float(atoi(Batt_Info[i]->Present_Rate)); 
++			if(Is_Charging) {
++			  if (strcmp(Batt_Info[i]->Charge_Now,"")!=0 &&
++			      strcmp(Batt_Info[i]->Charge_Now,"unknown")!=0)
++			  	Remaining_Time = (float(atoi(Batt_Info[i]->Charge_Full)) - float(atoi(Batt_Info[i]->Charge_Now))) / float(atoi(Batt_Info[i]->Present_Rate));
++			  else
++			  	Remaining_Time = (float(atoi(Batt_Info[i]->LastFull_Cap)) - float(atoi(Batt_Info[i]->Remaining_Cap))) / float(atoi(Batt_Info[i]->Present_Rate)); 
++			}
+ 			else
+ 			  Remaining_Time = float(atoi(Batt_Info[i]->Remaining_Cap)) / float(atoi(Batt_Info[i]->Present_Rate)); 
+ 			// this represents hours //
+@@ -180,9 +193,11 @@
+ 			Minutes = Time_In_Seconds / 60;
+ 			Time_In_Seconds = Time_In_Seconds - (Minutes * 60);
+ 	    	    }
+-		    
++		   
+ 		    if(atoi(Batt_Info[i]->Design_Cap) > 0)
+ 		      Battery_Left_Percent = float(atoi(Batt_Info[i]->LastFull_Cap)) / float(atoi(Batt_Info[i]->Design_Cap)) * 100.0;
++		    else if(atoi(Batt_Info[i]->Charge_Full_Design) > 0)
++		      Battery_Left_Percent = float(atoi(Batt_Info[i]->Charge_Full)) / float(atoi(Batt_Info[i]->Charge_Full_Design)) * 100.0;
+ 		    else
+ 		      Battery_Left_Percent = -1.0;
+ 		      			  
+@@ -207,8 +222,15 @@
+ 				    <<setfill('0')<<setw(2)<<Time_In_Seconds;
+ 				 cout<<endl;
+ 				 
+-				 cout<<"    Design capacity    : "<<Batt_Info[i]->Design_Cap<<endl;
+-				 cout<<"    Last full capacity : "<<Batt_Info[i]->LastFull_Cap;
++		    		 if(atoi(Batt_Info[i]->Design_Cap) > 0)
++				 	cout<<"    Design capacity    : "<<Batt_Info[i]->Design_Cap<<endl;
++				 else if(atoi(Batt_Info[i]->Charge_Full_Design) > 0)
++				 	cout<<"    Design capacity    : "<<Batt_Info[i]->Charge_Full_Design<<endl;
++
++		    		 if(atoi(Batt_Info[i]->LastFull_Cap) > 0)
++					cout<<"    Last full capacity : "<<Batt_Info[i]->LastFull_Cap;
++				 else if(atoi(Batt_Info[i]->Charge_Full) > 0)
++					cout<<"    Last full capacity : "<<Batt_Info[i]->Charge_Full;
+ 				 
+ 				 if(Battery_Left_Percent<100.0)
+ 				 {
+@@ -327,7 +349,7 @@
+ 
+ 
+ 
+-int Get_Battery_Info_from_Proc(const int bat_nr, Battery_Info *bat_info, int verbose)
++int Get_Battery_Info_from_Proc(const int bat_nr, Battery_Info *batt_info, int verbose)
+ {
+     ifstream file_in;
+     char filename[4][65], str[100], temp[100];
+@@ -378,7 +400,7 @@
+     {
+ 	if(!verbose)
+    	{
+-   	    bat_info->Battery_Present = 2;     // 2 represents error value //
++   	    batt_info->Battery_Present = 2;     // 2 represents error value //
+    	    return 0;
+    	}
+    	else
+@@ -422,24 +444,24 @@
+     	file_in.getline(str, 100);
+     	strncpy(temp, str+25, 4);
+     	if(strncmp(temp,"yes",3)==0)
+-    	    bat_info->Battery_Present = 1;               //yes, we have a battery //
++    	    batt_info->Battery_Present = 1;               //yes, we have a battery //
+     	else
+     	{
+-    	    bat_info->Battery_Present = 0;
++    	    batt_info->Battery_Present = 0;
+     	    return 0;                  //bail out if battery is not present //
+     	}
+     	
+ 	// then get the design capacity //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Design_Cap, str+25, 9);
++    	strncpy(batt_info->Design_Cap, str+25, 9);
+ 	
+     	// then get the last full capacity //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->LastFull_Cap, str+25, 9);
++    	strncpy(batt_info->LastFull_Cap, str+25, 9);
+ 	
+-	if (strncmp(bat_info->LastFull_Cap,"unknown",7)==0)
++	if (strncmp(batt_info->LastFull_Cap,"unknown",7)==0)
+ 	{
+-    	    bat_info->Battery_Present = 0;
++    	    batt_info->Battery_Present = 0;
+     	    return 0;                  //bail out if battery is not present //
+     	}
+ 	/* some Dell laptops seem to report a 2nd battery as being present, while it is NOT, but then report the 
+@@ -449,21 +471,21 @@
+     
+     	// then get the technology //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Technology, str+25, 12);
++    	strncpy(batt_info->Technology, str+25, 12);
+     
+     	// then get the model number //
+     	for(int t=0; t<5; t++)
+ 	file_in.getline(str, 100);            //skip 5 lines //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Model, str+25, 12);
++    	strncpy(batt_info->Model, str+25, 12);
+     
+     	// then get the serial number //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Serial, str+25, 12);
++    	strncpy(batt_info->Serial, str+25, 12);
+     
+     	// then get the battery type //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Bat_Type, str+25, 12);
++    	strncpy(batt_info->Bat_Type, str+25, 12);
+     
+     	file_in.close();
+     	
+@@ -480,17 +502,17 @@
+     	// then get the charging state //
+     	file_in.getline(str, 100); file_in.getline(str, 100);     // skip first 2 lines //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Charging_State, str+25, 12);
+-	if (strncmp(bat_info->Charging_State,"unknown",7)==0) strncpy(bat_info->Charging_State, "charged",7);
++    	strncpy(batt_info->Charging_State, str+25, 12);
++	if (strncmp(batt_info->Charging_State,"unknown",7)==0) strncpy(batt_info->Charging_State, "charged",7);
+ 	/* on older kernels, like 2.4.22, the charging state is reported as "unknown", whereas in recent kernels
+ 	   this was changed to "charged". */  
+ 
+     	// then get the charging rate //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Present_Rate, str+25, 9);
+-	if (strncmp(bat_info->Charging_State,"charged",7)==0)
++    	strncpy(batt_info->Present_Rate, str+25, 9);
++	if (strncmp(batt_info->Charging_State,"charged",7)==0)
+ 	{
+-	    if (strncmp(bat_info->Present_Rate, "unknown",7)==0) strncpy(bat_info->Present_Rate, "0      ",7);
++	    if (strncmp(batt_info->Present_Rate, "unknown",7)==0) strncpy(batt_info->Present_Rate, "0      ",7);
+ 	}    
+ 	/* some batteries report the present rate as "unknown", even when they report the battery as being charged.
+ 	   If the battery is charged, the rate should be 0 */     
+@@ -498,12 +520,12 @@
+ 
+     	// then get the remaining capacity //
+     	file_in.getline(str, 100);
+-    	strncpy(bat_info->Remaining_Cap, str+25, 9);
++    	strncpy(batt_info->Remaining_Cap, str+25, 9);
+     
+     	file_in.close();
+ 	}
+ 	else      // battery dir is readable but empty : only . and .. at most //
+-	    bat_info->Battery_Present = 3;   
++	    batt_info->Battery_Present = 3;   
+ 	
+ 	return 0;
+ }
+@@ -513,8 +535,8 @@
+ int Get_Battery_Info_from_Sys(const int bat_nr, Battery_Info *batt_info, int verbose)
+ {
+     ifstream file_in;
+-    char filename[6][65], str[100], temp[100];
+-    int bat_count = 0, start = 0, findex = 0;
++    char filename[6][65], str[100], temp[100], attr[100];
++    int bat_count = 0, start = 0, findex = 0, value = 0;
+     DIR *battery_dir;
+     char *name, *dirname;
+        
+@@ -613,165 +635,104 @@
+ 	    return -1;
+     	}
+     	
+-    	memset(str, '\0', 100);
+-	for(int t=0; t<5; t++)
+-	    fgets(str, 100, power_fp);            /* skip first 5 lines */
+-    	
+-    	/* get battery status (full, charging, ...) */
+-    	memset(str, '\0', 100);
+-    	fgets(str, 100, power_fp);
+-    	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Charging_State, temp, 12);
+-    	}   
+-	
+-	    
+-	/* get battery presence (0 or 1) */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);   
+-	if (strlen(str)>0)
+-	{
+-	    memset(temp, '\0', 100);
+-	    strncpy(temp, str+21, 1);
+-    	    if(strncmp(temp,"1",1)==0)
+-    	        batt_info->Battery_Present = 1;               /* yes, we have a battery */
+-    	    else
+-    	    {
+-    		batt_info->Battery_Present = 0;
+-    		printf(" Battery is not present, bailing out. \n");
+-    		return 0;                                    /* bail out if battery is not present */
+-    	    }
+-    	}
+-    	    
+-    	    
+-    	/* get technology */    
+-    	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);   
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Technology, temp, 12);
+-    	} 
+-    	else
+-    	    strncpy(batt_info->Technology, "unknown", 7);
+-    	    
+-    	    
+-    	    
+-    	//printf(" \n bat_info_tech = %s \n\n ",  batt_info->Technology);    
+-    	
+-    	
+-
+-	fgets(str, 100, power_fp);    	/* skip 1 line */	
+-
+-
+-	/* get voltage_now */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Voltage_Now, temp, 12);
+-    	}    
+-    	else
+-    	    strncpy(batt_info->Voltage_Now, "unknown", 7);
+-
+-    	
+-	/* get current_now, which I believe is the charging rate ? */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Present_Rate, temp, 12);
+-    	}       
+-    	else
+-    	    strncpy(batt_info->Present_Rate, "unknown", 7);
+-
+-	
+-	/* get charge_full_design */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Design_Cap, temp, 12);
+-    	}          
+-    	else
+-    	    strncpy(batt_info->Design_Cap, "unknown", 7);
+-    	    
+-    	    
+-    	//printf(" \n bat_info_design_cap = %s \n ",  batt_info->Design_Cap);    
+-
+-
+-	/* get charge_full, which is the last full capacity I guess ? */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);   
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->LastFull_Cap, temp, 12);
+-    	}       
+-    	else
+-    	    strncpy(batt_info->LastFull_Cap, "unknown", 7);
+-
+-
+-	//printf(" \n bat_info_lastfull_cap = %s \n\n ",  batt_info->LastFull_Cap); 
+-
+-
+-	/* get charge_now */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);   
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Remaining_Cap, temp, 12);
+-    	}       
+-    	else
+-    	    strncpy(batt_info->Remaining_Cap, "unknown", 7);
+-
+-	//printf(" \n bat_info_remaining_cap = %s \n\n ",  batt_info->Remaining_Cap); 
+-
+-
+-	/* get model_name */  
+-	memset(str, '\0', 100);  
+-	fgets(str, 100, power_fp);   
+-	if (strlen(str)>0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-	    strncpy(temp, str+24, 12);         // use strncpy here because sscanf chokes on blanks in this one ? //
+-
+-    	    memset(str, '\0', 100);
+-    	    sscanf(temp, "%[^\n]", str);       // strip trailing \n, fucks up output //
+-    	    
+-    	    strncpy(batt_info->Model, str, 12);
++	strncpy(batt_info->Technology, "unknown", 7);
++	strncpy(batt_info->Voltage_Now, "unknown", 7);
++	strncpy(batt_info->Charge_Now, "unknown", 7);
++	strncpy(batt_info->Charge_Full, "unknown", 7);
++	strncpy(batt_info->Charge_Full_Design, "unknown", 7);
++	strncpy(batt_info->Present_Rate, "unknown", 7);
++	strncpy(batt_info->Design_Cap, "unknown", 7);
++	strncpy(batt_info->LastFull_Cap, "unknown", 7);
++	strncpy(batt_info->Remaining_Cap, "unknown", 7);
++	strncpy(batt_info->Model, "unknown", 7);
++	strncpy(batt_info->Serial, "unknown", 7);
++
++	// see linux-2.6/drivers/power/power_supply_sysfs.c
++	// there can be different number of lines, so read up to 40 lines
++	for(int t=0; t<40; t++) {
++    		memset(str, '\0', 100);
++		memset(attr, '\0', 100);
++    		memset(temp, '\0', 100);
++		fgets(str, 100, power_fp);
++		sscanf(str, "%[^=]s %*s %*[^\n]", attr);
++    		sscanf(str, "%*[^=] %*c %s %*[^\n]",temp); 
++		if (strcmp(attr,"POWER_SUPPLY_STATUS")==0) {
++    			strncpy(batt_info->Charging_State, temp, 12);
++    		}   
++		else if (strcmp(attr,"POWER_SUPPLY_TYPE")==0) {
++			strncpy(batt_info->Bat_Type, temp, 12);
++    		}
++		else if (strcmp(attr,"POWER_SUPPLY_TECHNOLOGY")==0) {
++    			strncpy(batt_info->Technology, temp, 12);
++    		} 
++		else if (strcmp(attr,"POWER_SUPPLY_VOLTAGE_NOW")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mV", value);
++    	    		strncpy(batt_info->Voltage_Now, temp, 12);
++    		}    
++		else if (strcmp(attr,"POWER_SUPPLY_CURRENT_NOW")==0 ||
++			 strcmp(attr,"POWER_SUPPLY_POWER_NOW")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i", value);
++			strncpy(batt_info->Present_Rate, temp, 9);
++		}
++		else if (strcmp(attr,"POWER_SUPPLY_CHARGE_NOW")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mA", value);
++			strncpy(batt_info->Charge_Now, temp, 12);
++		}
++		else if (strcmp(attr,"POWER_SUPPLY_CHARGE_FULL_DESIGN")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mA", value);
++			strncpy(batt_info->Charge_Full_Design, temp, 12);
++		}
++		else if (strcmp(attr,"POWER_SUPPLY_CHARGE_FULL")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mA", value);
++			strncpy(batt_info->Charge_Full, temp, 12);
++		}
++		else if (strcmp(attr,"POWER_SUPPLY_ENERGY_FULL_DESIGN")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mWh", value);
++			strncpy(batt_info->Design_Cap, temp, 9);
++		}
++		else if (strcmp(attr,"POWER_SUPPLY_ENERGY_FULL")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mWh", value);
++			strncpy(batt_info->LastFull_Cap, temp, 9);
++		}
++		else if (strcmp(attr,"POWER_SUPPLY_ENERGY_NOW")==0) {
++			value = atoi(temp) / 1000;
++			snprintf(temp, sizeof(temp), "%i mWh", value);
++			strncpy(batt_info->Remaining_Cap, temp, 9);
++    		}       
++		else if (strcmp(attr,"POWER_SUPPLY_MODEL_NAME")==0) {
++			strncpy(batt_info->Model, temp, 12);
++    		}
++		else if (strcmp(attr,"POWER_SUPPLY_SERIAL_NUMBER")==0) {
++			strncpy(batt_info->Serial, temp, 12);
++    		}       
++		else if (strcmp(attr,"POWER_SUPPLY_PRESENT")==0) {
++			if(strncmp(temp,"1",1)==0) {
++				batt_info->Battery_Present = 1;
++			}
++			else {
++				batt_info->Battery_Present = 0;
++				printf(" Battery is not present, bailing out. \n");
++				return 0;
++    			}
++           	}       
+     	}       
++	if (strcmp(batt_info->Charge_Now,"")!=0 &&
++	   strcmp(batt_info->Charge_Now,"unknown")!=0)
++		snprintf(temp, sizeof(temp), "%s mA", batt_info->Present_Rate);
+     	else
+-    	    strncpy(batt_info->Model, "unknown", 7);
++		snprintf(temp, sizeof(temp), "%s mW", batt_info->Present_Rate);
+ 
+-	fgets(str, 100, power_fp);   
++	strncpy(batt_info->Present_Rate, temp, 9);
+ 	
+-	/* get serial */    
+-	memset(str, '\0', 100);
+-	fgets(str, 100, power_fp);   
+-	if (strlen(str)!=0)
+-    	{
+-    	    memset(temp, '\0', 100);
+-    	    sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+-    	    strncpy(batt_info->Serial, temp, 12);
+-    	}       
+-    	else
+-    	    strncpy(batt_info->Serial, "unknown", 7);
+-    
+     	fclose(power_fp);
+-	}
++    }
+     else      // battery dir is readable but empty : only . and .. at most //
+         batt_info->Battery_Present = 3;   
+     return 0;
--- acpitool-0.5.1.orig/debian/patches/series
+++ acpitool-0.5.1/debian/patches/series
@@ -0,0 +1,4 @@
+ac_adapter.patch
+battery.patch
+kernel3.patch
+wakeup.patch
