summaryrefslogtreecommitdiffstats
path: root/mDNSResponder/mDNSMacOS9/mDNSLibraryLoader.c
blob: 584ff9e20224bf999b718ae8842c26acca0b1692 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* -*- Mode: C; tab-width: 4 -*-
 *
 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <Resources.h>
#include <CodeFragments.h>
#include "ShowInitIcon.h"

extern pascal OSErr FragRegisterFileLibs(ConstFSSpecPtr fss, Boolean unregister);

extern void main(void)
{
    OSStatus err;
    FCBPBRec fcbPB;
    FSSpec fss;

    // 1. Show our "icon march" icon
    ShowInitIcon(128, true);

    // 2. Find our FSSpec
    fss.name[0] = 0;
    fcbPB.ioNamePtr = fss.name;
    fcbPB.ioVRefNum = 0;
    fcbPB.ioRefNum = (short)CurResFile();
    fcbPB.ioFCBIndx = 0;
    err = PBGetFCBInfoSync(&fcbPB);

    // 3. Tell CFM that we're a CFM library container file
    fss.vRefNum = fcbPB.ioFCBVRefNum;
    fss.parID = fcbPB.ioFCBParID;
    if (err == noErr) err = FragRegisterFileLibs(&fss, false);

    // 4. Now that CFM knows we're a library container, tell it to go and get our library
    if (err == noErr)
    {
        CFragConnectionID c;
        Ptr m;
        Str255 e;
        THz oldZone = GetZone();
        SetZone(SystemZone());
        err = GetSharedLibrary("\pDarwin;mDNS", kPowerPCCFragArch, kLoadCFrag, &c, &m, e);
        SetZone(oldZone);
    }
}

// There's no CFM stub library for the FragRegisterFileLibs() call, so we'll make our own
#if __ide_target("FragRegisterFileLibsStub")
#pragma export on
pascal OSErr FragRegisterFileLibs(ConstFSSpecPtr fss, Boolean unregister)
{
    (void)fss;          // Unused
    (void)unregister;   // Unused
    return(0);
}
#endif