GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_binres_language_info_load.c Lines: 20 20 100.0 %
Date: 2024-12-05 08:52:37 Branches: 8 8 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
/**   Binres Loader Management (Binres Loader)                            */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_binres_loader.h"
28
29
/**************************************************************************/
30
/*                                                                        */
31
/*  FUNCTION                                               RELEASE        */
32
/*                                                                        */
33
/*    gx_binres_language_info_load                        PORTABLE C      */
34
/*                                                           6.1          */
35
/*  AUTHOR                                                                */
36
/*                                                                        */
37
/*    Kenneth Maxwell, Microsoft Corporation                              */
38
/*                                                                        */
39
/*  DESCRIPTION                                                           */
40
/*                                                                        */
41
/*    This function retrives language header information.                 */
42
/*                                                                        */
43
/*  INPUT                                                                 */
44
/*                                                                        */
45
/*    root_address                          Root address of binary        */
46
/*                                            resource data               */
47
/*    header                                Returned Language header      */
48
/*                                                                        */
49
/*  OUTPUT                                                                */
50
/*                                                                        */
51
/*    Status                                Completion status             */
52
/*                                                                        */
53
/*  CALLS                                                                 */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLED BY                                                             */
58
/*                                                                        */
59
/*    Application Code                                                    */
60
/*    GUIX Internal 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
#ifdef GX_BINARY_RESOURCE_SUPPORT
72
4
UINT _gx_binres_language_info_load(GX_UBYTE *root_address, GX_LANGUAGE_HEADER *put_info)
73
{
74
4
UINT                status = GX_SUCCESS;
75
GX_BINRES_DATA_INFO info;
76
GX_RESOURCE_HEADER  header;
77
GX_STRING_HEADER    string_header;
78
UINT                lang_index;
79
80
4
    memset(&info, 0, sizeof(GX_BINRES_DATA_INFO));
81
82
4
    info.gx_binres_root_address = root_address;
83
84
    /* Read Resource header. */
85
4
    info.gx_binres_read_offset = 0;
86
4
    _gx_binres_resource_header_load(&info, &header);
87
88
    /* Skip theme info.  */
89
4
    info.gx_binres_read_offset += header.gx_resource_header_theme_data_size;
90
91
4
    if (header.gx_resource_header_magic_number != GX_MAGIC_NUMBER)
92
    {
93
1
        return GX_INVALID_FORMAT;
94
    }
95
96
    /* Read string header. */
97
3
    _gx_binres_string_header_load(&info, &string_header);
98
99
3
    if (string_header.gx_string_header_magic_number != GX_MAGIC_NUMBER)
100
    {
101
1
        status = GX_INVALID_FORMAT;
102
    }
103
    else
104
    {
105
3
        for (lang_index = 0; lang_index < string_header.gx_string_header_language_count; lang_index++)
106
        {
107
            /* Read language header.  */
108
2
            _gx_binres_language_header_load(&info, put_info);
109
110
2
            if (put_info -> gx_language_header_magic_number != GX_MAGIC_NUMBER)
111
            {
112
1
                status = GX_INVALID_FORMAT;
113
1
                break;
114
            }
115
1
            info.gx_binres_read_offset += put_info -> gx_language_header_data_size;
116
1
            put_info++;
117
        }
118
    }
119
120
3
    return status;
121
}
122
#endif
123