aboutsummaryrefslogtreecommitdiffstats
path: root/src/blackbody.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-04 21:29:46 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-04 21:29:46 +0100
commit950bea118fe6de45f170d8b13cd08cc46435e5a7 (patch)
tree6c69a4df5a59a570480f0bb075e81c1c50ce26eb /src/blackbody.c
parentdedup ciexyy_to_srgb (diff)
downloadlibred-950bea118fe6de45f170d8b13cd08cc46435e5a7.tar.gz
libred-950bea118fe6de45f170d8b13cd08cc46435e5a7.tar.bz2
libred-950bea118fe6de45f170d8b13cd08cc46435e5a7.tar.xz
make the file descriptor visible
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r--src/blackbody.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/blackbody.c b/src/blackbody.c
index 70b58db..92597ae 100644
--- a/src/blackbody.c
+++ b/src/blackbody.c
@@ -22,10 +22,11 @@
#include <fcntl.h>
+
/**
* The file descriptor to the colour lookup table.
*/
-static int fd = -1;
+int libred_fd = -1;
@@ -40,8 +41,8 @@ static int fd = -1;
int libred_init_colour(void)
{
libred_term_colour();
- fd = open(SYSDEPRESDIR "/" PACKAGE "/10deg", O_RDONLY);
- return fd < 0 ? -1 : 0;
+ libred_fd = open(SYSDEPRESDIR "/" PACKAGE "/10deg", O_RDONLY);
+ return libred_fd < 0 ? -1 : 0;
}
@@ -51,8 +52,8 @@ int libred_init_colour(void)
*/
void libred_term_colour(void)
{
- if (fd >= 0)
- close(fd), fd = -1;
+ if (libred_fd >= 0)
+ close(libred_fd), libred_fd = -1;
}
@@ -142,7 +143,7 @@ int libred_get_colour(long int temp, double *r, double *g, double *b)
/* Read table. */
offset = ((off_t)temp - LIBRED_LOWEST_TEMPERATURE) / LIBRED_DELTA_TEMPERATURE;
offset *= (off_t)(sizeof(values) / 2);
- errno = 0; xpread(fd, values, sizeof(values), offset);
+ errno = 0; xpread(libred_fd, values, sizeof(values), offset);
/* Get colour. */
if (temp % LIBRED_DELTA_TEMPERATURE)