/*
 * Process program's flags.
 */
static
int
options(int argc, char** argv)
{
	int i;

	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') {
			break;
		}

		if (strcmp(argv[i], "-help") == 0) {
			usage();
			exit(0);
		}
		else if (strcmp(argv[i], "-version") == 0) {
			dprintf("Kaffeh Stub Generator\n");
			dprintf("Copyright (c) 1996, 1997\nTransvirtual Technologies, Inc.  All rights reserved\n");

			dprintf("Version: %s\n", PACKAGE_VERSION);
			exit(0);
		}
		else if (strcmp(argv[i], "-base") == 0) {
			flag_shrt = 1;
		}
		else if (strcmp(argv[i], "-jni") == 0) {
			flag_jni = 1;
		}
#ifdef KAFFE_VMDEBUG
		else if (strcmp(argv[i], "-Xdebug") == 0) {
			i++;
			dbgSetMaskStr(argv[i]);
		}
#endif /*KAFFE_VMDEBUG*/
		else if (strcmp(argv[i], "-classpath") == 0) {
			i++;
			strcpy(realClassPath, argv[i]);
		}
		else if (strcmp(argv[i], "-bootclasspath") == 0) {
			i++;
			strcpy(realClassPath, argv[i]);
		}
		else if (strcmp(argv[i], "-o") == 0) {
			i++;
			outputName = argv[i];
		}
		else if (strcmp(argv[i], "-d") == 0) {
			i++;
			directoryName = argv[i];
		}
		else {
			dprintf("Unknown flag: %s\n", argv[i]);
		}
	}

	/* Return first no-flag argument */
	return (i);
}
Exemple #2
0
/*
 * Process program's flags.
 */
static
int
options(int argc, char** argv)
{
	int i;


	char * bootclasspath = NULL;
	char * classpath = NULL;

	bootclasspath = malloc(1);
	if (bootclasspath == NULL) 
	  {
	    fprintf(stderr, "%s", _("Error: out of memory.\n"));
	    exit(EXIT_FAILURE);
	  }
	*bootclasspath = '\0';

	classpath = malloc(1);
	if (classpath == NULL) 
	  {
	    fprintf(stderr, "%s",  _("Error: out of memory.\n"));
	    exit(EXIT_FAILURE);
	  }
	*classpath = '\0';

	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') {
			break;
		}

		if (strcmp(argv[i], "-help") == 0) {
			usage();
			exit(0);
		}
		else if (strcmp(argv[i], "-version") == 0) {
			dprintf("Kaffeh Stub Generator\n");
			dprintf("Copyright (c) 1996, 1997\nTransvirtual Technologies, Inc.  All rights reserved\n");

			dprintf("Version: %s\n", PACKAGE_VERSION);
			exit(0);
		}
		else if (strcmp(argv[i], "-base") == 0) {
			flag_shrt = 1;
		}
		else if (strcmp(argv[i], "-jni") == 0) {
			flag_jni = 1;
		}
#ifdef KAFFE_VMDEBUG
		else if (strcmp(argv[i], "-Xdebug") == 0) {
			i++;
			dbgSetMaskStr(argv[i]);
		}
#endif /*KAFFE_VMDEBUG*/
		else if (strcmp(argv[i], "-classpath") == 0) {
		  char * newcp;
		  size_t cplen;

		  i++;

		  cplen = strlen(classpath)
		    + strlen(argv[i])
		    + strlen(path_separator)
		    + 1;

		  newcp = malloc(cplen);
		  if (newcp == NULL)
		    {
		      fprintf(stderr, "%s", _("Error: out of memory.\n"));
		      exit(EXIT_FAILURE);
		    }
		  
		  strcpy(newcp, classpath);
		  strcat(newcp, path_separator);
		  strcat(newcp, argv[i]);

		  free(classpath);
		  classpath = newcp;
		}
		else if (strcmp(argv[i], "-bootclasspath") == 0) {
		  char * newcp;
		  size_t cplen;

		  i++;

		  cplen = strlen(bootclasspath)
		    + strlen(argv[i])
		    + strlen(path_separator)
		    + 1;

		  newcp = malloc(cplen);
		  if (newcp == NULL)
		    {
		      fprintf(stderr, "%s", _("Error: out of memory.\n"));
		      exit(EXIT_FAILURE);
		    }
		  
		  strcpy(newcp, bootclasspath);
		  strcat(newcp, path_separator);
		  strcat(newcp, argv[i]);

		  free(bootclasspath);
		  bootclasspath = newcp;
		}
		else if (strcmp(argv[i], "-o") == 0) {
			i++;
			outputName = argv[i];
		}
		else if (strcmp(argv[i], "-d") == 0) {
			i++;
			directoryName = argv[i];
		}
		else if (strcmp(argv[i], "-force") == 0) {
		  /* ignore the flag, since kaffeh overwrites
		   * the output file in any case.
		   */
		}
		else {
			dprintf("Unknown flag: %s\n", argv[i]);
		}
	}


	if (strlen(bootclasspath) > 0) 
	  {
	    strcpy(realClassPath, bootclasspath);
	  } 

	free(bootclasspath);

	if (strlen(classpath) > 0)
	  {
	    strcat(realClassPath, classpath);
	  }

	free(classpath);

	/* Return first no-flag argument */
	return (i);
}
/*
 * MAIN
 */
int
main(int argc, char* argv[])
{
	int farg;
	const char* cp;
	void* env;

#if defined(MAIN_MD)
	MAIN_MD;
#endif

#if defined(HAVE_LC_MESSAGES)
	setlocale(LC_MESSAGES, "");
	setlocale(LC_CTYPE, "");
#endif
#if defined(HAVE_GETTEXT)
	bindtextdomain(PACKAGE, KAFFE_LOCALEDIR);
	textdomain(PACKAGE);
#endif

	vmargs.version = JNI_VERSION_1_1;

#if defined(KAFFE_PROFILER)
	profFlag = 0;
#endif

	JNI_GetDefaultJavaVMInitArgs(&vmargs);

	/* set up libtool/libltdl dlopen emulation */
	LTDL_SET_PRELOADED_SYMBOLS();

#if defined(KAFFE_VMDEBUG)
	cp = getenv("KAFFE_VMDEBUG");
	if (cp != 0)
		dbgSetMaskStr(cp);
#endif

	cp = getenv(BOOTCLASSPATH);
	vmargs.bootClasspath = cp;

	cp = getenv(CLASSPATH1);
	if (cp == 0) {
		cp = getenv(CLASSPATH2);
#if defined(DEFAULT_CLASSPATH)
		if (cp == 0) {
			cp = DEFAULT_CLASSPATH;
		}
#endif
	}
	vmargs.classpath = (cp == NULL? NULL :strdup(cp));

        cp = getenv(LIBRARYPATH1);
	if (cp == 0) {
		cp = getenv(LIBRARYPATH2);
	}
        vmargs.libraryhome = cp;

        cp = getenv(KAFFEHOME);
        if (cp == 0) {
#if defined(DEFAULT_KAFFEHOME)
                cp = DEFAULT_KAFFEHOME;
#endif
        }
        vmargs.classhome = cp;

	/* Process program options */
	farg = options(argv, argc);
	argc = argc - farg;

#if defined(KAFFE_XPROFILER)
	if( xProfFlag )
	{
		if( !enableXCallGraph() && !enableXProfiling() )
		{
			fprintf(stderr, 
				"Unable to initialize cross "
				"language profiling\n");
			xProfFlag = 0;
		}
	}
#endif

	/* Get the class name to start with */
	if (argv[farg] == 0) {
		usage();
		exit(EXIT_FAILURE);
	}

	if (strcmp(argv[farg] + strlen(argv[farg]) - strlen(".class"),
		   ".class") == 0) {
		fprintf(stderr,
			"Please do not specify the .class extension\n");
		exit(EXIT_FAILURE);
	}

	/* Initialise */
	if (JNI_CreateJavaVM(&global_vm, 
			     &env, 
			     &vmargs) 
	    < 0)
	  {
	    fprintf(stderr, "Cannot create the Java VM\n");
	    exit(EXIT_FAILURE);
	  }

	return main2(env, argv, farg, argc);
}
/*
 * Process program's flags.
 */
