gtxt.c revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1993, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* Copyright (c) 1988 AT&T */ 2N/A/* All Rights Reserved */ 2N/A/* __gtxt(): Common part to gettxt() and pfmt() */ 2N/A/* Minimum number of open catalogues */ 2N/A * setcat(cat): Specify the default catalogue. 2N/A * Return a pointer to the local copy of the default catalogue 2N/A * load a message catalog which specified with current locale, 2N/A /* First time called, allocate space */ 2N/A * We won't set err here, because an invalid locale is not 2N/A * the fatal condition, but we can fall back to "C" 2N/A * unmap the message catalog, and release the db_info slot. 2N/A * go through the db_info, and find out a db_info slot regarding 2N/A * the given current locale and catalog name. 2N/A * If db is not NULL, then search will start from top of the array, 2N/A * otherwise it will start from the next of given db. 2N/A * If curloc is set to NULL, then return a cache without regards of 2N/A /* catalog has been loaded */ 2N/A /* not a valid id */ 2N/A * __gtxt(catname, id, dflt): Return a pointer to a message. 2N/A * catname is the name of the catalog. If null, the default catalog is 2N/A * id is the numeric id of the message in the catalogue 2N/A * dflt is the default message. 2N/A * Information about non-existent catalogues is kept in db_info, in 2N/A * such a way that subsequent calls with the same catalogue do not 2N/A * try to open the catalogue again. 2N/A /* Check for invalid message id */ 2N/A * If catalogue is unspecified, use default catalogue. 2N/A * No catalogue at all is an error 2N/A /* First look up the cache */ 2N/A * The catalog has been loaded, and if id seems valid, 2N/A * seems given id is out of bound or does not exist. In this 2N/A * case, we need to look up a message for the "C" locale as 2N/A * documented in the man page. 2N/A * Even the message catalog for the "C" has not been 2N/A /* no message found */ 2N/A * The catalog has not been loaded or even has not 2N/A * attempted to be loaded, invalidate all caches related to 2N/A * the catname for possibly different locale. 2N/A * load a message catalog for the requested locale. 2N/A * If the requested catalog is either not exist or message 2N/A * id is invalid, then try to load from "C" locale. 2N/A /* no message found */