irclibs/C/irc.h

54 lines
1.0 KiB
C
Raw Normal View History

2023-08-16 07:53:53 +00:00
/*
2023-12-13 13:15:52 +00:00
LICENSE: WTFPL
2023-08-16 07:53:53 +00:00
Simple libary for working with ipv4 irc servers
Dont support:
ssl
ddc
ipv6
2023-12-13 13:15:52 +00:00
motd
2023-08-16 07:53:53 +00:00
*/
2023-08-01 19:40:45 +00:00
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
2023-10-06 13:03:43 +00:00
#include <sys/time.h>
2023-08-01 19:40:45 +00:00
#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-17 07:01:33 +00:00
#define IRCC_PING_TIMEOUT 600
2023-08-16 07:53:53 +00:00
enum {
2023-08-16 07:53:53 +00:00
IRCC_NICK = 1,
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,
IRCC_DISCONNECTED,
IRCC_ERROR,
IRCC_SUCCESS
};
2023-08-01 19:40:45 +00:00
typedef struct {
int socket;
2023-10-06 13:03:43 +00:00
2023-12-13 13:15:52 +00:00
char raw[IRCC_MSG_MAX + 1];
2023-08-01 19:40:45 +00:00
char *msg;
char *channel;
char *nick;
} IRCC_client;
2023-11-02 21:49:37 +00:00
int IRCC_connect(IRCC_client *irc, const char *ip, const unsigned int port);
int IRCC_recv(IRCC_client *irc);
2023-12-13 13:15:52 +00:00
int IRCC_join(IRCC_client *irc, const char *channel, const char *key);
2023-11-02 21:49:37 +00:00
int IRCC_send(IRCC_client *irc, const char *msg, const char *channel);
2023-12-13 13:15:52 +00:00
int IRCC_register(IRCC_client *irc, const char *nickname);
2023-11-02 21:49:37 +00:00
int IRCC_init(IRCC_client *irc);
2023-08-01 19:40:45 +00:00
void IRCC_close(IRCC_client *irc);