listing.c revision 34345a63
1f46a6179Smrg/************************************************************
2f46a6179Smrg Copyright 1996 by Silicon Graphics Computer Systems, Inc.
3f46a6179Smrg
4f46a6179Smrg Permission to use, copy, modify, and distribute this
5f46a6179Smrg software and its documentation for any purpose and without
6f46a6179Smrg fee is hereby granted, provided that the above copyright
7f46a6179Smrg notice appear in all copies and that both that copyright
8f46a6179Smrg notice and this permission notice appear in supporting
9f46a6179Smrg documentation, and that the name of Silicon Graphics not be
10f46a6179Smrg used in advertising or publicity pertaining to distribution
11f46a6179Smrg of the software without specific prior written permission.
12f46a6179Smrg Silicon Graphics makes no representation about the suitability
13f46a6179Smrg of this software for any purpose. It is provided "as is"
14f46a6179Smrg without any express or implied warranty.
15f46a6179Smrg
16f46a6179Smrg SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17f46a6179Smrg SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18f46a6179Smrg AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19f46a6179Smrg GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20f46a6179Smrg DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21f46a6179Smrg DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22f46a6179Smrg OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23f46a6179Smrg THE USE OR PERFORMANCE OF THIS SOFTWARE.
24f46a6179Smrg
25f46a6179Smrg ********************************************************/
26f46a6179Smrg/***********************************************************
27f46a6179Smrg
28f46a6179SmrgCopyright 1988, 1998  The Open Group
29f46a6179Smrg
30f46a6179SmrgPermission to use, copy, modify, distribute, and sell this software and its
31f46a6179Smrgdocumentation for any purpose is hereby granted without fee, provided that
32f46a6179Smrgthe above copyright notice appear in all copies and that both that
33f46a6179Smrgcopyright notice and this permission notice appear in supporting
34f46a6179Smrgdocumentation.
35f46a6179Smrg
36f46a6179SmrgThe above copyright notice and this permission notice shall be included in
37f46a6179Smrgall copies or substantial portions of the Software.
38f46a6179Smrg
39f46a6179SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40f46a6179SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41f46a6179SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
42f46a6179SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
43f46a6179SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44f46a6179SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45f46a6179Smrg
46f46a6179SmrgExcept as contained in this notice, the name of The Open Group shall not be
47f46a6179Smrgused in advertising or otherwise to promote the sale, use or other dealings
48f46a6179Smrgin this Software without prior written authorization from The Open Group.
49f46a6179Smrg
50f46a6179Smrg
51f46a6179SmrgCopyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
52f46a6179Smrg
53f46a6179Smrg                        All Rights Reserved
54f46a6179Smrg
55f46a6179SmrgPermission to use, copy, modify, and distribute this software and its
56f46a6179Smrgdocumentation for any purpose and without fee is hereby granted,
57f46a6179Smrgprovided that the above copyright notice appear in all copies and that
58f46a6179Smrgboth that copyright notice and this permission notice appear in
59f46a6179Smrgsupporting documentation, and that the name of Digital not be
60f46a6179Smrgused in advertising or publicity pertaining to distribution of the
61f46a6179Smrgsoftware without specific, written prior permission.
62f46a6179Smrg
63f46a6179SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
64f46a6179SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
65f46a6179SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
66f46a6179SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
67f46a6179SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
68f46a6179SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
69f46a6179SmrgSOFTWARE.
70f46a6179Smrg
71f46a6179Smrg******************************************************************/
72f46a6179Smrg
73f46a6179Smrg#include <stdio.h>
74f46a6179Smrg#include <ctype.h>
75f46a6179Smrg#include <sys/types.h>
76f46a6179Smrg#include <sys/stat.h>
77f46a6179Smrg#include <X11/keysym.h>
78f46a6179Smrg
79f46a6179Smrg#if defined(sgi)
80f46a6179Smrg#include <malloc.h>
81f46a6179Smrg#endif
82f46a6179Smrg
83f46a6179Smrg#define	DEBUG_VAR listingDebug
84f46a6179Smrg#include "xkbcomp.h"
85f46a6179Smrg#include <stdlib.h>
8634345a63Smrg
87f46a6179Smrg#ifdef _POSIX_SOURCE
8834345a63Smrg# include <limits.h>
89f46a6179Smrg#else
9034345a63Smrg# define _POSIX_SOURCE
9134345a63Smrg# include <limits.h>
9234345a63Smrg# undef _POSIX_SOURCE
93f46a6179Smrg#endif
9434345a63Smrg
95f46a6179Smrg#ifndef PATH_MAX
96f46a6179Smrg#ifdef WIN32
97f46a6179Smrg#define PATH_MAX 512
98f46a6179Smrg#else
99f46a6179Smrg#include <sys/param.h>
100f46a6179Smrg#endif
101f46a6179Smrg#ifndef PATH_MAX
102f46a6179Smrg#ifdef MAXPATHLEN
103f46a6179Smrg#define PATH_MAX MAXPATHLEN
104f46a6179Smrg#else
105f46a6179Smrg#define PATH_MAX 1024
106f46a6179Smrg#endif
107f46a6179Smrg#endif
108f46a6179Smrg#endif
109f46a6179Smrg
110f46a6179Smrg#ifdef WIN32
11134345a63Smrg# include <windows.h>
11234345a63Smrg# define FileName(file) file.cFileName
11334345a63Smrg# undef TEXT
11434345a63Smrg# undef ALTERNATE
115f46a6179Smrg#else
11634345a63Smrg# include <dirent.h>
11734345a63Smrg# define FileName(file) file->d_name
118f46a6179Smrg#endif
119f46a6179Smrg
120f46a6179Smrg#include "xkbpath.h"
121f46a6179Smrg#include "parseutils.h"
122f46a6179Smrg#include "misc.h"
123f46a6179Smrg#include "tokens.h"
124f46a6179Smrg#include <X11/extensions/XKBgeom.h>
125f46a6179Smrg
126f46a6179Smrg#define	lowbit(x)	((x) & (-(x)))
127f46a6179Smrg
12834345a63Smrgunsigned int listingDebug;
12934345a63Smrg
13034345a63Smrgstatic int szListing = 0;
13134345a63Smrgstatic int nListed = 0;
13234345a63Smrgstatic int nFilesListed = 0;
133f46a6179Smrg
13434345a63Smrgtypedef struct _Listing
13534345a63Smrg{
13634345a63Smrg    char *file;
13734345a63Smrg    char *map;
138f46a6179Smrg} Listing;
139f46a6179Smrg
14034345a63Smrgstatic int szMapOnly;
14134345a63Smrgstatic int nMapOnly;
14234345a63Smrgstatic char **mapOnly;
143f46a6179Smrg
14434345a63Smrgstatic Listing *list = NULL;
145f46a6179Smrg
146f46a6179Smrg/***====================================================================***/
147f46a6179Smrg
148f46a6179Smrgint
149f46a6179SmrgAddMapOnly(char *map)
150f46a6179Smrg{
15134345a63Smrg    if (nMapOnly >= szMapOnly)
15234345a63Smrg    {
15334345a63Smrg        if (szMapOnly < 1)
15434345a63Smrg            szMapOnly = 5;
15534345a63Smrg        else
15634345a63Smrg            szMapOnly *= 2;
15734345a63Smrg        mapOnly = uTypedRealloc(list, szMapOnly, char *);
15834345a63Smrg        if (!mapOnly)
15934345a63Smrg        {
16034345a63Smrg            WSGO("Couldn't allocate list of maps\n");
16134345a63Smrg            return 0;
16234345a63Smrg        }
163f46a6179Smrg    }
16434345a63Smrg    mapOnly[nMapOnly++] = map;
165f46a6179Smrg    return 1;
166f46a6179Smrg}
167f46a6179Smrg
168f46a6179Smrgint
16934345a63SmrgAddListing(char *file, char *map)
170f46a6179Smrg{
17134345a63Smrg    if (nListed >= szListing)
17234345a63Smrg    {
17334345a63Smrg        if (szListing < 1)
17434345a63Smrg            szListing = 10;
17534345a63Smrg        else
17634345a63Smrg            szListing *= 2;
17734345a63Smrg        list = uTypedRealloc(list, szListing, Listing);
17834345a63Smrg        if (!list)
17934345a63Smrg        {
18034345a63Smrg            WSGO("Couldn't allocate list of files and maps\n");
18134345a63Smrg            ACTION("Exiting\n");
18234345a63Smrg            exit(1);
18334345a63Smrg        }
184f46a6179Smrg    }
185f46a6179Smrg
18634345a63Smrg    list[nListed].file = file;
18734345a63Smrg    list[nListed].map = map;
188f46a6179Smrg    nListed++;
18934345a63Smrg    if (file != NULL)
19034345a63Smrg        nFilesListed++;
191f46a6179Smrg    return 1;
192f46a6179Smrg}
193f46a6179Smrg
194f46a6179Smrg/***====================================================================***/
195f46a6179Smrg
196f46a6179Smrgstatic void
19734345a63SmrgListFile(FILE * outFile, char *fileName, XkbFile * map)
198f46a6179Smrg{
19934345a63Smrg    register unsigned flags;
20034345a63Smrg    char *mapName;
20134345a63Smrg
20234345a63Smrg    flags = map->flags;
20334345a63Smrg    if ((flags & XkbLC_Hidden) && (!(verboseLevel & WantHiddenMaps)))
20434345a63Smrg        return;
20534345a63Smrg    if ((flags & XkbLC_Partial) && (!(verboseLevel & WantPartialMaps)))
20634345a63Smrg        return;
20734345a63Smrg    if (verboseLevel & WantLongListing)
20834345a63Smrg    {
20934345a63Smrg        fprintf(outFile, (flags & XkbLC_Hidden) ? "h" : "-");
21034345a63Smrg        fprintf(outFile, (flags & XkbLC_Default) ? "d" : "-");
21134345a63Smrg        fprintf(outFile, (flags & XkbLC_Partial) ? "p" : "-");
21234345a63Smrg        fprintf(outFile, "----- ");
21334345a63Smrg        if (map->type == XkmSymbolsIndex)
21434345a63Smrg        {
21534345a63Smrg            fprintf(outFile, (flags & XkbLC_AlphanumericKeys) ? "a" : "-");
21634345a63Smrg            fprintf(outFile, (flags & XkbLC_ModifierKeys) ? "m" : "-");
21734345a63Smrg            fprintf(outFile, (flags & XkbLC_KeypadKeys) ? "k" : "-");
21834345a63Smrg            fprintf(outFile, (flags & XkbLC_FunctionKeys) ? "f" : "-");
21934345a63Smrg            fprintf(outFile, (flags & XkbLC_AlternateGroup) ? "g" : "-");
22034345a63Smrg            fprintf(outFile, "--- ");
22134345a63Smrg        }
22234345a63Smrg        else
22334345a63Smrg            fprintf(outFile, "-------- ");
224f46a6179Smrg    }
22534345a63Smrg    mapName = map->name;
22634345a63Smrg    if ((!(verboseLevel & WantFullNames)) && ((flags & XkbLC_Default) != 0))
22734345a63Smrg        mapName = NULL;
22834345a63Smrg    if (dirsToStrip > 0)
22934345a63Smrg    {
23034345a63Smrg        char *tmp, *last;
23134345a63Smrg        int i;
23234345a63Smrg        for (i = 0, tmp = last = fileName; (i < dirsToStrip) && tmp; i++)
23334345a63Smrg        {
23434345a63Smrg            last = tmp;
23534345a63Smrg            tmp = strchr(tmp, '/');
23634345a63Smrg            if (tmp != NULL)
23734345a63Smrg                tmp++;
23834345a63Smrg        }
23934345a63Smrg        fileName = (tmp ? tmp : last);
240f46a6179Smrg    }
241f46a6179Smrg    if (mapName)
24234345a63Smrg        fprintf(outFile, "%s(%s)\n", fileName, mapName);
24334345a63Smrg    else
24434345a63Smrg        fprintf(outFile, "%s\n", fileName);
245f46a6179Smrg    return;
246f46a6179Smrg}
247f46a6179Smrg
248f46a6179Smrg/***====================================================================***/
249f46a6179Smrg
250f46a6179Smrgstatic int
25134345a63SmrgAddDirectory(char *head, char *ptrn, char *rest, char *map)
252f46a6179Smrg{
253f46a6179Smrg#ifdef WIN32
25434345a63Smrg    HANDLE dirh;
25534345a63Smrg    WIN32_FIND_DATA file;
256f46a6179Smrg#else
25734345a63Smrg    DIR *dirp;
25834345a63Smrg    struct dirent *file;
259f46a6179Smrg#endif
26034345a63Smrg    int nMatch;
26134345a63Smrg
26234345a63Smrg    if (map == NULL)
26334345a63Smrg    {
26434345a63Smrg        char *tmp = ptrn;
26534345a63Smrg        if ((rest == NULL) && (ptrn != NULL) && (strchr(ptrn, '/') == NULL))
26634345a63Smrg        {
26734345a63Smrg            tmp = ptrn;
26834345a63Smrg            map = strchr(ptrn, '(');
26934345a63Smrg        }
27034345a63Smrg        else if ((rest == NULL) && (ptrn == NULL) &&
27134345a63Smrg                 (head != NULL) && (strchr(head, '/') == NULL))
27234345a63Smrg        {
27334345a63Smrg            tmp = head;
27434345a63Smrg            map = strchr(head, '(');
27534345a63Smrg        }
27634345a63Smrg        if (map != NULL)
27734345a63Smrg        {
27834345a63Smrg            tmp = strchr(tmp, ')');
27934345a63Smrg            if ((tmp == NULL) || (tmp[1] != '\0'))
28034345a63Smrg            {
28134345a63Smrg                ERROR1("File and map must have the format file(map)\n");
28234345a63Smrg                return 0;
28334345a63Smrg            }
28434345a63Smrg            *map = '\0';
28534345a63Smrg            map++;
28634345a63Smrg            *tmp = '\0';
28734345a63Smrg        }
288f46a6179Smrg    }
289f46a6179Smrg#ifdef WIN32
290f46a6179Smrg    if ((dirh = FindFirstFile("*.*", &file)) == INVALID_HANDLE_VALUE)
29134345a63Smrg        return 0;
292f46a6179Smrg#else
29334345a63Smrg    if ((dirp = opendir((head ? head : "."))) == NULL)
29434345a63Smrg        return 0;
29534345a63Smrg    nMatch = 0;
296f46a6179Smrg#endif
297f46a6179Smrg#ifdef WIN32
298f46a6179Smrg    do
299f46a6179Smrg#else
30034345a63Smrg    while ((file = readdir(dirp)) != NULL)
301f46a6179Smrg#endif
302f46a6179Smrg    {
30334345a63Smrg        char *tmp, *filename;
30434345a63Smrg        struct stat sbuf;
30534345a63Smrg
30634345a63Smrg        filename = FileName(file);
30734345a63Smrg        if (!filename || filename[0] == '.')
30834345a63Smrg            continue;
30934345a63Smrg        if (ptrn && (!XkbNameMatchesPattern(filename, ptrn)))
31034345a63Smrg            continue;
31134345a63Smrg        tmp =
31234345a63Smrg            (char *) uAlloc((head ? strlen(head) : 0) + strlen(filename) + 2);
31334345a63Smrg        if (!tmp)
31434345a63Smrg            continue;
31534345a63Smrg        sprintf(tmp, "%s%s%s", (head ? head : ""), (head ? "/" : ""),
31634345a63Smrg                filename);
31734345a63Smrg        if (stat(tmp, &sbuf) < 0)
31834345a63Smrg        {
31934345a63Smrg            uFree(tmp);
32034345a63Smrg            continue;
32134345a63Smrg        }
32234345a63Smrg        if (((rest != NULL) && (!S_ISDIR(sbuf.st_mode))) ||
32334345a63Smrg            ((map != NULL) && (S_ISDIR(sbuf.st_mode))))
32434345a63Smrg        {
32534345a63Smrg            uFree(tmp);
32634345a63Smrg            continue;
32734345a63Smrg        }
32834345a63Smrg        if (S_ISDIR(sbuf.st_mode))
32934345a63Smrg        {
33034345a63Smrg            if ((rest != NULL) || (verboseLevel & ListRecursive))
33134345a63Smrg                nMatch += AddDirectory(tmp, rest, NULL, map);
33234345a63Smrg        }
33334345a63Smrg        else
33434345a63Smrg            nMatch += AddListing(tmp, map);
335f46a6179Smrg    }
336f46a6179Smrg#ifdef WIN32
337f46a6179Smrg    while (FindNextFile(dirh, &file));
338f46a6179Smrg#endif
339f46a6179Smrg    return nMatch;
340f46a6179Smrg}
341f46a6179Smrg
342f46a6179Smrg/***====================================================================***/
343f46a6179Smrg
344f46a6179SmrgBool
345f46a6179SmrgAddMatchingFiles(char *head_in)
346f46a6179Smrg{
34734345a63Smrg    char *str, *head, *ptrn, *rest = NULL;
34834345a63Smrg
34934345a63Smrg    if (head_in == NULL)
35034345a63Smrg        return 0;
35134345a63Smrg    ptrn = NULL;
35234345a63Smrg    for (str = head_in; (*str != '\0') && (*str != '?') && (*str != '*');
35334345a63Smrg         str++)
35434345a63Smrg    {
35534345a63Smrg        if ((str != head_in) && (*str == '/'))
35634345a63Smrg            ptrn = str;
357f46a6179Smrg    }
35834345a63Smrg    if (*str == '\0')
35934345a63Smrg    {                           /* no wildcards */
36034345a63Smrg        head = head_in;
36134345a63Smrg        ptrn = NULL;
36234345a63Smrg        rest = NULL;
363f46a6179Smrg    }
36434345a63Smrg    else if (ptrn == NULL)
36534345a63Smrg    {                           /* no slash before the first wildcard */
36634345a63Smrg        head = NULL;
36734345a63Smrg        ptrn = head_in;
368f46a6179Smrg    }
36934345a63Smrg    else
37034345a63Smrg    {                           /* slash followed by wildcard */
37134345a63Smrg        head = head_in;
37234345a63Smrg        *ptrn = '\0';
37334345a63Smrg        ptrn++;
374f46a6179Smrg    }
37534345a63Smrg    if (ptrn)
37634345a63Smrg    {
37734345a63Smrg        rest = strchr(ptrn, '/');
37834345a63Smrg        if (rest != NULL)
37934345a63Smrg        {
38034345a63Smrg            *rest = '\0';
38134345a63Smrg            rest++;
38234345a63Smrg        }
383f46a6179Smrg    }
38434345a63Smrg    if (((rest && ptrn)
38534345a63Smrg         && ((strchr(ptrn, '(') != NULL) || (strchr(ptrn, ')') != NULL)))
38634345a63Smrg        || (head
38734345a63Smrg            && ((strchr(head, '(') != NULL) || (strchr(head, ')') != NULL))))
38834345a63Smrg    {
38934345a63Smrg        ERROR1("Files/maps to list must have the form file(map)\n");
39034345a63Smrg        ACTION("Illegal specifier ignored\n");
39134345a63Smrg        return 0;
392f46a6179Smrg    }
39334345a63Smrg    return AddDirectory(head, ptrn, rest, NULL);
394f46a6179Smrg}
395f46a6179Smrg
396f46a6179Smrg/***====================================================================***/
397f46a6179Smrg
398f46a6179Smrgstatic Bool
399f46a6179SmrgMapMatches(char *mapToConsider, char *ptrn)
400f46a6179Smrg{
40134345a63Smrg    int i;
40234345a63Smrg
40334345a63Smrg    if (ptrn != NULL)
40434345a63Smrg        return XkbNameMatchesPattern(mapToConsider, ptrn);
40534345a63Smrg    if (nMapOnly < 1)
40634345a63Smrg        return True;
40734345a63Smrg    for (i = 0; i < nMapOnly; i++)
40834345a63Smrg    {
40934345a63Smrg        if (XkbNameMatchesPattern(mapToConsider, mapOnly[i]))
41034345a63Smrg            return True;
411f46a6179Smrg    }
412f46a6179Smrg    return False;
413f46a6179Smrg}
414f46a6179Smrg
415f46a6179Smrgint
416f46a6179SmrgGenerateListing(char *out_name)
417f46a6179Smrg{
41834345a63Smrg    int i;
41934345a63Smrg    FILE *inputFile, *outFile;
42034345a63Smrg    XkbFile *rtrn, *mapToUse;
42134345a63Smrg    unsigned oldWarningLevel;
42234345a63Smrg    char *mapName;
42334345a63Smrg
42434345a63Smrg    if (nFilesListed < 1)
42534345a63Smrg    {
42634345a63Smrg        ERROR1("Must specify at least one file or pattern to list\n");
42734345a63Smrg        return 0;
428f46a6179Smrg    }
42934345a63Smrg    if ((!out_name) || ((out_name[0] == '-') && (out_name[1] == '\0')))
43034345a63Smrg        outFile = stdout;
43134345a63Smrg    else if ((outFile = fopen(out_name, "w")) == NULL)
43234345a63Smrg    {
43334345a63Smrg        ERROR1("Cannot open \"%s\" to write keyboard description\n",
43434345a63Smrg               out_name);
43534345a63Smrg        ACTION("Exiting\n");
43634345a63Smrg        return 0;
437f46a6179Smrg    }
438f46a6179Smrg#ifdef DEBUG
43934345a63Smrg    if (warningLevel > 9)
44034345a63Smrg        fprintf(stderr, "should list:\n");
441f46a6179Smrg#endif
44234345a63Smrg    for (i = 0; i < nListed; i++)
44334345a63Smrg    {
444f46a6179Smrg#ifdef DEBUG
44534345a63Smrg        if (warningLevel > 9)
44634345a63Smrg        {
44734345a63Smrg            fprintf(stderr, "%s(%s)\n",
44834345a63Smrg                    (list[i].file ? list[i].file : "*"),
44934345a63Smrg                    (list[i].map ? list[i].map : "*"));
45034345a63Smrg        }
451f46a6179Smrg#endif
45234345a63Smrg        oldWarningLevel = warningLevel;
45334345a63Smrg        warningLevel = 0;
45434345a63Smrg        if (list[i].file)
45534345a63Smrg        {
45634345a63Smrg            struct stat sbuf;
45734345a63Smrg
45834345a63Smrg            if (stat(list[i].file, &sbuf) < 0)
45934345a63Smrg            {
46034345a63Smrg                if (oldWarningLevel > 5)
46134345a63Smrg                    WARN1("Couldn't open \"%s\"\n", list[i].file);
46234345a63Smrg                continue;
46334345a63Smrg            }
46434345a63Smrg            if (S_ISDIR(sbuf.st_mode))
46534345a63Smrg            {
46634345a63Smrg                if (verboseLevel & ListRecursive)
46734345a63Smrg                    AddDirectory(list[i].file, NULL, NULL, NULL);
46834345a63Smrg                continue;
46934345a63Smrg            }
47034345a63Smrg
47134345a63Smrg            inputFile = fopen(list[i].file, "r");
47234345a63Smrg            if (!inputFile)
47334345a63Smrg            {
47434345a63Smrg                if (oldWarningLevel > 5)
47534345a63Smrg                    WARN1("Couldn't open \"%s\"\n", list[i].file);
47634345a63Smrg                continue;
47734345a63Smrg            }
47834345a63Smrg            setScanState(list[i].file, 1);
47934345a63Smrg            if (XKBParseFile(inputFile, &rtrn) && (rtrn != NULL))
48034345a63Smrg            {
48134345a63Smrg                mapName = list[i].map;
48234345a63Smrg                mapToUse = rtrn;
48334345a63Smrg                for (; mapToUse; mapToUse = (XkbFile *) mapToUse->common.next)
48434345a63Smrg                {
48534345a63Smrg                    if (!MapMatches(mapToUse->name, mapName))
48634345a63Smrg                        continue;
48734345a63Smrg                    ListFile(outFile, list[i].file, mapToUse);
48834345a63Smrg                }
48934345a63Smrg            }
49034345a63Smrg            fclose(inputFile);
49134345a63Smrg        }
49234345a63Smrg        warningLevel = oldWarningLevel;
493f46a6179Smrg    }
494f46a6179Smrg    return 1;
495f46a6179Smrg}
496