- build fix for poor distros who have a hard time with libircclient (now we just include this small lib in the source tree) so no longer required as an external lib

This commit is contained in:
Mark Vejvoda
2010-12-27 09:01:40 +00:00
parent b76cc89b60
commit 8d8afe78b5
873 changed files with 99837 additions and 95 deletions

View File

@@ -0,0 +1,109 @@
/* include/config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the `getaddrinfo' function. */
#undef HAVE_GETADDRINFO
/* Define to 1 if you have the `gethostbyname_r' function. */
#undef HAVE_GETHOSTBYNAME_R
/* Define to 1 if you have the `inet_ntoa' function. */
#undef HAVE_INET_NTOA
/* Define to 1 if you have the `inet_pton' function. */
#undef HAVE_INET_PTON
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
/* Define to 1 if stdbool.h conforms to C99. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to the type of arg 1 for `select'. */
#undef SELECT_TYPE_ARG1
/* Define to the type of args 2, 3 and 4 for `select'. */
#undef SELECT_TYPE_ARG234
/* Define to the type of arg 5 for `select'. */
#undef SELECT_TYPE_ARG5
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
#ifndef INCLUDE_IRC_DCC_H
#define INCLUDE_IRC_DCC_H
#ifndef IN_INCLUDE_LIBIRC_H
#error This file should not be included directly, include just libirclient.h
#endif
#include <stdio.h>
/*
* This structure keeps the state of a single DCC connection.
*/
struct irc_dcc_session_s
{
irc_dcc_session_t * next;
irc_dcc_t id;
void * ctx;
socket_t sock; /*!< DCC socket */
int dccmode; /*!< Boolean value to differ chat vs send
requests. Changes the cb behavior - when
it is chat, data is sent by lines with
stripped CRLFs. In file mode, the data
is sent as-is */
int state;
time_t timeout;
FILE * dccsend_file_fp;
unsigned int received_file_size;
unsigned int file_confirm_offset;
struct sockaddr_in remote_addr;
char incoming_buf[LIBIRC_DCC_BUFFER_SIZE];
unsigned int incoming_offset;
char outgoing_buf[LIBIRC_DCC_BUFFER_SIZE];
unsigned int outgoing_offset;
port_mutex_t mutex_outbuf;
irc_dcc_callback_t cb;
};
#endif /* INCLUDE_IRC_DCC_H */

View File

