Debian Codegraph @

Framework/Pantomime/CWDNSManager.h

raw symbols SCIP
1 /*
2 ** CWDNSManager.h
3 **
4 ** Copyright (c) 2004-2007 Ludovic Marcotte
5 ** Copyright (C) 2013 The GNUstep team
6 **
7 ** Author: Ludovic Marcotte <[email protected]>
8 ** Riccardo Mottola
9 **
10 ** This library is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU Lesser General Public
12 ** License as published by the Free Software Foundation; either
13 ** version 2.1 of the License, or (at your option) any later version.
14 **
15 ** This library is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** Lesser General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #ifndef _Pantomime_H_CWDNSManager
25 #define _Pantomime_H_CWDNSManager
26
27 #include <Pantomime/CWConnection.h>
28
29 #import <Foundation/NSArray.h>
30 #import <Foundation/NSDictionary.h>
31 #import <Foundation/NSNotification.h>
32 #import <Foundation/NSObject.h>
33 #import <Foundation/NSRunLoop.h>
34 #import <Foundation/NSTimer.h>
35
36 #ifdef MACOSX
37 #import <Foundation/NSMapTable.h>
38 #include <CoreFoundation/CoreFoundation.h>
39 #endif
40
41 #if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
42 #ifndef NSUInteger
43 #define NSUInteger unsigned int
44 #endif
45 #ifndef NSInteger
46 #define NSInteger int
47 #endif
48 #endif
49
50 /*!
51 @const PantomimeDNSResolutionCompleted
52 @discussion This notification is automatically posted when
53 the DNS resolution has completed successfully.
54 */
55 extern NSString* PantomimeDNSResolutionCompleted;
56
57 /*!
58 @const PantomimeDNSResolutionFailed
59 @discussion This notification is automatically posted when
60 the DNS resolution has failed.
61 */
62 extern NSString* PantomimeDNSResolutionFailed;
63
64 #ifdef MACOSX
65 typedef enum {ET_RDESC, ET_WDESC, ET_EDESC} RunLoopEventType;
66 /*!
67 @class CWDNSManager
68 @discussion This class is used in Pantomime to perform DNS resolution.
69 Currently, it does not do asynchronous lookups but implements
70 a simple cache to speedup repetitive requets.
71 */
72 @interface CWDNSManager : NSObject
73 #else
74 @interface CWDNSManager : NSObject <RunLoopEvents>
75 #endif
76 {
77 @private
78 NSMutableArray *_servers, *_queue;
79 NSMutableDictionary *_cache;
80 NSTimer *_timer;
81
82 #ifdef MACOSX
83 CFRunLoopSourceRef _runLoopSource;
84 CFSocketContext *_context;
85 CFSocketRef _cf_socket;
86 #endif
87
88 unsigned short _packet_id;
89 BOOL _is_asynchronous;
90 NSInteger _socket;
91 }
92
93 /*!
94 @method addressesForName:background:
95 @discussion This method is used to obtain an array of IP
96 addresses from a fully qualified domain name.
97 @param theName The fully qualified domain name.
98 @param theBOOL If YES, the call is non-blocking and returns nil.
99 Otherwise, the call is block and returns an
100 array of addresses, if any.
101 @result The array of addresses encoded as NSData instances.
102 */
103 - (NSArray *) addressesForName: (NSString *) theName
104 background: (BOOL) theBOOL;
105 /*!
106 @method singleInstance
107 @discussion This method is used to obtain the shared
108 CWDNSManager instance for DNS resolution.
109 @result The shared instance.
110 */
111 + (id) singleInstance;
112
113 #ifdef MACOSX
114 - (void) receivedEvent: (void *) theData
115 type: (RunLoopEventType) theType
116 extra: (void *) theExtra
117 forMode: (NSString *) theMode;
118 #endif
119
120 @end
121
122 #endif // _Pantomime_H_CWDNSManager