# libircclient.h File Reference

This file defines all prototypes and functions to use libircclient. More...

`#include <sys/select.h>`
`#include "libirc_errors.h"`
`#include "libirc_rfcnumeric.h"`
`#include "libirc_events.h"`
`#include "libirc_options.h"`

## Typedefs

typedef struct irc_session_s | irc_session_t
| A libircclient IRC session.
typedef struct irc_dcc_session_s | irc_dcc_session_t
| A libircclient DCC session.
typedef unsigned int | irc_dcc_t
| A DCC session identifier.
typedef void(* | irc_dcc_callback_t )(irc_session_t *session, irc_dcc_t id, int status, void *ctx, const char *data, unsigned int length)
| A common DCC callback, used to inform you about the current DCC state or event.

## Functions

irc_session_t * | irc_create_session (irc_callbacks_t *callbacks)
| Creates and initiates a new IRC session.
void | irc_destroy_session (irc_session_t *session)
| Destroys previously created IRC session.
int | irc_connect (irc_session_t *session, const char *server, unsigned short port, const char *server_password, const char *nick, const char *username, const char *realname)
| Initiates a connection to IRC server.
int | irc_connect6 (irc_session_t *session, const char *server, unsigned short port, const char *server_password, const char *nick, const char *username, const char *realname)
| Initiates a connection to IRC server using IPv6.
void | irc_disconnect (irc_session_t *session)
| Disconnects a connection to IRC server.
int | irc_is_connected (irc_session_t *session)
| Checks whether the session is connecting/connected to the IRC server.
int | irc_run (irc_session_t *session)
| Goes into forever-loop, processing IRC events and generating callbacks.
int | irc_add_select_descriptors (irc_session_t *session, fd_set *in_set, fd_set *out_set, int *maxfd)
| Adds IRC socket(s) for the descriptor set to use in select().
int | irc_process_select_descriptors (irc_session_t *session, fd_set *in_set, fd_set *out_set)
| Processes the IRC socket(s), which descriptor(s) are set.
int | irc_send_raw (irc_session_t *session, const char *format,...)
| Sends raw data to the IRC server.
int | irc_cmd_quit (irc_session_t *session, const char *reason)
| Sends QUIT command to the IRC server.
int | irc_cmd_join (irc_session_t *session, const char *channel, const char *key)
| Joins the new IRC channel.
int | irc_cmd_part (irc_session_t *session, const char *channel)
| Leaves the IRC channel.
int | irc_cmd_invite (irc_session_t *session, const char *nick, const char *channel)
| Invites a user to invite-only channel.
int | irc_cmd_names (irc_session_t *session, const char *channel)
| Obtains a list of users who're in channel.
int | irc_cmd_list (irc_session_t *session, const char *channel)
| Obtains a list of active server channels with their topics.
int | irc_cmd_topic (irc_session_t *session, const char *channel, const char *topic)
| Views or changes the channel topic.
int | irc_cmd_channel_mode (irc_session_t *session, const char *channel, const char *mode)
| Views or changes the channel mode.
int | irc_cmd_user_mode (irc_session_t *session, const char *mode)
| Views or changes your own user mode.
int | irc_cmd_nick (irc_session_t *session, const char *newnick)
| Changes your nick.
int | irc_cmd_whois (irc_session_t *session, const char *nick)
| Queries the information about the nick.
int | irc_cmd_msg (irc_session_t *session, const char *nch, const char *text)
| Sends the message to the nick or to the channel.
int | irc_cmd_me (irc_session_t *session, const char *nch, const char *text)
| Sends the /me (CTCP ACTION) message to the nick or to the channel.
int | irc_cmd_notice (irc_session_t *session, const char *nch, const char *text)
| Sends the notice to the nick or to the channel.
int | irc_cmd_kick (irc_session_t *session, const char *nick, const char *channel, const char *reason)
| Kick some lazy ass out of channel.
int | irc_cmd_ctcp_request (irc_session_t *session, const char *nick, const char *request)
| Generates a CTCP request.
int | irc_cmd_ctcp_reply (irc_session_t *session, const char *nick, const char *reply)
| Generates a reply to the CTCP request.
void | irc_target_get_nick (const char *target, char *nick, size_t size)
| Gets the nick part from the target.
void | irc_target_get_host (const char *target, char *nick, size_t size)
| Gets the host part from the target.
int | irc_dcc_chat (irc_session_t *session, void *ctx, const char *nick, irc_dcc_callback_t callback, irc_dcc_t *dccid)
| Initiates a DCC CHAT.
int | irc_dcc_msg (irc_session_t *session, irc_dcc_t dccid, const char *text)
| Sends the message to the specific DCC CHAT.
int | irc_dcc_accept (irc_session_t *session, irc_dcc_t dccid, void *ctx, irc_dcc_callback_t callback)
| Accepts a remote DCC CHAT or DCC RECVFILE request.
int | irc_dcc_decline (irc_session_t *session, irc_dcc_t dccid)
| Declines a remote DCC CHAT or DCC RECVFILE request.
int | irc_dcc_sendfile (irc_session_t *session, void *ctx, const char *nick, const char *filename, irc_dcc_callback_t callback, irc_dcc_t *dccid)
| Sends a file via DCC.
int | irc_dcc_destroy (irc_session_t *session, irc_dcc_t dccid)
| Destroys a DCC session.
void | irc_get_version (unsigned int *high, unsigned int *low)
| Obtains a libircclient version.
void | irc_set_ctx (irc_session_t *session, void *ctx)
| Sets the IRC session context.
void * | irc_get_ctx (irc_session_t *session)
| Returns the IRC session context.
int | irc_errno (irc_session_t *session)
| Returns the last error code.
const char * | irc_strerror (int ircerrno)
| Returns the text error message associated with this error code.
void | irc_option_set (irc_session_t *session, unsigned int option)
| Sets the libircclient option.
void | irc_option_reset (irc_session_t *session, unsigned int option)
| Resets the libircclient option.
char * | irc_color_strip_from_mirc (const char *message)
| Removes all the color codes and format options.
char * | irc_color_convert_from_mirc (const char *message)
| Converts all the color codes and format options to libircclient colors.
char * | irc_color_convert_to_mirc (const char *message)
| Converts all the color codes from libircclient format to mIRC.

