| 2752 | */ |
| 2753 | |
| 2754 | ipp_t * /* O - IPP response message */ |
| 2755 | ippNewResponse(ipp_t *request) /* I - IPP request message */ |
| 2756 | { |
| 2757 | ipp_t *response; /* IPP response message */ |
| 2758 | ipp_attribute_t *attr; /* Current attribute */ |
| 2759 | |
| 2760 | |
| 2761 | /* |
| 2762 | * Range check input... |
| 2763 | */ |
| 2764 | |
| 2765 | if (!request) |
| 2766 | return (NULL); |
| 2767 | |
| 2768 | /* |
| 2769 | * Create a new IPP message... |
| 2770 | */ |
| 2771 | |
| 2772 | if ((response = ippNew()) == NULL) |
| 2773 | return (NULL); |
| 2774 | |
| 2775 | /* |
| 2776 | * Copy the request values over to the response... |
| 2777 | */ |
| 2778 | |
| 2779 | response->request.status.version[0] = request->request.op.version[0]; |
| 2780 | response->request.status.version[1] = request->request.op.version[1]; |
| 2781 | response->request.status.request_id = request->request.op.request_id; |
| 2782 | |
| 2783 | /* |
| 2784 | * The first attribute MUST be attributes-charset... |
| 2785 | */ |
| 2786 | |
| 2787 | attr = request->attrs; |
| 2788 | |
| 2789 | if (attr && attr->name && !strcmp(attr->name, "attributes-charset") && |
| 2790 | attr->group_tag == IPP_TAG_OPERATION && |
| 2791 | attr->value_tag == IPP_TAG_CHARSET && |
| 2792 | attr->num_values == 1) |
| 2793 | { |
| 2794 | /* |
| 2795 | * Copy charset from request... |
| 2796 | */ |
| 2797 | |
| 2798 | ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_CHARSET, |
| 2799 | "attributes-charset", NULL, attr->values[0].string.text); |
| 2800 | } |
| 2801 | else |
| 2802 | { |
| 2803 | /* |
| 2804 | * Use "utf-8" as the default... |
| 2805 | */ |
| 2806 | |
| 2807 | ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_CHARSET, |
| 2808 | "attributes-charset", NULL, "utf-8"); |
| 2809 | } |
| 2810 | |
| 2811 | /* |
no test coverage detected