diff --git a/build.sh b/build.sh index ccda8c3..8dc04fc 100755 --- a/build.sh +++ b/build.sh @@ -8,8 +8,8 @@ PROGN=${PROGN:-probotic} PREFIX=${PREFIX:-$DIR} CC=${CC-cc} -CFLAGS='-std=c99 -Wall -Wextra -Wpedantic' -CPPFLAGS="-I/usr/include/libircclient/ -Iinclude -D_GNU_SOURCE -DDELC=static -DPROGN=\"$PROGN\"" +CFLAGS='-std=c99 -Wall -Wextra -Wpedantic -Wno-unused-function' +CPPFLAGS="-I/usr/include/libircclient/ -Iinclude -D_GNU_SOURCE -DPROGN=\"$PROGN\"" LDFLAGS='-lircclient -lsqlite3' mkdir -p $PREFIX && echo "Made directory: $PREFIX" diff --git a/src/main.c b/src/main.c index 51b8039..c11583b 100644 --- a/src/main.c +++ b/src/main.c @@ -21,49 +21,46 @@ #include #include -#include "utils.h" +#include "error.h" #include "irc.h" - -/* args: server port channel [username] - username defaults to probotic */ - -extern void rope(void); +#include "api.h" /* args: server port channel [username] - defaults to probotic */ -/* I'd have to give up constification for server:port */ int main(int argc, char const ** argv) { - char const * username; - char const * server; - int port; + + /* Usage */ if (argc > 5 || argc < 4) { ERRMSG("server port channel [username]"); return 1; } - if (argc > 4) - { username = argv[4]; } else - { username = "probotic"; } - channel = argv[3]; - port = atoi(argv[2]); - server = argv[1]; -#ifdef NDEBUG - fprintf(stderr, "-- %s:%d %s %s --\n", server, port, channel, username); -#endif /* NDEBUG */ - if (!init(username, server, port)) { + /* Arguments */ + char const * username = "probotic"; + char const * server = argv[1]; + int const port = atoi(argv[2]); + channel = argv[3]; + + if (argc > 4) + { username = argv[4]; } + +#ifdef NDEBUG + fprintf(stderr, "-- %s:%d %s %s --\n", server, port, channel, username); +#endif /* NDEBUG */ + + /* initialization (1 means bad , 0 mean good > ; ) */ + if (init(username, server, port)) + { return 1; } atexit(rope); /* We should figure out how the failure happens so we can tell the user that. */ if (irc_run(session) != 0) { ERR(1, "Error running IRC session\nPossible issue: bad URL," - " no network connection, bad port, refused connection."); } - irc_destroy_session(session); + " no network connection, bad port, refused connection."); } return 0; } - else - { return 1; } } diff --git a/src/parse.c b/src/parse.c index a7b6d41..41c9781 100644 --- a/src/parse.c +++ b/src/parse.c @@ -22,28 +22,7 @@ #include #include "parse.h" -#include "utils.h" - -/* possibly globalize creds so that we can ensure by using - atexit that it is always cleansed? */ - -/* these are closer described as 'setters', no? */ - -DELC int -parse_remind(char const * arg) -{ - (void) arg; - ERRMSG("not implemented"); - return 0; -} - -DELC int -parse_repo(char const * arg) -{ - (void) arg; - ERRMSG("not implemented"); - return 0; -} +#include "error.h" DELC int parse_creds(creds_t * creds, diff --git a/src/unity.c b/src/unity.c index 3d00a80..fe67c9e 100644 --- a/src/unity.c +++ b/src/unity.c @@ -1,3 +1,4 @@ +#define DELC static #include "irc.c" #include "api.c" #include "parse.c"