lpc.c revision f928ce67ef743c33ea27c573c9c7e2d4a4833cbd
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* lpc -- line printer control program
*/
#include <locale.h>
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <setjmp.h>
#include <pwd.h>
#include <assert.h>
#include <sys/systeminfo.h>
#include "lpc.h"
#include "lp.h"
#include "msgs.h"
#include "oam_def.h"
int fromatty;
char cmdline[200];
int margc;
char *margv[20];
int top;
int isadmin; /* set if root or lp */
extern int NCMDS;
extern char *Lhost;
extern char *Printer;
extern char *Name;
#if defined (__STDC__)
void done(int);
static void cmdscanner(int);
static void intr(int);
static void makeargv(void);
static void startup(void);
#else
void done();
static void cmdscanner();
static void intr();
static void makeargv();
static void startup();
#endif
int
{
register struct cmd *c;
struct passwd *p;
char my_name[MAXNAMELEN];
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
exit(1);
}
endpwent();
if (--argc > 0) {
if (c == (struct cmd *)-1) {
exit(1);
}
if (c == 0) {
exit(1);
}
exit(1);
}
startup();
done(0);
}
startup();
if (top)
for (;;) {
top = 1;
}
}
/*ARGSUSED*/
static void
#if defined(__STDC__)
intr(int s)
#else
intr(s)
int s;
#endif
{
if (!fromatty)
done(0);
}
/*
* Command parser.
*/
static void
#if defined(__STDC__)
cmdscanner(int top)
#else
int top;
#endif
{
register struct cmd *c;
if (!top)
putchar('\n');
for (;;) {
if (fromatty) {
printf("lpc> ");
}
done(0);
if (cmdline[0] == 0)
break;
makeargv();
if (!margv[0])
break;
if (c == (struct cmd *)-1) {
continue;
}
if (c == 0) {
continue;
}
continue;
}
}
}
static struct cmd *
#if defined(__STDC__)
#else
register char *name;
#endif
{
register char *p, *q;
longest = 0;
nmatches = 0;
found = 0;
if (!name) return(0);
for (q = name; *q == *p++; q++)
if (*q == 0) /* exact match? */
return(c);
if (!*q) { /* the name was a prefix */
nmatches = 1;
found = c;
nmatches++;
}
}
if (nmatches > 1)
return((struct cmd *)-1);
return(found);
}
/*
*/
static void
#if defined(__STDC__)
makeargv(void)
#else
makeargv()
#endif
{
register char *cp;
margc = 0;
cp++;
if (*cp == '\0')
break;
margc += 1;
cp++;
if (*cp == '\0')
break;
*cp++ = '\0';
}
*argp++ = 0;
}
#define HELPINDENT (sizeof ("directory"))
/*
* Help command.
*/
void
#if defined(__STDC__)
#else
int argc;
char **argv;
#endif
{
register struct cmd *c;
if (argc == 1) {
register int i, j, w;
}
if (columns == 0)
columns = 1;
for (i = 0; i < lines; i++) {
for (j = 0; j < columns; j++) {
printf("\n");
break;
}
while (w < width) {
w = (w + 8) &~ 7;
putchar('\t');
}
}
}
return;
}
while (--argc > 0) {
register char *arg;
if (c == (struct cmd *)-1)
else if (c == (struct cmd *)0)
else
}
}
static void
#if defined(__STDC__)
catch(int s)
#else
catch(s)
int s;
#endif
{
done(2);
}
static void
#if defined(__STDC__)
startup(void)
#else
startup()
#endif
{
register int try = 0;
(void)mopen();
}
void
#if defined(__STDC__)
#else
int rc;
#endif
{
(void)mclose();
}