Greenbone Vulnerability Management Libraries: util/streamvalidator.h Source File

Greenbone Vulnerability Management Libraries 23.1.1

streamvalidator.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6#ifndef _GVM_UTIL_STREAMVALIDATOR_H
7#define _GVM_UTIL_STREAMVALIDATOR_H
8
9#include <stdio.h>
10
11#define GVM_STREAM_VALIDATOR_NO_SIZE ((size_t) - 1)
12
17
18 typedef enum
19{
21 GVM_STREAM_VALIDATOR_INTERNAL_ERROR = -1,
23 GVM_STREAM_VALIDATOR_OK = 0,
25 GVM_STREAM_VALIDATOR_DATA_TOO_SHORT = 1,
27 GVM_STREAM_VALIDATOR_DATA_TOO_LONG,
29 GVM_STREAM_VALIDATOR_INVALID_HASH_SYNTAX,
31 GVM_STREAM_VALIDATOR_INVALID_HASH_ALGORITHM,
34 GVM_STREAM_VALIDATOR_INVALID_HASH_VALUE,
36 GVM_STREAM_VALIDATOR_HASH_MISMATCH
37} gvm_stream_validator_return_t;
38
42 typedef struct gvm_stream_validator *gvm_stream_validator_t;
43
44const char *gvm_stream_validator_return_str (gvm_stream_validator_return_t);
45
46 gvm_stream_validator_return_t
47 gvm_stream_validator_new (const char *, gvm_stream_validator_t *);
48
49 gvm_stream_validator_return_t
50 gvm_stream_validator_with_size_new (const char *, size_t,
51 gvm_stream_validator_t *);
52
53void gvm_stream_validator_rewind (gvm_stream_validator_t);
54
55void gvm_stream_validator_free (gvm_stream_validator_t);
56
57 gvm_stream_validator_return_t
58 gvm_stream_validator_write (gvm_stream_validator_t, const char *, size_t);
59
60 gvm_stream_validator_return_t gvm_stream_validator_end (gvm_stream_validator_t);
61
62#endif /* not _GVM_UTIL_STREAMVALIDATOR_H */
gvm_stream_validator_return_str
const char * gvm_stream_validator_return_str(gvm_stream_validator_return_t)
Gets a string representation of a gvm_stream_validator_return_t.
Definition streamvalidator.c:44
gvm_stream_validator_end
gvm_stream_validator_return_t gvm_stream_validator_end(gvm_stream_validator_t)
Signal the end of data input into a validator and produce the result of the validation.
Definition streamvalidator.c:260
gvm_stream_validator_free
void gvm_stream_validator_free(gvm_stream_validator_t)
Free a stream validator and all of its fields.
Definition streamvalidator.c:216
gvm_stream_validator_write
gvm_stream_validator_return_t gvm_stream_validator_write(gvm_stream_validator_t, const char *, size_t)
Write data to a validator, updating the hash state and current size.
Definition streamvalidator.c:236
gvm_stream_validator_with_size_new
gvm_stream_validator_return_t gvm_stream_validator_with_size_new(const char *, size_t, gvm_stream_validator_t *)
Allocate and initialize a new data stream validator.
Definition streamvalidator.c:117
gvm_stream_validator_rewind
void gvm_stream_validator_rewind(gvm_stream_validator_t)
Rewind the validation state of a stream validator while keeping the expected hash and data size.
Definition streamvalidator.c:204
gvm_stream_validator_new
gvm_stream_validator_return_t gvm_stream_validator_new(const char *, gvm_stream_validator_t *)
Allocate and initialize a checksum-only stream validator.
Definition streamvalidator.c:87
gvm_stream_validator_t
struct gvm_stream_validator * gvm_stream_validator_t
Pointer to an opaque stream validator data structure.
Definition streamvalidator.h:42
gvm_stream_validator_return_t
gvm_stream_validator_return_t
Definition streamvalidator.h:19
GVM_STREAM_VALIDATOR_INVALID_HASH_ALGORITHM
@ GVM_STREAM_VALIDATOR_INVALID_HASH_ALGORITHM
Definition streamvalidator.h:31
GVM_STREAM_VALIDATOR_HASH_MISMATCH
@ GVM_STREAM_VALIDATOR_HASH_MISMATCH
Definition streamvalidator.h:36
GVM_STREAM_VALIDATOR_DATA_TOO_SHORT
@ GVM_STREAM_VALIDATOR_DATA_TOO_SHORT
Definition streamvalidator.h:25
GVM_STREAM_VALIDATOR_DATA_TOO_LONG
@ GVM_STREAM_VALIDATOR_DATA_TOO_LONG
Definition streamvalidator.h:27
GVM_STREAM_VALIDATOR_INTERNAL_ERROR
@ GVM_STREAM_VALIDATOR_INTERNAL_ERROR
Definition streamvalidator.h:21
GVM_STREAM_VALIDATOR_OK
@ GVM_STREAM_VALIDATOR_OK
Definition streamvalidator.h:23
GVM_STREAM_VALIDATOR_INVALID_HASH_SYNTAX
@ GVM_STREAM_VALIDATOR_INVALID_HASH_SYNTAX
Definition streamvalidator.h:29
GVM_STREAM_VALIDATOR_INVALID_HASH_VALUE
@ GVM_STREAM_VALIDATOR_INVALID_HASH_VALUE
Definition streamvalidator.h:34
gvm_stream_validator
Data stream validator structure.
Definition streamvalidator.c:25