Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /bathyscaphe/trunk/frameworks/CocoMonar/framework/src/CMRHostTypes.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1159 - (hide annotations) (download)
Sun Mar 7 07:09:12 2010 UTC (14 years ago) by tsawada2
File size: 3282 byte(s)
CocoMonar Framework and CocoaOniguruma Framework are now 64-bit clean, and the base SDK changed to Mac OS X 10.5
1 tsawada2 1159 //
2     // CMRHostTypes.h
3     // BathyScaphe
4     //
5     // Updated by Tsutomu Sawada on 10/03/07.
6     // Copyright 2005-2010 BathyScaphe Project. All rights reserved.
7     // encoding="UTF-8"
8     //
9 tsawada2 3
10     #import "CMRHostTypes.h"
11     #import <SGFoundation/SGFoundation.h>
12     #import "UTILKit.h"
13    
14    
15    
16     const char *CMRGetHostCStringFromBoardURL(NSURL *anURL, const char **pbbs)
17     {
18     NSMutableData *buffer = nil;
19    
20     const char *path_;
21     const char *host_;
22     size_t bufSize;
23     size_t pathsize;
24     char *p;
25     size_t n;
26    
27 tsawada2 1159 if (pbbs != NULL) {
28     *pbbs = NULL;
29     }
30     if (NULL == anURL || NULL == (path_ = [[anURL absoluteString] UTF8String])) {
31 tsawada2 3 return NULL;
32 tsawada2 1159 }
33    
34 tsawada2 3 pathsize = strlen(path_) * sizeof(char) + 1;
35    
36     buffer = SGTemporaryData();
37     bufSize = [buffer length];
38 tsawada2 1159 if (bufSize < pathsize) {
39     [buffer setLength:pathsize];
40     }
41 tsawada2 3 bufSize = [buffer length];
42     p = (char*)[buffer mutableBytes];
43    
44     memset(p, bufSize, '\0');
45     memmove(p, path_, pathsize);
46 tsawada2 1159
47 tsawada2 3 p = (char*)[[anURL scheme] UTF8String];
48 tsawada2 1159 if (NULL == p) {
49     return NULL;
50     }
51 tsawada2 3 n = strlen(p);
52 tsawada2 1159
53 tsawada2 3 // http://pc.2ch.net/mac
54     host_ = [buffer mutableBytes];
55     // ://pc.2ch.net/mac
56     host_ += n;
57    
58     // //pc.2ch.net/mac
59 tsawada2 1159 if (*host_ != ':') {
60     return NULL;
61     }
62 tsawada2 3 host_++;
63 tsawada2 1159
64 tsawada2 3 // pc.2ch.net/mac
65 tsawada2 1159 while ('/' == *host_) {
66 tsawada2 3 host_++;
67 tsawada2 1159 }
68     while (1) {
69 tsawada2 3 p = strrchr(host_, '/');
70 tsawada2 1159 if (NULL == p) {
71 tsawada2 3 return host_;
72 tsawada2 1159 }
73 tsawada2 3 *p = '\0';
74 tsawada2 1159 if (*(p +1) != '\0') {
75 tsawada2 3 break;
76 tsawada2 1159 }
77 tsawada2 3 }
78 tsawada2 1159
79     if (pbbs != NULL) {
80     *pbbs = ++p;
81     }
82 tsawada2 3 return host_;
83     }
84    
85     NSString *CMRGetHostStringFromBoardURL(NSURL *anURL, NSString **pbbs)
86     {
87     const char *host_;
88     const char *bbs_ = NULL;
89    
90     host_ = CMRGetHostCStringFromBoardURL(anURL, (pbbs ? &bbs_ : NULL));
91    
92 tsawada2 1159 if (pbbs != NULL) {
93 tsawada2 3 *pbbs = bbs_ ? [NSString stringWithUTF8String : bbs_] : nil;
94 tsawada2 1159 }
95     return [NSString stringWithUTF8String:host_];
96 tsawada2 3 }
97 tsawada2 1159
98 tsawada2 3 /*
99 tsawada2 1159 * read.cgi���������������������������������������������������������
100     * ���������������������offlaw���������������URL���������������������������
101 tsawada2 3 */
102     bool can_readcgi(const char *host)
103     {
104 tsawada2 1159 // const char *p;
105     // char *ep;
106     //#warning 64BIT: Inspect use of long
107     // long l;
108 tsawada2 3
109 tsawada2 1159 if (NULL == host) {
110     return false;
111     }
112     if (strstr(host, ".2ch.net")) {
113 tsawada2 3 return !strstr(host, "tako") && !strstr(host, "piza.");
114 tsawada2 1159 }
115     if (strstr(host, ".bbspink.com")) {
116 tsawada2 3 return !strstr(host, "www.");
117 tsawada2 1159 }
118     /* 64.71.128.0/18 216.218.128.0/17 ������������ */
119     // p = strstr(host, "64.71.");
120     // if (p) {
121     // l = strtol(p + 6, &ep, 10);
122     // if (*ep == '.' && (l & 0xc0) == 128) {
123     // return true;
124     // }
125     // }
126     // p = strstr(host, "216.218.");
127     // if (p) {
128     // l = strtol(p + 8, &ep, 10);
129     // if (*ep == '.' && (l & 0x80) == 128) {
130     // return true;
131     // }
132     // }
133     // return strstr(host, ".he.net") != NULL;
134     return false;
135 tsawada2 3 }
136 tsawada2 1159
137 tsawada2 3 bool is_2channel(const char *host)
138     {
139     return can_readcgi(host);
140     }
141 tsawada2 238
142     bool is_2ch_belogin_needed(const char *host)
143     {
144     if (host != NULL) {
145 tsawada2 1159 return strstr(host, "be.2ch.net") != NULL || strstr(host, "qa.2ch.net") != NULL;
146 tsawada2 238 }
147     return false;
148     }
149    
150 tsawada2 1159 bool is_jbbs_livedoor(const char *host)
151 tsawada2 3 {
152     if (host != NULL) {
153 tsawada2 1159 return strstr(host, "jbbs.shitaraba.com") != NULL || strstr(host, "jbbs.livedoor.jp") != NULL || strstr(host, "jbbs.livedoor.com") != NULL;
154 tsawada2 3 }
155     return false;
156     }
157    
158     bool is_machi(const char *host)
159     {
160     return host ? strstr(host, ".machi.to") || strstr(host, ".machibbs.com") : false;
161     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26