ref: a9516693e7142a658f4e3ea190272f4cd73b24be
dir: /eval.c/
#include <u.h> #include <libc.h> #include <bio.h> #include "pdf.h" int pdfeval(Pdf *pdf, Object *o) { Object *d; Xref *x; int i; if(o == nil || o->type != Oindir) return 0; for(i = 0; i < pdf->nxref && pdf->xref[i].id != o->indir.id; i++); if(i >= pdf->nxref){ werrstr("no object id %d in xref", o->indir.id); return -1; } x = &pdf->xref[i]; if(Bseek(pdf->bio, x->off, 0) != x->off){ werrstr("xref seek failed"); return -1; } if((d = pdfobj(pdf, pdf->bio)) == nil) return -1; *o = *d; memset(d, 0, sizeof(*d)); pdfobjfree(d); return 0; }