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