2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 Change History (most recent first):
27 $Log: mDNSLibrary.c,v $
28 Revision 1.1 2004/03/12 21:30:26 cheshire
29 Build a System-Context Shared Library from mDNSCore, for the benefit of developers
30 like Muse Research who want to be able to use mDNS/DNS-SD from GPL-licensed code.
34 // Define the required CFM Shared Library entry and exit points
35 #include <CodeFragments.h>
36 #include "mDNSClientAPI.h" // Defines the interface to the client layer above
37 #include "mDNSMacOS9.h" // Defines the specific types needed to run mDNS on this platform
40 static mDNS_PlatformSupport PlatformSupportStorage
;
41 #define RR_CACHE_SIZE 64
42 static CacheRecord rrcachestorage
[RR_CACHE_SIZE
];
44 mDNSlocal
void mDNS_StatusCallback(mDNS
*const m
, mStatus result
)
46 if (result
== mStatus_GrowCache
)
48 // If we've run out of cache space, then double the total cache size and give the memory to mDNSCore
49 mDNSu32 numrecords
= m
->rrcache_size
;
50 CacheRecord
*storage
= OTAllocMem(sizeof(CacheRecord
) * numrecords
);
51 LogMsg("mStatus_GrowCache %d", numrecords
);
52 if (storage
) mDNS_GrowCache(m
, storage
, numrecords
);
56 extern pascal OSErr
mDNS_CFMInit(const CFragInitBlock
*theInitBlock
);
57 pascal OSErr
mDNS_CFMInit(const CFragInitBlock
*theInitBlock
)
59 extern pascal OSErr
__initialize(const CFragInitBlock
*theInitBlock
);
60 __initialize(theInitBlock
); // MUST do this first!
63 THz oldZone
= GetZone();
64 SetZone(SystemZone());
65 LogMsg("mDNS/DNS-SD with Macsbug breaks -- do not ship this version to customers");
66 err
= mDNS_Init(&mDNSStorage
, &PlatformSupportStorage
, rrcachestorage
, RR_CACHE_SIZE
,
67 mDNS_Init_AdvertiseLocalAddresses
, mDNS_StatusCallback
, mDNS_Init_NoInitCallbackContext
);
73 extern void mDNS_CFMTerm(void);
74 void mDNS_CFMTerm(void)
76 extern pascal void __terminate(void);
77 LogMsg("mDNS_CFMTerm");
78 mDNS_Close(&mDNSStorage
);