#import <appkit/appkit.h>
#import "PBTypes.h"

int main (int argc, char * argv [])
{
	while (++ argv, -- argc)
	{	char * ext = strrchr(*argv, '.');
		NXAtom from;
		const NXAtom * types, * nap;
		id pb;

		if (argv[0][0] == '-')
			from = [[PBTypes new] type:argv[0]+1];
		else if (strchr(argv[0], ' ') || ! ext)
			from = NXUniqueString(argv[0]);
		else if (! ext[1])
			from = NXAsciiPboardType;
		else
			from = NXCreateFilenamePboardType(++ ext);

		if (types = [Pasteboard typesFilterableTo:from])
		{	printf("to %s:\n", from);
			for (nap = types; *nap; ++ nap)
				printf("\t%s\n", *nap);
			free((void *) types);
		}

		pb = [Pasteboard newByFilteringFile:argv[0]];
		if (types = [pb types])
		{	printf("from %s to:\n", *argv);
			for (nap = types; *nap; ++ nap)
				printf("\t%s\n", *nap);
		}
		[pb free];
	}
	return 0;
}
