Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / src / its.h
1 /* Internationalization Tag Set (ITS) handling
2    Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _ITS_H_
20 #define _ITS_H_
21
22 #include "message.h"
23 #include "xgettext.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 enum its_whitespace_type_ty
30 {
31   ITS_WHITESPACE_PRESERVE,
32   ITS_WHITESPACE_NORMALIZE,
33   ITS_WHITESPACE_TRIM
34 };
35
36 typedef struct its_rule_list_ty its_rule_list_ty;
37
38 typedef message_ty *
39         (*its_extract_callback_ty) (message_list_ty *mlp,
40                                     const char *msgctxt,
41                                     const char *msgid,
42                                     lex_pos_ty *pos,
43                                     const char *extracted_comment,
44                                     const char *marker,
45                                     enum its_whitespace_type_ty whitespace);
46
47 /* Creates a fresh its_rule_list_ty holding global ITS rules.  */
48 extern its_rule_list_ty *its_rule_list_alloc (void);
49
50 /* Releases memory allocated for RULES.  */
51 extern void its_rule_list_free (its_rule_list_ty *rules);
52
53 /* Loads global ITS rules from STRING.  */
54 extern bool its_rule_list_add_from_string (struct its_rule_list_ty *rules,
55                                            const char *rule);
56
57 /* Loads global ITS rules from FILENAME.  */
58 extern bool its_rule_list_add_from_file (its_rule_list_ty *rules,
59                                          const char *filename);
60
61 /* Extracts messages from FP, accoding to the loaded ITS rules.  */
62 extern void its_rule_list_extract (its_rule_list_ty *rules,
63                                    FILE *fp, const char *real_filename,
64                                    const char *logical_filename,
65                                    flag_context_list_table_ty *flag_table,
66                                    msgdomain_list_ty *mdlp,
67                                    its_extract_callback_ty callback);
68
69 typedef struct its_merge_context_ty its_merge_context_ty;
70
71 extern its_merge_context_ty *
72        its_merge_context_alloc (its_rule_list_ty *rules, const char *filename);
73 extern void its_merge_context_free (its_merge_context_ty *context);
74 extern void its_merge_context_merge (its_merge_context_ty *context,
75                                      const char *language,
76                                      message_list_ty *mlp);
77
78 extern void its_merge_context_write (its_merge_context_ty *context,
79                                      FILE *fp);
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif  /* _ITS_H_ */