~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/PEX5/ddpex/mi/shared/miLUTProcs.ci

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: miLUTProcs.ci,v 1.4 2001/02/09 02:04:13 xorgcvs Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1990, 1991, 1998  The Open Group
 
5
 
 
6
Permission to use, copy, modify, distribute, and sell this software and its
 
7
documentation for any purpose is hereby granted without fee, provided that
 
8
the above copyright notice appear in all copies and that both that
 
9
copyright notice and this permission notice appear in supporting
 
10
documentation.
 
11
 
 
12
The above copyright notice and this permission notice shall be included
 
13
in all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
21
OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall
 
24
not be used in advertising or otherwise to promote the sale, use or
 
25
other dealings in this Software without prior written authorization
 
26
from The Open Group.
 
27
 
 
28
 
 
29
Copyright 1990, 1991 by Sun Microsystems, Inc. 
 
30
All Rights Reserved
 
31
 
 
32
Permission to use, copy, modify, and distribute this software and its
 
33
documentation for any purpose and without fee is hereby granted,
 
34
provided that the above copyright notice appear in all copies and that
 
35
both that copyright notice and this permission notice appear in
 
36
supporting documentation, and that the name of Sun Microsystems
 
37
not be used in advertising or publicity pertaining to distribution
 
38
 of the software without specific, written prior permission.
 
39
 
 
40
SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
41
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
 
42
SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 
43
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
44
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
45
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
46
SOFTWARE.
 
47
 
 
48
*/
 
49
 
 
50
#ifndef MILUT_PROCS_CI
 
51
#define MILUT_PROCS_CI
 
52
 
 
53
#include "pexUtils.h"
 
54
 
 
55
/* this file is a template for defining the lut procedures */
 
56
/* it uses a bunch of macros (blah) but allows easier porting */
 
57
/* the following macros must be defined in the file which includes
 
58
 * this one before this file is included:
 
59
 *      LUT_TYPE        the table type
 
60
 *      LUT_TABLE_START pointer to the first entry in the table
 
61
 *      LUT_PDE_ENTRIES the beginning of the predefined entries table
 
62
 *      LUT_SET_PDE_ENTRY       macro which sets an entry to a predefined
 
63
 *                              value
 
64
 *      LUT_SET_DEFAULT_VALUES  macro which sets an entry to the default
 
65
 *                              values
 
66
 * data structure names:
 
67
 *      DD_LUT_ENTRY_STR         devPriv data structure def 
 
68
 *      MI_LUT_ENTRY_STR         table entry data structure def 
 
69
 *      PEX_LUT_ENTRY_STR        pex data structure def 
 
70
 * renderer dynamics changes bit:
 
71
 *      LUT_REND_DYN_BIT
 
72
 * table info:
 
73
 *      LUT_START_INDEX          
 
74
 *      LUT_DEFAULT_INDEX        
 
75
 * table info dependent on drawable type (SI only supports one type):
 
76
 *      LUT_0_DEFINABLE_ENTRIES  
 
77
 *      LUT_0_NUM_PREDEFINED     
 
78
 *      LUT_0_PREDEFINED_MIN     
 
79
 *      LUT_0_PREDEFINED_MAX     
 
80
 *
 
81
 * procedure definition flags: 
 
82
 *      define the ones whose definitions you want to use from this file
 
83
 * procedure definition names: 
 
84
 *      define the names of the procedures to use for the lut
 
85
 */
 
86
 
 
87
extern ddpex4rtn miDealWithDynamics();  /* in level4/miDynamics.c */
 
88
 
 
89
/* get pointer to first legal entry in the table */
 
90
#define FIRST_ENTRY( pheader )          \
 
91
        LUT_TABLE_START(pheader)
 
92
 
 
93
#define SET_TABLE_INFO( drawType, pInfo )       \
 
94
        switch(drawType) {                               \
 
95
                case MI_DRAWABLE0:                       \
 
96
                        (pInfo)->definableEntries =      \
 
97
                                LUT_0_DEFINABLE_ENTRIES; \
 
98
                        (pInfo)->numPredefined =         \
 
99
                                LUT_0_NUM_PREDEFINED;    \
 
100
                        (pInfo)->predefinedMin =         \
 
101
                                LUT_0_PREDEFINED_MIN;    \
 
102
                        (pInfo)->predefinedMax =         \
 
103
                                LUT_0_PREDEFINED_MAX;    \
 
104
                break; }
 
