ref: 02fc81c3d68b45a6901de9032e61cb91f33b033c
dir: /misc.c/
#include <u.h> #include <libc.h> #include <bio.h> #include "pdf.h" static char *otypes[] = { [Obool] = "bool", [Onum] = "num", [Ostr] = "str", [Oname] = "name", [Oarray] = "array", [Odict] = "dict", [Ostream] = "stream", [Onull] = "null", [Oindir] = "indir", }; static char *xtypes[] = { [Xusual] = "usual", [Xuncompressed] = "uncompressed", [Xcompressed] = "compressed", }; Object null = { .type = Onull, }; int Tfmt(Fmt *f) { Object *o; o = va_arg(f->args, Object*); if(o == nil || o == &null) return fmtprint(f, "null"); if(o->type < 0 || o->type >= nelem(otypes)) return fmtprint(f, "????"); return fmtprint(f, "%s", otypes[o->type]); } int ⊗fmt(Fmt *f) { Xref x; x = va_arg(f->args, Xref); switch(x.type){ case Xusual: return fmtprint(f, "<%s id=%d gen=%d off=%d>", xtypes[x.type], x.id, x.gen, x.off); case Xuncompressed: return fmtprint(f, "<%s gen=%d off=%d>", xtypes[x.type], x.gen, x.off); case Xcompressed: return fmtprint(f, "<%s id=%d objnum=%d>", xtypes[x.type], x.id, x.objnum); } return -1; } int isws(int c) { return /* \0 is missing on purpose */ c == '\t' || c == '\n' || c == '\f' || c == '\r' || c == ' '; } int isdelim(int c) { return c == '(' || c == ')' || c == '<' || c == '>' || c == '[' || c == ']' || c == '{' || c == '}' || c == '/' || c == '%'; }