This is look.m in view mode; [Download] [Up]
#import <appkit/Listener.h> // NXPortNameLookup
#import "Filter.h"
@interface Look: Object
{
int any;
}
@end
@implementation Look
- (void) filter: (Filter *) f flag: (char) ch
{
NXPrintf(f->err, "usage: %s [portname...]\n", f->progname),
NXFlush(f->err);
exit(1);
}
- (int) filter: (Filter *) f arg: (const char *) port
{
if (port)
NXPrintf(f->out, "port \"%s\" %sfound\n", port,
(any |= NXPortNameLookup(port, NULL)) == PORT_NULL ? "not " : "");
return 0;
}
- (int) filter: (Filter *) f exit: (int) code
{
return any == 0; // success if any is found
}
@end
int main (int argc, char * argv [])
{
return [[[Filter alloc] initFor: [Look new]] run: argv];
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.