ref: a080ae88c6c65503575da220cb131ddada107bf6
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 = pdfobject(pdf->bio)) == nil) return -1; *o = *d; memset(d, 0, sizeof(*d)); freeobject(d); return 0; }