shithub: pdffs

ref: a080ae88c6c65503575da220cb131ddada107bf6
dir: /main.c/

View raw version
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <bio.h>
#include "pdf.h"

int mainstacksize = 32768;

static void
usage(void)
{
	fprint(2, "usage: %s FILE\n", argv0);
	threadexitsall("usage");
}

void
threadmain(int argc, char **argv)
{
	int fd;
	Pdf *pdf;
	Object *v;

	quotefmtinstall();

	ARGBEGIN{
	default:
		usage();
	}ARGEND

#ifdef TEST
#define T(x) \
	void x(void); \
	x();

	if(argc != 1){
		T(test_pdfstring);
		T(test_pdfname);
		threadexitsall(nil);
	}
#endif

	if(argc != 1)
		usage();
	if((fd = open(argv[0], OREAD)) < 0)
		sysfatal("%r");
	if((pdf = pdfopen(fd)) == nil)
		sysfatal("%r");
	if((v = pdfdictget(pdf->info, "Creator")) != nil)
		fprint(2, "creator: %s\n", v->str);
	if((v = pdfdictget(pdf->info, "Producer")) != nil)
		fprint(2, "producer: %s\n", v->str);
	pdfclose(pdf);

	threadexitsall(nil);
}