GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_utility_unicode_to_string.c Lines: 7 7 100.0 %
Date: 2024-12-12 17:16:36 Branches: 2 2 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
/** USBX Component                                                        */
16
/**                                                                       */
17
/**   Utility                                                             */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
23
/* Include necessary system files.  */
24
25
#define UX_SOURCE_CODE
26
27
#include "ux_api.h"
28
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _ux_utility_unicode_to_string                       PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Chaoqiong Xiao, Microsoft Corporation                               */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This function converts a unicode string to a zero terminated        */
43
/*    ascii string.                                                       */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    source                                Unicode String                */
48
/*    destination                           Ascii String                  */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    none                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    USBX Components                                                     */
61
/*                                                                        */
62
/*  RELEASE HISTORY                                                       */
63
/*                                                                        */
64
/*    DATE              NAME                      DESCRIPTION             */
65
/*                                                                        */
66
/*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
67
/*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
68
/*                                            resulting in version 6.1    */
69
/*                                                                        */
70
/**************************************************************************/
71
21
VOID  _ux_utility_unicode_to_string(UCHAR *source, UCHAR *destination)
72
{
73
ULONG   string_length;
74
75
    /* Obtain the length of the unicode string.  This is the first byte*/
76
21
    string_length = (ULONG) *source++;
77
78
    /* Parse the unicode string. First byte is always 0, second byte is the
79
       ASCII character.  */
80
286
    while(string_length--)
81
    {
82
        /* First character is from the source.  */
83
265
        *destination++ = *source++;
84
85
        /* Second character of unicode word is 0.  */
86
265
        source++;
87
    }
88
89
    /* We are done with the ascii string. Insert a zero at the end. */
90
21
    *destination = 0;
91
92
    /* Finished.  */
93
21
    return;
94
}
95