• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Internationalization Tag Set (ITS) handling
2    Copyright (C) 2015, 2018 Free Software Foundation, Inc.
3 
4    This file was written by Daiki Ueno <ueno@gnu.org>, 2015.
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 3 of the License, or
9    (at your option) 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, see <https://www.gnu.org/licenses/>.  */
18 
19 #ifndef _ITS_H_
20 #define _ITS_H_
21 
22 #include <stdio.h>
23 
24 #include "message.h"
25 #include "pos.h"
26 #include "xg-arglist-context.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 enum its_whitespace_type_ty
33 {
34   ITS_WHITESPACE_PRESERVE,
35   ITS_WHITESPACE_NORMALIZE,
36   ITS_WHITESPACE_NORMALIZE_PARAGRAPH,
37   ITS_WHITESPACE_TRIM
38 };
39 
40 typedef struct its_rule_list_ty its_rule_list_ty;
41 
42 typedef message_ty *
43         (*its_extract_callback_ty) (message_list_ty *mlp,
44                                     const char *msgctxt,
45                                     const char *msgid,
46                                     lex_pos_ty *pos,
47                                     const char *extracted_comment,
48                                     const char *marker,
49                                     enum its_whitespace_type_ty whitespace);
50 
51 /* Creates a fresh its_rule_list_ty holding global ITS rules.  */
52 extern its_rule_list_ty *its_rule_list_alloc (void);
53 
54 /* Releases memory allocated for RULES.  */
55 extern void its_rule_list_free (its_rule_list_ty *rules);
56 
57 /* Loads global ITS rules from STRING.  */
58 extern bool its_rule_list_add_from_string (struct its_rule_list_ty *rules,
59                                            const char *rule);
60 
61 /* Loads global ITS rules from FILENAME.  */
62 extern bool its_rule_list_add_from_file (its_rule_list_ty *rules,
63                                          const char *filename);
64 
65 /* Extracts messages from FP, accoding to the loaded ITS rules.  */
66 extern void its_rule_list_extract (its_rule_list_ty *rules,
67                                    FILE *fp, const char *real_filename,
68                                    const char *logical_filename,
69                                    flag_context_list_table_ty *flag_table,
70                                    msgdomain_list_ty *mdlp,
71                                    its_extract_callback_ty callback);
72 
73 typedef struct its_merge_context_ty its_merge_context_ty;
74 
75 extern its_merge_context_ty *
76        its_merge_context_alloc (its_rule_list_ty *rules, const char *filename);
77 extern void its_merge_context_free (its_merge_context_ty *context);
78 extern void its_merge_context_merge (its_merge_context_ty *context,
79                                      const char *language,
80                                      message_list_ty *mlp);
81 
82 extern void its_merge_context_write (its_merge_context_ty *context,
83                                      FILE *fp);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif	/* _ITS_H_ */
90