105
 
 
106
/* the following procedure definitions are useful for all SI lut types */
 
107
/* replace them in the mi*LUT.c files if these are not appropriate */
 
108
 
 
109
/* don't use special procs for these - use the general ones called
 
110
 * directly by diPEX */
 
111
 
 
112
#ifdef  LUT_USE_FREE
 
113
extern  ddpex43rtn      FreeLUT();
 
114
#define LUT_FREE        FreeLUT
 
115
#endif  /* LUT_USE_FREE */
 
116
 
 
117
#ifdef  LUT_USE_INQ_PREDEF
 
118
extern  ddpex43rtn      InquireLUTPredEntries();
 
119
#define LUT_INQ_PREDEF  InquireLUTPredEntries
 
120
#endif  /* LUT_USE_INQ_PREDEF */
 
121
 
 
122
#ifdef  LUT_USE_INQ_ENTRIES
 
123
extern  ddpex43rtn      InquireLUTEntries();
 
124
#define LUT_INQ_ENTRIES InquireLUTEntries
 
125
#endif  /* LUT_USE_INQ_ENTRIES */
 
126
 
 
127
/*
 
128
        The default entry: uninitialized, non-static, this scratch
 
129
        structure is kept around so that we can fill it with default
 
130
        data and return its address from routines like those made
 
131
        from LUT_INQ_ENTRY_ADDRESS
 
132
 */
 
133
static MI_LUT_ENTRY_STR def_entry;
 
134
 
 
135
 
 
136
 
 
137
#ifdef  LUT_USE_COPY
 
138
ddpex43rtn
 
139
LUT_COPY (pSrcLUT, pDestLUT)
 
140
/* in */
 
141
    diLUTHandle         pSrcLUT;  /* source lookup table */
 
142
    diLUTHandle         pDestLUT; /* destination lookup table */
 
143
/* out */
 
144
{
 
145
    MILUT_DEFINE_HEADER(pSrcLUT, srcHeader);
 
146
    MILUT_DEFINE_HEADER(pDestLUT, destHeader);
 
147
    MI_LUT_ENTRY_STR       *pentry;
 
148
    ddpex43rtn          err;
 
149
    register int        i;
 
150
 
 
151
#ifdef DDTEST
 
152
    ErrorF( "\ncopy src lut %d type %d\n", pSrcLUT->id, pSrcLUT->lutType);
 
153
    ErrorF( "\ncopy dest lut %d type %d\n", pDestLUT->id, pDestLUT->lutType);
 
154
#endif
 
155
 
 
156
    /* set all entries to undefined */
 
157
    pentry = LUT_TABLE_START(destHeader);
 
158
    MILUT_SET_STATUS(pentry, MILUT_ALLOC_ENTS(destHeader), MILUT_UNDEFINED, MI_FALSE);
 
159
 
 
160
    /* copy entries */
 
161
    mibcopy(LUT_TABLE_START(srcHeader),  LUT_TABLE_START(destHeader),
 
162
        sizeof(MI_LUT_ENTRY_STR) * MILUT_ALLOC_ENTS(srcHeader));
 
163
 
 
164
    MILUT_NUM_ENTS(destHeader) = MILUT_NUM_ENTS(srcHeader);
 
165
 
 
166
   err =  destHeader->ops[MILUT_REQUEST_OP(milut_mod_call_back)](pDestLUT,
 
167
         MILUT_START_INDEX(destHeader), MILUT_DEF_ENTS(destHeader), MILUT_COPY_MOD);
 
168
   /* check err here if your call back proc can return an error */
 
169
 
 
170
    return (err);
 
171
}                             
 
172
#endif  /* LUT_USE_COPY */
 
173
 
 
174
#ifdef  LUT_USE_INQ_INFO
 
175
ddpex43rtn
 
176
LUT_INQ_INFO (pDrawable, pLUTinfo)
 
