Greenbone Security Assistant
validator.h
Go to the documentation of this file.
1 /* Copyright (C) 2009-2021 Greenbone Networks GmbH
2  *
3  * SPDX-License-Identifier: AGPL-3.0-or-later
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as
7  * published by the Free Software Foundation, either version 3 of the
8  * License, or (at your option) 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 Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
24 #ifndef _VALIDATOR_H
25 #define _VALIDATOR_H
26 
27 #include <glib.h>
28 
32 typedef GHashTable *validator_t;
33 
38 {
39  gchar *alias_for;
40  gchar *regex;
41  gboolean is_binary;
42 };
43 
47 typedef struct validator_rule validator_rule_t;
48 
51 
52 void
53 gvm_validator_add (validator_t, const char *, const char *);
54 
55 void
57 
58 int
59 gvm_validator_alias (validator_t, const char *, const char *);
60 
61 gchar *
62 gvm_validator_alias_for (validator_t, const char *);
63 
64 int
65 gvm_validate (validator_t, const char *, const char *);
66 
68 
69 #endif /* not _VALIDATOR_H */
A validator rule.
Definition: validator.h:38
gchar * regex
Regular expression.
Definition: validator.h:40
gboolean is_binary
Whether to expect raw byte data, skip UTF-8 checks.
Definition: validator.h:41
gchar * alias_for
Name of the rule for which this is an alias.
Definition: validator.h:39
void gvm_validator_add_binary(validator_t, const char *)
Add or overwrite a validation rule for a binary data param.
Definition: validator.c:128
validator_t gvm_validator_new()
Create a new validator.
Definition: validator.c:101
int gvm_validate(validator_t, const char *, const char *)
Validate a string for a given rule.
Definition: validator.c:196
GHashTable * validator_t
A set of name rule pairs.
Definition: validator.h:32
int gvm_validator_alias(validator_t, const char *, const char *)
Make an alias for a rule name.
Definition: validator.c:144
gchar * gvm_validator_alias_for(validator_t, const char *)
Get the name of the rule for which a rule is an alias.
Definition: validator.c:171
void gvm_validator_add(validator_t, const char *, const char *)
Add or overwrite a validation rule.
Definition: validator.c:115
void gvm_validator_free(validator_t)
Free a validator.
Definition: validator.c:265