From 2fd1f7c34e9ee85d5b995dc165fe8531fcb0ad31 Mon Sep 17 00:00:00 2001 From: Marq Schneider Date: Sun, 6 May 2012 22:54:39 -0500 Subject: Add optional label to be associated with torrent. If none given, use announce URL as label. Torrents added with previous versions of btpd will show up as "bad torrent entry" Closes GH-26 --- misc/btpd_if.c | 4 +++- misc/btpd_if.h | 2 +- misc/ipcdefs.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'misc') diff --git a/misc/btpd_if.c b/misc/btpd_if.c index e208d64..3c32b9c 100644 --- a/misc/btpd_if.c +++ b/misc/btpd_if.c @@ -264,13 +264,15 @@ btpd_tget_wc(struct ipc *ipc, enum ipc_twc twc, enum ipc_tval *keys, enum ipc_err btpd_add(struct ipc *ipc, const char *mi, size_t mi_size, const char *content, - const char *name) + const char *name, const char *label) { struct iobuf iob = iobuf_init(1 << 10); iobuf_print(&iob, "l3:addd7:content%d:%s", (int)strlen(content), content); if (name != NULL) iobuf_print(&iob, "4:name%d:%s", (int)strlen(name), name); + if (label != NULL) + iobuf_print(&iob, "5:label%d:%s", (int)strlen(label), label); iobuf_print(&iob, "7:torrent%lu:", (unsigned long)mi_size); iobuf_write(&iob, mi, mi_size); iobuf_swrite(&iob, "ee"); diff --git a/misc/btpd_if.h b/misc/btpd_if.h index 66b247a..070cb29 100644 --- a/misc/btpd_if.h +++ b/misc/btpd_if.h @@ -75,7 +75,7 @@ void ipc_close(struct ipc *ipc); const char *ipc_strerror(enum ipc_err err); enum ipc_err btpd_add(struct ipc *ipc, const char *mi, size_t mi_size, - const char *content, const char *name); + const char *content, const char *name, const char *label); enum ipc_err btpd_del(struct ipc *ipc, struct ipc_torrent *tp); enum ipc_err btpd_rate(struct ipc *ipc, unsigned up, unsigned down); enum ipc_err btpd_start(struct ipc *ipc, struct ipc_torrent *tp); diff --git a/misc/ipcdefs.h b/misc/ipcdefs.h index fa06949..573c007 100644 --- a/misc/ipcdefs.h +++ b/misc/ipcdefs.h @@ -41,7 +41,8 @@ TVDEF(STATE, TSTATE, "state") TVDEF(TOTDWN, NUM, "total_down") TVDEF(TOTUP, NUM, "total_up") TVDEF(TRERR, NUM, "tr_errors") -TVDEF(TRGOOD, NUM, "tr_good") +TVDEF(TRGOOD, NUM, "tr_good") +TVDEF(LABEL, STR, "label") #ifdef __IPCTV #undef __IPCTV #undef TVDEF -- cgit 1.4.1