1 line
3.4 KiB
Plaintext
Executable File
1 line
3.4 KiB
Plaintext
Executable File
open(SRC,"<$ARGV[0]") || die;
|
|
open(DEFS,">:include:$ARGV[0].h") || die;
|
|
open(RFIL,">$ARGV[0].r") || die;
|
|
open(CFIL,">$ARGV[0].c") || die;
|
|
open(EFIL,"<$ARGV[0].extras") || die;
|
|
|
|
#
|
|
# read the extras file
|
|
#
|
|
$n = 0;
|
|
while (<EFILE>)
|
|
{
|
|
chop;
|
|
($enum,$pass,$word,$item,$help) = split('\t');
|
|
$EHelp{$enum} = $help;
|
|
$n++;
|
|
}
|
|
|
|
#
|
|
# read the input file
|
|
#
|
|
$n = 0;
|
|
while (<SRC>)
|
|
{
|
|
chop;
|
|
($enum[$n],$pass[$n],$pro[$n],$word[$n],$item[$n],$help[$n]) = split('\t');
|
|
($pass[$n],$multiple[$n]) = split(',',$pass[$n]);
|
|
if ($enum[$n] ne "" && $EHelp{$enum[$n]} ne "")
|
|
{
|
|
$help[$n] = $EHelp{$enum[$n]};
|
|
}
|
|
$n++;
|
|
}
|
|
|
|
#
|
|
# prepare the .h file
|
|
#
|
|
print DEFS <<EOF;
|
|
#ifdef TWO
|
|
#ifndef FILTDEFS_H
|
|
#define FILTDEFS_H
|
|
|
|
typedef enum {
|
|
flkZero,
|
|
EOF
|
|
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($enum[$i] eq "dash")
|
|
{
|
|
print DEFS "\tflkDash$i,\n";
|
|
}
|
|
else
|
|
{
|
|
print DEFS "\t$enum[$i],\n";
|
|
}
|
|
}
|
|
|
|
print DEFS <<EOF;
|
|
flkLimit
|
|
} FilterKeywordEnum;
|
|
|
|
#define FilterKeywordStrn 25200
|
|
|
|
void *FATable(FilterKeywordEnum fk);
|
|
short FAPass(FilterKeywordEnum fk);
|
|
short FAMultiple(FilterKeywordEnum fk);
|
|
Boolean FAProOnly(FilterKeywordEnum fk);
|
|
#endif
|
|
#endif
|
|
EOF
|
|
|
|
#
|
|
# prepare the .c file
|
|
#
|
|
print CFIL <<EOF;
|
|
#include "filtdefs.h"
|
|
EOF
|
|
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "")
|
|
{
|
|
print CFIL "extern void *FA$enum[$i](void);\n";
|
|
}
|
|
}
|
|
|
|
print CFIL <<EOF;
|
|
|
|
#pragma segment FILTRUN
|
|
void *FATable(FilterKeywordEnum fk)
|
|
{
|
|
switch (fk)
|
|
{
|
|
EOF
|
|
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "")
|
|
{
|
|
print CFIL "\t\tcase $enum[$i]: return(FA$enum[$i]);\n";
|
|
}
|
|
}
|
|
|
|
print CFIL <<EOF;
|
|
default:
|
|
return(nil);
|
|
}
|
|
}
|
|
EOF
|
|
|
|
print CFIL <<EOF;
|
|
|
|
short FAPass(FilterKeywordEnum fk)
|
|
{
|
|
switch (fk)
|
|
{
|
|
EOF
|
|
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "")
|
|
{
|
|
print CFIL "\t\tcase $enum[$i]: return($pass[$i]);\n";
|
|
}
|
|
}
|
|
|
|
print CFIL <<EOF;
|
|
default: return(0);
|
|
}
|
|
}
|
|
EOF
|
|
print CFIL <<EOF;
|
|
|
|
#pragma segment FilterWin
|
|
short FAMultiple(FilterKeywordEnum fk)
|
|
{
|
|
switch (fk)
|
|
{
|
|
EOF
|
|
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "")
|
|
{
|
|
print CFIL "\t\tcase $enum[$i]: return($multiple[$i]);\n";
|
|
}
|
|
}
|
|
|
|
print CFIL <<EOF;
|
|
default: return(0);
|
|
}
|
|
}
|
|
|
|
Boolean FAProOnly(FilterKeywordEnum fk)
|
|
{
|
|
switch (fk)
|
|
{
|
|
EOF
|
|
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "" && $pro[$i] ne "Both")
|
|
{
|
|
print CFIL "\t\tcase $enum[$i]:\n";
|
|
}
|
|
}
|
|
|
|
print CFIL <<EOF;
|
|
return(1); break;
|
|
default:
|
|
return(0); break;
|
|
}
|
|
}
|
|
EOF
|
|
|
|
#
|
|
# prepare the resource file
|
|
#
|
|
|
|
# the keyword strings
|
|
print RFIL <<EOF;
|
|
resource 'STR#' (25200,purgeable) {{
|
|
EOF
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
print RFIL qq/\t"$word[$i]",\n/;
|
|
}
|
|
print RFIL "}};\n\n";
|
|
|
|
# the menu resource
|
|
print RFIL <<EOF;
|
|
resource 'MENU' (1535) {535, 63,allEnabled, enabled, "FActions", {
|
|
EOF
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "")
|
|
{
|
|
print RFIL qq/\t"$item[$i]", noIcon, noKey, noMark, plain,\n/;
|
|
}
|
|
elsif ($enum[$i] eq "dash")
|
|
{
|
|
print RFIL qq/\t"-",noIcon, noKey, noMark, plain,\n/;
|
|
}
|
|
}
|
|
|
|
print RFIL "}};\n\n";
|
|
|
|
# then, the help strings
|
|
print RFIL <<EOF;
|
|
resource 'STR#' (535,purgeable) {{
|
|
EOF
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
print RFIL qq/\t"$help[$i]",\n/;
|
|
}
|
|
print RFIL "}};\n\n";
|
|
|
|
# finally, the hmnu
|
|
print RFIL <<EOF;
|
|
resource 'hmnu' (535,purgeable) {HelpMgrVersion,0,0,0,
|
|
HMSkipItem{},
|
|
{
|
|
HMSkipItem{},
|
|
EOF
|
|
$s = 0;
|
|
for ($i=0;$i<$n;$i++)
|
|
{
|
|
if ($item[$i] ne "")
|
|
{
|
|
$s++;
|
|
print RFIL qq/\t\tHMStringResItem{535,$s,535,$s,535,$s,535,$s},\n/;
|
|
}
|
|
elsif ($enum[$i] eq "dash")
|
|
{
|
|
$s++;
|
|
print RFIL "\tHMSkipItem\{\},\n";
|
|
}
|
|
}
|
|
print RFIL "}};\n\n";
|
|
|
|
#
|
|
# Uffdah, as we say here in the midwest. We're done.
|
|
# |