2
* @OPENGROUP_COPYRIGHT@
4
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
5
* Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
6
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
7
* the full copyright text.
9
* This software is subject to an open license. It may only be
10
* used on, with or for operating systems which are themselves open
11
* source systems. You must contact The Open Group for a license
12
* allowing distribution and sublicensing of this software on, with,
13
* or for operating systems which are not Open Source programs.
15
* See http://www.opengroup.org/openmotif/license for full
16
* details of the license agreement. Any use, reproduction, or
17
* distribution of the program constitutes recipient's acceptance of
20
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
21
* PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
* KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
23
* WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
24
* OR FITNESS FOR A PARTICULAR PURPOSE
26
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
27
* NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
28
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
30
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
33
* EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGES.
46
static char rcsid[] = "$XConsortium: Mrmtable.c /main/13 1996/11/13 14:04:22 drk $"
49
/* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
59
* This module contains the keyword tables and functions used by to
60
* support the compressing and uncompressing of strings in URM.
72
#include <X11/Intrinsic.h>
73
#include <Mrm/MrmAppl.h>
82
* Urm__FixupCompressionTable make table memory resident
84
* Urm__FindClassDescriptor find descriptor in file/memory
86
* Urm__UncompressCode uncompress a code
88
* Urm__IsSubtreeResource predicate for subtree resources
94
* FUNCTIONAL DESCRIPTION:
96
* This routine fixes up a file-based compression table. It resolves
97
* offsets into memory pointers. If requested, it then looks up
98
* each resulting string and attempts to replace it with a
99
* function pointer (from the function hash table).
103
* ctable the compression table to fix up
104
* qfindcldesc if TRUE, attempt to look up the strings as
105
* indexes of class descriptors
115
* MrmSUCCESS if all fixup operations succeed
116
* MrmFAILURE if any operation fails (usually function lookup)
126
Urm__FixupCompressionTable (UidCompressionTablePtr ctable,
128
Boolean byte_swapped)
133
int fixndx ; /* table fixup loop index */
134
Cardinal result = MrmSUCCESS;
135
WCIClassDescPtr cldesc; /* for class descriptor */
136
Cardinal clres; /* lookup result */
138
* Swap bytes if necessary and fix up the table offsets to be pointers
142
swapbytes(ctable->validation);
143
swapbytes(ctable->num_entries);
145
for ( fixndx=UilMrmMinValidCode ; fixndx<ctable->num_entries ; fixndx++ )
147
if ( byte_swapped ) swapbytes(ctable->entry[fixndx].stoffset);
148
ctable->entry[fixndx].cstring =
149
((char *)ctable+ctable->entry[fixndx].stoffset);
152
* Look up each string as a function if requested
155
for ( fixndx=UilMrmMinValidCode ; fixndx<ctable->num_entries ; fixndx++ )
157
clres = Urm__WCI_LookupClassDescriptor
158
(ctable->entry[fixndx].cstring, &cldesc);
159
if ( clres == MrmSUCCESS )
160
ctable->entry[fixndx].cldesc = cldesc;
163
ctable->entry[fixndx].cldesc = NULL;
177
* FUNCTIONAL DESCRIPTION:
179
* This routine finds a class descriptor corresponding to a class
180
* compression code or name. It looks up the class in the file's
181
* compression table if possible. Otherwise, it uses the older built-in
186
* cfile IDB file in which to find compression table
187
* code compression code to be uncompressed
188
* name the class name; the convenience function name.
189
* class_return to return the class descriptor
199
* MrmSUCCESS if class descriptor found
200
* MrmFAILURE otherwise
210
Urm__FindClassDescriptor (IDBFile cfile,
213
WCIClassDescPtr *class_return)
217
* Use the built-in tables if the file has none. Else a simple lookup.
219
if ( code == UilMrmUnknownCode )
220
return Urm__WCI_LookupClassDescriptor (name, class_return);
221
if ( cfile->class_ctable == NULL )
222
return Urm__UT_Error ("Urm__FindClassDescriptor", _MrmMMsg_0050,
223
NULL, NULL, MrmFAILURE);
224
if ( code < UilMrmMinValidCode )
226
if ( code >= cfile->class_ctable->num_entries )
228
*class_return = cfile->class_ctable->entry[code].cldesc;
229
if ( *class_return == NULL )
240
* FUNCTIONAL DESCRIPTION:
242
* This routine returns the string corresponding to a compression code.
243
* It looks up the code in the file's compression table if it has
244
* one, else falls back on the old built-in tables. The code is looked
245
* up in the resource tables.
249
* cfile IDB file in which to find compression table
250
* code compression code to be uncompressed
251
* stg_return to return result of uncompression
261
* MrmSUCCESS if uncompression successful
262
* MrmFAILURE otherwise
272
Urm__UncompressCode (IDBFile cfile,
278
* A simple lookup in the file's compression tables.
280
if ( cfile->resource_ctable == NULL )
281
return Urm__UT_Error ("Urm__UncompressCode", _MrmMMsg_0050,
282
NULL, NULL, MrmFAILURE);
283
if ( code < UilMrmMinValidCode )
285
if ( code >= cfile->resource_ctable->num_entries )
287
*stg_return = cfile->resource_ctable->entry[code].cstring;
297
* FUNCTIONAL DESCRIPTION:
299
* This routine checks to see if a resource is marked as rooting a
300
* widget subtree, that is, is a resource which requires that a
301
* widget subtree be instantiated as its value.
303
* Initial version uses crude check. To be replaced by table lookup.
307
* cfile file containing table information
308
* code code to be checked
318
* TRUE if subtree value is required
329
Urm__IsSubtreeResource (IDBFile cfile,
334
* Do a string comparison for for the subtree resources.
336
if ( code < UilMrmMinValidCode )
338
if ( code >= cfile->resource_ctable->num_entries )
341
if ( strcmp(cfile->resource_ctable->entry[code].cstring,XmNsubMenuId) == 0 )