aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/blackbody.c13
-rw-r--r--src/libred.h5
2 files changed, 12 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)
diff --git a/src/libred.h b/src/libred.h
index 83554e8..23075e2 100644
--- a/src/libred.h
+++ b/src/libred.h
@@ -124,6 +124,11 @@ int libred_check_timetravel(void);
#define LIBRED_DELTA_TEMPERATURE 100
+/**
+ * The file descriptor to the colour lookup table.
+ */
+extern int libred_fd;
+
/**
* This function must be called, once,