GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_text_button_text_set.c Lines: 24 24 100.0 %
Date: 2026-03-06 19:21:09 Branches: 28 28 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
/**   Text Button Management (Button)                                     */
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_button.h"
30
#include "gx_utility.h"
31
32
/* Bring in externs for caller checking code.  */
33
GX_CALLER_CHECKING_EXTERNS
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gxe_text_button_text_set                           PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function checks for errors in the text button text set call.   */
47
/*                                                                        */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    button                                Button control block          */
52
/*    text                                  pointer to text string        */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                                Completion status             */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _gx_text_button_text_set              Actual text button text set   */
61
/*                                            function call               */
62
/*                                                                        */
63
/*  CALLED BY                                                             */
64
/*                                                                        */
65
/*    Application Code                                                    */
66
/*                                                                        */
67
/**************************************************************************/
68
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
69
20
UINT  _gxe_text_button_text_set(GX_TEXT_BUTTON *button, GX_CONST GX_CHAR *text)
70
{
71
UINT status;
72
73
    /* Check for appropriate caller.  */
74

20
    GX_INIT_AND_THREADS_CALLER_CHECKING
75
76
    /* Check for invalid input pointers.  */
77
18
    if (button == GX_NULL)
78
    {
79
2
        return(GX_PTR_ERROR);
80
    }
81
82
    /* Check for invalid widget. */
83
16
    if (button -> gx_widget_type == 0)
84
    {
85
1
        return(GX_INVALID_WIDGET);
86
    }
87
88
    /* Call actual widget hide function.  */
89
15
    status = _gx_text_button_text_set(button, text);
90
91
    /* Return completion status.  */
92
15
    return(status);
93
}
94
#endif
95
96
/**************************************************************************/
97
/*                                                                        */
98
/*  FUNCTION                                               RELEASE        */
99
/*                                                                        */
100
/*    _gxe_text_button_text_set_ext                       PORTABLE C      */
101
/*                                                           6.1          */
102
/*  AUTHOR                                                                */
103
/*                                                                        */
104
/*    Kenneth Maxwell, Microsoft Corporation                              */
105
/*                                                                        */
106
/*  DESCRIPTION                                                           */
107
/*                                                                        */
108
/*    This function checks for errors in the text button text set call.   */
109
/*                                                                        */
110
/*                                                                        */
111
/*  INPUT                                                                 */
112
/*                                                                        */
113
/*    button                                Button control block          */
114
/*    text                                  pointer to text string        */
115
/*                                                                        */
116
/*  OUTPUT                                                                */
117
/*                                                                        */
118
/*    status                                Completion status             */
119
/*                                                                        */
120
/*  CALLS                                                                 */
121
/*                                                                        */
122
/*    _gx_text_button_text_set_ext          Actual text button text set   */
123
/*                                            function call               */
124
/*                                                                        */
125
/*  CALLED BY                                                             */
126
/*                                                                        */
127
/*    Application Code                                                    */
128
/*                                                                        */
129
/**************************************************************************/
130
18
UINT _gxe_text_button_text_set_ext(GX_TEXT_BUTTON *button, GX_CONST GX_STRING *text)
131
{
132
UINT status;
133
18
UINT text_length = 0;
134
135
    /* Check for appropriate caller.  */
136

18
    GX_INIT_AND_THREADS_CALLER_CHECKING
137
138
    /* Check for invalid input pointers.  */
139
16
    if (button == GX_NULL)
140
    {
141
1
        return(GX_PTR_ERROR);
142
    }
143
144
    /* Check for invalid widget. */
145
15
    if (button -> gx_widget_type == 0)
146
    {
147
1
        return(GX_INVALID_WIDGET);
148
    }
149
150
14
    if (text)
151
    {
152
10
        if (text -> gx_string_ptr)
153
        {
154
9
            status = _gx_utility_string_length_check(text -> gx_string_ptr, &text_length, text -> gx_string_length);
155
156
9
            if (status != GX_SUCCESS)
157
            {
158
1
                return status;
159
            }
160
        }
161
162
9
        if (text_length != text -> gx_string_length)
163
        {
164
1
            return GX_INVALID_STRING_LENGTH;
165
        }
166
    }
167
168
    /* Call actual text set function.  */
169
12
    status = _gx_text_button_text_set_ext(button, text);
170
171
    /* Return completion status.  */
172
12
    return(status);
173
}
174