#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
static int
{
int i;
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "led-pin=", sizeof("led-pin=") - 1)) {
const char *
value = argv[i] +
sizeof(
"led-pin=") - 1;
int pin = -1;
if (sscanf(value, "%d", &pin) == 1) {
if (pin > -1)
return pin;
}
}
}
return -1;
}
static int
{
const char prefix[] = "soletta.led-pin=";
const size_t prefixlen = sizeof("soletta.led-pin=") - 1;
char *tmp;
int pin = -1;
if (len <= prefixlen)
return -1;
if (memcmp(start, prefix, prefixlen) != 0)
return -1;
start += prefixlen;
len -= prefixlen;
tmp = strndupa(start, len);
if (sscanf(tmp, "%d", &pin) == 1) {
if (pin > -1)
return pin;
}
return -1;
}
static int
{
char buf[4096] = {};
const char *p, *start, *end;
int err, pin = -1;
if (err < 1)
return err;
start = buf;
end = start + strlen(buf);
for (p = start; pin < 0 && p < end; p++) {
if (isblank(*p) && start < p) {
start = p + 1;
}
}
if (pin < 0 && start < end)
return pin;
}
"console",
"hostname",
"network-up",
"sysctl",
"watchdog",
NULL
};
static bool
{
puts("soletta is ticking!");
if (gpio) {
}
return true;
}
static void
{
printf("platform state changed to: %d\n", state);
}
static void
{
printf("service %s state changed to: %d\n", service, state);
}
static void
{
const char **itr;
if (pin < 0)
if (pin >= 0) {
};
if (gpio)
printf("blinking led on gpio pin=%d\n", pin);
else
fprintf(stderr, "failed to open gpio pin=%d for writing.\n", pin);
}
for (itr = services; *itr != NULL; itr++) {
printf("service %s state: %d\n",
}
}
static void
{
const char **itr;
if (gpio)
for (itr = services; *itr != NULL; itr++)
}