Browse Source

Each torrent now gets a number. This number is used to select which torrent

to operate on from btcli.
master
Richard Nyberg 19 years ago
parent
commit
53c3ba32cf
2 changed files with 12 additions and 0 deletions
  1. +11
    -0
      btpd/torrent.c
  2. +1
    -0
      btpd/torrent.h

+ 11
- 0
btpd/torrent.c View File

@@ -19,6 +19,16 @@
#include "tracker_req.h"
#include "stream.h"

static unsigned m_next_num;

static unsigned
num_get_next(void)
{
if (m_next_num == UINT_MAX)
btpd_err("Reached maximum torrent number.\n");
return m_next_num++;
}

off_t
torrent_piece_size(struct torrent *tp, uint32_t index)
{
@@ -107,6 +117,7 @@ torrent_load(struct torrent **res, const char *path)
*res = btpd_calloc(1, sizeof(**res));
(*res)->relpath = strdup(path);
(*res)->meta = *mi;
(*res)->num = num_get_next();
free(mi);
} else {
clear_metainfo(mi);


+ 1
- 0
btpd/torrent.h View File

@@ -11,6 +11,7 @@ enum torrent_state {
};

struct torrent {
unsigned num;
const char *relpath;
struct metainfo meta;



Loading…
Cancel
Save