projects
/
breezed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Small hack to handle temperature values in 1000th of degree.
[breezed.git]
/
breezed.cc
diff --git
a/breezed.cc
b/breezed.cc
index
78dd2b5
..
ae61293
100644
(file)
--- a/
breezed.cc
+++ b/
breezed.cc
@@
-3,7
+3,7
@@
breezed is a fan speed control daemon for Linux computers.
breezed is a fan speed control daemon for Linux computers.
- Copyright (c) 2008 Francois Fleuret
+ Copyright (c) 2008
, 2009
Francois Fleuret
Written by Francois Fleuret <francois@fleuret.org>
This file is part of breezed.
Written by Francois Fleuret <francois@fleuret.org>
This file is part of breezed.
@@
-37,11
+37,11
@@
using namespace std;
const int major_version_number = 1;
using namespace std;
const int major_version_number = 1;
-const int minor_version_number =
1
;
+const int minor_version_number =
2
;
const int buffer_size = 1024;
const int buffer_size = 1024;
-const char *default_confguration_file = "/etc/breezed.conf";
+const char *default_conf
i
guration_file = "/etc/breezed.conf";
// The time period to check the temperature.
const int polling_delay = 5;
// The time period to check the temperature.
const int polling_delay = 5;
@@
-61,7
+61,7
@@
int last_level = -1;
int file_fan_fd;
int file_fan_fd;
-int nb_temperature_thresholds
= 0
;
+int nb_temperature_thresholds;
int *temperature_thresholds = 0;
int nb_file_thermal = 0;
int *temperature_thresholds = 0;
int nb_file_thermal = 0;
@@
-148,6
+148,8
@@
void define_temperature_thresholds(char *definition) {
exit(1);
}
exit(1);
}
+ nb_temperature_thresholds = 1;
+
char *s;
s = definition;
while(s) {
char *s;
s = definition;
while(s) {
@@
-157,8
+159,10
@@
void define_temperature_thresholds(char *definition) {
temperature_thresholds = new int[nb_temperature_thresholds];
temperature_thresholds = new int[nb_temperature_thresholds];
+ temperature_thresholds[0] = -1;
+
s = definition;
s = definition;
- int k =
0
;
+ int k =
1
;
while(s) {
s = next_word(token, s, buffer_size);
temperature_thresholds[k] = atoi(token);
while(s) {
s = next_word(token, s, buffer_size);
temperature_thresholds[k] = atoi(token);
@@
-170,8
+174,6
@@
void define_temperature_thresholds(char *definition) {
}
k++;
}
}
k++;
}
-
- temperature_thresholds[0] = -1;
}
//////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////
@@
-180,8
+182,8
@@
int main(int argc, char **argv) {
char buffer[buffer_size], token[buffer_size];
char buffer[buffer_size], token[buffer_size];
- configuration_file = new char[strlen(default_confguration_file) + 1];
- strcpy(configuration_file, default_confguration_file);
+ configuration_file = new char[strlen(default_conf
i
guration_file) + 1];
+ strcpy(configuration_file, default_conf
i
guration_file);
int i = 1;
while(i < argc) {
int i = 1;
while(i < argc) {
@@
-319,6
+321,7
@@
Written by Francois Fleuret (francois@fleuret.org).\n";
if(configuration_file) {
ifstream cf(configuration_file);
if(configuration_file) {
ifstream cf(configuration_file);
+
if(cf.fail()) {
cerr << "Can not open " << configuration_file << " for reading." << endl;
exit(1);
if(cf.fail()) {
cerr << "Can not open " << configuration_file << " for reading." << endl;
exit(1);
@@
-468,6
+471,10
@@
Written by Francois Fleuret (francois@fleuret.org).\n";
cout << " " << t;
}
cout << " " << t;
}
+ // So that we can deal with the new files where the
+ // temperature are in 1/1000th of C
+ if(t > 1000) t /= 1000;
+
if(t > temperature) temperature = t;
}
}
if(t > temperature) temperature = t;
}
}