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
a236a439
Commit
a236a439
authored
Sep 13, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db_print: move code to function db_selection_print()
Use it in handle_lsinfo(), and eliminate some duplicate code.
parent
c779e267
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
134 deletions
+27
-134
Makefile.am
Makefile.am
+0
-2
command.c
src/command.c
+6
-9
db_print.c
src/db_print.c
+15
-2
db_print.h
src/db_print.h
+6
-0
directory_print.c
src/directory_print.c
+0
-74
directory_print.h
src/directory_print.h
+0
-29
song_print.c
src/song_print.c
+0
-15
song_print.h
src/song_print.h
+0
-3
No files found.
Makefile.am
View file @
a236a439
...
...
@@ -78,7 +78,6 @@ mpd_headers = \
src/decoder_internal.h
\
src/directory.h
\
src/directory_save.h
\
src/directory_print.h
\
src/database.h
\
src/encoder_plugin.h
\
src/encoder_list.h
\
...
...
@@ -269,7 +268,6 @@ src_mpd_SOURCES = \
src/decoder_print.c
\
src/directory.c
\
src/directory_save.c
\
src/directory_print.c
\
src/database.c
\
src/db_error.h
\
src/db_save.c src/db_save.h
\
...
...
src/command.c
View file @
a236a439
...
...
@@ -30,7 +30,6 @@
#include "uri.h"
#include "decoder_print.h"
#include "directory.h"
#include "directory_print.h"
#include "database.h"
#include "update.h"
#include "volume.h"
...
...
@@ -45,6 +44,7 @@
#include "dbUtils.h"
#include "db_error.h"
#include "db_print.h"
#include "db_selection.h"
#include "tag.h"
#include "client.h"
#include "client_idle.h"
...
...
@@ -840,7 +840,6 @@ static enum command_return
handle_lsinfo
(
struct
client
*
client
,
int
argc
,
char
*
argv
[])
{
const
char
*
uri
;
const
struct
directory
*
directory
;
if
(
argc
==
2
)
uri
=
argv
[
1
];
...
...
@@ -848,14 +847,12 @@ handle_lsinfo(struct client *client, int argc, char *argv[])
/* default is root directory */
uri
=
""
;
directory
=
db_get_directory
(
uri
);
if
(
directory
==
NULL
)
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"directory not found"
);
return
COMMAND_RETURN_ERROR
;
}
struct
db_selection
selection
;
db_selection_init
(
&
selection
,
uri
,
false
);
directory_print
(
client
,
directory
);
GError
*
error
=
NULL
;
if
(
!
db_selection_print
(
client
,
&
selection
,
true
,
&
error
))
return
print_error
(
client
,
error
);
if
(
isRootDirectory
(
uri
))
{
GPtrArray
*
list
=
spl_list
(
NULL
);
...
...
src/db_print.c
View file @
a236a439
...
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "db_print.h"
#include "db_selection.h"
#include "db_visitor.h"
#include "locate.h"
#include "directory.h"
...
...
@@ -119,6 +120,14 @@ static const struct db_visitor print_info_visitor = {
.
playlist
=
print_visitor_playlist_info
,
};
bool
db_selection_print
(
struct
client
*
client
,
const
struct
db_selection
*
selection
,
bool
full
,
GError
**
error_r
)
{
return
db_visit
(
selection
,
full
?
&
print_info_visitor
:
&
print_visitor
,
client
,
error_r
);
}
struct
search_data
{
struct
client
*
client
;
const
struct
locate_item_list
*
criteria
;
...
...
@@ -233,14 +242,18 @@ searchStatsForSongsIn(struct client *client, const char *name,
bool
printAllIn
(
struct
client
*
client
,
const
char
*
uri_utf8
,
GError
**
error_r
)
{
return
db_walk
(
uri_utf8
,
&
print_visitor
,
client
,
error_r
);
struct
db_selection
selection
;
db_selection_init
(
&
selection
,
uri_utf8
,
true
);
return
db_selection_print
(
client
,
&
selection
,
false
,
error_r
);
}
bool
printInfoForAllIn
(
struct
client
*
client
,
const
char
*
uri_utf8
,
GError
**
error_r
)
{
return
db_walk
(
uri_utf8
,
&
print_info_visitor
,
client
,
error_r
);
struct
db_selection
selection
;
db_selection_init
(
&
selection
,
uri_utf8
,
true
);
return
db_selection_print
(
client
,
&
selection
,
true
,
error_r
);
}
static
ListCommandItem
*
...
...
src/db_print.h
View file @
a236a439
...
...
@@ -27,10 +27,16 @@
struct
client
;
struct
locate_item_list
;
struct
db_selection
;
struct
db_visitor
;
gcc_nonnull
(
1
,
2
)
bool
db_selection_print
(
struct
client
*
client
,
const
struct
db_selection
*
selection
,
bool
full
,
GError
**
error_r
);
gcc_nonnull
(
1
,
2
)
bool
printAllIn
(
struct
client
*
client
,
const
char
*
uri_utf8
,
GError
**
error_r
);
gcc_nonnull
(
1
,
2
)
...
...
src/directory_print.c
deleted
100644 → 0
View file @
c779e267
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "directory_print.h"
#include "directory.h"
#include "client.h"
#include "song_print.h"
#include "mapper.h"
#include "decoder_list.h"
#include "path.h"
#include "uri.h"
#include "input_stream.h"
#include <sys/types.h>
#include <dirent.h>
static
void
dirvec_print
(
struct
client
*
client
,
const
struct
dirvec
*
dv
)
{
size_t
i
;
for
(
i
=
0
;
i
<
dv
->
nr
;
++
i
)
client_printf
(
client
,
DIRECTORY_DIR
"%s
\n
"
,
directory_get_path
(
dv
->
base
[
i
]));
}
static
void
print_playlist_in_directory
(
struct
client
*
client
,
const
struct
directory
*
directory
,
const
char
*
name_utf8
)
{
if
(
directory_is_root
(
directory
))
client_printf
(
client
,
"playlist: %s
\n
"
,
name_utf8
);
else
client_printf
(
client
,
"playlist: %s/%s
\n
"
,
directory_get_path
(
directory
),
name_utf8
);
}
/**
* Print a list of playlists in the specified directory.
*/
static
void
directory_print_playlists
(
struct
client
*
client
,
const
struct
directory
*
directory
)
{
for
(
const
struct
playlist_metadata
*
pm
=
directory
->
playlists
.
head
;
pm
!=
NULL
;
pm
=
pm
->
next
)
print_playlist_in_directory
(
client
,
directory
,
pm
->
name
);
}
void
directory_print
(
struct
client
*
client
,
const
struct
directory
*
directory
)
{
dirvec_print
(
client
,
&
directory
->
children
);
songvec_print
(
client
,
&
directory
->
songs
);
directory_print_playlists
(
client
,
directory
);
}
src/directory_print.h
deleted
100644 → 0
View file @
c779e267
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DIRECTORY_PRINT_H
#define MPD_DIRECTORY_PRINT_H
struct
client
;
struct
directory
;
void
directory_print
(
struct
client
*
client
,
const
struct
directory
*
directory
);
#endif
src/song_print.c
View file @
a236a439
...
...
@@ -94,18 +94,3 @@ song_print_info(struct client *client, struct song *song)
if
(
song
->
tag
)
tag_print
(
client
,
song
->
tag
);
}
static
int
song_print_info_x
(
struct
song
*
song
,
void
*
data
)
{
struct
client
*
client
=
data
;
song_print_info
(
client
,
song
);
return
0
;
}
void
songvec_print
(
struct
client
*
client
,
const
struct
songvec
*
sv
)
{
songvec_for_each
(
sv
,
song_print_info_x
,
client
);
}
src/song_print.h
View file @
a236a439
...
...
@@ -28,9 +28,6 @@ void
song_print_info
(
struct
client
*
client
,
struct
song
*
song
);
void
songvec_print
(
struct
client
*
client
,
const
struct
songvec
*
sv
);
void
song_print_uri
(
struct
client
*
client
,
struct
song
*
song
);
#endif
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