/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Messaging support. To minimize ld.so.1's overhead, messaging support isn't
* enabled until we need to contruct a message - Note that we don't rely on the
* application to signify whether messaging is applicable, as many message
* conditions (such as relocations) are generated before the application gains
* control.
*
* This code implements a very trimmed down version of the capabilities found
* via setlocale(3c), textdomain(3i) and gettext(3i). Dragging in the original
* be included which is far too expensive for ld.so.1.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <libintl.h>
#include "_rtld.h"
#include "msg.h"
/*
* A message object file (as generated by msgfmt(1)) consists of a message
* header, followed by a message list, followed by the msgid strings and then
* the msgstr strings. None of this is defined in any OSNET available headers
* so we have our own local definitions :-(
*/
typedef struct {
} Msghdr;
typedef struct {
int lst_less;
int lst_more;
int lst_idoff;
int lst_stroff;
} Msglst;
/*
* Define a local structure for maintaining the domains we care about.
*/
typedef struct {
const char *dom_name;
} Domain;
/*
* Perform a binary search of a message file (described by the Msghdr) for a
* msgid (string). Given a match return the associated msgstr, otherwise
* return the original msgid.
*/
static const char *
{
/*
* Establish pointers to the message list (we actually start the search
* in the middle of this list (hdr->midlst), the msgid strings (ids)
* and the msgstr strings (strs).
*/
for (;;) {
if (var < 0) {
return (msgid);
} else {
return (msgid);
}
}
/* NOTREACHED */
return (NULL); /* keep gcc happy */
}
/*
* Open a message file. Following the model of setlocale(3c) we obtain the
* message file for the specified locale. Normally this is:
*
*
* The locale was determined during initial environment processing (see
* readenv()), which was determined from an LC_ALL, LC_MESSAGES or LANG
* setting. If no locale has been specified, or any file processing errors
* occur, internationalization is basically disabled.
*/
static void
{
int fd;
int count;
return;
return;
}
/* LINTED */
return;
}
/* checks if opened file is msg file */
return;
}
return;
}
(int)sizeof (Msghdr);
return;
}
/*
* We have a good message file, initialize the Domain information.
*/
}
/*
* Two interfaces are established to support our internationalization.
* gettext(3i) calls originate from all link-editor libraries, and thus the
* SUNW_OST_SGS domain is assumed. dgettext() calls originate from
* dependencies such as libelf and libc.
*
* Presently we support two domains (libc's strerror() uses SUNW_OST_OSLIB).
* If ld.so.1's dependencies evolve to require more then the `domain' array
* maintained below can be enlarged or made more dynamic in nature.
*/
char *
{
static int domaincnt = 0;
int cnt;
return ((char *)msgid);
/*
* Determine if we've initialized any domains yet.
*/
if (domaincnt == 0) {
return ((char *)msgid);
domaincnt = 2;
}
/*
* If this is a new locale make sure we clean up any old ones.
*/
if (rtld_flags & RT_FL_NEWLOCALE) {
cnt = 0;
if (_domain->dom_msghdr == 0)
continue;
_domain->dom_msghdr = 0;
}
}
/*
* Determine which domain we need.
*/
break;
break;
}
return ((char *)msgid);
/*
* Determine if the domain has been initialized yet.
*/
if (_domain->dom_msghdr == 0)
return ((char *)msgid);
}
/*
* This satisfies any dependencies of code dragged in from libc, as we don't
* want libc's gettext implementation in ld.so.1. This routine may not be
* referenced, in which case -zignore will discard it.
*/
char *
{
}
/*
* The sgsmsg.1l use requires the following interface.
*/
const char *
{
}