about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-02-05 11:30:08 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-02-05 11:30:08 +0000
commit65f3eb2185e3cb9ed91f3c76d68673fc0b8d4d4c (patch)
tree52478fdbe755de3728d56e832df4bcd21b6ab331
parent53c3ba32cf834840ae2fdcb38aca3a7f99a42cbd (diff)
downloadbtpd-65f3eb2185e3cb9ed91f3c76d68673fc0b8d4d4c.tar.gz
btpd-65f3eb2185e3cb9ed91f3c76d68673fc0b8d4d4c.zip
Add a function to look up a torrent by its number.
-rw-r--r--btpd/btpd.c11
-rw-r--r--btpd/btpd.h3
2 files changed, 13 insertions, 1 deletions
diff --git a/btpd/btpd.c b/btpd/btpd.c
index 3a4a346..c73d5bd 100644
--- a/btpd/btpd.c
+++ b/btpd/btpd.c
@@ -123,6 +123,15 @@ btpd_get_torrent(const uint8_t *hash)
     return tp;
 }
 
+struct torrent *
+btpd_get_torrent_num(unsigned num)
+{
+    struct torrent *tp = BTPDQ_FIRST(&m_torrents);
+    while (tp != NULL && tp->num != num)
+        tp = BTPDQ_NEXT(tp, entry);
+    return tp;
+}
+
 const uint8_t *
 btpd_get_peer_id(void)
 {
@@ -253,9 +262,11 @@ btpd_init(void)
 
     load_library();
 
+#if 0
     struct torrent *tp;
     BTPDQ_FOREACH(tp, &m_torrents, entry)
         torrent_activate(tp);
+#endif
 
     signal(SIGPIPE, SIG_IGN);
 
diff --git a/btpd/btpd.h b/btpd/btpd.h
index 6feba67..1700248 100644
--- a/btpd/btpd.h
+++ b/btpd/btpd.h
@@ -50,7 +50,8 @@ void *btpd_calloc(size_t nmemb, size_t size);
 
 void btpd_shutdown(struct timeval *grace_tv);
 
-struct torrent * btpd_get_torrent(const uint8_t *hash);
+struct torrent *btpd_get_torrent(const uint8_t *hash);
+struct torrent *btpd_get_torrent_num(unsigned num);
 const struct torrent_tq *btpd_get_torrents(void);
 void btpd_add_torrent(struct torrent *tp);
 void btpd_del_torrent(struct torrent *tp);