177
/* in */
 
178
    DrawablePtr         pDrawable;/* pointer to example drawable */
 
179
/* out */
 
180
    ddTableInfo        *pLUTinfo; /* table information */
 
181
{
 
182
    ddSHORT             drawtype;
 
183
 
 
184
#ifdef DDTEST
 
185
    ErrorF( "\ninquire info, table type %d \n", LUT_TYPE );
 
186
#endif
 
187
 
 
188
    MI_WHICHDRAW(pDrawable, drawtype);
 
189
    SET_TABLE_INFO( drawtype, pLUTinfo );
 
190
 
 
191
    return (Success);
 
192
}
 
193
#endif  /* LUT_USE_INQ_INFO */
 
194
 
 
195
#ifdef  LUT_USE_INQ_IND
 
196
ddpex43rtn
 
197
LUT_INQ_IND (pLUT, pNumIndices, pBuffer)
 
198
/* in */
 
199
    diLUTHandle         pLUT;     /* lut handle */
 
200
/* out */
 
201
    ddULONG            *pNumIndices;    /* number of indices in list */
 
202
    ddBufferPtr         pBuffer;  /* list of table indices */
 
203
{
 
204
    MILUT_DEFINE_HEADER(pLUT, pheader);
 
205
    register ddUSHORT   macks;  /* number of definable entries */
 
206
    register    ddTableIndex    *pb;
 
207
    MI_LUT_ENTRY_STR            *pentry;
 
208
 
 
209
#ifdef DDTEST
 
210
    ErrorF( "\n inquire indices lut %d type %d\n", pLUT->id, pLUT->lutType);
 
211
#endif
 
212
 
 
213
    PU_CHECK_BUFFER_SIZE(pBuffer,MILUT_NUM_ENTS(pheader) * sizeof(ddTableIndex));
 
214
    *pNumIndices = MILUT_NUM_ENTS(pheader);
 
215
    pBuffer->dataSize = *pNumIndices * sizeof(ddTableIndex);
 
216
    pb = (ddTableIndex *)(pBuffer->pBuf);
 
217
 
 
218
    pentry = FIRST_ENTRY(pheader);
 
219
 
 
220
    for ( macks = MILUT_DEF_ENTS(pheader); 
 
221
        macks > 0; macks--, pentry++ )
 
222
              if (pentry->entry_info.status != MILUT_UNDEFINED) 
 
223
                *pb++ = pentry->entry_info.index;
 
224
 
 
225
    return (Success);
 
226
}
 
227
#endif  /* LUT_USE_INQ_IND */
 
228
 
 
229
#ifdef  LUT_USE_INQ_ENTRY
 
230
ddpex43rtn
 
231
LUT_INQ_ENTRY (pLUT, index,  valueType, pStatus, pBuffer)
 
232
/* in */
 
233
    diLUTHandle         pLUT;     /* lut handle */
 
234
    ddTableIndex        index;    /* index of entry to get */
 
235
    ddUSHORT            valueType;      /* SET or REALIZED */
 
236
/* out */
 
237
    ddUSHORT           *pStatus;  /* entry status */
 
238
    ddBufferPtr         pBuffer;  /* table entry */
 
