Code

screen_client: screen_auth() returns bool
authorMax Kellermann <max@duempel.org>
Tue, 29 Sep 2009 18:36:07 +0000 (20:36 +0200)
committerMax Kellermann <max@duempel.org>
Tue, 29 Sep 2009 18:36:07 +0000 (20:36 +0200)
true for success, false for error.

src/mpdclient.c
src/screen_client.c
src/screen_client.h

index 1434d172acd62f926c1acd630d455a3f2d62a6d0..6eb41448264c056ae38dfaa21de25d8807f0087d 100644 (file)
@@ -112,7 +112,7 @@ mpdclient_handle_error(struct mpdclient *c)
 
        if (error == MPD_ERROR_SERVER &&
            mpd_connection_get_server_error(c->connection) == MPD_SERVER_ERROR_PERMISSION &&
-           screen_auth(c) == 0)
+           screen_auth(c))
                return 0;
 
        if (error == MPD_ERROR_SERVER)
index 397a7cb474658b958b9a7abc9004f2cfdadff21c..7583e8a15e476d434a6f1c62dd507ee483acdf48 100644 (file)
 #include "screen_utils.h"
 #include "mpdclient.h"
 
-static gint
+static bool
 _screen_auth(struct mpdclient *c, gint recursion)
 {
        char *password;
 
        mpd_connection_clear_error(c->connection);
        if (recursion > 2)
-               return 1;
+               return false;
 
        password = screen_read_password(NULL, NULL);
        if (password == NULL)
-               return 1;
+               return false;
 
        mpd_send_password(c->connection, password);
        g_free(password);
@@ -43,10 +43,11 @@ _screen_auth(struct mpdclient *c, gint recursion)
        if (mpd_connection_get_error(c->connection) == MPD_ERROR_SERVER &&
            mpd_connection_get_server_error(c->connection) == MPD_SERVER_ERROR_PASSWORD)
                return  _screen_auth(c, ++recursion);
-       return 0;
+
+       return true;
 }
 
-gint
+bool
 screen_auth(struct mpdclient *c)
 {
        return _screen_auth(c, 0);
index 73e90d523cb58c61b5fb4b8eb7750c4a33b02873..9b419d148e175ddf84b86de383e56f95217cab9b 100644 (file)
 #ifndef NCMPC_SCREEN_CLIENT_H
 #define NCMPC_SCREEN_CLIENT_H
 
-#include <glib.h>
+#include <stdbool.h>
 
 struct mpdclient;
 
-gint
+bool
 screen_auth(struct mpdclient *c);
 
 #endif