コード例 #1
0
ファイル: xcmsdb.c プロジェクト: Bluerise/bitrig-xenocara
int
main(int argc, char *argv[])
{
    Display *dpy;
    int i;
    char *displayname = NULL;
    char *filename = NULL;
    int query = 0;
    int remove = 0;
    int load = 0;
    int color = -1;
    int targetFormat = 32;

    ProgramName = argv[0];

    for (i = 1; i < argc; i++) {
	char *arg = argv[i];

	if (arg[0] == '-') {
	    if (arg[1] == '\0') {
		filename = NULL;
		continue;
	    } else if (optionmatch ("-help", arg, 1)) {
		Syntax ();
		/* doesn't return */
	    } else if (optionmatch ("-display", arg, 1)) {
		if (++i >= argc) Syntax ();
		displayname = argv[i];
		continue;
	    } else if (optionmatch ("-format", arg, 1)) {
		if (++i >= argc) Syntax ();
		targetFormat = atoi(argv[i]);
		if (targetFormat != 32 && targetFormat != 16 &&
			targetFormat != 8) Syntax();
		continue;
	    } else if (optionmatch ("-query", arg, 1)) {
		query = 1;
		continue;
	    } else if (optionmatch ("-remove", arg, 1)) {
		remove = 1;
		continue;
#ifdef GRAY
	    } else if (optionmatch ("-color", arg, 1)) {
		color = 1;
		continue;
	    } else if (optionmatch ("-gray", arg, 1)) {
		color = 0;
		continue;
#endif /* GRAY */
	    }
	    Syntax ();
	} else {
	    load = 1;
	    filename = arg;
	}
    }

    /* Open display  */ 
    if (!(dpy = XOpenDisplay (displayname))) {
      fprintf (stderr, "%s:  Can't open display '%s'\n",
	       ProgramName, XDisplayName(displayname));
      exit (1);
    }

    if (query || remove) {
	load = 0;
    }

    if (load) {
	LoadSCCData(dpy, DefaultScreen(dpy), filename, targetFormat);
    }

    if (query) {
	if (color != 0)
	    QuerySCCDataRGB(dpy, RootWindow(dpy, DefaultScreen(dpy)));
#ifdef GRAY
	if (color != 1)
	    QuerySCCDataGray(dpy, RootWindow(dpy, DefaultScreen(dpy)));
#endif /* GRAY */
    }

    if (remove) {
	RemoveSCCData(dpy, RootWindow(dpy, DefaultScreen(dpy)), color);
    }

    XCloseDisplay(dpy);
    exit (0);
    /*NOTREACHED*/
}
コード例 #2
0
ファイル: stub.c プロジェクト: amadvance/advancemame
int main(int argc, char* argv[])
{
	char config[128];
	int arg_load;
	unsigned i;

	printf(OEM_PRODUCT_STR " by " OEM_VENDOR_STR " v" OEM_VERSION_STR "\n");

	strcpy(config, "vbe.rc");

	arg_load = 0;
	for(i=1;i<argc;++i) {
		const char* tok = argv[i];
		if (optionmatch(tok, "l")) {
			arg_load = 1;
		} else if (optionmatch(tok, "c")) {
			tok = argv[++i];
			if (!tok) {
				printf("Missing config file path\n");
				exit(EXIT_FAILURE);
			}
			strcpy(config, tok);
		} else {
			printf("Unknown option %s\n", tok);
			exit(EXIT_FAILURE);
		}
	}

	if (!arg_load) {
		printf(
		"Usage:\n"
		"    vbe32 [/l] [/c CONFIG]\n"
		"Commands:\n"
		"    /l         Load the TSR\n"
		"Options:\n"
		"    /c CONFIG  Use this config file instead of vbe.rc\n"
		);

		return EXIT_SUCCESS;
	}

	if (detect() != 0) {
		exit(EXIT_FAILURE);
	}

	if (vbe_init(config) != 0) {
		exit(EXIT_FAILURE);
	}

#if 1
	if (install() != 0) {
		exit(EXIT_FAILURE);
	}

	__djgpp_exception_toggle();
	keep(0, 0);
#else
	{
		_go32_dpmi_registers r;
		r.x.ax = 0x4F02;
		r.x.bx = 0x4103;
		vbe_service(&r);
	}
	printf("Exit\n");
#endif

	return EXIT_SUCCESS;
}