239
{
 
240
    MILUT_DEFINE_HEADER(pLUT, pheader);
 
241
    MI_LUT_ENTRY_STR            *pentry, *plast;
 
242
    ddPointer                   pb;
 
243
 
 
244
#ifdef DDTEST
 
245
    ErrorF( "\ninquire entry lut %d type %d\n", pLUT->id, pLUT->lutType);
 
246
#endif
 
247
 
 
248
    PU_CHECK_BUFFER_SIZE(pBuffer, sizeof(PEX_LUT_ENTRY_STR)); 
 
249
 
 
250
    pentry = FIRST_ENTRY(pheader);
 
251
    plast = pentry + MILUT_DEF_ENTS(pheader);
 
252
 
 
253
    MILUT_GET_ENTRY(index, pentry, plast);
 
254
 
 
255
    if ((pentry == NULL) || (pentry->entry_info.status == MILUT_UNDEFINED))
 
256
    {
 
257
        *pStatus = PEXDefaultEntry;
 
258
        pentry = FIRST_ENTRY(pheader);
 
259
        MILUT_GET_ENTRY(MILUT_DEFAULT_INDEX(pheader), pentry, plast);
 
260
        if (pentry == NULL)
 
261
        {
 
262
                /* default entry doesn't exist -  get the default values */
 
263
                LUT_SET_DEFAULT_VALUES(&def_entry);
 
264
                pentry = &def_entry;
 
265
        }
 
266
        else if (pentry->entry_info.status == MILUT_UNDEFINED)
 
267
                {
 
268
                /* default entry is undefined - get default values */
 
269
                        LUT_SET_DEFAULT_VALUES(&def_entry);
 
270
                        pentry = &def_entry;
 
271
                }
 
272
    } else
 
273
        *pStatus = PEXDefinedEntry;
 
274
 
 
275
    pb = pBuffer->pBuf;
 
276
 
 
277
    pheader->ops[MILUT_REQUEST_OP(milut_copy_mi_to_pex)](pheader, valueType, pentry, &pb);
 
278
 
 
279
    pBuffer->dataSize = pb - pBuffer->pBuf;
 
280
            
 
281
    return (Success);
 
282
}
 
283
#endif  /* LUT_USE_INQ_ENTRY */
 
284
 
 
285
#ifdef  LUT_USE_SET_ENTRIES
 
286
ddpex43rtn
 
287
LUT_SET_ENTRIES (pLUT, start, numEntries, pEntries)
 
288
/* in */
 
289
    diLUTHandle         pLUT;     /* lut handle */
 
290
    ddTableIndex        start;    /* index of first entry to set */
 
291
    ddUSHORT            numEntries;     /* number of entries to set */
 
292
    ddPointer           pEntries; /* list of entries */
 
