diff options
| -rw-r--r-- | DEPENDENCIES | 4 | ||||
| -rw-r--r-- | LICENSE | 2 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | README | 8 | ||||
| -rw-r--r-- | communication.c | 6 | ||||
| -rw-r--r-- | communication.h | 12 | ||||
| -rw-r--r-- | config.mk | 12 | ||||
| -rw-r--r-- | coopgammad.1 | 10 | ||||
| -rw-r--r-- | coopgammad.c | 11 | ||||
| -rw-r--r-- | servers-coopgamma.c | 4 | ||||
| -rw-r--r-- | servers-crtc.c | 2 | ||||
| -rw-r--r-- | servers-crtc.h | 2 | ||||
| -rw-r--r-- | servers-gamma.c | 18 | ||||
| -rw-r--r-- | servers-kernel.c | 11 | ||||
| -rw-r--r-- | state.c | 6 | ||||
| -rw-r--r-- | state.h | 10 | ||||
| -rw-r--r-- | types-output.h | 2 | ||||
| -rw-r--r-- | types-ramps.c | 4 | ||||
| -rw-r--r-- | types-ramps.h | 14 | ||||
| -rw-r--r-- | types-ring.c | 2 | ||||
| -rw-r--r-- | types-ring.h | 2 | ||||
| -rw-r--r-- | util.c | 8 | ||||
| -rw-r--r-- | util.h | 4 |
23 files changed, 81 insertions, 77 deletions
diff --git a/DEPENDENCIES b/DEPENDENCIES index c449ab4..ff47212 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,13 +1,13 @@ RUNTIME DEPENDENCIES: libc - libgamma + libgamma>=0.7.4 BUILD DEPENDENCIES: libc - libgamma + libgamma>=0.7.4 libclut cc make @@ -1,6 +1,6 @@ ISC License -© 2016, 2019 Mattias Andrée <maandree@kth.se> +© 2016, 2019 Mattias Andrée <m@maandree.se> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -20,12 +20,12 @@ PARTS =\ types-message\ types-ring -OBJ = $(PARTS:=.o) coopgammad.c +OBJ = $(PARTS:=.o) coopgammad.o HDR = $(PARTS:=.h) arg.h all: coopgammad -$(OBJ): $(@:.o=.c) $(HDR) +$(OBJ): $(HDR) .c.o: $(CC) -c -o $@ $< $(XCPPFLAGS) $(CPPFLAGS) $(CFLAGS) @@ -23,7 +23,7 @@ OPTIONS -f Don't fork the process to the background. If used, you can still detect when the - process has been initialised be waiting + process has been initialised by waiting for its stdout to close. -k @@ -43,7 +43,7 @@ OPTIONS The adjustment methods are supported via libgamma(7). Only methods that were enabled - when libgamma as compiled will be supported. + when libgamma was compiled will be supported. -p Add the current gamma adjustments to the @@ -59,10 +59,10 @@ OPTIONS the name of the selected site on the second line to stdout. The second line can be omitted if -s has not been used and the default site - cannot be find. + cannot be found. If used at least twice, print the pathname - of the socket for the select method and site + of the socket for the selected method and site combination to stdout. Under unusual circumstances, the path may contain LF characters, but it will always be terminated diff --git a/communication.c b/communication.c index 13d5046..75a6429 100644 --- a/communication.c +++ b/communication.c @@ -14,7 +14,7 @@ * @param conn The index of the connection * @param buf The data to send * @param n The size of `buf` - * @return Zero on success, -1 on error, 1 if disconncted + * @return Zero on success, -1 on error, 1 if disconnected * EINTR, EAGAIN, EWOULDBLOCK, and ECONNRESET count * as success (ECONNRESET cause 1 to be returned), * and are handled appropriately. @@ -110,7 +110,7 @@ proper_fail: * @param message_id The ID of the message to which this message is a response * @param desc The error description to send * @return 1: Client disconnected - * 0: Success (possibily delayed) + * 0: Success (possibly delayed) * -1: An error occurred */ int @@ -139,7 +139,7 @@ int * @param message_id The ID of the message to which this message is a response * @param number The value of `errno`, 0 to indicate success * @return 1: Client disconnected - * 0: Success (possibily delayed) + * 0: Success (possibly delayed) * -1: An error occurred */ int diff --git a/communication.h b/communication.h index b40022b..e2407b7 100644 --- a/communication.h +++ b/communication.h @@ -38,7 +38,7 @@ * * @param ... The error description to send * @return 1: Client disconnected - * 0: Success (possibily delayed) + * 0: Success (possibly delayed) * -1: An error occurred */ #define send_error(...) ((send_error)(conn, message_id, __VA_ARGS__)) @@ -48,7 +48,7 @@ * * @param ... The value of `errno`, 0 to indicate success * @return 1: Client disconnected - * 0: Success (possibily delayed) + * 0: Success (possibly delayed) * -1: An error occurred */ #define send_errno(...) ((send_errno)(conn, message_id, __VA_ARGS__)) @@ -59,7 +59,7 @@ * @param conn The index of the connection * @param buf The data to send * @param n The size of `buf` - * @return Zero on success, -1 on error, 1 if disconncted + * @return Zero on success, -1 on error, 1 if disconnected * EINTR, EAGAIN, EWOULDBLOCK, and ECONNRESET count * as success (ECONNRESET cause 1 to be returned), * and are handled appropriately. @@ -73,7 +73,7 @@ int send_message(size_t conn, char *restrict buf, size_t n); * @param message_id The ID of the message to which this message is a response * @param desc The error description to send * @return 1: Client disconnected - * 0: Success (possibily delayed) + * 0: Success (possibly delayed) * -1: An error occurred */ GCC_ONLY(__attribute__((__nonnull__))) @@ -86,7 +86,7 @@ int (send_error)(size_t conn, const char *restrict message_id, const char *restr * @param message_id The ID of the message to which this message is a response * @param number The value of `errno`, 0 to indicate success * @return 1: Client disconnected - * 0: Success (possibily delayed) + * 0: Success (possibly delayed) * -1: An error occurred */ GCC_ONLY(__attribute__((__nonnull__))) @@ -96,7 +96,7 @@ int (send_errno)(size_t conn, const char *restrict message_id, int number); * Continue sending the queued messages * * @param conn The index of the connection - * @return Zero on success, -1 on error, 1 if disconncted + * @return Zero on success, -1 on error, 1 if disconnected * EINTR, EAGAIN, EWOULDBLOCK, and ECONNRESET count * as success (ECONNRESET cause 1 to be returned), * and are handled appropriately. @@ -1,12 +1,14 @@ PREFIX = /usr MANPREFIX = $(PREFIX)/share/man -# For class of preserved clut +# For class of preserved CLUT PKGNAME = coopgammad COMMAND = coopgammad -CC=cc +# The makefile uses $(CC) and therefore expects it to be a single command name. +# If you need a specific language mode, set it via CFLAGS. +CC = cc -std=c11 -CPPFLAGS = -D_XOPEN_SOURCE=700 -D_GNU_SOURCE -DUSE_VALGRIND -CFLAGS = -std=c11 -Wall -Og -LDFLAGS = -lgamma -s +CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -DUSE_VALGRIND +CFLAGS = -Wall +LDFLAGS = -lgamma diff --git a/coopgammad.1 b/coopgammad.1 index b8166b5..b20c6f6 100644 --- a/coopgammad.1 +++ b/coopgammad.1 @@ -1,7 +1,7 @@ .TH COOPGAMMAD 1 COOPGAMMAD .SH "NAME" coopgammad - Cooperative gamma server -.SH "SYNPOSIS" +.SH "SYNOPSIS" .B coopgammad .RB [ -m .IR method ] @@ -30,7 +30,7 @@ modified or removed later by another process. .B -f Don't fork the process to the background. If used, you can still detect when the -process has been initialised be waiting +process has been initialised by waiting for its stdout to close. .TP .B -k @@ -55,7 +55,7 @@ The adjustment methods are supported via .BR libgamma (7). Only methods that were enabled when .B libgamma -as compiled will be supported. +was compiled will be supported. .TP .B -p Add the current gamma adjustments to the @@ -73,10 +73,10 @@ line to stdout. The second line can be omitted if .B -s has not been used and the default site cannot -be find. +be found. If used at least twice, print the pathname -of the socket for the select method and site +of the socket for the selected method and site combination to stdout. Under unusual circumstances, the path may contain LF characters, but it will always be terminated diff --git a/coopgammad.c b/coopgammad.c index 50ba53b..3f4eb78 100644 --- a/coopgammad.c +++ b/coopgammad.c @@ -37,7 +37,7 @@ /** * Lists all function recognised adjustment methods, - * will call macro X with the code for the each + * will call macro X with the code for each * adjustment method as the first argument and * corresponding name as the second argument */ @@ -166,7 +166,7 @@ GCC_ONLY(__attribute__((__nonnull__))) static int get_method(const char *restrict arg) { -#if LIBGAMMA_METHOD_MAX > 5 +#if LIBGAMMA_METHOD_COUNT > 6 # warning libgamma has added more adjustment methods #endif @@ -278,7 +278,7 @@ daemonise(int keep_stderr) fd = open(pidpath, O_WRONLY); if (fd < 0) goto fail; - if (dprintf(fd, "%llu\n", (unsigned long long)getpid()) < 0) + if (dprintf(fd, "%llu\n", (unsigned long long int)getpid()) < 0) goto fail; close(fd); fd = -1; @@ -664,6 +664,7 @@ static int print_method_and_site(int query) { const char *restrict methodname = NULL; + const char *const_sitename; char *p; if (query == 1) { @@ -682,8 +683,8 @@ print_method_and_site(int query) } if (!sitename) - if ((sitename = libgamma_method_default_site(method))) - if (!(sitename = memdup(sitename, strlen(sitename) + 1))) + if ((const_sitename = libgamma_method_default_site(method))) + if (!(sitename = memdup(const_sitename, strlen(const_sitename) + 1))) return -1; if (sitename) { diff --git a/servers-coopgamma.c b/servers-coopgamma.c index f14c0c4..42cd783 100644 --- a/servers-coopgamma.c +++ b/servers-coopgamma.c @@ -6,13 +6,13 @@ #include "util.h" #include "types-output.h" -#include <libclut.h> - #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <libclut.h> + /** * Apply a filter on top of another filter diff --git a/servers-crtc.c b/servers-crtc.c index 24018e1..9171586 100644 --- a/servers-crtc.c +++ b/servers-crtc.c @@ -53,7 +53,7 @@ handle_enumerate_crtcs(size_t conn, const char *restrict message_id) * @return The name of the CRTC, `NULL` on error */ char * -get_crtc_name(const libgamma_crtc_information_t *restrict info, const libgamma_crtc_state_t *restrict crtc) +get_crtc_name(const struct libgamma_crtc_information *restrict info, const struct libgamma_crtc_state *restrict crtc) { char *name; if (!info->edid_error && info->edid) { diff --git a/servers-crtc.h b/servers-crtc.h index 08e4b02..64606b2 100644 --- a/servers-crtc.h +++ b/servers-crtc.h @@ -33,7 +33,7 @@ int handle_enumerate_crtcs(size_t conn, const char *restrict message_id); * @return The name of the CRTC, `NULL` on error */ GCC_ONLY(__attribute__((__nonnull__))) -char *get_crtc_name(const libgamma_crtc_information_t *restrict info, const libgamma_crtc_state_t *restrict crtc); +char *get_crtc_name(const struct libgamma_crtc_information *restrict info, const struct libgamma_crtc_state *restrict crtc); /** * Initialise the site diff --git a/servers-gamma.c b/servers-gamma.c index 8907e8f..3b480b3 100644 --- a/servers-gamma.c +++ b/servers-gamma.c @@ -120,12 +120,12 @@ set_gamma(const struct output *restrict output, const union gamma_ramps *restric return; switch (output->depth) { - case 8: r = libgamma_crtc_set_gamma_ramps8(output->crtc, ramps->u8); break; - case 16: r = libgamma_crtc_set_gamma_ramps16(output->crtc, ramps->u16); break; - case 32: r = libgamma_crtc_set_gamma_ramps32(output->crtc, ramps->u32); break; - case 64: r = libgamma_crtc_set_gamma_ramps64(output->crtc, ramps->u64); break; - case -1: r = libgamma_crtc_set_gamma_rampsf(output->crtc, ramps->f); break; - case -2: r = libgamma_crtc_set_gamma_rampsd(output->crtc, ramps->d); break; + case 8: r = libgamma_crtc_set_gamma_ramps8(output->crtc, &ramps->u8); break; + case 16: r = libgamma_crtc_set_gamma_ramps16(output->crtc, &ramps->u16); break; + case 32: r = libgamma_crtc_set_gamma_ramps32(output->crtc, &ramps->u32); break; + case 64: r = libgamma_crtc_set_gamma_ramps64(output->crtc, &ramps->u64); break; + case -1: r = libgamma_crtc_set_gamma_rampsf(output->crtc, &ramps->f); break; + case -2: r = libgamma_crtc_set_gamma_rampsd(output->crtc, &ramps->d); break; default: abort(); } @@ -224,12 +224,12 @@ parse_edid(struct output *restrict output, const unsigned char *restrict edid, s int initialise_gamma_info(void) { - libgamma_crtc_information_t info; + struct libgamma_crtc_information info; int saved_errno; size_t i; for (i = 0; i < outputs_n; i++) { - libgamma_get_crtc_information(&info, crtcs + i, + libgamma_get_crtc_information(&info, sizeof(info), &crtcs[i], LIBGAMMA_CRTC_INFO_EDID | LIBGAMMA_CRTC_INFO_MACRO_RAMP | LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT | @@ -334,7 +334,7 @@ restore_gamma(void) #define RESTORE_RAMPS(SUFFIX, MEMBER)\ do {\ if (outputs[i].saved_ramps.MEMBER.red) {\ - gerror = libgamma_crtc_set_gamma_ramps##SUFFIX(outputs[i].crtc, outputs[i].saved_ramps.MEMBER);\ + gerror = libgamma_crtc_set_gamma_ramps##SUFFIX(outputs[i].crtc, &outputs[i].saved_ramps.MEMBER);\ if (gerror)\ libgamma_perror(argv0, gerror);\ }\ diff --git a/servers-kernel.c b/servers-kernel.c index fd60aef..a5e3871 100644 --- a/servers-kernel.c +++ b/servers-kernel.c @@ -3,8 +3,6 @@ #include "state.h" #include "util.h" -#include <libgamma.h> - #include <sys/socket.h> #include <sys/stat.h> #include <sys/un.h> @@ -16,6 +14,8 @@ #include <string.h> #include <unistd.h> +#include <libgamma.h> + /** * Get the pathname of the runtime file @@ -29,6 +29,7 @@ get_pathname(const char *restrict suffix) { const char *restrict rundir = getenv("XDG_RUNTIME_DIR"); const char *restrict username = ""; + const char *const_name; char *name = NULL; char *p; char *restrict rc; @@ -39,8 +40,8 @@ get_pathname(const char *restrict suffix) name = memdup(sitename, strlen(sitename) + 1); if (!name) goto fail; - } else if ((name = libgamma_method_default_site(method))) { - name = memdup(name, strlen(name) + 1); + } else if ((const_name = libgamma_method_default_site(method))) { + name = memdup(const_name, strlen(const_name) + 1); if (!name) goto fail; } @@ -176,7 +177,7 @@ retry: goto bad; if ((size_t)(p - content) != n) goto bad; - sprintf(temp, "%llu\n", (unsigned long long)pid); + sprintf(temp, "%llu\n", (unsigned long long int)pid); if (strcmp(content, temp)) goto bad; free(content); @@ -107,17 +107,17 @@ char *restrict sitename = NULL; /** * The libgamma site state */ -libgamma_site_state_t site; /* do not marshal */ +struct libgamma_site_state site; /* do not marshal */ /** * The libgamma partition states */ -libgamma_partition_state_t *restrict partitions = NULL; /* do not marshal */ +struct libgamma_partition_state *restrict partitions = NULL; /* do not marshal */ /** * The libgamma CRTC states */ -libgamma_crtc_state_t *restrict crtcs = NULL; /* do not marshal */ +struct libgamma_crtc_state *restrict crtcs = NULL; /* do not marshal */ /** * Preserve gamma ramps at priority 0? @@ -6,11 +6,11 @@ #include "types-ring.h" #include "types-output.h" -#include <libgamma.h> - #include <stddef.h> #include <signal.h> +#include <libgamma.h> + #ifndef GCC_ONLY # if defined(__GNUC__) && !defined(__clang__) # define GCC_ONLY(...) __VA_ARGS__ @@ -118,17 +118,17 @@ extern char *restrict sitename; /** * The libgamma site state */ -extern libgamma_site_state_t site; +extern struct libgamma_site_state site; /** * The libgamma partition states */ -extern libgamma_partition_state_t *restrict partitions; +extern struct libgamma_partition_state *restrict partitions; /** * The libgamma CRTC states */ -extern libgamma_crtc_state_t *restrict crtcs; +extern struct libgamma_crtc_state *restrict crtcs; /** * Preserve gamma ramps at priority 0? diff --git a/types-output.h b/types-output.h index ca5bf61..17890a0 100644 --- a/types-output.h +++ b/types-output.h @@ -184,7 +184,7 @@ struct output { /** * The libgamma state for the output */ - libgamma_crtc_state_t *restrict crtc; + struct libgamma_crtc_state *restrict crtc; /** * Saved gamma ramps diff --git a/types-ramps.c b/types-ramps.c index a80f66b..87a3012 100644 --- a/types-ramps.c +++ b/types-ramps.c @@ -1,12 +1,12 @@ /* See LICENSE file for copyright and license details. */ #include "types-ramps.h" -#include <libclut.h> - #include <errno.h> #include <stdlib.h> #include <string.h> +#include <libclut.h> + /** * The name of the process diff --git a/types-ramps.h b/types-ramps.h index e8e6956..b0b1992 100644 --- a/types-ramps.h +++ b/types-ramps.h @@ -14,38 +14,38 @@ /** * Gamma ramps union for all - * lbigamma gamma ramps types + * libgamma gamma ramps types */ union gamma_ramps { /** * Ramps with 8-bit value */ - libgamma_gamma_ramps8_t u8; + struct libgamma_gamma_ramps8 u8; /** * Ramps with 16-bit value */ - libgamma_gamma_ramps16_t u16; + struct libgamma_gamma_ramps16 u16; /** * Ramps with 32-bit value */ - libgamma_gamma_ramps32_t u32; + struct libgamma_gamma_ramps32 u32; /** * Ramps with 64-bit value */ - libgamma_gamma_ramps64_t u64; + struct libgamma_gamma_ramps64 u64; /** * Ramps with `float` value */ - libgamma_gamma_rampsf_t f; + struct libgamma_gamma_rampsf f; /** * Ramps with `double` value */ - libgamma_gamma_rampsd_t d; + struct libgamma_gamma_rampsd d; }; /** diff --git a/types-ring.c b/types-ring.c index 6cceea1..15e52d6 100644 --- a/types-ring.c +++ b/types-ring.c @@ -173,7 +173,7 @@ ring_peek(struct ring *restrict this, size_t *restrict n) /** - * Dequeue data from a ring bubber + * Dequeue data from a ring buffer * * @param this The ring buffer * @param n The number of bytes to dequeue diff --git a/types-ring.h b/types-ring.h index c8b5f77..0a022ee 100644 --- a/types-ring.h +++ b/types-ring.h @@ -94,7 +94,7 @@ GCC_ONLY(__attribute__((__nonnull__))) void *ring_peek(struct ring *restrict this, size_t *restrict n); /** - * Dequeue data from a ring bubber + * Dequeue data from a ring buffer * * @param this The ring buffer * @param n The number of bytes to dequeue @@ -1,8 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "util.h" -#include <libclut.h> - #include <sys/stat.h> #include <errno.h> #include <fcntl.h> @@ -11,6 +9,8 @@ #include <time.h> #include <unistd.h> +#include <libclut.h> + /** * Duplicate a memory segment @@ -92,7 +92,7 @@ fail: * Not cancelled by `EINTR` * * @param fd The file descriptor - * @param buf The buffer which shall be written to the fail + * @param buf The buffer which shall be written to the file * @param n The size of the buffer * @return The number of written bytes, less than `n` * on error, cannot exceed `n` @@ -119,7 +119,7 @@ nwrite(int fd, const void *restrict buf, size_t n) /** - * Perform a timed suspention of the process. + * Perform a timed suspension of the process. * The process resumes when the timer expires, * or when it is interrupted. * @@ -42,7 +42,7 @@ void *nread(int fd, size_t *restrict n); * Not cancelled by `EINTR` * * @param fd The file descriptor - * @param buf The buffer which shall be written to the fail + * @param buf The buffer which shall be written to the file * @param n The size of the buffer * @return The number of written bytes, less than `n` * on error, cannot exceed `n` @@ -50,7 +50,7 @@ void *nread(int fd, size_t *restrict n); size_t nwrite(int fd, const void *restrict buf, size_t n); /** - * Perform a timed suspention of the process. + * Perform a timed suspension of the process. * The process resumes when the timer expires, * or when it is interrupted. * |
