JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 3: Extended Library Functions     Oracle Solaris 10 1/13 Information Library
search filter icon
search icon

Document Information

Preface

Extended Library Functions - Part 1

Extended Library Functions - Part 2

Extended Library Functions - Part 3

Extended Library Functions - Part 4

MP_EnablePath(3MPAPI)

MP_FreeOidList(3MPAPI)

mp_gcd(3MP)

MP_GetAssociatedPathOidList(3MPAPI)

MP_GetAssociatedPluginOid(3MPAPI)

MP_GetAssociatedTPGOidList(3MPAPI)

MP_GetDeviceProductOidList(3MPAPI)

MP_GetDeviceProductProperties(3MPAPI)

MP_GetInitiatorPortOidList(3MPAPI)

MP_GetInitiatorPortProperties(3MPAPI)

MP_GetLibraryProperties(3MPAPI)

MP_GetMPLogicalUnitProperties(3MPAPI)

MP_GetMPLuOidListFromTPG(3MPAPI)

MP_GetMultipathLus(3MPAPI)

MP_GetObjectType(3MPAPI)

MP_GetPathLogicalUnitProperties(3MPAPI)

MP_GetPluginOidList(3MPAPI)

MP_GetPluginProperties(3MPAPI)

MP_GetProprietaryLoadBalanceOidList(3MPAPI)

MP_GetProprietaryLoadBalanceProperties(3MPAPI)

MP_GetTargetPortGroupProperties(3MPAPI)

MP_GetTargetPortOidList(3MPAPI)

MP_GetTargetPortProperties(3MPAPI)

mp_itom(3MP)

mp_madd(3MP)

mp_mcmp(3MP)

mp_mdiv(3MP)

mp_mfree(3MP)

mp_min(3MP)

mp_mout(3MP)

mp_msqrt(3MP)

mp_msub(3MP)

mp_mtox(3MP)

mp_mult(3MP)

mp_pow(3MP)

MP_RegisterForObjectPropertyChanges(3MPAPI)

MP_RegisterForObjectVisibilityChanges(3MPAPI)

MP_RegisterPlugin(3MPAPI)

mp_rpow(3MP)

mp_sdiv(3MP)

MP_SetFailbackPollingRate(3MPAPI)

MP_SetLogicalUnitLoadBalanceType(3MPAPI)

MP_SetOverridePath(3MPAPI)

MP_SetPathWeight(3MPAPI)

MP_SetPluginLoadBalanceType(3MPAPI)

MP_SetProbingPollingRate(3MPAPI)

MP_SetProprietaryProperties(3MPAPI)

MP_SetTPGAccess(3MPAPI)

mp_xtom(3MP)

m_setvalues_layout(3LAYOUT)

m_transform_layout(3LAYOUT)

m_wtransform_layout(3LAYOUT)

nan(3M)

nanf(3M)

nanl(3M)

nearbyint(3M)

nearbyintf(3M)

nearbyintl(3M)

new_CplFileConf(3TECLA)

newDmiOctetString(3DMI)

newDmiString(3DMI)

new_ExpandFile(3TECLA)

new_GetLine(3TECLA)

new_PathCache(3TECLA)

new_PcaPathConf(3TECLA)

new_WordCompletion(3TECLA)

nextafter(3M)

nextafterf(3M)

nextafterl(3M)

nexttoward(3M)

nexttowardf(3M)

nexttowardl(3M)

nlist(3ELF)

NOTE(3EXT)

_NOTE(3EXT)

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_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_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_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_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_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)

p2close(3GEN)

p2open(3GEN)

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)

pathfind(3GEN)

pca_last_error(3TECLA)

pca_lookup_file(3TECLA)

pca_path_completions(3TECLA)

pca_scan_path(3TECLA)

pca_set_check_fn(3TECLA)

pctx_capture(3CPC)

pctx_create(3CPC)

pctx_release(3CPC)

pctx_run(3CPC)

pctx_set_events(3CPC)

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)

Extended Library Functions - Part 5

Extended Library Functions - Part 6

papiJobSubmit

, papiJobSubmitByReference

, papiJobValidate

, papiJobStreamOpen

, papiJobStreamWrite

, papiJobStreamClose

, papiJobQuery

, papiJobModify

, papiJobMove

, papiJobCancel

, papiJobHold

, papiJobRelease

, papiJobRestart

, papiJobPromote

, papiJobGetAttributeList

, papiJobGetPrinterName

, papiJobGetId

, papiJobGetJobTicket

, papiJobFree

, papiJobListFree

- job object manipulation

Synopsis

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

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);
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);
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);
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);
papi_status_t papiJobStreamWrite(papi_service_t handle,
     papi_stream_t stream, void *buffer, size_t buflen);
papi_status_t papiJobStreamClose(papi_service_t handle,
     papi_stream_t stream, papi_job_t *job);
papi_status_t papiJobQuery(papi_service_t handle,
     char *printer, int32_t job_id, char **requested_attrs,
     papi_job_t *job);
papi_status_t papiJobModify(papi_service_t handle,
     char *printer, int32_t job_id,
     papi_attribute_t **attributes, papi_job_t *job);
papi_status_t papiJobMove(papi_service_t handle,
     char *printer, int32_t job_id, char *destination);
papi_status_t papiJobCancel(papi_service_t handle,
     char *printer, int32_t job_id);
papi_status_t papiJobHold(papi_service_t handle,
     char *printer, int32_t job_id);
papi_status_t papiJobRelease(papi_service_t handle,
     char *printer, int32_t job_id);
papi_status_t papiJobRestart(papi_service_t handle,
     char *printer, int32_t job_id);
papi_status_t papiJobPromote(papi_service_t handle,
     char *printer, int32_t job_id);
papi_attribute_t **papiJobGetAttributeList(papi_job_t job);
char *papiJobGetPrinterName(papi_job_t job);
int32_t papiJobGetId(papi_job_t job);
papi_job_ticket_t *papiJobGetJobTicket(papi_job_t job);
void papiJobFree(papi_job_t job);
void papiJobListFree(papi_job_t *jobs);

Parameters

attributes

a set of attributes to be applied to a printer object

buffer

a buffer of data to be written to the job stream

bufflen

the size of the supplied buffer

destination

the name of the printer where a print job should be relocated, which must reside within the same print services as the job is currently queued

files

files to use during job submission

handle

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

job

a pointer to a printer object (initialized to NULL) to be filled in by papiJobQuery(), papiJobSubmit(), papiJobSubmitByReference(), papiJobValidate(), papiJobStreamClose(), and papiJobModify()

job_attributes

attributes to apply during job creation or modification

job_id

ID number of the job reported on or manipulated

job_ticket

unused

jobs

a list of job objects returned by papiPrinterListJobs() or papiPrinterPurgeJobs()

printer

name of the printer where the job is or should reside

requested_attrs

a null-terminated array of pointers to attribute names requested during job enumeration (papiPrinterListJobs()) or job query (papiJobQuery())

stream

a communication endpoint for sending print job data

Description

The papiJobSubmit() function creates a print job containing the passed in files with the supplied attributes. When the function returns, the data in the passed files will have been copied by the print service. A job object is returned that reflects the state of the job.

The papiJobSubmitByReference() function creates a print job containing the passed in files with the supplied attributes. When the function returns, the data in the passed files might have been copied by the print service. A job object is returned that reflects the state of the job.

The papiJobStreamOpen(), papiJobStreamWrite(), papiJobStreamClose() functions create a print job by opening a stream, writing to the stream, and closing it.

The papiJobValidate() function validates that the supplied attributes and files will result in a valid print job.

The papiJobQuery() function retrieves job information from the print service.

The papiJobModify() function modifies a queued job according to the attribute list passed into the call. A job object is returned that reflects the state of the job after the modification has been applied.

The papiJobMove() function moves a job from its current queue to the named destination within the same print service.

The papiJobCancel() function removes a job from the queue.

The papiJobHold() and papiJobRelease() functions set the job state to “held” or “idle” to indicate whether the job is eligible for processing.

The papiJobRestart() function restarts processing of a currently queued print job.

The papiJobGetAttributeList() function returns a list of attributes describing the job. This list can be searched and/or enumerated using papiAttributeList*() calls. See papiAttributeListAddValue(3PAPI).

The papiJobGetPrinterName() function returns the name of the queue where the job is currently queued.

The papiJobGetId() function returns a job identifier number from the job object passed in.

The papiJobPromote() function moves a job to the head of the print queue.

The papiJobGetJobTicket() function retrieves a pointer to a job ticket associated with the job object.

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

Return Values

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

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

Examples

Example 1 Enumerate all jobs in a queue

/*
 * program to enumerate queued jobs using PAPI interfaces.
 */
