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

« back to all changes in this revision

Viewing changes to unix/xc/lib/Xft1/xftmatrix.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
/*
 
2
 * $XFree86: xc/lib/Xft1/xftmatrix.c,v 1.1.1.1 2002/02/15 01:26:16 keithp Exp $
 
3
 *
 
4
 * Copyright � 2000 Tuomas J. Lukka
 
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, and that the name of Tuomas Lukka not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Tuomas Lukka makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * TUOMAS LUKKA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL TUOMAS LUKKA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
 
 
25
#include <math.h>
 
26
#include <stdlib.h>
 
27
#include <ctype.h>
 
28
#include "xftint.h"
 
29
 
 
30
XftMatrix *
 
31
_XftSaveMatrix (const XftMatrix *mat) 
 
32
{
 
33
    XftMatrix *r;
 
34
    if(!mat) 
 
35
        return 0;
 
36
    r = (XftMatrix *) malloc (sizeof (*r) );
 
37
    if (!r)
 
38
        return 0;
 
39
    *r = *mat;
 
40
    return r;
 
41
}
 
42
 
 
43
int
 
44
XftMatrixEqual (const XftMatrix *mat1, const XftMatrix *mat2)
 
45
{
 
46
    if(mat1 == mat2) return True;
 
47
    if(mat1 == 0 || mat2 == 0) return False;
 
48
    return mat1->xx == mat2->xx && 
 
49
           mat1->xy == mat2->xy &&
 
50
           mat1->yx == mat2->yx &&
 
51
           mat1->yy == mat2->yy;
 
52
}
 
53
 
 
54
void
 
55
XftMatrixMultiply (XftMatrix *result, XftMatrix *a, XftMatrix *b)
 
56
{
 
57
    XftMatrix   r;
 
58
 
 
59
    r.xx = a->xx * b->xx + a->xy * b->yx;
 
60
    r.xy = a->xx * b->xy + a->xy * b->yy;
 
61
    r.yx = a->yx * b->xx + a->yy * b->yx;
 
62
    r.yy = a->yx * b->xy + a->yy * b->yy;
 
63
    *result = r;
 
64
}
 
65
 
 
66
void
 
67
XftMatrixRotate (XftMatrix *m, double c, double s)
 
68
{
 
69
    XftMatrix   r;
 
70
 
 
71
    /*
 
72
     * X Coordinate system is upside down, swap to make
 
73
     * rotations counterclockwise
 
74
     */
 
75
    r.xx = c;
 
76
    r.xy = -s;
 
77
    r.yx = s;
 
78
    r.yy = c;
 
79
    XftMatrixMultiply (m, &r, m);
 
80
}
 
81
 
 
82
void
 
83
XftMatrixScale (XftMatrix *m, double sx, double sy)
 
84
{
 
85
    XftMatrix   r;
 
86
 
 
87
    r.xx = sx;
 
88
    r.xy = 0;
 
89
    r.yx = 0;
 
90
    r.yy = sy;
 
91
    XftMatrixMultiply (m, &r, m);
 
92
}
 
93
 
 
94
void
 
95
XftMatrixShear (XftMatrix *m, double sh, double sv)
 
96
{
 
97
    XftMatrix   r;
 
98
 
 
99
    r.xx = 1;
 
100
    r.xy = sh;
 
101
    r.yx = sv;
 
102
    r.yy = 1;
 
103
    XftMatrixMultiply (m, &r, m);
 
104
}