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 libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: I18nUtil.c /main/1 1996/03/25 00:52:03 pascale $ */
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
33 /************************************<+>*************************************
34 ****************************************************************************
38 ** Description: Contains utility functions for the Dtstyle I18N component.
41 ****************************************************************************
42 ************************************<+>*************************************/
44 /*+++++++++++++++++++++++++++++++++++++++*/
46 /*+++++++++++++++++++++++++++++++++++++++*/
51 /*+++++++++++++++++++++++++++++++++++++++*/
52 /* include extern functions */
53 /*+++++++++++++++++++++++++++++++++++++++*/
55 /*+++++++++++++++++++++++++++++++++++++++*/
57 /*+++++++++++++++++++++++++++++++++++++++*/
59 #define TAG_END_CHAR ':'
62 /*+++++++++++++++++++++++++++++++++++++++*/
63 /* Internal Functions */
64 /*+++++++++++++++++++++++++++++++++++++++*/
66 static char *trim_line (char * );
68 /*+++++++++++++++++++++++++++++++++++++++*/
69 /* Internal Variables */
70 /*+++++++++++++++++++++++++++++++++++++++*/
72 /* ******** file reading ******** */
74 static int tag_line_num = 0;
75 static char *tag_linebuf = NULL;
76 static char *tag_file = NULL;
85 tag_linebuf = (char *) XtCalloc(BUFSIZ, sizeof(char));
91 tag_linebuf = tag_file = 0;
104 while (fgets(lp = tag_linebuf, BUFSIZ, fp)) {
106 skip_white(lp); /* lp = trim_line(lp); */
107 if (!*lp || *lp == '\n' || is_comment_char(*lp))
109 if (!(lp2 = strchr(lp, TAG_END_CHAR))) {
113 lp2 = trim_line(lp2);
116 *valp = *lp2 ? lp2 : 0;
121 return (ferror(fp)) ? -1 : 0;
124 /* ******** string manupilation ******** */
131 register char *lastp;
134 for (lastp = ptr + strlen(ptr) - 1;
135 lastp >= ptr && (is_white(*lastp) || *lastp == '\n'); lastp--) ;
137 return ptr; /* return lastp > ptr ? ptr : NULL; */
149 /* if (!ptr || !*ptr || !val) return(False); */
151 base = ptr[0] == '0' ? (((ptr[1] & 0xdf) == 'X') ? 16 : 8) : 10;
152 *val = strtol(ptr, &pp, base);
153 if (!pp || *pp) return(False);
164 if (!ptr || !*ptr) return def_val;
167 switch (*ptr) { /* true/false , 1/0 , yes/no , on/off */
171 def_val = True; break;
176 def_val = False; break;
179 if (ptr[1] == 'N' || ptr[1] == 'n')
181 else if (ptr[1] == 'F' || ptr[1] == 'f')