diff -uNrd ircd-hybrid-6.3.1.dist/README.services ircd-hybrid-6.3.1/README.services --- ircd-hybrid-6.3.1.dist/README.services Wed Dec 31 19:00:00 1969 +++ ircd-hybrid-6.3.1/README.services Tue Mar 25 19:57:37 2003 @@ -0,0 +1,28 @@ +The services commands patch provides a script to create a set +of services shortcuts for a Hybrid 6 server. + +To install the services shortcuts, edit services.conf and put +the definitions for your network's services. Once complete, + +WARNING: The command name MUST be in all capital letters. + +run: + +$ perl services.pl install + +The script will rerun configure and make depend. You can now +compile and install the ircd as you normally would. + +If you wish to remove the services shortcuts, run: + +$ perl services.pl remove + +The script will rerun configure and make depend. You will then +need to recompile the ircd. + +If you change the configuration file, you must remove then +install the services commands. You will then need to recompile +the ircd again. + +Code originally by Hwy +Upper case msgtab bug found by DB7 and `Mage. diff -uNrd ircd-hybrid-6.3.1.dist/include/m_commands.h ircd-hybrid-6.3.1/include/m_commands.h --- ircd-hybrid-6.3.1.dist/include/m_commands.h Tue Mar 25 19:52:55 2003 +++ ircd-hybrid-6.3.1/include/m_commands.h Tue Mar 25 19:53:38 2003 @@ -99,4 +99,7 @@ extern int m_dns(struct Client *,struct Client *,int,char **); extern int m_htm(struct Client *,struct Client *,int,char **); extern int m_set(struct Client *,struct Client *,int,char **); + +/* BEGIN MESSAGE DECLARATIONS */ + #endif /* INCLUDED_m_commands_h */ diff -uNrd ircd-hybrid-6.3.1.dist/include/msg.h ircd-hybrid-6.3.1/include/msg.h --- ircd-hybrid-6.3.1.dist/include/msg.h Tue Mar 25 19:52:56 2003 +++ ircd-hybrid-6.3.1/include/msg.h Tue Mar 25 19:53:42 2003 @@ -129,6 +129,8 @@ #define MSG_KNOCK "KNOCK" /* KNOCK */ +/* BEGIN MESSAGE DECLARATION */ + #define MAXPARA 15 #define MSG_TESTLINE "TESTLINE" @@ -252,6 +254,7 @@ { MSG_DIE, m_die, 0, MAXPARA, 1, 0, 0, 0L }, { MSG_HTM, m_htm, 0, MAXPARA, 1, 0, 0, 0L }, { MSG_SET, m_set, 0, MAXPARA, 1, 0, 0, 0L }, +/* BEGIN MESSAGE TABLE */ { MSG_TESTLINE, m_testline, 0, MAXPARA, 1, 0, 0, 0L }, { (char *) 0, (int (*)()) 0 , 0, 0, 0, 0, 0, 0L } }; diff -uNrd ircd-hybrid-6.3.1.dist/services.conf ircd-hybrid-6.3.1/services.conf --- ircd-hybrid-6.3.1.dist/services.conf Wed Dec 31 19:00:00 1969 +++ ircd-hybrid-6.3.1/services.conf Tue Mar 25 19:59:53 2003 @@ -0,0 +1,27 @@ +# Services commands configuration file +# +# format: command,nick,user@server,alias +# Please do not include spaces. +# If you do not wish to have an alias, please +# put the word NONE. +# +# WARNING: The command MUST be in all capital letters. +# +# Examples: +# +# For Dal style services +NICKSERV,NickServ,nickserv@services.irc,ns +CHANSERV,ChanServ,chanserv@services.irc,cs +MEMOSERV,MemoServ,memoserv@services.irc,ms +OPERSERV,OperServ,operserv@services.irc,os +# +# For the Hybrid testnet +NOTESERV,NoteServ,noteserv@note.efnow,NONE +STATSERV,[Stats],stats@efnow.stats,NONE +JUPESERV,[Jupe],jupe@efnow.stats,NONE +ADMINSERV,[Admin],admin@efnow.stats,NONE +SPLITSERV,[Split],split@efnow.stats,NONE +# +# For an EFnet like network +CHANFIX,ChanFix,services@services.int,NONE +SERVICES,SERVICES,services@services.xo,NONE diff -uNrd ircd-hybrid-6.3.1.dist/services.pl ircd-hybrid-6.3.1/services.pl --- ircd-hybrid-6.3.1.dist/services.pl Wed Dec 31 19:00:00 1969 +++ ircd-hybrid-6.3.1/services.pl Tue Mar 25 19:53:42 2003 @@ -0,0 +1,225 @@ +#!/bin/perl + +# Services commands for Hybrid 6.3 +# +# Adding Services Commands to an installation: +# 1. Read the configuration file +# 2. Update include/msg.h +# 3. Update include/m_commands.h +# 4. Create src/m_services.c +# 5. Update src/Makefile.in +# 6. Create include/m_services.h +# 7. Rerun configure +# 8. Rerun make depend +# +# Removing Services Commands from an installation: +# 1. Clean up include/msg.h +# 2. Clean up include/m_commands.h +# 3. Clean up src/Makefile.in +# 4. Remove src/m_service.c +# 5. Remove include/m_services.h +# 6. Rerun configure +# 7. Rerun make depend + +# Defaults +$conffile = "services.conf"; + +# Global variables +# Note: For all the hashes, the command is the key +%nicks = (); +%userhosts = (); +%aliases = (); + +if ($ARGV[0] =~ /install/i) +{ + process_install(); +} +elsif ($ARGV[0] =~ /deintall/i) +{ + process_deinstall(); +} +elsif ($ARGV[0] =~ /remove/i) +{ + process_deinstall(); +} +else +{ + print "Invalid option\nperl services.pl [install|remove]\n"; +} + +sub process_install() +{ + # 1. Read configuration file + open(CONF, "<$conffile"); + while () + { + chomp; + if (/^#/) + { + next; + } + ($tcommand, $tnick, $tuhost, $talias) = split(','); + $nicks{$tcommand} = $tnick; + $userhosts{$tcommand} = $tuhost; + if ($talias ne "NONE") + { + $aliases{$tcommand} = $talias; + } + } + close(CONF); + + # 2. Update include/msg.h + system("cp include/msg.h include/msg.h.svs"); + open(MSGHIN, "include/msg.h"); + while () + { + if (/BEGIN MESSAGE DECLARATION/) + { + print MSGHOUT "/* BEGIN MESSAGE DECLARATION */\n"; + foreach $k (keys %userhosts) + { + print MSGHOUT "#define MSG_$k \"$k\" /* SVSCOM */\n"; + } + foreach $k (keys %aliases) + { + print MSGHOUT "#define MSG_$aliases{$k} \"$aliases{$k}\" /* SVSCOM */\n"; + } + } + elsif (/BEGIN MESSAGE TABLE/) + { + print MSGHOUT "/* BEGIN MESSAGE TABLE */\n"; + foreach $k (keys %userhosts) + { + print MSGHOUT " { MSG_$k, m_$k, 0, MAXPARA, 1, 0, 0, 0L }, /* SVSCOM */\n"; + } + foreach $k (keys %aliases) + { + print MSGHOUT " { MSG_$aliases{$k}, m_$k, 0, MAXPARA, 1, 0, 0, 0L }, /* SVSCOM */\n"; + } + } + else + { + print MSGHOUT $_; + } + } + close(MSGHIN); + close(MSGHOUT); + + # 3. Update include/m_commands.h + system("cp include/m_commands.h include/m_commands.h.svs"); + open(MCHIN, "include/m_commands.h"); + while () + { + if (/BEGIN MESSAGE DECLARATIONS/) + { + print MCHOUT "/* BEGIN MESSAGE DECLARATIONS */\n"; + foreach $k (keys %userhosts) + { + print MCHOUT "extern int m_$k(struct Client *,struct Client *,int,char **); /* SVSCOM */\n"; + } + } + else + { + print MCHOUT $_; + } + } + close(MCHIN); + close(MCHOUT); + + # 4. Create src/m_services.c + generate_m_services(); + + # 5. Update src/Makefile.in + system("cp src/Makefile.in src/Makefile.in.svs"); + open(MAKEIN, "src/Makefile.in"); + while () + { + if (/m_server\.c/) + { + print MAKEOUT "\tm_server.c \\\n\tm_services.c \\\n"; + } + else + { + print MAKEOUT $_; + } + } + close(MAKEIN); + close(MAKEOUT); + + # 6. Create include/m_services.h + open(SOUT, ">include/m_services.h"); + print SOUT "/* m_services.h - Script generated services commands declaration file\n"; + print SOUT "** Do not edit this file\n*/\n\n"; + foreach $k (keys %userhosts) + { + print SOUT "#define SVS_${k}_NICK \"$nicks{$k}\"\n"; + print SOUT "#define SVS_${k}_USERSERV \"$userhosts{$k}\"\n"; + } + close(SOUT); + + # 7. Rerun configure + system("sh configure"); + + # 8. Rerun make depend + system("make depend"); + + print "Services commands added.\n"; +} + +sub generate_m_services() +{ + open(SOUT, ">src/m_services.c"); + print SOUT "/* m_services.c - Script generated services commands definition file\n"; + print SOUT "** Do not edit this file\n"; + print SOUT "*/\n\n#include \"m_commands.h\"\n#include \"client.h\"\n"; + print SOUT "#include \"ircd.h\"\n#include \"numeric.h\"\n#include \"s_misc.h\"\n"; + print SOUT "#include \"s_serv.h\"\n#include \"send.h\"\n#include \"m_services.h\"\n\n"; + + foreach $k (keys %userhosts) + { + print SOUT "int m_$k(struct Client *cptr, struct Client *sptr, int parc, char *parv[])\n"; + print SOUT "{\n struct Client *acptr;\n\n if (parc<2 || *parv[1] == '\\0')\n"; + print SOUT " {\n sendto_one(sptr, form_str(ERR_NOTEXTTOSEND), me.name, parv[0]);\n"; + print SOUT " return -1;\n }\n\n if ((acptr = find_person(SVS_${k}_NICK, NULL)))\n"; + print SOUT " {\n sendto_one(acptr, \":%s PRIVMSG %s :%s\", parv[0], SVS_${k}_USERSERV, parv[1]);\n"; + print SOUT " return 0;\n }\n else\n {\n sendto_one(sptr, form_str(ERR_NOSUCHNICK), me.name, parv[0], SVS_${k}_NICK);\n"; + print SOUT " return -1;\n }\n}\n\n"; + } + + close(SOUT); +} + +sub process_deinstall() +{ + # 1. Clean up include/msg.h + system("cp include/msg.h include/msg.h.srm"); + system("grep -v SVSCOM include/msg.h.srm >include/msg.h"); + system("rm include/msg.h.srm"); + + # 2. Clean up include/m_commands.h + system("cp include/m_commands.h include/m_commands.h.srm"); + system("grep -v SVSCOM include/m_commands.h.srm >include/m_commands.h"); + system("rm include/m_commands.h.srm"); + + # 3. Clean up src/Makefile.in + system("cp src/Makefile.in src/Makefile.in.srm"); + system("grep -v m_services src/Makefile.in.srm >src/Makefile.in"); + system("rm src/Makefile.in.srm"); + + # 4. Remove src/m_service.c + system("rm src/m_services.c"); + + # 5. Remove include/m_services.h + system("rm include/m_services.h"); + + # 6. Rerun configure + system("sh configure"); + + # 7. Rerun make depend + system("make depend"); +} + +exit 0;