added ssl support
This commit is contained in:
parent
b4825a3fb7
commit
de4223170b
7 changed files with 117 additions and 111 deletions
39
C/irc.h
39
C/irc.h
|
@ -1,16 +1,22 @@
|
|||
/*
|
||||
LICENSE: WTFPL
|
||||
Simple libary for working with ipv4 irc servers
|
||||
Simple library for working with ipv4 irc servers
|
||||
Dont support:
|
||||
ssl
|
||||
ddc
|
||||
ipv6
|
||||
motd
|
||||
*/
|
||||
|
||||
#ifndef _IRCC_H
|
||||
#define _IRCC_H
|
||||
|
||||
#define IRCC_MSG_MAX 512
|
||||
#define IRCC_PING_TIMEOUT 600
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
IRCC_NICK = 1,
|
||||
IRCC_PRIVMSG,
|
||||
|
@ -26,6 +32,19 @@ enum {
|
|||
IRCC_SUCCESS
|
||||
};
|
||||
|
||||
enum {
|
||||
IRCC_SSL_INIT = 1,
|
||||
IRCC_SSL_METHOD,
|
||||
IRCC_SSL_SESSION
|
||||
};
|
||||
|
||||
static const char *IRCC_errno[] = {
|
||||
"",
|
||||
"Could not initialize the SSL library",
|
||||
"Unable to create a new SSL context struct",
|
||||
"Could not build a SSL session"
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int irc_socket;
|
||||
|
||||
|
@ -33,6 +52,14 @@ typedef struct {
|
|||
char *irc_msg;
|
||||
char *irc_channel;
|
||||
char *irc_nick;
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
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 unsigned int port);
|
||||
|
@ -41,5 +68,11 @@ int IRCC_parse(IRCC_client *irc);
|
|||
int IRCC_join(IRCC_client *irc, const char *channel, const char *key);
|
||||
int IRCC_send(IRCC_client *irc, const char *msg, const char *channel);
|
||||
int IRCC_register(IRCC_client *irc, const char *nickname);
|
||||
void IRCC_init(IRCC_client *irc);
|
||||
int IRCC_initssl(IRCC_client *irc, int *ircc_errno);
|
||||
void IRCC_close(IRCC_client *irc);
|
||||
|
||||
//u - mean universal. Functions uses internal fields in structure
|
||||
int IRCC_usend(IRCC_client *irc, off_t bytes);
|
||||
int IRCC_urecv(IRCC_client *irc);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue