cancel.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 <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <syslog.h>
#include <ctype.h>
#include <locale.h>
#ifndef SUNOS_4
#include <libintl.h>
#endif
#include <cancel_list.h>
extern char *optarg;
int exit_code = 0;
extern char *getenv(const char *);
static int all = 0; /* global for canceling everything */
static char *
vappend_list(void **list)
{
int current = 0;
char *string;
int stringlen;
int listlen;
}
current++;
}
}
return (string);
}
/*
* vcancel_local() attempts to cancel all locally spooled jobs that are
* are associated with a cancel_req_t structure. This function is
* intended to be called by list_iterate().
*/
static int
{
}
/*
* vcancel_remote() attempts to send a cancel request to a print server
* for any jobs that might be associated with the cancel_req_t structure
* passed in. This function is intended to be called by list_iterate().
*/
static int
{
int nd,
rc;
char *string;
gettext("could not talk to print service at %s\n"),
server);
return (-1);
}
string);
if (rc < 0)
return (0);
}
/*
* vsysv_printer() adds an entry to the cancel list with the items supplied.
*/
static void
{
}
/*
* vsysv_binding() adds an entry to the cancel list with the items supplied.
*/
static void
{
}
/*
* sysv_remove() parses the command line arguments as defined for cancel
* and builds a list of cancel_req_t structures to return
*/
static cancel_req_t **
{
char *printer,
int c;
int user = 0;
if (ac == 1) {
exit(-1);
}
switch (c) {
case 'u':
user++;
break;
default:
"Usage:\t%s [-u user-list] [printer-list]\n", av[0]);
"\t%s [request-list] [printer-list]\n", av[0]);
exit(-1);
}
ac--;
char *p,
*q;
int req = 0;
while (*++q != NULL)
if (isdigit(*q) == 0)
req++;
if (req == 0)
break;
}
} else
break;
ac--;
}
if (user != 0) { /* list o users */
} else { /* list o jobs */
char *p;
*(p++) = NULL;
if (*p == NULL) {
gettext("invalid job id: %s-\n"),
exit(-1);
}
} else { /* just a number */
}
}
ac--;
}
(void) list_iterate((void **)addrs,
}
return (list);
}
/*
* bsd_remove() parses the command line arguments as defined for lprm
* and builds a list of cancel_req_t structures to return
*/
static cancel_req_t **
{
char *printer;
int c;
switch (c) {
case 'P':
break;
default:
"Usage: %s [-P printer] [-] [job # ...] [username ...]\n"),
av[0]);
exit(-1);
}
if (getuid() == 0) {
all = 1;
"-all");
} else {
get_user_name());
}
} else {
}
return (list);
}
/*
* main() calls the appropriate routine to parse the command line arguments
* and then calls the local remove routine, followed by the remote remove
* routine to remove jobs.
*/
int
{
int rc = 0;
char *program;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
else
program++;
if (check_client_spool(NULL) < 0) {
gettext("couldn't validate local spool area (%s)\n"),
return (-1);
}
else
get_user_name()) != 0)
start_daemon(1);
if (exit_code == 0)
return (exit_code);
}