GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_system_string_width_get.c Lines: 27 27 100.0 %
Date: 2026-03-06 19:21:09 Branches: 38 38 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   System Management (System)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
31
/* Bring in externs for caller checking code.  */
32
GX_CALLER_CHECKING_EXTERNS
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gxe_system_string_width_get                        PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function checks for errors in system string width get call.    */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    font                                  Font used by the string       */
51
/*    string                                Pointer to string             */
52
/*    string_length                         Length of string              */
53
/*    return_width                          Destination for width of      */
54
/*                                            string                      */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_utility_string_length_check       Test string length            */
63
/*    _gx_system_string_width_get           Actual system string width    */
64
/*                                            get call                    */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    Application Code                                                    */
69
/*                                                                        */
70
/**************************************************************************/
71
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
72
12
UINT  _gxe_system_string_width_get(GX_CONST GX_FONT *font, GX_CONST GX_CHAR *string, INT string_length, GX_VALUE *return_width)
73
{
74
UINT status;
75
UINT length;
76
77
    /* Check for invalid caller.  */
78

12
    GX_INIT_AND_THREADS_CALLER_CHECKING
79
80
    /* Check for invalid pointer.  */
81

10
    if ((font == GX_NULL) || (string == GX_NULL) || (return_width == GX_NULL))
82
    {
83
3
        return(GX_PTR_ERROR);
84
    }
85
86
    /* Check for invalid font.  */
87
7
    if (font -> gx_font_glyphs.gx_font_normal_glyphs == GX_NULL)
88
    {
89
2
        return(GX_INVALID_FONT);
90
    }
91
92
5
    if(string_length > 0)
93
    {
94
        /* Calculate input string length. */
95
3
        status = _gx_utility_string_length_check(string, &length, GX_MAX_STRING_LENGTH);
96
97
3
        if (status != GX_SUCCESS)
98
        {
99
1
            return status;
100
        }
101
102
        /* Check for invalid string length.  */
103
2
        if (string_length > (INT)length)
104
        {
105
1
            return(GX_INVALID_STRING_LENGTH);
106
        }
107
    }
108
109
    /* Call actual system string width get.  */
110
3
    status = _gx_system_string_width_get(font, string, string_length, return_width);
111
112
    /* Return status.  */
113
3
    return(status);
114
}
115
#endif
116
117
/**************************************************************************/
118
/*                                                                        */
119
/*  FUNCTION                                               RELEASE        */
120
/*                                                                        */
121
/*    _gx_system_string_width_get_ext                     PORTABLE C      */
122
/*                                                           6.1          */
123
/*  AUTHOR                                                                */
124
/*                                                                        */
125
/*    Kenneth Maxwell, Microsoft Corporation                              */
126
/*                                                                        */
127
/*  DESCRIPTION                                                           */
128
/*                                                                        */
129
/*    This function checks for errors in system string width get call.    */
130
/*                                                                        */
131
/*  INPUT                                                                 */
132
/*                                                                        */
133
/*    font                                  Font used by the string       */
134
/*    string                                Pointer to string             */
135
/*    return_width                          Destination for width of      */
136
/*                                            string                      */
137
/*                                                                        */
138
/*  OUTPUT                                                                */
139
/*                                                                        */
140
/*    status                                Completion status             */
141
/*                                                                        */
142
/*  CALLS                                                                 */
143
/*                                                                        */
144
/*    _gx_utility_string_length_check       Test string length            */
145
/*    _gx_system_string_width_get_ext       Actual system string width    */
146
/*                                            get exe call                */
147
/*                                                                        */
148
/*  CALLED BY                                                             */
149
/*                                                                        */
150
/*    Application Code                                                    */
151
/*                                                                        */
152
/**************************************************************************/
153
9
UINT  _gxe_system_string_width_get_ext(GX_CONST GX_FONT *font, GX_CONST GX_STRING *string, GX_VALUE *return_width)
154
{
155
UINT status;
156
UINT length;
157
158
    /* Check for invalid caller.  */
159

9
    GX_INIT_AND_THREADS_CALLER_CHECKING
160
161
    /* Check for invalid pointer.  */
162

7
    if ((font == GX_NULL) || (string == GX_NULL) || (return_width == GX_NULL))
163
    {
164
3
        return(GX_PTR_ERROR);
165
    }
166
167
    /* Check for invalid font.  */
168
4
    if (font -> gx_font_glyphs.gx_font_normal_glyphs == GX_NULL)
169
    {
170
1
        return(GX_INVALID_FONT);
171
    }
172
173
    /* Calculate input string length. */
174
3
    status = _gx_utility_string_length_check(string -> gx_string_ptr, &length, string -> gx_string_length);
175
176
3
    if (status != GX_SUCCESS)
177
    {
178
1
        return status;
179
    }
180
181
    /* Check for invalid string length.  */
182
2
    if (string -> gx_string_length > length)
183
    {
184
1
        return(GX_INVALID_STRING_LENGTH);
185
    }
186
187
    /* Call actual system string width get.  */
188
1
    status = _gx_system_string_width_get_ext(font, string, return_width);
189
190
    /* Return status.  */
191
1
    return(status);
192
}
193