show_queue.c revision 0a44ef6d9afbfe052a7e975f55ea0d2954b62a82
/*
* 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 <string.h>
#include <libintl.h>
#include <syslog.h>
/* lpsched include files */
#include "lp.h"
#include "msgs.h"
#include "printers.h"
#include "class.h"
#include "misc.h"
static char *
{
*dis_reason = NULL,
*rej_reason = NULL,
return ("no destination");
} else {
return (mesg);
}
switch (status) {
case MNODEST:
break;
case MNOINFO:
break;
case MTRANSMITERR:
gettext("failure to communicate with lpsched"));
break;
case MOK:
gettext("Warning: %s is down: %s\n"),
prname, dis_reason);
else if (prstatus & PS_REJECTED)
gettext("Warning: %s queue is turned off: %s\n"),
prname, rej_reason);
*bad_status = 0;
gettext("%s is ready and printing\n"),
prname);
}
break;
default:
break;
}
return (mesg);
}
static char *_rank_suffixes[] = {
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"
};
static char *
rank_string(const int rank)
{
/* Room for ten digits (2 ^ 31) plus suffix plus NUL */
static char buf[13];
if (rank < 0)
else if (rank == 0)
else
return (buf);
}
static int
{
return (1);
return (1);
else
list++;
return (0);
}
static int
{
int count = 0;
return (0);
do {
int id;
&file) < 0)
return (count);
continue;
switch (status) {
case MOK:
case MOKMORE:
count++;
if (status_message != NULL) {
if (type == 3)
}
gettext("%s\t%s\t%d\t%-32.32s%d bytes\n"),
} else { /* long format */
gettext("\n%s: %s\t\t\t\t[job %d %s]\n\t%-32.32s\t%d bytes\n"),
}
}
return (count);
}
/*
* lpsched_show_queue() attempts to display the queue of "pending" jobs. The
* "type" is used to determine if this should be a short or long format
* that gets written back to ofp.
*/
int
const char **list)
{
char *status_message = NULL;
int rank = 0;
return (-1);
do {
(const char *)status_message, &rank) > 0)
if (rank == 0)
else if (status_message != NULL)
return (0);
}