lpstat.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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <syslog.h>
#include <locale.h>
#ifndef SUNOS_4
#include <libintl.h>
#endif
#include <sys/systeminfo.h>
#include <errno.h>
#include <netdb.h>
#include "parse.h"
#include "sysv-functions.h"
#include "bsd-functions.h"
extern char *optarg;
extern char *getenv(const char *);
extern char *getname(void);
static int exit_code = 0;
static int _processing_all = 0;
static int sysvVerbose = 0;
static int sysvDesc = 0;
static int sysvLocal = 0;
static int bsdFormat = SHOW_QUEUE_SHORT_REQUEST;
static int bsdInterval = 0;
static char **bsdv;
static int bsdc;
typedef enum _work_type work_type_t;
typedef struct _work_entry work_entry_t;
struct _work_entry {
char *printer;
char *user;
int id;
};
static void
{
return;
(void **)workList,
(void *)tmp);
gettext("No default destination\n"));
exit_code = 1;
} else {
printer);
exit_code = 1;
}
} else
(void *)tmp);
}
static char *
check_for_req_id(char *name)
{
char *p;
char *p1;
/* request id has the form <name>-<number> */
return (NULL);
p = p1 - 1;
p--;
if (*p != '-' || p == name)
return (NULL);
else
return (p);
}
static void
{
char *p;
char *elem;
return;
}
switch (type) {
case RANK:
case ACCEPTING:
case STATUS:
case DEVICE:
break;
case CHAR_SETS:
case CLASSES:
case FORMS:
case USER:
break;
case ENTRIES:
else {
*p++ = '\0';
}
break;
}
}
}
static char *
{
switch (type) {
case STATUS:
return ("-p");
case RANK:
return ("-R");
case USER:
return ("-u");
case ENTRIES:
return ("-o");
default:
return (NULL);
}
}
/*
* This function is for a performance improvement.
*/
static int
{
char buf[MAXPATHLEN];
return (-1);
}
}
return (1);
printer);
/* OK its not a local printer but may be a local class */
return (1);
}
return (0);
}
/*
* Determine if there are any local printers in the list
*/
static int
{
static int local_printer_found = 0;
static int already_looked = 0;
if (already_looked == 0) {
already_looked = 1;
return (0);
}
/* Step through list and break out if we find a local printer */
continue;
break;
printers++;
}
local_printer_found = 1;
}
return (local_printer_found);
}
/*
* Determine if local status needs to be run. This is true
* if there are any local printers in the list with a local
* printer definition.
*/
static int
{
}
static int
{
int rank = 0;
int rc = 0;
case RUNNING:
sysv_running();
return (0);
case DEFAULT:
sysv_default();
return (0);
case FORMS:
gettext("form listing not supported on client\n")));
case CLASSES:
gettext("class listing not supported on client\n")));
case CHAR_SETS:
gettext("char set listing not supported on client\n")));
}
return (0);
/*
* If the printer is a local LP printer, we can use the local lpstat
* and it should be faster than going via the network.
*/
/*
* If we are processing all printers
* (ie. -p, -o, -r,
* -u, -t), simply return, because the local lpstat
* was already run and all local printers were reported
* against.
*/
if (_processing_all != 0)
return (0);
return (sysv_local_status(option,
gettext("can't execute \n")));
return (sysv_local_status(option,
gettext("can't execute \n")));
else
return (sysv_local_status(option,
gettext("can't execute \n")));
}
}
case STATUS:
case RANK:
case USER:
case ENTRIES:
case STATUS:
sysvDesc);
else
break;
case ENTRIES:
case USER:
rank = -1;
/*FALLTHRU*/
case RANK:
NS_NAME_DEFAULT) != 0))
else
break;
}
}
}
break;
default:
case DEVICE:
break;
case ACCEPTING:
break;
case BSD_QUEUE:
do {
int i;
if (bsdInterval != 0)
clear_screen();
break;
if (bsdInterval != 0)
(void) sleep(bsdInterval);
} while (bsdInterval != 0);
break;
}
}
return (rc);
}
static int
{
}
static int
{
int rc = 0;
case RUNNING:
case DEFAULT:
case CLASSES:
case FORMS:
case CHAR_SETS:
break;
case STATUS:
case RANK:
case ENTRIES:
case ACCEPTING:
case DEVICE:
case SUMMARY:
case USER:
case FULL:
if (_printer_bindings == NULL) {
if (sysvLocal == 0) {
} else {
}
}
rc += list_iterate(
(void **)_printer_bindings,
_processing_all = 1;
rc += list_iterate(
(void **)_printer_bindings,
"can't execute \n"));
rc += list_iterate(
(void **)_printer_bindings,
"can't execute \n"));
rc += list_iterate(
(void **)_printer_bindings_unique,
_processing_all = 0;
}
/*
* Put this here to preserve same ordering
* as found in previous releases.
*/
}
rc += list_iterate(
(void **)_printer_bindings,
"can't execute \n"));
} else {
"can't execute \n"));
}
}
_processing_all = 1;
rc += list_iterate(
(void **)_printer_bindings,
} else {
rc += list_iterate(
(void **)_printer_bindings_unique,
}
_processing_all = 0;
} else
rc += list_iterate(
(void **)_printer_bindings,
verbose);
return (rc);
default:
return (rc);
}
} else {
}
return (rc);
}
static void
{
char **argv,
*program;
int c;
int argc = 0;
char *user;
else
program++;
exit(1);
}
switch (c) { /* these may or may not have an option */
case 'R':
case 'a':
case 'c':
case 'f':
case 'o':
case 'p':
case 'u':
case 'v':
if (optarg[0] == '-') {
/* this check stop a possible infinite loop */
optind--;
}
switch (c) {
case 'D':
sysvDesc++;
break;
case 'L':
sysvLocal++;
/* undocumented option that keeps it long and local */
break;
case 'R':
break;
case 'S':
break;
case 'a':
break;
case 'c':
break;
case 'd':
break;
case 'f':
break;
case 'l':
sysvVerbose++;
break;
case 'o':
break;
case 'p':
break;
case 'r':
break;
case 's':
break;
case 't':
break;
case 'u':
break;
case 'v':
break;
default:
"Usage: %s [-drtslDL] [-R [list]] [-S [list]] "
"[-a [list]] [-c [list]] [-f [list]] "
"[-o [list]] [-p [printer]] [-u [list]] "
"[-v [list]] [list]\n"),
av[0]);
exit(1);
}
}
user = get_user_name();
}
}
static void
{
char *printer;
int c;
return;
switch (c) {
case 'l':
break;
case 'P':
break;
default:
gettext("Usage: %s [-P printer] [-l] [+ interval] [list]\n"),
av[0]);
exit(1);
}
else
}
int
{
char *program;
int rc = 0;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
else
program++;
if (check_client_spool(NULL) < 0) {
"area (%s)\n"), SPOOL_DIR);
return (1);
}
else {
}
if (exit_code == 0)
return (exit_code);
}