]>
Commit | Line | Data |
---|---|---|
b0f6947b MS |
1 | #!/usr/bin/php -f |
2 | <?php | |
3 | ||
4 | $fp = popen("zgrep '^\\*Product:' /Library/Printers/PPDs/Contents/Resources/*.gz", "r"); | |
5 | $files = array(); | |
6 | $maxlen = 0; | |
7 | ||
8 | while ($line = fgets($fp, 1024)) | |
9 | { | |
10 | $data = explode(":", $line); | |
11 | if (array_key_exists($data[0], $files)) | |
12 | $files[$data[0]] ++; | |
13 | else | |
14 | $files[$data[0]] = 1; | |
15 | ||
16 | $data = explode("\"", $line); | |
17 | if (strlen($data[1]) > $maxlen) | |
18 | $maxlen = strlen($data[1]); | |
19 | } | |
20 | ||
21 | pclose($fp); | |
22 | ||
23 | arsort($files); | |
24 | ||
25 | $current_count = 0; | |
26 | $current_files = 0; | |
27 | ||
28 | foreach ($files as $file => $count) | |
29 | { | |
30 | if ($current_count == 0) | |
31 | print(basename($file) . " => $count products\n"); | |
32 | ||
33 | if ($count != $current_count) | |
34 | { | |
35 | if ($current_count != 0) | |
36 | print("$current_files PPDs with $current_count products.\n"); | |
37 | ||
38 | $current_count = $count; | |
39 | $current_files = 1; | |
40 | } | |
41 | else | |
42 | $current_files ++; | |
43 | } | |
44 | ||
45 | if ($current_count != 0) | |
46 | print("$current_files PPDs with $current_count products.\n"); | |
47 | ||
48 | print("Maximum length of Product string: $maxlen\n"); | |
49 | ||
50 | ?> |