#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <getopt.h>
};
};
static void
{
if (r < 0)
fputs("ERROR: could not store digest as hexadecimal\n", stderr);
}
static struct entry *
{
struct entry *entry;
};
entry = calloc(1, sizeof(struct entry));
if (!entry)
return NULL;
fprintf(stderr,
"ERROR: could not create message digest for algorithm %s\n",
free(entry);
return NULL;
}
return entry;
}
static void
{
free(entry);
}
static int
{
printf("TODO check stdin\n");
return 0;
}
static bool
{
struct entry *entry = data;
bool is_last = false;
int err;
if (flags & SOL_FD_FLAGS_IN) {
char *
mem = malloc(PATH_MAX);
ssize_t r;
if (!mem) {
fputs("ERROR: cannot allocate memory to read stdin.\n", stderr);
return true;
}
if (!b) {
fputs("ERROR: cannot allocate blob for stdin.\n", stderr);
free(mem);
return true;
}
while ((r = read(fd, mem, PATH_MAX)) < 0) {
if (errno == EINTR)
continue;
fprintf(stderr, "ERROR: cannot read from stdin: %s\n",
r = 0;
break;
}
is_last = !r;
if (err < 0) {
fprintf(stderr, "ERROR: cannot feed message digest: %s\n",
}
}
if (flags & (SOL_FD_FLAGS_ERR | SOL_FD_FLAGS_HUP | SOL_FD_FLAGS_NVAL) && !is_last) {
if (!b) {
fputs("ERROR: cannot allocate blob for stdin.\n", stderr);
return true;
}
is_last = true;
if (err < 0) {
fprintf(stderr, "ERROR: cannot feed message digest: %s\n",
}
}
if (is_last) {
stdin_watch = NULL;
return false;
}
return true;
}
static int
{
int flags;
flags = fcntl(fd, F_GETFL);
if (flags < 0)
return -errno;
flags |= flag;
if (fcntl(fd, F_SETFL, flags) < 0)
return -errno;
return 0;
}
static int
{
struct entry *entry;
int r;
if (stdin_watch)
return 0;
if (!entry)
return -ENOMEM;
if (r < 0)
fputs("WARNING: cannot set stdin to non-blocking.\n", stderr);
stdin_watch = sol_fd_add(STDIN_FILENO,
SOL_FD_FLAGS_IN | SOL_FD_FLAGS_HUP | SOL_FD_FLAGS_ERR,
if (!stdin_watch) {
return -ENOMEM;
}
if (r < 0) {
sol_fd_del(stdin_watch);
stdin_watch = NULL;
return -ENOMEM;
}
return 0;
}
static int
{
printf("TODO check file\n");
return 0;
}
static int
{
struct entry *entry;
int r;
if (!fr)
return -errno;
if (!blob)
return -ENOMEM;
if (!entry) {
return -ENOMEM;
}
if (r < 0) {
return -ENOMEM;
}
return r;
}
static int
{
}
static int
{
}
static void
{
while (1) {
static const struct option opts[] = {
{ "binary", no_argument, NULL, 'b' },
{ "text", no_argument, NULL, 't' },
{ "tag", no_argument, NULL, 'T' },
{ "check", no_argument, NULL, 'c' },
{ "quiet", no_argument, NULL, 'q' },
{ "status", no_argument, NULL, 's' },
{ "strict", no_argument, NULL, 'S' },
{ "warn", no_argument, NULL, 'w' },
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ 0, 0, 0, 0 }
};
int opt_idx = 0, c;
c = getopt_long(argc, argv, "btcw", opts, &opt_idx);
if (c == -1)
break;
switch (c) {
case 'b':
fputs("WARNING: ignored unsupported option -b/--binary.\n", stderr);
break;
case 't':
fputs("WARNING: ignored unsupported option -t/--text.\n", stderr);
break;
case 'T':
fputs("ERROR: unsupported option --tag.\n", stderr);
return;
case 'c':
break;
case 'q':
break;
case 's':
break;
case 'S':
break;
case 'w':
break;
case 'h':
printf(
"Usage:\n"
"\t%s [OPTION]... [FILE]...\n"
"\n"
"With no FILE, or when FILE is -, read standard input.\n"
"\n"
"\t-b, --binary read in binary mode (ignored).\n"
"\t-c, --check read SHA-256 sums from the FILEs and check them\n"
"\t --tag create a BSD-style checksum (not supported).\n"
"\t-t, --text read in text mode (ignored).\n"
"\n"
"The following four options are useful only when verifying checksums:\n"
"\t --quiet don't print OK for each successfully verified file\n"
"\t --status don't output anything, status code shows success\n"
"\t --strict exit non-zero for improperly formatted checksum lines\n"
"\t-w, --warn warn about improperly formatted checksum lines\n"
"\t --version output version information and exit\n"
"\t --help display this help and exit\n"
"\n",
argv[0]);
return;
case 'v':
printf("%s soletta %s\n", argv[0], VERSION);
return;
default:
return;
}
}
if (optind >= argc)
else {
int i;
for (i = optind; i < argc; i++) {
}
}
}
static void
{
struct entry *entry;
uint16_t i;
} else {
}
}
}