lpd-job.c revision 286caa64ad16838107c004ca772b1d153e7c7510
/*
* 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
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: lpd-job.c 157 2006-04-26 15:07:55Z ktou $ */
#define __EXTENSIONS__ /* for strtok_r() */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
#include <string.h>
#include <pwd.h>
#include <libintl.h>
#include <papi_impl.h>
static char
mime_type_to_rfc1179_type(char *mime)
{
{ "application/octet-stream", 'l' },
{ "application/x-pr", 'p' },
{ "application/x-cif", 'c' },
{ "application/x-dvi", 'd' },
{ "application/x-fortran", 'r' },
{ "application/x-plot", 'g' },
{ "application/x-ditroff", 'n' },
{ "application/x-troff", 't' },
{ "application/x-raster", 'v' },
{ NULL, 0}
};
char result = '\0';
int i;
break;
}
}
return (result);
}
static papi_status_t
{
return (PAPI_BAD_REQUEST);
} else {
void *tmp;
if (tmp) {
} else
return (PAPI_TEMPORARY_ERROR);
}
return (PAPI_OK);
}
static papi_status_t
{
return (PAPI_BAD_REQUEST);
}
static papi_status_t
{
return (PAPI_BAD_REQUEST);
}
static papi_status_t
{
char buf[16];
else
}
static papi_status_t
{
char *s;
int integer;
char bool;
char *user = "nobody";
char *h1;
return (PAPI_BAD_REQUEST);
/* There is nothing to do */
if (attributes == NULL)
return (PAPI_OK);
"job-host", h1);
}
"job-originating-host-name", host);
if (uid == 0)
&user);
"job-originating-user-name", user);
/* Class for Banner Page */
s = NULL;
if (s != NULL) {
"rfc-1179-class", s);
}
/* Print Banner Page */
s = NULL;
"job-sheets", s);
}
/* Jobname */
s = NULL;
if (s != NULL) {
"job-name", s);
}
/* User to mail when job is done - lpr -m */
bool = PAPI_FALSE;
if (bool == PAPI_TRUE) {
"rfc-1179-mail", bool);
}
/* Title for pr */
s = NULL;
if (s != NULL) {
"pr-title", s);
}
/* Indent - used with pr filter */
integer = 0;
if (integer >= 1) {
"pr-indent", integer);
}
/* Width - used with pr filter */
integer = 0;
if (integer >= 1) {
"pr-width", integer);
}
/* file with Times Roman font lpr -1 */
s = NULL;
if (s != NULL) {
"rfc-1179-font-r", s);
}
/* file with Times Roman font lpr -2 */
s = NULL;
if (s != NULL) {
"rfc-1179-font-i", s);
}
/* file with Times Roman font lpr -3 */
s = NULL;
if (s != NULL) {
"rfc-1179-font-b", s);
}
/* file with Times Roman font lpr -4 */
s = NULL;
if (s != NULL) {
"rfc-1179-font-s", s);
}
/*
* The document format needs to be added, but the control line
* should be added when the filenames are figured out.
*/
s = NULL;
if (s != NULL) {
"document-format", s);
}
return (status);
}
static char *
{
int i;
return (NULL);
/* add these to the list of things to ignore */
do {
size += 1024;
}
}
return (result);
}
/*
* lpd_add_svr4_attributes
* Solaris 2.x LP - BSD protocol extensions
*/
static papi_status_t
{
char *s;
int integer;
return (PAPI_BAD_REQUEST);
/* media */
s = NULL;
if (s != NULL) {
"media", s);
}
/* Handling */
s = NULL;
"job-hold-until", "indefinite");
"job-hold-until", "no-hold");
} else if (s != NULL) {
"job-hold-until", s);
}
/* Pages */
s = NULL;
"page-ranges", s);
}
}
/* Priority : lp -q */
integer = -1;
if (integer != -1) {
"job-priority", integer);
}
/* Charset : lp -S */
s = NULL;
if (s != NULL) {
"lp-charset", s);
}
/* Type : done when adding file */
/* Mode : lp -y */
s = NULL;
if (s != NULL) {
"lp-modes", s);
}
/* Options lp -o are handled elsewhere */
free(s);
}
return (PAPI_OK);
}
{
char *s = NULL;
/* Options lp -o */
free(s);
}
return (PAPI_OK);
}
{
return (PAPI_BAD_REQUEST);
/* add protocol extensions if applicable */
used);
used);
/*
* others could be added here:
* lprng, sco, aix, digital unix, xerox, ...
*/
}
return (PAPI_OK);
}
{
char rfc_fmt = 'l';
int copies = 1;
int i;
return (PAPI_BAD_ARGUMENT);
&format);
"document-format", format);
rfc_fmt = 'l';
}
if (copies < 1)
copies = 1;
char key;
int j;
return (PAPI_NOT_AUTHORIZED);
}
gettext("Cannot access file: %s: %s"),
return (PAPI_DOCUMENT_ACCESS_ERROR);
}
gettext("Zero byte (empty) file: %s"),
files[i]);
return (PAPI_BAD_ARGUMENT);
}
}
if (i < 26)
key = 'A' + i;
else if (i < 52)
else if (i < 62)
else {
gettext("too many files, truncated at 62"));
return (PAPI_OK_SUBST);
}
for (j = 0; j < copies; j++)
}
return (PAPI_OK);
}
int *ofd)
{
int fd;
char path[32];
char *list[2];
return (PAPI_BAD_ARGUMENT);
switch (errno) {
case ENOSPC:
break;
case EIO:
break;
case ECONNREFUSED:
break;
case ENOENT:
break;
case EBADMSG:
case EBADF:
break;
default:
break;
}
} else
else
/* read the ID and add it to to the job */
int job_id = 0;
"job-id", job_id);
}
return (status);
}