#import <stdio.h>
#import <appkit/Application.h>
#import <appkit/workspaceRequest.h>

char *path;

@interface MyObj : Object
{
}
- appDidInit:sender;
@end

@implementation MyObj

- appDidInit:sender
{
    int rc;
    printf("App did init path=%s\n", path);
    
    [[Application workspace] unmountAndEjectDeviceAt:path];
    [NXApp perform:@selector(terminate:) with:self
        afterDelay:1000.0 cancelPrevious:NO];

    return self;
}
@end

main(int argc, char **argv)
{
    id obj;

    obj = [[MyObj alloc] init];

    if (argc != 2)
    {
	fprintf(stderr, "Usage: %s path\n", argv[0]);
	exit(1);
    }

    path = argv[1];
    printf("Ejecting %s\n", path);
    
    [Application new];
    [NXApp setDelegate:obj];
    [NXApp run];
    [NXApp free];
}

