Lines 73-78
Link Here
|
73 |
btContent::btContent() |
73 |
btContent::btContent() |
74 |
{ |
74 |
{ |
75 |
m_announce = global_piece_buffer = (char*) 0; |
75 |
m_announce = global_piece_buffer = (char*) 0; |
|
|
76 |
m_comment = (char *) 0; |
76 |
m_hash_table = (unsigned char *) 0; |
77 |
m_hash_table = (unsigned char *) 0; |
77 |
pBF = (BitField*) 0; |
78 |
pBF = (BitField*) 0; |
78 |
pBMasterFilter = (BitField*) 0; |
79 |
pBMasterFilter = (BitField*) 0; |
Lines 163-168
Link Here
|
163 |
if (bencode_str(m_ann1, fp) != 1) goto err; |
164 |
if (bencode_str(m_ann1, fp) != 1) goto err; |
164 |
if (fwrite("ee", strlen("ee"), 1, fp) != 1) goto err; |
165 |
if (fwrite("ee", strlen("ee"), 1, fp) != 1) goto err; |
165 |
} |
166 |
} |
|
|
167 |
|
168 |
if (m_comment) { |
169 |
if (bencode_str("comments", fp) != 1) goto err; |
170 |
if (bencode_str(m_comment, fp) != 1) goto err; |
171 |
} |
172 |
|
166 |
// create date |
173 |
// create date |
167 |
if( bencode_str("creation date", fp) != 1 ) goto err; |
174 |
if( bencode_str("creation date", fp) != 1 ) goto err; |
168 |
if( bencode_int(m_create_date, fp) != 1 ) goto err; |
175 |
if( bencode_int(m_create_date, fp) != 1 ) goto err; |
Lines 195-201
Link Here
|
195 |
return -1; |
202 |
return -1; |
196 |
} |
203 |
} |
197 |
|
204 |
|
198 |
int btContent::InitialFromFS(const char *pathname, char *ann_url, size_t piece_length) |
205 |
int btContent::InitialFromFS(const char *pathname, char *ann_url, char *comment, size_t piece_length) |
199 |
{ |
206 |
{ |
200 |
size_t n, percent; |
207 |
size_t n, percent; |
201 |
|
208 |
|
Lines 211-216
Link Here
|
211 |
m_piece_length = 262144; |
218 |
m_piece_length = 262144; |
212 |
|
219 |
|
213 |
m_announce = ann_url; |
220 |
m_announce = ann_url; |
|
|
221 |
m_comment = comment; |
214 |
m_create_date = time((time_t*) 0); |
222 |
m_create_date = time((time_t*) 0); |
215 |
|
223 |
|
216 |
if(m_btfiles.BuildFromFS(pathname) < 0) return -1; |
224 |
if(m_btfiles.BuildFromFS(pathname) < 0) return -1; |
Lines 248-253
Link Here
|
248 |
{ |
256 |
{ |
249 |
CONSOLE.Print("META INFO"); |
257 |
CONSOLE.Print("META INFO"); |
250 |
CONSOLE.Print("Announce: %s", m_announce); |
258 |
CONSOLE.Print("Announce: %s", m_announce); |
|
|
259 |
if (m_comment) { |
260 |
CONSOLE.Print("Comments: %s", m_comment); |
261 |
} |
251 |
if( m_create_date ){ |
262 |
if( m_create_date ){ |
252 |
char s[42]; |
263 |
char s[42]; |
253 |
#ifdef HAVE_CTIME_R_3 |
264 |
#ifdef HAVE_CTIME_R_3 |
Lines 290-295
Link Here
|
290 |
memcpy(m_announce, s, r); |
301 |
memcpy(m_announce, s, r); |
291 |
m_announce[r] = '\0'; |
302 |
m_announce[r] = '\0'; |
292 |
|
303 |
|
|
|
304 |
// comments |
305 |
if (meta_str("comments", &s, &r)) { |
306 |
if (r > MAXPATHLEN) { |
307 |
ERR_RETURN(); |
308 |
} |
309 |
m_comment = new char [r + 1]; |
310 |
memcpy(m_comment, s, r); |
311 |
m_comment[r] = '\0'; |
312 |
} |
313 |
|
293 |
// infohash |
314 |
// infohash |
294 |
if( !(r = meta_pos("info")) ) ERR_RETURN(); |
315 |
if( !(r = meta_pos("info")) ) ERR_RETURN(); |
295 |
if( !(q = decode_dict(b + r, flen - r, (char *) 0)) ) ERR_RETURN(); |
316 |
if( !(q = decode_dict(b + r, flen - r, (char *) 0)) ) ERR_RETURN(); |