/*
 * $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.
 */
#ident "$Header: ttydevname.c 1.1 88/12/20 $"

#include <stdio.h>
#include <sys/types.h>		/* for dev_t */
#include <sys/sysmacros.h>	/* for major(), minor() and makedev() */

extern int ttyname_to_dev();
extern char *dev_to_ttyname();

main(argc, argv)
	int argc;
	char *argv[];
{
	dev_t dev;

	switch (argc) {
	case 2:
		if (ttyname_to_dev(argv[1], &dev) == -1) {
			fprintf(stderr, "error: %s: invalid name\n", argv[1]);
			return(1);
		}
		printf("major = %d, minor = %d\n", major(dev), minor(dev));
		break;
	case 3:
		dev = makedev((short)atoi(argv[1]), (short)atoi(argv[2]));
		printf("%s\n", dev_to_ttyname(dev));
		break;
	default:
		fprintf(stderr, "usage: %s <ttypath>\n", argv[0]);
		fprintf(stderr, "usage: %s <major> <minor>\n", argv[0]);
		return(1);
	}
	return(0);
}
