|
Packit Service |
50ad14 |
#include "config.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
#include <stdio.h>
|
|
Packit Service |
50ad14 |
#include <stdlib.h>
|
|
Packit Service |
50ad14 |
#include <errno.h>
|
|
Packit Service |
50ad14 |
#include <sys/ioctl.h>
|
|
Packit Service |
50ad14 |
#include <linux/kd.h>
|
|
Packit Service |
50ad14 |
#include "getfd.h"
|
|
Packit Service |
50ad14 |
#include "version.h"
|
|
Packit Service |
50ad14 |
#include "kbd_error.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
int main(int argc, char **argv)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
int fd, indx, red, green, blue;
|
|
Packit Service |
50ad14 |
unsigned char cmap[48];
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
set_progname(argv[0]);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (argc != 5) {
|
|
Packit Service |
50ad14 |
fprintf(stderr, "usage: %s index red green blue\n", progname);
|
|
Packit Service |
50ad14 |
exit(EXIT_FAILURE);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
indx = atoi(argv[1]);
|
|
Packit Service |
50ad14 |
red = atoi(argv[2]);
|
|
Packit Service |
50ad14 |
green = atoi(argv[3]);
|
|
Packit Service |
50ad14 |
blue = atoi(argv[4]);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (indx < 0 || red < 0 || green < 0 || blue < 0 ||
|
|
Packit Service |
50ad14 |
indx > 15 || red > 255 || green > 255 || blue > 255) {
|
|
Packit Service |
50ad14 |
fprintf(stderr, "indx must be in 0..15, colors in 0..255\n");
|
|
Packit Service |
50ad14 |
exit(EXIT_FAILURE);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if ((fd = getfd(NULL)) < 0)
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (ioctl(fd, GIO_CMAP, cmap))
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, errno, "ioctl GIO_CMAP");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
cmap[3 * indx] = red;
|
|
Packit Service |
50ad14 |
cmap[3 * indx + 1] = green;
|
|
Packit Service |
50ad14 |
cmap[3 * indx + 2] = blue;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (ioctl(fd, PIO_CMAP, cmap))
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, errno, "ioctl PIO_CMAP");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
return EXIT_SUCCESS;
|
|
Packit Service |
50ad14 |
}
|