~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to source/blender/imbuf/intern/md5.h

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* md5.h - Declaration of functions and data types used for MD5 sum
 
2
   computing library functions.
 
3
   Copyright (C) 1995 Free Software Foundation, Inc.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify
 
6
it under the terms of the GNU General Public License as published by
 
7
the Free Software Foundation; either version 2, or (at your option)
 
8
any later version.
 
9
 
 
10
This program is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
GNU General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public License
 
16
along with this program; if not, write to the Free Software
 
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
18
 
 
19
#ifndef _MD5_H
 
20
#define _MD5_H
 
21
 
 
22
#include <stdio.h>
 
23
 
 
24
#if defined HAVE_LIMITS_H || _LIBC
 
25
# include <limits.h>
 
26
#endif
 
27
 
 
28
/* The following contortions are an attempt to use the C preprocessor
 
29
   to determine an unsigned integral type that is 32 bits wide.  An
 
30
   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
 
31
   doing that would require that the configure script compile and *run*
 
32
   the resulting executable.  Locally running cross-compiled executables
 
33
   is usually not possible.  */
 
34
 
 
35
#if defined __STDC__ && __STDC__
 
36
# define UINT_MAX_32_BITS 4294967295U
 
37
#else
 
38
# define UINT_MAX_32_BITS 0xFFFFFFFF
 
39
#endif
 
40
 
 
41
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
 
42
   This should be valid for all systems GNU cares about because
 
43
   that doesn't include 16-bit systems, and only modern systems
 
44
   (that certainly have <limits.h>) have 64+-bit integral types.  */
 
45
 
 
46
#ifndef UINT_MAX
 
47
# define UINT_MAX UINT_MAX_32_BITS
 
48
#endif
 
49
 
 
50
#if UINT_MAX == UINT_MAX_32_BITS
 
51
  typedef unsigned int md5_uint32;
 
52
#else
 
53
# if USHRT_MAX == UINT_MAX_32_BITS
 
54
   typedef unsigned short md5_uint32;
 
55
# else
 
56
#  if ULONG_MAX == UINT_MAX_32_BITS
 
57
    typedef unsigned long md5_uint32;
 
58
#  else
 
59
    /* The following line is intended to evoke an error.
 
60
       Using #error is not portable enough.  */
 
61
    "Cannot determine unsigned 32-bit data type."
 
62
#  endif
 
63
# endif
 
64
#endif
 
65
 
 
66
#undef __P
 
67
#if defined (__STDC__) && __STDC__
 
68
#define __P(x) x
 
69
#else
 
70
#define __P(x) ()
 
71
#endif
 
72
 
 
73
/* Structure to save state of computation between the single steps.  */
 
74
struct md5_ctx
 
75
{
 
76
  md5_uint32 A;
 
77
  md5_uint32 B;
 
78
  md5_uint32 C;
 
79
  md5_uint32 D;
 
80
};
 
81
 
 
82
/*
 
83
 * The following three functions are build up the low level used in
 
84
 * the functions `md5_stream' and `md5_buffer'.
 
85
 */
 
86
 
 
87
/* Initialize structure containing state of computation.
 
88
   (RFC 1321, 3.3: Step 3)  */
 
89
void md5_init_ctx __P ((struct md5_ctx *ctx));
 
90
 
 
91
/* Starting with the result of former calls of this function (or the
 
92
   initialzation function update the context for the next LEN bytes
 
93
   starting at BUFFER.
 
94
   It is necessary that LEN is a multiple of 64!!! */
 
95
void md5_process_block __P ((const void *buffer, size_t len,
 
96
                             struct md5_ctx *ctx));
 
97
 
 
98
/* Put result from CTX in first 16 bytes following RESBUF.  The result is
 
99
   always in little endian byte order, so that a byte-wise output yields
 
100
   to the wanted ASCII representation of the message digest.  */
 
101
void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
 
102
 
 
103
 
 
104
/* Compute MD5 message digest for bytes read from STREAM.  The
 
105
   resulting message digest number will be written into the 16 bytes
 
106
   beginning at RESBLOCK.  */
 
107
int md5_stream __P ((FILE *stream, void *resblock));
 
108
 
 
109
/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
 
110
   result is always in little endian byte order, so that a byte-wise
 
111
   output yields to the wanted ASCII representation of the message
 
112
   digest.  */
 
113
void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
 
114
 
 
115
#endif
 
116