summaryrefslogtreecommitdiff
path: root/libobj/test/main.c
blob: 1a60b421a97ddc2e11015b0706f3ff76e7759e7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <u.h>
#include <libc.h>
#include "../../obj.h"

static char fd0[] = "/fd/0";

void
usage(void)
{
	fprint(2, "usage: %s [file]\n", argv0);
	exits("usage");
}

void
main(int argc, char *argv[])
{
	OBJ *obj;
	char *f;

	f = fd0;
	OBJfmtinstall();
	ARGBEGIN{
	default: usage();
	}ARGEND;
	if(argc > 1)
		usage();
	if(argc == 1)
		f = argv[0];
	obj = objparse(f);
	if(obj == nil)
		sysfatal("objparse: %r");
	print("%O\n", obj);
	objfree(obj);
	exits(0);
}