Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
weston
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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
Pekka Paalanen
weston
Commits
81c2c2eb
Commit
81c2c2eb
authored
11 years ago
by
Kristian Høgsberg
Browse files
Options
Downloads
Patches
Plain Diff
shared: Remove no longer used parse_config_file()
parent
b159560d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
shared/config-parser.c
+0
-128
0 additions, 128 deletions
shared/config-parser.c
shared/config-parser.h
+0
-5
0 additions, 5 deletions
shared/config-parser.h
with
0 additions
and
133 deletions
shared/config-parser.c
+
0
−
128
View file @
81c2c2eb
...
...
@@ -41,134 +41,6 @@
const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
static
int
handle_key
(
const
struct
config_key
*
key
,
const
char
*
value
)
{
char
*
end
,
*
s
;
int
i
,
len
;
unsigned
int
ui
;
switch
(
key
->
type
)
{
case
CONFIG_KEY_INTEGER
:
i
=
strtol
(
value
,
&
end
,
0
);
if
(
*
end
!=
'\n'
)
{
fprintf
(
stderr
,
"invalid integer: %s
\n
"
,
value
);
return
-
1
;
}
*
(
int
*
)
key
->
data
=
i
;
return
0
;
case
CONFIG_KEY_UNSIGNED_INTEGER
:
ui
=
strtoul
(
value
,
&
end
,
0
);
if
(
*
end
!=
'\n'
)
{
fprintf
(
stderr
,
"invalid integer: %s
\n
"
,
value
);
return
-
1
;
}
*
(
unsigned
int
*
)
key
->
data
=
ui
;
return
0
;
case
CONFIG_KEY_STRING
:
len
=
strlen
(
value
);
while
(
len
>
0
&&
isspace
(
value
[
len
-
1
]))
len
--
;
s
=
malloc
(
len
+
1
);
if
(
s
==
NULL
)
return
-
1
;
memcpy
(
s
,
value
,
len
);
s
[
len
]
=
'\0'
;
*
(
char
**
)
key
->
data
=
s
;
return
0
;
case
CONFIG_KEY_BOOLEAN
:
if
(
strcmp
(
value
,
"false
\n
"
)
==
0
)
*
(
int
*
)
key
->
data
=
0
;
else
if
(
strcmp
(
value
,
"true
\n
"
)
==
0
)
*
(
int
*
)
key
->
data
=
1
;
else
{
fprintf
(
stderr
,
"invalid bool: %s
\n
"
,
value
);
return
-
1
;
}
return
0
;
default:
assert
(
0
);
break
;
}
return
-
1
;
}
int
parse_config_file
(
int
fd
,
const
struct
config_section
*
sections
,
int
num_sections
,
void
*
data
)
{
FILE
*
fp
;
char
line
[
512
],
*
p
;
const
struct
config_section
*
current
=
NULL
;
int
i
;
if
(
fd
==
-
1
)
return
-
1
;
fp
=
fdopen
(
dup
(
fd
),
"r"
);
if
(
fp
==
NULL
)
{
perror
(
"couldn't open config file"
);
return
-
1
;
}
rewind
(
fp
);
while
(
fgets
(
line
,
sizeof
line
,
fp
))
{
if
(
line
[
0
]
==
'#'
||
line
[
0
]
==
'\n'
)
{
continue
;
}
if
(
line
[
0
]
==
'['
)
{
p
=
strchr
(
&
line
[
1
],
']'
);
if
(
!
p
||
p
[
1
]
!=
'\n'
)
{
fprintf
(
stderr
,
"malformed "
"section header: %s
\n
"
,
line
);
fclose
(
fp
);
return
-
1
;
}
if
(
current
&&
current
->
done
)
current
->
done
(
data
);
p
[
0
]
=
'\0'
;
for
(
i
=
0
;
i
<
num_sections
;
i
++
)
{
if
(
strcmp
(
sections
[
i
].
name
,
&
line
[
1
])
==
0
)
{
current
=
&
sections
[
i
];
break
;
}
}
if
(
i
==
num_sections
)
current
=
NULL
;
}
else
if
(
p
=
strchr
(
line
,
'='
),
p
!=
NULL
)
{
if
(
current
==
NULL
)
continue
;
p
[
0
]
=
'\0'
;
for
(
i
=
0
;
i
<
current
->
num_keys
;
i
++
)
{
if
(
strcmp
(
current
->
keys
[
i
].
name
,
line
)
==
0
)
{
if
(
handle_key
(
&
current
->
keys
[
i
],
&
p
[
1
])
<
0
)
{
fclose
(
fp
);
return
-
1
;
}
break
;
}
}
}
else
{
fprintf
(
stderr
,
"malformed config line: %s
\n
"
,
line
);
fclose
(
fp
);
return
-
1
;
}
}
if
(
current
&&
current
->
done
)
current
->
done
(
data
);
fclose
(
fp
);
return
0
;
}
int
open_config_file
(
const
char
*
name
)
{
...
...
This diff is collapsed.
Click to expand it.
shared/config-parser.h
+
0
−
5
View file @
81c2c2eb
...
...
@@ -47,11 +47,6 @@ struct config_section {
void
(
*
done
)(
void
*
data
);
};
int
parse_config_file
(
int
config_fd
,
const
struct
config_section
*
sections
,
int
num_sections
,
void
*
data
);
int
open_config_file
(
const
char
*
name
);
...
...
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