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
cb00f766
Commit
cb00f766
authored
Jun 12, 2013
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error messages from configuration parser.
parent
052068bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
babeld.c
babeld.c
+5
-3
configuration.c
configuration.c
+26
-6
configuration.h
configuration.h
+1
-1
No files found.
babeld.c
View file @
cb00f766
...
@@ -260,11 +260,13 @@ main(int argc, char **argv)
...
@@ -260,11 +260,13 @@ main(int argc, char **argv)
config_file
=
"/etc/babeld.conf"
;
config_file
=
"/etc/babeld.conf"
;
}
}
if
(
config_file
)
{
if
(
config_file
)
{
rc
=
parse_config_from_file
(
config_file
);
int
line
;
rc
=
parse_config_from_file
(
config_file
,
&
line
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"Couldn't parse configuration from file %s.
\n
"
,
"Couldn't parse configuration from file %s "
config_file
);
"(error at line %d).
\n
"
,
config_file
,
line
);
exit
(
1
);
exit
(
1
);
}
}
}
else
{
}
else
{
...
...
configuration.c
View file @
cb00f766
...
@@ -594,17 +594,37 @@ parse_config(gnc_t gnc, void *closure)
...
@@ -594,17 +594,37 @@ parse_config(gnc_t gnc, void *closure)
return
1
;
return
1
;
}
}
struct
file_state
{
FILE
*
f
;
int
line
;
};
static
int
gnc_file
(
struct
file_state
*
s
)
{
int
c
;
c
=
fgetc
(
s
->
f
);
if
(
c
==
'\n'
)
s
->
line
++
;
return
c
;
}
int
int
parse_config_from_file
(
c
har
*
filename
)
parse_config_from_file
(
c
onst
char
*
filename
,
int
*
line_return
)
{
{
FILE
*
f
;
struct
file_state
s
=
{
NULL
,
1
}
;
int
rc
;
int
rc
;
f
=
fopen
(
filename
,
"r"
);
s
.
f
=
fopen
(
filename
,
"r"
);
if
(
f
==
NULL
)
if
(
s
.
f
==
NULL
)
{
*
line_return
=
0
;
return
-
1
;
return
-
1
;
rc
=
parse_config
((
gnc_t
)
fgetc
,
f
);
}
fclose
(
f
);
rc
=
parse_config
((
gnc_t
)
gnc_file
,
&
s
);
fclose
(
s
.
f
);
*
line_return
=
s
.
line
;
return
rc
;
return
rc
;
}
}
...
...
configuration.h
View file @
cb00f766
...
@@ -34,7 +34,7 @@ struct filter {
...
@@ -34,7 +34,7 @@ struct filter {
struct
filter
*
next
;
struct
filter
*
next
;
};
};
int
parse_config_from_file
(
c
har
*
filename
);
int
parse_config_from_file
(
c
onst
char
*
filename
,
int
*
line_return
);
int
parse_config_from_string
(
char
*
string
);
int
parse_config_from_string
(
char
*
string
);
void
renumber_filters
(
void
);
void
renumber_filters
(
void
);
...
...
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