]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOS9/mDNSLibrary.c
mDNSResponder-107.5.tar.gz
[apple/mdnsresponder.git] / mDNSMacOS9 / mDNSLibrary.c
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 Change History (most recent first):
24
25 $Log: mDNSLibrary.c,v $
26 Revision 1.3 2004/12/16 20:49:35 cheshire
27 <rdar://problem/3324626> Cache memory management improvements
28
29 Revision 1.2 2004/09/17 01:08:50 cheshire
30 Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
31 The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
32 declared in that file are ONLY appropriate to single-address-space embedded applications.
33 For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
34
35 Revision 1.1 2004/03/12 21:30:26 cheshire
36 Build a System-Context Shared Library from mDNSCore, for the benefit of developers
37 like Muse Research who want to be able to use mDNS/DNS-SD from GPL-licensed code.
38
39 */
40
41 // Define the required CFM Shared Library entry and exit points
42 #include <CodeFragments.h>
43 #include "mDNSEmbeddedAPI.h" // Defines the interface to the client layer above
44 #include "mDNSMacOS9.h" // Defines the specific types needed to run mDNS on this platform
45
46 mDNS mDNSStorage;
47 static mDNS_PlatformSupport PlatformSupportStorage;
48 // Start off with a default cache of 16K (about 100 records)
49 #define RR_CACHE_SIZE ((16*1024) / sizeof(CacheRecord))
50 static CacheEntity rrcachestorage[RR_CACHE_SIZE];
51
52 mDNSlocal void mDNS_StatusCallback(mDNS *const m, mStatus result)
53 {
54 if (result == mStatus_GrowCache)
55 {
56 // Allocate another chunk of cache storage
57 CacheEntity *storage = OTAllocMem(sizeof(CacheEntity) * RR_CACHE_SIZE);
58 if (storage) mDNS_GrowCache(m, storage, RR_CACHE_SIZE);
59 }
60 }
61
62 extern pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock);
63 pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock)
64 {
65 extern pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
66 __initialize(theInitBlock); // MUST do this first!
67 {
68 mStatus err;
69 THz oldZone = GetZone();
70 SetZone(SystemZone());
71 LogMsg("mDNS/DNS-SD with Macsbug breaks -- do not ship this version to customers");
72 err = mDNS_Init(&mDNSStorage, &PlatformSupportStorage, rrcachestorage, RR_CACHE_SIZE,
73 mDNS_Init_AdvertiseLocalAddresses, mDNS_StatusCallback, mDNS_Init_NoInitCallbackContext);
74 SetZone(oldZone);
75 return((OSErr)err);
76 }
77 }
78
79 extern void mDNS_CFMTerm(void);
80 void mDNS_CFMTerm(void)
81 {
82 extern pascal void __terminate(void);
83 LogMsg("mDNS_CFMTerm");
84 mDNS_Close(&mDNSStorage);
85 __terminate();
86 }