/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*/
/* system header files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <errno.h>
#include <signal.h>
#include <locale.h>
/* typedefs */
typedef int BOOL;
/* constants */
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#endif
/* external variables */
/* prototypes for static functions */
static void Usage(void);
static void EmitPSFile(const char *name);
static void EmitJobData(void);
static void EmitPrologue(void);
static void EmitCommandLineInfo(void);
static void EmitClockBasedInfo(void);
static void EmitLabelInfo(void);
static void CopyStdin(void);
/* static variables */
static char *ArgSeparatorPS;
static char *ArgBannerPS;
static char *ArgTrailerPS;
static char *ArgPSLib;
static char *ArgPrinter;
static char *ArgJobID;
static char *ArgUser;
static char *ArgTitle;
static char *ArgFile;
static int ArgDebugLevel;
static char *remoteLabel;
int
{
int err;
/*
* Run immune from typical interruptions, so that
* we stand a chance to get the fault message.
* EOF (or startup error) is the only way out.
*/
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
exit(1);
exit(1);
/*
* If the job was submitted via remotely, the label of the
* remote peer will be set in the SLABEL environment variable
* by copying it out of the SECURE structure.
*
* If there is no SLABEL value, the job was submitted locally
* via the named pipe, and the file label can be determined
* from its pathname.
*/
perror("str_to_label");
exit(1);
}
(void) fprintf(ArgLogFile,
gettext("%1$s: cannot get label of %2$s: %3$s\n"),
exit(1);
}
/* All of these functions exit if they encounter an error */
EmitJobData();
if (ArgReverse)
else
CopyStdin();
if (ArgReverse)
else
if (ArgDebugLevel >= 1)
return (0);
}
static void
EmitJobData(void)
{
EmitPrologue();
/* Emit ending PostScript code */
(void) printf("end\n\n");
}
static void
EmitPrologue(void)
{
/* Emit preliminary PostScript code */
(void) printf("%%!\n\n");
(void) printf("%%%% Create JobDict if it doesn't exist\n");
(void) printf("userdict /JobDict known not {\n");
(void) printf(" userdict /JobDict 100 dict put\n");
(void) printf("} if\n\n");
(void) printf("%%%% Define job parameters, including TSOL security "
"info\n");
(void) printf("JobDict\n");
(void) printf("begin\n");
}
/* Emit parameters obtained from command line options */
static void
EmitCommandLineInfo(void)
{
(void) printf("\t/Job_DoPageLabels (%s) def\n",
(void) printf("\n");
}
/* Emit parameters generated from the system clock */
static void
EmitClockBasedInfo(void)
{
(void) printf("\n");
}
/* Emit parameters derived from the SL and IL of the file being printed. */
static void
EmitLabelInfo(void)
{
DEF_NAMES) != 0) {
(void) fprintf(ArgLogFile,
gettext("%s: label_to_str PRINTER_TOP_BOTTOM: %s.\n"),
exit(1);
}
DEF_NAMES) != 0) {
(void) fprintf(ArgLogFile,
gettext("%s: label_to_str PRINTER_LABEL: %s.\n"),
exit(1);
}
DEF_NAMES) != 0) {
(void) fprintf(ArgLogFile,
gettext("%s: label_to_str PRINTER_CAVEATS: %s.\n"),
exit(1);
}
DEF_NAMES) != 0) {
(void) fprintf(ArgLogFile,
gettext("%s: label_to_str PRINTER_CHANNELS: %s.\n"),
exit(1);
}
LONG_NAMES) != 0) {
(void) fprintf(ArgLogFile,
gettext("%s: label_to_str M_LABEL: %s.\n"),
exit(1);
}
/* Free memory allocated label_to_str */
}
/*
* Parse input "host!user" to separate host and user names.
*/
static void
{
char *cp;
/* user@host */
*cp = '\0';
*cp = '@';
/* host!user */
*cp = '\0';
*cp = '!';
} else {
/* user */
host[0] = '\0';
}
}
static void
CopyStdin(void)
{
(void) fprintf(ArgLogFile,
exit(1);
}
}
static BOOL
{
int len;
return (FALSE);
}
return (FALSE);
return (TRUE);
}
static void
{
if (name[0] != '/') {
} else {
}
(void) fprintf(ArgLogFile,
gettext("%s: Error opening PostScript file %s. %s.\n"),
exit(1);
}
if (!emitted) {
"%s: Error copying PostScript file %s to stdout.\n"),
exit(1);
}
}
static int
{
int option_letter;
/* set default values for arguments */
ArgDebugLevel = 0;
ArgLogFile = stderr;
/* read switch arguments once to get error log file */
switch (option_letter) {
case 'd':
break;
case 'e':
if (ArgLogFile == NULL) {
gettext("Cannot open log file %s\n"),
optarg);
return (-1);
}
break;
case '?': /* ? or unrecognized option */
Usage();
return (-1);
}
}
if (ArgDebugLevel > 0)
(void) fprintf(ArgLogFile,
gettext("Processing switch arguments\n"));
/* re-read switch arguments */
optind = 1;
switch (option_letter) {
case 'd':
break;
case 'e':
/* This was handled in earlier pass through args */
break;
case 'l':
break;
case 'r':
ArgReverse = TRUE;
break;
case 's':
break;
case 'b':
break;
case 't':
break;
case 'L':
break;
case '?': /* ? or unrecognized option */
Usage();
return (-1);
}
}
/* Adjust arguments to skip over options */
if (argc != 5) {
(void) fprintf(ArgLogFile,
gettext("Wrong number of arguments.\n\n"));
Usage();
return (-1);
}
ArgPrinter = argv++[0];
if (ArgDebugLevel >= 1) {
}
return (0);
}
static void
Usage(void)
{
(void) fprintf(ArgLogFile,
gettext("PRINTER JOBID HOST!USER TITLE FILE"));
gettext("Banner"),
gettext("PostScript program for banner (default tsol_banner.ps)"));
gettext("Separator"),
gettext("PostScript program for separator "
"(default tsol_separator.ps)"));
gettext("Trailer"),
gettext("PostScript program for trailer "
"(default tsol_trailer.ps)"));
gettext("Library"),
gettext("Directory to search for PostScript programs"));
gettext("(default /usr/lib/lp/postscript)"));
gettext("Set debug level to N"));
gettext("Error File"),
gettext("Append error and debugging output to FILE"));
}