| 1 |
root |
1.1 |
#!/usr/bin/perl |
| 2 |
|
|
|
| 3 |
|
|
require 5; |
| 4 |
|
|
|
| 5 |
|
|
# LCL symbol... localize symbols |
| 6 |
|
|
# ARC arch architecture symbol |
| 7 |
|
|
# DFT cpp-expr default method? |
| 8 |
|
|
# DEF symbol alternatives... specifiy alternatives |
| 9 |
|
|
# DEP cpp-expr when to apply these (which architecture &c) |
| 10 |
|
|
# MTH name init crack load new method independent of everything else |
| 11 |
|
|
# LOD load load method to use |
| 12 |
|
|
# END guess |
| 13 |
|
|
|
| 14 |
|
|
$method_count=0; |
| 15 |
|
|
|
| 16 |
|
|
while(<>) { |
| 17 |
|
|
if(/^\s+\*\s+(\w+)\s+(.*)$/) { |
| 18 |
|
|
$1 eq "END" and last; |
| 19 |
|
|
$1 eq "LCL" and do { |
| 20 |
|
|
@lcl=split /\s+/,$2; |
| 21 |
|
|
}; |
| 22 |
|
|
$1 eq "ARC" and do { |
| 23 |
|
|
$arch=$2; |
| 24 |
|
|
}; |
| 25 |
|
|
$1 eq "DFT" and do { |
| 26 |
|
|
$default=$2; |
| 27 |
|
|
}; |
| 28 |
|
|
$1 eq "LOD" and do { |
| 29 |
|
|
$load=$2; |
| 30 |
|
|
}; |
| 31 |
|
|
$1 eq "MTH" and do { |
| 32 |
|
|
my($name,$init,$crack,$load)=split /\s+/,$2; |
| 33 |
|
|
$methods .= " { \"$name\", $init, $crack, $load },\n"; |
| 34 |
|
|
$method_count++; |
| 35 |
|
|
}; |
| 36 |
|
|
$1 eq "DEF" and do { |
| 37 |
|
|
my($def,$val)=split /\s+/,$2,2; |
| 38 |
|
|
my(@val); |
| 39 |
|
|
if($val) { |
| 40 |
|
|
@val=split /\s*\$\s*/,$val; |
| 41 |
|
|
for(@val) { |
| 42 |
|
|
$_=["# undef $def\n# define $def $_\n", ", $def=$_"]; |
| 43 |
|
|
} |
| 44 |
|
|
} else { |
| 45 |
|
|
@val = (["# undef $def\n", ""], ["# define $def 1\n", ", $def"]); |
| 46 |
|
|
} |
| 47 |
|
|
$def{$def}=[@val]; |
| 48 |
|
|
}; |
| 49 |
|
|
$1 eq "DEP" and do { |
| 50 |
|
|
$method=$method_count; |
| 51 |
|
|
$def.="#elif $2\n"; |
| 52 |
|
|
$tab.="#elif $2\n$methods"; |
| 53 |
|
|
$def.="# define $arch 1\n" if $arch; |
| 54 |
|
|
gen_def(""); |
| 55 |
|
|
$def.="# undef $arch\n" if $arch; |
| 56 |
|
|
undef $arch; |
| 57 |
|
|
undef $default; |
| 58 |
|
|
undef %def; |
| 59 |
|
|
}; |
| 60 |
|
|
} |
| 61 |
|
|
} |
| 62 |
|
|
|
| 63 |
|
|
sub gen_def { |
| 64 |
|
|
my($sym)=(keys %def)[0]; |
| 65 |
|
|
if($sym) { |
| 66 |
|
|
my($val)=delete $def{$sym}; |
| 67 |
|
|
for(@{$val}) { |
| 68 |
|
|
gen_def($_[0].$_->[0],$_[1].$_->[1]); |
| 69 |
|
|
} |
| 70 |
|
|
$def{$sym}=$val; |
| 71 |
|
|
} else { |
| 72 |
|
|
$def.="# undef METHOD\n# define METHOD $method\n$_[0]"; |
| 73 |
|
|
$tab.=" { \"zip$method$_[1]\""; |
| 74 |
|
|
for(@lcl) { |
| 75 |
|
|
$def.="# undef $_\n# define $_ METHOD${method}_$_\n"; |
| 76 |
|
|
$tab.=", METHOD${method}_$_"; |
| 77 |
|
|
} |
| 78 |
|
|
$tab.=", $load },\n"; |
| 79 |
|
|
$def.="# if $default\n# define DEFAULT_METHOD $method\n# endif\n" if $default; |
| 80 |
|
|
$def.="# include \"zipcrack.c\"\n"; |
| 81 |
|
|
$method++; |
| 82 |
|
|
} |
| 83 |
|
|
} |
| 84 |
|
|
|
| 85 |
|
|
############################################################################## |
| 86 |
|
|
|
| 87 |
|
|
open C,">crackdef.c" or die "crackdef.c: $!"; |
| 88 |
|
|
print C <<EOF; |
| 89 |
|
|
/* |
| 90 |
|
|
* this file is automatically generated from zipcrack.c, do NOT modify |
| 91 |
|
|
*/ |
| 92 |
|
|
|
| 93 |
|
|
#if 0 |
| 94 |
|
|
$def#else |
| 95 |
|
|
#warn no architecture compiled in |
| 96 |
|
|
#endif |
| 97 |
|
|
|
| 98 |
|
|
#ifndef DEFAULT_METHOD |
| 99 |
|
|
#define DEFAULT_METHOD 0 |
| 100 |
|
|
#endif |
| 101 |
|
|
|
| 102 |
|
|
int default_method = DEFAULT_METHOD; |
| 103 |
|
|
|
| 104 |
|
|
method methods[] = { |
| 105 |
|
|
#if 0 |
| 106 |
|
|
$tab#else |
| 107 |
|
|
#endif |
| 108 |
|
|
{ 0, 0, 0, 0 } |
| 109 |
|
|
}; |
| 110 |
|
|
|
| 111 |
|
|
EOF |