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 238 - (hide annotations) (download)
Wed Nov 30 23:22:51 2005 UTC (18 years, 4 months ago) by tsawada2
File size: 5039 byte(s)
BoardInfoInspector Update

1 tsawada2 3 /**
2 tsawada2 238 * $Id: CMRHostTypes.m,v 1.2 2005-11-30 23:22:51 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     NSString *CMRGetHostStringFromBoardURLNoCopy(NSURL *anURL, NSString **pbbs)
90     {
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    
101     /*
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     bool is_machi(const char *host)
162     {
163     return host ? strstr(host, ".machi.to") || strstr(host, ".machibbs.com") : false;
164     }
165    
166     bool is_jbbs(const char *host)
167     {
168     return host ? strstr(host, ".jbbs.net") || is_jbbs_shita(host) : false;
169     }
170    
171     bool is_shitaraba(const char *host)
172     {
173     return host ? strstr(host, ".shitaraba.com") != NULL && !is_jbbs_shita(host) : false;
174     }
175    
176     bool is_tanteifile(const char *host)
177     {
178     return host ? strstr(host, "tanteifile2.gasuki.com") : false;
179     }
180    
181    
182     /*
183     * offlaw.cgi���g������������
184     */
185     bool can_offlaw(const char *host)
186     {
187     return false;
188     // return can_readcgi(host) && strstr(host, "choco.");
189     }
190    
191    
192     /*
193     * �������O�q�����V�`����������
194     */
195     bool kako_salad(const char *host, const char *bbs)
196     {
197     static char *oldkako_servers[] = {
198     "piza.",
199     "www.bbspink",
200     NULL,
201     };
202     int i;
203    
204     if (!can_readcgi(host))
205     return false;
206    
207     for (i = 0; oldkako_servers[i]; i++) {
208     if (strstr(host, oldkako_servers[i]))
209     return false;
210     }
211    
212     if (strstr(host, "mentai.2ch.net")) {
213     //debugout && fprintf(debugout, "kako_salad: bbs=%s\n", bbs);
214     if(strstr(bbs, "mukashi/"))
215     return false;
216     }
217    
218     if (strstr(host, "www.2ch.net")) {
219     //debugout && fprintf(debugout, "kako_salad: bbs=%s\n", bbs);
220     if(strstr(bbs, "tako/") || strstr(bbs, "kitanet/"))
221     return false;
222     }
223    
224     return true;
225     }
226    
227     /*
228     * bbs.cgi���V�^�C�v��������
229     */
230     bool bbs_qb(const char *host)
231     {
232     #if 0
233     static char *newbbs_servers[] = {
234     // "qb.",
235     "ex.",
236     "choco.",
237     "comic.",
238     "music.",
239     "teri.",
240     // "cocoa.",
241     "game.",
242     "oyster.",
243     NULL,
244     };
245     int i;
246    
247     if (!can_readcgi(host))
248     return false;
249    
250     for (i = 0; newbbs_servers[i]; i++) {
251     if (strstr(host, newbbs_servers[i]))
252     return true;
253     }
254    
255     #endif
256     return false;
257     }

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