]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/mkcommandlist.pl
22 print "Usage: $0 <module name>\n";
30 $smallname=~s/\.so$//;
33 $cname=$smallname . ".c";
34 $smallname=~s/^chanserv_//;
38 next if (/commandlist.c/);
39 next if ($_ eq $cname);
42 my ($cn, $cl, $ca, $cd, $cf, $cp, $ch, $cal);
46 open INFILE
,"<$fname";
51 if (/CMDNAME: (.*)/) {
55 if (/CMDLEVEL: (.*)/) {
59 if (/CMDARGS: (.*)/) {
63 if (/CMDDESC: (.*)/) {
67 if (/CMDFUNC: (.*)/) {
71 if (/CMDPROTO: (.*)/) {
75 if (/CMDHELP: (.*)/) {
79 if (/CMDALIASES: (.*)/) {
84 if (defined $cn and defined $cl and defined $ca and defined $cd and defined $cf and defined $cp) {
86 $cmdhash{$cn} = scalar @cmdnames;
96 push @cmdaliases, $cal;
98 print "Warning: found source file $fname without complete tags, skipping...\n";
103 print "No commands found - are you in the right directory?\n";
104 print "Exiting before I destroy something important.\n";
109 open CL
, ">commandlist.c";
111 print CL
"/* Automatically generated by mkcommandlist.pl, do not edit. */\n\n";
112 print CL
"#include \"../chanserv.h\"\n\n";
115 print CL
"/* Prototypes */\n";
120 print CL
"void ".$smallname."_init(void);\n";
121 print CL
"void ".$smallname."_fini(void);\n\n";
123 print CL
"\nvoid _init() {\n";
124 print CL
" ".$smallname."_init();\n";
126 sub generate_help_text
{
131 $SUBS{"COMMAND"} = $cn;
132 $SUBS{"UCOMMAND"} = uc($cn);
135 while(my ($key, $value) = each(%SUBS)) {
136 $key = '@'.quotemeta($key).'@';
137 $value = quotemeta($value);
138 $ch =~ s/$key/$value/g;
145 my ($cn, $i, $isalias) = @_;
147 my $cl = $cmdlevels[$i];
149 $cl .= " | " if ($cl ne "");
153 print CL
" chanservaddcommand(\"".$cn."\", ".($cl).", ".($cmdargs[$i]).", ";
154 print CL
($cmdfunc[$i]).", \"".($cmddesc[$i])."\", \"".(generate_help_text
($cn,$help[$i])),"\");\n";
157 for (my $i=0;$i<scalar @cmdnames;$i++) {
158 writecmd
($cmdnames[$i], $i, 0);
160 foreach (split / /, $cmdaliases[$i]) {
165 print CL
"}\n\nvoid _fini() {\n";
166 print CL
" ".$smallname."_fini();\n";
170 print CL
" chanservremovecommand(\"".$cn."\", ".($cmdfunc[$i]).");\n";
173 for (my $i=0;$i<scalar @cmdnames;$i++) {
174 writercmd
($cmdnames[$i], $i);
176 foreach (split / /, $cmdaliases[$i]) {
185 open MF
,">autobuild.mk";
187 print MF
"# Automatically generated Makefile, do not edit.\n";
189 print MF
"\n$modname: ";
191 push @files,"commandlist.c";