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
d093352f
Commit
d093352f
authored
Feb 12, 2016
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to return an error message in the local interface.
parent
c7b44dac
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
14 deletions
+22
-14
babeld.c
babeld.c
+1
-1
configuration.c
configuration.c
+12
-6
configuration.h
configuration.h
+1
-1
local.c
local.c
+8
-6
No files found.
babeld.c
View file @
d093352f
...
...
@@ -295,7 +295,7 @@ main(int argc, char **argv)
config_files
[
num_config_files
++
]
=
optarg
;
break
;
case
'C'
:
rc
=
parse_config_from_string
(
optarg
,
strlen
(
optarg
));
rc
=
parse_config_from_string
(
optarg
,
strlen
(
optarg
)
,
NULL
);
if
(
rc
!=
CONFIG_ACTION_DONE
)
{
fprintf
(
stderr
,
"Couldn't parse configuration from command line.
\n
"
);
...
...
configuration.c
View file @
d093352f
...
...
@@ -853,11 +853,14 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
}
static
int
parse_config_line
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
int
*
action_return
)
parse_config_line
(
int
c
,
gnc_t
gnc
,
void
*
closure
,
int
*
action_return
,
const
char
**
message_return
)
{
char
*
token
;
if
(
action_return
)
*
action_return
=
CONFIG_ACTION_DONE
;
if
(
message_return
)
*
message_return
=
NULL
;
c
=
skip_whitespace
(
c
,
gnc
,
closure
);
if
(
c
<
0
||
c
==
'\n'
||
c
==
'#'
)
...
...
@@ -1002,7 +1005,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
,
NULL
);
c
=
parse_config_line
(
c
,
(
gnc_t
)
gnc_file
,
&
s
,
NULL
,
NULL
);
if
(
c
<
-
1
)
{
*
line_return
=
s
.
line
;
return
-
1
;
...
...
@@ -1030,19 +1033,22 @@ gnc_buf(struct buf_state *s)
}
int
parse_config_from_string
(
char
*
string
,
int
n
)
parse_config_from_string
(
char
*
string
,
int
n
,
const
char
**
message_return
)
{
int
c
,
action
;
const
char
*
message
;
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
,
&
action
);
if
(
c
==
-
1
)
c
=
parse_config_line
(
c
,
(
gnc_t
)
gnc_buf
,
&
s
,
&
action
,
&
message
);
if
(
c
==
-
1
)
{
if
(
message_return
)
*
message_return
=
message
;
return
action
;
else
}
else
return
-
1
;
}
...
...
configuration.h
View file @
d093352f
...
...
@@ -58,7 +58,7 @@ extern struct interface_conf *default_interface_conf;
void
flush_ifconf
(
struct
interface_conf
*
if_conf
);
int
parse_config_from_file
(
const
char
*
filename
,
int
*
line_return
);
int
parse_config_from_string
(
char
*
string
,
int
n
);
int
parse_config_from_string
(
char
*
string
,
int
n
,
const
char
**
message_return
);
void
renumber_filters
(
void
);
int
input_filter
(
const
unsigned
char
*
id
,
...
...
local.c
View file @
d093352f
...
...
@@ -315,7 +315,8 @@ local_read(struct local_socket *s)
{
int
rc
;
char
*
eol
;
char
*
reply
=
"ok
\n
"
;
char
reply
[
100
]
=
"ok
\n
"
;
const
char
*
message
=
NULL
;
if
(
s
->
buf
==
NULL
)
s
->
buf
=
malloc
(
LOCAL_BUFSIZE
);
...
...
@@ -336,13 +337,13 @@ local_read(struct local_socket *s)
if
(
eol
==
NULL
)
return
1
;
rc
=
parse_config_from_string
(
s
->
buf
,
eol
+
1
-
s
->
buf
);
rc
=
parse_config_from_string
(
s
->
buf
,
eol
+
1
-
s
->
buf
,
&
message
);
switch
(
rc
)
{
case
CONFIG_ACTION_DONE
:
break
;
case
CONFIG_ACTION_QUIT
:
shutdown
(
s
->
fd
,
1
);
reply
=
NULL
;
reply
[
0
]
=
'\0'
;
break
;
case
CONFIG_ACTION_DUMP
:
local_notify_all_1
(
s
);
...
...
@@ -355,13 +356,14 @@ local_read(struct local_socket *s)
s
->
monitor
=
0
;
break
;
case
CONFIG_ACTION_NO
:
reply
=
"no
\n
"
;
snprintf
(
reply
,
sizeof
(
reply
),
"no%s%s
\n
"
,
message
?
" "
:
""
,
message
?
message
:
""
);
break
;
default:
reply
=
"bad
\n
"
;
snprintf
(
reply
,
sizeof
(
reply
),
"bad
\n
"
)
;
}
if
(
reply
!=
NULL
)
{
if
(
reply
[
0
]
!=
'\0'
)
{
rc
=
write_timeout
(
s
->
fd
,
reply
,
strlen
(
reply
));
if
(
rc
<
0
)
goto
fail
;
...
...
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