~ubuntu-branches/ubuntu/trusty/gettext/trusty

« back to all changes in this revision

Viewing changes to src/po.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2002-04-10 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20020410131742-npf89tsaygdolprj
Tags: upstream-0.10.40
ImportĀ upstreamĀ versionĀ 0.10.40

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GNU gettext - internationalization aids
 
2
   Copyright (C) 1995, 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
 
3
 
 
4
   This file was written by Peter Miller <millerp@canb.auug.org.au>
 
5
 
 
6
This program is free software; you can redistribute it and/or modify
 
7
it under the terms of the GNU General Public License as published by
 
8
the Free Software Foundation; either version 2, or (at your option)
 
9
any later version.
 
10
 
 
11
This program is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
GNU General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU General Public License
 
17
along with this program; if not, write to the Free Software
 
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
19
 
 
20
#ifndef SRC_PO_H
 
21
#define SRC_PO_H
 
22
 
 
23
#include "po-lex.h"
 
24
 
 
25
/* Note: the _t suffix is reserved by ANSI C, so the _ty suffix is
 
26
   used to indicate a type name.  */
 
27
 
 
28
/* The following pair of structures cooperate to create an "Object" in
 
29
   the OO sense, we are simply doing it manually, rather than with the
 
30
   help of an OO compiler.  This implementation allows polymorphism
 
31
   and inheritance - more than enough for the immediate needs.
 
32
 
 
33
   This first structure contains pointers to functions.  Each function
 
34
   is a method for the class (base or derived).
 
35
 
 
36
   Use a NULL pointer where no action is required.  */
 
37
 
 
38
/* Forward decaration.  */
 
39
struct po_ty;
 
40
 
 
41
 
 
42
typedef struct po_method_ty po_method_ty;
 
43
struct po_method_ty
 
44
{
 
45
  /* how many bytes to malloc for this class */
 
46
  size_t size;
 
47
 
 
48
  /* what to do immediately after the instance is malloc()ed */
 
49
  void (*constructor) PARAMS ((struct po_ty *__pop));
 
50
 
 
51
  /* what to do immediately before the instance is free()ed */
 
52
  void (*destructor) PARAMS ((struct po_ty *__pop));
 
53
 
 
54
  /* what to do with a domain directive */
 
55
  void (*directive_domain) PARAMS ((struct po_ty *__pop, char *__name));
 
56
 
 
57
  /* what to do with a message directive */
 
58
  void (*directive_message) PARAMS ((struct po_ty *__pop,
 
59
                                     char *__msgid, lex_pos_ty *__msgid_pos,
 
60
                                     char *__msgid_plural,
 
61
                                     char *__msgstr, size_t __msgstr_len,
 
62
                                     lex_pos_ty *__msgstr_pos));
 
63
 
 
64
  /* This method is invoked before the parse, but after the file is
 
65
     opened by the lexer.  */
 
66
  void (*parse_brief) PARAMS ((struct po_ty *__pop));
 
67
 
 
68
  /* This method is invoked after the parse, but before the file is
 
69
     closed by the lexer.  The intention is to make consistency checks
 
70
     against the file here, and emit the errors through the lex_error*
 
71
     functions.  */
 
72
  void (*parse_debrief) PARAMS ((struct po_ty *__pop));
 
73
 
 
74
  /* What to do with a plain-vanilla comment - the expectation is that
 
75
     they will be accumulated, and added to the next message
 
76
     definition seen.  Or completely ignored.  */
 
77
  void (*comment) PARAMS ((struct po_ty *__pop, const char *__s));
 
78
 
 
79
  /* What to do with a comment that starts with a dot (i.e.  extracted
 
80
     by xgettext) - the expectation is that they will be accumulated,
 
81
     and added to the next message definition seen.  Or completely
 
82
     ignored.  */
 
83
  void (*comment_dot) PARAMS ((struct po_ty *__pop, const char *__s));
 
84
 
 
85
  /* What to do with a file position seen in a comment (i.e. a message
 
86
     location comment extracted by xgettext) - the expectation is that
 
87
     they will be accumulated, and added to the next message
 
88
     definition seen.  Or completely ignored.  */
 
89
  void (*comment_filepos) PARAMS ((struct po_ty *__pop, const char *__s,
 
90
                                   int __line));
 
91
 
 
92
  /* What to do with a comment that starts with a `!' - this is a
 
93
     special comment.  One of the possible uses is to indicate a
 
94
     inexact translation.  */
 
95
  void (*comment_special) PARAMS ((struct po_ty *__pop, const char *__s));
 
96
};
 
97
 
 
98
 
 
99
/* This next structure defines the base class passed to the methods.
 
100
   Derived methods will often need to cast their first argument before
 
101
   using it (this corresponds to the implicit ``this'' argument of many
 
102
   C++ implementations).
 
103
 
 
104
   When declaring derived classes, use the PO_BASE_TY define at the
 
105
   start of the structure, to declare inherited instance variables,
 
106
   etc.  */
 
107
 
 
108
#define PO_BASE_TY \
 
109
  po_method_ty *method; \
 
110
  int next_is_fuzzy;
 
111
 
 
112
typedef struct po_ty po_ty;
 
113
struct po_ty
 
114
{
 
115
  PO_BASE_TY
 
116
};
 
117
 
 
118
 
 
119
/* Allocate a fresh po_ty (or derived class) instance and call its
 
120
   constructor.  */
 
121
extern po_ty *po_alloc PARAMS ((po_method_ty *__jtable));
 
122
 
 
123
/* Read a PO file, and dispatch to the various po_method_ty methods.  */
 
124
extern void po_scan PARAMS ((po_ty *__pop, const char *__filename));
 
125
 
 
126
/* Call the destructor and deallocate a po_ty (or derived class)
 
127
   instance.  */
 
128
extern void po_free PARAMS ((po_ty *__pop));
 
129
 
 
130
 
 
131
/* Callbacks used by po-gram.y or po-hash.y or po-lex.c, indirectly
 
132
   from po_scan.  */
 
133
extern void po_callback_domain PARAMS ((char *__name));
 
134
extern void po_callback_message PARAMS ((char *__msgid,
 
135
                                         lex_pos_ty *__msgid_pos,
 
136
                                         char *__msgid_plural,
 
137
                                         char *__msgstr, size_t __msgstr_len,
 
138
                                         lex_pos_ty *__msgstr_pos));
 
139
extern void po_callback_comment PARAMS ((const char *__s));
 
140
extern void po_callback_comment_dot PARAMS ((const char *__s));
 
141
extern void po_callback_comment_filepos PARAMS ((const char *__s, int __line));
 
142
 
 
143
#endif