~aritra1911/mc_client

1b5427ed6427e0c44dbf4c63bfe3902f14dfe673 — Aritra Sarkar 2 years ago 4f43aa8 send_codes
Describe invalid send code response error
2 files changed, 11 insertions(+), 10 deletions(-)

M common.h
M message.c
M common.h => common.h +1 -0
@@ 47,6 47,7 @@ typedef enum {
    NICK_TAKEN,         /* User tried to reuse someone else's nick */
    EMPTY_NICK,         /* User setnicked to nothing */
    NO_NICK_CHANGE,     /* User changed to the same nick */
    IN_SEND_CODE,       /* Client sent an unknown send code */
} ResponseError;

#endif

M message.c => message.c +10 -10
@@ 25,41 25,41 @@
#include "common.h"
#include "message.h"

int
describe_error(ResponseError err_code, char *description)
int describe_error(ResponseError err_code, char *description)
{
    switch ( err_code ) {

    case COMMAND_OK:
        strcpy(description, "Everything is OK!");
        break;
        return 0;

    case COMMAND_INVALID:
        strcpy(description, "Command not recognized.");
        break;
        return 0;

    case NO_NICK:
        strcpy(description, "You don't have a nick yet. "
                            "Issue '/setnick <nick>' to set your nick.");
        break;
        return 0;

    case NICK_TAKEN:
        strcpy(description, "Nick already exists.");
        break;
        return 0;

    case EMPTY_NICK:
        strcpy(description, "You cannot change to a null nick.");
        break;
        return 0;

    case NO_NICK_CHANGE:
        strcpy(description, "No change in user's nick.");
        break;
        return 0;

    default:
    case IN_SEND_CODE:
        strcpy(description, "You shouldn't be seeing this.");
        return -1;
    }

    return 0;
    return -1;
}

int parse_response(const char *buf, int len, Message *msg)