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