Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

connection: moved code to error.c

  • Loading branch information...
commit 31f6bba346347d572dfd3d957518c69cfd1af221 1 parent 405e42e
@MaxKellermann MaxKellermann authored
Showing with 71 additions and 38 deletions.
  1. +1 −0  Makefile.am
  2. +0 −38 src/connection.c
  3. +70 −0 src/error.c
View
1  Makefile.am
@@ -48,6 +48,7 @@ src_libmpdclient_la_SOURCES = \
src/database.c \
src/directory.c \
src/rdirectory.c \
+ src/error.c \
src/output.c \
src/coutput.c \
src/entity.c \
View
38 src/connection.c
@@ -217,44 +217,6 @@ mpd_connection_new_async(struct mpd_async *async, const char *welcome)
return connection;
}
-enum mpd_error
-mpd_get_error(const struct mpd_connection *connection)
-{
- return connection->error.code;
-}
-
-const char *
-mpd_get_error_message(const struct mpd_connection *connection)
-{
- assert(connection->error.code != MPD_ERROR_SUCCESS);
- assert(connection->error.message != NULL ||
- connection->error.code == MPD_ERROR_OOM);
-
- if (connection->error.message == NULL)
- return "Out of memory";
-
- return connection->error.message;
-}
-
-enum mpd_ack
-mpd_get_server_error(const struct mpd_connection *connection)
-{
- assert(connection->error.code == MPD_ERROR_ACK);
-
- return connection->error.ack;
-}
-
-bool
-mpd_clear_error(struct mpd_connection *connection)
-{
- if (mpd_error_is_fatal(&connection->error))
- /* impossible to recover */
- return false;
-
- mpd_error_clear(&connection->error);
- return true;
-}
-
void mpd_connection_free(struct mpd_connection *connection)
{
assert(connection->pair_state != PAIR_STATE_FLOATING);
View
70 src/error.c
@@ -0,0 +1,70 @@
+/* libmpdclient
+ (c) 2003-2009 The Music Player Daemon Project
+ This project's homepage is: http://www.musicpd.org
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <mpd/connection.h>
+#include "internal.h"
+
+#include <assert.h>
+
+enum mpd_error
+mpd_get_error(const struct mpd_connection *connection)
+{
+ return connection->error.code;
+}
+
+const char *
+mpd_get_error_message(const struct mpd_connection *connection)
+{
+ assert(connection->error.code != MPD_ERROR_SUCCESS);
+ assert(connection->error.message != NULL ||
+ connection->error.code == MPD_ERROR_OOM);
+
+ if (connection->error.message == NULL)
+ return "Out of memory";
+
+ return connection->error.message;
+}
+
+enum mpd_ack
+mpd_get_server_error(const struct mpd_connection *connection)
+{
+ assert(connection->error.code == MPD_ERROR_ACK);
+
+ return connection->error.ack;
+}
+
+bool
+mpd_clear_error(struct mpd_connection *connection)
+{
+ if (mpd_error_is_fatal(&connection->error))
+ /* impossible to recover */
+ return false;
+
+ mpd_error_clear(&connection->error);
+ return true;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.