Beispiel #1
0
int main(int argc, char **argv)
{
#if ENABLE_NLS
	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);
#endif
	setup_signals();
	parse_args(argc, argv);

        /* If we inherited a relay_basedir_fd, we want to keep it to ourselves -
           i.e., FD_CLOEXEC the bad boy. */
        if (relay_basedir_fd >= 0) {
                int rc =  set_clexec(relay_basedir_fd);
                if (rc) 
                        exit(-1);
        }


	if (buffer_size)
		dbug(1, "Using a buffer of %u MB.\n", buffer_size);

	if (optind < argc) {
		parse_modpath(argv[optind++]);
		dbug(2, "modpath=\"%s\", modname=\"%s\"\n", modpath, modname);
	}

	if (optind < argc) {
		if (attach_mod) {
			err(_("Cannot have module options with attach (-A).\n"));
			usage(argv[0],1);
		} else {
			unsigned start_idx = 3;	/* reserve three slots in modoptions[] */
			while (optind < argc && start_idx + 1 < MAXMODOPTIONS)
				modoptions[start_idx++] = argv[optind++];
			modoptions[start_idx] = NULL;
		}
	}

	if (modpath == NULL || *modpath == '\0') {
		err(_("Need a module name or path to load.\n"));
		usage(argv[0],1);
	}

	if (init_stapio())
		exit(1);

	if (stp_main_loop()) {
		err(_("Couldn't enter main loop. Exiting.\n"));
		exit(1);
	}

	return 0;
}
Beispiel #2
0
int main(int argc, char **argv)
{
	setup_signals();
	parse_args(argc, argv);

	if (buffer_size)
		dbug(1, "Using a buffer of %u MB.\n", buffer_size);

	if (optind < argc) {
		parse_modpath(argv[optind++]);
		dbug(2, "modpath=\"%s\", modname=\"%s\"\n", modpath, modname);
	}

	if (optind < argc) {
		if (attach_mod) {
			err("ERROR: Cannot have module options with attach (-A).\n");
			usage(argv[0]);
		} else {
			unsigned start_idx = 3;	/* reserve three slots in modoptions[] */
			while (optind < argc && start_idx + 1 < MAXMODOPTIONS)
				modoptions[start_idx++] = argv[optind++];
			modoptions[start_idx] = NULL;
		}
	}

	if (modpath == NULL || *modpath == '\0') {
		err("ERROR: Need a module name or path to load.\n");
		usage(argv[0]);
	}

	if (init_stapio())
		exit(1);

	if (stp_main_loop()) {
		err("ERROR: Couldn't enter main loop. Exiting.\n");
		exit(1);
	}

	return 0;
}