/* $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.
*/

/*	Copyright (c) 1988 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: getwidth.c 1.2 90/02/28 $@(#)libw:port/getwidth.c 1.0 AT&T-UP"

/*
 *                         ***** NOTE *****
 * This file is a duplicate of _getwidth.c in libcurses. If you change this
 * file you should change that file too. The alternative to these duplicate
 * files was to include -lw whenever one includes -lcurses, and this was
 * deemed too user-visible.
 *                                        richl@sequent 2/28/90
 */

#include <libw.h>
#include <ctype.h>
#define CSWIDTH	514

void getwidth(eucstruct)
eucwidth_t *eucstruct;
{
	unsigned char *cswidth = &_ctype[CSWIDTH];
	eucstruct->_eucw1 = cswidth[0];
	eucstruct->_eucw2 = cswidth[1];
	eucstruct->_eucw3 = cswidth[2];
	eucstruct->_multibyte = (cswidth[6] > 1);
	if (cswidth[0] > sizeof(unsigned short) 
	|| cswidth[1] > sizeof(unsigned short) 
	|| cswidth[2] > sizeof(unsigned short))
		eucstruct->_pcw = sizeof(unsigned long);
	else
		eucstruct->_pcw = sizeof(unsigned short);
	eucstruct->_scrw1 = cswidth[3];
	eucstruct->_scrw2 = cswidth[4];
	eucstruct->_scrw3 = cswidth[5];
	return;
}
