GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_multi_line_text_button_text_set.c Lines: 20 20 100.0 %
Date: 2024-12-05 08:52:37 Branches: 24 24 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
/**   Button Management (Button)                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_button.h"
29
#include "gx_utility.h"
30
31
/* Bring in externs for caller checking code.  */
32
GX_CALLER_CHECKING_EXTERNS
33
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _gxe_multi_line_text_button_text_set                PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    Kenneth Maxwell, Microsoft Corporation                              */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function checks for errors in the text assigment.              */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    button                                Pointer to the button         */
52
/*                                            control block               */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_multi_line_text_button_text_set   Actual text assignment        */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*                                                                        */
65
/*  RELEASE HISTORY                                                       */
66
/*                                                                        */
67
/*    DATE              NAME                      DESCRIPTION             */
68
/*                                                                        */
69
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71
/*                                            resulting in version 6.1    */
72
/*                                                                        */
73
/**************************************************************************/
74
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
75
7
UINT  _gxe_multi_line_text_button_text_set(GX_MULTI_LINE_TEXT_BUTTON *button,
76
                                           GX_CONST GX_CHAR *text)
77
{
78
UINT status;
79
80
    /* Check for appropriate caller.  */
81

7
    GX_INIT_AND_THREADS_CALLER_CHECKING
82
83
    /* Check for invalid input pointers.  */
84
5
    if (button == GX_NULL)
85
    {
86
2
        return(GX_PTR_ERROR);
87
    }
88
89
    /* Call the actual button draw function.  */
90
3
    status = _gx_multi_line_text_button_text_set(button, text);
91
92
    /* Return completion status.  */
93
3
    return status;
94
}
95
#endif
96
97
/**************************************************************************/
98
/*                                                                        */
99
/*  FUNCTION                                               RELEASE        */
100
/*                                                                        */
101
/*    _gxe_multi_line_text_button_text_set_ext            PORTABLE C      */
102
/*                                                           6.1          */
103
/*  AUTHOR                                                                */
104
/*                                                                        */
105
/*    Kenneth Maxwell, Microsoft Corporation                              */
106
/*                                                                        */
107
/*  DESCRIPTION                                                           */
108
/*                                                                        */
109
/*    This function checks for errors in the text assigment.              */
110
/*                                                                        */
111
/*  INPUT                                                                 */
112
/*                                                                        */
113
/*    button                                Pointer to the button         */
114
/*                                            control block               */
115
/*    text                                  Text to be set                */
116
/*                                                                        */
117
/*  OUTPUT                                                                */
118
/*                                                                        */
119
/*    status                                Completion status             */
120
/*                                                                        */
121
/*  CALLS                                                                 */
122
/*                                                                        */
123
/*    _gx_multi_line_text_button_text_set_ext                             */
124
/*                                          Actual text assignment        */
125
/*                                                                        */
126
/*  CALLED BY                                                             */
127
/*                                                                        */
128
/*    Application Code                                                    */
129
/*                                                                        */
130
/*  RELEASE HISTORY                                                       */
131
/*                                                                        */
132
/*    DATE              NAME                      DESCRIPTION             */
133
/*                                                                        */
134
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
135
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
136
/*                                            resulting in version 6.1    */
137
/*                                                                        */
138
/**************************************************************************/
139
8
UINT _gxe_multi_line_text_button_text_set_ext(GX_MULTI_LINE_TEXT_BUTTON *button, GX_CONST GX_STRING *text)
140
{
141
UINT status;
142
8
UINT text_length = 0;
143
144
    /* Check for appropriate caller.  */
145

8
    GX_INIT_AND_THREADS_CALLER_CHECKING
146
147
    /* Check for invalid input pointers.  */
148
6
    if (button == GX_NULL)
149
    {
150
1
        return(GX_PTR_ERROR);
151
    }
152
153
5
    if (text)
154
    {
155
4
        if (text -> gx_string_ptr)
156
        {
157
3
            status = _gx_utility_string_length_check(text -> gx_string_ptr, &text_length, text -> gx_string_length);
158
159
3
            if (status != GX_SUCCESS)
160
            {
161
1
                return status;
162
            }
163
        }
164
165
3
        if (text_length != text -> gx_string_length)
166
        {
167
1
            return GX_INVALID_STRING_LENGTH;
168
        }
169
    }
170
171
    /* Call the actual button draw function.  */
172
3
    status = _gx_multi_line_text_button_text_set_ext(button, text);
173
174
    /* Return completion status.  */
175
3
    return status;
176
}
177