xref: /titanic_41/usr/src/lib/print/libpapi-dynamic/common/job.c (revision 355b4669e025ff377602b6fc7caaf30dbc218371)
1*355b4669Sjacobs /*
2*355b4669Sjacobs  * CDDL HEADER START
3*355b4669Sjacobs  *
4*355b4669Sjacobs  * The contents of this file are subject to the terms of the
5*355b4669Sjacobs  * Common Development and Distribution License (the "License").
6*355b4669Sjacobs  * You may not use this file except in compliance with the License.
7*355b4669Sjacobs  *
8*355b4669Sjacobs  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*355b4669Sjacobs  * or http://www.opensolaris.org/os/licensing.
10*355b4669Sjacobs  * See the License for the specific language governing permissions
11*355b4669Sjacobs  * and limitations under the License.
12*355b4669Sjacobs  *
13*355b4669Sjacobs  * When distributing Covered Code, include this CDDL HEADER in each
14*355b4669Sjacobs  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*355b4669Sjacobs  * If applicable, add the following below this CDDL HEADER, with the
16*355b4669Sjacobs  * fields enclosed by brackets "[]" replaced with your own identifying
17*355b4669Sjacobs  * information: Portions Copyright [yyyy] [name of copyright owner]
18*355b4669Sjacobs  *
19*355b4669Sjacobs  * CDDL HEADER END
20*355b4669Sjacobs  */
21*355b4669Sjacobs 
22*355b4669Sjacobs /*
23*355b4669Sjacobs  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*355b4669Sjacobs  * Use is subject to license terms.
25*355b4669Sjacobs  *
26*355b4669Sjacobs  */
27*355b4669Sjacobs 
28*355b4669Sjacobs /* $Id: job.c 146 2006-03-24 00:26:54Z njacobs $ */
29*355b4669Sjacobs 
30*355b4669Sjacobs #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*355b4669Sjacobs 
32*355b4669Sjacobs /*LINTLIBRARY*/
33*355b4669Sjacobs 
34*355b4669Sjacobs #include <stdlib.h>
35*355b4669Sjacobs #include <papi_impl.h>
36*355b4669Sjacobs 
37*355b4669Sjacobs void
papiJobFree(papi_job_t job)38*355b4669Sjacobs papiJobFree(papi_job_t job)
39*355b4669Sjacobs {
40*355b4669Sjacobs 	job_t *tmp = (job_t *)job;
41*355b4669Sjacobs 
42*355b4669Sjacobs 	if (tmp != NULL) {
43*355b4669Sjacobs 		void (*f)();
44*355b4669Sjacobs 
45*355b4669Sjacobs 		f = (void (*)())psm_sym(tmp->svc, "papiJobFree");
46*355b4669Sjacobs 		if (f != NULL)
47*355b4669Sjacobs 			f(tmp->job);
48*355b4669Sjacobs 		free(tmp);
49*355b4669Sjacobs 	}
50*355b4669Sjacobs }
51*355b4669Sjacobs 
52*355b4669Sjacobs void
papiJobListFree(papi_job_t * jobs)53*355b4669Sjacobs papiJobListFree(papi_job_t *jobs)
54*355b4669Sjacobs {
55*355b4669Sjacobs 	if (jobs != NULL) {
56*355b4669Sjacobs 		int i;
57*355b4669Sjacobs 
58*355b4669Sjacobs 		for (i = 0; jobs[i] != NULL; i++)
59*355b4669Sjacobs 			papiJobFree(jobs[i]);
60*355b4669Sjacobs 		free(jobs);
61*355b4669Sjacobs 	}
62*355b4669Sjacobs }
63*355b4669Sjacobs 
64*355b4669Sjacobs papi_attribute_t **
papiJobGetAttributeList(papi_job_t job)65*355b4669Sjacobs papiJobGetAttributeList(papi_job_t job)
66*355b4669Sjacobs {
67*355b4669Sjacobs 	papi_attribute_t **result = NULL;
68*355b4669Sjacobs 	job_t *j = job;
69*355b4669Sjacobs 
70*355b4669Sjacobs 	if (job != NULL) {
71*355b4669Sjacobs 		papi_attribute_t **(*f)();
72*355b4669Sjacobs 
73*355b4669Sjacobs 		f = (papi_attribute_t **(*)())psm_sym(j->svc,
74*355b4669Sjacobs 						"papiJobGetAttributeList");
75*355b4669Sjacobs 		if (f != NULL)
76*355b4669Sjacobs 			result = f(j->job);
77*355b4669Sjacobs 	}
78*355b4669Sjacobs 
79*355b4669Sjacobs 	return (result);
80*355b4669Sjacobs }
81*355b4669Sjacobs 
82*355b4669Sjacobs char *
papiJobGetPrinterName(papi_job_t job)83*355b4669Sjacobs papiJobGetPrinterName(papi_job_t job)
84*355b4669Sjacobs {
85*355b4669Sjacobs 	char *result = NULL;
86*355b4669Sjacobs 	job_t *j = job;
87*355b4669Sjacobs 
88*355b4669Sjacobs 	if (job != NULL) {
89*355b4669Sjacobs 		char *(*f)();
90*355b4669Sjacobs 
91*355b4669Sjacobs 		f = (char *(*)())psm_sym(j->svc, "papiJobGetPrinterName");
92*355b4669Sjacobs 		if (f != NULL)
93*355b4669Sjacobs 			result = f(j->job);
94*355b4669Sjacobs 	}
95*355b4669Sjacobs 
96*355b4669Sjacobs 	return (result);
97*355b4669Sjacobs }
98*355b4669Sjacobs 
99*355b4669Sjacobs int32_t
papiJobGetId(papi_job_t job)100*355b4669Sjacobs papiJobGetId(papi_job_t job)
101*355b4669Sjacobs {
102*355b4669Sjacobs 	int32_t result = -1;
103*355b4669Sjacobs 	job_t *j = job;
104*355b4669Sjacobs 
105*355b4669Sjacobs 	if (job != NULL) {
106*355b4669Sjacobs 		int32_t (*f)();
107*355b4669Sjacobs 
108*355b4669Sjacobs 		f = (int32_t (*)())psm_sym(j->svc, "papiJobGetId");
109*355b4669Sjacobs 		if (f != NULL)
110*355b4669Sjacobs 			result = f(j->job);
111*355b4669Sjacobs 	}
112*355b4669Sjacobs 
113*355b4669Sjacobs 	return (result);
114*355b4669Sjacobs }
115*355b4669Sjacobs 
116*355b4669Sjacobs papi_job_ticket_t *
papiJobGetJobTicket(papi_job_t job)117*355b4669Sjacobs papiJobGetJobTicket(papi_job_t job)
118*355b4669Sjacobs {
119*355b4669Sjacobs 	papi_job_ticket_t *result = NULL;
120*355b4669Sjacobs 	job_t *j = job;
121*355b4669Sjacobs 
122*355b4669Sjacobs 	if (job != NULL) {
123*355b4669Sjacobs 		papi_job_ticket_t *(*f)();
124*355b4669Sjacobs 
125*355b4669Sjacobs 		f = (papi_job_ticket_t *(*)())psm_sym(j->svc,
126*355b4669Sjacobs 						"papiJobGetJobTicket");
127*355b4669Sjacobs 		if (f != NULL)
128*355b4669Sjacobs 			result = f(j->job);
129*355b4669Sjacobs 	}
130*355b4669Sjacobs 
131*355b4669Sjacobs 	return (result);
132*355b4669Sjacobs }
133*355b4669Sjacobs 
134*355b4669Sjacobs /* common support for papiJob{Submit|SubmitByReference|Validate} */
135*355b4669Sjacobs static papi_status_t
_papi_job_submit_reference_or_validate(papi_service_t handle,char * printer,papi_attribute_t ** job_attributes,papi_job_ticket_t * job_ticket,char ** files,papi_job_t * job,char * function)136*355b4669Sjacobs _papi_job_submit_reference_or_validate(papi_service_t handle, char *printer,
137*355b4669Sjacobs 		papi_attribute_t **job_attributes,
138*355b4669Sjacobs 		papi_job_ticket_t *job_ticket, char **files, papi_job_t *job,
139*355b4669Sjacobs 		char *function)
140*355b4669Sjacobs {
141*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
142*355b4669Sjacobs 	service_t *svc = handle;
143*355b4669Sjacobs 	job_t *j = NULL;
144*355b4669Sjacobs 	papi_status_t (*f)();
145*355b4669Sjacobs 
146*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL) || (files == NULL) ||
147*355b4669Sjacobs 	    (job == NULL))
148*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
149*355b4669Sjacobs 
150*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
151*355b4669Sjacobs 		return (result);
152*355b4669Sjacobs 
153*355b4669Sjacobs 	if ((*job = j = calloc(1, sizeof (*j))) == NULL)
154*355b4669Sjacobs 		return (PAPI_TEMPORARY_ERROR);
155*355b4669Sjacobs 
156*355b4669Sjacobs 	j->svc = svc;
157*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(j->svc, function);
158*355b4669Sjacobs 	if (f != NULL)
159*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_attributes,
160*355b4669Sjacobs 				job_ticket, files, &j->job);
161*355b4669Sjacobs 
162*355b4669Sjacobs 	return (result);
163*355b4669Sjacobs }
164*355b4669Sjacobs 
165*355b4669Sjacobs papi_status_t
papiJobSubmit(papi_service_t handle,char * printer,papi_attribute_t ** job_attributes,papi_job_ticket_t * job_ticket,char ** files,papi_job_t * job)166*355b4669Sjacobs papiJobSubmit(papi_service_t handle, char *printer,
167*355b4669Sjacobs 		papi_attribute_t **job_attributes,
168*355b4669Sjacobs 		papi_job_ticket_t *job_ticket, char **files, papi_job_t *job)
169*355b4669Sjacobs {
170*355b4669Sjacobs 	return (_papi_job_submit_reference_or_validate(handle, printer,
171*355b4669Sjacobs 				job_attributes, job_ticket, files, job,
172*355b4669Sjacobs 				"papiJobSubmit"));
173*355b4669Sjacobs }
174*355b4669Sjacobs 
175*355b4669Sjacobs papi_status_t
papiJobSubmitByReference(papi_service_t handle,char * printer,papi_attribute_t ** job_attributes,papi_job_ticket_t * job_ticket,char ** files,papi_job_t * job)176*355b4669Sjacobs papiJobSubmitByReference(papi_service_t handle, char *printer,
177*355b4669Sjacobs 		papi_attribute_t **job_attributes,
178*355b4669Sjacobs 		papi_job_ticket_t *job_ticket, char **files, papi_job_t *job)
179*355b4669Sjacobs {
180*355b4669Sjacobs 	return (_papi_job_submit_reference_or_validate(handle, printer,
181*355b4669Sjacobs 				job_attributes, job_ticket, files, job,
182*355b4669Sjacobs 				"papiJobSubmitByReference"));
183*355b4669Sjacobs }
184*355b4669Sjacobs 
185*355b4669Sjacobs papi_status_t
papiJobValidate(papi_service_t handle,char * printer,papi_attribute_t ** job_attributes,papi_job_ticket_t * job_ticket,char ** files,papi_job_t * job)186*355b4669Sjacobs papiJobValidate(papi_service_t handle, char *printer,
187*355b4669Sjacobs 		papi_attribute_t **job_attributes,
188*355b4669Sjacobs 		papi_job_ticket_t *job_ticket, char **files, papi_job_t *job)
189*355b4669Sjacobs {
190*355b4669Sjacobs 	return (_papi_job_submit_reference_or_validate(handle, printer,
191*355b4669Sjacobs 				job_attributes, job_ticket, files, job,
192*355b4669Sjacobs 				"papiJobValidate"));
193*355b4669Sjacobs }
194*355b4669Sjacobs 
195*355b4669Sjacobs papi_status_t
papiJobStreamOpen(papi_service_t handle,char * printer,papi_attribute_t ** job_attributes,papi_job_ticket_t * job_ticket,papi_stream_t * stream)196*355b4669Sjacobs papiJobStreamOpen(papi_service_t handle, char *printer,
197*355b4669Sjacobs 		papi_attribute_t **job_attributes,
198*355b4669Sjacobs 		papi_job_ticket_t *job_ticket, papi_stream_t *stream)
199*355b4669Sjacobs {
200*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
201*355b4669Sjacobs 	service_t *svc = handle;
202*355b4669Sjacobs 	papi_status_t (*f)();
203*355b4669Sjacobs 
204*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL) || (stream == NULL))
205*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
206*355b4669Sjacobs 
207*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
208*355b4669Sjacobs 		return (result);
209*355b4669Sjacobs 
210*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(svc, "papiJobStreamOpen");
211*355b4669Sjacobs 	if (f != NULL)
212*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_attributes,
213*355b4669Sjacobs 				job_ticket, stream);
214*355b4669Sjacobs 
215*355b4669Sjacobs 	return (result);
216*355b4669Sjacobs }
217*355b4669Sjacobs 
218*355b4669Sjacobs papi_status_t
papiJobStreamWrite(papi_service_t handle,papi_stream_t stream,void * buffer,size_t buflen)219*355b4669Sjacobs papiJobStreamWrite(papi_service_t handle,
220*355b4669Sjacobs 		papi_stream_t stream, void *buffer, size_t buflen)
221*355b4669Sjacobs {
222*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
223*355b4669Sjacobs 	service_t *svc = handle;
224*355b4669Sjacobs 	papi_status_t (*f)();
225*355b4669Sjacobs 
226*355b4669Sjacobs 	if ((svc == NULL) || (stream == NULL) || (buffer == NULL) ||
227*355b4669Sjacobs 	    (buflen == 0))
228*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
229*355b4669Sjacobs 
230*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(svc, "papiJobStreamWrite");
231*355b4669Sjacobs 	if (f != NULL)
232*355b4669Sjacobs 		result = f(svc->svc_handle, stream, buffer, buflen);
233*355b4669Sjacobs 
234*355b4669Sjacobs 	return (result);
235*355b4669Sjacobs }
236*355b4669Sjacobs 
237*355b4669Sjacobs papi_status_t
papiJobStreamClose(papi_service_t handle,papi_stream_t stream,papi_job_t * job)238*355b4669Sjacobs papiJobStreamClose(papi_service_t handle, papi_stream_t stream, papi_job_t *job)
239*355b4669Sjacobs {
240*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
241*355b4669Sjacobs 	service_t *svc = handle;
242*355b4669Sjacobs 	job_t *j = NULL;
243*355b4669Sjacobs 	papi_status_t (*f)();
244*355b4669Sjacobs 
245*355b4669Sjacobs 	if ((svc == NULL) || (stream == NULL) || (job == NULL))
246*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
247*355b4669Sjacobs 
248*355b4669Sjacobs 	if ((*job = j = calloc(1, sizeof (*j))) == NULL)
249*355b4669Sjacobs 		return (PAPI_TEMPORARY_ERROR);
250*355b4669Sjacobs 
251*355b4669Sjacobs 	j->svc = svc;
252*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(j->svc, "papiJobStreamClose");
253*355b4669Sjacobs 	if (f != NULL)
254*355b4669Sjacobs 		result = f(svc->svc_handle, stream, &j->job);
255*355b4669Sjacobs 
256*355b4669Sjacobs 	return (result);
257*355b4669Sjacobs }
258*355b4669Sjacobs 
259*355b4669Sjacobs papi_status_t
papiJobQuery(papi_service_t handle,char * printer,int32_t job_id,char ** requested_attrs,papi_job_t * job)260*355b4669Sjacobs papiJobQuery(papi_service_t handle, char *printer, int32_t job_id,
261*355b4669Sjacobs 		char **requested_attrs, papi_job_t *job)
262*355b4669Sjacobs {
263*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
264*355b4669Sjacobs 	service_t *svc = handle;
265*355b4669Sjacobs 	job_t *j = NULL;
266*355b4669Sjacobs 	papi_status_t (*f)();
267*355b4669Sjacobs 
268*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL))
269*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
270*355b4669Sjacobs 
271*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
272*355b4669Sjacobs 		return (result);
273*355b4669Sjacobs 
274*355b4669Sjacobs 	if ((*job = j = calloc(1, sizeof (*j))) == NULL)
275*355b4669Sjacobs 		return (PAPI_TEMPORARY_ERROR);
276*355b4669Sjacobs 
277*355b4669Sjacobs 	j->svc = svc;
278*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(j->svc, "papiJobQuery");
279*355b4669Sjacobs 	if (f != NULL)
280*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_id,
281*355b4669Sjacobs 				requested_attrs, &j->job);
282*355b4669Sjacobs 
283*355b4669Sjacobs 	return (result);
284*355b4669Sjacobs }
285*355b4669Sjacobs 
286*355b4669Sjacobs papi_status_t
papiJobMove(papi_service_t handle,char * printer,int32_t job_id,char * destination)287*355b4669Sjacobs papiJobMove(papi_service_t handle, char *printer, int32_t job_id,
288*355b4669Sjacobs 		char *destination)
289*355b4669Sjacobs {
290*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
291*355b4669Sjacobs 	service_t *svc = handle;
292*355b4669Sjacobs 	papi_status_t (*f)();
293*355b4669Sjacobs 
294*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL) || (job_id < 0))
295*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
296*355b4669Sjacobs 
297*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
298*355b4669Sjacobs 		return (result);
299*355b4669Sjacobs 
300*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(svc, "papiJobMove");
301*355b4669Sjacobs 	if (f != NULL) {
302*355b4669Sjacobs 		papi_attribute_t **attrs = getprinterbyname(destination, NULL);
303*355b4669Sjacobs 
304*355b4669Sjacobs 		papiAttributeListGetString(attrs, NULL,
305*355b4669Sjacobs 				"printer-uri-supported", &destination);
306*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_id, destination);
307*355b4669Sjacobs 		papiAttributeListFree(attrs);
308*355b4669Sjacobs 	}
309*355b4669Sjacobs 
310*355b4669Sjacobs 	return (result);
311*355b4669Sjacobs }
312*355b4669Sjacobs 
313*355b4669Sjacobs /* common support for papiJob{Cancel|Release|Restart|Promote} */
314*355b4669Sjacobs static papi_status_t
_papi_job_handle_printer_id(papi_service_t handle,char * printer,int32_t job_id,char * function)315*355b4669Sjacobs _papi_job_handle_printer_id(papi_service_t handle,
316*355b4669Sjacobs 		char *printer, int32_t job_id, char *function)
317*355b4669Sjacobs {
318*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
319*355b4669Sjacobs 	service_t *svc = handle;
320*355b4669Sjacobs 	papi_status_t (*f)();
321*355b4669Sjacobs 
322*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL) || (job_id < 0))
323*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
324*355b4669Sjacobs 
325*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
326*355b4669Sjacobs 		return (result);
327*355b4669Sjacobs 
328*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(svc, function);
329*355b4669Sjacobs 	if (f != NULL)
330*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_id);
331*355b4669Sjacobs 
332*355b4669Sjacobs 	return (result);
333*355b4669Sjacobs }
334*355b4669Sjacobs 
335*355b4669Sjacobs papi_status_t
papiJobCancel(papi_service_t handle,char * printer,int32_t job_id)336*355b4669Sjacobs papiJobCancel(papi_service_t handle, char *printer, int32_t job_id)
337*355b4669Sjacobs {
338*355b4669Sjacobs 	return (_papi_job_handle_printer_id(handle, printer, job_id,
339*355b4669Sjacobs 				"papiJobCancel"));
340*355b4669Sjacobs }
341*355b4669Sjacobs 
342*355b4669Sjacobs papi_status_t
papiJobRelease(papi_service_t handle,char * printer,int32_t job_id)343*355b4669Sjacobs papiJobRelease(papi_service_t handle, char *printer, int32_t job_id)
344*355b4669Sjacobs {
345*355b4669Sjacobs 	return (_papi_job_handle_printer_id(handle, printer, job_id,
346*355b4669Sjacobs 				"papiJobRelease"));
347*355b4669Sjacobs }
348*355b4669Sjacobs 
349*355b4669Sjacobs papi_status_t
papiJobRestart(papi_service_t handle,char * printer,int32_t job_id)350*355b4669Sjacobs papiJobRestart(papi_service_t handle, char *printer, int32_t job_id)
351*355b4669Sjacobs {
352*355b4669Sjacobs 	return (_papi_job_handle_printer_id(handle, printer, job_id,
353*355b4669Sjacobs 				"papiJobRestart"));
354*355b4669Sjacobs }
355*355b4669Sjacobs 
356*355b4669Sjacobs papi_status_t
papiJobPromote(papi_service_t handle,char * printer,int32_t job_id)357*355b4669Sjacobs papiJobPromote(papi_service_t handle, char *printer, int32_t job_id)
358*355b4669Sjacobs {
359*355b4669Sjacobs 	return (_papi_job_handle_printer_id(handle, printer, job_id,
360*355b4669Sjacobs 				"papiJobPromote"));
361*355b4669Sjacobs }
362*355b4669Sjacobs 
363*355b4669Sjacobs papi_status_t
papiJobCommit(papi_service_t handle,char * printer,int32_t job_id)364*355b4669Sjacobs papiJobCommit(papi_service_t handle, char *printer, int32_t job_id)
365*355b4669Sjacobs {
366*355b4669Sjacobs 	return (_papi_job_handle_printer_id(handle, printer, job_id,
367*355b4669Sjacobs 				"papiJobCommit"));
368*355b4669Sjacobs }
369*355b4669Sjacobs 
370*355b4669Sjacobs papi_status_t
papiJobHold(papi_service_t handle,char * printer,int32_t job_id)371*355b4669Sjacobs papiJobHold(papi_service_t handle, char *printer, int32_t job_id)
372*355b4669Sjacobs {
373*355b4669Sjacobs 	return (_papi_job_handle_printer_id(handle, printer, job_id,
374*355b4669Sjacobs 				"papiJobHold"));
375*355b4669Sjacobs }
376*355b4669Sjacobs 
377*355b4669Sjacobs papi_status_t
papiJobModify(papi_service_t handle,char * printer,int32_t job_id,papi_attribute_t ** attributes,papi_job_t * job)378*355b4669Sjacobs papiJobModify(papi_service_t handle, char *printer, int32_t job_id,
379*355b4669Sjacobs 		papi_attribute_t **attributes, papi_job_t *job)
380*355b4669Sjacobs {
381*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
382*355b4669Sjacobs 	service_t *svc = handle;
383*355b4669Sjacobs 	job_t *j = NULL;
384*355b4669Sjacobs 	papi_status_t (*f)();
385*355b4669Sjacobs 
386*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL) || (job_id < 0) ||
387*355b4669Sjacobs 	    (attributes == NULL))
388*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
389*355b4669Sjacobs 
390*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
391*355b4669Sjacobs 		return (result);
392*355b4669Sjacobs 
393*355b4669Sjacobs 	if ((*job = j = calloc(1, sizeof (*j))) == NULL)
394*355b4669Sjacobs 		return (PAPI_TEMPORARY_ERROR);
395*355b4669Sjacobs 
396*355b4669Sjacobs 	j->svc = svc;
397*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(j->svc, "papiJobModify");
398*355b4669Sjacobs 	if (f != NULL)
399*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_id, attributes,
400*355b4669Sjacobs 				&j->job);
401*355b4669Sjacobs 
402*355b4669Sjacobs 	return (result);
403*355b4669Sjacobs }
404*355b4669Sjacobs 
405*355b4669Sjacobs /*
406*355b4669Sjacobs  * The functions defined below are private to Solaris.  They are here
407*355b4669Sjacobs  * temporarily, until equivalent functionality makes it's way into the PAPI
408*355b4669Sjacobs  * spec.  This is expected in the next minor version after v1.0.
409*355b4669Sjacobs  */
410*355b4669Sjacobs papi_status_t
papiJobCreate(papi_service_t handle,char * printer,papi_attribute_t ** job_attributes,papi_job_ticket_t * job_ticket,papi_job_t * job)411*355b4669Sjacobs papiJobCreate(papi_service_t handle, char *printer,
412*355b4669Sjacobs 		papi_attribute_t **job_attributes,
413*355b4669Sjacobs 		papi_job_ticket_t *job_ticket, papi_job_t *job)
414*355b4669Sjacobs {
415*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
416*355b4669Sjacobs 	service_t *svc = handle;
417*355b4669Sjacobs 	job_t *j = NULL;
418*355b4669Sjacobs 	papi_status_t (*f)();
419*355b4669Sjacobs 
420*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL) || (job == NULL))
421*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
422*355b4669Sjacobs 
423*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
424*355b4669Sjacobs 		return (result);
425*355b4669Sjacobs 
426*355b4669Sjacobs 	if ((*job = j = calloc(1, sizeof (*j))) == NULL)
427*355b4669Sjacobs 		return (PAPI_TEMPORARY_ERROR);
428*355b4669Sjacobs 
429*355b4669Sjacobs 	j->svc = svc;
430*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(j->svc, "papiJobCreate");
431*355b4669Sjacobs 	if (f != NULL)
432*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, job_attributes,
433*355b4669Sjacobs 				job_ticket, &j->job);
434*355b4669Sjacobs 
435*355b4669Sjacobs 	return (result);
436*355b4669Sjacobs }
437*355b4669Sjacobs 
438*355b4669Sjacobs papi_status_t
papiJobStreamAdd(papi_service_t handle,char * printer,int32_t id,papi_stream_t * stream)439*355b4669Sjacobs papiJobStreamAdd(papi_service_t handle, char *printer, int32_t id,
440*355b4669Sjacobs 		papi_stream_t *stream)
441*355b4669Sjacobs {
442*355b4669Sjacobs 	papi_status_t result = PAPI_INTERNAL_ERROR;
443*355b4669Sjacobs 	service_t *svc = handle;
444*355b4669Sjacobs 	papi_status_t (*f)();
445*355b4669Sjacobs 
446*355b4669Sjacobs 	if ((svc == NULL) || (printer == NULL))
447*355b4669Sjacobs 		return (PAPI_BAD_ARGUMENT);
448*355b4669Sjacobs 
449*355b4669Sjacobs 	if ((result = service_connect(svc, printer)) != PAPI_OK)
450*355b4669Sjacobs 		return (result);
451*355b4669Sjacobs 
452*355b4669Sjacobs 	f = (papi_status_t (*)())psm_sym(svc, "papiJobStreamAdd");
453*355b4669Sjacobs 	if (f != NULL)
454*355b4669Sjacobs 		result = f(svc->svc_handle, svc->name, id, stream);
455*355b4669Sjacobs 
456*355b4669Sjacobs 	return (result);
457*355b4669Sjacobs }
458