Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sergi
Tor
Commits
7fa62453
Commit
7fa62453
authored
5 years ago
by
George Kadianakis
Browse files
Options
Downloads
Plain Diff
Merge branch 'tor-github/pr/1269'
parents
a617001f
1ef084c5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/feature/nodelist/routerset.c
+45
-2
45 additions, 2 deletions
src/feature/nodelist/routerset.c
src/test/test_confparse.c
+4
-0
4 additions, 0 deletions
src/test/test_confparse.c
with
49 additions
and
2 deletions
src/feature/nodelist/routerset.c
+
45
−
2
View file @
7fa62453
...
...
@@ -466,6 +466,13 @@ routerset_free_(routerset_t *routerset)
tor_free
(
routerset
);
}
/**
* config helper: parse a routerset-typed variable.
*
* Takes as input as a single line in <b>line</b>; writes its results into a
* routerset_t** passed as <b>target</b>. On success return 0; on failure
* return -1 and store an error message into *<b>errmsg</b>.
**/
static
int
routerset_kv_parse
(
void
*
target
,
const
config_line_t
*
line
,
char
**
errmsg
,
const
void
*
params
)
...
...
@@ -479,11 +486,21 @@ routerset_kv_parse(void *target, const config_line_t *line, char **errmsg,
*
errmsg
=
tor_strdup
(
"Invalid router list."
);
return
-
1
;
}
else
{
if
(
routerset_is_empty
(
rs
))
{
/* Represent empty sets as NULL. */
routerset_free
(
rs
);
}
*
p
=
rs
;
return
0
;
}
}
/**
* config helper: encode a routerset-typed variable.
*
* Return a newly allocated string containing the value of the
* routerset_t** passed as <b>value</b>.
*/
static
char
*
routerset_encode
(
const
void
*
value
,
const
void
*
params
)
{
...
...
@@ -492,6 +509,11 @@ routerset_encode(const void *value, const void *params)
return
routerset_to_string
(
*
p
);
}
/**
* config helper: free and clear a routerset-typed variable.
*
* Clear the routerset_t** passed as <b>value</b>.
*/
static
void
routerset_clear
(
void
*
value
,
const
void
*
params
)
{
...
...
@@ -500,6 +522,13 @@ routerset_clear(void *value, const void *params)
routerset_free
(
*
p
);
// sets *p to NULL.
}
/**
* config helper: copy a routerset-typed variable.
*
* Takes it input from a routerset_t** in <b>src</b>; writes its output to a
* routerset_t** in <b>dest</b>. Returns 0 on success, -1 on (impossible)
* failure.
**/
static
int
routerset_copy
(
void
*
dest
,
const
void
*
src
,
const
void
*
params
)
{
...
...
@@ -507,11 +536,16 @@ routerset_copy(void *dest, const void *src, const void *params)
routerset_t
**
output
=
(
routerset_t
**
)
dest
;
const
routerset_t
*
input
=
*
(
routerset_t
**
)
src
;
routerset_free
(
*
output
);
// sets *output to NULL
*
output
=
routerset_new
();
routerset_union
(
*
output
,
input
);
if
(
!
routerset_is_empty
(
input
))
{
*
output
=
routerset_new
();
routerset_union
(
*
output
,
input
);
}
return
0
;
}
/**
* Function table to implement a routerset_t-based configuration type.
**/
static
const
var_type_fns_t
routerset_type_fns
=
{
.
kv_parse
=
routerset_kv_parse
,
.
encode
=
routerset_encode
,
...
...
@@ -519,6 +553,15 @@ static const var_type_fns_t routerset_type_fns = {
.
copy
=
routerset_copy
};
/**
* Definition of a routerset_t-based configuration type.
*
* Values are mapped to and from strings using the format defined in
* routerset_parse(): nicknames, IP address patterns, and fingerprints--with
* optional space, separated by commas.
*
* Empty sets are represented as NULL.
**/
const
var_type_def_t
ROUTERSET_type_defn
=
{
.
name
=
"RouterList"
,
.
fns
=
&
routerset_type_fns
...
...
This diff is collapsed.
Click to expand it.
src/test/test_confparse.c
+
4
−
0
View file @
7fa62453
...
...
@@ -592,6 +592,10 @@ test_confparse_reset(void *arg)
config_reset_line
(
&
test_fmt
,
tst
,
"interval"
,
1
);
tt_int_op
(
tst
->
interval
,
OP_EQ
,
10
);
tt_ptr_op
(
tst
->
routerset
,
OP_NE
,
NULL
);
config_reset_line
(
&
test_fmt
,
tst
,
"routerset"
,
0
);
tt_ptr_op
(
tst
->
routerset
,
OP_EQ
,
NULL
);
done:
config_free
(
&
test_fmt
,
tst
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment