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_output_getdevicestatus_                 */
36 /*                                       errorreason                      */
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 errorreason 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_output_getdevicestatus_errorreason(UX_PICTBRIDGE * pictbridge,UCHAR * input_variable,UCHAR * input_string,UCHAR * xml_parameter)76 UINT  _ux_pictbridge_xml_function_output_getdevicestatus_errorreason(UX_PICTBRIDGE *pictbridge,
77                             UCHAR *input_variable, UCHAR *input_string, UCHAR *xml_parameter)
78 {
79 UINT    status;
80 ULONG   hexa_element;
81 
82     UX_PARAMETER_NOT_USED(input_string);
83     UX_PARAMETER_NOT_USED(input_variable);
84 
85     /* Get the error reason variable.  */
86     status = _ux_pictbridge_element_to_hexa(xml_parameter, &hexa_element);
87 
88     /* Check status.  */
89     if (status == UX_SUCCESS)
90     {
91         /* Check the returned value. Must be one of 5 possibilities.  */
92         if ((hexa_element & UX_PICTBRIDGE_PARAMETER_MAJOR_CODE_MASK) == UX_PICTBRIDGE_ERROR_REASON_NO_REASON        ||
93             (hexa_element & UX_PICTBRIDGE_PARAMETER_MAJOR_CODE_MASK) == UX_PICTBRIDGE_ERROR_REASON_PAPER_RELATED    ||
94             (hexa_element & UX_PICTBRIDGE_PARAMETER_MAJOR_CODE_MASK) == UX_PICTBRIDGE_ERROR_REASON_INK_RELATED      ||
95             (hexa_element & UX_PICTBRIDGE_PARAMETER_MAJOR_CODE_MASK) == UX_PICTBRIDGE_ERROR_REASON_HARDWARE_RELATED ||
96             (hexa_element & UX_PICTBRIDGE_PARAMETER_MAJOR_CODE_MASK) == UX_PICTBRIDGE_ERROR_REASON_FILE_RELATED)
97         {
98 
99             /* Save this value.  */
100             pictbridge -> ux_pictbridge_dpsclient.ux_pictbridge_devinfo_errorreason = hexa_element;
101 
102            /* We are done. */
103             return(UX_SUCCESS);
104         }
105     }
106 
107     /* We get here when we reached an unexpected end of the XML object or a format error.  */
108     return(UX_PICTBRIDGE_ERROR_SCRIPT_SYNTAX_ERROR);
109 
110 
111 }
112 
113 
114