/*
 * |-----------------------------------------------------------|
 * | Copyright (c) 1990 MIPS Computer Systems, Inc.            |
 * | All Rights Reserved                                       |
 * |-----------------------------------------------------------|
 * |          Restricted Rights Legend                         |
 * | Use, duplication, or disclosure by the Government is      |
 * | subject to restrictions as set forth in                   |
 * | subparagraph (c)(1)(ii) of the Rights in Technical        |
 * | Data and Computer Software Clause of DFARS 52.227-7013.   |
 * |         MIPS Computer Systems, Inc.                       |
 * |         928 Arques Avenue                                 |
 * |         Sunnyvale, CA 94086                               |
 * |-----------------------------------------------------------|
 */
#ident	"$Header: _locale.c,v 1.1.2.1 92/06/24 14:10:39 marker Exp $"

/*	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	"@(#)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},
	};
	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)	/* "/lib/locale/<loc>/<file>" */
char *loc;
char *file;
{
	static char ans[14 + 2 * LC_NAMELEN] = "/lib/locale/";
	register char *p = ans + 12;

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