Пример #1
0
/*---------------------------------------------------------------------------
 Next part is the implementaion of all functions 
---------------------------------------------------------------------------*/
XF86ConfigPtr ReadConfigFile (char *filename) {
	const char *file = NULL; 
	XF86ConfigPtr conf;

	char CONFPATH[SIZE]=
		"%A,%R,/etc/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \
		"%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \
		"%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X";

	//===================================
	// X11 version 4.1 or higher...
	//-----------------------------------
	if (!(file = (char*)xf86openConfigFile (CONFPATH, filename, NULL))) {
		fprintf (stderr, "Unable to open config file\n");
		return(NULL);
	}

	if ((conf = (XF86ConfigPtr)xf86readConfigFile ()) == NULL) {
		fprintf (stderr, "Problem when parsing config file\n");
		xf86closeConfigFile ();
		return(NULL);
	}
	xf86closeConfigFile ();
	return(conf);
}
Пример #2
0
int
main (int argc, char *argv[])
{
	const char *filename;
	char *cmdline = NULL;
	XF86ConfigPtr conf;

	if (argc > 1)
	{
		cmdline = argv[1];
	}
	if ((filename = xf86openConfigFile (CONFPATH, cmdline, NULL)))
	{
		fprintf (stderr, "Opened %s for the config file\n", filename);
	}
	else
	{
		fprintf (stderr, "Unable to open config file\n");
		exit (1);
	}

	if ((conf = xf86readConfigFile ()) == NULL)
	{
		fprintf (stderr, "Problem when parsing config file\n");
	}
	else
	{
		fprintf (stderr, "Config file parsed OK\n");
	}
	xf86closeConfigFile ();

	if (argc > 2) {
		fprintf(stderr, "Writing config file to `%s'\n", argv[2]);
		xf86writeConfigFile (argv[2], conf);
	}
	exit(0);
}
Пример #3
0
Bool
winReadConfigfile()
{
    Bool retval = TRUE;
    char *filename, *dirname;
    MessageType filefrom = X_DEFAULT;
    MessageType dirfrom = X_DEFAULT;
    char *xf86ConfigFile = NULL;
    char *xf86ConfigDir = NULL;

    if (g_cmdline.configFile) {
        filefrom = X_CMDLINE;
        xf86ConfigFile = g_cmdline.configFile;
    }
    if (g_cmdline.configDir) {
        dirfrom = X_CMDLINE;
        xf86ConfigDir = g_cmdline.configDir;
    }

    /* Parse config file into data structure */
    xf86initConfigFiles();
    dirname = xf86openConfigDirFiles(CONFIGDIRPATH, xf86ConfigDir, PROJECTROOT);
    filename = xf86openConfigFile(CONFIGPATH, xf86ConfigFile, PROJECTROOT);

    /* Hack for backward compatibility */
    if (!filename && from == X_DEFAULT)
        filename = xf86openConfigFile(CONFIGPATH, "XF86Config", PROJECTROOT);

    if (filename) {
        winDebug ("Using config file: \"%s\"\n", filename);
    }
    else {
        ErrorF ("Unable to locate/open config file");
        if (xf86ConfigFile)
            ErrorF(": \"%s\"", xf86ConfigFile);
        ErrorF("\n");
    }
    if (dirname) {
        winDebug("Using config directory: \"%s\"\n", dirname);
    }
    else {
        winDebug("Unable to locate/open config directory");
        if (xf86ConfigDir)
            ErrorF(": \"%s\"", xf86ConfigDir);
        ErrorF("\n");
    }
    if (!filename && !dirname) {
        return FALSE;
    }
    free(filename);
    free(dirname);
    if ((g_xf86configptr = xf86readConfigFile()) == NULL) {
        ErrorF ("Problem parsing the config file\n");
        return FALSE;
    }
    xf86closeConfigFile();

    LogPrintMarkers();

    /* set options from data structure */

    if (g_xf86configptr->conf_layout_lst == NULL ||
        g_cmdline.screenname != NULL) {
        if (g_cmdline.screenname == NULL) {
            winDebug ("No Layout section. Using the first Screen section.\n");
        }
        if (!configImpliedLayout(&g_winConfigLayout,
                                 g_xf86configptr->conf_screen_lst)) {
            ErrorF ("Unable to determine the screen layout\n");
            return FALSE;
        }
    }
    else {
        /* Check if layout is given in the config file */
        if (g_xf86configptr->conf_flags != NULL) {
            char *dfltlayout = NULL;
            void *optlist = g_xf86configptr->conf_flags->flg_option_lst;

            if (optlist && winFindOption(optlist, "defaultserverlayout"))
                dfltlayout =
                    winSetStrOption(optlist, "defaultserverlayout", NULL);

            if (!configLayout(&g_winConfigLayout,
                              g_xf86configptr->conf_layout_lst, dfltlayout)) {
                ErrorF ("Unable to determine the screen layout\n");
                return FALSE;
            }
        }
        else {
            if (!configLayout(&g_winConfigLayout,
                              g_xf86configptr->conf_layout_lst, NULL)) {
                ErrorF ("Unable to determine the screen layout\n");
                return FALSE;
            }
        }
    }

    /* setup special config files */
    winConfigFiles();
    return retval;
}
Пример #4
0
/*
 * Implementation
 */
