static int journal_seek_realtime_usec (lua_State *L) { sd_journal *j = check_journal(L, 1); uint64_t usec = luaL_checkuint64(L, 2); int err = sd_journal_seek_realtime_usec(j, usec); if (err != 0) return handle_error(L, -err); lua_pushboolean(L, 1); return 1; }
static tlog_grc tlog_journal_json_reader_init(struct tlog_json_reader *reader, va_list ap) { struct tlog_journal_json_reader *journal_json_reader = (struct tlog_journal_json_reader*)reader; uint64_t since = va_arg(ap, uint64_t); uint64_t until = va_arg(ap, uint64_t); const char * const *match_sym_list = va_arg(ap, const char * const *); int sd_rc; tlog_grc grc; /* Create JSON tokener */ journal_json_reader->tok = json_tokener_new(); if (journal_json_reader->tok == NULL) { grc = TLOG_GRC_ERRNO; goto error; } /* Open journal */ sd_rc = sd_journal_open(&journal_json_reader->journal, 0); if (sd_rc < 0) { grc = TLOG_GRC_FROM(systemd, sd_rc); goto error; } /* Add matches */ sd_rc = tlog_journal_add_match_sym_list(journal_json_reader->journal, match_sym_list); if (sd_rc < 0) { grc = TLOG_GRC_FROM(systemd, sd_rc); goto error; } /* Seek to "since" timestamp */ sd_rc = sd_journal_seek_realtime_usec(journal_json_reader->journal, since); if (sd_rc < 0) { grc = TLOG_GRC_FROM(systemd, sd_rc); goto error; } /* Store "until" timestamp */ journal_json_reader->until = until; return TLOG_RC_OK; error: tlog_journal_json_reader_cleanup(reader); return grc; }