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 (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 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_utility_string_compare                          PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function compares two strings character by character.          */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    string_1                              String to be compared         */
48 /*    string_2                              Another string to be compared */
49 /*    count                                 number of bytes to compare    */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    [GX_TRUE | GX_FALSE]                  [equal | not equal]           */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    GUIX Internal Code                                                  */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  09-30-2020     Kenneth Maxwell          Initial Version 6.1           */
68 /*                                                                        */
69 /**************************************************************************/
_gx_utility_string_compare(GX_CONST GX_STRING * string_1,GX_CONST GX_STRING * string_2,UINT count)70 GX_BOOL _gx_utility_string_compare(GX_CONST GX_STRING *string_1, GX_CONST GX_STRING *string_2, UINT count)
71 {
72 UINT index = 0;
73 
74     if ((string_1 -> gx_string_length < count) || (string_2 -> gx_string_length < count))
75     {
76         /* Not equal.*/
77         return GX_FALSE;
78     }
79 
80     while (index < count)
81     {
82         if (string_1 -> gx_string_ptr[index] != string_2 -> gx_string_ptr[index])
83         {
84             /* Not equal. */
85             return GX_FALSE;
86         }
87 
88         index++;
89     }
90 
91     /* Equal. */
92     return GX_TRUE;
93 }
94 
95