in.lpd.c revision 43b9c05035ac59f7f7a8e7827598db5a15f30ed3
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: in.lpd.c 170 2006-05-20 05:58:49Z njacobs $ */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <libintl.h>
#include <pwd.h>
#include <grp.h>
#include <netdb.h>
#include <sys/systeminfo.h>
#include <papi.h>
#include <uri.h>
#include "common.h"
/*
* This file contains the front-end of the BSD Print Protocol adaptor. This
* code assumes a BSD Socket interface to the networking side.
*/
static char *
{
struct sockaddr_in6 peer;
int error_num;
char *hostname;
/* who is our peer ? */
return (NULL);
else
return (strdup("localhost"));
}
/* get their name or return a string containing their address */
}
/* is it "localhost" ? */
return (strdup("localhost"));
/* duplicate the name because gethostbyXXXX() is not reentrant */
/* is it from one of my addresses ? */
int i = 0;
== 0) {
return (strdup("localhost"));
}
}
}
/* It must be someone else */
return (hostname);
}
static void
{
exit(1);
}
static void
{
int i;
}
}
}
}
static papi_attribute_t **
{
*entry,
*s,
int count = 0,
copies_set = 0,
copies = 0;
/* count the copies */
copies++;
copies_set = 1;
/* process the control message */
switch (entry[0]) {
/* RFC-1179 options */
case 'J': /* RFC-1179 Banner Job Name */
"job-name", ++entry);
break;
case 'C': /* RFC-1179 Banner Class Name */
"rfc-1179-class", ++entry);
break;
case 'L': /* RFC-1179 Banner toggle */
"job-sheets", "standard");
break;
case 'T': /* RFC-1179 Title (pr) */
"pr-title", ++entry);
break;
case 'H': /* RFC-1179 Host */
/*
* use the host as known by us, not by them
*
* papiAttributeListAddString(&list, PAPI_ATTR_EXCL,
* "job-originating-host-name", ++entry);
*/
break;
case 'P': /* RFC-1179 User */
++entry;
"requesting-user-name", entry);
break;
case 'M': /* RFC-1179 Mail to User */
"rfc-1179-mail", 1);
break;
case 'W': /* RFC-1179 Width (pr) */
break;
case 'I': /* RFC-1179 Indent (pr) */
break;
case 'N': /* RFC-1179 Filename */
/* could have HPUX extension embedded */
#ifdef DEBUG
"flist", ++entry);
#endif
PAPI_ATTR_APPEND, ++entry);
break;
case 'U': /* RFC-1179 Unlink */
break; /* ignored */
case '1': /* RFC-1179 TROFF Font R */
"rfc-1179-font-r", ++entry);
break;
case '2': /* RFC-1179 TROFF Font I */
"rfc-1179-font-i", ++entry);
break;
case '3': /* RFC-1179 TROFF Font B */
"rfc-1179-font-b", ++entry);
break;
case '4': /* RFC-1179 TROFF Font S */
"rfc-1179-font-s", ++entry);
break;
case 'f': /* RFC-1179 ASCII file (print) */
format = "application/postscript";
break;
case 'l': /* RFC-1179 CATV file (print) */
format = "application/postscript";
break;
case 'o': /* RFC-1179 Postscript file (print) */
format = "application/postscript";
break;
case 'p': /* RFC-1179 PR file (print) */
format = "application/x-pr";
"pr-filter", 1);
break;
case 't': /* RFC-1179 TROFF file (print) */
format = "application/x-troff";
break;
case 'n': /* RFC-1179 DITROFF file (print) */
format = "application/x-ditroff";
break;
case 'd': /* RFC-1179 DVI file (print) */
format = "application/x-dvi";
break;
case 'g': /* RFC-1179 GRAPH file (print) */
format = "application/x-plot";
break;
case 'c': /* RFC-1179 CIF file (print) */
format = "application/x-cif";
break;
case 'v': /* RFC-1179 RASTER file (print) */
format = "application/x-raster";
break;
case 'r': /* RFC-1179 FORTRAN file (print) */
format = "application/x-fortran";
break;
/* Sun Solaris Extensions */
case 'O':
++entry;
do {
if (*entry != '"')
} while (*entry++);
text);
break;
case '5':
++entry;
switch (entry[0]) {
case 'f': /* Solaris form */
"form", ++entry);
break;
case 'H': /* Solaris handling */
++entry;
"job-hold-until", "indefinite");
"job-hold-until", "no-hold");
else
"job-hold-until", entry);
break;
case 'p': /* Solaris notification */
break;
case 'P': { /* Solaris page list */
++entry);
}
break;
case 'q': { /* Solaris priority */
i = 100 - (i * 2.5);
if ((i < 1) || (i > 100))
i = 50;
PAPI_ATTR_EXCL, "job-priority", i);
}
break;
case 'S': /* Solaris character set */
PAPI_ATTR_EXCL, "lp-charset",
++entry);
break;
case 'T': /* Solaris type */
break;
case 'y': /* Solaris mode */
break;
default:
"Warning: cf message (%s) ignored",
entry);
break;
}
break;
/* Undefined Extensions: SCO, Ultrix, AIX, ... */
default:
"Warning: cf message (%s) ignored", entry);
break;
}
"document-format", format);
}
"copies", ++copies);
"job-sheets", "none");
return (list);
}
static papi_status_t
{
char *format = "";
/* use the host as known by us, not by them */
"job-originating-host-name", host);
}
}
}
return (status);
}
static char *
{
return (NULL);
} else
while (size > 0) {
int rc;
return (NULL);
} else {
}
}
return (NULL);
}
return (cf_data);
}
static char *
{
char file[] = "lpdXXXXXX";
int fd;
return (NULL);
} else
while (size > 0) {
return (NULL);
} else {
while (rc > 0) {
if (wrc < 0) {
return (NULL);
}
}
}
}
return (NULL);
}
}
static papi_status_t
{
int size;
#ifdef DEBUG /* translate [1-3]... messages to \[1-3] to run by hand */
buf[0] -= '0';
#endif
switch (buf[0]) {
case 0x01: /* Abort */
break;
case 0x02: { /* Receive control file */
return (PAPI_BAD_REQUEST);
files);
}
}
break;
case 0x03: { /* Receive data file */
return (PAPI_TEMPORARY_ERROR);
}
}
break;
default:
break;
}
}
return (status);
}
static papi_status_t
char *printer)
{
papi_printer_t p = NULL;
char accepting = PAPI_FALSE;
"printer-is-accepting-jobs", &accepting);
} else
papiPrinterFree(p);
} else
return (status);
}
static int
cyclical_service_check(char *svc_name)
{
char *s = NULL;
/* was there a printer? */
return (0);
return (0); /* if it doesnt' resolve, we will fail later */
return (0); /* they don't match */
/* is it in uri form? */
if (uri_from_string(s, &uri) < 0)
return (0);
return (0);
}
/* is it in lpd form? */
return (0);
}
/* is it the local host? */
return (0);
}
return (1);
}
/*
* This is the entry point for this program. The program takes the
* following options:
* (none)
*/
int
{
int c;
**args,
*printer,
switch (c) {
case 'E':
break;
case 'd': /* run where they tell you */
break;
case 'u': /* run as */
break;
default:
;
}
}
}
exit(1);
}
exit(1);
}
#ifdef DEBUG /* translate [1-5]... messages to \[1-5] to run by hand */
buf[0] -= '0';
#endif
exit(1);
}
exit(1);
}
if (cyclical_service_check(printer) != 0) {
exit(1);
}
encryption, NULL);
exit(1);
}
/*
* Trusted Solaris can't be trusting of intermediaries. Pass
* the socket connection to the print service to retrieve the
* sensativity label off of a multi-level port.
*/
switch (buf[0]) {
case '\1': /* restart printer */
break;
case '\2': /* transfer job(s) */
break;
case '\3': /* show queue (short) */
case '\4': { /* show queue (long) */
int count;
}
break;
case '\5': { /* cancel job(s) */
int count;
} else
}
break;
default:
}
return (0);
}