-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathIPSeeker.h
56 lines (47 loc) · 1.7 KB
/
IPSeeker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* LumaQQ - Cross platform QQ client, special edition for Mac
*
* Copyright (C) 2007 luma <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import <Cocoa/Cocoa.h>
@interface IPSeeker : NSObject {
NSFileHandle* m_file;
UInt32 m_indexBegin;
UInt32 m_indexEnd;
// cache
NSMutableDictionary* m_cache;
}
+ (IPSeeker*)shared;
// API
- (NSString*)getLocation:(const char*)ip locationOnly:(BOOL)locationOnly;
- (NSString*)getLocation:(const char*)ip;
- (NSString*)getLocationByOffset:(unsigned long long)offset;
// helper
- (int)compareByte:(char)b1 withByte:(char)b2;
- (int)compareIP:(const char*)ip withIP:(const char*)beginIp;
- (UInt32)getMiddleOffset:(UInt32)begin end:(UInt32)end;
- (UInt32)locateIP:(const char*)ip;
// basic reading
- (UInt32)readInt3;
- (UInt32)readInt3:(unsigned long long)offset;
- (UInt32)readInt4;
- (UInt32)readInt4:(unsigned long long)offset;
- (NSString*)readString:(unsigned long long)offset;
// advanced reading
- (NSString*)readArea:(unsigned long long)offset;
- (NSData*)readIP:(unsigned long long)offset;
@end