This commit is contained in:
Your Name 2025-06-28 10:58:12 +03:00
parent 718f290ba4
commit 73b55ebd79
3 changed files with 103 additions and 64 deletions

85
C/irc.h
View file

@ -4,15 +4,15 @@
Dont support:
ddc
ipv6
motd
*/
#ifndef _IRCC_H
#define _IRCC_H
#define IRCC_PING_TIMEOUT 600
#define IRCC_VERSION "2.1.0b"
#define IRCC_VERSION "2.1.0"
#include <stdarg.h>
#if defined(ENABLE_SSL) || defined(ENABLE_TLS)
#include <openssl/ssl.h>
#endif
@ -34,43 +34,74 @@ enum {
IRCC_MODE
};
static const char *IRCC_ERROR_MSGS[] = {
"IRCC_ALLOC",
"IRCC_DISCONNECTED",
"IRCC_ERROR",
};
#define IRCC_GET_ERROR(n) (IRCC_ERROR_MSGS[n + 3])
#ifndef IRCC_FMT
#define IRCC_FMT
enum {
IRCC_FMT_SEND,
IRCC_FMT_TOPIC,
IRCC_FMT_USER,
IRCC_FMT_NICK,
IRCC_FMT_PASS,
IRCC_FMT_JOIN,
IRCC_FMT_JOIN_PASS,
_IRCC_FMT_MAX
};
typedef struct {
int irc_connected;
int irc_socket;
static const char *IRCC_FMTS[] = {
"PRIVMSG %s :%s\r\n",
"TOPIC %s :%s\r\n",
"USER %s %s %s %s\r\n",
"NICK %s\r\n",
"PASS %s\r\n",
"JOIN %s\r\n",
"JOIN %s :%s\r\n",
};
int irc_alloc;
char *irc_raw;
#define IRCC_GET_CMD(n) ((n >= _IRCC_FMT_MAX) ? "error" : IRCC_FMTS[n])
#endif
/* RONLY */
char *irc_msg;
char *irc_channel;
char *irc_nick;
#ifndef IRCC_ERR_STR
#define IRCC_ERR_STR
static const char *IRCC_ERROR_MSGS[] = {
"IRCC_ALLOC",
"IRCC_DISCONNECTED",
"IRCC_ERROR",
};
#define IRCC_GET_ERROR(n) ((n >= sizeof(IRCC_ERROR_MSGS) / sizeof(char *)) ? "error" : IRCC_ERROR_MSGS[n + 3])
#endif
#ifndef IRCC_CLIENT
#define IRCC_CLIENT
typedef struct {
int irc_connected;
int irc_socket;
int irc_alloc;
char *irc_raw;
#if defined(ENABLE_SSL) || defined(ENABLE_TLS)
/* RONLY */
int irc_usingssl;
char *irc_msg;
char *irc_channel;
char *irc_nick;
SSL_METHOD *irc_sslmethod;
SSL_CTX *irc_sslctx;
SSL *irc_ssl;
#endif
#if defined(ENABLE_SSL) || defined(ENABLE_TLS)
/* RONLY */
int irc_usingssl;
} IRCC_client;
SSL_METHOD *irc_sslmethod;
SSL_CTX *irc_sslctx;
SSL *irc_ssl;
#endif
} IRCC_client;
#endif
int IRCC_connect(IRCC_client *irc, const char *ip, const int port);
int IRCC_recv(IRCC_client *irc);
int IRCC_parse(IRCC_client *irc);
int IRCC_register(IRCC_client *irc, const char *nickname);
int IRCC_join(IRCC_client *irc, const char *channel, const char *key);
int IRCC_send(IRCC_client *irc, const char *channel, const char *msg);
int IRCC_send(IRCC_client *irc, const char *fmt, ...);
int IRCC_initssl(IRCC_client *irc);
void IRCC_close(IRCC_client *irc);