2023-08-16 07:53:53 +00:00
|
|
|
/*
|
|
|
|
LICENSE: MIT
|
|
|
|
Simple libary for working with ipv4 irc servers
|
|
|
|
Dont support:
|
|
|
|
ssl
|
|
|
|
ddc
|
|
|
|
ipv6
|
|
|
|
motd parsing
|
|
|
|
*/
|
|
|
|
|
2023-08-01 19:40:45 +00:00
|
|
|
#ifndef IRC_LINUX
|
|
|
|
#define IRC_LINUX
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <arpa/inet.h>
|
2023-08-16 07:53:53 +00:00
|
|
|
#define IRCC_MSG_MAX 512
|
|
|
|
|
2023-08-07 15:06:44 +00:00
|
|
|
enum {
|
2023-08-16 07:53:53 +00:00
|
|
|
IRCC_NICK = 1,
|
2023-08-07 15:06:44 +00:00
|
|
|
IRCC_PRIVMSG,
|
|
|
|
IRCC_JOIN,
|
|
|
|
IRCC_PART,
|
|
|
|
IRCC_PING,
|
2023-08-16 07:53:53 +00:00
|
|
|
IRCC_TOPIC,
|
|
|
|
IRCC_MODE,
|
2023-08-01 19:40:45 +00:00
|
|
|
|
2023-08-16 07:53:53 +00:00
|
|
|
IRCC_CONNECTED,
|
2023-08-07 15:06:44 +00:00
|
|
|
IRCC_DISCONNECTED,
|
|
|
|
IRCC_ERROR,
|
|
|
|
IRCC_SUCCESS
|
|
|
|
};
|
2023-08-01 19:40:45 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int socket;
|
|
|
|
size_t size;
|
|
|
|
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, char *msg, char *channel);
|
|
|
|
unsigned int IRCC_init(IRCC_client *irc, size_t size);
|
|
|
|
void IRCC_close(IRCC_client *irc);
|
|
|
|
#endif
|