]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOS9/mDNSLibrary.c
mDNSResponder-87.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.2 2004/09/17 01:08:50 cheshire
27 Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
28 The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
29 declared in that file are ONLY appropriate to single-address-space embedded applications.
30 For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
31
32 Revision 1.1 2004/03/12 21:30:26 cheshire
33 Build a System-Context Shared Library from mDNSCore, for the benefit of developers
34 like Muse Research who want to be able to use mDNS/DNS-SD from GPL-licensed code.
35
36 */
37
38 // Define the required CFM Shared Library entry and exit points
39 #include <CodeFragments.h>
40 #include "mDNSEmbeddedAPI.h" // Defines the interface to the client layer above
41 #include "mDNSMacOS9.h" // Defines the specific types needed to run mDNS on this platform
42
43 mDNS mDNSStorage;
44 static mDNS_PlatformSupport PlatformSupportStorage;
45 #define RR_CACHE_SIZE 64
46 static CacheRecord rrcachestorage[RR_CACHE_SIZE];
47
48 mDNSlocal void mDNS_StatusCallback(mDNS *const m, mStatus result)
49 {
50 if (result == mStatus_GrowCache)
51 {
52 // If we've run out of cache space, then double the total cache size and give the memory to mDNSCore
53 mDNSu32 numrecords = m->rrcache_size;
54 CacheRecord *storage = OTAllocMem(sizeof(CacheRecord) * numrecords);
55 LogMsg("mStatus_GrowCache %d", numrecords);
56 if (storage) mDNS_GrowCache(m, storage, numrecords);
57 }
58 }
59
60 extern pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock);
61 pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock)
62 {
63 extern pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
64 __initialize(theInitBlock); // MUST do this first!
65 {
66 mStatus err;
67 THz oldZone = GetZone();
68 SetZone(SystemZone());
69 LogMsg("mDNS/DNS-SD with Macsbug breaks -- do not ship this version to customers");
70 err = mDNS_Init(&mDNSStorage, &PlatformSupportStorage, rrcachestorage, RR_CACHE_SIZE,
71 mDNS_Init_AdvertiseLocalAddresses, mDNS_StatusCallback, mDNS_Init_NoInitCallbackContext);
72 SetZone(oldZone);
73 return((OSErr)err);
74 }
75 }
76
77 extern void mDNS_CFMTerm(void);
78 void mDNS_CFMTerm(void)
79 {
80 extern pascal void __terminate(void);
81 LogMsg("mDNS_CFMTerm");
82 mDNS_Close(&mDNSStorage);
83 __terminate();
84 }