aboutsummaryrefslogtreecommitdiffstats
path: root/cputemp2maxfreq.h
diff options
context:
space:
mode:
authorPA4WDH2023-05-21 14:45:18 +0200
committerPA4WDH2023-05-21 14:45:18 +0200
commitf282d50f98c5b26afd69acdafd650a7e8fc570b4 (patch)
tree44de5e4130ac4f5ce937695cd95ebbfc4f126161 /cputemp2maxfreq.h
parentFix all .h files (diff)
downloadcputemp2maxfreq-f282d50f98c5b26afd69acdafd650a7e8fc570b4.tar.gz
cputemp2maxfreq-f282d50f98c5b26afd69acdafd650a7e8fc570b4.tar.bz2
cputemp2maxfreq-f282d50f98c5b26afd69acdafd650a7e8fc570b4.zip
Add argument parsing and validation
Diffstat (limited to 'cputemp2maxfreq.h')
-rw-r--r--cputemp2maxfreq.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/cputemp2maxfreq.h b/cputemp2maxfreq.h
index ef33fd5..39886fd 100644
--- a/cputemp2maxfreq.h
+++ b/cputemp2maxfreq.h
@@ -1,3 +1,22 @@
+#ifndef HAVE_CPUTEMP2MAXFREQ_H
+#define HAVE_CPUTEMP2MAXFREQ_H
+
+// Valid frequencies are between 100MHz and 10GHz
+#define VALID_FREQ_MIN 100000
+#define VALID_FREQ_MAX 10000000
+
+// Valid frequency steps are between 1MHz and 1GHz
+#define VALID_STEP_MIN 1000
+#define VALID_STEP_MAX 1000000
+
+// Valid temperatures are between 10 and 150 degrees
+#define VALID_TEMP_MIN 10000
+#define VALID_TEMP_MAX 150000
+
+// Valid intervals are between 1 and 30
+#define VALID_INTERVAL_MIN 1
+#define VALID_INTERVAL_MAX 30
+
struct s_cpudata {
long int min_freq; // CPU's minimum frequency
long int max_freq; // CPU's maximum frequency
@@ -7,11 +26,12 @@ struct s_cpudata {
};
struct s_config {
- char *governor; // The governor to use
- long int max_temp; // The target temperature
- char *temp_input; // Input file to read the temperature
- long int freq_step; // Step size to increase/decrease CPU frequency
- long int fallback_freq; // CPU frquency to set if we fail to protect hardware
- unsigned int interval; // Time interval to check CPU temperature
+ char governor[255]; // The governor to use
+ long int max_temp; // The target temperature
+ char temp_input[255]; // Input file to read the temperature
+ long int freq_step; // Step size to increase/decrease CPU frequency
+ long int fallback_freq; // CPU frquency to set if we fail to protect hardware
+ unsigned int interval; // Time interval to check CPU temperature
};
+#endif