Mercurial > hg > octave-shane > gnulib-hg
annotate lib/md5.h @ 742:cddc2692eef4
Define and use macro, PARAMS, not __P.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Thu, 17 Oct 1996 02:59:09 +0000 |
parents | b4be735c843c |
children | 7ee3d04f9624 |
rev | line source |
---|---|
464 | 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 | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
66 #undef PARAMS |
466
b4be735c843c
(md5_stream): Update prototype.
Jim Meyering <jim@meyering.net>
parents:
464
diff
changeset
|
67 #if defined (__STDC__) && __STDC__ |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
68 # define PARAMS(x) x |
466
b4be735c843c
(md5_stream): Update prototype.
Jim Meyering <jim@meyering.net>
parents:
464
diff
changeset
|
69 #else |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
70 # define PARAMS(x) () |
466
b4be735c843c
(md5_stream): Update prototype.
Jim Meyering <jim@meyering.net>
parents:
464
diff
changeset
|
71 #endif |
b4be735c843c
(md5_stream): Update prototype.
Jim Meyering <jim@meyering.net>
parents:
464
diff
changeset
|
72 |
464 | 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) */ | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
89 void md5_init_ctx PARAMS ((struct md5_ctx *ctx)); |
464 | 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!!! */ | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
95 void md5_process_block PARAMS ((const void *buffer, size_t len, |
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
96 struct md5_ctx *ctx)); |
464 | 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. */ | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
101 void *md5_read_ctx PARAMS ((const struct md5_ctx *ctx, void *resbuf)); |
464 | 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. */ | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
107 int md5_stream PARAMS ((FILE *stream, void *resblock)); |
464 | 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. */ | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
466
diff
changeset
|
113 void *md5_buffer PARAMS ((const char *buffer, size_t len, void *resblock)); |
464 | 114 |
115 #endif |