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_input_getcapability_capability_layouts */
36 /* PORTABLE C */
37 /* 6.1 */
38 /* */
39 /* */
40 /* AUTHOR */
41 /* */
42 /* Chaoqiong Xiao, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function decodes the "layouts" tag */
47 /* */
48 /* INPUT */
49 /* */
50 /* pictbridge Pictbridge instance */
51 /* input_variable Pointer to variable */
52 /* input_string Pointer to string */
53 /* xml_parameter Pointer to xml parameter */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* Completion Status */
58 /* */
59 /* CALLS */
60 /* */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* _ux_pictbridge_object_parse */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
71 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
72 /* resulting in version 6.1 */
73 /* */
74 /**************************************************************************/
_ux_pictbridge_xml_function_input_getcapability_capability_layouts(UX_PICTBRIDGE * pictbridge,UCHAR * input_variable,UCHAR * input_string,UCHAR * xml_parameter)75 UINT _ux_pictbridge_xml_function_input_getcapability_capability_layouts(UX_PICTBRIDGE *pictbridge,
76 UCHAR *input_variable, UCHAR *input_string, UCHAR *xml_parameter)
77 {
78 UINT input_length = 0;
79 UINT length = 0;
80 ULONG papersize;
81 UINT status;
82
83 UX_PARAMETER_NOT_USED(xml_parameter);
84
85 /* Get the length of the variable. This is an option and there may be none.*/
86 status = _ux_utility_string_length_check(input_variable, &input_length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
87 if (status != UX_SUCCESS)
88 return(status);
89
90 /* Check if there is a variable defined. */
91 if (input_length == 0)
92 {
93
94 /* No variable. Reset the layouts paperTypes option. */
95 pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_layouts_papersize = 0;
96
97 /* Return success. */
98 return(UX_SUCCESS);
99 }
100
101 /* Get the length of the "papersize " variable. */
102 status = _ux_utility_string_length_check(_ux_pictbridge_xml_variable_papersize, &length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
103 if (status != UX_SUCCESS)
104 return(status);
105
106 /* If length do not match, no need to check for a match. */
107 if (length == input_length)
108 {
109
110 /* Both length match, we may have a variable name match. Check the names */
111 if (_ux_utility_memory_compare(_ux_pictbridge_xml_variable_papersize,input_variable, length) == UX_SUCCESS)
112 {
113
114 /* Get the value for the papersize. */
115 status = _ux_pictbridge_element_to_hexa(input_string, &papersize);
116
117 /* Check status. If OK, save the papersize value for layout. */
118 if (status == UX_SUCCESS)
119 {
120
121 /* Set the layouts paperTypes option with the string value. */
122 pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_layouts_papersize = papersize;
123
124 /* The variable name is OK. We are done. */
125 return(UX_SUCCESS);
126 }
127 }
128
129 }
130 /* We get here when we reached an unexpected end of the XML object or a format error. */
131 return(UX_PICTBRIDGE_ERROR_SCRIPT_SYNTAX_ERROR);
132 }
133
134
135