]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/mkcommandlist.pl
22 print "Usage: $0 <module name>\n";
37 $smallname=~s/\.so$//;
40 $cname=$smallname . ".c";
41 $smallname=~s/^chanserv_//;
45 next if (/commandlist.c/);
46 next if ($_ eq $cname);
49 my ($cn, $cl, $ca, $cd, $cf, $cp, $ch, $cal);
53 open INFILE
,"<$fname";
58 if (/CMDNAME: (.*)/) {
62 if (/CMDLEVEL: (.*)/) {
66 if (/CMDARGS: (.*)/) {
70 if (/CMDDESC: (.*)/) {
74 if (/CMDFUNC: (.*)/) {
78 if (/CMDPROTO: (.*)/) {
82 if (/CMDHELP: (.*)/) {
86 if (/CMDALIASES: (.*)/) {
91 if (defined $cn and defined $cl and defined $ca and defined $cd and defined $cf and defined $cp) {
93 $cmdhash{$cn} = scalar @cmdnames;
103 push @cmdaliases, $cal;
105 print "Warning: found source file $fname without complete tags, skipping...\n";
110 print "No commands found - are you in the right directory?\n";
111 print "Exiting before I destroy something important.\n";
116 open CL
, ">commandlist.c";
118 print CL
"/* Automatically generated by mkcommandlist.pl, do not edit. */\n\n";
119 print CL
"#include \"".$rootpath."/chanserv.h\"\n\n";
122 print CL
"/* Prototypes */\n";
127 print CL
"void ".$smallname."_init(void);\n";
128 print CL
"void ".$smallname."_fini(void);\n\n";
130 print CL
"\nvoid _init() {\n";
131 print CL
" ".$smallname."_init();\n";
133 sub generate_help_text
{
138 $SUBS{"COMMAND"} = $cn;
139 $SUBS{"UCOMMAND"} = uc($cn);
142 while(my ($key, $value) = each(%SUBS)) {
143 $key = '@'.quotemeta($key).'@';
144 $value = quotemeta($value);
145 $ch =~ s/$key/$value/g;
152 my ($cn, $i, $isalias) = @_;
154 my $cl = $cmdlevels[$i];
156 $cl .= " | " if ($cl ne "");
160 print CL
" chanservaddcommand(\"".$cn."\", ".($cl).", ".($cmdargs[$i]).", ";
161 print CL
($cmdfunc[$i]).", \"".($cmddesc[$i])."\", \"".(generate_help_text
($cn,$help[$i])),"\");\n";
164 for (my $i=0;$i<scalar @cmdnames;$i++) {
165 writecmd
($cmdnames[$i], $i, 0);
167 foreach (split / /, $cmdaliases[$i]) {
172 print CL
"}\n\nvoid _fini() {\n";
173 print CL
" ".$smallname."_fini();\n";
177 print CL
" chanservremovecommand(\"".$cn."\", ".($cmdfunc[$i]).");\n";
180 for (my $i=0;$i<scalar @cmdnames;$i++) {
181 writercmd
($cmdnames[$i], $i);
183 foreach (split / /, $cmdaliases[$i]) {
192 open MF
,">.autobuild.mk";
194 print MF
"# Automatically generated Makefile, do not edit.\n";
196 print MF
"\n$modname: ";
198 push @files,"commandlist.c";