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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/XIE/dixie/process/pgeom.c

  • 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: pgeom.c,v 1.4 2001/02/09 02:04:22 xorgcvs Exp $ */
 
2
/**** module pgeom.c ****/
 
3
/******************************************************************************
 
4
 
 
5
Copyright 1993, 1994, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 
 
27
 
 
28
                                NOTICE
 
29
                              
 
30
This software is being provided by AGE Logic, Inc. under the
 
31
following license.  By obtaining, using and/or copying this software,
 
32
you agree that you have read, understood, and will comply with these
 
33
terms and conditions:
 
34
 
 
35
     Permission to use, copy, modify, distribute and sell this
 
36
     software and its documentation for any purpose and without
 
37
     fee or royalty and to grant others any or all rights granted
 
38
     herein is hereby granted, provided that you agree to comply
 
39
     with the following copyright notice and statements, including
 
40
     the disclaimer, and that the same appears on all copies and
 
41
     derivative works of the software and documentation you make.
 
42
     
 
43
     "Copyright 1993, 1994 by AGE Logic, Inc."
 
44
     
 
45
     THIS SOFTWARE IS PROVIDED "AS IS".  AGE LOGIC MAKES NO
 
46
     REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By way of
 
47
     example, but not limitation, AGE LOGIC MAKE NO
 
48
     REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
 
49
     FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
 
50
     INFRINGE THIRD-PARTY PROPRIETARY RIGHTS.  AGE LOGIC 
 
51
     SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE.  IN NO
 
52
     EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
 
53
     INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
 
54
     OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
 
55
     ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
 
56
     BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
 
57
     HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
 
58
     DAMAGES.
 
59
    
 
60
     The name of AGE Logic, Inc. may not be used in
 
61
     advertising or publicity pertaining to this software without
 
62
     specific, written prior permission from AGE Logic.
 
63
 
 
64
     Title to this software shall at all times remain with AGE
 
65
     Logic, Inc.
 
66
*****************************************************************************
 
67
  
 
68
        pgeom.c -- DIXIE routines for managing the Geometry element
 
69
  
 
70
        Ben Fahy -- AGE Logic, Inc. June 1993
 
71
  
 
72
*****************************************************************************/
 
73
/* $XFree86: xc/programs/Xserver/XIE/dixie/process/pgeom.c,v 3.6 2001/12/14 19:58:05 dawes Exp $ */
 
74
 
 
75
#define _XIEC_PGEOM
 
76
 
 
77
/*
 
78
 *  Include files
 
79
 */
 
80
  /*
 
81
   *  Core X Includes
 
82
   */
 
83
#define NEED_EVENTS
 
84
#include <X.h>
 
85
#include <Xproto.h>
 
86
  /*
 
87
   *  XIE Includes
 
88
   */
 
89
#include <dixie_p.h>
 
90
  /*
 
91
   *  Server XIE Includes
 
92
   */
 
93
#include <corex.h>
 
94
#include <error.h>
 
95
#include <macro.h>
 
96
#include <element.h>
 
97
#include <technq.h>
 
98
#include <difloat.h>
 
99
#include <memory.h>
 
100
 
 
101
/*
 
102
 *  routines internal to this module
 
103
 */
 
104
static Bool PrepGeometry(
 
105
                floDefPtr flo,
 
106
                peDefPtr ped);
 
107
static Bool CopyGeomNoParams(TECHNQ_COPY_ARGS);
 
108
 
 
109
/*
 
110
 * dixie entry points
 
111
 */
 
112
static diElemVecRec pGeometryVec = {
 
113
    PrepGeometry                /* prepare for analysis and execution   */
 
114
    };
 
115
 
 
116
/*------------------------------------------------------------------------
 
117
----------------------- routine: make a convolution element --------------
 
118
------------------------------------------------------------------------*/
 
119
peDefPtr MakeGeometry(floDefPtr flo, xieTypPhototag tag, xieFlo *pe)
 
120
{
 
121
  int inputs;
 
122
  peDefPtr ped;
 
123
  inFloPtr inFlo;
 
124
  pGeomDefPtr pvt;
 
125
  xieTypFloat *kptr;
 
126
  int i;
 
127
  ELEMENT(xieFloGeometry);
 
128
  ELEMENT_AT_LEAST_SIZE(xieFloGeometry);
 
129
  ELEMENT_NEEDS_1_INPUT(src);
 
130
  inputs = 1;
 
131
 
 
132
 
 
133
  if(!(ped = MakePEDef(inputs, (CARD32)stuff->elemLength<<2,
 
134
                               sizeof(pGeomDefRec))))
 
135
    FloAllocError(flo, tag, xieElemGeometry, return(NULL));
 
136
 
 
137
  ped->diVec         = &pGeometryVec;
 
138
  ped->phototag      = tag;
 
139
  ped->flags.process = TRUE;
 
140
  raw = (xieFloGeometry *)ped->elemRaw;
 
141
  /*
 
142
   * copy the client element parameters (swap if necessary)
 
143
   */
 
144
  if( flo->reqClient->swapped ) {
 
145
    raw->elemType   = stuff->elemType;
 
146
    raw->elemLength = stuff->elemLength;
 
147
    cpswaps(stuff->src, raw->src);
 
148
    raw->bandMask = stuff->bandMask;
 
149
    cpswapl(stuff->width, raw->width);
 
150
    cpswapl(stuff->height, raw->height);
 
151
    cpswaps(stuff->sample, raw->sample);
 
152
    cpswaps(stuff->lenParams, raw->lenParams);
 
153
  }
 
154
  else
 
155
    memcpy((char *)raw, (char *)stuff, sizeof(xieFloGeometry));
 
156
 
 
157
  /* Copy over and convert the floating point stuff */
 
158
  kptr = (xieTypFloat *)&stuff->a;
 
159
  pvt = (pGeomDefPtr)ped->elemPvt;
 
160
 
 
161
  if (flo->reqClient->swapped) {
 
162
          for (i = 0; i < 6; ++kptr, ++i)
 
163
                pvt->coeffs[i] = ConvertFromIEEE(lswapl(*kptr));
 
164
          for (i = 0; i < xieValMaxBands; ++kptr, ++i)
 
165
                pvt->constant[i] = ConvertFromIEEE(lswapl(*kptr));
 
166
  } else {
 
167
          for (i = 0; i < 6; i++) 
 
168
                pvt->coeffs[i] = ConvertFromIEEE(*kptr++);
 
169
          for (i = 0; i < xieValMaxBands; i++) 
 
170
                pvt->constant[i] = ConvertFromIEEE(*kptr++);
 
171
  }
 
172
  /*
 
173
   * copy technique data (if any) 
 
174
   */
 
175
  if(!(ped->techVec = FindTechnique(xieValGeometry, raw->sample)) ||
 
176
     !(ped->techVec->copyfnc(flo, ped,  &stuff[1], &raw[1], raw->lenParams,
 
177
                                        raw->sample == xieValDefault))) 
 
178
    TechniqueError(flo,ped,xieValGeometry,raw->sample,raw->lenParams,
 
179
                   return(ped));
 
180
 
 
181
  /*
 
182
   * assign phototags to inFlos
 
183
   */
 
184
  inFlo = ped->inFloLst;
 
185
  inFlo[SRCtag].srcTag = raw->src;
 
186
  
 
187
  return(ped);
 
188
}                               /* end MakeGeometry */
 
189
 
 
190
/*------------------------------------------------------------------------
 
191
----------- routine: copy routine for NearestNeighbor technique  ---------
 
192
------------------------------------------------------------------------*/
 
193
 
 
194
#undef  sparms
 
195
#define sparms ((xieTecGeomNearestNeighbor *)sParms)
 
196
#undef  rparms
 
197
#define rparms ((xieTecGeomNearestNeighbor *)rParms)
 
198
 
 
199
Bool CopyGeomNearestNeighbor(TECHNQ_COPY_ARGS)
 
