it sorta works i guess lol
This commit is contained in:
parent
33bb7de0d0
commit
a0cbc30959
1 changed files with 8 additions and 5 deletions
13
fbflut.c
13
fbflut.c
|
@ -37,16 +37,19 @@ void *handle_connection(void *socket_desc) {
|
||||||
int xpos = atoi(safestrtok(NULL, " \n"));
|
int xpos = atoi(safestrtok(NULL, " \n"));
|
||||||
int ypos = atoi(safestrtok(NULL, " \n"));
|
int ypos = atoi(safestrtok(NULL, " \n"));
|
||||||
char colorcode[8];
|
char colorcode[8];
|
||||||
strcpy(colorcode, safestrtok(NULL, " \n"));
|
strncpy(colorcode, safestrtok(NULL, " \n"), 8);
|
||||||
if (strlen(colorcode) < 2*fb_bytes)
|
if (strlen(colorcode) < 2*fb_bytes)
|
||||||
strcat(colorcode, "FF");
|
strcat(colorcode, "00");
|
||||||
int color = (int)strtol(colorcode, NULL, 16);
|
int color = (int)strtol(colorcode, NULL, 16);
|
||||||
|
|
||||||
if (xpos >= 0 && ypos >= 0 && xpos <= fb_width && ypos <= fb_height) {
|
if (xpos >= 0 && ypos >= 0 && xpos <= fb_width && ypos <= fb_height) {
|
||||||
if (color == 0 || 1) {
|
if (color == 0) {
|
||||||
asprintf(&message, "PX %i %i %X\n",xpos,ypos,color);
|
message = calloc(sizeof(char), 36);
|
||||||
|
asprintf(&message, "PX %i %i %X\n",xpos,ypos,fbdata[ypos*fb_width+xpos]);
|
||||||
write(sock, message, strlen(message));
|
write(sock, message, strlen(message));
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
fbdata[ypos*fb_width+xpos] = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -58,7 +61,7 @@ void *handle_connection(void *socket_desc) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp("HELP", command)) {
|
if (!strcmp("HELP", command)) {
|
||||||
message = "HELP\nSIZE\nPX x y [rrggbb[aa]]\n";
|
message = "HELP\nSIZE\nPX x y [color]\n";
|
||||||
write(sock, message, strlen(message));
|
write(sock, message, strlen(message));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue