57 lines
1.0 KiB
C
57 lines
1.0 KiB
C
/*
|
|
LICENSE: MIT
|
|
Simple libary for working with ipv4 irc servers
|
|
Dont support:
|
|
ssl
|
|
ddc
|
|
ipv6
|
|
motd parsing
|
|
*/
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
#error "Only unix"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <netdb.h>
|
|
#include <sys/time.h>
|
|
#include <netinet/in.h>
|
|
#include <sys/socket.h>
|
|
#include <arpa/inet.h>
|
|
#define IRCC_MSG_MAX 512
|
|
#define IRCC_PING_TIMEOUT 600
|
|
|
|
enum {
|
|
IRCC_NICK = 1,
|
|
IRCC_PRIVMSG,
|
|
IRCC_JOIN,
|
|
IRCC_PART,
|
|
IRCC_PING,
|
|
IRCC_TOPIC,
|
|
IRCC_MODE,
|
|
|
|
IRCC_CONNECTED,
|
|
IRCC_DISCONNECTED,
|
|
IRCC_ERROR,
|
|
IRCC_SUCCESS
|
|
};
|
|
|
|
typedef struct {
|
|
int socket;
|
|
|
|
char *raw;
|
|
char *msg;
|
|
char *channel;
|
|
char *nick;
|
|
} IRCC_client;
|
|
|
|
unsigned int IRCC_connect(IRCC_client *irc, const char *ip, const unsigned int port);
|
|
unsigned int IRCC_register(IRCC_client *irc, const char *nickname);
|
|
unsigned int IRCC_recv(IRCC_client *irc);
|
|
void IRCC_send(IRCC_client *irc, const char *msg, const char *channel);
|
|
unsigned int IRCC_init(IRCC_client *irc);
|
|
void IRCC_close(IRCC_client *irc);
|