Bläddra i källkod

Remove use of the ugly PRI* print macros.

master
Richard Nyberg 19 år sedan
förälder
incheckning
1eea7650a2
3 ändrade filer med 14 tillägg och 34 borttagningar
  1. +2
    -6
      btpd/cli_if.c
  2. +7
    -16
      btpd/tracker_req.c
  3. +5
    -12
      misc/metainfo.c

+ 2
- 6
btpd/cli_if.c Visa fil

@@ -13,10 +13,6 @@

#include "btpd.h"

#ifndef PRIu64
#define PRIu64 "llu"
#endif

#define buf_swrite(iob, s) buf_write(iob, s, sizeof(s) - 1)

static struct event m_cli_incoming;
@@ -44,7 +40,7 @@ cmd_stat(int argc, const char *args, FILE *fp)
for (uint32_t i = 0; i < tp->meta.npieces; i++)
if (tp->piece_count[i] > 0)
seen_npieces++;
errdie(buf_print(&iob, "d4:downi%" PRIu64 "e", tp->downloaded));
errdie(buf_print(&iob, "d4:downi%jue", (intmax_t)tp->downloaded));
errdie(buf_swrite(&iob, "4:hash20:"));
errdie(buf_write(&iob, tp->meta.info_hash, 20));
errdie(buf_print(&iob, "12:have npiecesi%ue", tp->have_npieces));
@@ -53,7 +49,7 @@ cmd_stat(int argc, const char *args, FILE *fp)
errdie(buf_print(&iob, "4:path%d:%s",
(int)strlen(tp->relpath), tp->relpath));
errdie(buf_print(&iob, "12:seen npiecesi%ue", seen_npieces));
errdie(buf_print(&iob, "2:upi%" PRIu64 "ee", tp->uploaded));
errdie(buf_print(&iob, "2:upi%juee", (intmax_t)tp->uploaded));
}
errdie(buf_swrite(&iob, "ee"));



+ 7
- 16
btpd/tracker_req.c Visa fil

@@ -17,10 +17,6 @@
#include "btpd.h"
#include "tracker_req.h"

#ifndef PRIu64
#define PRIu64 "llu"
#endif

#define REQ_SIZE (getpagesize() * 2)

struct tracker_req {
@@ -175,18 +171,13 @@ create_url(struct tracker_req *req, struct torrent *tp, char **url)

left = cm_bytes_left(tp);

i = asprintf(url, "%s%cinfo_hash=%s"
"&peer_id=%s"
"&port=%d"
"&uploaded=%" PRIu64
"&downloaded=%" PRIu64
"&left=%" PRIu64
"&compact=1"
"%s%s",
tp->meta.announce, qc, e_hash, e_id, net_port,
tp->uploaded, tp->downloaded, left,
req->tr_event == TR_EMPTY ? "" : "&event=",
event);
i =
asprintf(url, "%s%cinfo_hash=%s&peer_id=%s&port=%d&uploaded=%ju"
"&downloaded=%ju&left=%ju&compact=1%s%s",
tp->meta.announce, qc, e_hash, e_id, net_port,
(intmax_t)tp->uploaded, (intmax_t)tp->downloaded, (intmax_t)left,
req->tr_event == TR_EMPTY ? "" : "&event=",
event);

if (i < 0)
return ENOMEM;


+ 5
- 12
misc/metainfo.c Visa fil

@@ -30,13 +30,6 @@
*
*/

#ifndef PRId64
#define PRId64 "lld"
#endif
#ifndef PRIu32
#define PRIu32 "u"
#endif

void
print_metainfo(struct metainfo *tp)
{
@@ -47,16 +40,16 @@ print_metainfo(struct metainfo *tp)
printf("%.2x", tp->info_hash[i]);
printf("\n");
printf("Tracker URL: %s\n", tp->announce);
printf("Piece length: %" PRId64 "\n", (int64_t)tp->piece_length);
printf("Number of pieces: %" PRIu32 "\n", tp->npieces);
printf("Piece length: %jd\n", (intmax_t)tp->piece_length);
printf("Number of pieces: %u\n", tp->npieces);
printf("Number of files: %u\n", tp->nfiles);
printf("Advisory name: %s\n", tp->name);
printf("Files:\n");
for (i = 0; i < tp->nfiles; i++) {
printf("%s (%" PRId64 ")\n",
tp->files[i].path, (int64_t)tp->files[i].length);
printf("%s (%jd)\n",
tp->files[i].path, (intmax_t)tp->files[i].length);
}
printf("Total length: %" PRId64 "\n\n", (int64_t)tp->total_length);
printf("Total length: %jd\n\n", (intmax_t)tp->total_length);
}

static int


Laddar…
Avbryt
Spara