More Fun With Internet Config Prefs in Mac OS X

| | Comments (0)
I was having problems with my IC mappings (IC == Internet Config / Internet Control Panel / Internet System Preferences, stored in 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. :)

#!perl -w
use Mac::InternetConfig;
use MIME::Base64;
my %dups;
for my $e (keys %InternetConfigMap) {
    next if exists $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";

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on August 20, 2002 9:04 PM.

Entry Deleted was the previous entry in this site.

More on "Mac OS X" is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.