JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 3: Extended Library Functions, Volume 3     Oracle Solaris 11 Information Library
search filter icon
search icon

Document Information

Preface

Extended Library Functions, Volume 3

endprojent(3PROJECT)

Exacct(3PERL)

Exacct::Catalog(3PERL)

Exacct::File(3PERL)

Exacct::Object(3PERL)

Exacct::Object::Group(3PERL)

Exacct::Object::Item(3PERL)

fgetprojent(3PROJECT)

getdefaultproj(3PROJECT)

getprojbyid(3PROJECT)

getprojbyname(3PROJECT)

getprojent(3PROJECT)

getprojidbyname(3PROJECT)

inproj(3PROJECT)

Kstat(3PERL)

Lgrp(3PERL)

libpicl(3PICL)

libpicltree(3PICLTREE)

nv_alloc_fini(3NVPAIR)

nv_alloc_init(3NVPAIR)

nv_alloc_reset(3NVPAIR)

nvlist_add_boolean(3NVPAIR)

nvlist_add_boolean_array(3NVPAIR)

nvlist_add_boolean_value(3NVPAIR)

nvlist_add_byte(3NVPAIR)

nvlist_add_byte_array(3NVPAIR)

nvlist_add_double(3NVPAIR)

nvlist_add_int16(3NVPAIR)

nvlist_add_int16_array(3NVPAIR)

nvlist_add_int32(3NVPAIR)

nvlist_add_int32_array(3NVPAIR)

nvlist_add_int64(3NVPAIR)

nvlist_add_int64_array(3NVPAIR)

nvlist_add_int8(3NVPAIR)

nvlist_add_int8_array(3NVPAIR)

nvlist_add_nvlist(3NVPAIR)

nvlist_add_nvlist_array(3NVPAIR)

nvlist_add_nvpair(3NVPAIR)

nvlist_add_string(3NVPAIR)

nvlist_add_string_array(3NVPAIR)

nvlist_add_uint16(3NVPAIR)

nvlist_add_uint16_array(3NVPAIR)

nvlist_add_uint32(3NVPAIR)

nvlist_add_uint32_array(3NVPAIR)

nvlist_add_uint64(3NVPAIR)

nvlist_add_uint64_array(3NVPAIR)

nvlist_add_uint8(3NVPAIR)

nvlist_add_uint8_array(3NVPAIR)

nvlist_alloc(3NVPAIR)

nvlist_dup(3NVPAIR)

nvlist_exists(3NVPAIR)

nvlist_flag(3NVPAIR)

nvlist_free(3NVPAIR)

nvlist_lookup_boolean(3NVPAIR)

nvlist_lookup_boolean_array(3NVPAIR)

nvlist_lookup_boolean_value(3NVPAIR)

nvlist_lookup_byte(3NVPAIR)

nvlist_lookup_byte_array(3NVPAIR)

nvlist_lookup_double(3NVPAIR)

nvlist_lookup_int16(3NVPAIR)

nvlist_lookup_int16_array(3NVPAIR)

nvlist_lookup_int32(3NVPAIR)

nvlist_lookup_int32_array(3NVPAIR)

nvlist_lookup_int64(3NVPAIR)

nvlist_lookup_int64_array(3NVPAIR)

nvlist_lookup_int8(3NVPAIR)

nvlist_lookup_int8_array(3NVPAIR)

nvlist_lookup_nv_alloc(3NVPAIR)

nvlist_lookup_nvlist(3NVPAIR)

nvlist_lookup_nvlist_array(3NVPAIR)

nvlist_lookup_nvpair(3NVPAIR)

nvlist_lookup_pairs(3NVPAIR)

nvlist_lookup_string(3NVPAIR)

nvlist_lookup_string_array(3NVPAIR)

nvlist_lookup_uint16(3NVPAIR)

nvlist_lookup_uint16_array(3NVPAIR)

