]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOS9/mDNSLibrary.c
mDNSResponder-567.tar.gz
[apple/mdnsresponder.git] / mDNSMacOS9 / mDNSLibrary.c
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 // Define the required CFM Shared Library entry and exit points
19 #include <CodeFragments.h>
20 #include "mDNSEmbeddedAPI.h" // Defines the interface to the client layer above
21 #include "mDNSMacOS9.h" // Defines the specific types needed to run mDNS on this platform
22
23 mDNS mDNSStorage;
24 static mDNS_PlatformSupport PlatformSupportStorage;
25 // Start off with a default cache of 16K (about 100 records)
26 #define RR_CACHE_SIZE ((16*1024) / sizeof(CacheRecord))
27 static CacheEntity rrcachestorage[RR_CACHE_SIZE];
28
29 mDNSlocal void mDNS_StatusCallback(mDNS *const m, mStatus result)
30 {
31 if (result == mStatus_GrowCache)
32 {
33 // Allocate another chunk of cache storage
34 CacheEntity *storage = OTAllocMem(sizeof(CacheEntity) * RR_CACHE_SIZE);
35 if (storage) mDNS_GrowCache(m, storage, RR_CACHE_SIZE);
36 }
37 }
38
39 extern pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock);
40 pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock)
41 {
42 extern pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
43 __initialize(theInitBlock); // MUST do this first!
44 {
45 mStatus err;
46 THz oldZone = GetZone();
47 SetZone(SystemZone());
48 LogMsg("mDNS/DNS-SD with Macsbug breaks -- do not ship this version to customers");
49 err = mDNS_Init(&mDNSStorage, &PlatformSupportStorage, rrcachestorage, RR_CACHE_SIZE,
50 mDNS_Init_AdvertiseLocalAddresses, mDNS_StatusCallback, mDNS_Init_NoInitCallbackContext);
51 SetZone(oldZone);
52 return((OSErr)err);
53 }
54 }
55
56 extern void mDNS_CFMTerm(void);
57 void mDNS_CFMTerm(void)
58 {
59 extern pascal void __terminate(void);
60 LogMsg("mDNS_CFMTerm");
61 mDNS_Close(&mDNSStorage);
62 __terminate();
63 }