[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Apple Events over TCP/IP



For those who care, here is the code I came up with.  As I suspected, it
was the LocationNameRec that was the problem ... I got the right
PPCLocationKind and instead of an EntityName, then I use the new structure
PPCAddrRec.  This will be in a coming release of Mac::AppleEvents::Simple
and Mac::Glue.

sub pack_ppc  { _pack_ppc('ppc',  @_) }
sub pack_eppc { _pack_ppc('eppc', @_) }

sub _pack_ppc {
    my($type, $id, $name, $server, $zone) = @_;
    my %TargetID;

    $TargetID{sess} = ['l', 0];             # long sessionID
    $TargetID{name} = ['sca33sca33',        # PPCPortRec name
        0,                                      # ScriptCode nameScript
        length($name), $name,                   # Str32Field name
        2,                                      # PPCPortKinds ppcByString
        length($id . 'ep01'), $id . 'ep01',     # Str32 portTypeStr
    ];

    if ($type eq 'ppc') {
        my $atype = 'PPCToolbox';
        $zone ||= '*';
        $TargetID{loca} = ['sca33ca33ca33', # LocationNameRec location
            1,                              # PPCLocationKind ppcNBPLocation
                                            # EntityName
            length($server), $server,           # Str32Field objStr
            length($atype), $atype,             # Str32Field typeStr
            length($zone), $zone,               # Str32Field zoneStr
        ];
    } elsif ($type eq 'eppc') {
        $TargetID{loca} = ['ssssa*',        # LocationNameRec location
            3,                              # PPCLocationKind
                                            #     ppcXTIAddrLocation
                                            # PPCAddrRec xtiType
            0,                                  # UInt8 Reserved (0)
            2 + length($server),                # UInt8 xtiAddrLen
                                                # PPCXTIAddress xtiAddr
            42,                                     # PPCXTIAddressType
                                                    #     kDNSAddrType
            $server                                 # UInt8 fAddress[96]
        ];
    } else {
        die "Type $type not recognized\n";
    }

    my($format, @args, $targ);
    for (qw[sess name loca]) {
        my @foo = @{$TargetID{$_}};
        $format .= shift @foo;
        push @args, @foo;
    }
    $targ  = pack $format, @args;

    printf("> %s\n< %s\n\n", $targ, join("|", unpack $format, $targ))
        if $DEBUG > 1;
    return $targ;
}

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org