lpmove.c revision 355b4669e025ff377602b6fc7caaf30dbc218371
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 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 */
#pragma ident "%Z%%M% %I% %E% SMI"
/* lpmove dest1 dest2 - move all requests from dest1 to dest2
* lpmove request ... dest - move requests to destination dest
*
* This command may be used only by an LP Administrator
*/
#include <assert.h>
#include <signal.h>
#include <locale.h>
#include "lp.h"
#include "msgs.h"
#include "printers.h"
#define WHO_AM_I I_AM_LPMOVE
#include "oam.h"
char message[100],
reply[100];
#define TRUE 1
#define FALSE 0
static int accept(char *);
static int reject(char *, char *);
#if defined(__STDC__)
void catch();
#else
int catch();
#endif
void
usage()
{
"usage:\n"
"\n"
" (move all requests, reject any new requests)\n"
" lpmove from-destination to-destination\n"
"\n"
" (move individual requests)\n"
" lpmove requests ... to-destination\n"));
return;
}
char *strncpy();
int
{
short status;
long chkbits;
short nmove = 0;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
usage();
exit(0);
}
if(argc < 3) {
usage();
exit(1);
}
startup();
if(argc != 3) {
usage();
exit(1);
}
goto Errexit;
}
while (1) {
goto Errexit;
}
if (type != R_MOVE_DEST
goto Errexit;
}
switch (status) {
case MOK:
break;
case MNODEST:
err_exit();
case MERRDEST:
rc = 1;
break;
case MMORERR:
rc = 1;
continue;
case MNOPERM:
err_exit();
default:
rc = 1;
}
break;
}
} else {
err_exit();
}
err_exit();
}
if (type != R_MOVE_REQUEST
err_exit();
}
switch (status) {
case MOK:
nmove++;
break;
case MDENYDEST:
if (chkbits) {
chkp[-2] = 0;
}
rc = 1;
break;
case MNOMEDIA:
rc = 1;
break;
case MDENYMEDIA:
rc = 1;
break;
case MNOMOUNT:
rc = 1;
break;
case MNOFILTER:
rc = 1;
break;
case MERRDEST:
rc = 1;
break;
case MNODEST:
err_exit();
case MUNKNOWN:
rc = 1;
break;
case MBUSY:
rc = 1;
break;
case M2LATE:
rc = 1;
break;
case MNOPERM:
err_exit();
case MGONEREMOTE:
break;
default:
rc = 1;
}
}
}
cleanup();
return (rc);
}
static int
{
short status;
return(1);
}
return(1);
}
if (type != R_ACCEPT_DEST
return(1);
}
switch (status) {
case MNODEST:
return(1);
case MNOPERM:
return(1);
default:
return(1);
case MOK:
case MERRDEST:
;
}
return (0);
}
static int
{
short status;
char reason[128];
/* reject(dest, reason) */
return(1);
}
return(1);
}
if (type != R_REJECT_DEST
return(1);
}
switch (status) {
case MNODEST:
return(1);
case MNOPERM:
return(1);
default:
return(1);
case MERRDEST:
return(-1); /* was rejecting */
case MOK:
break;
}
return (0);
}
void
startup()
{
}
/* catch -- catch signals */
#if defined(__STDC__)
void
#endif
catch()
{
err_exit();
}
void
cleanup()
{
(void)mclose ();
}
void
err_exit()
{
cleanup();
exit(1);
}