#include <errno.h>
#include <fcntl.h>
#include <linux/kd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
static bool
{
if (ioctl(
console_fd, KDGETLED, (
char *)&value)) {
perror("Could not get led state");
return false;
}
return value & LED_SCR;
}
static bool
{
char old;
printf("setting LED to %s\n", on ? "true" : "false");
return true;
}
perror("Could not get led state");
return false;
}
if (ioctl(
console_fd, KDSETLED, on ? (old | LED_SCR) : (old & ~LED_SCR))) {
perror("Could not set led state");
return false;
}
return true;
}
static int
{
int r;
error:
if (response)
}
static int
{
else
goto end;
}
}
end:
}
const char *resource_type)
{
.get = {
.handle = handle_get
},
.put = {
.handle = handle_put
}
};
}
int
main(
int argc,
char *argv[])
{
char old_led_state;
const char *resource_type = "core.light";
if (argc < 2) {
printf("No resource type specified, assuming core.light\n");
} else {
printf("Resource type specified: %s\n", argv[1]);
resource_type = argv[1];
}
resource_type);
if (!res) {
SOL_WRN(
"Could not register light resource type.");
return -1;
}
SOL_WRN(
"Could not open '/dev/console', printing to stdout");
}
else if (ioctl(
console_fd, KDGETLED, (
char *)&old_led_state)) {
SOL_ERR(
"Could not get the keyboard leds state");
return -1;
}
SOL_ERR(
"Could not return the leds to the old state");
return -1;
}
return 0;
}