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_dps PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Chaoqiong Xiao, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function decodes the "dps" 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_dps(UX_PICTBRIDGE * pictbridge,UCHAR * input_variable,UCHAR * input_string,UCHAR * xml_parameter)71 UINT _ux_pictbridge_xml_function_root_dps(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(xml_parameter);
79 UX_PARAMETER_NOT_USED(pictbridge);
80
81 /* Get the length of the variable. */
82 status = _ux_utility_string_length_check(input_variable, &input_length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
83 if (status != UX_SUCCESS)
84 return(status);
85
86 /* Get the length of the "xmlns " variable. */
87 status = _ux_utility_string_length_check(_ux_pictbridge_xml_variable_xmlns, &length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
88 if (status != UX_SUCCESS)
89 return(status);
90
91 /* If length do not match, no need to check for a match. */
92 if (length == input_length)
93 {
94
95 /* Both length match, we may have a variable name match. Check the names */
96 if (_ux_utility_memory_compare(_ux_pictbridge_xml_variable_xmlns,input_variable, length) == UX_SUCCESS)
97 {
98
99 /* Get the length of the string. */
100 status = _ux_utility_string_length_check(input_string, &input_length, UX_PICTBRIDGE_MAX_STRING_SIZE);
101 if (status != UX_SUCCESS)
102 return(status);
103
104 /* Get the length of the "xmlns" string. */
105 status = _ux_utility_string_length_check(_ux_pictbridge_xml_string_xmlns, &length, UX_PICTBRIDGE_MAX_STRING_SIZE);
106 if (status != UX_SUCCESS)
107 return(status);
108
109 /* If length do not match, no need to check for a match. */
110 if (length == input_length)
111 {
112
113 /* Both length match, we may have a string name match. Check the names */
114 if (_ux_utility_memory_compare(_ux_pictbridge_xml_string_xmlns,input_string, length) == UX_SUCCESS)
115
116 /* The variable name is OK. We are done. */
117 return(UX_SUCCESS);
118 }
119 }
120
121 }
122 /* We get here when we reached an unexpected end of the XML object. */
123 return(UX_ERROR);
124 }
125
126
127