@@ -0,0 +1,166 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
/*!
* \file libirc_doc.h
* \author Georgy Yunaev
* \version 1.0
* \date 09.2004
* \brief This file contains Doxygen modules.
*/
/*! \mainpage libircclient - a IRC library to create IRC clients
*
* \section intro_sec Introduction
*
* 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.
* - Good documentation and examples available.
*
* \section install_sec Compilation on Unix
*
* To compile libircclient, unpack the distribution, and do the standard mantra:
* \code
* # ./configure
* # make
* # make install
* \endcode
*
* \section install_secw Compilation under MS Windows
*
* To compile libircclient under MS Windows:
* - open the src/win32/libircclient.dsw file;
* - select the appropriate library linkage (static or dynamic), and
* debug/release version;
* - do 'Make build'
*
* You can also build the example using spammer.dsp project file. Here you
* can see how to integrate libircclient into your own project.
*
* \section doc Documentation
*
* Documentation is not installed with \a make \a install; you should copy it
* somewhere by hand.
* There is html documentation (in \a doc/html) and manual pages (\a doc/man).
* It is also recommended to check the \a examples directory, there are a
* few examples, they'll help you.
*
* \section cocoa Cocoa Support
*
* There is an experimental Cocoa framework wrapper around libircclient, called
* <a href="../../cocoa/doc/html/index.html">IRCClient</a>. You can find the Xcode project
* and source in the cocoa/ directory in the current trunk.
*
* \section author Author, copyright, support.
*
* If you have any questions, bug reports, suggestions regarding libircclient -
* please send them to gyunaev@ulduzsoft.com.
*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
*/
/*!
* \defgroup initclose Initiating and destroying IRC session.
*/
/*!
* \defgroup conndisc Connecting, disconnecting from IRC server.
*/
/*!
* \defgroup running Running IRC session.
*/
/*!
* \defgroup ircmd_ch IRC commands: channel management.
*/
/*!
* \defgroup ircmd_msg IRC commands: sending messages/notices.
*/
/*!
* \defgroup ircmd_oth IRC commands: other stuff.
*/
/*!
* \defgroup ctcp CTCP requests and replies.
*/
/*!
* \defgroup nnparse Nickname parsing.
*/
/*!
* \defgroup dccstuff DCC chat/send requests and replies.
*/
/*!
* \defgroup events Handling IRC events.
*/
/*!
* \defgroup errors Obtaining error values and descriptions.
*/
/*!
* \defgroup errorcodes Error codes generated by libircclient.
*/
/*!
* \defgroup contexts Managing contexts.
*/
/*!
* \defgroup common Getting libircclient version.
*/
/*!
* \defgroup options Managing libircclient options.
*/
/*!
* \defgroup rfcnumbers Numeric reply codes from RFC1459
*/
/*!
* \defgroup colors Messages colors manipulation
*/

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
/*!
* \file libirc_doc_faq.h
* \author Georgy Yunaev
* \version 1.0
* \date 09.2004
* \brief This file contains libircclient FAQ.
*/
/*! \page pagefaq Frequently Asked Questions
\section faq FAQ
\subsection faq1 Why the IRC server generates all these event_numeric events, and what is their meaning?
The IRC protocol itself is asynchronous and server-driven.
For you, this means the following:
- For any IRC command, it is not possible to obtain an immediate response
whether the command succeed or not. Instead the server will send the
reply in a short (or long) period of time.
- For some IRC command there is no 'success' response at all. For example,
when you send a text message, IRC server will not send anything to confirm
that the message is already sent.
- You can send several commands to the IRC server, and then receive several
replies regarding every command. The order of the replies you receive
is generally undefined.
- A lot of IRC events sent to you is generated by other users, or the IRC
server itself, and are sent to you just when they are generated.
- Long lists (for example, channel lists) are also sent as events. Moreover,
these events could be separated by other events (message or notices). And
it is your responsibility to separate the data (using event codes), and
use some sort of data structure that will hold it until the data is
complete. It is not possible to simply query the list of channels, and
expect that its content will immediately arrive.
- IRC protocol is event-based, not request-based. This means that if you
send JOIN request asking to join a channel, you cannot assume that you
have joined it until the server tells you so with JOIN event. Also it is
possible for server to "JOIN" you to a specific channel implicitly,
without even sending a join request.
- You should be prepared to expect the unexpected from the IRC server.
For example, the server can change your nick (seen on most servers, which
use \a nickserv authentication. You can be "forced" to join the channel,
to say something, to leave a channel, to change your usermode and so on.
Listen what IRC server tells you, and do so.
\subsection faq2 Why the irc_cmd_... functions does not return an error if the IRC server reports it? For example, why irc_cmd_join() returns success when I attempt to join a password-protected channel, and then the IRC server sends an error?
The irc_cmd_... functions return success when the command is sent to the
IRC server. The asynchronous nature of IRC makes it impossible to obtain
the command result immediately. Please read \ref faq1.
\subsection faq3 How to register/auth with NICKSERV?
There is no 'standard' way. However, knowing that all NICKSERV messages are
sent via irc_callbacks_t::event_notice, you can use following algorithm:
\code
static void event_notice (irc_session_t * session, const char * event,
const char * origin, const char ** params, unsigned int count)
{
char buf[256];
if ( !origin )
return;
if ( strcasecmp (origin, "nickserv") )
return;
if ( strstr (params[1], "This nick is not registered") == params[1] )
{
sprintf (buf, "REGISTER %s NOMAIL", gCfg.irc_nickserv_password);
irc_cmd_msg (session, "nickserv", buf);
}
else if ( strstr (params[1], "This nickname is registered and protected")
== params[1] )
{
sprintf (buf, "IDENTIFY %s", gCfg.irc_nickserv_password);
irc_cmd_msg (session, "nickserv", buf);
}
else if ( strstr (params[1], "Password accepted - you are now recognized")
== params[1] )
printf ("Nickserv authentication succeed.");
}
\endcode
The idea is to parse the messages sent from NICKSERV, and if they're matched
the specific patterns, react on them appropriately.
\subsection faq4 What is CTCP, and why do I need my own handler?
CTCP abbreviature is deciphered as "Client-to-Client Protocol". It is used
between the IRC clients to query the remote client for some data, or to send
some information - for example, /me messages are sent via CTCP. There is no
standard list of possible CTCP requests, and different IRC clients often add
their own CTCP codes. The built-in handler reacts on TIME, VERSION, PING and
FINGER CTCP queries. If you need to react on other queries, you'll have to
write your own CTCP handler. See the source code of libirc_event_ctcp_internal
to get an idea how to write it.
\subsection faq5 Why don't I receive event_umode when I am made +o (a channel operator)?
Because this is a channel mode, not a user mode. The user mode \c +o means that
this user is an IRC network operator, not just a channel operator.
\subsection faq6 Why do I get a LIBIRC_ERR_SOCKET error while using static library under Win32?
Because if you use static library, you have to initialize Winsock manually:
\code
WORD wVersionRequested = MAKEWORD (1, 1);
WSADATA wsaData;
if ( WSAStartup (wVersionRequested, &wsaData) != 0 )
// report an error
// And now we can use libircclient
\endcode
*/

