[NeoStats-Devel] [Commits] r2674 - in trunk: include modules/perltest modules/textserv src
[email protected] Tue, 19 Jul 2005 01:01:34 +1000
Newsgroups
gmane.comp.neostats.devel
Message-ID
<[email protected] >
Author: Fish
Date: Mon Jul 18 23:01:27 2005
New Revision: 2674
Modified:
trunk/include/neostats.h
trunk/modules/perltest/test.pl
trunk/modules/textserv/Makefile.in
trunk/src/Makefile.am
trunk/src/Makefile.in
trunk/src/NeoStats.pm
trunk/src/neostats.pm.h
trunk/src/perl.c
trunk/src/timer.c
Log:
Perl Hash's Suck... No. Perl Doco Sucks
Modified: trunk/include/neostats.h
==============================================================================
--- trunk/include/neostats.h (original)
+++ trunk/include/neostats.h Mon Jul 18 23:01:27 2005
@@ -840,7 +840,7 @@
#define EVENT_FLAG_EXCLUDE_ME 0x00000008 /* Event excludes neostats bots and servers */
#define EVENT_FLAG_EXCLUDE_MODME 0x00000010 /* Event excludes module bots */
-#ifdef PERL
+#ifdef USE_PERL
/** @brief Forward declaration of perl events
*/
struct PerlEvent;
Modified: trunk/modules/perltest/test.pl
==============================================================================
--- trunk/modules/perltest/test.pl (original)
+++ trunk/modules/perltest/test.pl Mon Jul 18 23:01:27 2005
@@ -81,239 +81,248 @@
sub event_server {
my ($test) = @_;
- NeoStats::print "New Server $test";
+ NeoStats::print ("New Server $test");
}
sub event_squit {
my ($server, $msg) = @_;
- NeoStats::print "Server $server Squit: $msg";
+ NeoStats::print ("Server $server Squit: $msg");
}
sub event_ping {
my ($source) = @_;
- NeoStats::print "Ping $source";
+ NeoStats::print ("Ping $source");
}
sub event_pong {
my ($source) = @_;
- NeoStats::print "Pong $source";
+ NeoStats::print ("Pong $source");
}
sub event_signon {
my ($source) = @_;
- NeoStats::print "Signon $source";
+ NeoStats::print ("Signon $source");
}
sub event_quit {
my ($source, $msg) = @_;
- NeoStats::print "Quit $source: $msg";
+ NeoStats::print ("Quit $source: $msg");
}
sub event_nickip {
my ($source) = @_;
- NeoStats::print "NickIP $source";
+ NeoStats::print ("NickIP $source");
}
sub event_kill {
my ($source, $target, $msg) = @_;
- NeoStats::print "KILL $target by $source: $msg";
+ NeoStats::print ("KILL $target by $source: $msg");
}
sub event_globalkill {
my ($source, $target, $msg) = @_;
- NeoStats::print "GLOBALKILL $target by $source: $msg";
+ NeoStats::print ("GLOBALKILL $target by $source: $msg");
}
sub event_localkill {
my ($source, $target, $msg) = @_;
- NeoStats::print "LOCALKILL $target by $source: $msg";
+ NeoStats::print ("LOCALKILL $target by $source: $msg");
}
sub event_serverkill {
my ($source, $target, $msg) = @_;
- NeoStats::print "SEVERKILL $target by $source: $msg";
+ NeoStats::print ("SEVERKILL $target by $source: $msg");
}
sub event_botkill {
my ($target, $msg) = @_;
- NeoStats::print "BOTKILL $target: $msg";
+ NeoStats::print ("BOTKILL $target: $msg");
}
sub event_nick {
my ($source, $target) = @_;
- NeoStats::print "NICKChange $source: $target";
+ NeoStats::print ("NICKChange $source: $target");
}
sub event_away {
my ($source) = @_;
- NeoStats::print "AwayChange $source";
+ NeoStats::print ("AwayChange $source");
}
sub event_umode {
my ($source, $mode) = @_;
- NeoStats::print "UMODE $source, $mode";
+ NeoStats::print ("UMODE $source, $mode");
}
sub event_smode {
my ($source, $mode) = @_;
- NeoStats::print "SMODE $source, $mode";
+ NeoStats::print ("SMODE $source, $mode");
}
sub event_newchan {
my ($channel) = @_;
- NeoStats::print "NewChan $channel";
+ NeoStats::print ("NewChan $channel");
}
sub event_delchan {
my ($channel) = @_;
- NeoStats::print "DelChan $channel";
+ NeoStats::print ("DelChan $channel");
}
sub event_join {
my ($channel, $source) = @_;
- NeoStats::print "Join $channel: $source";
+ NeoStats::print ("Join $channel: $source");
}
sub event_part {
my ($channel, $source, $msg) = @_;
- NeoStats::print "Part $channel: $source: $msg";
+ NeoStats::print ("Part $channel: $source: $msg");
}
sub event_partbot {
my ($channel, $source, $msg) = @_;
- NeoStats::print "Partbot $channel: $source: $msg";
+ NeoStats::print ("Partbot $channel: $source: $msg");
}
sub event_emptychan {
my ($channel, $source, $bot, $msg) = @_;
- NeoStats::print "Empty $channel $source $bot: $msg";
+ NeoStats::print ("Empty $channel $source $bot: $msg");
}
sub event_kick {
my ($channel, $source, $target, $msg) = @_;
- NeoStats::print "Kick $channel $source $target: $msg";
+ NeoStats::print ("Kick $channel $source $target: $msg");
}
sub event_kickbot {
my ($channel, $source, $target, $msg) = @_;
- NeoStats::print "Kickbot $channel $source $target: $msg";
+ NeoStats::print ("Kickbot $channel $source $target: $msg");
}
sub event_topic {
my ($channel, $source) = @_;
- NeoStats::print "Topic $channel $source";
+ NeoStats::print ("Topic $channel $source");
}
sub event_cmode {
- NeoStats::print "ToDO";
+ NeoStats::print ("ToDO");
}
sub event_private {
my ($source, $target, $msg) = @_;
- NeoStats::print "Privmsg $source $target: $msg";
+ NeoStats::print ("Privmsg $source $target: $msg");
}
sub event_notice {
my ($source, $target, $msg) = @_;
- NeoStats::print "NOTICE $source $target: $msg";
+ NeoStats::print ("NOTICE $source $target: $msg");
}
sub event_cprivate {
my ($source, $target, $msg) = @_;
- NeoStats::print "CPRIVATE $source $target: $msg";
+ NeoStats::print ("CPRIVATE $source $target: $msg");
}
sub event_cnotice {
my ($source, $target, $msg) = @_;
- NeoStats::print "CNOTICE $source $target: $msg";
+ NeoStats::print ("CNOTICE $source $target: $msg");
}
sub event_globops {
my ($source, $msg) = @_;
- NeoStats::print "GLOBOPS $source $msg";
+ NeoStats::print ("GLOBOPS $source $msg");
}
sub event_chatops {
my ($source, $msg) = @_;
- NeoStats::print "CHATOPS $source: $msg";
+ NeoStats::print ("CHATOPS $source: $msg");
}
sub event_wallops {
my ($source, $msg) = @_;
- NeoStats::print "WALLOPS $source: $msg";
+ NeoStats::print ("WALLOPS $source: $msg");
}
sub event_ctcpversionrpl {
my ($source, $msg) = @_;
- NeoStats::print "CTCPVERSIONRPL $source: $msg";
+ NeoStats::print ("CTCPVERSIONRPL $source: $msg");
}
sub event_ctcpversionreq {
my ($source) = @_;
- NeoStats::print "CTCPVERSIONREQ $source";
+ NeoStats::print ("CTCPVERSIONREQ $source");
}
sub event_ctcpfingerrpl {
my ($source, $msg) = @_;
- NeoStats::print "CTCPFINGERRPL $source: $msg";
+ NeoStats::print ("CTCPFINGERRPL $source: $msg");
}
sub event_ctcpfingerreq {
my ($source) = @_;
- NeoStats::print "CTCPFINGERREQ $source";
+ NeoStats::print ("CTCPFINGERREQ $source");
}
sub event_ctcpactionreq {
my ($source) = @_;
- NeoStats::print "CTCPACTIONREQ $source";
+ NeoStats::print ("CTCPACTIONREQ $source");
}
sub event_ctcptimerpl {
my ($source, $msg) = @_;
- NeoStats::print "CTCPTIMERPL $source: $msg";
+ NeoStats::print ("CTCPTIMERPL $source: $msg");
}
sub event_ctcptimereq {
my ($source) = @_;
- NeoStats::print "CTCPTIMEREQ $source";
+ NeoStats::print ("CTCPTIMEREQ $source");
}
sub event_ctcppingrpl {
my ($source, $msg) = @_;
- NeoStats::print "CTCPPINGRPL $source: $msg";
+ NeoStats::print ("CTCPPINGRPL $source: $msg");
}
sub event_ctcppingreq {
my ($source) = @_;
- NeoStats::print "CTCPPINGREQ $source";
+ NeoStats::print ("CTCPPINGREQ $source");
}
sub event_dccsend {
my ($source, $msg) = @_;
- NeoStats::print "DCCSEND $source: $msg";
+ NeoStats::print ("DCCSEND $source: $msg");
}
sub event_dccchat {
my ($source, $msg) = @_;
- NeoStats::print "DCCCHAT $source: $msg";
+ NeoStats::print ("DCCCHAT $source: $msg");
}
sub event_dccmsg {
my ($source, $msg) = @_;
- NeoStats::print "DCCMSG $source: $msg";
+ NeoStats::print ("DCCMSG $source: $msg");
}
sub event_addban {
- NeoStats::print "AddBan";
+ NeoStats::print ("AddBan");
}
sub event_delban {
- NeoStats::print "DelBan";
+ NeoStats::print ("DelBan");
}
+sub setupbot {
+ my $botinfo;
+ $botinfo->{nick} = "Fishy";
+ $botinfo->{altnick} = "Fishy2";
+ $botinfo->{ident} = "fish";
+ $botinfo->{host} = "Host.com";
+ $botinfo->{gecos} = "My Gecos";
+ NeoStats::AddBot($botinfo, 0);
+}
-
+setupbot();
Modified: trunk/modules/textserv/Makefile.in
==============================================================================
--- trunk/modules/textserv/Makefile.in (original)
+++ trunk/modules/textserv/Makefile.in Mon Jul 18 23:01:27 2005
@@ -184,7 +184,7 @@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
-datadir = $(prefix)/data/TSDB
+datadir = $(prefix)/data
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Jul 18 23:01:27 2005
@@ -22,7 +22,9 @@
$(top_srcdir)/lib/event/libevent.a
neostats_LDFLAGS = --export-dynamic -rdynamic
-noinst_HEADERS = confuselexer.l NeoStats.pm generate_header
+noinst_HEADERS = confuselexer.l NeoStats.pm
+neostats.pm.h: NeoStats.pm
+ $(top_builddir)/tools/generate_header
include $(top_srcdir)/autotools/rules.mk
Modified: trunk/src/Makefile.in
==============================================================================
--- trunk/src/Makefile.in (original)
+++ trunk/src/Makefile.in Mon Jul 18 23:01:27 2005
@@ -252,7 +252,7 @@
$(top_srcdir)/lib/event/libevent.a
neostats_LDFLAGS = --export-dynamic -rdynamic
-noinst_HEADERS = confuselexer.l NeoStats.pm generate_header
+noinst_HEADERS = confuselexer.l NeoStats.pm
LINK = $(LIBTOOL) --tag=CXX --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
@@ -550,6 +550,9 @@
uninstall-binPROGRAMS uninstall-info-am
+neostats.pm.h: NeoStats.pm
+ $(top_builddir)/tools/generate_header
+
.c.o:
@USECCDV@ @echo "Building $@"
@am__fastdepCC_TRUE@ @if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
Modified: trunk/src/NeoStats.pm
==============================================================================
--- trunk/src/NeoStats.pm (original)
+++ trunk/src/NeoStats.pm Mon Jul 18 23:01:27 2005
@@ -93,6 +93,50 @@
}
}
+# AddBot(botinfo, botflag)
+ sub AddBot {
+ return undef unless @_ >= 2;
+
+ my $botinfo = shift;
+ my $botflag = shift;
+ my $data = shift;
+ my ($package) = caller;
+# $callback = NeoStats::Embed::fix_callback( $package, $callback );
+
+ if (!ref( $botinfo ) eq 'HASH' ) {
+ return NeoStats::NS_FAILURE;
+ }
+ if ((!exists( $botinfo->{nick} )) || (!defined( $botinfo->{nick} ))) {
+ NeoStats::print("Botinfo->{nick} not defined");
+ return NeoStats::NS_FAILURE;
+ }
+ if ((!exists( $botinfo->{altnick} )) || (!defined( $botinfo->{altnick} ))) {
+ NeoStats::print("Botinfo->{altnick} not defined");
+ return NeoStats::NS_FAILURE;
+ }
+ if ((!exists( $botinfo->{ident} )) || (!defined( $botinfo->{ident} ))) {
+ NeoStats::print("Botinfo->{ident} not defined");
+ return NeoStats::NS_FAILURE;
+ }
+ if ((!exists( $botinfo->{host} )) || (!defined( $botinfo->{host} ))) {
+ NeoStats::print("Botinfo->{host} not defined");
+ return NeoStats::NS_FAILURE;
+ }
+ if ((!exists( $botinfo->{gecos} )) || (!defined( $botinfo->{gecos} ))) {
+ NeoStats::print("Botinfo->{gecos} not defined");
+ return NeoStats::NS_FAILURE;
+ }
+
+ my $pkg_info = NeoStats::Embed::pkg_info( $package );
+ my $bot = NeoStats::Internal::AddBot( $botinfo, $botflag, $data);
+ if ( defined ( $bot )) {
+ push @{$pkg_info->{bots}}, $bot;
+ return NeoStats::NS_SUCCESS;
+ } else {
+ return NeoStats::NS_FAILURE;
+ }
+ }
+
sub hook_server {
return undef unless @_ >= 2;
Modified: trunk/src/neostats.pm.h
==============================================================================
--- trunk/src/neostats.pm.h (original)
+++ trunk/src/neostats.pm.h Mon Jul 18 23:01:27 2005
@@ -94,6 +94,50 @@
"}\n"
"\n"
"\n"
+"sub AddBot {\n"
+"return undef unless @_ >= 2;\n"
+"\n"
+"my $botinfo = shift;\n"
+"my $botflag = shift;\n"
+"my $data = shift;\n"
+"my ($package) = caller;\n"
+"\n"
+"\n"
+"if (!ref( $botinfo ) eq 'HASH' ) {\n"
+"return NeoStats::NS_FAILURE;\n"
+"}\n"
+"if ((!exists( $botinfo->{nick} )) || (!defined( $botinfo->{nick} ))) {\n"
+"NeoStats::print(\"Botinfo->{nick} not defined\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"} \n"
+"if ((!exists( $botinfo->{altnick} )) || (!defined( $botinfo->{altnick} ))) {\n"
+"NeoStats::print(\"Botinfo->{altnick} not defined\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"} \n"
+"if ((!exists( $botinfo->{ident} )) || (!defined( $botinfo->{ident} ))) {\n"
+"NeoStats::print(\"Botinfo->{ident} not defined\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"} \n"
+"if ((!exists( $botinfo->{host} )) || (!defined( $botinfo->{host} ))) {\n"
+"NeoStats::print(\"Botinfo->{host} not defined\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"} \n"
+"if ((!exists( $botinfo->{gecos} )) || (!defined( $botinfo->{gecos} ))) {\n"
+"NeoStats::print(\"Botinfo->{gecos} not defined\");\n"
+"return NeoStats::NS_FAILURE;\n"
+"} \n"
+"\n"
+"my $pkg_info = NeoStats::Embed::pkg_info( $package );\n"
+"my $bot = NeoStats::Internal::AddBot( $botinfo, $botflag, $data);\n"
+"if ( defined ( $bot )) {\n"
+"push @{$pkg_info->{bots}}, $bot;\n"
+"return NeoStats::NS_SUCCESS;\n"
+"} else {\n"
+"return NeoStats::NS_FAILURE;\n"
+"}\n"
+"}\n"
+"\n"
+"\n"
"sub hook_server {\n"
"return undef unless @_ >= 2;\n"
"\n"
Modified: trunk/src/perl.c
==============================================================================
--- trunk/src/perl.c (original)
+++ trunk/src/perl.c Mon Jul 18 23:01:27 2005
@@ -35,6 +35,7 @@
#include <dirent.h>
extern void boot_DynaLoader (pTHX_ CV * cv);
+static void dump_hash(HV *rethash);
@@ -595,6 +596,54 @@
}
+static
+XS (XS_NeoStats_AddBot)
+{
+ Module *mod;
+ HV * rethash;
+ SV *ret;
+ int flags;
+ SV *value;
+
+ dXSARGS;
+ mod = GET_CUR_MODULE();
+ if (items < 2) {
+ nlog(LOG_WARNING, "Usage: NeoStats:Internal:AddBot(botinfo, flags, data)");
+ } else {
+ ret = ST(0);
+ flags = (int) SvIV (ST (1));
+ if(SvTYPE(SvRV(ret))!=SVt_PVHV) {
+ dlog(DEBUG1, "XS_NeoStats_AddBot: unsuported input %lu, must %i", SvTYPE(SvRV(ret)), SVt_PVHV);
+ XSRETURN_EMPTY;
+ }
+ rethash = (HV*)SvRV(ret);
+ value = *hv_fetch(rethash, "nick", strlen("nick"), FALSE);
+ printf("Nick: %s\n", SvPV_nolen(value));
+ value = *hv_fetch(rethash, "altnick", strlen("altnick"), FALSE);
+ printf("AltNick: %s\n", SvPV_nolen(value));
+ dump_hash(rethash);
+
+
+ }
+exit(-1);
+ XSRETURN_EMPTY;
+}
+
+
+static void
+dump_hash(HV *rethash) {
+ char *key;
+ SV *value;
+ int keycount;
+ I32 *keylen;
+
+ keycount = hv_iterinit(rethash);
+ printf("%d items in call\n",keycount);
+ while(keycount-- != 0) {
+ value = hv_iternextsv(rethash, &key, &keylen);
+ printf("Return (%s) -> (%s)\n",key,SvPV_nolen(value));
+ }
+}
@@ -918,6 +967,7 @@
newXS ("NeoStats::Internal::register", XS_NeoStats_register, __FILE__);
newXS ("NeoStats::Internal::hook_event", XS_NeoStats_hook_event, __FILE__);
newXS ("NeoStats::Internal::unhook_event", XS_NeoStats_unhook_event, __FILE__);
+ newXS ("NeoStats::Internal::AddBot", XS_NeoStats_AddBot, __FILE__);
stash = get_hv ("NeoStats::", TRUE);
if (stash == NULL) {
exit (1);
Modified: trunk/src/timer.c
==============================================================================
--- trunk/src/timer.c (original)
+++ trunk/src/timer.c Mon Jul 18 23:01:27 2005
@@ -307,7 +307,7 @@
timer = hnode_get (tn);
irc_prefmsg (ns_botptr, cmdparams->source, "%s:", timer->moduleptr->info->name);
irc_prefmsg (ns_botptr, cmdparams->source, __("Timer: %s", cmdparams->source), timer->name);
- irc_prefmsg (ns_botptr, cmdparams->source, __("Interval: %d", cmdparams->source), timer->interval);
+ irc_prefmsg (ns_botptr, cmdparams->source, __("Interval: %ld", cmdparams->source), (long)timer->interval);
irc_prefmsg (ns_botptr, cmdparams->source, __("Next run in: %ld", cmdparams->source), (long)(timer->interval - (me.now - timer->lastrun)));
}
irc_prefmsg (ns_botptr, cmdparams->source, __("End of list.", cmdparams->source));