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 /**   Utility Management (Utility)                                        */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_utility.h"
28 #include "gx_system.h"
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    _gxe_utility_string_to_alphamap                     PORTABLE C      */
35 /*                                                           6.1          */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    Kenneth Maxwell, Microsoft Corporation                              */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function checks error in utility string to alphamap function.  */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    text                                  pointer to string             */
47 /*                                                                        */
48 /*  OUTPUT                                                                */
49 /*                                                                        */
50 /*    status                                Completion status             */
51 /*                                                                        */
52 /*  CALLS                                                                 */
53 /*                                                                        */
54 /*    _gx_utility_string_to_alphamap        The actual utility string to  */
55 /*                                            alphamap function           */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    Application Code                                                    */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
66 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
67 /*                                            resulting in version 6.1    */
68 /*                                                                        */
69 /**************************************************************************/
70 #if defined(GX_ENABLE_DEPRECATED_STRING_API)
_gxe_utility_string_to_alphamap(GX_CONST GX_CHAR * text,GX_CONST GX_FONT * font,GX_PIXELMAP * textmap)71 UINT _gxe_utility_string_to_alphamap(GX_CONST GX_CHAR *text, GX_CONST GX_FONT *font, GX_PIXELMAP *textmap)
72 {
73 UINT status;
74 
75     if (text == GX_NULL || font == GX_NULL || textmap == GX_NULL)
76     {
77         return GX_PTR_ERROR;
78     }
79 
80     if (!_gx_system_memory_allocator || !_gx_system_memory_free)
81     {
82         return GX_SYSTEM_MEMORY_ERROR;
83     }
84 
85     status = _gx_utility_string_to_alphamap(text, font, textmap);
86 
87     /* Return completion status code. */
88     return(status);
89 }
90 #endif
91 
92 /**************************************************************************/
93 /*                                                                        */
94 /*  FUNCTION                                               RELEASE        */
95 /*                                                                        */
96 /*    _gxe_utility_string_to_alphamap_ext                 PORTABLE C      */
97 /*                                                           6.1          */
98 /*  AUTHOR                                                                */
99 /*                                                                        */
100 /*    Kenneth Maxwell, Microsoft Corporation                              */
101 /*                                                                        */
102 /*  DESCRIPTION                                                           */
103 /*                                                                        */
104 /*    This function checks error in utility string to alphamap function.  */
105 /*                                                                        */
106 /*  INPUT                                                                 */
107 /*                                                                        */
108 /*    text                                  pointer to string             */
109 /*                                                                        */
110 /*  OUTPUT                                                                */
111 /*                                                                        */
112 /*    status                                Completion status             */
113 /*                                                                        */
114 /*  CALLS                                                                 */
115 /*                                                                        */
116 /*    _gx_utility_string_to_alphamap_ext    The actual utility string to  */
117 /*                                            alphamap ext function       */
118 /*                                                                        */
119 /*  CALLED BY                                                             */
120 /*                                                                        */
121 /*    Application Code                                                    */
122 /*                                                                        */
123 /*  RELEASE HISTORY                                                       */
124 /*                                                                        */
125 /*    DATE              NAME                      DESCRIPTION             */
126 /*                                                                        */
127 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
128 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
129 /*                                            resulting in version 6.1    */
130 /*                                                                        */
131 /**************************************************************************/
_gxe_utility_string_to_alphamap_ext(GX_CONST GX_STRING * text,GX_CONST GX_FONT * font,GX_PIXELMAP * textmap)132 UINT    _gxe_utility_string_to_alphamap_ext(GX_CONST GX_STRING *text, GX_CONST GX_FONT *font, GX_PIXELMAP *textmap)
133 {
134 UINT status;
135 UINT text_length = 0;
136 
137     if ((text == GX_NULL) ||
138         (text -> gx_string_ptr == GX_NULL) ||
139         (font == GX_NULL) ||
140         (textmap == GX_NULL))
141     {
142         return GX_PTR_ERROR;
143     }
144 
145     if (!_gx_system_memory_allocator || !_gx_system_memory_free)
146     {
147         return GX_SYSTEM_MEMORY_ERROR;
148     }
149 
150     status = _gx_utility_string_length_check(text -> gx_string_ptr, &text_length, text -> gx_string_length);
151 
152     if (status != GX_SUCCESS)
153     {
154         return status;
155     }
156 
157     if (text_length != text -> gx_string_length)
158     {
159         return GX_INVALID_STRING_LENGTH;
160     }
161 
162     status = _gx_utility_string_to_alphamap_ext(text, font, textmap);
163 
164     /* Return completion status code. */
165     return(status);
166 }
167 
168