/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 *
 */

extern char *gettxt();
/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: device.c 1.3 89/12/01 $@(#)nlp:cmd/lpstat/device.c	1.3"

#include "sys/types.h"

#include "lp.h"
#include "printers.h"

#define	WHO_AM_I	I_AM_LPSTAT
#include "oam.h"

#include "lpstat.h"


static void		putdline();

/**
 ** do_device()
 **/

void			do_device (list)
	char			**list;
{
	register PRINTER	*pp;

	while (*list) {
		if (STREQU(NAME_ALL, *list))
			while ((pp = getprinter(NAME_ALL)))
				putdline (pp);

		else if ((pp = getprinter(*list)))
			putdline (pp);

		else {
			LP_ERRMSG1 (ERROR, E_LP_NOPRINTER, *list);
			exit_rc = 1;
		}

		list++;
	}
	return;
}

static void		putdline (pp)
	register PRINTER	*pp;
{
	if (!pp->device && !pp->dial_info) {
		LP_ERRMSG1 (ERROR, E_LP_PGONE, pp->name);
		done (1);

	} else if (pp->dial_info) {
		PRINTF (gettxt("lpstat:11", "dial token for %s: %s"), pp->name, pp->dial_info);
		if (pp->device)
			PRINTF (gettxt("lpstat:12", " (on port %s)"), pp->device);
		PRINTF ("\n");

	} else
		PRINTF (gettxt("lpstat:13", "device for %s: %s\n"), pp->name, pp->device);

	return;
}
