lpmove.c revision b11ac39f7d50211a3de081489d8d964e4cfeb0f9
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <locale.h>
#ifndef SUNOS_4
#include <libintl.h>
#endif
/*
* This program will submit print jobs to a spooler using the BSD
* printing protcol as defined in RFC1179, plus some extension for
* support of additional lp functionality.
*/
extern char *optarg;
extern char *getenv(const char *);
/*
* If a job is moved, we should return 1 regardless of whether we
* killed the daemon or not. This will allow us to attempt to start
*/
static int
{
lock;
return (0);
return (0);
return (0);
/* just do it */
return (1);
}
static int
{
int rc = 0;
return (rc);
}
/*
* move print jobs from one queue to another. This gets the lock
* file (killing the locking process if necessary), Moves the jobs, and
* restarts the transfer daemon.
*/
int
{
*user = get_user_name();
int remote_moved = 0,
i, argc = 0;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
else
program++;
exit(1);
}
}
/*
* Get the destination; use binding to set it; the input may
* be an alias, not a printer name
*/
return (-1);
}
/*
* Decrement orig arg count so the following for() loop iterates for
* each source request or destination. Also, when we later check if
* there are local jobs to move, we will be comparing number of remote
* requests moved with the total number supplied.
*/
ac--;
for (i = 1; i <= ac; i++) {
int id = -1;
/*
* if the argument contains a '-', see if it is a request
* or a printer.
*/
*(s++) = NULL;
errno = 0;
id = -1;
*(--s) = '-';
}
}
/*
* get the binding for the printer, so we can use the printer
* name from the binding to move the job(s)
*/
return (-1);
}
/*
* There was nothing "remote" to move, so add it to the
* list of "local" items to move. Use the printer name
* from the binding, because that is the one that
* lpsched is most likely to understand.
*/
} else
remote_moved++;
}
/* if we moved a "remote" job(s), try to (re)start the transfer agent */
if (remote_moved != 0)
start_daemon(1);
/* if there is something "local" to move, try it */
/* limit ourselves to real user's perms before exec'ing */
}
return (0);
}