]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/dnssd_object.m
mDNSResponder-1096.100.3.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / dnssd_object.m
1 /*
2 * Copyright (c) 2019 Apple Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #import "dnssd_object.h"
18
19 #import <stdlib.h>
20 #import <Foundation/Foundation.h>
21 #import <os/object_private.h>
22
23 #if 0
24 //======================================================================================================================
25 #pragma mark - Class Declarations
26 #endif
27
28 #define DNSSD_OBJECT_CLASS_DECLARE(NAME) \
29 _OS_OBJECT_DECL_SUBCLASS_INTERFACE(dnssd_ ## NAME, dnssd_object) \
30 extern int _dnssd_dummy_variable
31
32 _OS_OBJECT_DECL_SUBCLASS_INTERFACE(dnssd_object, object)
33
34 DNSSD_OBJECT_CLASS_DECLARE(getaddrinfo);
35 DNSSD_OBJECT_CLASS_DECLARE(getaddrinfo_result);
36
37 #if 0
38 //======================================================================================================================
39 #pragma mark - Class Definitions
40 #endif
41
42 @implementation OS_OBJECT_CLASS(dnssd_object)
43 - (void)dealloc
44 {
45 dnssd_object_finalize(self);
46 [super dealloc];
47 }
48
49 - (NSString *)description
50 {
51 char * const desc = dnssd_object_copy_description(self, false, false);
52 if (desc) {
53 NSString * const string = [NSString stringWithUTF8String:desc];
54 free(desc);
55 return string;
56 } else {
57 return nil;
58 }
59 }
60
61 - (NSString *)debugDescription
62 {
63 char * const desc = dnssd_object_copy_description(self, true, false);
64 if (desc) {
65 NSString * const string = [NSString stringWithUTF8String:desc];
66 free(desc);
67 return string;
68 } else {
69 return nil;
70 }
71 }
72
73 - (NSString *)redactedDescription
74 {
75 char * const desc = dnssd_object_copy_description(self, false, true);
76 if (desc) {
77 NSString * const string = [NSString stringWithUTF8String:desc];
78 free(desc);
79 return string;
80 } else {
81 return nil;
82 }
83 }
84 @end
85
86 #define DNSSD_CLASS(NAME) OS_OBJECT_CLASS(dnssd_ ## NAME)
87 #define DNSSD_OBJECT_CLASS_DEFINE(NAME) \
88 @implementation DNSSD_CLASS(NAME) \
89 @end \
90 \
91 dnssd_ ## NAME ## _t \
92 dnssd_object_ ## NAME ## _alloc(const size_t size) \
93 { \
94 return (dnssd_## NAME ##_t)_os_object_alloc([DNSSD_CLASS(NAME) class], size); \
95 } \
96 extern int _dnssd_dummy_variable
97
98 DNSSD_OBJECT_CLASS_DEFINE(getaddrinfo);
99 DNSSD_OBJECT_CLASS_DEFINE(getaddrinfo_result);