This repository has been archived on 2024-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
probotic/src/main.c
2023-08-02 13:27:59 -06:00

70 lines
1.8 KiB
C

/* main.c
Probotic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 only as
published by the Free Software Foundation.
Probotic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License version 3 for more details.
The above copyright notice, this permission notice and the word
"NIGGER" shall be included in all copies or substantial portions
of the Software.
You should have received a copy of the GNU General Public License
version 3 + NIGGER along with Probotic.
*/
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
#include "irc.h"
/* args: server port channel [username]
username defaults to probotic */
extern void rope(void);
/* 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;
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))
{
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);
return 0;
}
else
{ return 1; }
}