nvlist_lookup_uint32(3NVPAIR)

nvlist_lookup_uint32_array(3NVPAIR)

nvlist_lookup_uint64(3NVPAIR)

nvlist_lookup_uint64_array(3NVPAIR)

nvlist_lookup_uint8(3NVPAIR)

nvlist_lookup_uint8_array(3NVPAIR)

nvlist_merge(3NVPAIR)

nvlist_next_nvpair(3NVPAIR)

nvlist_pack(3NVPAIR)

nvlist_remove(3NVPAIR)

nvlist_remove_all(3NVPAIR)

nvlist_size(3NVPAIR)

nvlist_unpack(3NVPAIR)

nvlist_xalloc(3NVPAIR)

nvlist_xdup(3NVPAIR)

nvlist_xpack(3NVPAIR)

nvlist_xunpack(3NVPAIR)

nvpair_name(3NVPAIR)

nvpair_type(3NVPAIR)

nvpair_value_boolean_array(3NVPAIR)

nvpair_value_boolean_value(3NVPAIR)

nvpair_value_byte(3NVPAIR)

nvpair_value_byte_array(3NVPAIR)

nvpair_value_double(3NVPAIR)

nvpair_value_int16(3NVPAIR)

nvpair_value_int16_array(3NVPAIR)

nvpair_value_int32(3NVPAIR)

nvpair_value_int32_array(3NVPAIR)

nvpair_value_int64(3NVPAIR)

nvpair_value_int64_array(3NVPAIR)

nvpair_value_int8(3NVPAIR)

nvpair_value_int8_array(3NVPAIR)

nvpair_value_nvlist(3NVPAIR)

nvpair_value_nvlist_array(3NVPAIR)

nvpair_value_string(3NVPAIR)

nvpair_value_string_array(3NVPAIR)

nvpair_value_uint16(3NVPAIR)

nvpair_value_uint16_array(3NVPAIR)

nvpair_value_uint32(3NVPAIR)

nvpair_value_uint32_array(3NVPAIR)

nvpair_value_uint64(3NVPAIR)

nvpair_value_uint64_array(3NVPAIR)

nvpair_value_uint8(3NVPAIR)

nvpair_value_uint8_array(3NVPAIR)

pam(3PAM)

pam_acct_mgmt(3PAM)

pam_authenticate(3PAM)

pam_chauthtok(3PAM)

pam_close_session(3PAM)

pam_end(3PAM)

pam_get_data(3PAM)

pam_getenv(3PAM)

pam_getenvlist(3PAM)

pam_get_item(3PAM)

pam_get_user(3PAM)

pam_open_session(3PAM)

pam_putenv(3PAM)

pam_setcred(3PAM)

pam_set_data(3PAM)

pam_set_item(3PAM)

pam_sm(3PAM)

pam_sm_acct_mgmt(3PAM)

pam_sm_authenticate(3PAM)

pam_sm_chauthtok(3PAM)

pam_sm_close_session(3PAM)

pam_sm_open_session(3PAM)

pam_sm_setcred(3PAM)

pam_start(3PAM)

pam_strerror(3PAM)

papiAttributeListAddBoolean(3PAPI)

papiAttributeListAddCollection(3PAPI)

papiAttributeListAddDatetime(3PAPI)

papiAttributeListAddInteger(3PAPI)

papiAttributeListAddMetadata(3PAPI)

papiAttributeListAddRange(3PAPI)

papiAttributeListAddResolution(3PAPI)

papiAttributeListAddString(3PAPI)

papiAttributeListAddValue(3PAPI)

papiAttributeListDelete(3PAPI)

papiAttributeListFind(3PAPI)

papiAttributeListFree(3PAPI)

papiAttributeListFromString(3PAPI)

papiAttributeListGetBoolean(3PAPI)

papiAttributeListGetCollection(3PAPI)

papiAttributeListGetDatetime(3PAPI)

papiAttributeListGetInteger(3PAPI)

