GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_display_language_table_set.c Lines: 28 28 100.0 %
Date: 2024-12-05 08:52:37 Branches: 34 34 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Display Management (Display)                                        */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
#include "gx_utility.h"
29
30
/* Bring in externs for caller checking code.  */
31
GX_CALLER_CHECKING_EXTERNS
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gxe_display_language_table_set                     PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function checks for errors in display language table set call. */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    display                               Pointer to display instance.  */
50
/*    language_table                        The language table to be set  */
51
/*    num_languages                         Number of languages in the    */
52
/*                                            table                       */
53
/*    number_of_strings                     Number of strings in each     */
54
/*                                            language                    */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_display_language_table_set        Actual display language table */
63
/*                                            set call                    */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    Application Code                                                    */
68
/*                                                                        */
69
/*  RELEASE HISTORY                                                       */
70
/*                                                                        */
71
/*    DATE              NAME                      DESCRIPTION             */
72
/*                                                                        */
73
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
74
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
75
/*                                            resulting in version 6.1    */
76
/*                                                                        */
77
/**************************************************************************/
78
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
79
17
UINT  _gxe_display_language_table_set(GX_DISPLAY *display, GX_CHAR ***language_table,
80
                                      GX_UBYTE number_of_languages, UINT number_of_strings)
81
{
82
UINT status;
83
84
    /* Check for invalid caller.  */
85

17
    GX_INIT_AND_THREADS_CALLER_CHECKING
86
87
15
    if (display == GX_NULL)
88
    {
89
        /* Check for null pointer*/
90
3
        return(GX_PTR_ERROR);
91
    }
92
93
    /* Allow string table to be NULL if number_of_strings is zero. */
94

12
    if (number_of_strings && language_table == GX_NULL)
95
    {
96
        /* Return error.  */
97
2
        return(GX_PTR_ERROR);
98
    }
99
100
    /* Call actual system string table set.  */
101
10
    status = _gx_display_language_table_set(display, language_table, number_of_languages, number_of_strings);
102
103
    /* Return status.  */
104
10
    return(status);
105
}
106
#endif
107
108
/**************************************************************************/
109
/*                                                                        */
110
/*  FUNCTION                                               RELEASE        */
111
/*                                                                        */
112
/*    _gxe_display_language_table_set_ext                 PORTABLE C      */
113
/*                                                           6.1          */
114
/*  AUTHOR                                                                */
115
/*                                                                        */
116
/*    Kenneth Maxwell, Microsoft Corporation                              */
117
/*                                                                        */
118
/*  DESCRIPTION                                                           */
119
/*                                                                        */
120
/*    This function checks for errors in display language table set call. */
121
/*                                                                        */
122
/*  INPUT                                                                 */
123
/*                                                                        */
124
/*    display                               Pointer to display instance.  */
125
/*    table                                 The language table to be set  */
126
/*    num_languages                         Number of languages in the    */
127
/*                                            table                       */
128
/*    number_of_strings                     Number of strings in each     */
129
/*                                            language                    */
130
/*                                                                        */
131
/*  OUTPUT                                                                */
132
/*                                                                        */
133
/*    status                                Completion status             */
134
/*                                                                        */
135
/*  CALLS                                                                 */
136
/*                                                                        */
137
/*    _gx_display_language_table_set_ext    Actual display language table */
138
/*                                            set ext call                */
139
/*                                                                        */
140
/*  CALLED BY                                                             */
141
/*                                                                        */
142
/*    Application Code                                                    */
143
/*                                                                        */
144
/*  RELEASE HISTORY                                                       */
145
/*                                                                        */
146
/*    DATE              NAME                      DESCRIPTION             */
147
/*                                                                        */
148
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
149
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
150
/*                                            resulting in version 6.1    */
151
/*                                                                        */
152
/**************************************************************************/
153
774
UINT _gxe_display_language_table_set_ext(GX_DISPLAY *display, GX_CONST GX_STRING **table, GX_UBYTE num_languages, UINT number_of_strings)
154
{
155
UINT                status;
156
UINT                language;
157
UINT                string_id;
158
GX_CONST GX_STRING *string_table;
159
GX_CONST GX_STRING *string;
160
UINT                string_length;
161
162
    /* Check for invalid caller.  */
163

774
    GX_INIT_AND_THREADS_CALLER_CHECKING
164
165
772
    if (display == GX_NULL)
166
    {
167
        /* Check for null pointer*/
168
1
        return(GX_PTR_ERROR);
169
    }
170
171
    /* Allow string table to be NULL if number_of_strings is zero. */
172
771
    if (number_of_strings)
173
    {
174
769
        if (table == GX_NULL)
175
        {
176
            /* Return error.  */
177
1
            return(GX_PTR_ERROR);
178
        }
179
180
1643
        for (language = 0; language < num_languages; language++)
181
        {
182
877
            string_table = table[language];
183
71531
            for (string_id = 0; string_id < number_of_strings; string_id++)
184
            {
185
70656
                string = &string_table[string_id];
186
187
70656
                if (string -> gx_string_ptr)
188
                {
189
68488
                    status = _gx_utility_string_length_check(string -> gx_string_ptr, &string_length, string -> gx_string_length);
190
191
68488
                    if (status != GX_SUCCESS)
192
                    {
193
1
                        return status;
194
                    }
195
                }
196
                else
197
                {
198
2168
                    string_length = 0;
199
                }
200
201
70655
                if (string_length != string -> gx_string_length)
202
                {
203
1
                    return GX_INVALID_STRING_LENGTH;
204
                }
205
            }
206
        }
207
    }
208
209
    /* Call actual system string table set.  */
210
768
    status = _gx_display_language_table_set_ext(display, table, num_languages, number_of_strings);
211
212
    /* Return status.  */
213
768
    return(status);
214
}
215
216
/**************************************************************************/
217
/*                                                                        */
218
/*  FUNCTION                                               RELEASE        */
219
/*                                                                        */
220
/*    _gxe_display_language_direction_table_set           PORTABLE C      */
221
/*                                                           6.1.10       */
222
/*  AUTHOR                                                                */
223
/*                                                                        */
224
/*    Ting Zhu, Microsoft Corporation                                     */
225
/*                                                                        */
226
/*  DESCRIPTION                                                           */
227
/*                                                                        */
228
/*    This function checks for errors in display language direction table */
229
/*    set call.                                                           */
230
/*                                                                        */
231
/*  INPUT                                                                 */
232
/*                                                                        */
233
/*    display                               Pointer to display instance.  */
234
/*    language_direction_table              The language direction table  */
235
/*                                            to be set                   */
236
/*    num_languages                         Number of languages in the    */
237
/*                                            table                       */
238
/*                                                                        */
239
/*  OUTPUT                                                                */
240
/*                                                                        */
241
/*    status                                Completion status             */
242
/*                                                                        */
243
/*  CALLS                                                                 */
244
/*                                                                        */
245
/*    _gx_display_language_direciton_table_set                            */
246
/*                                          Actual display language table */
247
/*                                            set ext call                */
248
/*                                                                        */
249
/*  CALLED BY                                                             */
250
/*                                                                        */
251
/*    Application Code                                                    */
252
/*                                                                        */
253
/*  RELEASE HISTORY                                                       */
254
/*                                                                        */
255
/*    DATE              NAME                      DESCRIPTION             */
256
/*                                                                        */
257
/*  01-31-2022     Ting Zhu                 Initial Version 6.1.10        */
258
/*                                                                        */
259
/**************************************************************************/
260
#if defined(GX_DYNAMIC_BIDI_TEXT_SUPPORT)
261
UINT _gxe_display_language_direction_table_set(GX_DISPLAY *display, GX_CONST GX_UBYTE *language_direction_table, GX_UBYTE num_languages)
262
{
263
UINT status;
264
265
    /* Check for invalid caller.  */
266
    GX_INIT_AND_THREADS_CALLER_CHECKING
267
268
    if (display == GX_NULL)
269
    {
270
        /* Check for null pointer*/
271
        return(GX_PTR_ERROR);
272
    }
273
274
    /* Call actual system string table set.  */
275
    status = _gx_display_language_direction_table_set(display, language_direction_table, num_languages);
276
277
    /* Return status.  */
278
    return(status);
279
}
280
#endif