#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_job_t *jobs = 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\
", svc_name ? svc_name :
                     "NULL", papiStatusString(status));
        papiServiceDestroy(svc);
        exit(1);
    }

    status = papiPrinterListJobs(svc, pname, NULL, 0, 0, &jobs);
    if (status != PAPI_OK) {
        printf("papiPrinterListJobs(%s): %s\
", pname,
                    papiStatusString(status));
        papiServiceDestroy(svc);
        exit(1);
    }

    if (jobs != NULL) {
        int i;

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

            if (list != NULL) {
                char *name = "unknown";
                            int32_t id = 0;
                char *buffer = NULL;
                size_t size = 0;

               (void) papiAttributeListGetString(list, NULL,
                                    "printer-name", &name);
               (void) papiAttributeListGetInteger(list, NULL,
                                    "job-id", &id);
                while (papiAttributeListToString(list, "\
\t", buffer, 
                            size) != PAPI_OK)
                    buffer = realloc(buffer, size += BUFSIZ);

                printf("%s-%d:\
\t%s\
", name, id, buffer);
                free(buffer);
            }
        }
        papiJobListFree(jobs);
    }

    papiServiceDestroy(svc);

    exit(0);
}

Example 2 Dump all job attributes.

/*
 * program to dump a queued job's attributes using PAPI interfaces.
 */
#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_job_t job = NULL;
    char *svc_name = NULL;
    char *pname = "unknown";
    int id = 0;
    int c;

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

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

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

    status = papiJobQuery(svc, pname, id, NULL, &job);
    if ((status == PAPI_OK) && (job != NULL)) {
        papi_attribute_t **list = papiJobGetAttributeList(job);

        if (list != NULL) {
            char *name = "unknown";
            int32_t id = 0;
            char *buffer = NULL;
            size_t size = 0;

            (void) papiAttributeListGetString(list, NULL,
                                    "printer-name", &name);
            (void) papiAttributeListGetInteger(list, NULL,
                                    "job-id", &id);
            while (papiAttributeListToString(list, "\
\t", buffer, size)
                            != PAPI_OK)
                buffer = realloc(buffer, size += BUFSIZ);

            printf("%s-%d:\
\t%s\
", name, id, buffer);
            free(buffer);
        }
    } else
        printf("papiJobQuery(%s-%d): %s\
", pname, id,
                    papiStatusString(status));

    papiJobFree(job);
    papiServiceDestroy(svc);

    exit(0);
}

Example 3 Submit a job (stream).

/*
 * program to submit a job from standard input.
 */
#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_stream_t stream = NULL;
    papi_job_t job = NULL;
    papi_attribute_t **attrs = NULL;
    char *svc_name = NULL;
    char *pname = "unknown";
    int id = 0;
    int c;
    int rc;
    char buf[BUFSIZ];

    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\
", svc_name ? svc_name : 
                    "NULL", papiStatusString(status));
        papiServiceDestroy(svc);
        exit(1);
    }

    papiAttributeListAddInteger(&attrs, PAPI_ATTR_EXCL, "copies", 1);
    papiAttributeListAddString(&attrs, PAPI_ATTR_EXCL,
                "document-format", "application/octet-stream");
    papiAttributeListAddString(&attrs, PAPI_ATTR_EXCL,
                "job-title", "Standard Input");

    status = papiJobStreamOpen(svc, pname, attrs, NULL, &stream);
    while ((status == PAPI_OK) && ((rc = read(0, buf, 
                     sizeof (buf))) > 0))
            status = papiJobStreamWrite(svc, stream, buf, rc);

    if (status == PAPI_OK)
            status = papiJobStreamClose(svc, stream, &job);


    if ((status == PAPI_OK) && (job != NULL)) {
        papi_attribute_t **list = papiJobGetAttributeList(job);

        if (list != NULL) {
            char *name = "unknown";
            int32_t id = 0;
            char *buffer = NULL;
            size_t size = 0;

            (void) papiAttributeListGetString(list, NULL,
                                    "printer-name", &name);
            (void) papiAttributeListGetInteger(list, NULL,
                                    "job-id", &id);
            while (papiAttributeListToString(list, "\
\t", buffer, size)
                            != PAPI_OK)
                buffer = realloc(buffer, size += BUFSIZ);

            printf("%s-%d:\
\t%s\
", name, id, buffer);
            free(buffer);
        }
    } else
        printf("papiJobStream*(%s-%d): %s\
", pname, id,
                    papiStatusString(status));

    papiJobFree(job);
    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), papiAttributeListAddValue(3PAPI), attributes(5)