check if color specified before conversion to hex
this allows black to be written instead of returning the pixel value
This commit is contained in:
parent
6b62d31dc5
commit
d3e9803cf2
1 changed files with 4 additions and 4 deletions
8
fbflut.c
8
fbflut.c
|
@ -40,17 +40,17 @@ void *handle_connection(void *socket_desc) {
|
|||
int ypos = atoi(safestrtok(NULL, " \n"));
|
||||
char colorcode[8];
|
||||
strncpy(colorcode, safestrtok(NULL, " \n"), 8);
|
||||
//if (strlen(colorcode) < 2*fb_bytes)
|
||||
// strcat(colorcode, "00");
|
||||
int color = (int)strtol(colorcode, NULL, 16);
|
||||
|
||||
if (xpos >= 0 && ypos >= 0 && xpos < fb_width && ypos < fb_height) {
|
||||
if (color == 0) {
|
||||
if (strlen(colorcode) == 0) {
|
||||
message = calloc(sizeof(char), 36);
|
||||
asprintf(&message, "PX %i %i %X\n",xpos,ypos,fbdata[ypos*fb_length+xpos]);
|
||||
write(sock, message, strlen(message));
|
||||
continue;
|
||||
} else {
|
||||
//if (strlen(colorcode) < 2*fb_bytes)
|
||||
// strcat(colorcode, "00");
|
||||
int color = (int)strtol(colorcode, NULL, 16);
|
||||
fbdata[ypos*fb_length+xpos] = color;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue