]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOS9/mDNSLibrary.c
mDNSResponder-66.3.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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
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
13 * file.
14 *
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.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24
25 Change History (most recent first):
26
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.
31
32 */
33
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
38
39 mDNS mDNSStorage;
40 static mDNS_PlatformSupport PlatformSupportStorage;
41 #define RR_CACHE_SIZE 64
42 static CacheRecord rrcachestorage[RR_CACHE_SIZE];
43
44 mDNSlocal void mDNS_StatusCallback(mDNS *const m, mStatus result)
45 {
46 if (result == mStatus_GrowCache)
47 {
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);
53 }
54 }
55
56 extern pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock);
57 pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock)
58 {
59 extern pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
60 __initialize(theInitBlock); // MUST do this first!
61 {
62 mStatus err;
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);
68 SetZone(oldZone);
69 return((OSErr)err);
70 }
71 }
72
73 extern void mDNS_CFMTerm(void);
74 void mDNS_CFMTerm(void)
75 {
76 extern pascal void __terminate(void);
77 LogMsg("mDNS_CFMTerm");
78 mDNS_Close(&mDNSStorage);
79 __terminate();
80 }