~ubuntu-branches/ubuntu/breezy/gettext/breezy

« back to all changes in this revision

Viewing changes to gettext-tools/src/format.h

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2004-03-14 17:40:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314174002-p1ad5ldve1hqzhye
Tags: 0.14.1-2
* Added libexpat1-dev to Build-Depends, for glade support.
* Added libc0.1-dev to Build-Depends, for GNU/kFreeBSD.
* Removed special-casing of knetbsd-gnu in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Format strings.
 
2
   Copyright (C) 2001-2004 Free Software Foundation, Inc.
 
3
   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
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 distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
   GNU General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU General Public License
 
16
   along with this program; if not, write to the Free Software Foundation,
 
17
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
18
 
 
19
#ifndef _FORMAT_H
 
20
#define _FORMAT_H
 
21
 
 
22
#include <stdbool.h>
 
23
 
 
24
#include "pos.h"        /* Get lex_pos_ty.  */
 
25
#include "message.h"    /* Get NFORMATS.  */
 
26
 
 
27
 
 
28
#ifdef __cplusplus
 
29
extern "C" {
 
30
#endif
 
31
 
 
32
 
 
33
/* This structure describes a format string parser for a language.  */
 
34
struct formatstring_parser
 
35
{
 
36
  /* Parse the given string as a format string.
 
37
     If translated is true, some extensions available only to msgstr but not
 
38
     to msgid strings are recognized.
 
39
     Return a freshly allocated structure describing
 
40
       1. the argument types/names needed for the format string,
 
41
       2. the total number of format directives.
 
42
     Return NULL if the string is not a valid format string. In this case,
 
43
     also set *invalid_reason to an error message explaining why.  */
 
44
  void * (*parse) (const char *string, bool translated, char **invalid_reason);
 
45
 
 
46
  /* Free a format string descriptor, returned by parse().  */
 
47
  void (*free) (void *descr);
 
48
 
 
49
  /* Return the number of format directives.
 
50
     A string that can be output literally has 0 format directives.  */
 
51
  int (*get_number_of_directives) (void *descr);
 
52
 
 
53
  /* Verify that the argument types/names in msgid_descr and those in
 
54
     msgstr_descr are the same (if equality=true), or (if equality=false)
 
55
     that those of msgid_descr extend those of msgstr_descr (i.e.
 
56
     msgstr_descr may omit some of the arguments of msgid_descr).
 
57
     If not, signal an error using
 
58
       error_with_progname = false;
 
59
       error_at_line (0, 0, pos->file_name, pos->line_number, ...);
 
60
       error_with_progname = true;
 
61
     (but only if noisy=true) and return true.  Otherwise return false.  */
 
62
  bool (*check) (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr, bool equality, bool noisy, const char *pretty_msgstr);
 
63
};
 
64
 
 
65
/* Format string parsers, each defined in its own file.  */
 
66
extern DLL_VARIABLE struct formatstring_parser formatstring_c;
 
67
extern DLL_VARIABLE struct formatstring_parser formatstring_objc;
 
68
extern DLL_VARIABLE struct formatstring_parser formatstring_sh;
 
69
extern DLL_VARIABLE struct formatstring_parser formatstring_python;
 
70
extern DLL_VARIABLE struct formatstring_parser formatstring_lisp;
 
71
extern DLL_VARIABLE struct formatstring_parser formatstring_elisp;
 
72
extern DLL_VARIABLE struct formatstring_parser formatstring_librep;
 
73
extern DLL_VARIABLE struct formatstring_parser formatstring_smalltalk;
 
74
extern DLL_VARIABLE struct formatstring_parser formatstring_java;
 
75
extern DLL_VARIABLE struct formatstring_parser formatstring_csharp;
 
76
extern DLL_VARIABLE struct formatstring_parser formatstring_awk;
 
77
extern DLL_VARIABLE struct formatstring_parser formatstring_pascal;
 
78
extern DLL_VARIABLE struct formatstring_parser formatstring_ycp;
 
79
extern DLL_VARIABLE struct formatstring_parser formatstring_tcl;
 
80
extern DLL_VARIABLE struct formatstring_parser formatstring_perl;
 
81
extern DLL_VARIABLE struct formatstring_parser formatstring_perl_brace;
 
82
extern DLL_VARIABLE struct formatstring_parser formatstring_php;
 
83
extern DLL_VARIABLE struct formatstring_parser formatstring_gcc_internal;
 
84
extern DLL_VARIABLE struct formatstring_parser formatstring_qt;
 
85
 
 
86
/* Table of all format string parsers.  */
 
87
extern DLL_VARIABLE struct formatstring_parser *formatstring_parsers[NFORMATS];
 
88
 
 
89
/* Returns an array of the ISO C 99 <inttypes.h> format directives and other
 
90
   format flags or directives with a system dependent expansion contained in
 
91
   the argument string.  *intervalsp is assigned to a freshly allocated array
 
92
   of intervals (startpos pointing to '<', endpos to the character after '>'),
 
93
   and *lengthp is assigned to the number of intervals in this array.  */
 
94
struct interval
 
95
{
 
96
  size_t startpos;
 
97
  size_t endpos;
 
98
};
 
99
extern void
 
100
       get_sysdep_c_format_directives (const char *string, bool translated,
 
101
                                 struct interval **intervalsp, size_t *lengthp);
 
102
 
 
103
 
 
104
#ifdef __cplusplus
 
105
}
 
106
#endif
 
107
 
 
108
 
 
109
#endif /* _FORMAT_H */