Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Tuesday August 20, 2002
11:04 PM

More Fun With Internet Config Prefs in Mac OS X

[ #7207 ]

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";

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.