Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
c7325f2f
Commit
c7325f2f
authored
Apr 04, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use C functions
parent
7e44fa82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
77 deletions
+41
-77
src/config/chain.c
src/config/chain.c
+41
-77
No files found.
src/config/chain.c
View file @
c7325f2f
...
@@ -54,7 +54,7 @@ static bool IsSpace( char c )
...
@@ -54,7 +54,7 @@ static bool IsSpace( char c )
return
c
==
' '
||
c
==
'\t'
;
return
c
==
' '
||
c
==
'\t'
;
}
}
#define SKIPSPACE( p )
do { while( *p && IsSpace( *p ) ) p++; } while(0
)
#define SKIPSPACE( p )
p += strspn( p, " \t"
)
#define SKIPTRAILINGSPACE( p, e ) \
#define SKIPTRAILINGSPACE( p, e ) \
do { while( e > p && IsSpace( *(e-1) ) ) e--; } while(0)
do { while( e > p && IsSpace( *(e-1) ) ) e--; } while(0)
...
@@ -174,107 +174,71 @@ static char *ChainGetValue( const char **ppsz_string )
...
@@ -174,107 +174,71 @@ static char *ChainGetValue( const char **ppsz_string )
return
psz_value
;
return
psz_value
;
}
}
char
*
config_ChainCreate
(
char
**
ppsz_name
,
config_chain_t
**
pp_cfg
,
const
char
*
psz_chain
)
char
*
config_ChainCreate
(
char
**
ppsz_name
,
config_chain_t
**
pp_cfg
,
const
char
*
psz_chain
)
{
{
config_chain_t
*
p_cfg
=
NULL
;
config_chain_t
*
*
pp_next
=
pp_cfg
;
const
char
*
p
=
psz_chai
n
;
size_t
le
n
;
*
ppsz_name
=
NULL
;
*
ppsz_name
=
NULL
;
*
pp_cfg
=
NULL
;
*
pp_cfg
=
NULL
;
if
(
!
p
)
if
(
!
p
sz_chain
)
return
NULL
;
return
NULL
;
psz_chain
+=
strspn
(
psz_chain
,
"
\t
"
);
/* Look for parameter(either a {...} or :...) or the end of name (space or nul) */
/* Look for parameter (a {...} or :...) or end of name (space or nul) */
SKIPSPACE
(
p
);
len
=
strcspn
(
psz_chain
,
"{:
\t
"
);
if
(
len
==
0
)
while
(
*
p
&&
*
p
!=
'{'
&&
*
p
!=
':'
&&
!
IsSpace
(
*
p
)
)
p
++
;
if
(
p
==
psz_chain
)
return
NULL
;
return
NULL
;
/* Extract the name */
/* Extract the name */
*
ppsz_name
=
strndup
(
psz_chain
,
p
-
psz_chain
);
*
ppsz_name
=
strndup
(
psz_chain
,
len
);
psz_chain
+=
len
;
/* Parse the parameters */
/* Parse the parameters */
SKIPSPACE
(
p
);
psz_chain
+=
strspn
(
psz_chain
,
"
\t
"
);
if
(
*
psz_chain
==
'{'
)
if
(
*
p
==
'{'
)
{
{
const
char
*
psz_name
;
/* Parse all name=value[,] elements */
do
/* Skip the opening '{' */
p
++
;
/* parse all name=value[,] elements */
for
(
;;
)
{
{
SKIPSPACE
(
p
);
psz_chain
++
;
/* skip previous delimiter */
psz_chain
+=
strspn
(
psz_chain
,
"
\t
"
);
psz_name
=
p
;
/* Look for the end of the name (,={}_space_) */
/* Look for the end of the name (,={}_space_) */
while
(
*
p
&&
*
p
!=
'='
&&
*
p
!=
','
&&
*
p
!=
'{'
&&
*
p
!=
'}'
&&
!
IsSpace
(
*
p
)
)
len
=
strcspn
(
psz_chain
,
"=,{}
\t
"
);
p
++
;
if
(
len
==
0
)
continue
;
/* ignore empty parameter */
// fprintf( stderr, "name=%s - rest=%s\n", psz_name, p );
/* Append the new parameter */
if
(
p
==
psz_name
)
config_chain_t
*
p_cfg
=
malloc
(
sizeof
(
*
p_cfg
)
);
{
if
(
!
p_cfg
)
fprintf
(
stderr
,
"config_ChainCreate: invalid options (empty)
\n
"
);
break
;
break
;
}
p_cfg
->
psz_name
=
strndup
(
psz_chain
,
len
);
psz_chain
+=
len
;
/* */
p_cfg
->
psz_value
=
NULL
;
config_chain_t
cfg
;
p_cfg
->
p_next
=
NULL
;
cfg
.
psz_name
=
strndup
(
psz_name
,
p
-
psz_name
);
cfg
.
psz_value
=
NULL
;
cfg
.
p_next
=
NULL
;
/* Parse the option name parameter */
*
pp_next
=
p_cfg
;
SKIPSPACE
(
p
)
;
pp_next
=
&
p_cfg
->
p_next
;
if
(
*
p
==
'='
||
*
p
==
'{'
)
/* Extract the option value */
psz_chain
+=
strspn
(
psz_chain
,
"
\t
"
);
if
(
strchr
(
"={"
,
*
psz_chain
)
)
{
{
cfg
.
psz_value
=
ChainGetValue
(
&
p
);
p_cfg
->
psz_value
=
ChainGetValue
(
&
psz_chain
);
psz_chain
+=
strspn
(
psz_chain
,
"
\t
"
);
SKIPSPACE
(
p
);
}
/* Append the new option */
config_chain_t
*
p_new
=
malloc
(
sizeof
(
*
p_new
)
);
if
(
!
p_new
)
{
free
(
cfg
.
psz_name
);
free
(
cfg
.
psz_value
);
break
;
}
*
p_new
=
cfg
;
if
(
p_cfg
)
{
p_cfg
->
p_next
=
p_new
;
p_cfg
=
p_cfg
->
p_next
;
}
else
{
*
pp_cfg
=
p_cfg
=
p_new
;
}
/* */
if
(
*
p
==
','
)
p
++
;
if
(
*
p
==
'}'
)
{
p
++
;
break
;
}
}
}
}
while
(
!
memchr
(
"}"
,
*
psz_chain
,
2
)
);
if
(
*
psz_chain
)
psz_chain
++
;
/* skip '}' */
;
psz_chain
+=
strspn
(
psz_chain
,
"
\t
"
);
}
}
if
(
*
p
==
':'
)
if
(
*
p
sz_chain
==
':'
)
return
strdup
(
&
p
[
1
]
);
return
strdup
(
psz_chain
+
1
);
return
NULL
;
return
NULL
;
}
}
...
...
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