293
{
 
294
    MILUT_DEFINE_HEADER(pLUT, pheader);
 
295
    MI_LUT_ENTRY_STR            *pentry, *plast, *psave;
 
296
    PEX_LUT_ENTRY_STR    *psrc;
 
297
     register   int     i;
 
298
    int                 freecount1 = 0, freecount2;
 
299
    ddpex43rtn          err;
 
300
    ddPointer           ps;
 
301
 
 
302
#ifdef DDTEST
 
303
    ErrorF( "\nset entries lut %d type %d\n", pLUT->id, pLUT->lutType);
 
304
#endif
 
305
 
 
306
    psrc = (PEX_LUT_ENTRY_STR *) pEntries;
 
307
    pentry = FIRST_ENTRY(pheader);
 
308
    plast = pentry + MILUT_DEF_ENTS(pheader);
 
309
 
 
310
    /* check for a place to put the entries and check them for errors */
 
311
    /* this is set up to work for tables with contiguous index
 
312
     * values most efficiently. it will work for sparse tables, too
 
313
     */
 
314
    for (i = start; i < (start + numEntries); i++)
 
315
    {
 
316
        /* starting at current pentry, see if entry 'i' is after it */
 
317
        psave = pentry;
 
318
        MILUT_GET_ENTRY(i, pentry, plast);
 
319
 
 
320
        if (!pentry)
 
321
        {
 
322
                /* make sure the entry wasn't before pentry 
 
323
                 * by starting at the beginning and looking until where
 
324
                 * pentry was (psave)
 
325
                 */
 
326
                pentry = FIRST_ENTRY(pheader);
 
327
                MILUT_GET_ENTRY(i, pentry, psave);
 
328
                if (!pentry)
 
329
                {
 
330
                        /* no entry defined with this index 
 
331
                         * put one in by looking for the first
 
332
                         * undefined entry. this has no intelligence
 
333
                         * about it
 
334
                         */
 
335
                        pentry = FIRST_ENTRY(pheader);
 
336
                        plast = pentry + MILUT_DEF_ENTS(pheader);
 
337
                        freecount2 = freecount1;
 
338
                        while ((pentry < plast) &&
 
339
                        ((pentry->entry_info.status != MILUT_UNDEFINED) || freecount2))
 
340
                        {
 
341
                                if (pentry->entry_info.status == MILUT_UNDEFINED)
 
342
                                        freecount2--;
 
343
                                pentry++;
 
344
                        }
 
345
                        if (pentry == plast)
 
346
                                /* couldn't find a place for it */
 
347
                                return(BadAlloc);
 
348
                        else
 
349
                                /* keep count of free places found so far */
 
350
                                freecount1++;
 
351
                }
 
352
        }
 
353
        /* check the entry and increment the source pointer */
 
354
        if ((err = pheader->ops[MILUT_REQUEST_OP(milut_entry_check)](pheader, &psrc)) != Success)
 
355
                return(err);
 
356
    }
 
357
 
 
358
    psrc = (PEX_LUT_ENTRY_STR *) pEntries;
 
359
    for (i = start; i < (start + numEntries); i++) 
 
360
    {
 
361
        /* starting at current pentry, see if entry 'i' is after it */
 
362
        psave = pentry;
 
363
        MILUT_GET_ENTRY(i, pentry, plast);
 
364
 
 
365
        if (!pentry)
 
366
        {
 
367
                /* make sure the entry wasn't before pentry 
 
368
                 * by starting at the beginning and looking until where
 
369
                 * pentry was (psave)
 
370
                 */
 
371
                pentry = FIRST_ENTRY(pheader);
 
372
                MILUT_GET_ENTRY(i, pentry, psave);
 
373
                if (!pentry)
 
374
                {
 
375
                        /* no entry defined with this index 
 
376
                         * put one in by looking for the first
 
377
                         * undefined entry. this has no intelligence
 
378
                         * about it
 
379
                         */
 
380
                        pentry = FIRST_ENTRY(pheader);
 
381
                        plast = pentry + MILUT_DEF_ENTS(pheader);
 
382
                        while ((pentry < plast) &&
 
383
                                (pentry->entry_info.status != MILUT_UNDEFINED))
 
384
                                        pentry++;
 
385
                        if (pentry == plast)
 
386
                                /* this shouldn't happen since it was
 
387
                                 * checked above, but just in case..
 
388
                                 * this is where one of those ASSURE
 
389
                                 * tests can be useful
 
390
                                 */
 
391
                                return(BadAlloc);
 
392
                }
 
393
        }
 
394
 
 
395
        if (pentry->entry_info.status == MILUT_UNDEFINED)
 
396
                MILUT_NUM_ENTS(pheader)++;
 
397
        pentry->entry_info.status = MILUT_DEFINED;
 
398
        pentry->entry_info.index = i;
 
399
 
 
400
        ps = (ddPointer)psrc;
 
401
        pheader->ops[MILUT_REQUEST_OP(milut_copy_pex_to_mi)](pheader, &ps, pentry);
 
402
 
 
403
        psrc = (PEX_LUT_ENTRY_STR *)ps;
 
404
    }
 
405
 
 
406
   err =  pheader->ops[MILUT_REQUEST_OP(milut_mod_call_back)](pLUT, 
 
407
         start, numEntries, MILUT_SET_MOD);
 
408
 
 
409
   /* check err here if your call back proc can return an error */
 
410
 
 
411
    return (err);
 
412
}
 
413
#endif  /* LUT_USE_SET_ENTRIES */
 
414
 
 
415
#ifdef  LUT_USE_DEL_ENTRIES
 
416
ddpex43rtn
 
417
LUT_DEL_ENTRIES (pLUT, start, numEntries)
 
418
/* in */
 
419
    diLUTHandle         pLUT;     /* lut handle */
 
420
    ddUSHORT            start;    /* index of first entry to delete */
 
421
    ddUSHORT            numEntries;     /* number of entries in range */
 
422
/* out */
 
