2015-03-24 03:12:35 -07:00
|
|
|
/*
|
|
|
|
* xbot: Just another IRC bot
|
|
|
|
*
|
|
|
|
* Written by Aaron Blakely <aaron@ephasic.org>
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef IRC_H
|
|
|
|
#define IRC_H
|
|
|
|
|
2024-03-09 01:38:58 -08:00
|
|
|
#define VERSION "0.1.0"
|
|
|
|
|
2015-03-24 03:12:35 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2024-03-06 01:45:01 -08:00
|
|
|
#include "util.h"
|
2024-03-05 18:12:10 -08:00
|
|
|
#include "db.h"
|
|
|
|
|
2024-03-12 17:38:52 -07:00
|
|
|
#define OUTBUF_SIZE 1200000
|
|
|
|
#define INBUF_SIZE 1200000
|
2024-03-13 04:50:58 -07:00
|
|
|
|
2024-03-11 03:22:05 -07:00
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#include <openssl/err.h>
|
2024-03-13 04:50:58 -07:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#else
|
|
|
|
#include <stdbool.h>
|
2024-02-12 23:22:10 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2015-03-24 03:12:35 -07:00
|
|
|
struct irc_conn
|
|
|
|
{
|
2024-02-12 23:22:10 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
SOCKET srv_fd;
|
|
|
|
#else
|
2015-03-24 03:12:35 -07:00
|
|
|
FILE *srv_fd;
|
2024-03-13 04:50:58 -07:00
|
|
|
#endif
|
|
|
|
|
2024-03-11 03:22:05 -07:00
|
|
|
int ssl_fd;
|
|
|
|
SSL *ssl;
|
|
|
|
SSL_CTX *ctx;
|
2015-03-24 03:12:35 -07:00
|
|
|
|
2024-03-09 01:57:13 -08:00
|
|
|
char nick[50];
|
|
|
|
char user[50];
|
2024-03-07 22:38:00 -08:00
|
|
|
char admin[256];
|
2024-02-12 23:22:10 -08:00
|
|
|
char host[256];
|
|
|
|
char port[5];
|
|
|
|
char real_name[512];
|
2015-03-24 03:12:35 -07:00
|
|
|
|
2024-03-11 03:22:05 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
BOOL use_ssl;
|
|
|
|
BOOL verify_ssl;
|
|
|
|
#else
|
|
|
|
bool use_ssl;
|
|
|
|
bool verify_ssl;
|
|
|
|
#endif
|
|
|
|
|
2024-03-05 18:12:10 -08:00
|
|
|
char db_file[256];
|
2024-03-09 00:40:06 -08:00
|
|
|
char log_file[256];
|
2024-03-05 18:12:10 -08:00
|
|
|
struct db_table *db;
|
|
|
|
|
2024-02-12 23:22:10 -08:00
|
|
|
// I/O Buffers
|
2024-02-23 17:57:59 -08:00
|
|
|
char *out;
|
|
|
|
char *in;
|
2015-03-24 03:12:35 -07:00
|
|
|
};
|
|
|
|
|
2024-02-12 23:22:10 -08:00
|
|
|
typedef struct handler event_handler;
|
|
|
|
|
2024-02-16 13:28:11 -08:00
|
|
|
void irc_connect(struct irc_conn *bot);
|
|
|
|
void irc_auth(struct irc_conn *bot);
|
|
|
|
|
2024-02-12 23:22:10 -08:00
|
|
|
MY_API void irc_notice(struct irc_conn *bot, char *to, char *fmt, ...);
|
|
|
|
MY_API void irc_privmsg(struct irc_conn *bot, char *to, char *fmt, ...);
|
|
|
|
MY_API void irc_raw(struct irc_conn *bot, char *fmt, ...);
|
2024-02-16 13:28:11 -08:00
|
|
|
MY_API void irc_join(struct irc_conn *bot, char *channel);
|
|
|
|
MY_API void irc_part(struct irc_conn *bot, char *channel, char *reason);
|
2024-02-23 17:57:59 -08:00
|
|
|
MY_API void irc_ban(struct irc_conn *bot, char *channel, char *nick);
|
|
|
|
MY_API void irc_kick(struct irc_conn *bot, char *channel, char *user, char *reason);
|
|
|
|
MY_API void irc_mode(struct irc_conn *bot, char *channel, char *mode);
|
2024-03-02 00:11:50 -08:00
|
|
|
MY_API void irc_ctcp(struct irc_conn *bot, char *to, char *fmt, ...);
|
2024-02-16 13:28:11 -08:00
|
|
|
|
|
|
|
void irc_parse_raw(struct irc_conn *bot, char *raw);
|
2015-03-24 03:12:35 -07:00
|
|
|
|
2024-03-07 22:38:00 -08:00
|
|
|
#ifdef _WIN32
|
|
|
|
MY_API BOOL check_hostmask_match(char *mask, char *host);
|
|
|
|
#else
|
|
|
|
MY_API bool check_hostmask_match(char *mask, char *host);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2016-02-21 20:40:41 -08:00
|
|
|
#endif
|