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 /** Pictbridge Application */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22
23 /* Include necessary system files. */
24
25 #define UX_SOURCE_CODE
26
27 #include "ux_api.h"
28 #include "ux_pictbridge.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _ux_pictbridge_xml_function_root_xml PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function decodes the "xml" tag */
44 /* */
45 /* INPUT */
46 /* */
47 /* pictbridge Pictbridge instance */
48 /* input_variable Pointer to variable */
49 /* input_string Pointer to string */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* Completion Status */
54 /* */
55 /* CALLS */
56 /* */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* _ux_pictbridge_object_parse */
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 /**************************************************************************/
_ux_pictbridge_xml_function_root_xml(UX_PICTBRIDGE * pictbridge,UCHAR * input_variable,UCHAR * input_string,UCHAR * xml_parameter)71 UINT _ux_pictbridge_xml_function_root_xml(UX_PICTBRIDGE *pictbridge, UCHAR *input_variable,
72 UCHAR *input_string, UCHAR *xml_parameter)
73 {
74 UINT status;
75 UINT input_length = 0;
76 UINT length = 0;
77
78 UX_PARAMETER_NOT_USED(input_string);
79 UX_PARAMETER_NOT_USED(xml_parameter);
80 UX_PARAMETER_NOT_USED(pictbridge);
81
82 /* Get the length of the variable. */
83 status = _ux_utility_string_length_check(input_variable, &input_length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
84 if (status != UX_SUCCESS)
85 return(status);
86
87 /* Get the length of the "version " variable. */
88 status = _ux_utility_string_length_check(_ux_pictbridge_xml_variable_version, &length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
89 if (status != UX_SUCCESS)
90 return(status);
91
92 /* If length do not match, no need to check for a match. */
93 if (length == input_length)
94 {
95
96 /* Both length match, we may have a variable name match. Check the names */
97 if (_ux_utility_memory_compare(_ux_pictbridge_xml_variable_version,input_variable, length) == UX_SUCCESS)
98 {
99
100 /* The variable name is OK, we do not check the xml version. */
101 return(UX_SUCCESS);
102
103 }
104
105 }
106 /* We get here when we reached an unexpected end of the XML object. */
107 return(UX_ERROR);
108 }
109
110