hibot/source/main.c

53 lines
742 B
C
Raw Normal View History

2023-12-15 17:45:27 -05:00
#define PROGRAM_NAME "hibot"
2023-12-15 18:23:46 -05:00
#define _GNU_SOURCE
2023-12-15 17:45:27 -05:00
#include "config.inc"
char * channel;
char * server;
char * port;
#include <stdio.h>
FILE * log_file;
#include "log.h"
2023-12-15 18:27:56 -05:00
#include "syntax.h"
2023-12-15 17:45:27 -05:00
#include "bot.h"
const char help_message[] =
PROGRAM_NAME " <server>:<port> <channel>\n"
;
signed main(int argc, char * * argv) {
if (argc != 3) {
goto USAGE_ERROR;
}
channel = argv[2];
server = strdup(argv[1]);
port = strchr(server, ':');
if (port) {
*port = '\0';
} else {
goto USAGE_ERROR;
}
++port;
int port_i = 0;
if(!sscanf(port, "%hd", &port_i)) {
goto USAGE_ERROR;
}
log_file = stdout;
2023-12-15 18:27:56 -05:00
syntax_c();
2023-12-15 18:23:46 -05:00
connect_bot(server, port_i);
2023-12-15 17:45:27 -05:00
connection_loop();
return 0;
USAGE_ERROR:
puts(help_message);
return 1;
}