Various refinements

This commit is contained in:
Emil 2023-08-02 13:45:42 -06:00
parent ee94922b48
commit 2bca0f6fea
4 changed files with 25 additions and 48 deletions

View File

@ -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"

View File

@ -21,49 +21,46 @@
#include <stdio.h>
#include <stdlib.h>
#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; }
}

View File

@ -22,28 +22,7 @@
#include <string.h>
#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,

View File

@ -1,3 +1,4 @@
#define DELC static
#include "irc.c"
#include "api.c"
#include "parse.c"