/* * Returns 0 for non-conforming footer * Returns 1 for conforming footer * Returns 2 when sob exists within conforming footer * Returns 3 when sob exists within conforming footer as last entry */ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob, int ignore_footer) { struct trailer_info info; int i; int found_sob = 0, found_sob_last = 0; trailer_info_get(&info, sb->buf); if (info.trailer_start == info.trailer_end) return 0; for (i = 0; i < info.trailer_nr; i++) if (sob && !strncmp(info.trailers[i], sob->buf, sob->len)) { found_sob = 1; if (i == info.trailer_nr - 1) found_sob_last = 1; } trailer_info_release(&info); if (found_sob_last) return 3; if (found_sob) return 2; return 1; }
static void format_trailers(struct strbuf *sb, const char *msg) { struct trailer_info info; trailer_info_get(&info, msg); strbuf_add(sb, info.trailer_start, info.trailer_end - info.trailer_start); trailer_info_release(&info); }