diff options
author | Ton Voon <ton.voon@opsera.com> | 2010-06-17 10:16:43 +0100 |
---|---|---|
committer | tonvoon <ton.voon@opsera.com> | 2010-06-23 13:30:34 +0000 |
commit | 18f6835edaf7d640a2c9e476cb1babdbdadbfd9b (patch) | |
tree | ae11f40e48dc34658445c99012726f32bfb45c56 /gl/sha1.h | |
parent | f61412478ceb7c821793c8356b936f64066508bf (diff) | |
download | monitoring-plugins-18f6835edaf7d640a2c9e476cb1babdbdadbfd9b.tar.gz |
Added state retention APIs. Implemented for check_snmp with --rate option.
See http://nagiosplugin.org/c-api-private for more details on the API.
Also updated check_snmp -l option to change the perfdata label.
Diffstat (limited to 'gl/sha1.h')
-rw-r--r-- | gl/sha1.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/gl/sha1.h b/gl/sha1.h new file mode 100644 index 00000000..de209b28 --- /dev/null +++ b/gl/sha1.h | |||
@@ -0,0 +1,92 @@ | |||
1 | /* Declarations of functions and data types used for SHA1 sum | ||
2 | library functions. | ||
3 | Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008, 2009, 2010 Free Software | ||
4 | Foundation, Inc. | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms of the GNU General Public License as published by the | ||
8 | Free Software Foundation; either version 3, or (at your option) any | ||
9 | later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; if not, write to the Free Software Foundation, | ||
18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
19 | |||
20 | #ifndef SHA1_H | ||
21 | # define SHA1_H 1 | ||
22 | |||
23 | # include <stdio.h> | ||
24 | # include <stdint.h> | ||
25 | |||
26 | # ifdef __cplusplus | ||
27 | extern "C" { | ||
28 | # endif | ||
29 | |||
30 | #define SHA1_DIGEST_SIZE 20 | ||
31 | |||
32 | /* Structure to save state of computation between the single steps. */ | ||
33 | struct sha1_ctx | ||
34 | { | ||
35 | uint32_t A; | ||
36 | uint32_t B; | ||
37 | uint32_t C; | ||
38 | uint32_t D; | ||
39 | uint32_t E; | ||
40 | |||
41 | uint32_t total[2]; | ||
42 | uint32_t buflen; | ||
43 | uint32_t buffer[32]; | ||
44 | }; | ||
45 | |||
46 | |||
47 | /* Initialize structure containing state of computation. */ | ||
48 | extern void sha1_init_ctx (struct sha1_ctx *ctx); | ||
49 | |||
50 | /* Starting with the result of former calls of this function (or the | ||
51 | initialization function update the context for the next LEN bytes | ||
52 | starting at BUFFER. | ||
53 | It is necessary that LEN is a multiple of 64!!! */ | ||
54 | extern void sha1_process_block (const void *buffer, size_t len, | ||
55 | struct sha1_ctx *ctx); | ||
56 | |||
57 | /* Starting with the result of former calls of this function (or the | ||
58 | initialization function update the context for the next LEN bytes | ||
59 | starting at BUFFER. | ||
60 | It is NOT required that LEN is a multiple of 64. */ | ||
61 | extern void sha1_process_bytes (const void *buffer, size_t len, | ||
62 | struct sha1_ctx *ctx); | ||
63 | |||
64 | /* Process the remaining bytes in the buffer and put result from CTX | ||
65 | in first 20 bytes following RESBUF. The result is always in little | ||
66 | endian byte order, so that a byte-wise output yields to the wanted | ||
67 | ASCII representation of the message digest. */ | ||
68 | extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); | ||
69 | |||
70 | |||
71 | /* Put result from CTX in first 20 bytes following RESBUF. The result is | ||
72 | always in little endian byte order, so that a byte-wise output yields | ||
73 | to the wanted ASCII representation of the message digest. */ | ||
74 | extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); | ||
75 | |||
76 | |||
77 | /* Compute SHA1 message digest for bytes read from STREAM. The | ||
78 | resulting message digest number will be written into the 20 bytes | ||
79 | beginning at RESBLOCK. */ | ||
80 | extern int sha1_stream (FILE *stream, void *resblock); | ||
81 | |||
82 | /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The | ||
83 | result is always in little endian byte order, so that a byte-wise | ||
84 | output yields to the wanted ASCII representation of the message | ||
85 | digest. */ | ||
86 | extern void *sha1_buffer (const char *buffer, size_t len, void *resblock); | ||
87 | |||
88 | # ifdef __cplusplus | ||
89 | } | ||
90 | # endif | ||
91 | |||
92 | #endif | ||