Ejemplo n.º 1
0
Archivo: qrview.c Proyecto: n13l/qrview
int
main(int argc, char *argv[]) 
{
	QRcode *qr = NULL;
#ifdef CONFIG_WINDOWS
	win32_io_init();
#endif

	while ((opt = getopt_long(argc, argv, opt_cmd, opt_long, NULL)) >= 0) {
		switch (opt) {
		case OPT_HELP:
		case '?':
			usage(0);
			break;
                case OPT_NAME:
                        name = strdup(optarg);
			break;
		case OPT_VERSION:
			version();
			exit(EXIT_SUCCESS);
		break;
		case OPT_QR_SIZE:
			qr_size = atoi(optarg);
		break;
		case OPT_TIMEOUT:
			timeout = atoi(optarg);
			break;
		case OPT_ALPHA:
			alpha_max = atoi(optarg);
			if (alpha_max > 255)
				alpha_max = 255;
			if (alpha_max < 0)
				alpha_max = 0;
		break;
		default:
		if (app->num_cmds >= MAX_CMDS)
			giveup("Too many commands specified");
			app->cmd[app->num_cmds] = opt;
			app->arg[app->num_cmds] = optarg;
			app->num_cmds++;
		}
	}

	if (optind + 1 != argc)
		usage(2);

	if (!(uri = argv[argc - 1]))
		usage(2);

	if (lock_instance())
		goto exit;

	qr = QRcode_encodeString8bit(uri , QR_MODE_8, QR_ECLEVEL_H);
	if (qr == NULL)
		goto exit;

        struct surface surface = (struct surface) {
		.width = qr->width,
		.data  = qr->data
	};

	main_window (argc, argv, &surface);

exit:
	if (qr)
		QRcode_free(qr);
	unlock_instance();
	return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
 /// \brief Unlocks the given lockable instance
 static void lock(lock_type &c)
 {
     unlock_instance(c);
 }