- added (commented out) libircclient to mega-glest for future irc connectivity. JAM build files are updated (but also commented out)
This commit is contained in:
parent
ae7802953c
commit
a4686e39d4
|
@ -20,6 +20,7 @@ for i in $(LIB_STREFLOP_DIRS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Library strefloplib : $(LIB_STREFLOP_SOURCES) ;
|
Library strefloplib : $(LIB_STREFLOP_SOURCES) ;
|
||||||
|
#ExternalLibs strefloplib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL IRCCLIENT ;
|
||||||
ExternalLibs strefloplib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL ;
|
ExternalLibs strefloplib : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL ;
|
||||||
IncludeDir strefloplib : $(LIB_STREFLOP_INCLUDE_DIRS) ;
|
IncludeDir strefloplib : $(LIB_STREFLOP_INCLUDE_DIRS) ;
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ for i in $(GLEST_DIRS) {
|
||||||
|
|
||||||
Application glest.bin : $(GLEST_SOURCES) ;
|
Application glest.bin : $(GLEST_SOURCES) ;
|
||||||
LinkWith glest.bin : glestlib strefloplib ;
|
LinkWith glest.bin : glestlib strefloplib ;
|
||||||
ExternalLibs glest.bin : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL X11 ;
|
ExternalLibs glest.bin : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL X11 ;
|
||||||
IncludeDir glest.bin : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_DIRS) ;
|
IncludeDir glest.bin : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_DIRS) ;
|
||||||
|
|
||||||
#### Editor ####
|
#### Editor ####
|
||||||
|
@ -112,7 +113,7 @@ if $(WX_AVAILABLE) = "yes" {
|
||||||
|
|
||||||
Application glest_g3dviewer : $(GLEST_VIEWER_SOURCES) ../glest_game/graphics/unit_particle_type.cpp ../glest_game/graphics/particle_type.cpp ;
|
Application glest_g3dviewer : $(GLEST_VIEWER_SOURCES) ../glest_game/graphics/unit_particle_type.cpp ../glest_game/graphics/particle_type.cpp ;
|
||||||
LinkWith glest_g3dviewer : glestlib strefloplib ;
|
LinkWith glest_g3dviewer : glestlib strefloplib ;
|
||||||
ExternalLibs glest_g3dviewer : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL WX X11 ;
|
ExternalLibs glest_g3dviewer : SDL GL GLU XERCES VORBIS VORBISFILE OGG OPENAL LUA JPEG PNG CURL WX X11 ;
|
||||||
IncludeDir glest_g3dviewer : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_VIEWER_DIRS) ../glest_game/graphics ../glest_game/global ../glest_game/sound ../glest_game/game ;
|
IncludeDir glest_g3dviewer : ../shared_lib/include/$(LIB_INCLUDE_DIRS) $(GLEST_VIEWER_DIRS) ../glest_game/graphics ../glest_game/global ../glest_game/sound ../glest_game/game ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ NP_FINDLIB([OPENAL], [OpenAL], [OpenAL],
|
||||||
[alcOpenDevice(0);]),
|
[alcOpenDevice(0);]),
|
||||||
[], [-lopenal],
|
[], [-lopenal],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([Please intall OpenAL])],
|
[AC_MSG_ERROR([Please install OpenAL])],
|
||||||
[], [])
|
[], [])
|
||||||
|
|
||||||
NP_FINDLIB([JPEG], [LibJPEG], [LibJPEG],
|
NP_FINDLIB([JPEG], [LibJPEG], [LibJPEG],
|
||||||
|
@ -119,7 +119,7 @@ NP_FINDLIB([JPEG], [LibJPEG], [LibJPEG],
|
||||||
[jpeg_create_decompress(0);]),
|
[jpeg_create_decompress(0);]),
|
||||||
[], [-ljpeg],
|
[], [-ljpeg],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([Please intall libjpeg])],
|
[AC_MSG_ERROR([Please install libjpeg])],
|
||||||
[], [])
|
[], [])
|
||||||
|
|
||||||
NP_FINDLIB([PNG], [LibPng], [LibPNG],
|
NP_FINDLIB([PNG], [LibPng], [LibPNG],
|
||||||
|
@ -127,7 +127,7 @@ NP_FINDLIB([PNG], [LibPng], [LibPNG],
|
||||||
[png_sig_cmp(0, 0, 8);]),
|
[png_sig_cmp(0, 0, 8);]),
|
||||||
[], [-lpng],
|
[], [-lpng],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([Please intall libpng])],
|
[AC_MSG_ERROR([Please install libpng])],
|
||||||
[], [])
|
[], [])
|
||||||
|
|
||||||
NP_FINDLIB([CURL], [LibCurl], [LibCurl],
|
NP_FINDLIB([CURL], [LibCurl], [LibCurl],
|
||||||
|
@ -135,15 +135,23 @@ NP_FINDLIB([CURL], [LibCurl], [LibCurl],
|
||||||
[curl_easy_init();]),
|
[curl_easy_init();]),
|
||||||
[], [-lcurl],
|
[], [-lcurl],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([Please intall libcurl])],
|
[AC_MSG_ERROR([Please install libcurl])],
|
||||||
[], [])
|
[], [])
|
||||||
|
|
||||||
|
#NP_FINDLIB([IRCCLIENT], [LibIrcClient], [LibIrcClient],
|
||||||
|
# NP_LANG_PROGRAM([#include <libircclient/libircclient.h>],
|
||||||
|
# []),
|
||||||
|
# [], [-lircclient],
|
||||||
|
# [],
|
||||||
|
# [AC_MSG_ERROR([Please install libircclient])],
|
||||||
|
# [], [])
|
||||||
|
|
||||||
NP_FINDLIB([X11], [LibX11], [LibX11],
|
NP_FINDLIB([X11], [LibX11], [LibX11],
|
||||||
NP_LANG_PROGRAM([],
|
NP_LANG_PROGRAM([],
|
||||||
[]),
|
[]),
|
||||||
[], [-lX11],
|
[], [-lX11],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR([Please intall libX11])],
|
[AC_MSG_ERROR([Please install libX11])],
|
||||||
[], [])
|
[], [])
|
||||||
|
|
||||||
CHECK_LUA([], [AC_MSG_ERROR([Please install lua 5.1])])
|
CHECK_LUA([], [AC_MSG_ERROR([Please install lua 5.1])])
|
||||||
|
|
|
@ -29,7 +29,7 @@ elif [ "$OSTYPE" = "x86_64" ]; then
|
||||||
else
|
else
|
||||||
echo "=====> Using build deps for 32 bit Linux..."
|
echo "=====> Using build deps for 32 bit Linux..."
|
||||||
|
|
||||||
sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev
|
sudo apt-get install libsdl1.2-dev libxerces-c2-dev libalut-dev libgl1-mesa-dev libglu1-mesa-dev libvorbis-dev libwxbase2.8-dev libwxgtk2.8-dev libx11-dev liblua5.1-0-dev libjpeg-dev libpng12-dev libcurl4-gnutls-dev libircclient-dev
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,323 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2004-2009 Georgy Yunaev gyunaev@ulduzsoft.com
|
||||||
|
*
|
||||||
|
* This example is free, and not covered by LGPL license. There is no
|
||||||
|
* restriction applied to their modification, redistribution, using and so on.
|
||||||
|
* You can study them, modify them, use them in your own program - either
|
||||||
|
* completely or partially. By using it you may give me some credits in your
|
||||||
|
* program, but you don't have to.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This example tests most features of libirc. It can join the specific
|
||||||
|
* channel, welcoming all the people there, and react on some messages -
|
||||||
|
* 'help', 'quit', 'dcc chat', 'dcc send', 'ctcp'. Also it can reply to
|
||||||
|
* CTCP requests, receive DCC files and accept DCC chats.
|
||||||
|
*
|
||||||
|
* Features used:
|
||||||
|
* - nickname parsing;
|
||||||
|
* - handling 'channel' event to track the messages;
|
||||||
|
* - handling dcc and ctcp events;
|
||||||
|
* - using internal ctcp rely procedure;
|
||||||
|
* - generating channel messages;
|
||||||
|
* - handling dcc send and dcc chat events;
|
||||||
|
* - initiating dcc send and dcc chat.
|
||||||
|
*
|
||||||
|
* $Id: irctest.c 73 2009-01-03 11:14:59Z gyunaev $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <libircclient/libircclient.h>
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// We store data in IRC session context.
|
||||||
|
//
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char * channel;
|
||||||
|
char * nick;
|
||||||
|
|
||||||
|
} irc_ctx_t;
|
||||||
|
|
||||||
|
|
||||||
|
void addlog (const char * fmt, ...)
|
||||||
|
{
|
||||||
|
FILE * fp;
|
||||||
|
char buf[1024];
|
||||||
|
va_list va_alist;
|
||||||
|
|
||||||
|
va_start (va_alist, fmt);
|
||||||
|
#if defined (WIN32)
|
||||||
|
_vsnprintf (buf, sizeof(buf), fmt, va_alist);
|
||||||
|
#else
|
||||||
|
vsnprintf (buf, sizeof(buf), fmt, va_alist);
|
||||||
|
#endif
|
||||||
|
va_end (va_alist);
|
||||||
|
|
||||||
|
printf ("%s\n", buf);
|
||||||
|
|
||||||
|
if ( (fp = fopen ("irctest.log", "ab")) != 0 )
|
||||||
|
{
|
||||||
|
fprintf (fp, "%s\n", buf);
|
||||||
|
fclose (fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dump_event (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
|
||||||
|
{
|
||||||
|
char buf[512];
|
||||||
|
int cnt;
|
||||||
|
|
||||||
|
buf[0] = '\0';
|
||||||
|
|
||||||
|
for ( cnt = 0; cnt < count; cnt++ )
|
||||||
|
{
|
||||||
|
if ( cnt )
|
||||||
|
strcat (buf, "|");
|
||||||
|
|
||||||
|
strcat (buf, params[cnt]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addlog ("Event \"%s\", origin: \"%s\", params: %d [%s]", event, origin ? origin : "NULL", cnt, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void event_join (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
|
||||||
|
{
|
||||||
|
dump_event (session, event, origin, params, count);
|
||||||
|
irc_cmd_user_mode (session, "+i");
|
||||||
|
irc_cmd_msg (session, params[0], "Hi all");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
|
||||||
|
{
|
||||||
|
irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session);
|
||||||
|
dump_event (session, event, origin, params, count);
|
||||||
|
|
||||||
|
irc_cmd_join (session, ctx->channel, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void event_privmsg (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
|
||||||
|
{
|
||||||
|
dump_event (session, event, origin, params, count);
|
||||||
|
|
||||||
|
printf ("'%s' said me (%s): %s\n",
|
||||||
|
origin ? origin : "someone",
|
||||||
|
params[0], params[1] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length)
|
||||||
|
{
|
||||||
|
static int count = 1;
|
||||||
|
char buf[12];
|
||||||
|
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case LIBIRC_ERR_CLOSED:
|
||||||
|
printf ("DCC %d: chat closed\n", id);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
if ( !data )
|
||||||
|
{
|
||||||
|
printf ("DCC %d: chat connected\n", id);
|
||||||
|
irc_dcc_msg (session, id, "Hehe");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("DCC %d: %s\n", id, data);
|
||||||
|
sprintf (buf, "DCC [%d]: %d", id, count++);
|
||||||
|
irc_dcc_msg (session, id, buf);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf ("DCC %d: error %s\n", id, irc_strerror(status));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dcc_file_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length)
|
||||||
|
{
|
||||||
|
if ( status == 0 && length == 0 )
|
||||||
|
{
|
||||||
|
printf ("File sent successfully\n");
|
||||||
|
|
||||||
|
if ( ctx )
|
||||||
|
fclose ((FILE*) ctx);
|
||||||
|
}
|
||||||
|
else if ( status )
|
||||||
|
{
|
||||||
|
printf ("File sent error: %d\n", status);
|
||||||
|
|
||||||
|
if ( ctx )
|
||||||
|
fclose ((FILE*) ctx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ctx )
|
||||||
|
fwrite (data, 1, length, (FILE*) ctx);
|
||||||
|
printf ("File sent progress: %d\n", length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void event_channel (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
|
||||||
|
{
|
||||||
|
char nickbuf[128];
|
||||||
|
|
||||||
|
if ( count != 2 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf ("'%s' said in channel %s: %s\n",
|
||||||
|
origin ? origin : "someone",
|
||||||
|
params[0], params[1] );
|
||||||
|
|
||||||
|
if ( !origin )
|
||||||
|
return;
|
||||||
|
|
||||||
|
irc_target_get_nick (origin, nickbuf, sizeof(nickbuf));
|
||||||
|
|
||||||
|
if ( !strcmp (params[1], "quit") )
|
||||||
|
irc_cmd_quit (session, "of course, Master!");
|
||||||
|
|
||||||
|
if ( !strcmp (params[1], "help") )
|
||||||
|
{
|
||||||
|
irc_cmd_msg (session, params[0], "quit, help, dcc chat, dcc send, ctcp");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !strcmp (params[1], "ctcp") )
|
||||||
|
{
|
||||||
|
irc_cmd_ctcp_request (session, nickbuf, "PING 223");
|
||||||
|
irc_cmd_ctcp_request (session, nickbuf, "FINGER");
|
||||||
|
irc_cmd_ctcp_request (session, nickbuf, "VERSION");
|
||||||
|
irc_cmd_ctcp_request (session, nickbuf, "TIME");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !strcmp (params[1], "dcc chat") )
|
||||||
|
{
|
||||||
|
irc_dcc_t dccid;
|
||||||
|
irc_dcc_chat (session, 0, nickbuf, dcc_recv_callback, &dccid);
|
||||||
|
printf ("DCC chat ID: %d\n", dccid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !strcmp (params[1], "dcc send") )
|
||||||
|
{
|
||||||
|
irc_dcc_t dccid;
|
||||||
|
irc_dcc_sendfile (session, 0, nickbuf, "irctest.c", dcc_file_recv_callback, &dccid);
|
||||||
|
printf ("DCC send ID: %d\n", dccid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !strcmp (params[1], "topic") )
|
||||||
|
irc_cmd_topic (session, params[0], 0);
|
||||||
|
else if ( strstr (params[1], "topic ") == params[1] )
|
||||||
|
irc_cmd_topic (session, params[0], params[1] + 6);
|
||||||
|
|
||||||
|
if ( strstr (params[1], "mode ") == params[1] )
|
||||||
|
irc_cmd_channel_mode (session, params[0], params[1] + 5);
|
||||||
|
|
||||||
|
if ( strstr (params[1], "nick ") == params[1] )
|
||||||
|
irc_cmd_nick (session, params[1] + 5);
|
||||||
|
|
||||||
|
if ( strstr (params[1], "whois ") == params[1] )
|
||||||
|
irc_cmd_whois (session, params[1] + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void irc_event_dcc_chat (irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid)
|
||||||
|
{
|
||||||
|
printf ("DCC chat [%d] requested from '%s' (%s)\n", dccid, nick, addr);
|
||||||
|
|
||||||
|
irc_dcc_accept (session, dccid, 0, dcc_recv_callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void irc_event_dcc_send (irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid)
|
||||||
|
{
|
||||||
|
FILE * fp;
|
||||||
|
printf ("DCC send [%d] requested from '%s' (%s): %s (%lu bytes)\n", dccid, nick, addr, filename, size);
|
||||||
|
|
||||||
|
if ( (fp = fopen ("file", "wb")) == 0 )
|
||||||
|
abort();
|
||||||
|
|
||||||
|
irc_dcc_accept (session, dccid, fp, dcc_file_recv_callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
void event_numeric (irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count)
|
||||||
|
{
|
||||||
|
char buf[24];
|
||||||
|
sprintf (buf, "%d", event);
|
||||||
|
|
||||||
|
dump_event (session, buf, origin, params, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
irc_callbacks_t callbacks;
|
||||||
|
irc_ctx_t ctx;
|
||||||
|
irc_session_t * s;
|
||||||
|
|
||||||
|
if ( argc != 4 )
|
||||||
|
{
|
||||||
|
printf ("Usage: %s <server> <nick> <channel>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (&callbacks, 0, sizeof(callbacks));
|
||||||
|
|
||||||
|
callbacks.event_connect = event_connect;
|
||||||
|
callbacks.event_join = event_join;
|
||||||
|
callbacks.event_nick = dump_event;
|
||||||
|
callbacks.event_quit = dump_event;
|
||||||
|
callbacks.event_part = dump_event;
|
||||||
|
callbacks.event_mode = dump_event;
|
||||||
|
callbacks.event_topic = dump_event;
|
||||||
|
callbacks.event_kick = dump_event;
|
||||||
|
callbacks.event_channel = event_channel;
|
||||||
|
callbacks.event_privmsg = event_privmsg;
|
||||||
|
callbacks.event_notice = dump_event;
|
||||||
|
callbacks.event_invite = dump_event;
|
||||||
|
callbacks.event_umode = dump_event;
|
||||||
|
callbacks.event_ctcp_rep = dump_event;
|
||||||
|
callbacks.event_ctcp_action = dump_event;
|
||||||
|
callbacks.event_unknown = dump_event;
|
||||||
|
callbacks.event_numeric = event_numeric;
|
||||||
|
|
||||||
|
callbacks.event_dcc_chat_req = irc_event_dcc_chat;
|
||||||
|
callbacks.event_dcc_send_req = irc_event_dcc_send;
|
||||||
|
|
||||||
|
s = irc_create_session (&callbacks);
|
||||||
|
|
||||||
|
if ( !s )
|
||||||
|
{
|
||||||
|
printf ("Could not create session\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.channel = argv[3];
|
||||||
|
ctx.nick = argv[2];
|
||||||
|
|
||||||
|
irc_set_ctx (s, &ctx);
|
||||||
|
|
||||||
|
if ( irc_connect (s, argv[1], 6667, 0, argv[2], 0, 0) )
|
||||||
|
{
|
||||||
|
printf ("Could not connect: %s\n", irc_strerror (irc_errno(s)));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
irc_run (s);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*/
|
Loading…
Reference in New Issue