~ubuntu-branches/ubuntu/quantal/openmotif/quantal

« back to all changes in this revision

Viewing changes to lib/Mrm/Mrmtable.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bauer
  • Date: 2010-06-23 12:12:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100623121231-u89gxdp51sg9wjj2
Tags: 2.3.0-1
* New Maintainer (Closes: #379258) 
* Acknowledge NMU changes
* New upstream release (Closes: #494375)
* Get rid of security patches as they are already part of new upstream
  release (00-xpmvuln.openmotif.patch, 342092-CVE-2005-3964.patch)
* Bump Standards to 3.8.4
* Added {misc:Depends} to make the package lintian cleaner
* Fix weak-library-dev-dependency by adding ${binary:Version}) for the
  -dev Package of openmotif
* Let package depend on autotools-dev to use newer autotools-helper-files
* Work around an autoconf-bug (Gentoo-Bug #1475)
* Added Client-side anti-aliased fonts support via XFT
* Added UTF-8 and UTF8_STRING atom support
* Ability to show text and pixmaps in Label, LabelGadget and all
  derived widgets
* Support of PNG/JPEG image formats in the same way as XPM is supported
* Increase FILE_OFFSET_BITS to 64 to show files >2GB in file-selector
  Idea taken from Magne Oestlyngen (Closes: #288537)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 *  @OPENGROUP_COPYRIGHT@
 
3
 *  COPYRIGHT NOTICE
 
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.
 
8
 *  
 
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.
 
14
 *  
 
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
 
18
 *  this agreement.
 
19
 *  
 
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
 
25
 *  
 
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.
 
35
 */ 
 
36
/* 
 
37
 * HISTORY
 
38
 */ 
 
39
#ifdef HAVE_CONFIG_H
 
40
#include <config.h>
 
41
#endif
 
42
 
 
43
 
 
44
#ifdef REV_INFO
 
45
#ifndef lint
 
46
static char rcsid[] = "$XConsortium: Mrmtable.c /main/13 1996/11/13 14:04:22 drk $"
 
47
#endif
 
48
#endif
 
49
/* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
 
50
 
 
51
/*
 
52
 *++
 
53
 *  FACILITY:
 
54
 *
 
55
 *      UIL Manager (URM)
 
56
 *
 
57
 *  ABSTRACT:
 
58
 *
 
59
 *      This module contains the keyword tables and functions used by to
 
60
 *      support the compressing and uncompressing of strings in URM.
 
61
 *
 
62
 *--
 
63
 */
 
64
 
 
65
 
 
66
/*
 
67
 *
 
68
 *  INCLUDE FILES
 
69
 *
 
70
 */
 
71
 
 
72
#include <X11/Intrinsic.h>
 
73
#include <Mrm/MrmAppl.h>
 
74
#include <Mrm/Mrm.h>
 
75
#include "MrmMsgI.h"
 
76
 
 
77
 
 
78
/*
 
79
 *
 
80
 *  TABLE of CONTENTS
 
81
 *
 
82
 *      Urm__FixupCompressionTable      make table memory resident
 
83
 *
 
84
 *      Urm__FindClassDescriptor        find descriptor in file/memory
 
85
 *
 
86
 *      Urm__UncompressCode             uncompress a code
 
87
 *
 
88
 *      Urm__IsSubtreeResource          predicate for subtree resources
 
89
 */
 
90
 
 
91
/*
 
92
 *++
 
93
 *
 
94
 *  FUNCTIONAL DESCRIPTION:
 
95
 *
 
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).
 
100
 *
 
101
 *  FORMAL PARAMETERS:
 
102
 *
 
103
 *      ctable          the compression table to fix up
 
104
 *      qfindcldesc     if TRUE, attempt to look up the strings as
 
105
 *                      indexes of class descriptors
 
106
 *
 
107
 *  IMPLICIT INPUTS:
 
108
 *
 
109
 *  IMPLICIT OUTPUTS:
 
110
 *
 
111
 *      none
 
112
 *
 
113
 *  FUNCTION VALUE:
 
114
 *
 
115
 *      MrmSUCCESS      if all fixup operations succeed
 
116
 *      MrmFAILURE      if any operation fails (usually function lookup)    
 
117
 *
 
118
 * SIDE EFFECTS:
 
119
 *
 
120
 *      none
 
121
 *
 
122
 *--
 
123
 */
 
124
 
 
125
Cardinal 
 
126
Urm__FixupCompressionTable (UidCompressionTablePtr      ctable,
 
127
                            Boolean                     qfindcldesc,
 
128
                            Boolean                     byte_swapped)
 
129
{
 
130
  /*
 
131
   *  Local variables
 
132
   */
 
133
  int                   fixndx ;        /* table fixup loop index */
 
134
  Cardinal              result = MrmSUCCESS;
 
135
  WCIClassDescPtr       cldesc;         /* for class descriptor */
 
136
  Cardinal              clres;          /* lookup result */
 
137
  /*
 
138
   * Swap bytes if necessary and fix up the table offsets to be pointers
 
139
   */
 
140
  if ( byte_swapped )
 
141
    {
 
142
      swapbytes(ctable->validation);
 
143
      swapbytes(ctable->num_entries);
 
144
    }
 
145
  for ( fixndx=UilMrmMinValidCode ; fixndx<ctable->num_entries ; fixndx++ )
 
146
    {
 
147
      if ( byte_swapped ) swapbytes(ctable->entry[fixndx].stoffset);
 
148
      ctable->entry[fixndx].cstring = 
 
149
        ((char *)ctable+ctable->entry[fixndx].stoffset);
 
150
    }   
 
151
  /*
 
152
   * Look up each string as a function if requested
 
153
   */
 
154
  if ( qfindcldesc )
 
155
    for ( fixndx=UilMrmMinValidCode ; fixndx<ctable->num_entries ; fixndx++ )
 
156
      {
 
157
        clres = Urm__WCI_LookupClassDescriptor
 
158
          (ctable->entry[fixndx].cstring, &cldesc);
 
159
        if ( clres == MrmSUCCESS )
 
160
          ctable->entry[fixndx].cldesc = cldesc;
 
161
        else
 
162
          {
 
163
            ctable->entry[fixndx].cldesc = NULL;
 
164
            result = MrmFAILURE;
 
165
          }
 
166
      }
 
167
 
 
168
  return result;
 
169
 
 
170
}    
 
171
 
 
172
 
 
173
 
 
174
/*
 
175
 *++
 
176
 *
 
177
 *  FUNCTIONAL DESCRIPTION:
 
178
 *
 
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
 
182
 *      tables.
 
183
 *
 
184
 *  FORMAL PARAMETERS:
 
185
 *
 
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
 
190
 *
 
191
 *  IMPLICIT INPUTS:
 
192
 *
 
193
 *  IMPLICIT OUTPUTS:
 
194
 *
 
195
 *      none
 
196
 *
 
197
 *  FUNCTION VALUE:
 
198
 *
 
199
 *      MrmSUCCESS      if class descriptor found
 
200
 *      MrmFAILURE      otherwise
 
201
 *
 
202
 * SIDE EFFECTS:
 
203
 *
 
204
 *      none
 
205
 *
 
206
 *--
 
207
 */
 
208
 
 
209
Cardinal 
 
210
Urm__FindClassDescriptor (IDBFile               cfile,
 
211
                          MrmCode               code,
 
212
                          char                  *name,
 
213
                          WCIClassDescPtr       *class_return)
 
214
{
 
215
 
 
216
  /*
 
217
   * Use the built-in tables if the file has none. Else a simple lookup.
 
218
   */
 
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 )
 
225
    return MrmFAILURE;
 
226
  if ( code >= cfile->class_ctable->num_entries )
 
227
    return MrmFAILURE;
 
228
  *class_return = cfile->class_ctable->entry[code].cldesc;
 
229
  if ( *class_return == NULL )
 
230
    return MrmFAILURE;
 
231
  return MrmSUCCESS;
 
232
 
 
233
}    
 
234
 
 
235
 
 
236
 
 
237
/*
 
238
 *++
 
239
 *
 
240
 *  FUNCTIONAL DESCRIPTION:
 
241
 *
 
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.
 
246
 *
 
247
 *  FORMAL PARAMETERS:
 
248
 *
 
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
 
252
 *
 
253
 *  IMPLICIT INPUTS:
 
254
 *
 
255
 *  IMPLICIT OUTPUTS:
 
256
 *
 
257
 *      none
 
258
 *
 
259
 *  FUNCTION VALUE:
 
260
 *
 
261
 *      MrmSUCCESS      if uncompression successful
 
262
 *      MrmFAILURE      otherwise
 
263
 *
 
264
 * SIDE EFFECTS:
 
265
 *
 
266
 *      none
 
267
 *
 
268
 *--
 
269
 */
 
270
 
 
271
Cardinal
 
272
Urm__UncompressCode (IDBFile                    cfile,
 
273
                     MrmCode                    code,
 
274
                     String                     *stg_return)
 
275
{
 
276
 
 
277
  /*
 
278
   * A simple lookup in the file's compression tables.
 
279
   */
 
280
  if ( cfile->resource_ctable == NULL )
 
281
    return Urm__UT_Error ("Urm__UncompressCode", _MrmMMsg_0050,
 
282
                          NULL, NULL, MrmFAILURE);
 
283
  if ( code < UilMrmMinValidCode )
 
284
    return MrmFAILURE;
 
285
  if ( code >= cfile->resource_ctable->num_entries )
 
286
    return MrmFAILURE;
 
287
  *stg_return = cfile->resource_ctable->entry[code].cstring;
 
288
  return MrmSUCCESS;
 
289
 
 
290
}    
 
291
 
 
292
 
 
293
 
 
294
/*
 
295
 *++
 
296
 *
 
297
 *  FUNCTIONAL DESCRIPTION:
 
298
 *
 
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.
 
302
 *
 
303
 *      Initial version uses crude check. To be replaced by table lookup.
 
304
 *
 
305
 *  FORMAL PARAMETERS:
 
306
 *
 
307
 *      cfile           file containing table information
 
308
 *      code            code to be checked
 
309
 *
 
310
 *  IMPLICIT INPUTS:
 
311
 *
 
312
 *  IMPLICIT OUTPUTS:
 
313
 *
 
314
 *      none
 
315
 *
 
316
 *  FUNCTION VALUE:
 
317
 *
 
318
 *      TRUE            if subtree value is required
 
319
 *      FALSE           otherwise
 
320
 *
 
321
 * SIDE EFFECTS:
 
322
 *
 
323
 *      none
 
324
 *
 
325
 *--
 
326
 */
 
327
 
 
328
Boolean 
 
329
Urm__IsSubtreeResource (IDBFile                 cfile,
 
330
                        MrmCode                 code)
 
331
{
 
332
 
 
333
  /*
 
334
   * Do a string comparison for for the subtree resources.
 
335
   */
 
336
  if ( code < UilMrmMinValidCode )
 
337
    return FALSE;
 
338
  if ( code >= cfile->resource_ctable->num_entries )
 
339
    return FALSE;
 
340
 
 
341
  if ( strcmp(cfile->resource_ctable->entry[code].cstring,XmNsubMenuId) == 0 )
 
342
    return TRUE;
 
343
  return FALSE;
 
344
 
 
345
}    
 
346
 
 
347