From 950bea118fe6de45f170d8b13cd08cc46435e5a7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 4 Jan 2016 21:29:46 +0100 Subject: make the file descriptor visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blackbody.c | 13 +++++++------ src/libred.h | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src') 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 + /** * 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, -- cgit v1.2.3-70-g09d2