annotate bin/cek.pl @ 613:1a996b35eaab

Style updates
author nanaya <me@nanaya.pro>
date Mon, 02 Apr 2018 17:44:25 +0900
parents 5bafb912837e
children 70355e17653e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
1 #!/usr/bin/env perl
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
2
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
3 use strict;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
4 use warnings;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
5 use String::CRC32;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
6 use File::Basename;
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
7
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
8 my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1);
613
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
9 my $num_ok = 0;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
10 my $num_err = 0;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
11 my $num_nf = 0;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
12 my $num_na = @files;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
13
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
14 foreach (@files) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
15 my $filename = $_;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
16 my ($name_crc,$real_crc);
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
17
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
18 unless (-f $filename) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
19 $num_nf++;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
20 $num_na--;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
21 print(qq(Could not find "$filename", skipping\n));
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
22 next();
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
23 }
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
24
613
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
25 if (/(\[|\()([0-9A-F]{8})(\]|\))/i){
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
26 $name_crc = uc($2);
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
27 }
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
28
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
29 open(FILE,"<",$filename);
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
30 binmode(FILE);
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
31 $real_crc = sprintf("%08X",crc32(*FILE));
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
32 close(FILE);
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
33
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
34 if ($name_crc) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
35 $num_na--;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
36 if($name_crc eq $real_crc) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
37 $num_ok++;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
38 print("$filename: OK - $real_crc\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
39 } else {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
40 $num_err++;
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
41 print("$filename: NOT OK - $real_crc, should be $name_crc\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
42 }
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
43 } else {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
44 print("$filename: $real_crc\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
45 }
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
46 }
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
47
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
48 printf("%s\n","-"x40);
613
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
49 if ($num_ok > 0) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
50 print("Files OK: $num_ok\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
51 }
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
52 if ($num_err > 0) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
53 print("Files error: $num_err\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
54 }
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
55 if ($num_nf > 0) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
56 print("Files not found: $num_nf\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
57 }
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
58 if ($num_na > 0) {
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
59 print("Files without crc information: $num_na\n");
1a996b35eaab Style updates
nanaya <me@nanaya.pro>
parents: 124
diff changeset
60 }
124
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
61
5bafb912837e Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff changeset
62 exit(0);