diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..acf8873 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/libircclient"] + path = lib/libircclient + url = https://git.lain.church/emil/libircclient diff --git a/CHANGELOG b/CHANGELOG index 5b2d9dc..59011fe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,3 +15,6 @@ VERSION X Added -identify ircmsg is now more useful Fixed some error return values being too high +Changed NVULN to NO_VULN +Added ENABLE_SSL=1 to enable SSL incomplete support +Added libircclient submodule diff --git a/Makefile b/Makefile index 0eb0c10..8def37b 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,10 @@ PROGN:=probotic CFLAGS:=-std=c99 -Wall -Wextra -Wpedantic -Wvla -Wshadow -Wundef -CPPFLAGS:=-I/usr/include/libircclient/ -Iinclude -D_GNU_SOURCE -DPROGN=\"${PROGN}\" -D_FORTIFY_SOURCE=2 +CPPFLAGS:=-I./lib/libircclient/include/ -Iinclude -D_GNU_SOURCE -DPROGN=\"${PROGN}\" -D_FORTIFY_SOURCE=2 -LDLIBS:=-lircclient -lsqlite3 +LDLIBS:=-lsqlite3 +LIB:=./lib/libircclient/src/libircclient.o SRC := api.c irc.c main.c parse.c unity.c HDR := api.h error.h irc.h irccolors.h parse.h stmt.h @@ -20,16 +21,27 @@ ifdef SAN CFLAGS += -fsanitize=${SAN} endif -ifeq (${NVULN},1) +ifeq (${NO_VULN},1) CPPFLAGS += -DNO_VULN_COMMANDS endif +ifeq (${ENABLE_SSL},1) + LDLIBS += -lssl -lcrypto + CPPFLAGS += -DIRC_SSL_SUPPORT +endif + +all: ${PROGN} + ${PROGN}: ${HDR} ${SRC} - ${LINK.c} src/unity.c -o $@ ${LDLIBS} + ${LINK.c} -pipe ${LIB} src/unity.c -o $@ ${LDLIBS} # do nothing but update them... $(SRC) $(HDR): -.PHONY: clean +submodules: + git submodule update --init --recursive + clean: -rm ${OBJ} + +.PHONY: submodules clean diff --git a/lib/libircclient b/lib/libircclient new file mode 160000 index 0000000..76ae5fd --- /dev/null +++ b/lib/libircclient @@ -0,0 +1 @@ +Subproject commit 76ae5fd5e7a3789756bcf07c42d10a9685987ae9 diff --git a/src/api.c b/src/api.c index 13f8eec..1ac539d 100644 --- a/src/api.c +++ b/src/api.c @@ -7,7 +7,8 @@ VARDECL char const * db = DBFILE; VARDECL sqlite3 * connection = NULL; -DECL void DBERR(const int l){ +DECL void DBERR(const int l) +{ if(l != SQLITE_OK && l != SQLITE_ROW && l != SQLITE_DONE) { fprintf(stderr, @@ -34,13 +35,13 @@ api_init(void) DECL void api_rope(void) { - DBERR(sqlite3_finalize(remind_stmt)); - DBERR(sqlite3_finalize(set_repo_stmt)); - DBERR(sqlite3_finalize(get_nth_id_stmt)); - DBERR(sqlite3_finalize(new_assignment_stmt)); - DBERR(sqlite3_finalize(purge_assignments_stmt)); - DBERR(sqlite3_finalize(is_no_assignment_stmt)); - sqlite3_close(connection); + DBERR(sqlite3_finalize(remind_stmt)); + DBERR(sqlite3_finalize(set_repo_stmt)); + DBERR(sqlite3_finalize(get_nth_id_stmt)); + DBERR(sqlite3_finalize(new_assignment_stmt)); + DBERR(sqlite3_finalize(purge_assignments_stmt)); + DBERR(sqlite3_finalize(is_no_assignment_stmt)); + sqlite3_close(connection); } DECL void diff --git a/src/irc.c b/src/irc.c index 26bf4d0..42e8362 100644 --- a/src/irc.c +++ b/src/irc.c @@ -159,13 +159,17 @@ init(void) ERRMSG("Error creating IRC session"); goto fail; } + atexit(rope); assert(creds.username != NULL); assert(creds.server != NULL); - irc_connect(session, - creds.server, creds.port, creds.password, - creds.username, creds.username, creds.username); + if (irc_connect(session, + creds.server, creds.port, creds.password, + creds.username, creds.username, creds.username)) + { + fprintf(stderr, "IRC ERROR: %s\n", irc_strerror(irc_errno(session))); + exit(1); + } FULL_FREE(creds.password); - atexit(rope); return 0; fail: FULL_FREE(creds.password); diff --git a/src/unity.o b/src/unity.o new file mode 100644 index 0000000..884780a Binary files /dev/null and b/src/unity.o differ