|
Packit |
352660 |
/*
|
|
Packit |
352660 |
* fontconfig/fc-conflist/fc-conflist.c
|
|
Packit |
352660 |
*
|
|
Packit |
352660 |
* Copyright © 2003 Keith Packard
|
|
Packit |
352660 |
* Copyright © 2014 Red Hat, Inc.
|
|
Packit |
352660 |
* Red Hat Author(s): Akira TAGOH
|
|
Packit |
352660 |
*
|
|
Packit |
352660 |
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit |
352660 |
* documentation for any purpose is hereby granted without fee, provided that
|
|
Packit |
352660 |
* the above copyright notice appear in all copies and that both that
|
|
Packit |
352660 |
* copyright notice and this permission notice appear in supporting
|
|
Packit |
352660 |
* documentation, and that the name of the author(s) not be used in
|
|
Packit |
352660 |
* advertising or publicity pertaining to distribution of the software without
|
|
Packit |
352660 |
* specific, written prior permission. The authors make no
|
|
Packit |
352660 |
* representations about the suitability of this software for any purpose. It
|
|
Packit |
352660 |
* is provided "as is" without express or implied warranty.
|
|
Packit |
352660 |
*
|
|
Packit |
352660 |
* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
Packit |
352660 |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
Packit |
352660 |
* EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
Packit |
352660 |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
Packit |
352660 |
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
Packit |
352660 |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
Packit |
352660 |
* PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
352660 |
*/
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
352660 |
#include <config.h>
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
#ifdef linux
|
|
Packit |
352660 |
#define HAVE_GETOPT_LONG 1
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
#define HAVE_GETOPT 1
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#include <fontconfig/fontconfig.h>
|
|
Packit |
352660 |
#include <stdio.h>
|
|
Packit |
352660 |
#include <unistd.h>
|
|
Packit |
352660 |
#include <stdlib.h>
|
|
Packit |
352660 |
#include <string.h>
|
|
Packit |
352660 |
#include <locale.h>
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#ifdef ENABLE_NLS
|
|
Packit |
352660 |
#include <libintl.h>
|
|
Packit |
352660 |
#define _(x) (dgettext(GETTEXT_PACKAGE, x))
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
#define dgettext(d, s) (s)
|
|
Packit |
352660 |
#define _(x) (x)
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#ifndef HAVE_GETOPT
|
|
Packit |
352660 |
#define HAVE_GETOPT 0
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
#ifndef HAVE_GETOPT_LONG
|
|
Packit |
352660 |
#define HAVE_GETOPT_LONG 0
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#if HAVE_GETOPT_LONG
|
|
Packit |
352660 |
#undef _GNU_SOURCE
|
|
Packit |
352660 |
#define _GNU_SOURCE
|
|
Packit |
352660 |
#include <getopt.h>
|
|
Packit |
352660 |
static const struct option longopts[] = {
|
|
Packit |
352660 |
{"version", 0, 0, 'V'},
|
|
Packit |
352660 |
{"help", 0, 0, 'h'},
|
|
Packit |
352660 |
{NULL,0,0,0},
|
|
Packit |
352660 |
};
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
#if HAVE_GETOPT
|
|
Packit |
352660 |
extern char *optarg;
|
|
Packit |
352660 |
extern int optind, opterr, optopt;
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
|
|
Packit |
352660 |
static void
|
|
Packit |
352660 |
usage (char *program, int error)
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
FILE *file = error ? stderr : stdout;
|
|
Packit |
352660 |
#if HAVE_GETOPT_LONG
|
|
Packit |
352660 |
fprintf (file, _("usage: %s [-Vh] [--version] [--help]\n"),
|
|
Packit |
352660 |
program);
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
fprintf (file, _("usage: %s [-Vh]\n"),
|
|
Packit |
352660 |
program);
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
fprintf (file, _("Show the ruleset files information on the system\n"));
|
|
Packit |
352660 |
fprintf (file, "\n");
|
|
Packit |
352660 |
#if HAVE_GETOPT_LONG
|
|
Packit |
352660 |
fprintf (file, _(" -V, --version display font config version and exit\n"));
|
|
Packit |
352660 |
fprintf (file, _(" -h, --help display this help and exit\n"));
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
fprintf (file, _(" -V (version) display font config version and exit\n"));
|
|
Packit |
352660 |
fprintf (file, _(" -h (help) display this help and exit\n"));
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
exit (error);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
|
|
Packit |
352660 |
int
|
|
Packit |
352660 |
main (int argc, char **argv)
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
FcConfig *config;
|
|
Packit |
352660 |
FcConfigFileInfoIter iter;
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#if HAVE_GETOPT_LONG || HAVE_GETOPT
|
|
Packit |
352660 |
int c;
|
|
Packit |
352660 |
|
|
Packit |
352660 |
setlocale (LC_ALL, "");
|
|
Packit |
352660 |
#if HAVE_GETOPT_LONG
|
|
Packit |
352660 |
while ((c = getopt_long (argc, argv, "Vh", longopts, NULL)) != -1)
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
while ((c = getopt (argc, argv, "Vh")) != -1)
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
switch (c) {
|
|
Packit |
352660 |
case 'V':
|
|
Packit |
352660 |
fprintf (stderr, "fontconfig version %d.%d.%d\n",
|
|
Packit |
352660 |
FC_MAJOR, FC_MINOR, FC_REVISION);
|
|
Packit |
352660 |
exit (0);
|
|
Packit |
352660 |
case 'h':
|
|
Packit |
352660 |
usage (argv[0], 0);
|
|
Packit |
352660 |
default:
|
|
Packit |
352660 |
usage (argv[0], 1);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
|
|
Packit |
352660 |
config = FcConfigGetCurrent ();
|
|
Packit |
352660 |
FcConfigFileInfoIterInit (config, &iter);
|
|
Packit |
352660 |
do
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
FcChar8 *name, *desc;
|
|
Packit |
352660 |
FcBool enabled;
|
|
Packit |
352660 |
|
|
Packit |
352660 |
if (FcConfigFileInfoIterGet (config, &iter, &name, &desc, &enabled))
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
printf ("%c %s: %s\n", enabled ? '+' : '-', name, desc);
|
|
Packit |
352660 |
FcStrFree (name);
|
|
Packit |
352660 |
FcStrFree (desc);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
} while (FcConfigFileInfoIterNext (config, &iter));
|
|
Packit |
352660 |
|
|
Packit |
352660 |
FcFini ();
|
|
Packit |
352660 |
|
|
Packit |
352660 |
return 0;
|
|
Packit |
352660 |
}
|