View File

@@ -0,0 +1,208 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
/*!
* \file libirc_errors.h
* \author Georgy Yunaev
* \version 1.0
* \date 09.2004
* \brief This file defines error codes generated by libircclient.
*/
#ifndef INCLUDE_IRC_ERRORS_H
#define INCLUDE_IRC_ERRORS_H
#ifndef IN_INCLUDE_LIBIRC_H
#error This file should not be included directly, include just libircclient.h
#endif
/*! brief No error
* \ingroup errorcodes
*/
#define LIBIRC_ERR_OK 0
/*! \brief Invalid argument
*
* An invalid value was given for one of the arguments to a function.
* For example, supplying the NULL value for \a channel argument of
* irc_cmd_join() produces LIBIRC_ERR_INVAL error. You should fix the code.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_INVAL 1
/*! \brief Could not resolve host.
*
* The host name supplied for irc_connect() function could not be resolved
* into valid IP address. Usually means that host name is invalid.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_RESOLV 2
/*! \brief Could not create socket.
*
* The new socket could not be created or made non-blocking. Usually means
* that the server is out of resources, or (rarely :) a bug in libircclient.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_SOCKET 3
/*! \brief Could not connect.
*
* The socket could not connect to the IRC server, or to the destination DCC
* part. Usually means that either the IRC server is down or its address is
* invalid. For DCC the reason usually is the firewall on your or destination
* computer, which refuses DCC transfer.
*
* \sa irc_run irc_connect
* \ingroup errorcodes
*/
#define LIBIRC_ERR_CONNECT 4
/*! \brief Connection closed by remote peer.
*
* The IRC connection was closed by the IRC server (which could mean that an
* IRC operator just have banned you from the server :)), or the DCC connection
* was closed by remote peer - for example, the other side just quits his mIrc.
* Usually it is not an error.
*
* \sa irc_run irc_connect irc_dcc_callback_t
* \ingroup errorcodes
*/
#define LIBIRC_ERR_CLOSED 5
/*! \brief Out of memory
*
* There are two possible reasons for this error. First is that memory could
* not be allocated for libircclient use, and this error usually is fatal.
* Second reason is that the command queue (which keeps command ready to be
* sent to the IRC server) is full, and could not accept more commands yet.
* In this case you should just wait, and repeat the command later.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_NOMEM 6
/*! \brief Could not accept new connection
*
* A DCC chat/send connection from the remote peer could not be accepted.
* Either the connection was just terminated before it is accepted, or there
* is a bug in libircclient.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_ACCEPT 7
/*! \brief Could not send this
*
* A \a filename supplied to irc_dcc_sendfile() could not be sent. Either is
* is not a file (a directory or a socket, for example), or it is not readable. *
*
* \sa LIBIRC_ERR_OPENFILE
* \ingroup errorcodes
*/
#define LIBIRC_ERR_NODCCSEND 9
/*! \brief Could not read DCC file or socket
*
* Either a DCC file could not be read (for example, was truncated during
* sending), or a DCC socket returns a read error, which usually means that
* the network connection is terminated.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_READ 10
/*! \brief Could not write DCC file or socket
*
* Either a DCC file could not be written (for example, there is no free space
* on disk), or a DCC socket returns a write error, which usually means that
* the network connection is terminated.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_WRITE 11
/*! \brief Invalid state
*
* The function is called when it is not allowed to be called. For example,
* irc_cmd_join() was called before the connection to IRC server succeed, and
* ::event_connect is called.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_STATE 12
/*! \brief Operation timed out
*
* The DCC request is timed out.
* There is a timer for each DCC request, which tracks connecting, accepting
* and non-accepted/declined DCC requests. For every request this timer
* is currently 60 seconds. If the DCC request was not connected, accepted
* or declined during this time, it will be terminated with this error.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_TIMEOUT 13
/*! \brief Could not open file for DCC send
*
* The file specified in irc_dcc_sendfile() could not be opened.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_OPENFILE 14
/*! \brief IRC server connection terminated
*
* The connection to the IRC server was terminated - possibly, by network
* error. Try to irc_connect() again.
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_TERMINATED 15
/*! \brief IPv6 not supported
*
* The function which requires IPv6 support was called, but the IPv6 support was not compiled
* into the application
*
* \ingroup errorcodes
*/
#define LIBIRC_ERR_NOIPV6 16
/*! brief Internal max error value count
*/
#define LIBIRC_ERR_MAX 17
#endif /* INCLUDE_IRC_ERRORS_H */

