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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 /* $Id: psm.c 146 2006-03-24 00:26:54Z njacobs $ */
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include <papi_impl.h>
41 #endif /* RTLD_GROUP */
44 #define PSM_DIR "/usr/lib/print"
48 psm_open(service_t
*svc
, char *scheme
)
50 papi_status_t result
= PAPI_OK
;
53 if ((scheme
== NULL
) || (strchr(scheme
, '/') != NULL
))
54 return (PAPI_BAD_ARGUMENT
);
56 snprintf(path
, sizeof (path
), PSM_DIR
"/psm-%s.so", scheme
);
58 svc
->so_handle
= dlopen(path
, RTLD_LAZY
|RTLD_LOCAL
|RTLD_GROUP
);
59 if (svc
->so_handle
== NULL
) { /* failed, set the result/message */
60 if ((access(path
, F_OK
) < 0) && (errno
== ENOENT
))
61 result
= PAPI_URI_SCHEME
;
63 result
= PAPI_NOT_POSSIBLE
;
65 detailed_error(svc
, "psm_open(%s): %s: %s", scheme
, path
,
74 psm_close(void *handle
)
80 psm_sym(service_t
*svc
, char *name
)
82 char *error
= "invalid input";
85 if ((svc
!= NULL
) && (svc
->so_handle
!= NULL
) && (name
!= NULL
)) {
86 if ((func
= dlsym(svc
->so_handle
, name
)) == NULL
)
91 detailed_error(svc
, "psm_sym(%s): %s", name
, error
);