1 /* This file is part of LED Pattern Editor.
3 * Copyright (C) 2010 Philipp Zabel
5 * LED Pattern Editor is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * LED Pattern Editor is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with LED Pattern Editor. If not, see <http://www.gnu.org/licenses/>.
19 List<LedPatternRX51> mce_ini_parse () {
20 var list = new List<LedPatternRX51> ();
21 var f = FileStream.open ("/etc/mce/mce.ini", "r");
23 var line = f.read_line ();
24 while (line != null) {
25 if (line == "[LEDPatternLystiRX51]") {
26 line = f.read_line ();
27 while ((line != null) && (line[0] != '[')) {
28 if (line.has_prefix ("Pattern")) {
29 var pattern = new LedPatternRX51 ();
31 list.append (pattern);
33 line = f.read_line ();
36 line = f.read_line ();
42 void mce_ini_store (List<LedPatternRX51> list) {
43 var f = FileStream.open ("/etc/mce/mce.ini", "r");
44 var g = FileStream.open ("/tmp/mce.ini", "w");
46 var line = f.read_line ();
47 while (line != null) {
48 if (line == "[LEDPatternLystiRX51]") {
49 g.printf ("%s\n", line);
50 line = f.read_line ();
51 while ((line != null) && (line[0] != '[')) {
52 if (line.has_prefix ("Pattern")) {
53 unowned List<LedPatternRX51> node;
54 for (node = list.first (); node != null; node = node.next) {
55 if (line.has_prefix (node.data.name + "=")) {
56 g.printf ("%s\n", node.data.dump ());
61 g.printf ("%s\n", line);
64 g.printf ("%s\n", line);
66 line = f.read_line ();
69 g.printf ("%s\n", line);
71 g.printf ("%s\n", line);
73 line = f.read_line ();