View File

@@ -0,0 +1,398 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
/*!
* \file libirc_events.h
* \author Georgy Yunaev
* \version 1.0
* \date 09.2004
* \brief Describes event callbacks generated by libircclient.
*
* This file should not be included directly. Include libircclient.h instead.
*/
#ifndef INCLUDE_IRC_EVENTS_H
#define INCLUDE_IRC_EVENTS_H
#ifndef IN_INCLUDE_LIBIRC_H
#error This file should not be included directly, include just libircclient.h
#endif
/*!
* \fn typedef void (*irc_event_callback_t) (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
* \brief A most common event callback
*
* \param session the session, which generates an event
* \param event the text name of the event. Useful in case you use a single
* event handler for several events simultaneously.
* \param origin the originator of the event. See the note below.
* \param params a list of event params. Depending on the event nature, it
* could have zero or more params. The actual number of params
* is specified in count. None of the params can be NULL, but
* 'params' pointer itself could be NULL for some events.
* \param count the total number of params supplied.
*
* Every event generates a callback. This callback is generated by most events.
* Depending on the event nature, it can provide zero or more params. For each
* event, the number of provided params is fixed, and their meaning is
* described.
*
* Every event has origin, though the \a origin variable may be NULL, which
* means that event origin is unknown. The origin usually looks like
* nick!host\@ircserver, i.e. like tim!home\@irc.krasnogorsk.ru. Such origins
* can not be used in IRC commands, and need to be stripped (i.e. host and
* server part should be cut off) before using. This can be done either
* explicitly, by calling irc_target_get_nick(), or implicitly for all the
* events - by setting the #LIBIRC_OPTION_STRIPNICKS option with irc_option_set().
*
* \ingroup events
*/
typedef void (*irc_event_callback_t) (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count);
/*!
* \fn typedef void (*irc_eventcode_callback_t) (irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count)
* \brief A numeric event callback
*
* \param session the session, which generates an event
* \param event the numeric code of the event. Useful in case you use a
* single event handler for several events simultaneously.
* \param origin the originator of the event. See the note below.
* \param params a list of event params. Depending on the event nature, it
* could have zero or more params. The actual number of params
* is specified in count. None of the params can be NULL, but
* 'params' pointer itself could be NULL for some events.
* \param count the total number of params supplied.
*
* Most times in reply to your actions the IRC server generates numeric
* callbacks. Most of them are error codes, and some of them mark list start
* and list stop markers. Every code has its own set of params; for details
* you can either experiment, or read RFC 1459.
*
* Every event has origin, though the \a origin variable may be NULL, which
* means that event origin is unknown. The origin usually looks like
* nick!host\@ircserver, i.e. like tim!home\@irc.krasnogorsk.ru. Such origins
* can not be used in IRC commands, and need to be stripped (i.e. host and
* server part should be cut off) before using. This can be done either
* explicitly, by calling irc_target_get_nick(), or implicitly for all the
* events - by setting the #LIBIRC_OPTION_STRIPNICKS option with irc_option_set().
*
* \ingroup events
*/
typedef void (*irc_eventcode_callback_t) (irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count);
/*!
* \fn typedef void (*irc_event_dcc_chat_t) (irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid)
* \brief A remote DCC CHAT request callback
*
* \param session the session, which generates an event
* \param nick the person who requested DCC CHAT with you.
* \param addr the person's IP address in decimal-dot notation.
* \param dccid an id associated with this request. Use it in calls to
* irc_dcc_accept() or irc_dcc_decline().
*
* This callback is called when someone requests DCC CHAT with you. In respond
* you should call either irc_dcc_accept() to accept chat request, or
* irc_dcc_decline() to decline chat request.
*
* \sa irc_dcc_accept or irc_dcc_decline
* \ingroup events
*/
typedef void (*irc_event_dcc_chat_t) (irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid);
/*!
* \fn typedef void (*irc_event_dcc_send_t) (irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid)
* \brief A remote DCC CHAT request callback
*
* \param session the session, which generates an event
* \param nick the person who requested DCC CHAT with you.
* \param addr the person's IP address in decimal-dot notation.
* \param filename the sent filename.
* \param size the filename size.
* \param dccid an id associated with this request. Use it in calls to
* irc_dcc_accept() or irc_dcc_decline().
*
* This callback is called when someone wants to send a file to you using
* DCC SEND. As with chat, in respond you should call either irc_dcc_accept()
* to accept this request and receive the file, or irc_dcc_decline() to
* decline this request.
*
* \sa irc_dcc_accept or irc_dcc_decline
* \ingroup events
*/
typedef void (*irc_event_dcc_send_t) (irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid);
/*! \brief Event callbacks structure.
*
* All the communication with the IRC network is based on events. Generally
* speaking, event is anything generated by someone else in the network,
* or by the IRC server itself. "Someone sends you a message", "Someone
* has joined the channel", "Someone has quits IRC" - all these messages
* are events.
*
* Every event has its own event handler, which is called when the
* appropriate event is received. You don't have to define all the event
* handlers; define only the handlers for the events you need to intercept.
*
* Most event callbacks are the types of ::irc_event_callback_t. There are
* also events, which generate ::irc_eventcode_callback_t,
* ::irc_event_dcc_chat_t and ::irc_event_dcc_send_t callbacks.
*
* \ingroup events
*/
typedef struct
{
/*!
* The "on_connect" event is triggered when the client successfully
* connects to the server, and could send commands to the server.
* No extra params supplied; \a params is 0.
*/
irc_event_callback_t event_connect;
/*!
* The "nick" event is triggered when the client receives a NICK message,
* meaning that someone (including you) on a channel with the client has
* changed their nickname.
*
* \param origin the person, who changes the nick. Note that it can be you!
* \param params[0] mandatory, contains the new nick.
*/
irc_event_callback_t event_nick;
/*!
* The "quit" event is triggered upon receipt of a QUIT message, which
* means that someone on a channel with the client has disconnected.
*
* \param origin the person, who is disconnected
* \param params[0] optional, contains the reason message (user-specified).
*/
irc_event_callback_t event_quit;
/*!
* The "join" event is triggered upon receipt of a JOIN message, which
* means that someone has entered a channel that the client is on.
*
* \param origin the person, who joins the channel. By comparing it with
* your own nickname, you can check whether your JOIN
* command succeed.
* \param params[0] mandatory, contains the channel name.
*/
irc_event_callback_t event_join;
/*!
* The "part" event is triggered upon receipt of a PART message, which
* means that someone has left a channel that the client is on.
*
* \param origin the person, who leaves the channel. By comparing it with
* your own nickname, you can check whether your PART
* command succeed.
* \param params[0] mandatory, contains the channel name.
* \param params[1] optional, contains the reason message (user-defined).
*/
irc_event_callback_t event_part;
/*!
* The "mode" event is triggered upon receipt of a channel MODE message,
* which means that someone on a channel with the client has changed the
* channel's parameters.
*
* \param origin the person, who changed the channel mode.
* \param params[0] mandatory, contains the channel name.
* \param params[1] mandatory, contains the changed channel mode, like
* '+t', '-i' and so on.
* \param params[2] optional, contains the mode argument (for example, a
* key for +k mode, or user who got the channel operator status for
* +o mode)
*/
irc_event_callback_t event_mode;
/*!
* The "umode" event is triggered upon receipt of a user MODE message,
* which means that your user mode has been changed.
*
* \param origin the person, who changed the channel mode.
* \param params[0] mandatory, contains the user changed mode, like
* '+t', '-i' and so on.
*/
irc_event_callback_t event_umode;
/*!
* The "topic" event is triggered upon receipt of a TOPIC message, which
* means that someone on a channel with the client has changed the
* channel's topic.
*
* \param origin the person, who changes the channel topic.
* \param params[0] mandatory, contains the channel name.
* \param params[1] optional, contains the new topic.
*/
irc_event_callback_t event_topic;
/*!
* The "kick" event is triggered upon receipt of a KICK message, which
* means that someone on a channel with the client (or possibly the
* client itself!) has been forcibly ejected.
*
* \param origin the person, who kicked the poor.
* \param params[0] mandatory, contains the channel name.
* \param params[0] optional, contains the nick of kicked person.
* \param params[1] optional, contains the kick text
*/
irc_event_callback_t event_kick;
/*!
* The "channel" event is triggered upon receipt of a PRIVMSG message
* to an entire channel, which means that someone on a channel with
* the client has said something aloud. Your own messages don't trigger
* PRIVMSG event.
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, contains the channel name.
* \param params[1] optional, contains the message text
*/
irc_event_callback_t event_channel;
/*!
* The "privmsg" event is triggered upon receipt of a PRIVMSG message
* which is addressed to one or more clients, which means that someone
* is sending the client a private message.
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, contains your nick.
* \param params[1] optional, contains the message text
*/
irc_event_callback_t event_privmsg;
/*!
* The "notice" event is triggered upon receipt of a NOTICE message
* which means that someone has sent the client a public or private
* notice. According to RFC 1459, the only difference between NOTICE
* and PRIVMSG is that you should NEVER automatically reply to NOTICE
* messages. Unfortunately, this rule is frequently violated by IRC
* servers itself - for example, NICKSERV messages require reply, and
* are NOTICEs.
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, contains the target nick name.
* \param params[1] optional, contains the message text
*/
irc_event_callback_t event_notice;
/*!
* The "channel_notice" event is triggered upon receipt of a NOTICE
* message which means that someone has sent the client a public
* notice. According to RFC 1459, the only difference between NOTICE
* and PRIVMSG is that you should NEVER automatically reply to NOTICE
* messages. Unfortunately, this rule is frequently violated by IRC
* servers itself - for example, NICKSERV messages require reply, and
* are NOTICEs.
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, contains the channel name.
* \param params[1] optional, contains the message text
*/
irc_event_callback_t event_channel_notice;
/*!
* The "invite" event is triggered upon receipt of an INVITE message,
* which means that someone is permitting the client's entry into a +i
* channel.
*
* \param origin the person, who INVITEs you.
* \param params[0] mandatory, contains your nick.
* \param params[1] mandatory, contains the channel name you're invited into.
*
* \sa irc_cmd_invite irc_cmd_chanmode_invite
*/
irc_event_callback_t event_invite;
/*!
* The "ctcp" event is triggered when the client receives the CTCP
* request. By default, the built-in CTCP request handler is used. The
* build-in handler automatically replies on most CTCP messages, so you
* will rarely need to override it.
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, the complete CTCP message, including its
* arguments.
*
* Mirc generates PING, FINGER, VERSION, TIME and ACTION messages,
* check the source code of \c libirc_event_ctcp_internal function to
* see how to write your own CTCP request handler. Also you may find
* useful this question in FAQ: \ref faq4
*/
irc_event_callback_t event_ctcp_req;
/*!
* The "ctcp" event is triggered when the client receives the CTCP reply.
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, the CTCP message itself with its arguments.
*/
irc_event_callback_t event_ctcp_rep;
/*!
* The "action" event is triggered when the client receives the CTCP
* ACTION message. These messages usually looks like:\n
* \code
* [23:32:55] * Tim gonna sleep.
* \endcode
*
* \param origin the person, who generates the message.
* \param params[0] mandatory, the ACTION message.
*/
irc_event_callback_t event_ctcp_action;
/*!
* The "unknown" event is triggered upon receipt of any number of
* unclassifiable miscellaneous messages, which aren't handled by the
* library.
*/
irc_event_callback_t event_unknown;
/*!
* The "numeric" event is triggered upon receipt of any numeric response
* from the server. There is a lot of such responses, see the full list
* here: \ref rfcnumbers.
*
* See the params in ::irc_eventcode_callback_t specification.
*/
irc_eventcode_callback_t event_numeric;
/*!
* The "dcc chat" event is triggered when someone requests a DCC CHAT from
* you.
*
* See the params in ::irc_event_dcc_chat_t specification.
*/
irc_event_dcc_chat_t event_dcc_chat_req;
/*!
* The "dcc chat" event is triggered when someone wants to send a file
* to you via DCC SEND request.
*
* See the params in ::irc_event_dcc_send_t specification.
*/
irc_event_dcc_send_t event_dcc_send_req;
} irc_callbacks_t;
#endif /* INCLUDE_IRC_EVENTS_H */

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
/*!
* \file libirc_options.h
* \author Georgy Yunaev
* \version 1.0
* \date 09.2004
* \brief This file defines the options used in irc_session_options()
*/
#ifndef INCLUDE_IRC_OPTIONS_H
#define INCLUDE_IRC_OPTIONS_H
#ifndef IN_INCLUDE_LIBIRC_H
#error This file should not be included directly, include just libircclient.h
#endif
/*!
* enables additional debug output
* \ingroup options
*/
#define LIBIRC_OPTION_DEBUG (1 << 1)
/*! \brief allows to strip origins automatically.
*
* For every IRC server event, the event origin is sent in standard form:
* nick!host\@ircserver, i.e. like tim!home\@irc.krasnogorsk.ru. Such origins
* can not be used in IRC commands, and need to be stripped (i.e. host and
* server part should be cut off) before using. This can be done either
* explicitly, by calling irc_target_get_nick(), or implicitly for all the
* events - by setting this option with irc_option_set().
* \ingroup options
*/
#define LIBIRC_OPTION_STRIPNICKS (1 << 2)
#endif /* INCLUDE_IRC_OPTIONS_H */

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
#ifndef INCLUDE_IRC_PARAMS_H
#define INCLUDE_IRC_PARAMS_H
#ifndef IN_INCLUDE_LIBIRC_H
#error This file should not be included directly, include just libircclient.h
#endif
#define LIBIRC_VERSION_HIGH 0x0001
#define LIBIRC_VERSION_LOW 0x0002
#define LIBIRC_BUFFER_SIZE 1024
#define LIBIRC_DCC_BUFFER_SIZE 1024
#define LIBIRC_STATE_INIT 0
#define LIBIRC_STATE_LISTENING 1
#define LIBIRC_STATE_CONNECTING 2
#define LIBIRC_STATE_CONNECTED 3
#define LIBIRC_STATE_DISCONNECTED 4
#define LIBIRC_STATE_CONFIRM_SIZE 5 // Used only by DCC send to confirm the amount of sent data
#define LIBIRC_STATE_REMOVED 10 // this state is used only in DCC
#endif /* INCLUDE_IRC_PARAMS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
#ifndef INCLUDE_IRC_SESSION_H
#define INCLUDE_IRC_SESSION_H
#ifndef IN_INCLUDE_LIBIRC_H
#error This file should not be included directly, include just libircclient.h
#endif
#include "libirc_params.h"
#include "libirc_dcc.h"
#include "libirc_events.h"
struct irc_session_s
{
void * ctx;
int dcc_timeout;
int options;
int lasterror;
char incoming_buf[LIBIRC_BUFFER_SIZE];
unsigned int incoming_offset;
char outgoing_buf[LIBIRC_BUFFER_SIZE];
unsigned int outgoing_offset;
port_mutex_t mutex_session;
socket_t sock;
int state;
int motd_received;
char * server;
char * server_password;
char * realname;
char * username;
char * nick;
#if defined( ENABLE_IPV6 )
struct in6_addr local_addr;
#else
struct in_addr local_addr;
#endif
irc_dcc_t dcc_last_id;
irc_dcc_session_t * dcc_sessions;
port_mutex_t mutex_dcc;
irc_callbacks_t callbacks;
};
#endif /* INCLUDE_IRC_SESSION_H */

File diff suppressed because it is too large Load Diff