2 * $XFree86: xc/lib/fontconfig/fc-cache/fc-cache.c,v 1.2 2002/02/15 07:36:14 keithp Exp $
4 * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
25 #include <fontconfig/fontconfig.h>
32 #define HAVE_GETOPT_LONG 1
40 #ifndef HAVE_GETOPT_LONG
41 #define HAVE_GETOPT_LONG 0
48 const struct option longopts[] = {
49 {"version", 0, 0, 'V'},
50 {"verbose", 0, 0, 'v'},
57 extern int optind, opterr, optopt;
64 fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [dirs]\n",
66 fprintf (stderr, "Build font information caches in [dirs]\n"
67 "(all directories in font configuration by default).\n");
68 fprintf (stderr, "\n");
69 fprintf (stderr, " -v, --verbose display status information while busy\n");
70 fprintf (stderr, " -V, --version display font config version and exit\n");
71 fprintf (stderr, " -?, --help display this help and exit\n");
76 main (int argc, char **argv)
83 #if HAVE_GETOPT_LONG || HAVE_GETOPT
87 while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
89 while ((c = getopt (argc, argv, "Vv?")) != -1)
94 fprintf (stderr, "fontconfig version %d.%d.%d\n",
95 FC_MAJOR, FC_MINOR, FC_REVISION);
109 if (!FcInitConfig ())
111 fprintf (stderr, "Can't init font config library\n");
115 dirs = (FcChar8 **) (argv+i);
117 dirs = FcConfigGetDirs (0);
119 * Now scan all of the directories into separate databases
120 * and write out the results
122 while (dirs && *dirs)
125 printf ("%s: Scanning directory \"%s\"\n", argv[0], *dirs);
126 set = FcFontSetCreate ();
129 fprintf (stderr, "Out of memory in \"%s\"\n", *dirs);
134 if (!FcDirScan (set, 0, FcConfigGetBlanks (0), *dirs, FcTrue))
136 fprintf (stderr, "Can't scan directory \"%s\"\n", *dirs);
142 printf ("%s: Saving %d font names for \"%s\"\n",
143 argv[0], set->nfont, *dirs);
144 if (!FcDirSave (set, *dirs))
146 fprintf (stderr, "Can't save cache in \"%s\"\n", *dirs);
150 FcFontSetDestroy (set);
155 printf ("%s: %s\n", argv[0], ret ? "failed" : "succeeded");