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 818 - (hide annotations) (download)
Sat Oct 20 02:21:29 2007 UTC (16 years, 6 months ago) by tsawada2
File size: 5133 byte(s)
Thread Contextual Menu Fix and Frameworks slimmed

1 tsawada2 3 /**
2 tsawada2 818 * $Id: CMRHostTypes.m,v 1.3 2007-10-20 02:21:29 tsawada2 Exp $
3 tsawada2 3 *
4     * CMRHostTypes.m
5     *
6     * Copyright (c) 2003, Takanori Ishikawa.
7     * See the file LICENSE for copying permission.
8     */
9    
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     if(pbbs != NULL) *pbbs = NULL;
28     if(NULL == anURL || NULL == (path_ = [[anURL absoluteString] UTF8String]))
29     return NULL;
30    
31    
32     pathsize = strlen(path_) * sizeof(char) + 1;
33    
34     buffer = SGTemporaryData();
35     bufSize = [buffer length];
36     if(bufSize < pathsize)
37     [buffer setLength : pathsize];
38    
39     bufSize = [buffer length];
40     p = (char*)[buffer mutableBytes];
41    
42     memset(p, bufSize, '\0');
43     memmove(p, path_, pathsize);
44    
45     p = (char*)[[anURL scheme] UTF8String];
46     if(NULL == p) return NULL;
47     n = strlen(p);
48    
49     // http://pc.2ch.net/mac
50     host_ = [buffer mutableBytes];
51     // ://pc.2ch.net/mac
52     host_ += n;
53    
54     // //pc.2ch.net/mac
55     if(*host_ != ':') return NULL;
56     host_++;
57    
58     // pc.2ch.net/mac
59     while('/' == *host_)
60     host_++;
61    
62     while(1){
63     p = strrchr(host_, '/');
64     if(NULL == p)
65     return host_;
66    
67     *p = '\0';
68     if(*(p +1) != '\0')
69     break;
70     }
71    
72     if(pbbs != NULL) *pbbs = ++p;
73    
74     return host_;
75     }
76    
77     NSString *CMRGetHostStringFromBoardURL(NSURL *anURL, NSString **pbbs)
78     {
79     const char *host_;
80     const char *bbs_ = NULL;
81    
82     host_ = CMRGetHostCStringFromBoardURL(anURL, (pbbs ? &bbs_ : NULL));
83    
84     if(pbbs != NULL)
85     *pbbs = bbs_ ? [NSString stringWithUTF8String : bbs_] : nil;
86    
87     return [NSString stringWithUTF8String : host_];
88     }
89 tsawada2 818 /*NSString *CMRGetHostStringFromBoardURLNoCopy(NSURL *anURL, NSString **pbbs)
90 tsawada2 3 {
91     const char *host_;
92     const char *bbs_ = NULL;
93    
94     host_ = CMRGetHostCStringFromBoardURL(anURL, (pbbs ? &bbs_ : NULL));
95     if(pbbs != NULL)
96     *pbbs = bbs_ ? [NSString stringWithCStringNoCopy:bbs_] : nil;
97    
98     return [NSString stringWithCStringNoCopy:host_];
99     }
100 tsawada2 818 */
101 tsawada2 3 /*
102     * read.cgi���p�X�d�l����������������������������
103     * �������O�q���Aofflaw�A���g�b�vURL�����������������p
104     */
105     bool can_readcgi(const char *host)
106     {
107     const char *p;
108     char *ep;
109     long l;
110    
111     if(NULL == host) return false;
112    
113     if (strstr(host, ".2ch.net"))
114     return !strstr(host, "tako") && !strstr(host, "piza.");
115     if (strstr(host, ".bbspink.com"))
116     return !strstr(host, "www.");
117     /* 64.71.128.0/18 216.218.128.0/17 ���e�X�g */
118     p = strstr(host, "64.71.");
119     if (p) {
120     l = strtol(p + 6, &ep, 10);
121     if (*ep == '.' && (l & 0xc0) == 128)
122     return true;
123     }
124     p = strstr(host, "216.218.");
125     if (p) {
126     l = strtol(p + 8, &ep, 10);
127     if (*ep == '.' && (l & 0x80) == 128)
128     return true;
129     }
130     return strstr(host, ".he.net") != NULL;
131     }
132     bool is_2channel(const char *host)
133     {
134     return can_readcgi(host);
135     }
136     //
137     bool is_be2ch(const char *host)
138     {
139     return host ? strstr(host, "be.2ch.net") != NULL && can_readcgi(host) : true;
140     }
141 tsawada2 238
142     bool is_2ch_belogin_needed(const char *host)
143     {
144     if (host != NULL) {
145     return strstr(host, "be.2ch.net") != NULL ||
146     strstr(host, "qa.2ch.net") != NULL;
147     }
148     return false;
149     }
150    
151 tsawada2 3 bool is_jbbs_shita(const char *host)
152     {
153     if (host != NULL) {
154     return strstr(host, "jbbs.shitaraba.com") != NULL ||
155     strstr(host, "jbbs.livedoor.jp") != NULL ||
156     strstr(host, "jbbs.livedoor.com") != NULL;
157     }
158     return false;
159     }
160    
161 tsawada2 818 bool is_jbbs_livedoor(const char *host)
162     {
163     return is_jbbs_shita(host);
164     }
165    
166 tsawada2 3 bool is_machi(const char *host)
167     {
168     return host ? strstr(host, ".machi.to") || strstr(host, ".machibbs.com") : false;
169     }
170 tsawada2 818 /*
171 tsawada2 3 bool is_jbbs(const char *host)
172     {
173     return host ? strstr(host, ".jbbs.net") || is_jbbs_shita(host) : false;
174     }
175    
176     bool is_shitaraba(const char *host)
177     {
178     return host ? strstr(host, ".shitaraba.com") != NULL && !is_jbbs_shita(host) : false;
179     }
180    
181     bool is_tanteifile(const char *host)
182     {
183     return host ? strstr(host, "tanteifile2.gasuki.com") : false;
184     }
185 tsawada2 818 */
186 tsawada2 3
187     /*
188     * offlaw.cgi���g������������
189     */
190 tsawada2 818 /*bool can_offlaw(const char *host)
191 tsawada2 3 {
192     return false;
193     // return can_readcgi(host) && strstr(host, "choco.");
194     }
195 tsawada2 818 */
196 tsawada2 3
197     /*
198     * �������O�q�����V�`����������
199     */
200 tsawada2 818 /*bool kako_salad(const char *host, const char *bbs)
201 tsawada2 3 {
202     static char *oldkako_servers[] = {
203     "piza.",
204     "www.bbspink",
205     NULL,
206     };
207     int i;
208    
209     if (!can_readcgi(host))
210     return false;
211    
212     for (i = 0; oldkako_servers[i]; i++) {
213     if (strstr(host, oldkako_servers[i]))
214     return false;
215     }
216    
217     if (strstr(host, "mentai.2ch.net")) {
218     //debugout && fprintf(debugout, "kako_salad: bbs=%s\n", bbs);
219     if(strstr(bbs, "mukashi/"))
220     return false;
221     }
222    
223     if (strstr(host, "www.2ch.net")) {
224     //debugout && fprintf(debugout, "kako_salad: bbs=%s\n", bbs);
225     if(strstr(bbs, "tako/") || strstr(bbs, "kitanet/"))
226     return false;
227     }
228    
229     return true;
230     }
231 tsawada2 818 */
232 tsawada2 3 /*
233     * bbs.cgi���V�^�C�v��������
234     */
235 tsawada2 818 /*bool bbs_qb(const char *host)
236 tsawada2 3 {
237     #if 0
238     static char *newbbs_servers[] = {
239     // "qb.",
240     "ex.",
241     "choco.",
242     "comic.",
243     "music.",
244     "teri.",
245     // "cocoa.",
246     "game.",
247     "oyster.",
248     NULL,
249     };
250     int i;
251    
252     if (!can_readcgi(host))
253     return false;
254    
255     for (i = 0; newbbs_servers[i]; i++) {
256     if (strstr(host, newbbs_servers[i]))
257     return true;
258     }
259    
260     #endif
261     return false;
262 tsawada2 818 }*/

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