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
3d2092ee
Commit
3d2092ee
authored
Aug 07, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
locate: make the structs opaque
parent
8855efeb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
29 deletions
+36
-29
DatabaseCommands.cxx
src/DatabaseCommands.cxx
+3
-3
locate.c
src/locate.c
+30
-3
locate.h
src/locate.h
+3
-23
No files found.
src/DatabaseCommands.cxx
View file @
3d2092ee
...
...
@@ -227,9 +227,9 @@ handle_list(struct client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
}
conditionals
=
locate_item_list_new
(
1
);
conditionals
->
items
[
0
].
tag
=
TAG_ARTIST
;
conditionals
->
items
[
0
].
needle
=
g_strdup
(
argv
[
2
]);
conditionals
=
locate_item_list_new_single
((
unsigned
)
TAG_ARTIST
,
argv
[
2
]);
}
else
{
conditionals
=
locate_item_list_parse
(
argv
+
2
,
argc
-
2
,
false
);
...
...
src/locate.c
View file @
3d2092ee
...
...
@@ -31,6 +31,24 @@
#define LOCATE_TAG_FILE_KEY_OLD "filename"
#define LOCATE_TAG_ANY_KEY "any"
/* struct used for search, find, list queries */
struct
locate_item
{
int8_t
tag
;
/* what we are looking for */
char
*
needle
;
};
/**
* An array of struct locate_item objects.
*/
struct
locate_item_list
{
/** number of items */
unsigned
length
;
/** this is a variable length array */
struct
locate_item
items
[
1
];
};
int
locate_parse_type
(
const
char
*
str
)
{
...
...
@@ -74,18 +92,27 @@ locate_item_list_free(struct locate_item_list *list)
g_free
(
list
);
}
struct
locate_item_list
*
st
atic
st
ruct
locate_item_list
*
locate_item_list_new
(
unsigned
length
)
{
struct
locate_item_list
*
list
=
g_malloc
0
(
sizeof
(
*
list
)
-
sizeof
(
list
->
items
[
0
])
+
length
*
sizeof
(
list
->
items
[
0
]));
g_malloc
(
sizeof
(
*
list
)
-
sizeof
(
list
->
items
[
0
])
+
length
*
sizeof
(
list
->
items
[
0
]));
list
->
length
=
length
;
return
list
;
}
struct
locate_item_list
*
locate_item_list_new_single
(
unsigned
tag
,
const
char
*
needle
)
{
struct
locate_item_list
*
list
=
locate_item_list_new
(
1
);
list
->
items
[
0
].
tag
=
tag
;
list
->
items
[
0
].
needle
=
g_strdup
(
needle
);
return
list
;
}
struct
locate_item_list
*
locate_item_list_parse
(
char
*
argv
[],
unsigned
argc
,
bool
fold_case
)
{
if
(
argc
==
0
||
argc
%
2
!=
0
)
...
...
src/locate.h
View file @
3d2092ee
...
...
@@ -28,36 +28,16 @@
#define LOCATE_TAG_FILE_TYPE TAG_NUM_OF_ITEM_TYPES+10
#define LOCATE_TAG_ANY_TYPE TAG_NUM_OF_ITEM_TYPES+20
struct
locate_item_list
;
struct
song
;
/* struct used for search, find, list queries */
struct
locate_item
{
int8_t
tag
;
/* what we are looking for */
char
*
needle
;
};
/**
* An array of struct locate_item objects.
*/
struct
locate_item_list
{
/** number of items */
unsigned
length
;
/** this is a variable length array */
struct
locate_item
items
[
1
];
};
gcc_pure
int
locate_parse_type
(
const
char
*
str
);
/**
* Allocates a new struct locate_item_list, and initializes all
* members with zero bytes.
*/
gcc_malloc
struct
locate_item_list
*
locate_item_list_new
(
unsigned
length
);
locate_item_list_new
_single
(
unsigned
tag
,
const
char
*
needle
);
/* return number of items or -1 on error */
gcc_nonnull
(
1
)
...
...
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