~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to base/smd5.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
2
   All Rights Reserved.
3
 
  
 
3
 
4
4
   This software is provided AS-IS with no warranty, either express or
5
5
   implied.
6
6
 
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: smd5.c 8250 2007-09-25 13:31:24Z giles $ */
 
14
/* $Id$ */
15
15
/* MD5Encode filter */
16
16
#include "memory_.h"
17
17
#include "strimpl.h"
35
35
/* Process a buffer. */
36
36
static int
37
37
s_MD5E_process(stream_state * st, stream_cursor_read * pr,
38
 
               stream_cursor_write * pw, bool last)
 
38
               stream_cursor_write * pw, bool last)
39
39
{
40
40
    stream_MD5E_state *const ss = (stream_MD5E_state *) st;
41
41
    int status = 0;
42
42
 
43
43
    if (pr->ptr < pr->limit) {
44
 
        gs_md5_append(&ss->md5, pr->ptr + 1, pr->limit - pr->ptr);
45
 
        pr->ptr = pr->limit;
 
44
        gs_md5_append(&ss->md5, pr->ptr + 1, pr->limit - pr->ptr);
 
45
        pr->ptr = pr->limit;
46
46
    }
47
47
    if (last) {
48
 
        if (pw->limit - pw->ptr >= 16) {
49
 
            gs_md5_finish(&ss->md5, pw->ptr + 1);
50
 
            pw->ptr += 16;
51
 
            status = EOFC;
52
 
        } else
53
 
            status = 1;
 
48
        if (pw->limit - pw->ptr >= 16) {
 
49
            gs_md5_finish(&ss->md5, pw->ptr + 1);
 
50
            pw->ptr += 16;
 
51
            status = EOFC;
 
52
        } else
 
53
            status = 1;
54
54
    }
55
55
    return status;
56
56
}
67
67
    stream_state *ss = s_alloc_state(mem, s_MD5E_template.stype, "s_MD5E_make_stream");
68
68
 
69
69
    if (ss == NULL || s == NULL)
70
 
        goto err;
 
70
        goto err;
71
71
    ss->template = &s_MD5E_template;
72
72
    if (s_init_filter(s, ss, digest, digest_size, NULL) < 0)
73
73
goto err;
82
82
/* Process a buffer. */
83
83
static int
84
84
s_MD5C_process(stream_state * st, stream_cursor_read * pr,
85
 
               stream_cursor_write * pw, bool last)
 
85
               stream_cursor_write * pw, bool last)
86
86
{
87
87
    stream_MD5E_state *const ss = (stream_MD5E_state *) st;
88
88
    int nr = pr->limit - pr->ptr;
94
94
    pr->ptr += n;
95
95
    pw->ptr += n;
96
96
    if (pw->limit == pw->ptr)
97
 
        return 1;
 
97
        return 1;
98
98
    return 0;
99
99
}
100
100
/* Stream template */
111
111
    byte *buffer = gs_alloc_bytes(mem, buffer_size, "s_MD5E_make_stream(buffer)");
112
112
 
113
113
    if (ss == NULL || s == NULL || buffer == NULL)
114
 
        goto err;
 
114
        goto err;
115
115
    ss->template = &s_MD5C_template;
116
116
    if (s_init_filter(s, ss, buffer, buffer_size, NULL) < 0)
117
 
        goto err;
 
117
        goto err;
118
118
    s->strm = strm;
119
119
    s->close_strm = true;
120
120
    return s;
135
135
    int l = min(16, buf_length), k;
136
136
 
137
137
    if (s->procs.process != s_MD5C_process)
138
 
        return 0; /* Must not happen. */
 
138
        return 0; /* Must not happen. */
139
139
    md5 = ss->md5;
140
140
    gs_md5_finish(&md5, b);
141
141
    memcpy(buf, b, l);
142
142
    for (p = b + l; p < b + sizeof(b); p += l) {
143
 
        for (k = 0; k < l && p + k < b + sizeof(b); k++)
144
 
            buf[k] ^= p[k];
 
143
        for (k = 0; k < l && p + k < b + sizeof(b); k++)
 
144
            buf[k] ^= p[k];
145
145
    }
146
146
    return l;
147
147
}
148
 
 
149