+ r = journal_file_move_to_object(f, cp, OBJECT_ENTRY, &c);
+ if (r < 0)
+ return r;
+
+ n = journal_file_entry_n_items(c);
+
+ /* Make sure we don't match the entry we are starting
+ * from. */
+ found = f->current_offset != cp;
+
+ np = 0;
+ LIST_FOREACH(matches, m, j->matches) {
+ uint64_t q, k;
+
+ for (k = 0; k < n; k++)
+ if (c->entry.items[k].hash == m->le_hash)
+ break;
+
+ if (k >= n) {
+ /* Hmm, didn't find any field that matched, so ignore
+ * this match. Go on with next match */
+
+ found = false;
+ continue;
+ }
+
+ /* Hmm, so, this field matched, let's remember
+ * where we'd have to try next, in case the other
+ * matches are not OK */
+
+ if (direction == DIRECTION_DOWN) {
+ q = le64toh(c->entry.items[k].next_entry_offset);
+
+ if (q > np)
+ np = q;
+ } else {
+ q = le64toh(c->entry.items[k].prev_entry_offset);
+
+ if (q != 0 && (np == 0 || q < np))
+ np = q;
+ }
+ }
+
+ /* Did this entry match against all matches? */
+ if (found) {
+ *o = c;
+ *p = cp;
+ return 1;
+ }
+
+ /* Did we find a subsequent entry? */
+ if (np == 0)
+ return 0;
+
+ /* Hmm, ok, this entry only matched partially, so
+ * let's try another one */
+ cp = np;
+ }