423
{
 
424
    MILUT_DEFINE_HEADER(pLUT, pheader);
 
425
    MI_LUT_ENTRY_STR    *pentry, *plast, *psave;
 
426
    ddpex43rtn          err;
 
427
 
 
428
#ifdef DDTEST
 
429
    ErrorF( "\ndelete entries lut %d type %d\n", pLUT->id, pLUT->lutType);
 
430
#endif
 
431
 
 
432
    pentry = FIRST_ENTRY(pheader);
 
433
    plast = pentry + MILUT_DEF_ENTS(pheader);
 
434
   
 
435
    /* invoke the call back before deleting the entries and changing
 
436
       start and numEntries
 
437
    */
 
438
    err =  pheader->ops[MILUT_REQUEST_OP(milut_mod_call_back)](pLUT,
 
439
         start, numEntries, MILUT_DEL_MOD);
 
440
 
 
441
    /* loop through and set each entry to undefined
 
442
     * this works most efficiently if the entries are stored
 
443
     * in the lut contiguously since MILUT_GET_ENTRY starts
 
444
     * where pentry points then searches forward colour_approxarly
 
445
     */
 
446
    for (; numEntries > 0; start++, numEntries--)
 
447
    {
 
448
        psave = pentry;
 
449
        MILUT_GET_ENTRY(start, pentry, plast);
 
450
 
 
451
        if (!pentry)
 
452
        {
 
453
                /* make sure the entry wasn't before pentry */
 
454
                pentry = FIRST_ENTRY(pheader);
 
455
                MILUT_GET_ENTRY(start, pentry, psave);
 
456
        }
 
457
 
 
458
        if (pentry)
 
459
        {
 
460
                if (pentry->entry_info.status != MILUT_UNDEFINED)
 
461
                {
 
462
                        MILUT_NUM_ENTS(pheader)--;
 
463
                        pentry->entry_info.status = MILUT_UNDEFINED;
 
464
                }
 
465
        }
 
466
        else
 
467
                pentry = psave;
 
468
    }
 
469
 
 
470
   /* check err here if your call back proc can return an error */
 
471
 
 
472
    return (err);
 
473
}
 
474
#endif  /* LUT_USE_DEL_ENTRIES */
 
475
 
 
476
#ifdef  LUT_USE_INQ_ENTRY_ADDRESS
 
477
ddpex43rtn
 
478
LUT_INQ_ENTRY_ADDRESS (LUTtype, pLUT, index,  pStatus, ppEntry)
 
479
/* in */
 
480
    ddUSHORT            LUTtype;  /* lookup table type use this if pLUT is NULL */
 
481
    diLUTHandle         pLUT;     /* lut handle */
 
482
    ddTableIndex        index;    /* index of entry to get */
 
483
/* out */
 
484
    ddUSHORT           *pStatus;  /* entry status */
 
485
    ddPointer         *ppEntry;  /* table entry */
 
486
{
 
487
    miLUTHeader         *pheader;
 
488
    MI_LUT_ENTRY_STR    *pentry, *plast;
 
489
 
 
490
#ifdef DDTEST
 
491
    ErrorF( "\ninquire entry address  lut type %d\n", LUTtype);
 
492
#endif
 
493
 
 
494
    pentry = NULL;                      
 
495
 
 
496
    if (!pLUT) 
 
497
    {
 
498
        /* get the default values */
 
499
        LUT_SET_DEFAULT_VALUES(&def_entry);
 
500
        *ppEntry = (ddPointer)&def_entry;               
 
501
        return (Success);
 
502
    }
 
503
 
 
504
    pheader = MILUT_HEADER(pLUT);
 
505
    pentry = FIRST_ENTRY(pheader);
 
506
    plast = pentry + MILUT_DEF_ENTS(pheader);
 
507
 
 
508
    MILUT_GET_ENTRY(index, pentry, plast);
 
509
    if ((pentry == NULL) || (pentry->entry_info.status == MILUT_UNDEFINED))
 
510
    {
 
511
        /* get the default entry */
 
512
        *pStatus = PEXDefaultEntry;
 
513
        pentry = FIRST_ENTRY(pheader);
 
514
        MILUT_GET_ENTRY(MILUT_DEFAULT_INDEX(pheader), pentry, plast);
 
515
        if (pentry == NULL)
 
516
        {
 
517
                /* default entry doesn't exist -  get the default values */
 
518
                LUT_SET_DEFAULT_VALUES(&def_entry);
 
519
                *ppEntry = (ddPointer)&def_entry;
 
520
        }
 
521
        else if (pentry->entry_info.status == MILUT_UNDEFINED)
 
522
                {
 
523
                /* default entry is undefined - get default values */
 
524
                        LUT_SET_DEFAULT_VALUES(&def_entry);
 
525
                        *ppEntry = (ddPointer)&def_entry;
 
526
                }
 
527
                else            /* the default entry is good */
 
528
                        *ppEntry = (ddPointer)pentry;
 
529
    } else      /* the entry was found and is defined */
 
530
    {
 
531
        *pStatus = PEXDefinedEntry;
 
532
        *ppEntry = (ddPointer)pentry;
 
533
    }
 
534
 
 
535
    return (Success);
 
536
}
 
