-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.c
27 lines (23 loc) · 721 Bytes
/
util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "util.h"
#include <mpd/client.h>
#include <stdlib.h>
#include "log.h"
void __attribute__((noreturn))
die(struct mpd_connection *connection, struct mpd_status *status, struct mpd_song *song, const char *msg) {
log_fatal("%s", msg);
if (connection) {
mpd_connection_free(connection);
}
if (status) {
mpd_status_free(status);
}
if (song) {
mpd_song_free(song);
}
exit(EXIT_FAILURE);
}
void mpd_check_error(struct mpd_connection *connection, struct mpd_status *status, struct mpd_song *song) {
if (mpd_connection_get_error(connection) != MPD_ERROR_SUCCESS) {
die(connection, status, song, mpd_connection_get_error_message(connection));
}
}