aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2016-07-15 14:14:49 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2016-07-15 14:14:49 +1200
commitdcdd25f7767fb06012b009ab19334f64a9f65431 (patch)
tree9189b0a57db89173769ac887c0f96e0ecce21936
parent09de14168c9c5b406a738116ab656f6e12a3fb30 (diff)
downloadbrightnessd-dcdd25f7767fb06012b009ab19334f64a9f65431.tar.xz
More general tidying
-rw-r--r--brightnessd.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/brightnessd.c b/brightnessd.c
index 893caad..da16644 100644
--- a/brightnessd.c
+++ b/brightnessd.c
@@ -13,19 +13,18 @@
#define STEP 1
#define BIG_STEP 10
+int get_now()
+{
+ char buffer[4096]; // FIXME: magic constant is icky
+ // FIXME: check return value for eror
+ fgets(buffer, sizeof(buffer), f);
-void get_now();
-
-/****************************************************************
- * Write something useful here for once
- */
-int target; // int because overflow checky checky woo yay blah
-int now;
-FILE *f;
+ return atoi(buffer);
+}
int brightness_within_bounds(int bright, int lower, int upper)
{
- // to do: make a horrible but funny ternary statement
+ // FIXME: make a horrible but funny ternary statement
if (bright < lower)
return lower;
@@ -37,6 +36,9 @@ int brightness_within_bounds(int bright, int lower, int upper)
int main(int argc, char **argv)
{
+ int target = 0;
+ int now = 0;
+ FILE *f = NULL;
char buffer[4]; /* size 4 because max bright is 255, plus null terminator */
// Open brightness file
@@ -46,13 +48,12 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- get_now();
+ now = get_now();
target = now;
// Open a FIFO
remove(FIFO_PATH);
mkfifo(FIFO_PATH, 0666);
- chmod(FIFO_PATH, 0666);
// FIXME : check return val
int fifo = open(FIFO_PATH, O_RDWR);
@@ -106,11 +107,3 @@ int main(int argc, char **argv)
}
-void get_now()
-{
- char buffer[4096]; // to do: magic constant is icky
- // to do check return value for eror
- fgets(buffer, sizeof(buffer), f);
-
- now = atoi(buffer);
-}