82 lines
1.8 KiB
C
82 lines
1.8 KiB
C
#ifndef IRC_H
|
|
#define IRC_H
|
|
|
|
#include <stdbool.h>
|
|
typedef enum
|
|
{
|
|
PLAIN,
|
|
EXTERNAL
|
|
} irc_sasl_method_t;
|
|
|
|
typedef struct
|
|
{
|
|
char *nickname;
|
|
int nicklen;
|
|
char *ident;
|
|
int identlen;
|
|
char *hostname;
|
|
int hostlen;
|
|
} irc_hostmask_t;
|
|
|
|
typedef struct {
|
|
char line[513];
|
|
char *source;
|
|
char *command;
|
|
char *argv[16];
|
|
int argc;
|
|
} irc_message_t;
|
|
|
|
typedef struct
|
|
{
|
|
irc_hostmask_t hostmask;
|
|
char prefix;
|
|
} irc_chanuser_t;
|
|
|
|
typedef struct
|
|
{
|
|
char name[64];
|
|
char topic[512];
|
|
irc_chanuser_t* users;
|
|
} irc_channel_t;
|
|
|
|
typedef struct
|
|
{
|
|
char capLine[96]; // A place for name and args to point to.
|
|
char *name;
|
|
char *args;
|
|
} irc_capability_t;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
int sockfd;
|
|
irc_hostmask_t ownHostmask;
|
|
char supportedCapabilities[512];
|
|
char* requestedCapabilities;
|
|
} irc_client_t;
|
|
|
|
typedef struct {
|
|
const char *name;
|
|
void (*handler)(irc_message_t *msg, irc_client_t *irc);
|
|
} command_t;
|
|
|
|
void IRC_ParseMessage(char* line, irc_message_t *msg);
|
|
void IRC_ProcessMessage(irc_message_t *msg, irc_client_t *irc);
|
|
|
|
// various IRC commands
|
|
void IRC_PRIVMSG(char* to, char* msg, irc_client_t *irc);
|
|
void IRC_NOTICE(char* to, char* msg, irc_client_t *irc);
|
|
void IRC_NICK(char *nick, irc_client_t *irc);
|
|
void IRC_USER(char *ident, char* realname, irc_client_t *irc);
|
|
|
|
// registration
|
|
void IRC_Register(char *nick, char* ident, char *realname, bool saslEnabled, irc_sasl_method_t saslMethod, char *saslUsername, char *saslPassword, irc_client_t *irc);
|
|
|
|
// Capability negotiation block
|
|
void IRC_StartCapabilityNegotiation(irc_client_t *irc);
|
|
void IRC_RequestCapabilities(char* caps, irc_client_t *irc);
|
|
void IRC_EndCapabilityNegotiation(irc_client_t *irc);
|
|
|
|
int IRC_ParseCapabilities(char* caps, irc_capability_t *capabilities, int capsLength);
|
|
|
|
#endif |