backlight.c

Sun, 09 Feb 2020 10:55:12 +0100

author
David Demelier <markand@malikania.fr>
date
Sun, 09 Feb 2020 10:55:12 +0100
changeset 21
bf880b3c0665
parent 19
0de3886f98ad
child 23
6081cc143d37
permissions
-rw-r--r--

backlight: fix usage

7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 /*
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 * main.c -- adjust laptop backlight using ACPI
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 *
19
0de3886f98ad misc: minor updates
David Demelier <markand@malikania.fr>
parents: 18
diff changeset
4 * Copyright (c) 2010-2020 David Demelier <markand@malikania.fr>
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 *
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 * Permission to use, copy, modify, and distribute this software for any
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 * copyright notice and this permission notice appear in all copies.
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 *
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 */
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
19 #include <errno.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 #include <stdarg.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
21 #include <stdio.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 #include <stdlib.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
23 #include <string.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
24
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
25 /*
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
26 * Functions to implement for your system:
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
27 *
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
28 * All of these functions are allowed to exit on failures.
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
29 */
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
30
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
31 /* Set the level explicitly to the nearest value */
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
32 static void
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
33 set(unsigned int);
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
34
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
35 /* Get the current value */
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
36 static unsigned int
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
37 get(void);
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
38
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 static void
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
40 increase(void)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
41 {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
42 unsigned int value = get();
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
43
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
44 if (value + 2 > 100)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
45 value = 100;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
46 else
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
47 value += 2;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
48
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
49 set(value);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
50 }
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
51
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
52 static void
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
53 decrease(void)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
54 {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
55 unsigned int value = get();
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
56
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
57 if ((int)value - 2 < 0)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
58 value = 0;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
59 else
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
60 value -= 2;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
61
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
62 set(value);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
63 }
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
64
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
65
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
66 static void
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 usage(const char *name)
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 {
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
69 fprintf(stderr, "usage: %s decrease\n", name);
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
70 fprintf(stderr, " %s get\n", name);
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
71 fprintf(stderr, " %s increase\n", name);
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
72 fprintf(stderr, " %s set percentage\n", name);
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 exit(1);
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
75
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 static void
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 die(const char *fmt, ...)
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 {
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
79 va_list ap;
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
80
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 va_start(ap, fmt);
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
82 fprintf(stderr, "abort: ");
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
83 vfprintf(stderr, fmt, ap);
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 va_end(ap);
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
85
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 exit(1);
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
87 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
88
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
89 /* {{{ Support for FreeBSD */
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
90
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
91 #if defined(__FreeBSD__)
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
92
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
93 #include <sys/types.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
94 #include <sys/sysctl.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
95
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
96 static int
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
97 upper_bound(int *levels, size_t length, unsigned int percent)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
98 {
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
99 size_t low = 0;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
100 size_t high = length - 1;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
101
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
102 while (low < high) {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
103 size_t mid = (low + high) / 2;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
104
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
105 if (percent <= (unsigned)levels[mid])
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
106 high = mid;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
107 else
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
108 low = mid + 1;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
109 }
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
110
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
111 return low;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
112 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
113
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
114 static int
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
115 min(const void *v1, const void *v2)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
116 {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
117 return *(int *)v1 - *(int *)v2;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
118 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
119
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
120 static void
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
121 sort(int *tab, size_t size)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
122 {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
123 qsort(tab, size, sizeof (int), min);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
124 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
125
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
126 static void
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
127 set(unsigned int percent)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
128 {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
129 int levels[200] = {0};
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
130 size_t length = sizeof (levels);
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
131
18
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
132 if (sysctlbyname("hw.acpi.video.lcd0.levels", levels, &length, NULL, 0) < 0)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
133 die("sysctl: %s\n", strerror(errno));
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
134
18
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
135 length /= sizeof (int);
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
136
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
137 /* Find appropriate nearest level */
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
138 if (percent > 0 && percent < 100) {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
139 sort(levels, length);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
140 percent = levels[upper_bound(levels, length, percent)];
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
141 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
142
18
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
143 if (sysctlbyname("hw.acpi.video.lcd0.brightness", NULL, NULL,
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
144 &percent, sizeof (int)) < 0)
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
145 die("sysctl: %s\n", strerror(errno));
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
146
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
147 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
148
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
149 static unsigned int
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
150 get(void)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
151 {
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
152 int current = 0;
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
153 size_t length = sizeof (int);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
154
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
155 if (sysctlbyname("hw.acpi.video.lcd0.brightness", &current, &length, NULL, 0) == -1)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
156 die("sysctl: %s\n", strerror(errno));
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
157
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
158 return current;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
159 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
160
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
161 /* }}} */
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
162
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
163 /* {{{ Support for Linux */
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
164
9
bd47bd0c977a backlight: fix for FreeBSD and pet a warning
David Demelier <markand@malikania.fr>
parents: 7
diff changeset
165 #elif defined(__linux__)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
166
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
167 #include <sys/types.h>
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
168 #include <sys/stat.h>
11
637ef49be6c9 backlight: use _XOPEN_SOURCE=700
David Demelier <markand@malikania.fr>
parents: 10
diff changeset
169 #include <dirent.h>
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
170 #include <fcntl.h>
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
171 #include <unistd.h>
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
172
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
173 #define SYS_PATH "/sys/class/backlight"
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
174
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
175 static unsigned int
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
176 read_int(int dfd, const char *file)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
177 {
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
178 char buf[32] = {0};
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
179 int fd;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
180
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
181 if ((fd = openat(dfd, file, O_RDONLY)) < 0)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
182 die("open: %s\n", strerror(errno));
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
183 if (read(fd, &buf[0], sizeof (buf) - 1) < 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
184 die("read: %s\n", strerror(errno));
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
185
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
186 close(fd);
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
187
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
188 return atoi(buf);
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
189 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
190
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
191 static int
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
192 write_int(int dfd, const char *file, unsigned int value)
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
193 {
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
194 char buf[32] = {0};
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
195 int length;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
196 int fd;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
197
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
198 if ((fd = openat(dfd, file, O_WRONLY)) < 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
199 die("open: %s\n", strerror(errno));
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
200 if ((length = snprintf(buf, sizeof (buf), "%d\n", value)) < 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
201 die("snprintf: %s\n", strerror(errno));
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
202 if (write(fd, buf, length) != length)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
203 die("write: %s\n", strerror(errno));
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
204
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
205 /* Re-read in case kernel change the value. */
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
206 return read_int(dfd, "brightness");
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
207 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
208
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
209 static int
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
210 try_adaptor(int parent_fd, const char *path)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
211 {
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
212 int dfd;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
213 struct stat st;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
214
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
215 if ((dfd = openat(parent_fd, path, O_RDONLY)) < 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
216 return -1;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
217 if (fstatat(dfd, "brightness", &st, 0) < 0) {
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
218 close(dfd);
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
219 return -1;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
220 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
221
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
222 return dfd;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
223 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
224
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
225 static int
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
226 find_adaptor(void)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
227 {
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
228 int dfd, adaptorfd = -1;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
229 DIR *dirp;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
230 struct dirent *dirent;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
231
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
232 if ((dfd = open(SYS_PATH, O_RDONLY)) < 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
233 die("open: %s: %s\n", SYS_PATH, strerror(errno));
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
234 if (!(dirp = fdopendir(dfd)))
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
235 die("fdopendir: %s: %s\n", SYS_PATH, strerror(errno));
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
236
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
237 while ((dirent = readdir(dirp))) {
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
238 if (strcmp(dirent->d_name, ".") == 0 ||
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
239 strcmp(dirent->d_name, "..") == 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
240 continue;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
241
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
242 if ((adaptorfd = try_adaptor(dfd, dirent->d_name)) >= 0)
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
243 break;
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
244 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
245
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
246 closedir(dirp);
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
247 close(dfd);
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
248
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
249 if (adaptorfd < 0)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
250 die("could not find card adaptor\n");
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
251
10
2b12d8bee90d backlight: search for card in Linux
David Demelier <markand@malikania.fr>
parents: 9
diff changeset
252 return adaptorfd;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
253 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
254
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
255 static unsigned int
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
256 downscale(int dfd, unsigned int value)
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
257 {
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
258 return value * 100 / read_int(dfd, "max_brightness");
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
259 }
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
260
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
261 static unsigned int
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
262 upscale(int dfd, unsigned int value)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
263 {
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
264 return value * read_int(dfd, "max_brightness") / 100;
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
265 }
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
266
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
267 static void
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
268 set(unsigned int percent)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
269 {
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
270 int dfd = find_adaptor();
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
271 unsigned int value = upscale(dfd, percent);
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
272
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
273 write_int(dfd, "brightness", value);
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
274 }
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
275
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
276 static unsigned int
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
277 get(void)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
278 {
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
279 int dfd = find_adaptor();
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
280 int value = read_int(dfd, "brightness");
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
281
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
282 return downscale(dfd, value);
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
283 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
284
16
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
285 /* }}} */
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
286
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
287 /* {{{ Non supported shims */
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
288
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
289 #else
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
290
16
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
291 static void
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
292 notsupported(void)
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
293 {
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
294 die("backlight is not supported on this system\n");
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
295 }
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
296
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
297 static void
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
298 set(unsigned int v)
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
299 {
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
300 (void)v;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
301
16
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
302 notsupported();
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
303 }
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
304
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
305 static unsigned int
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
306 get(void)
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
307 {
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
308 notsupported();
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
309
0d923f0155dd doc: improve documentation
David Demelier <markand@malikania.fr>
parents: 15
diff changeset
310 return -1;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
311 }
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
312
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
313 #endif
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
314
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
315 /* }}} */
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
316
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
317 int
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
318 main(int argc, char *argv[])
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
319 {
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
320 -- argc;
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
321 ++ argv;
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
322
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
323 if (argc < 1)
18
281cc3a22f1b backlight: fix FreeBSD implementation
David Demelier <markand@malikania.fr>
parents: 17
diff changeset
324 usage("backlight");
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
325
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
326 if (strcmp(argv[0], "get") == 0)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
327 printf("%d\n", get());
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
328 else if (strcmp(argv[0], "set") == 0) {
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
329 if (argc != 2)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
330 usage(argv[0]);
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
331
17
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
332 unsigned int value = atoi(argv[1]);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
333
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
334 if (value > 100)
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
335 die("value %u is out of range\n", value);
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
336
37d1b7dd73ee backlight: update FreeBSD support
David Demelier <markand@malikania.fr>
parents: 16
diff changeset
337 set(value);
15
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
338 } else if (strcmp(argv[0], "increase") == 0)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
339 increase();
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
340 else if (strcmp(argv[0], "decrease") == 0)
282ec7c30c04 backlight: now supports more commands
David Demelier <markand@malikania.fr>
parents: 11
diff changeset
341 decrease();
21
bf880b3c0665 backlight: fix usage
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
342 else
bf880b3c0665 backlight: fix usage
David Demelier <markand@malikania.fr>
parents: 19
diff changeset
343 usage("backlight");
7
45a06b02a61f misc: add missing files
David Demelier <markand@malikania.fr>
parents:
diff changeset
344 }

mercurial