• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Keeping track of the flags that apply to a string extracted
2    in a certain context.
3    Copyright (C) 2001-2018, 2020 Free Software Foundation, Inc.
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 3 of the License, or
8    (at your option) 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, see <https://www.gnu.org/licenses/>.  */
17 
18 #ifndef _XGETTEXT_ARGLIST_CONTEXT_H
19 #define _XGETTEXT_ARGLIST_CONTEXT_H
20 
21 #include <stdbool.h>
22 
23 #include "mem-hash-map.h"
24 #include "message.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 
31 /* Context representing some flags.  */
32 typedef struct flag_context_ty flag_context_ty;
33 struct flag_context_ty
34 {
35   /* Regarding the primary formatstring type.  */
36   /*enum is_format*/ unsigned int is_format1    : 3;
37   /*bool*/           unsigned int pass_format1  : 1;
38   /* Regarding the secondary formatstring type.  */
39   /*enum is_format*/ unsigned int is_format2    : 3;
40   /*bool*/           unsigned int pass_format2  : 1;
41   /* Regarding the tertiary formatstring type.  */
42   /*enum is_format*/ unsigned int is_format3    : 3;
43   /*bool*/           unsigned int pass_format3  : 1;
44 };
45 /* Null context.  */
46 extern flag_context_ty null_context;
47 /* Transparent context.  */
48 extern flag_context_ty passthrough_context;
49 /* Compute an inherited context.
50    The outer_context is assumed to have all pass_format* flags = false.
51    The result will then also have all pass_format* flags = false.  */
52 extern flag_context_ty
53        inherited_context (flag_context_ty outer_context,
54                           flag_context_ty modifier_context);
55 
56 /* Context representing some flags, for each possible argument number.
57    This is a linked list, sorted according to the argument number.  */
58 typedef struct flag_context_list_ty flag_context_list_ty;
59 struct flag_context_list_ty
60 {
61   int argnum;                   /* current argument number, > 0 */
62   flag_context_ty flags;        /* flags for current argument */
63   flag_context_list_ty *next;
64 };
65 
66 /* Iterator through a flag_context_list_ty.  */
67 typedef struct flag_context_list_iterator_ty flag_context_list_iterator_ty;
68 struct flag_context_list_iterator_ty
69 {
70   int argnum;                           /* current argument number, > 0 */
71   const flag_context_list_ty* head;     /* tail of list */
72 };
73 extern flag_context_list_iterator_ty null_context_list_iterator;
74 extern flag_context_list_iterator_ty passthrough_context_list_iterator;
75 extern flag_context_list_iterator_ty
76        flag_context_list_iterator (flag_context_list_ty *list);
77 extern flag_context_ty
78        flag_context_list_iterator_advance (flag_context_list_iterator_ty *iter);
79 
80 /* For nearly each backend, we have a separate table mapping a keyword to
81    a flag_context_list_ty *.  */
82 typedef hash_table /* char[] -> flag_context_list_ty * */
83         flag_context_list_table_ty;
84 extern flag_context_list_ty *
85        flag_context_list_table_lookup (flag_context_list_table_ty *flag_table,
86                                        const void *key, size_t keylen);
87 extern void
88        flag_context_list_table_add (flag_context_list_table_ty *table,
89                                     unsigned int index,
90                                     const char *name_start, const char *name_end,
91                                     int argnum, enum is_format value, bool pass);
92 
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 
99 #endif /* _XGETTEXT_ARGLIST_CONTEXT_H */
100