-
-static bool contains_unprintable(const void *p, size_t l) {
- const char *j;
-
- for (j = p; j < (const char *) p + l; j++)
- if (*j < ' ' || *j >= 127)
- return true;
-
- return false;
-}
-
-static int output_short(sd_journal *j, unsigned line) {
- int r;
- uint64_t realtime;
- time_t t;
- struct tm tm;
- char buf[64];
- const void *data;
- size_t length;
- size_t n = 0;
-
- assert(j);
-
- r = sd_journal_get_realtime_usec(j, &realtime);
- if (r < 0) {
- log_error("Failed to get realtime: %s", strerror(-r));
- return r;
- }
-
- t = (time_t) (realtime / USEC_PER_SEC);
- if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm)) <= 0) {
- log_error("Failed to format time.");
- return -EINVAL;
- }
-
- fputs(buf, stdout);
- n += strlen(buf);
-
- if (sd_journal_get_data(j, "_HOSTNAME", &data, &length) >= 0 &&
- (arg_show_all || (!contains_unprintable(data, length) &&
- length < PRINT_THRESHOLD))) {
- printf(" %.*s", (int) length - 10, ((const char*) data) + 10);
- n += length - 10 + 1;
- }
-
- if (sd_journal_get_data(j, "MESSAGE", &data, &length) >= 0) {
- if (arg_show_all)
- printf(" %.*s", (int) length - 8, ((const char*) data) + 8);
- else if (contains_unprintable(data, length))
- fputs(" [blob data]", stdout);
- else if (length - 8 + n < columns())
- printf(" %.*s", (int) length - 8, ((const char*) data) + 8);
- else if (n < columns()) {
- char *e;
-
- e = ellipsize_mem((const char *) data + 8, length - 8, columns() - n - 2, 90);
-
- if (!e)
- printf(" %.*s", (int) length - 8, ((const char*) data) + 8);
- else
- printf(" %s", e);
-
- free(e);
- }
- }
-
- fputc('\n', stdout);
+static bool arg_no_pager = false;
+static int arg_lines = -1;
+static bool arg_no_tail = false;
+static bool arg_new_id128 = false;
+
+static int help(void) {
+
+ printf("%s [OPTIONS...] {COMMAND} ...\n\n"
+ "Send control commands to or query the journal.\n\n"
+ " -h --help Show this help\n"
+ " --version Show package version\n"
+ " --no-pager Do not pipe output into a pager\n"
+ " -a --all Show all properties, including long and unprintable\n"
+ " -f --follow Follow journal\n"
+ " -n --lines=INTEGER Journal entries to show\n"
+ " --no-tail Show all lines, even in follow mode\n"
+ " -o --output=STRING Change journal output mode (short, short-monotonic,\n"
+ " verbose, export, json, cat)\n"
+ " --new-id128 Generate a new 128 Bit id\n",
+ program_invocation_short_name);