~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/lib/fontconfig/fc-list/fc-list.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $XFree86: xc/lib/fontconfig/fc-list/fc-list.c,v 1.6 2002/07/03 23:15:32 keithp Exp $
 
3
 *
 
4
 * Copyright � 2002 Keith Packard, member of The XFree86 Project, Inc.
 
5
 *
 
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.
 
15
 *
 
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.
 
23
 */
 
24
 
 
25
#include <fontconfig/fontconfig.h>
 
26
#include <stdio.h>
 
27
#include <unistd.h>
 
28
#include <stdlib.h>
 
29
#ifdef HAVE_CONFIG_H
 
30
#include <config.h>
 
31
#else
 
32
#ifdef linux
 
33
#define HAVE_GETOPT_LONG 1
 
34
#endif
 
35
#define HAVE_GETOPT 1
 
36
#endif
 
37
 
 
38
#ifndef HAVE_GETOPT
 
39
#define HAVE_GETOPT 0
 
40
#endif
 
41
#ifndef HAVE_GETOPT_LONG
 
42
#define HAVE_GETOPT_LONG 0
 
43
#endif
 
44
 
 
45
#if HAVE_GETOPT_LONG
 
46
#undef  _GNU_SOURCE
 
47
#define _GNU_SOURCE
 
48
#include <getopt.h>
 
49
const struct option longopts[] = {
 
50
    {"version", 0, 0, 'V'},
 
51
    {"verbose", 0, 0, 'v'},
 
52
    {"help", 0, 0, '?'},
 
53
    {NULL,0,0,0},
 
54
};
 
55
#else
 
56
#if HAVE_GETOPT
 
57
extern char *optarg;
 
58
extern int optind, opterr, optopt;
 
59
#endif
 
60
#endif
 
61
 
 
62
static void usage (char *program)
 
63
{
 
64
    fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [pattern] {element ...} \n",
 
65
             program);
 
66
    fprintf (stderr, "List fonts matching [pattern]\n");
 
67
    fprintf (stderr, "\n");
 
68
    fprintf (stderr, "  -v, --verbose        display status information while busy\n");
 
69
    fprintf (stderr, "  -V, --version        display font config version and exit\n");
 
70
    fprintf (stderr, "  -?, --help           display this help and exit\n");
 
71
    exit (1);
 
72
}
 
73
 
 
74
int
 
75
main (int argc, char **argv)
 
76
{
 
77
    int         verbose = 0;
 
78
    int         i;
 
79
    FcObjectSet *os = 0;
 
80
    FcFontSet   *fs;
 
81
    FcPattern   *pat;
 
82
#if HAVE_GETOPT_LONG || HAVE_GETOPT
 
83
    int         c;
 
84
 
 
85
#if HAVE_GETOPT_LONG
 
86
    while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
 
87
#else
 
88
    while ((c = getopt (argc, argv, "Vv?")) != -1)
 
89
#endif
 
90
    {
 
91
        switch (c) {
 
92
        case 'V':
 
93
            fprintf (stderr, "fontconfig version %d.%d.%d\n", 
 
94
                     FC_MAJOR, FC_MINOR, FC_REVISION);
 
95
            exit (0);
 
96
        case 'v':
 
97
            verbose = 1;
 
98
            break;
 
99
        default:
 
100
            usage (argv[0]);
 
101
        }
 
102
    }
 
103
    i = optind;
 
104
#else
 
105
    i = 1;
 
106
#endif
 
107
 
 
108
    if (!FcInit ())
 
109
    {
 
110
        fprintf (stderr, "Can't init font config library\n");
 
111
        return 1;
 
112
    }
 
113
    if (argv[i])
 
114
    {
 
115
        pat = FcNameParse ((FcChar8 *) argv[i]);
 
116
        while (argv[++i])
 
117
        {
 
118
            if (!os)
 
119
                os = FcObjectSetCreate ();
 
120
            FcObjectSetAdd (os, argv[i]);
 
121
        }
 
122
    }
 
123
    else
 
124
        pat = FcPatternCreate ();
 
125
    
 
126
    if (!os)
 
127
        os = FcObjectSetBuild (FC_FAMILY, FC_STYLE, 0);
 
128
    fs = FcFontList (0, pat, os);
 
129
    if (pat)
 
130
        FcPatternDestroy (pat);
 
131
 
 
132
    if (fs)
 
133
    {
 
134
        int     j;
 
135
 
 
136
        for (j = 0; j < fs->nfont; j++)
 
137
        {
 
138
            FcChar8 *font;
 
139
            FcChar8 *file;
 
140
 
 
141
            font = FcNameUnparse (fs->fonts[j]);
 
142
            if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch)
 
143
                printf ("%s: ", file);
 
144
            printf ("%s\n", font);
 
145
            free (font);
 
146
        }
 
147
        FcFontSetDestroy (fs);
 
148
    }
 
149
    return 0;
 
150
}