Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
490d6ef6
Commit
490d6ef6
authored
Feb 10, 2016
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for returning actions from parse_config_from_string.
parent
34fb107c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
babeld.c
babeld.c
+1
-1
configuration.c
configuration.c
+7
-5
configuration.h
configuration.h
+4
-0
No files found.
babeld.c
View file @
490d6ef6
...
...
@@ -293,7 +293,7 @@ main(int argc, char **argv)
break
;
case
'C'
:
rc
=
parse_config_from_string
(
optarg
,
strlen
(
optarg
));
if
(
rc
<
0
)
{
if
(
rc
!=
CONFIG_DONE
)
{
fprintf
(
stderr
,
"Couldn't parse configuration from command line.
\n
"
);
exit
(
1
);
...
...
configuration.c
View file @
490d6ef6
...
...
@@ -816,9 +816,11 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
}
static
int
parse_config_line
(
int
c
,
gnc_t
gnc
,
void
*
closure
)
parse_config_line
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
int
*
action_return
)
{
char
*
token
;
if
(
action_return
)
*
action_return
=
CONFIG_DONE
;
c
=
skip_whitespace
(
c
,
gnc
,
closure
);
if
(
c
<
0
||
c
==
'\n'
||
c
==
'#'
)
...
...
@@ -914,7 +916,7 @@ parse_config_from_file(const char *filename, int *line_return)
return
0
;
while
(
1
)
{
c
=
parse_config_line
(
c
,
(
gnc_t
)
gnc_file
,
&
s
);
c
=
parse_config_line
(
c
,
(
gnc_t
)
gnc_file
,
&
s
,
NULL
);
if
(
c
<
-
1
)
{
*
line_return
=
s
.
line
;
return
-
1
;
...
...
@@ -944,16 +946,16 @@ gnc_buf(struct buf_state *s)
int
parse_config_from_string
(
char
*
string
,
int
n
)
{
int
c
;
int
c
,
action
;
struct
buf_state
s
=
{
string
,
0
,
n
};
c
=
gnc_buf
(
&
s
);
if
(
c
<
0
)
return
-
1
;
c
=
parse_config_line
(
c
,
(
gnc_t
)
gnc_buf
,
&
s
);
c
=
parse_config_line
(
c
,
(
gnc_t
)
gnc_buf
,
&
s
,
&
action
);
if
(
c
==
-
1
)
return
1
;
return
action
;
else
return
-
1
;
}
...
...
configuration.h
View file @
490d6ef6
...
...
@@ -20,6 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* Values returned by parse_config_from_string. */
#define CONFIG_DONE 0
struct
filter_result
{
unsigned
int
add_metric
;
/* allow = 0, deny = INF, metric = <0..INF> */
unsigned
char
*
src_prefix
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment