update es, da language
[enigma2.git] / lib / driver / misc_options.cpp
1 #include <lib/driver/misc_options.h>
2
3 #include <unistd.h>
4 #include <fcntl.h>
5 #include <sys/ioctl.h>
6
7 #include <lib/base/init.h>
8 #include <lib/base/init_num.h>
9 #include <lib/base/eerror.h>
10
11 Misc_Options *Misc_Options::instance = 0;
12
13 Misc_Options::Misc_Options()
14         :m_12V_output_state(-1)
15 {
16         ASSERT(!instance);
17         instance = this;
18 }
19
20 int Misc_Options::set_12V_output(int state)
21 {
22         if (state == m_12V_output_state)
23                 return 0;
24         int fd = open("/proc/stb/misc/12V_output", O_WRONLY);
25         if (fd < 0)
26         {
27                 eDebug("couldn't open /proc/stb/misc/12V_output");
28                 return -1;
29         }
30         const char *str=0;
31         if (state == 0)
32                 str = "off";
33         else if (state == 1)
34                 str = "on";
35         if (str)
36                 write(fd, str, strlen(str));
37         m_12V_output_state = state;
38         close(fd);
39         return 0;
40 }
41
42 Misc_Options *Misc_Options::getInstance()
43 {
44         return instance;
45 }
46
47 //FIXME: correct "run/startlevel"
48 eAutoInitP0<Misc_Options> init_misc_options(eAutoInitNumbers::rc, "misc options");