Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
9550c873
Commit
9550c873
authored
Jun 30, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag: added function tag_name_parse()
Convert a string into a tag_type enum.
parent
e223e8a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
12 deletions
+60
-12
locate.c
src/locate.c
+3
-3
tag.c
src/tag.c
+41
-9
tag.h
src/tag.h
+16
-0
No files found.
src/locate.c
View file @
9550c873
...
@@ -42,9 +42,9 @@ locate_parse_type(const char *str)
...
@@ -42,9 +42,9 @@ locate_parse_type(const char *str)
if
(
0
==
g_ascii_strcasecmp
(
str
,
LOCATE_TAG_ANY_KEY
))
if
(
0
==
g_ascii_strcasecmp
(
str
,
LOCATE_TAG_ANY_KEY
))
return
LOCATE_TAG_ANY_TYPE
;
return
LOCATE_TAG_ANY_TYPE
;
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
i
=
tag_name_parse_i
(
str
);
if
(
0
==
g_ascii_strcasecmp
(
str
,
tag_item_names
[
i
])
)
if
(
i
!=
TAG_NUM_OF_ITEM_TYPES
)
return
i
;
return
i
;
return
-
1
;
return
-
1
;
}
}
...
...
src/tag.c
View file @
9550c873
...
@@ -64,6 +64,36 @@ const char *tag_item_names[TAG_NUM_OF_ITEM_TYPES] = {
...
@@ -64,6 +64,36 @@ const char *tag_item_names[TAG_NUM_OF_ITEM_TYPES] = {
bool
ignore_tag_items
[
TAG_NUM_OF_ITEM_TYPES
];
bool
ignore_tag_items
[
TAG_NUM_OF_ITEM_TYPES
];
enum
tag_type
tag_name_parse
(
const
char
*
name
)
{
assert
(
name
!=
NULL
);
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
{
assert
(
tag_item_names
[
i
]
!=
NULL
);
if
(
strcmp
(
name
,
tag_item_names
[
i
])
==
0
)
return
(
enum
tag_type
)
i
;
}
return
TAG_NUM_OF_ITEM_TYPES
;
}
enum
tag_type
tag_name_parse_i
(
const
char
*
name
)
{
assert
(
name
!=
NULL
);
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
{
assert
(
tag_item_names
[
i
]
!=
NULL
);
if
(
g_ascii_strcasecmp
(
name
,
tag_item_names
[
i
])
==
0
)
return
(
enum
tag_type
)
i
;
}
return
TAG_NUM_OF_ITEM_TYPES
;
}
static
size_t
items_size
(
const
struct
tag
*
tag
)
static
size_t
items_size
(
const
struct
tag
*
tag
)
{
{
return
tag
->
num_items
*
sizeof
(
struct
tag_item
*
);
return
tag
->
num_items
*
sizeof
(
struct
tag_item
*
);
...
@@ -76,7 +106,7 @@ void tag_lib_init(void)
...
@@ -76,7 +106,7 @@ void tag_lib_init(void)
char
*
temp
;
char
*
temp
;
char
*
s
;
char
*
s
;
char
*
c
;
char
*
c
;
int
i
;
enum
tag_type
type
;
/* parse the "metadata_to_use" config parameter below */
/* parse the "metadata_to_use" config parameter below */
...
@@ -98,16 +128,18 @@ void tag_lib_init(void)
...
@@ -98,16 +128,18 @@ void tag_lib_init(void)
if
(
*
s
==
'\0'
)
if
(
*
s
==
'\0'
)
quit
=
1
;
quit
=
1
;
*
s
=
'\0'
;
*
s
=
'\0'
;
for
(
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
i
++
)
{
if
(
g_ascii_strcasecmp
(
c
,
tag_item_names
[
i
])
==
0
)
{
c
=
g_strstrip
(
c
);
ignore_tag_items
[
i
]
=
false
;
if
(
*
c
==
0
)
break
;
continue
;
}
}
type
=
tag_name_parse_i
(
c
);
if
(
strlen
(
c
)
&&
i
==
TAG_NUM_OF_ITEM_TYPES
)
{
if
(
type
==
TAG_NUM_OF_ITEM_TYPES
)
g_error
(
"error parsing metadata item
\"
%s
\"
"
,
g_error
(
"error parsing metadata item
\"
%s
\"
"
,
c
);
c
);
}
ignore_tag_items
[
type
]
=
false
;
s
++
;
s
++
;
c
=
s
;
c
=
s
;
}
}
...
...
src/tag.h
View file @
9550c873
...
@@ -94,6 +94,22 @@ struct tag {
...
@@ -94,6 +94,22 @@ struct tag {
};
};
/**
/**
* Parse the string, and convert it into a #tag_type. Returns
* #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.
*/
enum
tag_type
tag_name_parse
(
const
char
*
name
);
/**
* Parse the string, and convert it into a #tag_type. Returns
* #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.
*
* Case does not matter.
*/
enum
tag_type
tag_name_parse_i
(
const
char
*
name
);
/**
* Creates an empty #tag.
* Creates an empty #tag.
*/
*/
struct
tag
*
tag_new
(
void
);
struct
tag
*
tag_new
(
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