diff options
Diffstat (limited to '')
-rw-r--r-- | doc/info/mds.texinfo | 11 | ||||
-rw-r--r-- | src/mds-colour.c | 57 |
2 files changed, 64 insertions, 4 deletions
diff --git a/doc/info/mds.texinfo b/doc/info/mds.texinfo index 7db4af0..719bf02 100644 --- a/doc/info/mds.texinfo +++ b/doc/info/mds.texinfo @@ -3086,7 +3086,8 @@ header @code{Error}. @item Message: Description of the error, single line, mid-sentence case, no punctuation in the end, must not be a -question but rather it must be a statement. +question but rather it must be a statement. The +message shall end with a line feed. @item Purpose: Enable keyboard layout servers to automatically set @@ -5073,7 +5074,8 @@ each of these values will be suffixed with a single regular blank space making the format @code{bytes red green blue name}. Note that the name may contain any whitespace@footnote{Tab space is discouraged.} -except a line feed. +except a line feed. Allowed values for the byte count +are 1, 2, 4 and 8. The payload will end with a line break unless it is empty. No empty lines will otherwise be included @@ -5130,6 +5132,7 @@ message contain the headers: @table @code @item Bytes The number of bytes with which each channel is encoded. +Allowed values are 1, 2, 4 and 8. @item Red The value of the red channel. @item Green @@ -5137,6 +5140,9 @@ The value of the green channel. @item Blue The value of the blue channel. @end table +If the colour is not defined, the @code{Command: error} +message will return a custom error, with the message +``not defined''. @item Purpose: @cpindex Toolkits, colours @@ -5195,6 +5201,7 @@ Add or modify colour definition. @item Conditionally required header: @code{Bytes} The number of bytes with which each channel is encoded. +Allowed values are 1, 2, 4 and 8. Required unless @code{Remove: yes} is included in the headers. @item Conditionally required header: @code{Red} diff --git a/src/mds-colour.c b/src/mds-colour.c index 489137e..b49348b 100644 --- a/src/mds-colour.c +++ b/src/mds-colour.c @@ -351,6 +351,20 @@ int handle_message(void) int handle_list_colours(const char* recv_client_id, const char* recv_message_id, const char* recv_include_values) { + int include_values = 0; + + if (strequals(recv_client_id, "0:0")) + return eprint("got a query from an anonymous client, ignoring."), 0; + + if (recv_include_values == NULL) remove_include_values = 0; + else if (strequals(recv_include_values, "yes")) remove_include_values = 1; + else if (strequals(recv_include_values, "no")) remove_include_values = 0; + else + ; /* TODO send EPROTO*/ + + /* TODO send list */ + + return 0; } @@ -365,6 +379,15 @@ int handle_list_colours(const char* recv_client_id, const char* recv_message_id, */ int handle_get_colour(const char* recv_client_id, const char* recv_message_id, const char* recv_name) { + if (strequals(recv_client_id, "0:0")) + return eprint("got a query from an anonymous client, ignoring."), 0; + + if (recv_name == NULL) + ; /* TODO send EPROTO */ + + /* TODO send colour, "not defined" if missing */ + + return 0; } @@ -383,15 +406,45 @@ int handle_get_colour(const char* recv_client_id, const char* recv_message_id, c int handle_set_colour(const char* recv_name, const char* recv_remove, const char* recv_bytes, const char* recv_red, const char* recv_green, const char* recv_blue) { + uint64_t limit = UINT64_MAX; int remove_colour = 0; + int bytes; + uint64_t red, green, blue; if (recv_remove == NULL) remove_colour = 0; else if (strequals(recv_remove, "yes")) remove_colour = 1; else if (strequals(recv_remove, "no")) remove_colour = 0; else + return eprint("got an invalid value on the Remove-header, ignoring."), 0; + + if (recv_name == NULL) + return eprint("did not get all required headers, ignoring."), 0; + + if (remove_colour == 0) { - eprint("got an invalid value on the Remove-header, ignoring."); - return 0; + if ((recv_bytes == NULL) || (recv_red == NULL) || (recv_green == NULL) || (recv_blue == NULL)) + return eprint("did not get all required headers, ignoring."), 0; + + if (strict_atoi(recv_bytes, &bytes, 1, 8)) + return eprint("got an invalid value on the Bytes-header, ignoring."), 0; + if ((bytes != 1) && (bytes != 2) && (bytes != 4) && (bytes != 8)) + return eprint("got an invalid value on the Bytes-header, ignoring."), 0; + + if (bytes < 8) + limit = (((uint64)1) << (bytes * 8)) - 1; + + if (strict_atou64(recv_red, &red, 0, limit)) + return eprint("got an invalid value on the Red-header, ignoring."), 0; + if (strict_atou64(recv_green, &green, 0, limit)) + return eprint("got an invalid value on the Green-header, ignoring."), 0; + if (strict_atou64(recv_blue, &blue, 0, limit)) + return eprint("got an invalid value on the Blue-header, ignoring."), 0; + + /* TOOD set colour */ + } + else + { + /* TODO remove colour */ } return 0; |