static
int
options(char** argv, int argc)
{
	int i;
	unsigned int j;
	size_t sz;
	userProperty* prop;

	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') {
			break;
		}

		if (strcmp(argv[i], "-help") == 0) {
			usage();
			exit(EXIT_SUCCESS);
		}
		else if (strcmp(argv[i], "-version") == 0) {
			printShortVersion();
			exit(EXIT_SUCCESS);
		}
		else if (strcmp(argv[i], "-fullversion") == 0) {
			printFullVersion();
			exit(EXIT_SUCCESS);
		}
#if defined(__ia64__)
		else if (strcmp(argv[i], "-ia32") == 0) {
			i++;
			/* FIXME: skip, case handled by the calle script */
		}
#endif
		else if (strcmp(argv[i], "-classpath") == 0
			 || strcmp(argv[i], "-cp") == 0) {

			i++;
			if (argv[i] == 0) {
				fprintf(stderr, 
				    "Error: No path found for %s option.\n",
				    argv[i - 1]);
				exit(EXIT_FAILURE);
			}

			/* set the new classpath */
			vmargs.classpath = strdup(argv[i]);
		}
		else if (strcmp(argv[i], "-addclasspath") == 0) {
			char	*newcpath;
			unsigned int      cpathlength;

			i++;
			if (argv[i] == 0) {
				fprintf(stderr, 
				    "Error: No path found for %s option.\n",
				    argv[i - 1]);
				exit(EXIT_FAILURE);
			}

			cpathlength = ((vmargs.classpath != NULL) ? strlen(vmargs.classpath) : 0)
				+ strlen(path_separator)
				+ strlen(argv[i])
				+ 1;

			/* Get longer buffer FIXME:  free the old one */
			if ((newcpath = malloc(cpathlength)) == NULL) {
				fprintf(stderr,  _("Error: out of memory.\n"));
				exit(EXIT_FAILURE);
			}

			/* Construct new classpath */
			if( vmargs.classpath != 0 )
			  	strcpy(newcpath, vmargs.classpath);
			else
				newcpath[0] = '\0';
			strcat(newcpath, path_separator);
			strcat(newcpath, argv[i]);

			/* set the new classpath */
			vmargs.classpath = newcpath;
		}
#ifdef KAFFE_X_AWT_INCLUDED
                /* Extra option to use kaffe's Xlib AWT backend.
                 */
                else if (strncmp(argv[i], "-Xkaffe-xlib-awt", (j=16)) == 0) {
			prop = setKaffeAWT("kaffe.awt.nativelib=xawt");
                }
#endif
#ifdef KAFFE_QT_AWT_INCLUDED
                /* Extra option to use kaffe's Qt/Embedded AWT backend.
                 */
                else if (strncmp(argv[i], "-Xkaffe-qt-awt", (j=15)) == 0) {
                        prop = setKaffeAWT("kaffe.awt.nativelib=qtawt");
                }
#endif
#ifdef KAFFE_NANOX_AWT_INCLUDED
		/* Extra option to use kaffe's Nano-X AWT backend.
		 */
		else if (strncmp(argv[i], "-Xkaffe-nanox-awt", (j=17)) == 0) {
			prop = setKaffeAWT("kaffe.awt.nativelib=nanoxawt");
		}
#endif
#if defined(USE_GMP)
		/* Extra option to use gmp for native, fast bignums.
		 * Only available with binreloc, since binreloc is used to
		 * find the gmpjavamath.jar file.
		 */
                else if (strncmp(argv[i], "-Xnative-big-math", (j=17)) == 0) {
                        char    *newbootcpath;
                        unsigned int      bootcpathlength;
			const char *prefix =
#if defined(ENABLE_BINRELOC)
				LIBDIR
#else /* !defined(ENABLE_BINRELOC) */
				DEFAULT_KAFFEHOME
#endif /* defined(ENABLE_BINRELOC) */
				;

 			const char *suffix = file_separator "gmpjavamath.jar";

                        bootcpathlength = strlen(prefix)
				+ strlen(suffix)
				+ strlen(path_separator)
                                + ((vmargs.bootClasspath != NULL) ?
                                        strlen(vmargs.bootClasspath) : 0)
                                + 1;

                        /* Get longer buffer FIXME:  free the old one */
                        if ((newbootcpath = malloc(bootcpathlength)) == NULL) {
                                fprintf(stderr,  _("Error: out of memory.\n"));
                                exit(EXIT_FAILURE);
                        }

                        /* Construct new boot classpath */
                        strcpy(newbootcpath, prefix);
			strcat(newbootcpath, suffix);
                        strcat(newbootcpath, path_separator);
                        if( vmargs.bootClasspath != 0 )
                                strcat(newbootcpath, vmargs.bootClasspath);

                        /* set the new boot classpath */
                        vmargs.bootClasspath = newbootcpath;
                }
