More Fun With Internet Config Prefs in Mac OS X
I was having problems with my IC mappings (IC == Internet Config / Internet Control Panel / Internet System Preferences, stored in com.apple.internetconfig.plist now in Mac OS X) not being carried over. So in many cases, my files ended up the wrong type.
I found out I could change single entries under Classic, via the Internet Control Panel. I guess the CP calls the IC API which now writes the plist file in Mac OS X instead of the resource file in Mac OS.
So I wrote this little program which gets the data from the IC prefs and writes it out into the right format. It must be run under Mac OS v9, NOT Classic. It just prints out the data to then paste into the proper location in the plist file (overwriting the corresponding entries). I pasted in the new data (after backing up the file) in Mac OS, before rebooting into Mac OS X.
An interesting note: what would have been nice to do is just get the raw data structure as a string, and encode_base64() it. But the module didn't allow for that, so rather than trying to add that to the module, I just re-packed it back into its original format, using the IC headers as a guide. :)
I found out I could change single entries under Classic, via the Internet Control Panel. I guess the CP calls the IC API which now writes the plist file in Mac OS X instead of the resource file in Mac OS.
So I wrote this little program which gets the data from the IC prefs and writes it out into the right format. It must be run under Mac OS v9, NOT Classic. It just prints out the data to then paste into the proper location in the plist file (overwriting the corresponding entries). I pasted in the new data (after backing up the file) in Mac OS, before rebooting into Mac OS X.
An interesting note: what would have been nice to do is just get the raw data structure as a string, and encode_base64() it. But the module didn't allow for that, so rather than trying to add that to the module, I just re-packed it back into its original format, using the IC headers as a guide.
#!perl -w
use Mac::InternetConfig;
use MIME::Base64;
my %dups;
for my $e (keys %InternetConfigMap) {
next if exists $dups{$e->extension};
$dups{$e->extension}++;
my $c = pack 'sa4a4a4l',
$e->version, $e->file_type, $e->file_creator,
$e->post_creator, $e->flags;
my $d;
for $meth (qw(extension creator_app_name post_app_name MIME_type entry_name)) {
my $s = $e->$meth;
$d.= sprintf "%s%s", chr(length $s), $s;
}
my $b = pack 'ss', 4+length($c . $d), 22; # 22 is constant
my $a = $b . $c . $d;
$a = encode_base64($a, '');
print "\t\t\t\t\t\t<data>\n";
for (split/(.{28})/, $a) {
print "\t\t\t\t\t\t$_\n" if $_;
}
print "\t\t\t\t\t\t</data>\n";
}
__END__
Leave a comment