/* $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: _locale.c 1.3 90/11/01 $@(#)libw:port/_locale.c 1.0 AT&T-UP"

#include "_locale.h"
#include <string.h>
#include <stdlib.h>

char *
_nativeloc(cat)	/* return value for category with "" locale */
int cat;
{
	static char lang[] = "LANG";
	static char *_loc_envs[LC_MAX][4] = /* env. vars for "" */
	{
		{"LC_CTYPE",	lang, 	"CHRCLASS",	0},
		{"LC_NUMERIC",	lang,	0},
		{"LC_TIME",	lang,	"LANGUAGE",	0},
		{"LC_COLLATE",	lang,	0},
		{"LC_MESSAGES",	lang,	0},
		{"LC_MONETARY",	lang,	0},		/* for posix compliance */
	};
	static char ans[LC_NAMELEN];
	register char *s;
	register char **p;

	for (p = _loc_envs[cat]; *p != 0; p++)
		if ((s = (char *)getenv(*p)) != 0 && s[0] != '\0')
			goto found;
	return  "C";
found:
	(void)strncpy(ans, s, LC_NAMELEN - 1);
	ans[LC_NAMELEN - 1] = '\0';
	return ans;
}

char *
_fullocale(loc, file)	/* "/usr/lib/locale/<loc>/<file>" */
char *loc;
char *file;
{
	static char ans[18 + 2 * LC_NAMELEN] = "/usr/lib/locale/";
	register char *p = ans + 16;

	(void)strcpy(p, loc);
	p += strlen(loc);
	p[0] = '/';
	(void)strcpy(p + 1, file);
	return ans;
}
