summaryrefslogtreecommitdiff
path: root/src/freebsd/up-acpi-native.vala
blob: 796d97e86ab71510c2693f3c5a2f9ecf324fe82e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class UpAcpiNative : 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 UpAcpiNative (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 UpAcpiNative.driver_unit (string driver, int unit) {
	_driver = driver;
	_unit = unit;
	_path = "dev.%s.%i".printf (_driver, _unit);
    }
}