USG_PG3/usr/source/cmd5/size.c

Compare this file to the similar file:
Show the results in this format:

/*
	size -- determine object size

*/

main(argc, argv)
char **argv;
{
	int buf[010], f, ac;
	long sum, itol();

	ac = argc;
	if (ac==1) {
		*argv = "a.out";
		ac++;
		--argv;
	}
	while(--ac) {
		++argv;
		if((f=open(*argv, 0))<0) {
			printf("%s not found\n", *argv);
			continue;
		}
		read(f, buf, 0020);
		if(buf[0]!=0410 && buf[0]!=0407 &&
		buf[0]!=0411 && buf[0]!=0405) {
			printf("%s not an object file\n", *argv);
			close(f);
			continue;
		}
		if (argc>2)
			printf("%s: ", *argv);
		printf("%l+%l+%l=", buf[1],buf[2],buf[3]);
		sum = itol(0, buf[1])+itol(0, buf[2])+itol(0, buf[3]);
		printf("%D (0%O)\n", sum, sum);
		close(f);
	}
	exit(0);
}