View | Details | Raw Unified | Return to bug 13930
Collapse All | Expand All

(-)ctorrent-dnh3.2/btconfig.cpp (+1 lines)
Lines 38-43 Link Here
38
38
39
size_t arg_piece_length = 262144;
39
size_t arg_piece_length = 262144;
40
char *arg_announce = (char*) 0;
40
char *arg_announce = (char*) 0;
41
char *arg_comment = (char *) 0;
41
42
42
char *arg_ctcs = (char*) 0;
43
char *arg_ctcs = (char*) 0;
43
char *arg_completion_exit = (char*) 0;
44
char *arg_completion_exit = (char*) 0;
(-)ctorrent-dnh3.2/btconfig.h (+1 lines)
Lines 52-57 Link Here
52
52
53
extern size_t arg_piece_length;
53
extern size_t arg_piece_length;
54
extern char *arg_announce;
54
extern char *arg_announce;
55
extern char *arg_comment;
55
56
56
extern char *arg_ctcs;
57
extern char *arg_ctcs;
57
extern char *arg_completion_exit;
58
extern char *arg_completion_exit;
(-)ctorrent-dnh3.2/btcontent.cpp (-1 / +22 lines)
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();
(-)ctorrent-dnh3.2/btcontent.h (-1 / +2 lines)
Lines 47-52 Link Here
47
{
47
{
48
  //METAINFO³ÉÔ±
48
  //METAINFO³ÉÔ±
49
  char *m_announce;
49
  char *m_announce;
50
  char *m_comment;
50
  unsigned char *m_hash_table;
51
  unsigned char *m_hash_table;
51
  unsigned char m_shake_buffer[68];
52
  unsigned char m_shake_buffer[68];
52
53
Lines 105-111 Link Here
105
  int FlushFailed() const { return m_flush_failed ? 1 : 0 ; }
106
  int FlushFailed() const { return m_flush_failed ? 1 : 0 ; }
106
107
107
  int CreateMetainfoFile(const char *mifn);
108
  int CreateMetainfoFile(const char *mifn);
108
  int InitialFromFS(const char *pathname, char *ann_url, size_t piece_length);
109
  int InitialFromFS(const char *pathname, char *ann_url, char *comment, size_t piece_length);
109
  int InitialFromMI(const char *metainfo_fname,const char *saveas);
110
  int InitialFromMI(const char *metainfo_fname,const char *saveas);
110
111
111
  int CheckNextPiece();
112
  int CheckNextPiece();
(-)ctorrent-dnh3.2/ctorrent.cpp (-2 / +11 lines)
Lines 84-90 Link Here
84
      CONSOLE.Warning(1, "please use -s to specify a metainfo file name!");
84
      CONSOLE.Warning(1, "please use -s to specify a metainfo file name!");
85
      exit(1);
85
      exit(1);
86
    }
86
    }
87
    if( BTCONTENT.InitialFromFS(arg_metainfo_file, arg_announce,
87
    if( BTCONTENT.InitialFromFS(arg_metainfo_file, arg_announce, arg_comment,
88
                                arg_piece_length) < 0 ||
88
                                arg_piece_length) < 0 ||
89
        BTCONTENT.CreateMetainfoFile(arg_save_as) < 0 ){
89
        BTCONTENT.CreateMetainfoFile(arg_save_as) < 0 ){
90
      CONSOLE.Warning(1, "create metainfo failed.");
90
      CONSOLE.Warning(1, "create metainfo failed.");
Lines 137-143 Link Here
137
  int c, l;
137
  int c, l;
138
  char *s;
138
  char *s;
139
  while( (c=getopt(argc,argv,
139
  while( (c=getopt(argc,argv,
140
            "aA:b:cC:dD:e:E:fi:l:M:m:n:P:p:s:S:tTu:U:vxX:z:hH"))
140
            "aA:b:cC:dD:e:E:fi:l:M:m:n:o:P:p:s:S:tTu:U:vxX:z:hH"))
141
           != -1 )
141
           != -1 )
142
    switch( c ){
142
    switch( c ){
143
    case 'a':
143
    case 'a':
Lines 264-269 Link Here
264
      strcpy(arg_announce, optarg);
264
      strcpy(arg_announce, optarg);
265
      break;
265
      break;
266
266
267
    case 'o':			// Comment
268
      if (arg_comment) return -1;  // specified twice
269
      arg_comment = new char[strlen(optarg) + 1];
270
#ifndef WINDOWS
271
      if (!arg_comment) return -1;
272
#endif
273
      strcpy(arg_comment, optarg);
274
      break;
275
267
    case 't':			// make Torrent
276
    case 't':			// make Torrent
268
      arg_flg_make_torrent = 1;
277
      arg_flg_make_torrent = 1;
269
      break;
278
      break;

Return to bug 13930