Ejemplo n.º 1
0
/**
 * Retrieve xkb values from the XKB_RULES_NAMES property and store their
 * contents in svValues.
 * If the property cannot be read, the built-in defaults are used.
 *
 * @return True.
 */
Bool
getServerValues(void)
{
    XkbRF_VarDefsRec vd;
    char *tmp = NULL;

    if (!XkbRF_GetNamesProp(dpy, &tmp, &vd) || !tmp)
    {
        VMSG1(3, "Couldn't interpret %s property\n", _XKB_RF_NAMES_PROP_ATOM);
        tmp = DFLT_XKB_RULES_FILE;
        vd.model = DFLT_XKB_MODEL;
        vd.layout = DFLT_XKB_LAYOUT;
        vd.variant = NULL;
        vd.options = NULL;
        VMSG3(3, "Use defaults: rules - '%s' model - '%s' layout - '%s'\n",
              tmp, vd.model, vd.layout);
    }
    if (tmp)
        trySetString(&settings.rules, tmp, FROM_SERVER);
    if (vd.model)
        trySetString(&settings.model, vd.model, FROM_SERVER);
    if (vd.layout)
        trySetString(&settings.layout, vd.layout, FROM_SERVER);
    if (vd.variant)
        trySetString(&settings.variant, vd.variant, FROM_SERVER);
    if ((vd.options) && (!clearOptions))
    {
        addStringToOptions(vd.options, &options);
        XFree(vd.options);
    }
    return True;
}
Ejemplo n.º 2
0
FILE *
findFileInPath(char *name, char *subdir)
{
    register int i;
    char buf[PATH_MAX];
    FILE *fp;

    if (name[0] == '/')
    {
        fp = fopen(name, "r");
        if ((verbose > 7) || ((!fp) && (verbose > 0)))
            MSG2("%s file %s\n", (fp ? "Found" : "Didn't find"), name);
        return fp;
    }
    for (i = 0; (i < numInclPath); i++)
    {
        if ((strlen(inclPath[i]) + strlen(subdir) + strlen(name) + 2) >
            PATH_MAX)
        {
            VMSG3(0, "Path too long (%s/%s%s). Ignored.\n", inclPath[i],
                  subdir, name);
            continue;
        }
        sprintf(buf, "%s/%s%s", inclPath[i], subdir, name);
        fp = fopen(name, "r");
        if ((verbose > 7) || ((!fp) && (verbose > 5)))
            MSG2("%s file %s\n", (fp ? "Found" : "Didn't find"), buf);
        if (fp != NULL)
            return fp;
    }
    return NULL;
}