GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_multi_line_text_input_char_insert.c Lines: 24 24 100.0 %
Date: 2024-12-05 08:52:37 Branches: 32 32 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
/**   Multi Line Text Input Management (Multi Line Text Input)            */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_multi_line_text_input.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_multi_line_text_input_char_insert              PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function checks for errors in the multi line text input        */
46
/*    char insert call.                                                   */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    text_input                            Multi line text input widget  */
51
/*                                            control block               */
52
/*    str                                   Utf8 string to be inserted    */
53
/*    str_size                              Inserted string size in bytes */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    status                                Completion status             */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_multi_line_text_input_char_insert                               */
62
/*                                          Actual multi line text input  */
63
/*                                            char insert 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
7
UINT _gxe_multi_line_text_input_char_insert(GX_MULTI_LINE_TEXT_INPUT *text_input, GX_UBYTE *str, UINT str_size)
80
{
81
UINT status;
82
83
    /* Check for invalid caller.  */
84

7
    GX_INIT_AND_THREADS_CALLER_CHECKING
85
86
    /* Check for invalid input pointers. */
87

5
    if ((text_input == GX_NULL) || (str == GX_NULL))
88
    {
89
2
        return(GX_PTR_ERROR);
90
    }
91
92
    /* Check for invalid value. */
93
3
    if (str_size == 0)
94
    {
95
1
        return(GX_INVALID_VALUE);
96
    }
97
98
    /* Check for invalid widget check. */
99
2
    if (text_input -> gx_widget_type == 0)
100
    {
101
1
        return(GX_INVALID_WIDGET);
102
    }
103
104
    /* Call actual multi line text input char insert function.  */
105
1
    status = _gx_multi_line_text_input_char_insert(text_input, str, str_size);
106
107
1
    return status;
108
}
109
#endif
110
111
/**************************************************************************/
112
/*                                                                        */
113
/*  FUNCTION                                               RELEASE        */
114
/*                                                                        */
115
/*    _gxe_multi_line_text_input_char_insert_ext          PORTABLE C      */
116
/*                                                           6.1          */
117
/*  AUTHOR                                                                */
118
/*                                                                        */
119
/*    Kenneth Maxwell, Microsoft Corporation                              */
120
/*                                                                        */
121
/*  DESCRIPTION                                                           */
122
/*                                                                        */
123
/*    This function checks for errors in the multi line text input        */
124
/*    char insert call.                                                   */
125
/*                                                                        */
126
/*  INPUT                                                                 */
127
/*                                                                        */
128
/*    text_input                            Multi line text input widget  */
129
/*                                            control block               */
130
/*    str                                   Utf8 string to be inserted    */
131
/*                                                                        */
132
/*  OUTPUT                                                                */
133
/*                                                                        */
134
/*    status                                Completion status             */
135
/*                                                                        */
136
/*  CALLS                                                                 */
137
/*                                                                        */
138
/*    _gx_multi_line_text_input_char_insert_ext                           */
139
/*                                          Actual multi line text input  */
140
/*                                            char insert ext call        */
141
/*                                                                        */
142
/*  CALLED BY                                                             */
143
/*                                                                        */
144
/*    Application Code                                                    */
145
/*                                                                        */
146
/*  RELEASE HISTORY                                                       */
147
/*                                                                        */
148
/*    DATE              NAME                      DESCRIPTION             */
149
/*                                                                        */
150
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
151
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
152
/*                                            resulting in version 6.1    */
153
/*                                                                        */
154
/**************************************************************************/
155
102
UINT _gxe_multi_line_text_input_char_insert_ext(GX_MULTI_LINE_TEXT_INPUT *text_input, GX_CONST GX_STRING *str)
156
{
157
UINT status;
158
102
UINT string_length = 0;
159
160
    /* Check for invalid caller.  */
161

102
    GX_INIT_AND_THREADS_CALLER_CHECKING
162
163
    /* Check for invalid input pointers. */
164

100
    if ((text_input == GX_NULL) || (str == GX_NULL) || (str -> gx_string_ptr == GX_NULL))
165
    {
166
3
        return(GX_PTR_ERROR);
167
    }
168
169
97
    status = _gx_utility_string_length_check(str -> gx_string_ptr, &string_length, str -> gx_string_length);
170
171
97
    if (status != GX_SUCCESS)
172
    {
173
1
        return status;
174
    }
175
176
    /* Check for invalid string length. */
177
96
    if (string_length != str -> gx_string_length)
178
    {
179
1
        return GX_INVALID_STRING_LENGTH;
180
    }
181
182
    /* Check for invalid widget check. */
183
95
    if (text_input -> gx_widget_type == 0)
184
    {
185
1
        return(GX_INVALID_WIDGET);
186
    }
187
188
    /* Call actual multi line text input char insert function.  */
189
94
    status = _gx_multi_line_text_input_char_insert_ext(text_input, str);
190
191
94
    return status;
192
}
193