#endif /* defined(USE_GMP) */
		else if (strncmp(argv[i], "-Xbootclasspath/p:", (j=18)) == 0) {
			char	*newbootcpath;
			unsigned int      bootcpathlength;

			bootcpathlength = strlen(&argv[i][j])
				+ strlen(path_separator)
				+ ((vmargs.bootClasspath != NULL) ?
					strlen(vmargs.bootClasspath) : 0)
				+ 1;

			/* Get longer buffer FIXME:  free the old one */
			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {
				fprintf(stderr,  _("Error: out of memory.\n"));
				exit(EXIT_FAILURE);
			}

			/* Construct new boot classpath */
			strcpy(newbootcpath, &argv[i][j]);
			strcat(newbootcpath, path_separator);
			if( vmargs.bootClasspath != 0 )
			  	strcat(newbootcpath, vmargs.bootClasspath);

			/* set the new boot classpath */
			vmargs.bootClasspath = newbootcpath;
		}
		else if (strncmp(argv[i], "-Xbootclasspath/a:", (j=18)) == 0) {
			char	*newbootcpath;
			unsigned int      bootcpathlength;

			bootcpathlength = strlen(&argv[i][j])
				+ strlen(path_separator)
				+ ((vmargs.bootClasspath != NULL) ?
					strlen(vmargs.bootClasspath) : 0)
				+ 1;

			/* Get longer buffer FIXME:  free the old one */
			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {
				fprintf(stderr,  _("Error: out of memory.\n"));
				exit(EXIT_FAILURE);
			}

			/* Construct new boot classpath */
			if( vmargs.bootClasspath != 0 ) {
			  	strcpy(newbootcpath, vmargs.bootClasspath);
				strcat(newbootcpath, path_separator);
			}
			strcat(newbootcpath, &argv[i][j]);

			/* set the new boot classpath */
			vmargs.bootClasspath = newbootcpath;
		}
		else if (strncmp(argv[i], "-Xbootclasspath:", (j=16)) == 0) {
			char	*newbootcpath;
			unsigned int      bootcpathlength;

			bootcpathlength = strlen(&argv[i][j]) + 1;

			/* Get longer buffer FIXME:  free the old one */
			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {
				fprintf(stderr,  _("Error: out of memory.\n"));
				exit(EXIT_FAILURE);
			}

			/* Construct new boot classpath */
			strcpy(newbootcpath, &argv[i][j]);

			/* set the new boot classpath */
			vmargs.bootClasspath = newbootcpath;
		}
		else if ((strncmp(argv[i], "-ss", (j=3)) == 0) 
			 || (strncmp(argv[i], "-Xss", (j=4)) == 0)) {
			if (argv[i][j] == 0) {
				i++;
				if (argv[i] == 0) {
					fprintf(stderr, _("Error: No stack size found for -ss option.\n"));
					exit(EXIT_FAILURE);
				}
				sz = parseSize(argv[i]);
			} else {
				sz = parseSize(&argv[i][j]);
			}
			if (sz < THREADSTACKSIZE) {
				fprintf(stderr,  _("Warning: Attempt to set stack size smaller than %d - ignored.\n"), THREADSTACKSIZE);
			}
			else {
				vmargs.nativeStackSize = sz;
			}
		}
		else if ((strncmp(argv[i], "-mx", (j=3)) == 0)
			 || (strncmp(argv[i], "-Xmx", (j=4)) == 0)) {
			if (argv[i][j] == 0) {
				i++;
				if (argv[i] == 0) {
					fprintf(stderr,  _("Error: No heap size found for -mx option.\n"));
					exit(EXIT_FAILURE);
				}
				if (strcmp(argv[i], "unlimited") == 0)
					vmargs.maxHeapSize = UNLIMITED_HEAP;
				else
					vmargs.maxHeapSize = parseSize(argv[i]);
			} else {
				if (strcmp(&argv[i][j], "unlimited") == 0)
					vmargs.maxHeapSize = UNLIMITED_HEAP;
				else
					vmargs.maxHeapSize = parseSize(&argv[i][j]);
			}
		}
		else if ((strncmp(argv[i], "-ms", (j=3)) == 0)
			 || (strncmp(argv[i], "-Xms", (j=4)) == 0)) {
			if (argv[i][j] == 0) {
				i++;
				if (argv[i] == 0) {
					fprintf(stderr,  _("Error: No heap size found for -ms option.\n"));
					exit(EXIT_FAILURE);
				}
				vmargs.minHeapSize = parseSize(argv[i]);
			} else {
				vmargs.minHeapSize = parseSize(&argv[i][j]);
			}
		}
		else if (strncmp(argv[i], "-as", 3) == 0) {
			if (argv[i][3] == 0) {
				i++;
				if (argv[i] == 0) {
					fprintf(stderr,  _("Error: No heap size found for -as option.\n"));
					exit(EXIT_FAILURE);
				}
				vmargs.allocHeapSize = parseSize(argv[i]);
			} else {
				vmargs.allocHeapSize = parseSize(&argv[i][3]);
			}
		}
		else if (strcmp(argv[i], "-verify") == 0) {
			vmargs.verifyMode = 3;
		}
		else if (strcmp(argv[i], "-verifyremote") == 0) {
			vmargs.verifyMode = 2;
		}
		else if (strcmp(argv[i], "-noverify") == 0) {
			vmargs.verifyMode = 0;
		}
		else if (strcmp(argv[i], "-verbosegc") == 0) {
			vmargs.enableVerboseGC = 1;
		}
		else if (strcmp(argv[i], "-noclassgc") == 0) {
			vmargs.enableClassGC = 0;
		}
		else if (strcmp(argv[i], "-verbosejit") == 0) {
			vmargs.enableVerboseJIT = 1;
		}
		else if (strcmp(argv[i], "-verbosemem") == 0) {
			vmargs.enableVerboseGC = 2;
		}
		else if (strcmp(argv[i], "-verbosecall") == 0) {
			vmargs.enableVerboseCall = 1;
		}
		else if (strcmp(argv[i], "-verbose") == 0 || strcmp(argv[i], "-v") == 0) {
			vmargs.enableVerboseClassloading = 1;
		}
                else if (strcmp(argv[i], "-jar") == 0) {
			char	*newcpath;
			unsigned int      cpathlength;

			cpathlength = strlen(argv[i+1]) + 
				strlen(path_separator) +
				((vmargs.classpath!=NULL) ? strlen(vmargs.classpath) : 0) +
				1;

			newcpath = (char *)malloc (cpathlength);
			if (newcpath == NULL) {
				fprintf(stderr,  _("Error: out of memory.\n"));
				exit(EXIT_FAILURE);
			}

			strcpy (newcpath, argv[i+1]);

			if (vmargs.classpath != NULL) {
				strcat (newcpath, path_separator);
				strcat (newcpath, vmargs.classpath);
				free ((void*)vmargs.classpath);
			}

			/* set the new classpath */
			vmargs.classpath = newcpath;

                        isJar = 1;
                }
		else if (strncmp(argv[i], "-Xrun", 5) == 0) {
		  char *argPos;
		  char *libName;
		  int libnameLen;

		  argPos = strchr(argv[i], ':');
		  if (argPos != NULL)
		    {
		      libnameLen = argPos - &argv[i][5];
		      vmargs.profilerArguments = strdup(argPos+1);
		    }
		  else
		    libnameLen = strlen(argv[i]) - 1;

		  libName = malloc(libnameLen+4);
		  strcpy(libName, "lib");
		  strncat(libName, &argv[i][5], libnameLen);

		  vmargs.profilerLibname = libName;
		}