void
StartConfig(void)
{
    static int first = 1;
    Widget pane, top, bottom, cancel;
    const char *filename;

    if (!first)
	return;
    first = 0;

    /* Read initial configuration */
    if ((filename = xf86openConfigFile(getuid() == 0 ? CONFPATH : USER_CONFPATH,
				       XF86Config_path, NULL)) == NULL) {
	int length = XF86Config_path ? strlen(XF86Config_path) : -1;

	if (length > 2 &&
	    XF86Config_path[length - 2] == '-' &&
	    XF86Config_path[length - 1] == '4') {
	    XF86Config_path[length - 2] = '\0';
	    filename = xf86openConfigFile(getuid() == 0 ?
					  CONFPATH : USER_CONFPATH,
					  XF86Config_path, NULL);
	}

	if (filename == NULL) {
	    fprintf(stderr, "Cannot open config file.\n");
	    exit(1);
	}
    }
    XF86Config_path = (char *)filename;
    if ((XF86Config = xf86readConfigFile()) == NULL) {
	fprintf(stderr, "Problem when parsing config file\n");
	exit(1);
    }

    shell = XtCreatePopupShell("config", transientShellWidgetClass,
			       toplevel, NULL, 0);
    pane = XtCreateManagedWidget("pane", panedWidgetClass,
				 shell, NULL, 0);
    top = XtCreateManagedWidget("top", formWidgetClass,
				pane, NULL, 0);
    (void) XtCreateManagedWidget("label", labelWidgetClass,
				  top, NULL, 0);
    ident_widget = XtVaCreateManagedWidget("identifier", asciiTextWidgetClass,
					   top,
					   XtNeditType, XawtextEdit,
					   NULL, 0);
    configp = XtCreateManagedWidget("work", formWidgetClass,
				    pane, NULL, 0);
    current = XtCreateManagedWidget("wellcome", labelWidgetClass,
				    configp, NULL, 0);
    bottom = XtCreateManagedWidget("bottom", formWidgetClass,
				   pane, NULL, 0);
    back = XtCreateManagedWidget("back", commandWidgetClass,
				 bottom, NULL, 0);
    XtAddCallback(back, XtNcallback, BackCallback, (XtPointer)&xf86info);
    next = XtCreateManagedWidget("next", commandWidgetClass,
				 bottom, NULL, 0);
    XtAddCallback(next, XtNcallback, NextCallback, (XtPointer)&xf86info);
    ok = XtCreateManagedWidget("ok", commandWidgetClass,
			       bottom, NULL, 0);
    XtAddCallback(ok, XtNcallback, ApplyCallback, (XtPointer)NULL);
    cancel = XtCreateManagedWidget("cancel", commandWidgetClass,
				   bottom, NULL, 0);
    XtAddCallback(cancel, XtNcallback, CloseCallback, (XtPointer)NULL);

    XtRealizeWidget(shell);

    XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1);
}