537
#endif  /* LUT_USE_INQ_ENTRY_ADDRESS */
 
538
 
 
539
#ifdef  LUT_USE_MOD_CALL_BACK
 
540
ddpex43rtn
 
541
LUT_MOD_CALL_BACK(pLUT, start, numEntries, mod)
 
542
    diLUTHandle         pLUT;
 
543
    ddTableIndex        start;    /* index of first entry to set */
 
544
    ddUSHORT            numEntries;     /* number of entries to set */
 
545
    ddUSHORT            mod;    /* modification: copy, set, delete */
 
546
{
 
547
        MILUT_DEFINE_HEADER(pLUT, pheader);
 
548
        register int    i;
 
549
        ddRendererPtr   *pprend;
 
550
        diWKSHandle     *phandle;
 
551
        miWksPtr        pwks;
 
552
        ddpex43rtn      err;
 
553
 
 
554
        /* set change flags in renderer so ValidateRenderer will
 
555
         * know to update the ddContext with changes
 
556
         * add to here and calls to hardware, etc. to realize 
 
557
         * modifications 
 
558
         */
 
559
        pprend = (ddRendererPtr *)pheader->rendRefList->pList;
 
560
        for (i=0; i<pheader->rendRefList->numObj; i++, pprend++) 
 
561
                (*pprend)->tablesChanges |= LUT_REND_DYN_BIT;   
 
562
 
 
563
        /* for view luts: this wks list only identifies the wks for 
 
564
         * which this is the current view.  The wks is not included
 
565
         * in the list of the requested view lut
 
566
         */
 
567
        if (pheader->wksRefList->numObj) 
 
568
        {
 
569
                phandle = (diWKSHandle *)pheader->wksRefList->pList;
 
570
                for (i=0; i<pheader->wksRefList->numObj; i++, phandle++) 
 
571
                {
 
572
                        pwks = (miWksPtr)((*phandle)->deviceData);
 
573
                        pwks->pRend->tablesChanges |= LUT_REND_DYN_BIT;
 
574
                }
 
575
        }
 
576
   
 
577
       err = Success;
 
578
 
 
579
#ifdef  DYNAMIC
 
580
       if (pheader->wksRefList->numObj)
 
581
               err = miDealWithDynamics( DYNAMIC, pheader->wksRefList );
 
582
#endif  /* DYNAMIC */
 
583
 
 
584
        return( err );
 
585
}
 
586
#endif  /* LUT_USE_MOD_CALL_BACK */
 
587
 
 
588
 
 
589
#ifdef  LUT_USE_CREATE
 
590
ddpex43rtn
 
591
LUT_CREATE (pLUT, pheader)
 
592
/* in */
 
593
    diLUTHandle         pLUT;     /* lut handle */
 
594
    miLUTHeader         *pheader; /* lut header */
 
595
/* out */
 
