#import	<Foundation/Foundation.h>

int
main (int argc, char** argv, char **env)
{
  NSAutoreleasePool *pool = [NSAutoreleasePool new];
  NSProcessInfo	    *proc = [NSProcessInfo processInfo];
  NSBundle        *bundle = [NSBundle mainBundle];
  NSArray	    *args;
  unsigned		i;
  int              retval = 0;

  [NSProcessInfo initializeWithArguments:argv
		 count:argc
		 environment:env];

  args = [proc arguments];
  GSPrintf (stderr, @"Useless info about bundle: %@\n", bundle);

  if ([args count] <= 1)
    {
      GSPrintf (stderr, @"Please specify some arguments.\n");
      RELEASE (pool);
      exit (EXIT_FAILURE);
    }
  else if ([[proc environment] valueForKey:@"NOHANDLE"] != nil)
    GSPrintf (stderr, @"NOHANDLE defined; should exit with success.\n");
  else
    {
      for (i = 1; i < [args count]; i++)
	{
	  NSString	*opt = [args objectAtIndex: i];

 	  NS_DURING
	    {
	      NSString	*tempString;
	      id	result;

	      tempString = [NSString stringWithString: opt];
	      if (tempString == nil)
		GSPrintf (stderr, @"This should not happen.\n");
	      /* Exception handler taking care here.  */
	      else if (![tempString propertyList]); 
	      else if ((result = [tempString propertyList]) == nil)
	       	GSPrintf (stderr, @"'%@' - a nil property list.\n", opt);
	      else if ([result isKindOfClass: [NSDictionary class]] == YES)
		GSPrintf (stderr, @"'%@' - a dictionary.\n", opt);
	      else if ([result isKindOfClass: [NSArray class]] == YES)
		GSPrintf (stderr, @"'%@' - an array.\n", opt);
	      else if ([result isKindOfClass: [NSString class]] == YES)
		GSPrintf (stderr, @"'%@' - a string.\n", opt);
	      else
		GSPrintf (stderr, @"'%@' - unknown class %@.\n",
		  opt, [[result class] description]);
	    }
	  NS_HANDLER
	    {
	      GSPrintf (stderr, @"'%@' failed with:\n%@.\n", opt,
		[localException reason]);
	      GSPrintf (stderr, @"Failure.\n");
	      retval = 1;
	    }
	  NS_ENDHANDLER
	}
    }
  RELEASE (pool);
  return retval;
}
