* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
* i3-dump-log/main.c: Dumps the i3 SHM log to stdout.
*
#include <i3/ipc.h>
static uint32_t offset_next_write,
- wrap_count;
+ wrap_count;
static i3_shmlog_header *header;
static char *logbuffer,
- *walk;
+ *walk;
static int check_for_wrap(void) {
if (wrap_count == header->wrap_count)
* of the log. */
wrap_count = header->wrap_count;
const int len = (logbuffer + header->offset_last_wrap) - walk;
- if (write(STDOUT_FILENO, walk, len) != len)
- err(EXIT_FAILURE, "write()");
+ swrite(STDOUT_FILENO, walk, len);
walk = logbuffer + sizeof(i3_shmlog_header);
return 1;
}
static void print_till_end(void) {
check_for_wrap();
const int len = (logbuffer + header->offset_next_write) - walk;
- const int n = write(STDOUT_FILENO, walk, len);
- if (len != n)
- err(EXIT_FAILURE, "write()");
- if (n > 0) {
- walk += n;
- }
+ swrite(STDOUT_FILENO, walk, len);
+ walk += len;
}
int main(int argc, char *argv[]) {
{"verbose", no_argument, 0, 'V'},
{"follow", no_argument, 0, 'f'},
{"help", no_argument, 0, 'h'},
- {0, 0, 0, 0}
- };
+ {0, 0, 0, 0}};
char *options_string = "s:vfVh";
if (logbuffer == MAP_FAILED)
err(EXIT_FAILURE, "Could not mmap SHM segment for the i3 log");
- header = (i3_shmlog_header*)logbuffer;
+ header = (i3_shmlog_header *)logbuffer;
if (verbose)
printf("next_write = %d, last_wrap = %d, logbuffer_size = %d, shmname = %s\n",