summaryrefslogtreecommitdiff
path: root/usr/src/cmd/lp/lib/papi/lpsched-misc.c
diff options
context:
space:
mode:
authorJohn Sonnenschein <johns@joyent.com>2012-05-07 05:39:48 +0000
committerJohn Sonnenschein <johns@joyent.com>2012-05-07 05:39:48 +0000
commitf9b92b874c7e2b0a97203e8b3e370a82027fee42 (patch)
tree5b0afcf9f17c210b1248494d7039b477f403793f /usr/src/cmd/lp/lib/papi/lpsched-misc.c
parent99ab767f0b40b10adde1dc9ceaf6bb39d2be5d69 (diff)
parent435bba8aa5d73ccd0b9ec7c79e28bec795904992 (diff)
downloadillumos-joyent-f9b92b874c7e2b0a97203e8b3e370a82027fee42.tar.gz
illumos sync
Diffstat (limited to 'usr/src/cmd/lp/lib/papi/lpsched-misc.c')
-rw-r--r--usr/src/cmd/lp/lib/papi/lpsched-misc.c189
1 files changed, 0 insertions, 189 deletions
diff --git a/usr/src/cmd/lp/lib/papi/lpsched-misc.c b/usr/src/cmd/lp/lib/papi/lpsched-misc.c
deleted file mode 100644
index ce45d1aa5c..0000000000
--- a/usr/src/cmd/lp/lib/papi/lpsched-misc.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <papi_impl.h>
-
-
-papi_status_t
-papiAttributeListAddLPString(papi_attribute_t ***list, int flags, char *name,
- char *value)
-{
- papi_status_t result = PAPI_BAD_ARGUMENT;
-
- if ((list != NULL) && (name != NULL) && (value != NULL) &&
- (value[0] != NULL))
- result = papiAttributeListAddString(list, flags, name, value);
- return (result);
-}
-
-papi_status_t
-papiAttributeListAddLPStrings(papi_attribute_t ***list, int flags, char *name,
- char **values)
-{
- papi_status_t result = PAPI_OK;
- int i, flgs = flags;
-
- if ((list == NULL) || (name == NULL) || (values == NULL))
- result = PAPI_BAD_ARGUMENT;
-
- for (i = 0; ((result == PAPI_OK) && (values[i] != NULL));
- i++, flgs = PAPI_ATTR_APPEND)
- result = papiAttributeListAddString(list, flgs, name,
- values[i]);
-
- return (result);
-}
-
-void
-papiAttributeListGetLPString(papi_attribute_t **attributes, char *key,
- char **string)
-{
- char *value = NULL;
-
- papiAttributeListGetString(attributes, NULL, key, &value);
- if (value != NULL) {
- if (*string != NULL)
- free(*string);
- *string = strdup(value);
- }
-}
-
-void
-papiAttributeListGetLPStrings(papi_attribute_t **attributes, char *key,
- char ***strings)
-{
- papi_status_t status;
- char **values = NULL;
- char *value = NULL;
- void *iter = NULL;
-
- for (status = papiAttributeListGetString(attributes, &iter,
- key, &value);
- status == PAPI_OK;
- status = papiAttributeListGetString(attributes, &iter,
- NULL, &value))
- addlist(&values, value);
-
- if (values != NULL) {
- if (*strings != NULL)
- freelist(*strings);
- *strings = values;
- }
-}
-
-char *
-printer_name_from_uri_id(char *uri, int32_t id)
-{
- REQUEST *request = NULL;
- char *result = "";
-
- if (uri != NULL) {
- if ((result = strrchr(uri, '/')) != NULL) {
- result += 1;
- } else
- result = (char *)uri;
-
- if ((strcmp(result, "jobs") == 0) ||
- (strcmp(result, "any") == 0) ||
- (strcmp(result, "all") == 0))
- result = "";
- }
-
- if ((result[0] == NULL) && (id != -1)) {
- char path[32];
-
- snprintf(path, sizeof (path), "%d-0", id);
- if ((request = getrequest(path)) != NULL)
- result = request->destination;
- }
-
- result = strdup(result);
-
- if (request != NULL)
- freerequest(request);
-
- return (result);
-}
-
-/*
- * LP content type <-> MIME type conversion table. (order dependent)
- */
-static struct {
- char *mime_type;
- char *lp_type;
-} type_map[] = {
- { "text/plain", "simple" },
- { "application/octet-stream", "raw" },
- { "application/octet-stream", "any" },
- { "application/postscript", "postscript" },
- { "application/postscript", "ps" },
- { "application/x-cif", "cif" },
- { "application/x-dvi", "dvi" },
- { "application/x-plot", "plot" },
- { "application/x-ditroff", "troff" },
- { "application/x-troff", "otroff" },
- { "application/x-pr", "pr" },
- { "application/x-fortran", "fortran" },
- { "application/x-raster", "raster" },
- { NULL, NULL}
-};
-
-char *
-mime_type_to_lp_type(char *mime_type)
-{
- int i;
-
- if (mime_type == NULL)
- return ("simple");
-
- for (i = 0; type_map[i].mime_type != NULL; i++)
- if (strcasecmp(type_map[i].mime_type, mime_type) == 0)
- return (type_map[i].lp_type);
-
- return (mime_type);
-}
-
-char *
-lp_type_to_mime_type(char *lp_type)
-{
- int i;
-
- if (lp_type == NULL)
- return ("text/plain");
-
- for (i = 0; type_map[i].lp_type != NULL; i++)
- if (strcasecmp(type_map[i].lp_type, lp_type) == 0)
- return (type_map[i].mime_type);
-
- return (lp_type);
-}