#if defined(KAFFE_PROFILER)
		else if (strcmp(argv[i], "-prof") == 0) {
			profFlag = 1;
			vmargs.enableClassGC = 0;
		}
#endif
#if defined(KAFFE_XPROFILER)
		else if (strcmp(argv[i], "-Xxprof") == 0) {
			xProfFlag = 1;
			vmargs.enableClassGC = 0;
		}
		else if (strcmp(argv[i], "-Xxprof_syms") == 0) {
			i++;
			if (argv[i] == 0) {
				fprintf(stderr, 
					_("Error: -Xxprof_syms option requires "
					"a file name.\n"));
			}
			else if( !profileSymbolFile(argv[i]) )
			{
				fprintf(stderr, 
					_("Unable to create profiler symbol "
					"file %s.\n"),
					argv[i]);
			}
		}
		else if (strcmp(argv[i], "-Xxprof_gmon") == 0) {
			i++;
			if (argv[i] == 0) {
				fprintf(stderr, 
					_("Error: -Xxprof_gmon option requires "
					"a file name.\n"));
			}
			else if (!profileGmonFile(argv[i]))
			{
				fprintf(stderr, 
					_("Unable to create gmon file %s.\n"),
					argv[i]);
			}
		}
#endif
#if defined(KAFFE_XDEBUGGING)
		else if (strcmp(argv[i], "-Xxdebug") == 0) {
			/* Use a default name */
			machine_debug_filename = "xdb.as";
		}
		else if (strcmp(argv[i], "-Xxdebug_file") == 0) {
			i++;
			if (argv[i] == 0) {
				fprintf(stderr, 
					_("Error: -Xxdebug_file option requires "
					"a file name.\n"));
			}
			else
			{
				machine_debug_filename = argv[i];
			}
		}
