1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   Pictbridge Application                                              */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /* Include necessary system files.  */
25 
26 #define UX_SOURCE_CODE
27 
28 #include "ux_api.h"
29 #include "ux_pictbridge.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _ux_pictbridge_xml_function_input_getcapability_capability_layouts  */
37 /*                                                        PORTABLE C      */
38 /*                                                           6.1          */
39 /*                                                                        */
40 /*                                                                        */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Chaoqiong Xiao, Microsoft Corporation                               */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function decodes the "layouts" tag                             */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    pictbridge                             Pictbridge instance          */
52 /*    input_variable                         Pointer to variable          */
53 /*    input_string                           Pointer to string            */
54 /*    xml_parameter                          Pointer to xml parameter     */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    Completion Status                                                   */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    _ux_pictbridge_object_parse                                         */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
72 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_ux_pictbridge_xml_function_input_getcapability_capability_layouts(UX_PICTBRIDGE * pictbridge,UCHAR * input_variable,UCHAR * input_string,UCHAR * xml_parameter)76 UINT  _ux_pictbridge_xml_function_input_getcapability_capability_layouts(UX_PICTBRIDGE *pictbridge,
77                             UCHAR *input_variable, UCHAR *input_string, UCHAR *xml_parameter)
78 {
79 UINT    input_length = 0;
80 UINT    length = 0;
81 ULONG   papersize;
82 UINT    status;
83 
84     UX_PARAMETER_NOT_USED(xml_parameter);
85 
86     /* Get the length of the variable. This is an option and there may be none.*/
87     status = _ux_utility_string_length_check(input_variable, &input_length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
88     if (status != UX_SUCCESS)
89         return(status);
90 
91     /* Check if there is a variable defined.  */
92     if (input_length == 0)
93     {
94 
95         /* No variable. Reset the layouts paperTypes option.  */
96         pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_layouts_papersize =  0;
97 
98         /* Return success.  */
99         return(UX_SUCCESS);
100     }
101 
102     /* Get the length of the "papersize " variable.  */
103     status = _ux_utility_string_length_check(_ux_pictbridge_xml_variable_papersize, &length, UX_PICTBRIDGE_MAX_VARIABLE_SIZE);
104     if (status != UX_SUCCESS)
105         return(status);
106 
107     /* If length do not match, no need to check for a match.  */
108     if (length == input_length)
109     {
110 
111         /* Both length match, we may have a variable name match. Check the names */
112         if (_ux_utility_memory_compare(_ux_pictbridge_xml_variable_papersize,input_variable, length) == UX_SUCCESS)
113         {
114 
115             /* Get the value for the papersize. */
116             status = _ux_pictbridge_element_to_hexa(input_string, &papersize);
117 
118             /* Check status. If OK, save the papersize value for layout.  */
119             if (status == UX_SUCCESS)
120             {
121 
122                 /* Set the layouts paperTypes option with the string value.  */
123                 pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_layouts_papersize =  papersize;
124 
125                 /* The variable name is OK. We are done.  */
126                 return(UX_SUCCESS);
127             }
128         }
129 
130     }
131     /* We get here when we reached an unexpected end of the XML object or a format error.  */
132     return(UX_PICTBRIDGE_ERROR_SCRIPT_SYNTAX_ERROR);
133 }
134 
135 
136