-static void
-XkbAddDefaultDirectoriesToPath(void);
-
-/**
- * Init memory for include paths.
- */
-static Bool
-XkbInitIncludePath(void)
-{
- if (includePath)
- return True;
-
- szPath = PATH_CHUNK;
- includePath = calloc(szPath, sizeof(char *));
- if (!includePath)
- return False;
-
- XkbAddDefaultDirectoriesToPath();
- return True;
-}
-
-/**
- * Remove all entries from the global includePath.
- */
-static void
-XkbClearIncludePath(void)
-{
- size_t i;
-
- if (szPath > 0)
- {
- for (i = 0; i < nPathEntries; i++)
- {
- if (includePath[i] != NULL)
- {
- free(includePath[i]);
- includePath[i] = NULL;
- }
- }
- nPathEntries = 0;
- }
- noDefaultPath = True;
-}
-
-void
-XkbFreeIncludePath(void)
-{
- XkbClearIncludePath();
- free(includePath);
- includePath = NULL;
-}
-
-/**
- * Add the given path to the global includePath variable.
- * If dir is NULL, the includePath is emptied.
- */
-static Bool
-XkbAddDirectoryToPath(const char *dir)
-{
- int len;
-
- if (!XkbInitIncludePath())
- return False;
-
- if ((dir == NULL) || (dir[0] == '\0'))
- {
- XkbClearIncludePath();
- return True;
- }
-#ifdef __UNIXOS2__
- dir = (char *) __XOS2RedirRoot(dir);
-#endif
- len = strlen(dir);
- if (len + 2 >= PATH_MAX)
- { /* allow for '/' and at least one character */
- ERROR("Path entry (%s) too long (maxiumum length is %d)\n",
- dir, PATH_MAX - 3);
- return False;
- }
- if (nPathEntries >= szPath)
- {
- szPath += PATH_CHUNK;
- includePath = realloc(includePath, szPath * sizeof(char *));
- if (includePath == NULL)
- {
- WSGO("Allocation failed (includePath)\n");
- return False;
- }
- }
- includePath[nPathEntries] = strdup(dir);
- if (includePath[nPathEntries] == NULL)
- {
- WSGO("Allocation failed (includePath[%zd])\n", nPathEntries);
- return False;
- }
- nPathEntries++;
- return True;
-}
-
-static void
-XkbAddDefaultDirectoriesToPath(void)
-{
- if (!XkbInitIncludePath())
- return;
- if (noDefaultPath)
- return;
- XkbAddDirectoryToPath(DFLT_XKB_CONFIG_ROOT);
-}
-