#endif
#if defined(KAFFE_FEEDBACK)
		else if (strcmp(argv[i], "-Xfeedback") == 0) {
			i++;
			if (argv[i] == 0) {
				fprintf(stderr, 
					_("Error: -Xfeedback option requires a "
					"file name.\n"));
			}
			else
			{
				feedback_filename = argv[i];
			}
		}
#endif
		else if (strcmp(argv[i], "-nodeadlock") == 0) {
			KaffeVM_setDeadlockDetection(0);
		}
#if defined(KAFFE_STATS)
                else if (strcmp(argv[i], "-vmstats") == 0) {
			extern void statsSetMaskStr(char *);
                        i++;
                        if (argv[i] == 0) { /* forgot second arg */
                                fprintf(stderr, 
					_("Error: -vmstats option requires a "
					"second arg.\n"));
                                exit(EXIT_FAILURE);
                        }
                        statsSetMaskStr(argv[i]);
                }
#endif
#if defined(KAFFE_VMDEBUG)
                else if (strcmp(argv[i], "-vmdebug") == 0) {
                        i++;
                        if (argv[i] == 0) { /* forgot second arg */
                                fprintf(stderr, 
					_("Error: -vmdebug option requires a "
					"debug flag. Use `list' for a list.\n"));
                                exit(EXIT_FAILURE);
                        }
                        if (!dbgSetMaskStr(argv[i]))
				exit(EXIT_FAILURE);
                }
#endif
                else if (strcmp(argv[i], "-debug-fd") == 0) {
			char *end;
                        i++;
                        if (argv[i] == 0) { /* forgot second arg */
                                fprintf(stderr, 
					_("Error: -debug-fd an open descriptor.\n"));
                                exit(EXIT_FAILURE);
                        }
			dbgSetDprintfFD(strtol(argv[i], &end, 10));
			if (end != 0 && *end != '\0') {
				fprintf(stderr,
					_("Error: -debug-fd requires an integer.\n"));
				exit(EXIT_FAILURE);
			}
                }
		else if (argv[i][1] ==  'D') {
			/* Set a property */
			char *propStr = strdup(&argv[i][2]);

			prop = setUserProperty(propStr);
		}
		else if (argv[i][1] == 'X') {
			fprintf(stderr, 
				_("Error: Unrecognized JVM specific option "
				"`%s'.\n"),
				argv[i]);
		}
		/* The following options are not supported and will be
		 * ignored for compatibility purposes.
		 */
		else if (strcmp(argv[i], "-noasyncgc") == 0 ||
		   strcmp(argv[i], "-cs") == 0 ||
		   strcmp(argv[i], "-checksource")) {
		}
		else if (strcmp(argv[i], "-oss") == 0) {
			i++;
		}
		else {
			fprintf(stderr,  _("Unknown flag: %s\n"), argv[i]);
		}
	}

	/* Return first no-flag argument */
	return (i);
}