Example #1
0
int main(int argc, char *argv[])
{
    client_t *c;

    c = create_client(argv[0]);

    if (c == NULL) {
        fprintf(stderr, "Failed to create client.");
        exit(1);
    }

    parse_cmdline(c, argc, &argv[0]);
    create_mainloop(c);
    setup_signals(c);
    setup_input(c);

    if (c->glib)
        print(c, "Using GMainLoop...");
    else
        print(c, "Using pa_manloop...");

    run_mainloop(c);
    cleanup_input(c);
    destroy_client(c);

    return 0;
}
Example #2
0
int main(int argc, char **argv) {
    SDL_Init(0);

    if (!init()) {
        return 1;
    }

    run_mainloop();

    deinit();

    SDL_Quit();
}
Example #3
0
int main(int argc, char *argv[])
{
    mrp_context_t *ctx;

    ctx = create_context();

    setup_signals(ctx);
    create_ruleset(ctx);
    parse_cmdline(ctx, argc, argv);
    load_configuration(ctx);
    start_plugins(ctx);
    load_ruleset(ctx);
    prepare_ruleset(ctx);
    setup_logging(ctx);
    daemonize(ctx);
    run_mainloop(ctx);
    stop_plugins(ctx);

    cleanup_context(ctx);

    return 0;
}
Example #4
0
int main(int argc, char **argv)
{
	char *gsmtap_host = "127.0.0.1";
	int rc;
	int c, ret = 1;
	int skip_atr = 0;
	int keep_running = 0;
	int dump_usb = 0;
	int replay = 0;
	struct libusb_device_handle *devh;

	print_welcome();

	while (1) {
		int option_index = 0;

		c = getopt_long(argc, argv, "i:ahkd:r:", opts, &option_index);
		if (c == -1)
			break;
		switch (c) {
		case 'h':
			print_help();
			exit(0);
			break;
		case 'i':
			gsmtap_host = optarg;
			break;
		case 'a':
			skip_atr = 1;
			break;
		case 'k':
			keep_running = 1;
			break;
		case 'd':
			dump_usb = 1;
			dump_usb_file = fopen(optarg,"wb");
			break;
		case 'r':
			replay = 1;
			dump_usb_file =  fopen(optarg,"rb");
			printf("replaying file %s...\n",optarg);
			break;
		}
	}

	rc = libusb_init(NULL);
	if (rc < 0) {
		fprintf(stderr, "libusb initialization failed\n");
		goto close_exit;
	}

	g_gti = gsmtap_source_init(gsmtap_host, GSMTAP_UDP_PORT, 0);
	if (!g_gti) {
		perror("unable to open GSMTAP");
		goto close_exit;
	}
	gsmtap_source_add_sink(g_gti);

	as = apdu_split_init(&apdu_out_cb, NULL);
	if (!as)
		goto release_exit;

	if (replay) {
		printf("done replaying file...\n");
		replay_mainloop(dump_usb_file);
		fclose(dump_usb_file);
	}
	else
	{
		do {
			devh = libusb_open_device_with_vid_pid(NULL, SIMTRACE_USB_VENDOR, SIMTRACE_USB_PRODUCT);
			if (!devh) {
				fprintf(stderr, "can't open USB device\n");
				goto close_exit;
			}

			rc = libusb_claim_interface(devh, 0);
			if (rc < 0) {
				fprintf(stderr, "can't claim interface; rc=%d\n", rc);
				goto close_exit;
			}

			run_mainloop(devh);
			ret = 0;

			libusb_release_interface(devh, 0);
	close_exit:
			if (devh)
				libusb_close(devh);
			if (keep_running)
				sleep(1);
		} while (keep_running);
	}

release_exit:
	libusb_exit(NULL);
	return ret;
}