ftp.nice.ch/pub/next/unix/text/rtfdtohtml.1.3.s.tar.gz#/rtfdtohtml-1.3/pbtools/trafo.m

This is trafo.m in view mode; [Download] [Up]

// leicht modifiziert, liest jetzt aus angegebenem Pasteboard statt aus Datei

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

int main (int argc, char * argv [])
{
	[Application new];	// anscheinend nötig...
	if (argc > 1)
	{	id pb; NXAtom type; char * buf; int len; id src; NXAtom pbKey;

		pbKey = argv[1][0] == '-' ? [[PBNames new] key:argv[1]+1] :
			NXUniqueString(argv[1]);
		src = [Pasteboard newName:pbKey];

		if (! (pb = [Pasteboard newByFilteringTypesInPasteboard:src]))
			fprintf(stderr, "%s: cannot filter\n", *argv), exit(1);

		if (argc > 2)
			type = argv[2][0] == '-' ?
		    		[[PBTypes new] type:argv[2]+1] :
				NXUniqueString(argv[2]);
		else
		{	char * p = strrchr(argv[0], '/');

			if (! p)
				p = argv[0];
			else
				++ p;
			type = [[PBTypes new] type:p];
		}

		if (! (type = [pb findAvailableTypeFrom:&type num:1]))
			[pb error:"no type\n"];
		else if ([pb readType:type data:&buf length:&len])
		{	fwrite(buf, len, 1, stdout);
			[pb deallocatePasteboardData:buf length:len];
		}
		else
			[pb error:"no data\n"];
	}
	return 0;
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.