cancel_job.c revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e
/*
* 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 2006 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 <sys/systeminfo.h>
#include <string.h>
#include <libintl.h>
#include <netdb.h>
#include <syslog.h>
/* lpsched include files */
#include "lp.h"
#include "msgs.h"
#include "printers.h"
#include "class.h"
#include "misc.h"
/* print NS include */
static char *
{
char *tmp, *s;
host = "all";
*s = '_';
char thost[MAXHOSTNAMELEN];
}
}
return (buf);
}
/*
* lpsched_cancel_job() attempts to cancel an lpsched requests that match the
* passed in criteria. a message is written for each cancelation or
* attempted cancelation
*/
int
{
short status;
char *cancel_name;
int first_job_only = 0;
return (-1);
/* if list is empty, then cancel only the first job */
first_job_only = 1;
return (-1);
}
return (-1);
}
do {
short outcome;
&file) < 0) {
gettext("Failure to communicate with lpsched\n"));
return (-1);
}
switch (status) {
case MOK:
case MOKMORE:
/*
* if cancelling only the fist job, then add
* the first job to job_list and increment
* first_job_only so no more jobs get added
*/
if (first_job_only == 1) {
reqid);
break;
} else if (first_job_only > 1)
break;
reqid);
break;
}
}
}
break;
default:
break;
}
requestor = "root";
"cancel %s, owned by %s, on %s, requested by %s\n",
gettext("Failure to communicate with lpsched\n"));
return (-1);
}
do {
int status2;
char *job_name = "unknown";
&job_name) < 0) {
gettext("Failure to communicate with lpsched\n"));
return (-1);
}
switch (status2) {
case MOK:
case MOKMORE:
job_name);
break;
case MUNKNOWN:
case MNOPERM:
reqid);
break;
break;
case M2LATE:
job_name);
break;
default:
gettext("%s: cancel failed (%d)\n"),
break;
}
job_list++;
}
return (0);
}