static const char * parse_error_msg(struct parsedb_state *ps, const char *fmt) { static char msg[1024]; char filename[256]; str_escape_fmt(filename, ps->filename, sizeof(filename)); if (ps->pkg && ps->pkg->set->name) { char pkgname[256]; str_escape_fmt(pkgname, pkgbin_name(ps->pkg, ps->pkgbin, pnaw_nonambig), sizeof(pkgname)); sprintf(msg, _("parsing file '%.255s' near line %d package '%.255s':\n" " %.255s"), filename, ps->lno, pkgname, fmt); } else sprintf(msg, _("parsing file '%.255s' near line %d:\n" " %.255s"), filename, ps->lno, fmt); return msg; }
void parse_error(struct parsedb_state *ps, const struct pkginfo *pigp, const char *fmt, ...) { va_list args; char buf1[768], buf2[1000], *q; parse_error_msg(ps, pigp, _("parse error"), buf1); q = str_escape_fmt(buf2, buf1, sizeof(buf2)); strcat(q,fmt); va_start(args, fmt); ohshitv(buf2, args); }
void parse_warn(struct parsedb_state *ps, const struct pkginfo *pigp, const char *fmt, ...) { va_list args; char buf1[768], buf2[1000], *q; parse_error_msg(ps, pigp, _("warning"), buf1); q = str_escape_fmt(buf2, buf1, sizeof(buf2)); strcat(q, fmt); va_start(args, fmt); ps->warncount++; strcat(q, "\n"); if (vfprintf(stderr, buf2, args) == EOF) ohshite(_("failed to write parsing warning")); va_end(args); }