2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $TOG: CatMgr.C /main/7 1998/04/20 12:53:56 mgreess $
24 /* Copyright (c) 1995 FUJITSU LIMITED */
25 /* All Rights Reserved */
37 #include <Dt/EnvControlP.h>
43 CatMgr* CatMgr::f_msg_catalog_mgr = NULL;
45 CatMgr::CatMgr() : f_msg(NULL), f_default(NULL)
48 char* nlspath = getenv("NLSPATH");
50 cerr << "(DEBUG) NLSPATH=" << nlspath << '\n' << flush;
52 cerr << "(WARNING) NLSPATH not specified" << '\n' << flush;
55 f_catd = catopen(CATALOG_PREFIX, NL_CAT_LOCALE);
57 // setup default message
58 if (is_open(f_catd)) {
60 cerr << "(DEBUG) catopen succeeded." << '\n' << flush;
62 char* msg = ::catgets(f_catd, Set_CatMgr, DEFAULT_MSG,
63 "default message not found.");
64 f_default = new char[strlen(msg) + 1];
65 strcpy(f_default, msg);
69 cerr << "(WARNING) catopen failed." << '\n' << flush;
70 static char* cat_not_found = (char*)"default message not found.";
72 static char* cat_not_found = (char*)"";
74 f_default = new char[strlen(cat_not_found) + 1];
75 strcpy(f_default, cat_not_found);
78 cerr << "(DEBUG) default msg=" << f_default << '\n' << flush;
81 f_msg_catalog_mgr = this;
92 if (is_open(f_catd)) {
93 int status = catclose(f_catd);
96 cerr << "(ERROR) catclose failed." << '\n' << flush;
100 cerr << "(DEBUG) catclose succeeded" << '\n' << flush;
106 cerr << "(DEBUG) catclose not attempted" << '\n' << flush;
112 CatMgr::catgets(int set_num, int msg_num, const char* def)
119 if (is_open(f_catd)) {
122 msg = ::catgets(f_catd, set_num, msg_num, def);
124 msg = ::catgets(f_catd, set_num, msg_num, f_default);
125 #if defined(UXPDS) && defined(GENCAT_BUG)
126 for (; *msg == ' ' || *msg == '\t'; msg++);
128 int msglen = strlen(msg);
129 f_msg = new char[msglen + 1];
130 #if defined(UXPDS) && defined(GENCAT_BUG)
132 cerr << "(DEBUG) catgets msg=<" << msg << ">\n" << flush;
134 // trim embracing double quotes on uxpds
135 if (msglen > 1 && *(msg + msglen - 1) == '"') {
136 if (*msg == *(msg + msglen - 1)) {
137 *(msg + msglen - 1) = '\0';
142 else if (*msg == '"') {
151 f_msg = new char[strlen(def) + 1];
155 f_msg =new char[strlen(f_default) + 1];
156 strcpy(f_msg, f_default);
160 assert( f_msg != NULL );
163 cerr << "(DEBUG) retrieved msg=" << f_msg << '\n' << flush;