200
{
 
201
     pTecGeomNearestNeighborDefPtr pvt;
 
202
 
 
203
     VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, isDefault);
 
204
 
 
205
     if (!(ped->techPvt = XieMalloc(sizeof(pTecGeomNearestNeighborDefRec))))
 
206
             FloAllocError(flo, ped->phototag, xieElemGeometry, return(TRUE));
 
207
 
 
208
     pvt = (pTecGeomNearestNeighborDefPtr)ped->techPvt;
 
209
 
 
210
    /*
 
211
     *  Nearest Neighbor can be called with no parameters
 
212
     */
 
213
     if (isDefault)
 
214
         pvt->modify = xieValFavorUp;
 
215
     else
 
216
         pvt->modify = sparms->modify;
 
217
 
 
218
     return (TRUE);
 
219
}
 
220
 
 
221
#if XIE_FULL
 
222
/*------------------------------------------------------------------------
 
223
------ routine: copy routine for bilinear interpolation technique --------
 
224
------------------------------------------------------------------------*/
 
225
Bool CopyGeomBilinearInterp(TECHNQ_COPY_ARGS)
 
226
{
 
227
     VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, isDefault);
 
228
 
 
229
     return( CopyGeomNoParams(flo, ped, sparms, rparms, tsize, isDefault) );
 
230
}
 
231
/*------------------------------------------------------------------------
 
232
------ routine: copy routine for gaussian interpolation technique --------
 
233
------------------------------------------------------------------------*/
 
234
 
 
235
#undef  sparms
 
236
#define sparms ((xieTecGeomGaussian *)sParms)
 
237
#undef  rparms
 
238
#define rparms ((xieTecGeomGaussian *)rParms)
 
239
 
 
240
Bool CopyGeomGaussian(TECHNQ_COPY_ARGS)
 
241
{
 
242
     pTecGeomGaussianDefPtr pvt;
 
243
 
 
244
     VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, isDefault);
 
245
 
 
246
     if (!(ped->techPvt=XieMalloc(sizeof(pTecGeomGaussianDefRec))))
 
247
             FloAllocError(flo, ped->phototag, xieElemGeometry, return(TRUE));
 
248
 
 
249
     pvt = (pTecGeomGaussianDefPtr)ped->techPvt;
 
250
 
 
251
      if( flo->reqClient->swapped ) {
 
252
             pvt->sigma     = ConvertFromIEEE(lswapl(sparms->sigma));
 
253
             pvt->normalize = ConvertFromIEEE(lswapl(sparms->normalize));
 
254
      } else {
 
255
             pvt->sigma     = ConvertFromIEEE(sparms->sigma);
 
256
             pvt->normalize = ConvertFromIEEE(sparms->normalize);
 
257
      }
 
258
      pvt->radius = sparms->radius;
 
259
      pvt->simple = sparms->simple;
 
260
 
 
261
     if (pvt->radius < 1)
 
262
        return(FALSE);          
 
263
 
 
264
     if (pvt->sigma == 0.0)
 
265
        return(FALSE);          /* musn't divide by zero, deary */
 
266
 
 
267
     if (pvt->normalize <= 0.0)
 
268
        return(FALSE);          /* don't want to bother clipping pixels < 0 */
 
269
 
 
270
     return (TRUE);
 
271
}
 
272
#endif
 
273
 
 
274
/*------------------------------------------------------------------------
 
275
------ routine: copy routine for antialias technique --------
 
276
------------------------------------------------------------------------*/
 
277
 
 
278
Bool CopyGeomAntiAlias(TECHNQ_COPY_ARGS)
 
279
{
 
280
     VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, isDefault);
 
281
 
 
282
     return( CopyGeomNoParams(flo, ped, sparms, rparms, tsize, isDefault) );
 
283
}
 
284
 
 
285
/*------------------------------------------------------------------------
 
286
------------ routine: copy routine for techniques with no params  --------
 
287
------------------------------------------------------------------------*/
 
288
 
 
289
#undef  sparms
 
290
#undef  rparms
 
291
 
 
292
static Bool CopyGeomNoParams(TECHNQ_COPY_ARGS)
 
293
{
 
294
  return(tsize == 0);
 
295
}
 
296
 
 
297
/*------------------------------------------------------------------------
 
298
---------------- routine: prepare for analysis and execution -------------
 
299
------------------------------------------------------------------------*/
 
300
static Bool PrepGeometry(floDefPtr flo, peDefPtr ped)
 
301
{
 
302
  xieFloGeometry *raw = (xieFloGeometry *)ped->elemRaw;
 
303
  inFloPtr  in = &ped->inFloLst[SRCtag];
 
304
  outFloPtr src = &in->srcDef->outFlo;
 
305
  outFloPtr dst = &ped->outFlo;
 
306
  pGeomDefPtr pvt = (pGeomDefPtr)ped->elemPvt;
 
307
  CARD32 b, bits;
 
308
 
 
309
  /* grab a copy of the input attributes and propagate them to our output */
 
310
  dst->bands = in->bands = src->bands;
 
311
 
 
312
  for(b = 0; b < dst->bands; b++) {
 
313
        if (IsntCanonic(src->format[b].class))
 
314
                MatchError(flo, ped, return(FALSE));
 
315
 
 
316
        dst->format[b] = in->format[b] = src->format[b];
 
317
        pvt->do_band[b] = (dst->bands==1)? 1 : raw->bandMask & (1<<b);
 
318
        if (pvt->do_band[b]) {
 
319
                dst->format[b].width  = raw->width;
 
320
                dst->format[b].height = raw->height;
 
321
        }
 
322
        bits = dst->format[b].width * dst->format[b].stride;
 
323
        dst->format[b].pitch = bits + Align(bits,PITCH_MOD);
 
324
  }
 
325
 
 
326
  if(!(ped->techVec->prepfnc(flo, ped, raw, &raw[1]))) {
 
327
    TechniqueError(flo,ped,xieValGeometry,raw->sample,raw->lenParams,
 
328
                   return(FALSE));
 
329
  }
 
330
 
 
331
  return( TRUE );
 
332
}                               /* end PrepGeometry */
 
333
 
 
334
/*------------------------------------------------------------------------
 
335
---------------- routine: prep routine for nearest neighbor --------------
 
336
------------------------------------------------------------------------*/
 
337
Bool PrepGeomNearestNeighbor(
 
338
     floDefPtr  flo,
 
339
     peDefPtr   ped,
 
340
     xieFloGeometry *raw,
 
341
     pointer tec)
 
342
{
 
343
  return(TRUE);
 
344
}
 
345
 
 
346
#if XIE_FULL
 
347
/*------------------------------------------------------------------------
 
348
---------- routine: prep routine for bilinear interpolation --------------
 
349
------------------------------------------------------------------------*/
 
350
Bool PrepGeomBilinearInterp(
 
351
     floDefPtr  flo,
 
352
     peDefPtr   ped,
 
353
     xieFloGeometry *raw,
 
354
     pointer tec)
 
355
{
 
356
  return(TRUE);
 
357
}
 
358
/*------------------------------------------------------------------------
 
359
---------- routine: prep routine for gaussian ----------------------------
 
360
------------------------------------------------------------------------*/
 
361
Bool PrepGeomGaussian(
 
362
     floDefPtr  flo,
 
363
     peDefPtr   ped,
 
364
     xieFloGeometry *raw,
 
365
     pointer tec)
 
366
{
 
367
  return(TRUE);
 
368
}
 
369
#endif
 
370
 
 
371
/*------------------------------------------------------------------------
 
372
---------- routine: prep routine for antialias ---------------------------
 
373
------------------------------------------------------------------------*/
 
374
Bool PrepGeomAntiAlias(
 
375
     floDefPtr  flo,
 
376
     peDefPtr   ped,
 
377
     xieFloGeometry *raw,
 
378
     pointer tec)
 
379
{
 
380
  return(TRUE);
 
381
}
 
382
 
 
383
/* end module pgeom.c */