summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: adaf6ca)
raw | patch | inline | side by side (parent: adaf6ca)
author | octo <octo> | |
Tue, 11 Apr 2006 18:41:06 +0000 (18:41 +0000) | ||
committer | octo <octo> | |
Tue, 11 Apr 2006 18:41:06 +0000 (18:41 +0000) |
src/iokit.c | patch | blob | history |
diff --git a/src/iokit.c b/src/iokit.c
index 637c8086083ad0107224e85c5c847bbfc7840c0b..8a533f0fa676b986355a9c547abf8b6d8791c203 100644 (file)
--- a/src/iokit.c
+++ b/src/iokit.c
#define MODULE_NAME "iokit"
+#if HAVE_CTYPE_H
+# include <ctype.h>
+#endif
#if HAVE_MACH_MACH_TYPES_H
# include <mach/mach_types.h>
#endif
}
#if IOKIT_HAVE_READ
-static void iokit_submit (char *type, char *inst, int value)
+static void iokit_submit (char *type, char *inst, double value)
{
char buf[128];
- if (snprintf (buf, 1024, "%u:%i", (unsigned int) curtime,
+ if (snprintf (buf, 1024, "%u:%f", (unsigned int) curtime,
value) >= 128)
return;
CFMutableDictionaryRef prop_dict;
CFTypeRef property;
- char type[128];
- char inst[128];
- int value;
+ char type[128];
+ char inst[128];
+ int value_int;
+ double value_double;
+ int i;
if (!io_master_port || (io_master_port == MACH_PORT_NULL))
return;
kCFStringEncodingASCII))
continue;
inst[127] = '\0';
+ for (i = 0; i < 128; i++)
+ {
+ if (inst[i] == '\0')
+ break;
+ else if (isalnum (inst[i]))
+ inst[i] = (char) tolower (inst[i]);
+ else
+ inst[i] = '_';
+ }
/* Get the actual value. Some computation, based on the `type'
* is neccessary. */
continue;
if (!CFNumberGetValue (property,
kCFNumberIntType,
- &value))
+ &value_int))
continue;
+ if ((strcmp (type, "temperature") == 0)
+ || (strcmp (type, "fanspeed") == 0)
+ || (strcmp (type, "voltage") == 0))
+ {
+ value_double = ((double) value_int) / 65536.0;
+ }
+ else
+ {
+ value_double = (double) value_int;
+ }
+
/* Do stuff */
- DBG ("type = %s, inst = %s, value = %i",
- type, inst, value);
- iokit_submit (type, inst, value);
+ DBG ("type = %s, inst = %s, value_int = %i, value_double = %f",
+ type, inst, value_int, value_double);
+ iokit_submit (type, inst, value_double);
CFRelease (prop_dict);
IOObjectRelease (io_obj);