ubase/dmesg.c
sin 7b228e69b7 Add dmesg(1)
No manpage yet.
2013-08-06 20:58:13 +01:00

39 lines
578 B
C

/* See LICENSE file for copyright and license details. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "ubase.h"
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s\n", argv0);
}
int
main(int argc, char *argv[])
{
int n;
char *buf;
ARGBEGIN {
default:
usage();
} ARGEND;
n = syslog_size();
if (n < 0)
eprintf("syslog_size:");
buf = malloc(n);
if (!buf)
eprintf("malloc:");
n = syslog_read(buf, n);
if (n < 0)
eprintf("syslog_read:");
if (write(STDOUT_FILENO, buf, n) != n)
eprintf("write:");
free(buf);
return 0;
}