From c524506e04927a39648d47ba55af4fdff32faab6 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 28 Oct 2022 01:17:59 +0100 Subject: horrible makefile tricks, making the buffer thing actually buffer the buffers bufferously, properly, also fix typos --- .gitignore | 3 +++ Makefile | 7 ++++--- bee.c | 5 +++-- conf.h | 2 ++ irc.c | 14 +++++++++++++- util.c | 2 +- 6 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c484265 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +apiobot + diff --git a/Makefile b/Makefile index cb02b50..2269f1c 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ .POSIX: .SUFFIXES: .c .o -CFLAGS=-Wall CC=cc debug=-g -DDEBUG -DLOCAL +CFLAGS=$(MORE_CFLAGS) -Wall OBJS=bee.o irc.o util.o @@ -12,10 +12,11 @@ apiobot: $(OBJS) $(CC) $(CFLAGS) -o apiobot $(OBJS) debug: - $(CC) $(CFLAGS) $(debug) -o apiobot $(OBJS) + make apiobot MORE_CFLAGS="-DDEBUG -DLOCAL -g" + .c.o: - $(CC) -c $< $(CFLAGS) -o $@ + $(CC) $(CFLAGS) -c $< -o $@ run: all ./apiobot diff --git a/bee.c b/bee.c index f7d1270..41fc24d 100644 --- a/bee.c +++ b/bee.c @@ -3,11 +3,12 @@ #include + int main() { - if (!irc_connect()) { fputs("irc_connect\n",stderr); return 1; } - if (!irc_handshake()) { fputs("irc_handshake\n",stderr); return 1; } + if (irc_connect()) { fputs("falure in irc_connect\n",stderr); return 1; } + if (irc_handshake()) { fputs("failure in irc_handshake\n",stderr); return 1; } int x; do { diff --git a/conf.h b/conf.h index 80d7181..96fbce5 100644 --- a/conf.h +++ b/conf.h @@ -25,9 +25,11 @@ printf(name " [%s]\n",__xxx); \ free(__xxx); \ } while (0) + #define DPf(...) fprintf(stderr,__VA_ARGS__) #else #define DP(x) #define DPn(n,x,l) + #define DPf(...) #endif #define NICK "Bee" diff --git a/irc.c b/irc.c index 5c206bd..314c3b7 100644 --- a/irc.c +++ b/irc.c @@ -13,6 +13,8 @@ irc_connect() hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; + printf("connecting to %s:%s....\n",HOST,PORT); + int status; struct addrinfo *res; if ((status = getaddrinfo(HOST, PORT, &hints, &res)) != 0) { @@ -103,10 +105,16 @@ irc_recv() return -1; } + DPf("recieved %ld ",amt); + // find the end of a message char *c; char *end = recv_cur+amt; char *msg_start = recv_buf; + + + DPn("BUF",recv_buf,end-recv_buf); + for (c=recv_buf; c