1355b466jacobs/*
2355b466jacobs * CDDL HEADER START
3355b466jacobs *
4355b466jacobs * The contents of this file are subject to the terms of the
5355b466jacobs * Common Development and Distribution License (the "License").
6355b466jacobs * You may not use this file except in compliance with the License.
7355b466jacobs *
8355b466jacobs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9355b466jacobs * or http://www.opensolaris.org/os/licensing.
10355b466jacobs * See the License for the specific language governing permissions
11355b466jacobs * and limitations under the License.
12355b466jacobs *
13355b466jacobs * When distributing Covered Code, include this CDDL HEADER in each
14355b466jacobs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15355b466jacobs * If applicable, add the following below this CDDL HEADER, with the
16355b466jacobs * fields enclosed by brackets "[]" replaced with your own identifying
17355b466jacobs * information: Portions Copyright [yyyy] [name of copyright owner]
18355b466jacobs *
19355b466jacobs * CDDL HEADER END
20355b466jacobs */
21355b466jacobs
22355b466jacobs/*
23355b466jacobs * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24355b466jacobs * Use is subject to license terms.
25355b466jacobs *
26355b466jacobs */
27355b466jacobs
28355b466jacobs/* $Id: cups-accept-jobs.c 146 2006-03-24 00:26:54Z njacobs $ */
29355b466jacobs
30355b466jacobs#pragma ident	"%Z%%M%	%I%	%E% SMI"
31355b466jacobs
32355b466jacobs#include <stdio.h>
33355b466jacobs#include <papi.h>
34355b466jacobs#include <ipp.h>
35355b466jacobs#include <ipp-listener.h>
36355b466jacobs
37355b466jacobspapi_status_t
38355b466jacobscups_accept_jobs(papi_service_t svc, papi_attribute_t **request,
39355b466jacobs		papi_attribute_t ***response)
40355b466jacobs{
41355b466jacobs	papi_status_t status;
42355b466jacobs	papi_attribute_t **operational = NULL;
43355b466jacobs
44355b466jacobs	char *queue = NULL;
45355b466jacobs
46355b466jacobs	/* Get operational attributes from the request */
47355b466jacobs	(void) papiAttributeListGetCollection(request, NULL,
48355b466jacobs				"operational-attributes-group", &operational);
49355b466jacobs
50355b466jacobs	/*
51355b466jacobs	 * The operational-attributes-group must contain:
52355b466jacobs	 *	printer-uri
53355b466jacobs	 */
54355b466jacobs	get_printer_id(operational, &queue, NULL);
55355b466jacobs	if (queue == NULL) {
56355b466jacobs		ipp_set_status(response, status, "printer-uri: %s",
57355b466jacobs			papiStatusString(status));
58355b466jacobs		return (PAPI_BAD_REQUEST);
59355b466jacobs	}
60355b466jacobs
61355b466jacobs	if ((status = papiPrinterResume(svc, queue)) != PAPI_OK) {
62355b466jacobs		ipp_set_status(response, status, "accept failed: %s: %s",
63355b466jacobs				(queue ? queue : "(null)"),
64355b466jacobs				ipp_svc_status_mesg(svc, status));
65355b466jacobs	}
66355b466jacobs
67355b466jacobs	return (status);
68355b466jacobs}
69