81 lines
1.5 KiB
C
81 lines
1.5 KiB
C
/*
|
|
LICENSE: WTFPL
|
|
Simple library for working with ipv4 irc servers
|
|
Dont support:
|
|
ddc
|
|
ipv6
|
|
motd
|
|
*/
|
|
|
|
#ifndef _IRCC_H
|
|
#define _IRCC_H
|
|
|
|
#define IRCC_PING_TIMEOUT 600
|
|
#define IRCC_VERSION "2.1.0b"
|
|
|
|
#if defined(ENABLE_SSL) || defined(ENABLE_TLS)
|
|
#include <openssl/ssl.h>
|
|
#endif
|
|
|
|
enum {
|
|
IRCC_ALLOC = -3,
|
|
IRCC_DISCONNECTED,
|
|
IRCC_ERROR,
|
|
|
|
IRCC_CONNECTED,
|
|
IRCC_SUCCESS,
|
|
|
|
IRCC_NICK,
|
|
IRCC_PRIVMSG,
|
|
IRCC_JOIN,
|
|
IRCC_QUIT,
|
|
IRCC_PING,
|
|
IRCC_TOPIC,
|
|
IRCC_MODE
|
|
};
|
|
|
|
static const char *IRCC_ERROR_MSGS[] = {
|
|
"IRCC_ALLOC",
|
|
"IRCC_DISCONNECTED",
|
|
"IRCC_ERROR",
|
|
};
|
|
|
|
#define IRCC_GET_ERROR(n) (IRCC_ERROR_MSGS[n + 3])
|
|
|
|
typedef struct {
|
|
int irc_connected;
|
|
int irc_socket;
|
|
|
|
int irc_alloc;
|
|
char *irc_raw;
|
|
|
|
/* RONLY */
|
|
char *irc_msg;
|
|
char *irc_channel;
|
|
char *irc_nick;
|
|
|
|
#if defined(ENABLE_SSL) || defined(ENABLE_TLS)
|
|
/* RONLY */
|
|
int irc_usingssl;
|
|
|
|
SSL_METHOD *irc_sslmethod;
|
|
SSL_CTX *irc_sslctx;
|
|
SSL *irc_ssl;
|
|
#endif
|
|
|
|
} IRCC_client;
|
|
|
|
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_initssl(IRCC_client *irc);
|
|
void IRCC_close(IRCC_client *irc);
|
|
|
|
/* Raw data operations. Uses tls when possible */
|
|
int IRCC_usend(IRCC_client *irc, const char *msg, const size_t size);
|
|
int IRCC_urecv(IRCC_client *irc, char **buf, const size_t size);
|
|
|
|
#endif
|