596
{
 
597
    register int        i;
 
598
    MI_LUT_ENTRY_STR    *pentry;
 
599
    DD_LUT_ENTRY_STR    *pdeentry;
 
600
 
 
601
#ifdef DDTEST
 
602
    ErrorF( "\ncreate lut %d type %d\n", pLUT->id, pLUT->lutType);
 
603
#endif
 
604
 
 
605
    MILUT_START_INDEX(pheader) = LUT_START_INDEX;
 
606
    MILUT_DEFAULT_INDEX(pheader) = LUT_DEFAULT_INDEX;
 
607
    MILUT_NUM_ENTS(pheader) = 0;
 
608
    SET_TABLE_INFO( pheader->drawType, &(pheader->tableInfo) );
 
609
 
 
610
    if (MILUT_ALLOC_ENTS(pheader) == 0)
 
611
    {
 
612
      LUT_TABLE_START(pheader) = NULL;
 
613
    }
 
614
    else if ( (LUT_TABLE_START(pheader) = (MI_LUT_ENTRY_STR *)
 
615
                xalloc(MILUT_ALLOC_ENTS(pheader) * sizeof(MI_LUT_ENTRY_STR)) ) 
 
616
                == NULL)
 
617
    {
 
618
        MILUT_DESTROY_HEADER(pheader);
 
619
        return(BadAlloc);
 
620
    }
 
621
 
 
622
    pentry = LUT_TABLE_START(pheader);
 
623
    MILUT_SET_STATUS(pentry, MILUT_ALLOC_ENTS(pheader), MILUT_UNDEFINED, MI_TRUE);
 
624
 
 
625
    /* if there are predefined entries, put them in */
 
626
    if (MILUT_PRENUM(pheader))
 
627
    {
 
628
        pentry = LUT_TABLE_START(pheader) + MILUT_PREMIN(pheader);
 
629
        pdeentry = &(LUT_PDE_ENTRIES);
 
630
 
 
631
        for (i=MILUT_PREMIN(pheader); 
 
632
                i<=MILUT_PREMAX(pheader); i++, pentry++, pdeentry++) 
 
633
        {
 
634
                pentry->entry_info.status = MILUT_PREDEFINED;
 
635
                pentry->entry_info.index = i;
 
636
                LUT_SET_PDE_ENTRY(pentry, pdeentry);
 
637
                pheader->numDefined++;
 
638
        }
 
639
    }
 
640
 
 
641
    pheader->ops[MILUT_REQUEST_OP(PEX_CreateLookupTable)] = LUT_CREATE;
 
642
    pheader->ops[MILUT_REQUEST_OP(PEX_CopyLookupTable)] = LUT_COPY;
 
643
    pheader->ops[MILUT_REQUEST_OP(PEX_FreeLookupTable)] = LUT_FREE;
 
644
    pheader->ops[MILUT_REQUEST_OP(PEX_GetTableInfo)] = LUT_INQ_INFO;
 
645
    pheader->ops[MILUT_REQUEST_OP(PEX_GetPredefinedEntries)] = LUT_INQ_PREDEF;
 
646
    pheader->ops[MILUT_REQUEST_OP(PEX_GetDefinedIndices)] = LUT_INQ_IND;
 
647
    pheader->ops[MILUT_REQUEST_OP(PEX_GetTableEntry)] = LUT_INQ_ENTRY;
 
648
    pheader->ops[MILUT_REQUEST_OP(PEX_GetTableEntries)] = LUT_INQ_ENTRIES;
 
649
    pheader->ops[MILUT_REQUEST_OP(PEX_SetTableEntries)] = LUT_SET_ENTRIES;
 
650
    pheader->ops[MILUT_REQUEST_OP(PEX_DeleteTableEntries)] = LUT_DEL_ENTRIES;
 
651
    pheader->ops[MILUT_REQUEST_OP(milut_InquireEntryAddress)] = LUT_INQ_ENTRY_ADDRESS;
 
652
    pheader->ops[MILUT_REQUEST_OP(milut_entry_check)] = LUT_ENTRY_CHECK;
 
653
    pheader->ops[MILUT_REQUEST_OP(milut_copy_pex_to_mi)] = LUT_COPY_PEX_MI;
 
654
    pheader->ops[MILUT_REQUEST_OP(milut_copy_mi_to_pex)] = LUT_COPY_MI_PEX;
 
655
    pheader->ops[MILUT_REQUEST_OP(milut_mod_call_back)] = LUT_MOD_CALL_BACK;
 
656
 
 
657
    pLUT->deviceData = (ddPointer) pheader;
 
658
    return (Success);
 
659
}
 
660
#endif  /* LUT_USE_CREATE */
 
661
 
 
662
#endif  /* MILUT_PROCS_CI */