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

538
    GX_INIT_AND_THREADS_CALLER_CHECKING
75
76
    /* Check error for valid pointer. */
77
536
    if (prompt == GX_NULL)
78
    {
79
2
        return(GX_PTR_ERROR);
80
    }
81
82
    /* Call the actual function.  */
83
534
    status = _gx_prompt_text_set(prompt, text);
84
85
    /* Return completion status.  */
86
534
    return(status);
87
}
88
#endif
89
90
/**************************************************************************/
91
/*                                                                        */
92
/*  FUNCTION                                               RELEASE        */
93
/*                                                                        */
94
/*    _gxe_prompt_text_set_ext                            PORTABLE C      */
95
/*                                                           6.1          */
96
/*  AUTHOR                                                                */
97
/*                                                                        */
98
/*    Kenneth Maxwell, Microsoft Corporation                              */
99
/*                                                                        */
100
/*  DESCRIPTION                                                           */
101
/*                                                                        */
102
/*    This function checks errors in the prompt text set function.        */
103
/*                                                                        */
104
/*  INPUT                                                                 */
105
/*                                                                        */
106
/*    prompt                                Pointer to prompt widget      */
107
/*                                            control block               */
108
/*    text                                  Pointer to text               */
109
/*                                                                        */
110
/*  OUTPUT                                                                */
111
/*                                                                        */
112
/*    status                                Completion status             */
113
/*                                                                        */
114
/*  CALLS                                                                 */
115
/*                                                                        */
116
/*    _gx_prompt_text_set_ext               The actual function           */
117
/*                                                                        */
118
/*  CALLED BY                                                             */
119
/*                                                                        */
120
/*    Application Code                                                    */
121
/*                                                                        */
122
/**************************************************************************/
123
29129
UINT _gxe_prompt_text_set_ext(GX_PROMPT *prompt, GX_CONST GX_STRING *text)
124
{
125
UINT status;
126
29129
UINT text_length = 0;
127
128
    /* Check for appropriate caller.  */
129

29129
    GX_INIT_AND_THREADS_CALLER_CHECKING
130
131
    /* Check error for valid pointer. */
132
29127
    if (prompt == GX_NULL)
133
    {
134
1
        return(GX_PTR_ERROR);
135
    }
136
137
29126
    if (text)
138
    {
139
29123
        if (text -> gx_string_ptr)
140
        {
141
29122
            status = _gx_utility_string_length_check(text -> gx_string_ptr, &text_length, text -> gx_string_length);
142
143
29122
            if (status != GX_SUCCESS)
144
            {
145
1
                return status;
146
            }
147
        }
148
149
29122
        if (text_length != text -> gx_string_length)
150
        {
151
1
            return GX_INVALID_STRING_LENGTH;
152
        }
153
    }
154
155
    /* Call the actual function.  */
156
29124
    status = _gx_prompt_text_set_ext(prompt, text);
157
158
    /* Return completion status.  */
159
29124
    return(status);
160
}
161