streamvalidator.h
Go to the documentation of this file.
/* SPDX-FileCopyrightText: 2025 Greenbone AG
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _GVM_UTIL_STREAMVALIDATOR_H
#define _GVM_UTIL_STREAMVALIDATOR_H
#include <stdio.h>
#define GVM_STREAM_VALIDATOR_NO_SIZE ((size_t) - 1)
typedef enum
{
GVM_STREAM_VALIDATOR_INTERNAL_ERROR = -1,
GVM_STREAM_VALIDATOR_OK = 0,
GVM_STREAM_VALIDATOR_DATA_TOO_SHORT = 1,
GVM_STREAM_VALIDATOR_DATA_TOO_LONG,
GVM_STREAM_VALIDATOR_INVALID_HASH_SYNTAX,
GVM_STREAM_VALIDATOR_INVALID_HASH_ALGORITHM,
GVM_STREAM_VALIDATOR_INVALID_HASH_VALUE,
GVM_STREAM_VALIDATOR_HASH_MISMATCH
} gvm_stream_validator_return_t;
typedef struct gvm_stream_validator *gvm_stream_validator_t;
const char *gvm_stream_validator_return_str (gvm_stream_validator_return_t);
gvm_stream_validator_return_t
gvm_stream_validator_new (const char *, gvm_stream_validator_t *);
gvm_stream_validator_return_t
gvm_stream_validator_with_size_new (const char *, size_t,
gvm_stream_validator_t *);
void gvm_stream_validator_rewind (gvm_stream_validator_t);
void gvm_stream_validator_free (gvm_stream_validator_t);
gvm_stream_validator_return_t
gvm_stream_validator_write (gvm_stream_validator_t, const char *, size_t);
gvm_stream_validator_return_t gvm_stream_validator_end (gvm_stream_validator_t);
#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