diff options
author | Akira TAGOH <akira@tagoh.org> | 2014-03-27 15:10:44 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2017-11-07 15:24:54 +0900 |
commit | 9a0fcb948fe7346f6c68028b2e54ab600a2a2a6f (patch) | |
tree | 34cd373fb1529028fc8bb68526227e85ac520ad4 /fc-conflist | |
parent | 0c149259e4cc8070f6c8bf149290abb1367f340a (diff) |
Add the ruleset description support
Trying to address what these configuration files really do.
This change allows to see the short description that mention
the purpose of the content in the config file and obtain
them through API.
This change also encourage one who want to make some UI for
the user-specific configuration management. it is the main
purpose of this change for me though.
Aside from that, I've also made programs translatable. so
we see more dependencies on the build time for gettext,
and itstool to generate PO from xml.
Diffstat (limited to 'fc-conflist')
-rw-r--r-- | fc-conflist/Makefile.am | 60 | ||||
-rw-r--r-- | fc-conflist/fc-conflist.c | 142 | ||||
-rw-r--r-- | fc-conflist/fc-conflist.sgml | 135 |
3 files changed, 337 insertions, 0 deletions
diff --git a/fc-conflist/Makefile.am b/fc-conflist/Makefile.am new file mode 100644 index 00000000..6938ca7f --- /dev/null +++ b/fc-conflist/Makefile.am @@ -0,0 +1,60 @@ +# +# fontconfig/fc-conflist/Makefile.am +# +# Copyright © 2003 Keith Packard +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of the author(s) not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. The authors make no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +bin_PROGRAMS=fc-conflist + +DOC2MAN = docbook2man + +FC_VALIDATE_SRC=${top_srcdir}/fc-conflist + +SGML = ${FC_VALIDATE_SRC}/fc-conflist.sgml + +AM_CPPFLAGS=-I${top_srcdir} $(FREETYPE_CFLAGS) $(WARN_CFLAGS) + +BUILT_MANS=fc-conflist.1 + +if ENABLE_DOCS +man_MANS=${BUILT_MANS} +endif + +EXTRA_DIST=fc-conflist.sgml $(BUILT_MANS) + +CLEANFILES = + +fc_conflist_LDADD = ${top_builddir}/src/libfontconfig.la $(FREETYPE_LIBS) + +if USEDOCBOOK + +${man_MANS}: ${SGML} + $(AM_V_GEN) $(RM) $@; \ + $(DOC2MAN) ${SGML}; \ + $(RM) manpage.* + +all-local: $(man_MANS) + +CLEANFILES += $(man_MANS) +else +all-local: +endif + +-include $(top_srcdir)/git.mk diff --git a/fc-conflist/fc-conflist.c b/fc-conflist/fc-conflist.c new file mode 100644 index 00000000..d02273b7 --- /dev/null +++ b/fc-conflist/fc-conflist.c @@ -0,0 +1,142 @@ +/* + * fontconfig/fc-conflist/fc-conflist.c + * + * Copyright © 2003 Keith Packard + * Copyright © 2014 Red Hat, Inc. + * Red Hat Author(s): Akira TAGOH + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author(s) not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#else +#ifdef linux +#define HAVE_GETOPT_LONG 1 +#endif +#define HAVE_GETOPT 1 +#endif + +#include <fontconfig/fontconfig.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(x) (dgettext(GETTEXT_PACKAGE, x)) +#else +#define dgettext(d, s) (s) +#define _(x) (x) +#endif + +#ifndef HAVE_GETOPT +#define HAVE_GETOPT 0 +#endif +#ifndef HAVE_GETOPT_LONG +#define HAVE_GETOPT_LONG 0 +#endif + +#if HAVE_GETOPT_LONG +#undef _GNU_SOURCE +#define _GNU_SOURCE +#include <getopt.h> +static const struct option longopts[] = { + {"version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {NULL,0,0,0}, +}; +#else +#if HAVE_GETOPT +extern char *optarg; +extern int optind, opterr, optopt; +#endif +#endif + +static void +usage (char *program, int error) +{ + FILE *file = error ? stderr : stdout; +#if HAVE_GETOPT_LONG + fprintf (file, _("usage: %s [-Vh] [--version] [--help]\n"), + program); +#else + fprintf (file, _("usage: %s [-Vh]\n"), + program); +#endif + fprintf (file, _("Show the ruleset files information on the system\n")); + fprintf (file, "\n"); +#if HAVE_GETOPT_LONG + fprintf (file, _(" -V, --version display font config version and exit\n")); + fprintf (file, _(" -h, --help display this help and exit\n")); +#else + fprintf (file, _(" -V (version) display font config version and exit\n")); + fprintf (file, _(" -h (help) display this help and exit\n")); +#endif + exit (error); +} + +int +main (int argc, char **argv) +{ + FcConfig *config; + FcConfigFileInfoIter iter; + +#if HAVE_GETOPT_LONG || HAVE_GETOPT + int c; + +#if HAVE_GETOPT_LONG + while ((c = getopt_long (argc, argv, "Vh", longopts, NULL)) != -1) +#else + while ((c = getopt (argc, argv, "Vh")) != -1) +#endif + { + switch (c) { + case 'V': + fprintf (stderr, "fontconfig version %d.%d.%d\n", + FC_MAJOR, FC_MINOR, FC_REVISION); + exit (0); + case 'h': + usage (argv[0], 0); + default: + usage (argv[0], 1); + } + } +#endif + + config = FcConfigGetCurrent (); + FcConfigFileInfoIterInit (config, &iter); + do + { + FcChar8 *name, *desc; + FcBool enabled; + + if (FcConfigFileInfoIterGet (config, &iter, &name, &desc, &enabled)) + { + printf ("%c %s: %s\n", enabled ? '+' : '-', name, desc); + FcStrFree (name); + FcStrFree (desc); + } + } while (FcConfigFileInfoIterNext (config, &iter)); + + FcFini (); + + return 0; +} diff --git a/fc-conflist/fc-conflist.sgml b/fc-conflist/fc-conflist.sgml new file mode 100644 index 00000000..a82dd1cc --- /dev/null +++ b/fc-conflist/fc-conflist.sgml @@ -0,0 +1,135 @@ +<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [ + +<!-- Process this file with docbook-to-man to generate an nroff manual + page: `docbook-to-man manpage.sgml > manpage.1'. You may view + the manual page with: `docbook-to-man manpage.sgml | nroff -man | + less'. A typical entry in a Makefile or Makefile.am is: + +manpage.1: manpage.sgml + docbook-to-man $< > $@ + + + The docbook-to-man binary is found in the docbook-to-man package. + Please remember that if you create the nroff version in one of the + debian/rules file targets (such as build), you will need to include + docbook-to-man in your Build-Depends control field. + + --> + + <!-- Fill in your name for FIRSTNAME and SURNAME. --> + <!ENTITY dhfirstname "<firstname>Akira</firstname>"> + <!ENTITY dhsurname "<surname>TAGOH</surname>"> + <!-- Please adjust the date whenever revising the manpage. --> + <!ENTITY dhdate "<date>Apr 1, 2014</date>"> + <!-- SECTION should be 1-8, maybe w/ subsection other parameters are + allowed: see man(7), man(1). --> + <!ENTITY dhsection "<manvolnum>1</manvolnum>"> + <!ENTITY dhemail "<email>akira@tagoh.org</email>"> + <!ENTITY dhusername "Akira TAGOH"> + <!ENTITY dhucpackage "<refentrytitle>fc-conflist</refentrytitle>"> + <!ENTITY dhpackage "fc-conflist"> + + <!ENTITY gnu "<acronym>GNU</acronym>"> + <!ENTITY gpl "&gnu; <acronym>GPL</acronym>"> +]> + +<refentry> + <refentryinfo> + <address> + &dhemail; + </address> + <author> + &dhfirstname; + &dhsurname; + </author> + <copyright> + <year>2014</year> + <holder>&dhusername;</holder> + </copyright> + &dhdate; + </refentryinfo> + <refmeta> + &dhucpackage; + + &dhsection; + </refmeta> + <refnamediv> + <refname>&dhpackage;</refname> + + <refpurpose>Show the ruleset files information on the system</refpurpose> + </refnamediv> + <refsynopsisdiv> + <cmdsynopsis> + <command>&dhpackage;</command> + + <arg><option>-Vh</option></arg> + <sbr> + <arg><option>--version</option></arg> + <arg><option>--help</option></arg> + + </cmdsynopsis> + </refsynopsisdiv> + <refsect1> + <title>DESCRIPTION</title> + + <para><command>&dhpackage;</command> shows the ruleset files' information + being installed on the system.</para> + + </refsect1> + <refsect1> + <title>OPTIONS</title> + + <para>This program follows the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below.</para> + + <variablelist> + <varlistentry> + <term><option>-V</option> + <option>--version</option> + </term> + <listitem> + <para>Show version of the program and exit.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>-h</option> + <option>--help</option> + </term> + <listitem> + <para>Show summary of options.</para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1> + <title>RETURN CODES</title> + <para><command>fc-conflist</command> returns error code 0 for successful parsing, + or 1 if any errors occured or if at least one font face could not be opened.</para> + </refsect1> + + <refsect1> + <title>AUTHOR</title> + + <para>This manual page was updated by &dhusername; &dhemail;.</para> + + </refsect1> +</refentry> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:2 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:nil +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +--> |