Feature: N records from start cursor
draft
if (this->startCursor) {
ret = sd_journal_seek_cursor(journal, this->startCursor);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to requested start cursor");
}
ret = sd_journal_next(journal);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to requested start cursor");
}
if (this->params.count == 0) {
ret = sd_journal_previous(journal);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to requested start cursor");
}
}
} else {
if (this->params.count) {
if (this->endCursor) {
ret = sd_journal_seek_cursor(journal, this->endCursor);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to requested end cursor");
}
ret = sd_journal_previous(journal);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to requested end cursor");
}
} else {
ret = sd_journal_seek_tail(journal);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to end of journal");
}
}
ret = sd_journal_previous_skip(journal, this->params.count + 1);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to skip the beginning of requested records");
}
} else {
ret = sd_journal_seek_head(journal);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to beginning of journal");
}
ret = sd_journal_next(journal);
if (ret < 0) {
handleError(journal, ErrCodes::JOURNAL_ERROR, ret, "Failed to seek to beginning of journal");
}
}
}
this may need to be altered, however the real problem is detecting last journal entry