Commit a6c5928c authored by Max Kellermann's avatar Max Kellermann

stats: don't pass "fd" to printStats()

Pass the client struct instead of the raw file descriptor.
parent 93e6d4c3
...@@ -999,7 +999,7 @@ static int handleRandom(struct client *client, mpd_unused int *permission, ...@@ -999,7 +999,7 @@ static int handleRandom(struct client *client, mpd_unused int *permission,
static int handleStats(struct client *client, mpd_unused int *permission, static int handleStats(struct client *client, mpd_unused int *permission,
mpd_unused int argc, mpd_unused char *argv[]) mpd_unused int argc, mpd_unused char *argv[])
{ {
return printStats(client_get_fd(client)); return printStats(client);
} }
static int handleClearError(mpd_unused struct client *client, mpd_unused int *permission, static int handleClearError(mpd_unused struct client *client, mpd_unused int *permission,
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "directory.h" #include "directory.h"
#include "tag.h" #include "tag.h"
#include "myfprintf.h" #include "client.h"
#include "player_control.h" #include "player_control.h"
#include "tagTracker.h" #include "tagTracker.h"
#include "os_compat.h" #include "os_compat.h"
...@@ -33,15 +33,22 @@ void initStats(void) ...@@ -33,15 +33,22 @@ void initStats(void)
stats.numberOfSongs = 0; stats.numberOfSongs = 0;
} }
int printStats(int fd) int printStats(struct client *client)
{ {
fdprintf(fd, "artists: %i\n", getNumberOfTagItems(TAG_ITEM_ARTIST)); client_printf(client,
fdprintf(fd, "albums: %i\n", getNumberOfTagItems(TAG_ITEM_ALBUM)); "artists: %i\n"
fdprintf(fd, "songs: %i\n", stats.numberOfSongs); "albums: %i\n"
fdprintf(fd, "uptime: %li\n", time(NULL) - stats.daemonStart); "songs: %i\n"
fdprintf(fd, "playtime: %li\n", "uptime: %li\n"
(long)(getPlayerTotalPlayTime() + 0.5)); "playtime: %li\n"
fdprintf(fd, "db_playtime: %li\n", stats.dbPlayTime); "db_playtime: %li\n"
fdprintf(fd, "db_update: %li\n", getDbModTime()); "db_update: %li\n",
getNumberOfTagItems(TAG_ITEM_ARTIST),
getNumberOfTagItems(TAG_ITEM_ALBUM),
stats.numberOfSongs,
time(NULL) - stats.daemonStart,
(long)(getPlayerTotalPlayTime() + 0.5),
stats.dbPlayTime,
getDbModTime());
return 0; return 0;
} }
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#ifndef STATS_H #ifndef STATS_H
#define STATS_H #define STATS_H
struct client;
typedef struct _Stats { typedef struct _Stats {
unsigned long daemonStart; unsigned long daemonStart;
int numberOfSongs; int numberOfSongs;
...@@ -31,6 +33,6 @@ extern Stats stats; ...@@ -31,6 +33,6 @@ extern Stats stats;
void initStats(void); void initStats(void);
int printStats(int fd); int printStats(struct client *client);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment