aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_apm.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-06-17 06:23:43 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-06-17 06:23:43 +0000
commit1d354fd87d4c07906e82d104ba8614d30ae9cbbe (patch)
treeca9aafd446dda125df1411933930669d303c9a30 /plugin_apm.c
parente8e56418dc7375b50f36e930fb6752fbe25b4ae1 (diff)
downloadlcd4linux-1d354fd87d4c07906e82d104ba8614d30ae9cbbe.tar.gz
[lcd4linux @ 2004-06-17 06:23:39 by reinelt]
hash handling rewritten to solve performance issues git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@473 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_apm.c')
-rw-r--r--plugin_apm.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/plugin_apm.c b/plugin_apm.c
index 6c58009..feebb41 100644
--- a/plugin_apm.c
+++ b/plugin_apm.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_apm.c,v 1.1 2004/03/14 07:11:42 reinelt Exp $
+/* $Id: plugin_apm.c,v 1.2 2004/06/17 06:23:43 reinelt Exp $
*
* plugin for APM (battery status)
*
@@ -26,6 +26,10 @@
*
*
* $Log: plugin_apm.c,v $
+ * Revision 1.2 2004/06/17 06:23:43 reinelt
+ *
+ * hash handling rewritten to solve performance issues
+ *
* Revision 1.1 2004/03/14 07:11:42 reinelt
* parameter count fixed for plugin_dvb()
* plugin_APM (battery status) ported
@@ -129,7 +133,7 @@ static int parse_proc_apm (void)
int age, i;
// reread every 10 msec only
- age = hash_age (&APM, NULL, NULL);
+ age = hash_age (&APM, NULL);
if (age > 0 && age <= 10) return 0;
if (fd == -2) {
@@ -156,10 +160,9 @@ static int parse_proc_apm (void)
for (i = 0; i < 9 && beg != NULL; i++) {
while (*beg == ' ') beg++;
if ((end = strpbrk(beg, " \n"))) *end='\0';
- hash_set (&APM, key[i], beg);
+ hash_put (&APM, key[i], beg);
beg = end ? end+1 : NULL;
}
-
return 0;
}
@@ -169,20 +172,23 @@ static void my_apm (RESULT *result, RESULT *arg1)
{
char *val;
- if (parse_proc_apm()<0) {
+ if (parse_proc_apm() < 0) {
SetResult(&result, R_STRING, "");
return;
}
- val=hash_get(&APM, R2S(arg1));
- if (val==NULL) val="";
+ val = hash_get(&APM, R2S(arg1), NULL);
+ if (val == NULL) val = "";
SetResult(&result, R_STRING, val);
}
int plugin_init_apm (void)
{
+ hash_create (&APM);
+
AddFunction ("apm", 1, my_apm);
+
return 0;
}
@@ -192,5 +198,6 @@ void plugin_exit_apm (void)
close (fd);
}
fd = -2;
+
hash_destroy(&APM);
}