papiAttributeListGetMetadata(3PAPI)

papiAttributeListGetNext(3PAPI)

papiAttributeListGetRange(3PAPI)

papiAttributeListGetResolution(3PAPI)

papiAttributeListGetString(3PAPI)

papiAttributeListGetValue(3PAPI)

papiAttributeListToString(3PAPI)

papiJobCancel(3PAPI)

papiJobFree(3PAPI)

papiJobGetAttributeList(3PAPI)

papiJobGetId(3PAPI)

papiJobGetJobTicket(3PAPI)

papiJobGetPrinterName(3PAPI)

papiJobHold(3PAPI)

papiJobListFree(3PAPI)

papiJobModify(3PAPI)

papiJobMove(3PAPI)

papiJobPromote(3PAPI)

papiJobQuery(3PAPI)

papiJobRelease(3PAPI)

papiJobRestart(3PAPI)

papiJobStreamClose(3PAPI)

papiJobStreamOpen(3PAPI)

papiJobStreamWrite(3PAPI)

papiJobSubmit(3PAPI)

papiJobSubmitByReference(3PAPI)

papiJobValidate(3PAPI)

papiLibrarySupportedCall(3PAPI)

papiLibrarySupportedCalls(3PAPI)

papiPrinterAdd(3PAPI)

papiPrinterDisable(3PAPI)

papiPrinterEnable(3PAPI)

papiPrinterFree(3PAPI)

papiPrinterGetAttributeList(3PAPI)

papiPrinterListFree(3PAPI)

papiPrinterListJobs(3PAPI)

papiPrinterModify(3PAPI)

papiPrinterPause(3PAPI)

papiPrinterPurgeJobs(3PAPI)

papiPrinterQuery(3PAPI)

papiPrinterRemove(3PAPI)

papiPrinterResume(3PAPI)

papiPrintersList(3PAPI)

papiServiceCreate(3PAPI)

papiServiceDestroy(3PAPI)

papiServiceGetAppData(3PAPI)

papiServiceGetAttributeList(3PAPI)

papiServiceGetEncryption(3PAPI)

papiServiceGetPassword(3PAPI)

papiServiceGetServiceName(3PAPI)

papiServiceGetStatusMessage(3PAPI)

papiServiceGetUserName(3PAPI)

papiServiceSetAppData(3PAPI)

papiServiceSetAuthCB(3PAPI)

papiServiceSetEncryption(3PAPI)

papiServiceSetPassword(3PAPI)

papiServiceSetUserName(3PAPI)

papiStatusString(3PAPI)

picld_log(3PICLTREE)

picld_plugin_register(3PICLTREE)

picl_find_node(3PICL)

picl_get_first_prop(3PICL)

picl_get_frutree_parent(3PICL)

picl_get_next_by_col(3PICL)

picl_get_next_by_row(3PICL)

picl_get_next_prop(3PICL)

picl_get_node_by_path(3PICL)

picl_get_prop_by_name(3PICL)

picl_get_propinfo(3PICL)

picl_get_propinfo_by_name(3PICL)

picl_get_propval(3PICL)

picl_get_propval_by_name(3PICL)

picl_get_root(3PICL)

picl_initialize(3PICL)

picl_set_propval(3PICL)

picl_set_propval_by_name(3PICL)

picl_shutdown(3PICL)

picl_strerror(3PICL)

picl_wait(3PICL)

picl_walk_tree_by_class(3PICL)

pool_associate(3POOL)

pool_component_info(3POOL)

pool_component_to_elem(3POOL)

pool_conf_alloc(3POOL)

pool_conf_close(3POOL)

pool_conf_commit(3POOL)

pool_conf_export(3POOL)

pool_conf_free(3POOL)

pool_conf_info(3POOL)

pool_conf_location(3POOL)

pool_conf_open(3POOL)

pool_conf_remove(3POOL)

pool_conf_rollback(3POOL)

pool_conf_status(3POOL)

pool_conf_to_elem(3POOL)

pool_conf_update(3POOL)

pool_conf_validate(3POOL)

pool_create(3POOL)

pool_destroy(3POOL)

pool_dissociate(3POOL)

pool_dynamic_location(3POOL)

pool_error(3POOL)

pool_get_binding(3POOL)

pool_get_owning_resource(3POOL)

pool_get_pool(3POOL)

pool_get_property(3POOL)

pool_get_resource(3POOL)

pool_get_resource_binding(3POOL)

pool_get_status(3POOL)

pool_info(3POOL)

pool_put_property(3POOL)

pool_query_components(3POOL)

pool_query_pool_resources(3POOL)

pool_query_pools(3POOL)

pool_query_resource_components(3POOL)

pool_query_resources(3POOL)

pool_resource_create(3POOL)

pool_resource_destroy(3POOL)

pool_resource_info(3POOL)

pool_resource_to_elem(3POOL)

pool_resource_transfer(3POOL)

pool_resource_type_list(3POOL)

pool_resource_xtransfer(3POOL)

pool_rm_property(3POOL)

pool_set_binding(3POOL)

pool_set_status(3POOL)

pool_static_location(3POOL)

pool_strerror(3POOL)

pool_to_elem(3POOL)

pool_value_alloc(3POOL)

pool_value_free(3POOL)

pool_value_get_bool(3POOL)

pool_value_get_double(3POOL)

pool_value_get_int64(3POOL)

pool_value_get_name(3POOL)

pool_value_get_string(3POOL)

pool_value_get_type(3POOL)

pool_value_get_uint64(3POOL)

pool_value_set_bool(3POOL)

pool_value_set_double(3POOL)

pool_value_set_int64(3POOL)

pool_value_set_name(3POOL)

pool_value_set_string(3POOL)

pool_value_set_uint64(3POOL)

pool_version(3POOL)

pool_walk_components(3POOL)

pool_walk_pools(3POOL)

pool_walk_properties(3POOL)

pool_walk_resources(3POOL)

Privilege(3PERL)

proc_service(3PROC)

Project(3PERL)

project_walk(3PROJECT)

ps_kill(3PROC)

ps_lcontinue(3PROC)

ps_lgetfpregs(3PROC)

ps_lgetregs(3PROC)

ps_lgetxregs(3PROC)

ps_lgetxregsize(3PROC)

ps_lrolltoaddr(3PROC)

ps_lsetfpregs(3PROC)

ps_lsetregs(3PROC)

ps_lsetxregs(3PROC)

ps_lstop(3PROC)

ps_pcontinue(3PROC)

ps_pdread(3PROC)

ps_pdwrite(3PROC)

ps_pglobal_lookup(3PROC)

ps_pglobal_sym(3PROC)

ps_pread(3PROC)

ps_pstop(3PROC)

ps_ptread(3PROC)

ps_ptwrite(3PROC)

ps_pwrite(3PROC)

ptree_add_node(3PICLTREE)

ptree_add_prop(3PICLTREE)

ptree_add_row_to_table(3PICLTREE)

ptree_create_and_add_node(3PICLTREE)

ptree_create_and_add_prop(3PICLTREE)

ptree_create_node(3PICLTREE)

ptree_create_prop(3PICLTREE)

ptree_create_table(3PICLTREE)

ptree_delete_node(3PICLTREE)

ptree_delete_prop(3PICLTREE)

ptree_destroy_node(3PICLTREE)

ptree_destroy_prop(3PICLTREE)

ptree_find_node(3PICLTREE)

ptree_get_first_prop(3PICLTREE)

ptree_get_frutree_parent(3PICLTREE)

ptree_get_next_by_col(3PICLTREE)

ptree_get_next_by_row(3PICLTREE)

ptree_get_next_prop(3PICLTREE)

ptree_get_node_by_path(3PICLTREE)

ptree_get_prop_by_name(3PICLTREE)

ptree_get_propinfo(3PICLTREE)

ptree_get_propinfo_by_name(3PICLTREE)

ptree_get_propval(3PICLTREE)

ptree_get_propval_by_name(3PICLTREE)

ptree_get_root(3PICLTREE)

ptree_init_propinfo(3PICLTREE)

ptree_post_event(3PICLTREE)

ptree_register_handler(3PICLTREE)

ptree_unregister_handler(3PICLTREE)

ptree_update_propval(3PICLTREE)

ptree_update_propval_by_name(3PICLTREE)

ptree_walk_tree_by_class(3PICLTREE)

reparse_add(3REPARSE)

reparse_create(3REPARSE)

reparse_delete(3REPARSE)

reparse_deref(3REPARSE)

reparse_free(3REPARSE)

reparse_init(3REPARSE)

reparse_parse(3REPARSE)

reparse_remove(3REPARSE)

reparse_unparse(3REPARSE)

reparse_validate(3REPARSE)

rp_plugin_init(3REPARSE)

setproject(3PROJECT)

setprojent(3PROJECT)

Task(3PERL)

Ucred(3PERL)

papiPrintersList

, papiPrinterQuery

, papiPrinterAdd

, papiPrinterModify

, papiPrinterRemove

, papiPrinterDisable

, papiPrinterEnable

, papiPrinterPause

, papiPrinterResume

, papiPrinterPurgeJobs

, papiPrinterListJobs

, papiPrinterGetAttributeList

, papiPrinterFree

, papiPrinterListFree

- print object manipulation

Synopsis

cc [ flag… ] file-lpapi [ library… ] 
#include <papi.h>

papi_status_t papiPrintersList(papi_service_t handle,
     char **requested_attrs, papi_filter_t *filter,
     papi_printer_t **printers);
papi_status_t papiPrinterQuery(papi_service_t handle, char *name,
     char **requested_attrs, papi_attribute_t **job_attributes,
     papi_printer_t *printer);
papi_status_t papiPrinterAdd(papi_service_t handle, char *name,
     papi_attribute_t **attributes, papi_printer_t *printer);
papi_status_t papiPrinterModify(papi_service_t handle, char *name,
     papi_attribute_t **attributes, papi_printer_t *printer);
papi_status_t papiPrinterRemove(papi_service_t handle, char *name);
papi_status_t papiPrinterDisable(papi_service_t handle, char *name,
     char *message);
papi_status_t papiPrinterEnable(papi_service_t handle, char *name);
papi_status_t papiPrinterPause(papi_service_t handle, char *name,
     char *message);
papi_status_t papiPrinterResume(papi_service_t handle, char *name);
papi_status_t papiPrinterPurgeJobs(papi_service_t handle, char *name,
     papi_job_t **jobs);
papi_status_t papiPrinterListJobs(papi_service_t handle, char *name,
     char **requested_attrs, int type_mask, int max_num_jobs,
     papi_job_t **jobs);
papi_attribute_t **papiPrinterGetAttributeList(papi_printer_t printer);
void papiPrinterFree(papi_printer_t printer);
void papiPrinterListFree(papi_printer_t *printers);

Parameters

attributes

a set of attributes to be applied to a printer object

filter

a filter to be applied during printer enumeration

handle

a pointer to a handle to be used for all PAPI operations, created by calling papiServiceCreate()

job_attributes

unused

jobs

a pointer to a list to return job objects (initialized to NULL) enumerated by papiPrinterGetJobs()

max_num_jobs

the maximum number of jobs to return from a papiPrinterGetJobs() request

message

a message to be associated with a printer while disabled or paused

name

the name of the printer object being operated on

printer

a pointer to a printer object (initialized to NULL) to be filled in by papiPrinterQuery(), papiPrinterAdd(), and papiPrinterModify()

printers

a pointer to a list to return printer objects (initialized to NULL) enumerated by papiPrintersList()

requested_attrs

a null-terminated array of pointers to attribute names requested during printer enumeration (papiPrintersList()), printer query (papiPrinterQuery()), or job enumeration (papiPrinterListJobs())

type_mask

a bit field indicating which type of jobs to return PAPI_LIST_JOBS_OTHERS include jobs submitted by others. The default is to report only on your own jobs

PAPI_LIST_JOBS_COMPLETED

include completed jobs

PAPI_LIST_JOBS_NOT_COMPLETED

include jobs not complete

PAPI_LIST_JOBS_ALL

report on all jobs

Description

The papiPrintersList() function retrieves the requested attributes from the print service(s) for all available printers. Because the Solaris implementation is name service-enabled, applications should retrieve only the printer-name and printer-uri-supported attributes using this function, thereby reducing the overhead involved in generating a printer list. Further integration of printer state and capabilities can be performed with papiPrinterQuery().

The papiPrinterAdd(), papiPrinterModify(), and papiPrinterRemove() functions allow for creation, modification, and removal of print queues. Print queues are added or modified according to the attribute list passed into the call. A printer object is returned that reflects the configuration of the printer after the addition or modification has been applied. At this time, they provide only minimal functionality and only for the LP print service.

The papiPrinterDisable() and papiPrinterEnable() functions allow applications to turn off and on queueing (accepting print requests) for a print queue. The papiPrinterEnable() and papiPrinterDisable() functions allow applications to turn on and off print job processing for a print queue.

The papiPrinterPause() function stops queueing of print jobs on the named print queue.

The papiPrinterResume() function resumes queueing of print jobs on the named print queue.

The papiPrinterPurgeJobs() function allows applications to delete all print jobs that it has privilege to remove. A list of cancelled jobs is returned in the jobs argument.

The papiPrinterListJobs() function enumerates print jobs on a particular queue. papiPrinterGetAttributeList() retrieves an attribute list from a printer object.

The papiPrinterGetAttributeList() function retrieves an attribute list from a printer object returned from papiPrinterQuery(), papiPrintersList(), papiPrinterModify(), and papiPrinterAdd(). This attribute list can be searched for various information about the printer object.

The papiPrinterFree() and papiPrinterListFree() functions deallocate memory allocated for the return of printer object(s) from functions that return printer objects.

Return Values

Upon successful completion, all functions that return a value return PAPI_OK. Otherwise, they return an appropriate papi_status_t() indicating the type of failure.

Upon successful completion, papiPrinterGetAttributeList() returns a pointer to the requested data. Otherwise, it returns NULL.

Examples

Example 1 Enumerate all available printers.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libintl.h>
#include <pwd.h>
#include <papi.h>

static int
authCB(papi_service_t svc, void *app_data)
{
    char prompt[BUFSIZ];
    char *user, *svc_name, *passphrase;

    /* get the name of the service we are contacting */
    if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
            return (-1);

    /* find out who we are supposed to be */
    if ((user = papiServiceGetUserName(svc)) == NULL) {
            struct passwd *pw;

            if ((pw = getpwuid(getuid())) != NULL)
                    user = pw->pw_name;
            else
                    user = "nobody";
    }

    /* build the prompt string */
    snprintf(prompt, sizeof (prompt),
            gettext("passphrase for %s to access %s: "), user,
                   svc_name);

    /* ask for the passphrase */
    if ((passphrase = getpassphrase(prompt)) != NULL)
            papiServiceSetPassword(svc, passphrase);

    return (0);
}

/*ARGSUSED*/
int
main(int ac, char *av[])
{
    papi_status_t status;
    papi_service_t svc = NULL;
    papi_printer_t *printers = NULL;
    char *attrs[] = { "printer-name", "printer-uri-supported", NULL };
    char *svc_name = NULL;
    int c;

    while ((c = getopt(ac, av, "s:")) != EOF)
        switch (c) {
        case 's':
            svc_name = optarg;
            break;
        }

    status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
                            PAPI_ENCRYPT_NEVER, NULL);

    if (status != PAPI_OK) {
        printf("papiServiceCreate(%s): %s\n", svc_name ? svc_name :
                     "NULL", papiStatusString(status));
        papiServiceDestroy(svc);
        exit(1);
    }

    status = papiPrintersList(svc, attrs, NULL, &printers);
    if (status != PAPI_OK) {
        printf("papiPrintersList(%s): %s\n", svc_name ? svc_name :
                     "NULL", papiStatusString(status));
        papiServiceDestroy(svc);
        exit(1);
    }

    if (printers != NULL) {
        int i;

        for (i = 0; printers[i] != NULL; i++) {
            papi_attribute_t **list = 
                papiPrinterGetAttributeList(printers[i]);

            if (list != NULL) {
                char *name = "unknown";
                char *uri = "unknown";

                (void) papiAttributeListGetString(list, NULL,
                                    "printer-name", &name);

                (void) papiAttributeListGetString(list, NULL,
                                    "printer-uri-supported", &uri);
                printf("%s is %s\
", name, uri);
            }
        }
        papiPrinterListFree(printers);
    }

    papiServiceDestroy(svc);

    exit(0);
}

Example 2 Dump all printer attributes.

/*
 * program to query a printer for it's attributes via PAPI
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libintl.h>
#include <pwd.h>
#include <papi.h>

static int
authCB(papi_service_t svc, void *app_data)
{
    char prompt[BUFSIZ];
    char *user, *svc_name, *passphrase;

    /* get the name of the service we are contacting */
    if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
            return (-1);

    /* find out who we are supposed to be */
    if ((user = papiServiceGetUserName(svc)) == NULL) {
            struct passwd *pw;

            if ((pw = getpwuid(getuid())) != NULL)
                    user = pw->pw_name;
            else
                    user = "nobody";
    }

    /* build the prompt string */
    snprintf(prompt, sizeof (prompt),
            gettext("passphrase for %s to access %s: "), user,
                    svc_name);

    /* ask for the passphrase */
    if ((passphrase = getpassphrase(prompt)) != NULL)
            papiServiceSetPassword(svc, passphrase);

    return (0);
}

/*ARGSUSED*/
int
main(int ac, char *av[])
{
    papi_status_t status;
    papi_service_t svc = NULL;
    papi_printer_t printer = NULL;
    char *svc_name = NULL;
    char *pname = "unknown";
    int c;

    while ((c = getopt(ac, av, "s:p:")) != EOF)
        switch (c) {
        case 's':
            svc_name = optarg;
            break;
        case 'p':
            pname = optarg;
            break;
        }

    status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
                            PAPI_ENCRYPT_NEVER, NULL);

    if (status != PAPI_OK) {
        printf("papiServiceCreate(%s): %s\n", svc_name ? svc_name : 
                    "NULL", papiStatusString(status));
        papiServiceDestroy(svc);
        exit(1);
    }

    status = papiPrinterQuery(svc, pname, NULL, NULL, &printer);
    if ((status == PAPI_OK) && (printer != NULL)) {
        papi_attribute_t **list = papiPrinterGetAttributeList(printer);
        char *buffer = NULL;
        size_t size = 0;

        while (papiAttributeListToString(list, "\n\t", buffer, size)
                    != PAPI_OK)
            buffer = realloc(buffer, size += BUFSIZ);

        printf("%s:\n\t%s\n", pname, buffer);
    } else
        printf("papiPrinterQuery(%s): %s\n", pname,
                    papiStatusString(status));

    papiPrinterFree(printer);
    papiServiceDestroy(svc);

    exit(0);
}

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Volatile
MT-Level
Safe

See Also

libpapi(3LIB), attributes(5)