Protos and data structures for Access Rules data sets.
More...
#include <glib.h>
Go to the source code of this file.
Protos and data structures for Access Rules data sets.
This file contains the protos for accessrules.c
The structure for a Access Rule.
The elements of this structure should never be accessed directly. Only the functions corresponding to this module should be used.
A collection of information records corresponding to Access Rules.
The possible types of a rule.
Enumerator |
---|
ALLOW |
allow a corresponding IP
|
REJECT |
reject a corresponding IP
|
Create a XML representation of a Access Rule.
- Parameters
-
r | The Access Rule structure. |
- Returns
- A newly allocated string with multi-line text. The string needs to be freed with g_free().
- Todo:
- Use g_markup_escape here
Get the comment string.
- Parameters
-
r | The Access Rule structure of which the comment should be returned. |
- Returns
- The comment string. Don't free this.
Free memory of a access rules structure.
- Parameters
-
r | The structure to be freed. |
Get the IP string.
- Parameters
-
r | The Access Rule structure of which the IP should be returned. |
- Returns
- The IP string. Don't free this.
Create a new access rule structure filled with the given values.
- Returns
- NULL in case the memory could not be allocated. Else an empty accessrule structure which needs to be released using accessrule_free . The whole struct is initalized with 0's.
Get the rule type.
- Parameters
-
r | The Access Rule structure of which the rule should be returned. |
- Returns
- The rule type.
int accessrule_set_comment |
( |
accessrule_t * |
r, |
|
|
const gchar * |
comment |
|
) |
| |
Set the comment of a Access Rule.
- Parameters
-
r | The Access Rule structure. |
comment | The comment string to set. A copy will be created from this. |
- Returns
- 0 for success. Anything else indicates an error.
int accessrule_set_ip |
( |
accessrule_t * |
r, |
|
|
const gchar * |
ip |
|
) |
| |
Set the IP of a Access Rule.
- Parameters
-
r | The Access Rule structure. |
ip | The IP string to set. A copy will be created from this. |
- Returns
- 0 for success. Anything else indicates an error.
Set the rule type of a Access Rule.
- Parameters
-
r | The Access Rule structure. |
rule | The rule type to set. A copy will be created from this. |
- Returns
- 0 for success. Anything else indicates an error.
Add an Access Rule to a collection of Access Rules.
- Parameters
-
rules | The collection of Access Rules (must have ip set). |
Free a collection of Access Rules.
- Parameters
-
rules | The collection of Access Rules. |
Read a collection of Access Rules from a file.
- Parameters
-
fn | The filename from which to read. |
- Returns
- NULL in case an error occured. Else a collection of access rules which might be empty e.g. if the format was incorrect.
- Todo:
- Create a access_rules_t* and pass as user data
- Todo:
- error checks, handling
Make a collection of Access Rules.
Get the size of a collection of Access Rules.
- Returns
- The number of entries in the collection.
Write the contents of a Access Rules collection to a file.
- Parameters
-
rules | The collection of Access Rules. |
fn | The filename where to store the Access Rules. |
- Returns
- 0 in case of success, other values mean a failure.