~ubuntu-branches/ubuntu/feisty/mp4h/feisty

« back to all changes in this revision

Viewing changes to modules/intl/gettext.c

  • Committer: Bazaar Package Importer
  • Author(s): Denis Barbier
  • Date: 2003-11-06 20:34:24 UTC
  • Revision ID: james.westby@ubuntu.com-20031106203424-nqx14tkfeirx01r3
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* mp4h -- A macro processor for HTML documents
 
2
   Copyright 2000-2003, Denis Barbier
 
3
   All rights reserved.
 
4
 
 
5
   This program is free software; you can redistribute it and/or modify
 
6
   it under the terms of the GNU General Public License as published by
 
7
   the Free Software Foundation; either version 2, or (at your option)
 
8
   any later version.
 
9
 
 
10
   This program is a work based on GNU m4 version 1.4n. Below is the
 
11
   original copyright.
 
12
*/
 
13
/* GNU m4 -- A simple macro processor
 
14
   Copyright (C) 1998 Free Software Foundation, Inc.
 
15
  
 
16
   This program is free software; you can redistribute it and/or modify
 
17
   it under the terms of the GNU General Public License as published by
 
18
   the Free Software Foundation; either version 2, or (at your option)
 
19
   any later version.
 
20
  
 
21
   This program is distributed in the hope that it will be useful,
 
22
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
23
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
24
   GNU General Public License for more details.
 
25
  
 
26
   You should have received a copy of the GNU General Public License
 
27
   along with this program; if not, write to the Free Software
 
28
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
29
*/
 
30
 
 
31
#define MP4H_MODULE
 
32
#include <mp4h.h>
 
33
#undef MP4H_MODULE
 
34
 
 
35
#include <libintl.h>
 
36
 
 
37
#define mp4h_macro_table                gettext_LTX_mp4h_macro_table
 
38
#define mp4h_init_module                gettext_LTX_mp4h_init_module
 
39
#define mp4h_finish_module              gettext_LTX_mp4h_finish_module
 
40
 
 
41
module_init_t mp4h_init_module;         /* initialisation function */
 
42
module_finish_t mp4h_finish_module;     /* cleanup function */
 
43
 
 
44
DECLARE(mp4m_intl_textdomain);
 
45
DECLARE(mp4m_intl_bindtextdomain);
 
46
DECLARE(mp4m_intl_bind_textdomain_codeset);
 
47
DECLARE(mp4m_intl_gettext);
 
48
 
 
49
#undef DECLARE
 
50
 
 
51
/* The table of builtins defined by this module - just one */
 
52
 
 
53
builtin mp4h_macro_table[] =
 
54
{
 
55
  /* name             container   expand    function
 
56
                                attributes                      */
 
57
 
 
58
  { "textdomain",       FALSE,    TRUE,   mp4m_intl_textdomain },
 
59
  { "bindtextdomain",   FALSE,    TRUE,   mp4m_intl_bindtextdomain },
 
60
  { "bind_textdomain_codeset",
 
61
                        FALSE,    TRUE,   mp4m_intl_bind_textdomain_codeset },
 
62
  { "gettext",           TRUE,    TRUE,   mp4m_intl_gettext },
 
63
  { 0,                  FALSE,   FALSE,   0 },
 
64
};
 
65
 
 
66
void
 
67
mp4h_init_module(struct obstack *obs)
 
68
{
 
69
}
 
70
 
 
71
void
 
72
mp4h_finish_module(void)
 
73
{
 
74
}
 
75
 
 
76
/* The functions for builtins can be static */
 
77
 
 
78
static void
 
79
mp4m_intl_textdomain (MP4H_BUILTIN_ARGS)
 
80
{
 
81
  const char *domain;
 
82
 
 
83
  domain = predefined_attribute ("domain", &argc, argv, FALSE);
 
84
  if (!domain)
 
85
    {
 
86
      MP4HERROR ((warning_status, 0,
 
87
        _("Warning:%s:%d: In <%s>, required attribute `%s' is not specified"),
 
88
           CURRENT_FILE_LINE, ARG (0), "domain"));
 
89
      return;
 
90
    }
 
91
  textdomain (domain);
 
92
}
 
93
 
 
94
static void
 
95
mp4m_intl_bindtextdomain (MP4H_BUILTIN_ARGS)
 
96
{
 
97
  const char *domain, *path;
 
98
 
 
99
  domain = predefined_attribute ("domain", &argc, argv, FALSE);
 
100
  path   = predefined_attribute ("path", &argc, argv, FALSE);
 
101
  if (!domain)
 
102
    {
 
103
      MP4HERROR ((warning_status, 0,
 
104
        _("Warning:%s:%d: In <%s>, required attribute `%s' is not specified"),
 
105
           CURRENT_FILE_LINE, ARG (0), "domain"));
 
106
      return;
 
107
    }
 
108
  if (!path)
 
109
    {
 
110
      MP4HERROR ((warning_status, 0,
 
111
        _("Warning:%s:%d: In <%s>, required attribute `%s' is not specified"),
 
112
           CURRENT_FILE_LINE, ARG (0), "path"));
 
113
      return;
 
114
    }
 
115
  bindtextdomain (domain, path);
 
116
}
 
117
 
 
118
static void
 
119
mp4m_intl_bind_textdomain_codeset (MP4H_BUILTIN_ARGS)
 
120
{
 
121
  const char *domain, *codeset;
 
122
 
 
123
  domain  = predefined_attribute ("domain", &argc, argv, FALSE);
 
124
  codeset = predefined_attribute ("codeset", &argc, argv, FALSE);
 
125
  if (!domain)
 
126
    {
 
127
      MP4HERROR ((warning_status, 0,
 
128
        _("Warning:%s:%d: In <%s>, required attribute `%s' is not specified"),
 
129
           CURRENT_FILE_LINE, ARG (0), "domain"));
 
130
      return;
 
131
    }
 
132
  if (!codeset)
 
133
    {
 
134
      MP4HERROR ((warning_status, 0,
 
135
        _("Warning:%s:%d: In <%s>, required attribute `%s' is not specified"),
 
136
           CURRENT_FILE_LINE, ARG (0), "codeset"));
 
137
      return;
 
138
    }
 
139
  bind_textdomain_codeset (domain, codeset);
 
140
}
 
141
 
 
142
static void
 
143
mp4m_intl_gettext (MP4H_BUILTIN_ARGS)
 
144
{
 
145
  const char *domain;
 
146
  char *cp, *msgstr;
 
147
 
 
148
  domain = predefined_attribute ("domain", &argc, argv, FALSE);
 
149
  for (cp = ARGBODY; *cp != '\0'; cp++)
 
150
    if (CHAR_SLASH == *cp)
 
151
      *cp = '/';
 
152
 
 
153
  if (domain)
 
154
    msgstr = dgettext(domain, ARGBODY);
 
155
  else
 
156
    msgstr = gettext(ARGBODY);
 
157
  obstack_grow (obs, msgstr, strlen (msgstr));
 
158
}
 
159