4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <papi_impl.h>
38 papiAttributeListAddLPString(papi_attribute_t
***list
, int flags
, char *name
,
41 papi_status_t result
= PAPI_BAD_ARGUMENT
;
43 if ((list
!= NULL
) && (name
!= NULL
) && (value
!= NULL
) &&
45 result
= papiAttributeListAddString(list
, flags
, name
, value
);
50 papiAttributeListAddLPStrings(papi_attribute_t
***list
, int flags
, char *name
,
53 papi_status_t result
= PAPI_OK
;
56 if ((list
== NULL
) || (name
== NULL
) || (values
== NULL
))
57 result
= PAPI_BAD_ARGUMENT
;
59 for (i
= 0; ((result
== PAPI_OK
) && (values
[i
] != NULL
));
60 i
++, flgs
= PAPI_ATTR_APPEND
)
61 result
= papiAttributeListAddString(list
, flgs
, name
,
68 papiAttributeListGetLPString(papi_attribute_t
**attributes
, char *key
,
73 papiAttributeListGetString(attributes
, NULL
, key
, &value
);
77 *string
= strdup(value
);
82 papiAttributeListGetLPStrings(papi_attribute_t
**attributes
, char *key
,
90 for (status
= papiAttributeListGetString(attributes
, &iter
,
93 status
= papiAttributeListGetString(attributes
, &iter
,
95 addlist(&values
, value
);
105 printer_name_from_uri_id(char *uri
, int32_t id
)
107 REQUEST
*request
= NULL
;
111 if ((result
= strrchr(uri
, '/')) != NULL
) {
114 result
= (char *)uri
;
116 if ((strcmp(result
, "jobs") == 0) ||
117 (strcmp(result
, "any") == 0) ||
118 (strcmp(result
, "all") == 0))
122 if ((result
[0] == NULL
) && (id
!= -1)) {
125 snprintf(path
, sizeof (path
), "%d-0", id
);
126 if ((request
= getrequest(path
)) != NULL
)
127 result
= request
->destination
;
130 result
= strdup(result
);
133 freerequest(request
);
139 * LP content type <-> MIME type conversion table. (order dependent)
145 { "text/plain", "simple" },
146 { "application/octet-stream", "raw" },
147 { "application/octet-stream", "any" },
148 { "application/postscript", "postscript" },
149 { "application/postscript", "ps" },
150 { "application/x-cif", "cif" },
151 { "application/x-dvi", "dvi" },
152 { "application/x-plot", "plot" },
153 { "application/x-ditroff", "troff" },
154 { "application/x-troff", "otroff" },
155 { "application/x-pr", "pr" },
156 { "application/x-fortran", "fortran" },
157 { "application/x-raster", "raster" },
162 mime_type_to_lp_type(char *mime_type
)
166 if (mime_type
== NULL
)
169 for (i
= 0; type_map
[i
].mime_type
!= NULL
; i
++)
170 if (strcasecmp(type_map
[i
].mime_type
, mime_type
) == 0)
171 return (type_map
[i
].lp_type
);
177 lp_type_to_mime_type(char *lp_type
)
182 return ("text/plain");
184 for (i
= 0; type_map
[i
].lp_type
!= NULL
; i
++)
185 if (strcasecmp(type_map
[i
].lp_type
, lp_type
) == 0)
186 return (type_map
[i
].mime_type
);