~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to general/g.mkfontcap/main.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 *****************************************************************************/
16
16
 
17
 
#define G_MKFONTCAP_MAIN 1
18
 
 
19
17
#include <stdio.h>
20
18
#include <stdlib.h>
21
19
#include <string.h>
25
23
#include <errno.h>
26
24
 
27
25
#include <grass/gis.h>
28
 
#include <grass/freetypecap.h>
 
26
#include <grass/fontcap.h>
 
27
#include <grass/glocale.h>
29
28
 
30
29
#include "local_proto.h"
31
30
 
 
31
char **searchdirs;
 
32
int numsearchdirs;
 
33
 
 
34
struct GFONT_CAP *fontcap;
 
35
int totalfonts;
 
36
int maxfonts;
 
37
 
32
38
static const char *standarddirs[] = {
33
39
    /* These are the directories that are searched for Freetype-compatible
34
40
     * font files by default. They may contain an environment variable 
55
61
 
56
62
    FILE *outstream;
57
63
    char *fontcapfile;
58
 
    struct stat status;
59
64
    int i;
60
65
 
61
66
    G_set_program_name(argv[0]);
63
68
    G_set_gisrc_mode(G_GISRC_MODE_MEMORY);
64
69
 
65
70
    module = G_define_module();
66
 
    module->keywords = "general";
 
71
    G_add_keyword(_("general"));
67
72
    module->description =
68
 
        "Generates the font configuration file by scanning various directories "
69
 
        "for fonts";
 
73
        _("Generates the font configuration file by scanning various directories "
 
74
          "for fonts.");
70
75
 
71
76
    overwrite = G_define_flag();
72
77
    overwrite->key = 'o';
73
78
    overwrite->description =
74
 
        "Overwrite font configuration file if already existing";
 
79
        _("Overwrite font configuration file if already existing");
75
80
 
76
81
    tostdout = G_define_flag();
77
82
    tostdout->key = 's';
78
83
    tostdout->description =
79
 
        "Write font configuration file to standard output instead of "
80
 
        "$GISBASE/etc";
 
84
        _("Write font configuration file to standard output instead of "
 
85
          "$GISBASE/etc");
81
86
 
82
87
    extradirs = G_define_option();
83
88
    extradirs->key = "extradirs";
84
89
    extradirs->type = TYPE_STRING;
85
90
    extradirs->required = NO;
 
91
    extradirs->label = _("List of extra directories to scan");
86
92
    extradirs->description =
87
 
        "Comma-separated list of extra directories to scan for "
88
 
        "Freetype-compatible fonts as well as the defaults (see documentation)";
 
93
        _("Comma-separated list of extra directories to scan for "
 
94
          "Freetype-compatible fonts as well as the defaults (see documentation)");
89
95
 
90
 
    if (argc > 1 && G_parser(argc, argv))
 
96
    if (G_parser(argc, argv))
91
97
        exit(EXIT_FAILURE);
92
98
 
93
99
    if (!tostdout->answer) {
99
105
        else
100
106
            G_asprintf(&fontcapfile, "%s/etc/fontcap", gisbase);
101
107
 
102
 
        if (!stat(fontcapfile, &status)) {      /* File exists? */
 
108
        if (!access(fontcapfile, F_OK)) {       /* File exists? */
103
109
            if (!overwrite->answer)
104
 
                G_fatal_error
105
 
                    ("Fontcap file %s already exists; use -%c flag if you "
106
 
                     "wish to overwrite it", fontcapfile, overwrite->key);
 
110
                G_fatal_error(_("Fontcap file %s already exists; use -%c flag if you "
 
111
                                "wish to overwrite it"),
 
112
                              fontcapfile, overwrite->key);
107
113
        }
108
114
    }
109
115
 
113
119
    /* Prepare list of directories to search */
114
120
    if (extradirs->answer) {
115
121
#ifndef HAVE_FT2BUILD_H
116
 
        G_warning("This GRASS installation was compiled without Freetype support, extradirs parameter ignored");
 
122
        G_warning(_("This GRASS installation was compiled without "
 
123
                    "Freetype support, extradirs parameter ignored"));
117
124
#endif
118
125
        char *str = G_store(extradirs->answer);
119
126
 
139
146
    else {
140
147
        outstream = fopen(fontcapfile, "w");
141
148
        if (outstream == NULL)
142
 
            G_fatal_error("Cannot open %s for writing: %s", fontcapfile,
 
149
            G_fatal_error(_("Cannot open %s for writing: %s"), fontcapfile,
143
150
                          strerror(errno));
144
151
    }
145
152