Module Name: src Committed By: pgoyette Date: Sun Jun 19 03:09:44 UTC 2011
Modified Files: src/sys/dev/sysmon: sysmon_envsys_tables.c sysmon_envsysvar.h Log Message: Add routine to lookup description tables by description instead of by type. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/sysmon/sysmon_envsys_tables.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/sysmon/sysmon_envsysvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/sysmon/sysmon_envsys_tables.c diff -u src/sys/dev/sysmon/sysmon_envsys_tables.c:1.6 src/sys/dev/sysmon/sysmon_envsys_tables.c:1.7 --- src/sys/dev/sysmon/sysmon_envsys_tables.c:1.6 Wed Dec 15 17:17:17 2010 +++ src/sys/dev/sysmon/sysmon_envsys_tables.c Sun Jun 19 03:09:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_tables.c,v 1.6 2010/12/15 17:17:17 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsys_tables.c,v 1.7 2011/06/19 03:09:43 pgoyette Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.6 2010/12/15 17:17:17 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.7 2011/06/19 03:09:43 pgoyette Exp $"); #include <sys/types.h> @@ -129,3 +129,29 @@ return table; } +const struct sme_descr_entry * +sme_find_table_desc(enum sme_descr_type table_id, const char *str) +{ + const struct sme_descr_entry *table = NULL; + + switch (table_id) { + case SME_DESC_UNITS: + table = sme_units_description; + break; + case SME_DESC_STATES: + table = sme_state_description; + break; + case SME_DESC_DRIVE_STATES: + table = sme_drivestate_description; + break; + case SME_DESC_BATTERY_CAPACITY: + table = sme_batterycap_description; + break; + } + + for (; table->type != -1; table++) + if (strcmp(table->desc, str) == 0) + break; + return table; +} + Index: src/sys/dev/sysmon/sysmon_envsysvar.h diff -u src/sys/dev/sysmon/sysmon_envsysvar.h:1.39 src/sys/dev/sysmon/sysmon_envsysvar.h:1.40 --- src/sys/dev/sysmon/sysmon_envsysvar.h:1.39 Wed Jun 8 18:22:24 2011 +++ src/sys/dev/sysmon/sysmon_envsysvar.h Sun Jun 19 03:09:43 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsysvar.h,v 1.39 2011/06/08 18:22:24 pgoyette Exp $ */ +/* $NetBSD: sysmon_envsysvar.h,v 1.40 2011/06/19 03:09:43 pgoyette Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -145,5 +145,7 @@ int sme_sensor_upstring(prop_dictionary_t, const char *, const char *); const struct sme_descr_entry *sme_find_table_entry(enum sme_descr_type, int); +const struct sme_descr_entry * sme_find_table_desc(enum sme_descr_type, + const char *); #endif /* _DEV_SYSMON_ENVSYSVAR_H_ */