summaryrefslogtreecommitdiff
path: root/src/freebsd/dkp-acpi-native.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/freebsd/dkp-acpi-native.vala')
-rw-r--r--src/freebsd/dkp-acpi-native.vala46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/freebsd/dkp-acpi-native.vala b/src/freebsd/dkp-acpi-native.vala
new file mode 100644
index 0000000..7710798
--- /dev/null
+++ b/src/freebsd/dkp-acpi-native.vala
@@ -0,0 +1,46 @@
+public class DkpAcpiNative : Object {
+ private string? _driver;
+ private int _unit;
+ private string _path;
+
+ public string driver {
+ get { return _driver; }
+ }
+
+ public int unit {
+ get { return _unit; }
+ }
+
+ public string path {
+ get { return _path; }
+ }
+
+ public DkpAcpiNative (string path) {
+ Regex r;
+ MatchInfo mi;
+ bool ret;
+
+ try {
+ r = new Regex("dev\\.([^\\.])\\.(\\d+)");
+ ret = r.match(path, 0, out mi);
+ if (ret) {
+ _driver = mi.fetch(1);
+ _unit = mi.fetch(2).to_int();
+ } else {
+ _driver = null;
+ _unit = -1;
+ }
+ } catch (RegexError re) {
+ _driver = null;
+ _unit = -1;
+ }
+
+ _path = path;
+ }
+
+ public DkpAcpiNative.driver_unit (string driver, int unit) {
+ _driver = driver;
+ _unit = unit;
+ _path = "dev.%s.%i".printf (_driver, _unit);
+ }
+}