~aritra1911/mc_server

457e33f93461bea4851f6282054e10ddf61dccef — Aritra Sarkar 1 year, 11 months ago 237d474
Be c89 friendly
4 files changed, 17 insertions(+), 7 deletions(-)

M Makefile
M Makefile.gmake
M common.h
M response.c
M Makefile => Makefile +4 -1
@@ 5,15 5,18 @@ PROGS				=	server
CFLAGS				=	-std=iso9899:1999 -pedantic -pedantic-errors -Wall -Wextra \
					-Werror-implicit-function-declaration -Wno-reserved-id-macro \
					-Wno-missing-prototypes -Wno-thread-safety-analysis -Wno-padded \
					-Wno-cast-align -g -O0 -fno-fast-math -fno-builtin
					-Wno-cast-align -Wno-comma -g -O0 -fno-fast-math -fno-builtin

CFLAGS_x86_64-linux-gcc		=	-m64
CFLAGS_i686-linux-gcc		=	-m32
CFLAGS_x86_64-linux-clang	=	-Weverything -m64
CFLAGS_i686-linux-clang		=	-Weverything -m32
CFLAGS_amd64-freebsd-clang	=	-Weverything -m64
CFLAGS_i686-freebsd-clang	=	-Weverything -m32

CPPFLAGS			=	-D_XOPEN_SOURCE=600 -D_POSIX_PTHREAD_SEMANTICS \
					-D_LARGEFILE64_SOURCE

LDFLAGS				=	-pthread

server_SRCS			=	main.c session.c response.c tpool.c events.c helpers.c

M Makefile.gmake => Makefile.gmake +6 -1
@@ 1,11 1,16 @@

CFLAGS		=	-std=iso9899:1999 -pedantic -pedantic-errors -Wall -Wextra \
			-Werror-implicit-function-declaration -Wno-reserved-id-macro \
			-Wno-missing-prototypes -Wno-thread-safety-analysis -Wno-padded \
			-Wno-cast-align -g -O0 -fno-fast-math -fno-builtin
			-Wno-cast-align -Wno-comma -g -O0 -fno-fast-math -fno-builtin

CPPFLAGS	=	-D_XOPEN_SOURCE=600 -D_POSIX_PTHREAD_SEMANTICS \
			-D_LARGEFILE64_SOURCE

LDFLAGS		=	-pthread

SRCS		=	main.c session.c response.c tpool.c events.c helpers.c

OBJS		=	$(SRCS:.c=.o)

.PHONY: all clean

M common.h => common.h +3 -3
@@ 30,7 30,7 @@ typedef enum {
    SND_JOIN,       /* Join */
    SND_SETNICK,    /* Change nick */
    SND_ACTION,     /* Perform an action */
    SND_QUIT,       /* Quit */
    SND_QUIT        /* Quit */
} SendCode;

typedef enum _ResponseCode {


@@ 39,7 39,7 @@ typedef enum _ResponseCode {
    RES_SETNICK,    /* Nick changes */
    RES_ACTION,     /* Actions */
    RES_QUIT,       /* User quits or disconnects */
    RES_ERROR,      /* User did something wrong */
    RES_ERROR       /* User did something wrong */
} ResponseCode;

typedef enum {


@@ 49,7 49,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 */
    IN_SEND_CODE        /* Client sent an unknown send code */
} ResponseError;

#endif

M response.c => response.c +4 -2
@@ 63,7 63,9 @@ static int
nick_exists(const char *nick, const client_t *client,
            const client_t *clients_list, size_t list_size)
{
    for (size_t i = 0; i < list_size; i++) {
    size_t  i;

    for (i = 0; i < list_size; i++) {
        if ( client != &clients_list[i] &&  /* skip self */
             !strcmp(nick, clients_list[i].nick) ) {
            return 0;


@@ 73,7 75,7 @@ nick_exists(const char *nick, const client_t *client,
    return -1;
}

static inline int
static int
set_nick(SendCode snd_code, client_t *client, const client_t *clients_list,
         size_t list_size, char *buf, ssize_t *len, ResponseError *err_code)
{