## Detailed Description

This file defines all prototypes and functions to use libircclient.

Author:
  Georgy Yunaev

Version:
  1.0

Date:
  09.2004 libircclient is a small but powerful library, which implements client-server IRC protocol. It is designed to be small, fast, portable and compatible to RFC standards, and most IRC clients. libircclient features include:
  - Full multi-threading support.
  - Single threads handles all the IRC processing.
  - Support for single-threaded applications, and socket-based applications, which use select()
  - Synchronous and asynchronous interfaces.
  - CTCP support with optional build-in reply code.
  - Flexible DCC support, including both DCC chat, and DCC file transfer.
  - Can both initiate and react to initiated DCC.
  - Can accept or decline DCC sessions asynchronously.
  - Plain C interface and implementation (possible to use from C++ code, obviously)
  - Compatible with RFC 1459 and most IRC clients.
  - Free, licensed under LGPL license.

Note that to use libircclient, only libircclient.h should be included into your program. Do not include other libirc_* headers.

## Typedef Documentation

typedef struct irc_dcc_session_s irc_dcc_session_t

A libircclient DCC session.

This structure describes a DCC session used by libircclient. Its members are internal to libircclient, and should not be used directly.

typedef unsigned int irc_dcc_t

A DCC session identifier.

The irc_dcc_t type is a DCC session identifier, used to identify the DCC sessions in callbacks and various functions.

typedef struct irc_session_s irc_session_t

A libircclient IRC session.

This structure describes an IRC session. Its members are internal to libircclient, and should not be used directly.