response->downloads = i;
if (tr_variantDictFindRaw (&benc, TR_KEY_peers6, &raw, &len)) {
- dbgmsg (data->log_name, "got a peers6 length of %zu", len);
+ dbgmsg (data->log_name, "got a peers6 length of %"TR_PRIuSIZE, len);
response->pex6 = tr_peerMgrCompact6ToPex (raw, len,
NULL, 0, &response->pex6_count);
}
if (tr_variantDictFindRaw (&benc, TR_KEY_peers, &raw, &len)) {
- dbgmsg (data->log_name, "got a compact peers length of %zu", len);
+ dbgmsg (data->log_name, "got a compact peers length of %"TR_PRIuSIZE, len);
response->pex = tr_peerMgrCompactToPex (raw, len,
NULL, 0, &response->pex_count);
} else if (tr_variantDictFindList (&benc, TR_KEY_peers, &tmp)) {
response->pex = listToPex (tmp, &response->pex_count);
- dbgmsg (data->log_name, "got a peers list with %zu entries",
+ dbgmsg (data->log_name, "got a peers list with %"TR_PRIuSIZE" entries",
response->pex_count);
}
}
return;
}
- dbgmsg (tracker->key, "addr %p -- connected %d (%zu %zu) -- connecting_at %zu",
+ dbgmsg (tracker->key, "addr %p -- connected %d (%"TR_PRIuSIZE" %"TR_PRIuSIZE") -- connecting_at %"TR_PRIuSIZE,
tracker->addr,
(int)(tracker->connection_expiration_time > now), (size_t)tracker->connection_expiration_time, (size_t)now,
(size_t)tracker->connecting_at);
tau_transaction_t transaction_id;
struct evbuffer * buf;
- /*fprintf (stderr, "got an incoming udp message w/len %zu\n", msglen);*/
+ /*fprintf (stderr, "got an incoming udp message w/len %"TR_PRIuSIZE"\n", msglen);*/
if (!session || !session->announcer_udp)
return false;
"interval:%d "
"min_interval:%d "
"tracker_id_str:%s "
- "pex:%zu "
- "pex6:%zu "
+ "pex:%"TR_PRIuSIZE" "
+ "pex6:%"TR_PRIuSIZE" "
"err:%s "
"warn:%s",
(int)response->did_connect,
/* schedule a rescrape */
interval = getRetryInterval (tier->currentTracker);
- dbgmsg (tier, "Retrying scrape in %zu seconds.", (size_t)interval);
- tr_logAddTorInfo (tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval);
+ dbgmsg (tier, "Retrying scrape in %"TR_PRIuSIZE" seconds.", (size_t)interval);
+ tr_logAddTorInfo (tier->tor, "Retrying scrape in %"TR_PRIuSIZE" seconds.", (size_t)interval);
tier->lastScrapeSucceeded = false;
tier->scrapeAt = get_next_scrape_time (session, tier, interval);
}
#ifdef DEBUG_DIRECTION
if ((dir == DEBUG_DIRECTION) && (band->isLimited))
-fprintf (stderr, "%p consumed %5zu bytes of %5s data... was %6zu, now %6zu left\n",
+fprintf (stderr, "%p consumed %5"TR_PRIuSIZE" bytes of %5s data... was %6"TR_PRIuSIZE", now %6"TR_PRIuSIZE" left\n",
b, byteCount, (isPieceData?"piece":"raw"), oldBytesLeft, band->bytesLeft);
#endif
break;
if (b->tor != ref->tor)
break;
- //fprintf (stderr, "pos %d tor %d block %zu time %zu\n", i, b->tor->uniqueId, (size_t)b->block, (size_t)b->time);
+ //fprintf (stderr, "pos %d tor %d block %"TR_PRIuSIZE" time %"TR_PRIuSIZE"\n", i, b->tor->uniqueId, (size_t)b->block, (size_t)b->time);
}
//fprintf (stderr, "run is %d long from [%d to %d)\n", (int)(i-pos), i, (int)pos);
tr_torGetFileBlockRange (torrent, i, &first, &last);
pos = findBlockPos (cache, torrent, first);
- dbgmsg ("flushing file %d from cache to disk: blocks [%zu...%zu]", (int)i, (size_t)first, (size_t)last);
+ dbgmsg ("flushing file %d from cache to disk: blocks [%"TR_PRIuSIZE"...%"TR_PRIuSIZE"]", (int)i, (size_t)first, (size_t)last);
/* flush out all the blocks in that file */
while (!err && (pos < tr_ptrArraySize (&cache->blocks)))
tr_torrent * tor;
uint8_t peer_id[PEER_ID_LEN];
- dbgmsg (handshake, "payload: need %d, got %zu",
+ dbgmsg (handshake, "payload: need %d, got %"TR_PRIuSIZE,
HANDSHAKE_SIZE, evbuffer_get_length (inbuf));
if (evbuffer_get_length (inbuf) < HANDSHAKE_SIZE)
{
const size_t needlen = handshake->pad_d_len;
- dbgmsg (handshake, "pad d: need %zu, got %zu",
+ dbgmsg (handshake, "pad d: need %"TR_PRIuSIZE", got %"TR_PRIuSIZE,
needlen, evbuffer_get_length (inbuf));
if (evbuffer_get_length (inbuf) < needlen)
return READ_LATER;
uint8_t reserved[HANDSHAKE_FLAGS_LEN];
uint8_t hash[SHA_DIGEST_LENGTH];
- dbgmsg (handshake, "payload: need %d, got %zu",
+ dbgmsg (handshake, "payload: need %d, got %"TR_PRIuSIZE,
INCOMING_HANDSHAKE_LEN, evbuffer_get_length (inbuf));
if (evbuffer_get_length (inbuf) < INCOMING_HANDSHAKE_LEN)
const uint8_t * secret;
int len;
- dbgmsg (handshake, "in readYa... need %d, have %zu",
+ dbgmsg (handshake, "in readYa... need %d, have %"TR_PRIuSIZE,
KEY_LEN, evbuffer_get_length (inbuf));
if (evbuffer_get_length (inbuf) < KEY_LEN)
return READ_LATER;
struct evbuffer * outbuf;
uint32_t crypto_select;
- dbgmsg (handshake, "reading IA... have %zu, need %zu",
+ dbgmsg (handshake, "reading IA... have %"TR_PRIuSIZE", need %"TR_PRIuSIZE,
evbuffer_get_length (inbuf), needlen);
if (evbuffer_get_length (inbuf) < needlen)
return READ_LATER;
int i;
const size_t needlen = HANDSHAKE_SIZE;
- dbgmsg (handshake, "reading payload stream... have %zu, need %zu",
+ dbgmsg (handshake, "reading payload stream... have %"TR_PRIuSIZE", need %"TR_PRIuSIZE,
evbuffer_get_length (inbuf), needlen);
if (evbuffer_get_length (inbuf) < needlen)
return READ_LATER;
assert (tr_isPeerIo (io));
rc = evbuffer_add (io->inbuf, buf, buflen);
- dbgmsg (io, "utp_on_read got %zu bytes", buflen);
+ dbgmsg (io, "utp_on_read got %"TR_PRIuSIZE" bytes", buflen);
if (rc < 0) {
tr_logAddNamedError ("UTP", "On read evbuffer_add");
assert (tr_isPeerIo (io));
rc = evbuffer_remove (io->outbuf, buf, buflen);
- dbgmsg (io, "utp_on_write sending %zu bytes... evbuffer_remove returned %d", buflen, rc);
+ dbgmsg (io, "utp_on_write sending %"TR_PRIuSIZE" bytes... evbuffer_remove returned %d", buflen, rc);
assert (rc == (int)buflen); /* if this fails, we've corrupted our bookkeeping somewhere */
if (rc < (long)buflen) {
tr_logAddNamedError ("UTP", "Short write: %d < %ld", rc, (long)buflen);
bytes = tr_bandwidthClamp (&io->bandwidth, TR_DOWN, UTP_READ_BUFFER_SIZE);
- dbgmsg (io, "utp_get_rb_size is saying it's ready to read %zu bytes", bytes);
+ dbgmsg (io, "utp_get_rb_size is saying it's ready to read %"TR_PRIuSIZE" bytes", bytes);
return UTP_READ_BUFFER_SIZE - bytes;
}
tr_peerIo *io = closure;
assert (tr_isPeerIo (io));
- dbgmsg (io, "utp_on_overhead -- count is %zu", count);
+ dbgmsg (io, "utp_on_overhead -- count is %"TR_PRIuSIZE, count);
tr_bandwidthUsed (&io->bandwidth, send ? TR_UP : TR_DOWN,
count, false, tr_time_msec ());
{
int n = 0;
const size_t old_len = evbuffer_get_length (io->outbuf);
- dbgmsg (io, "in tr_peerIoTryWrite %zu", howmuch);
+ dbgmsg (io, "in tr_peerIoTryWrite %"TR_PRIuSIZE, howmuch);
if (howmuch > old_len)
howmuch = old_len;
else
bytesUsed = tr_peerIoTryWrite (io, limit);
- dbgmsg (io, "flushing peer-io, direction %d, limit %zu, bytesUsed %d", (int)dir, limit, bytesUsed);
+ dbgmsg (io, "flushing peer-io, direction %d, limit %"TR_PRIuSIZE", bytesUsed %d", (int)dir, limit, bytesUsed);
return bytesUsed;
}
static void
dbgOutMessageLen (tr_peerMsgs * msgs)
{
- dbgmsg (msgs, "outMessage size is now %zu", evbuffer_get_length (msgs->outMessages));
+ dbgmsg (msgs, "outMessage size is now %"TR_PRIuSIZE, evbuffer_get_length (msgs->outMessages));
}
static void
tr_peerMsgsCancel (tr_peerMsgs * msgs, tr_block_index_t block)
{
struct peer_request req;
-/*fprintf (stderr, "SENDING CANCEL MESSAGE FOR BLOCK %zu\n\t\tFROM PEER %p ------------------------------------\n", (size_t)block, msgs->peer);*/
+/*fprintf (stderr, "SENDING CANCEL MESSAGE FOR BLOCK %"TR_PRIuSIZE"\n\t\tFROM PEER %p ------------------------------------\n", (size_t)block, msgs->peer);*/
blockToReq (msgs->torrent, block, &req);
protocolSendCancel (msgs, &req);
}
tr_peerIoReadUint8 (msgs->io, inbuf, &id);
msgs->incoming.id = id;
- dbgmsg (msgs, "msgs->incoming.id is now %d; msgs->incoming.length is %zu", id, (size_t)msgs->incoming.length);
+ dbgmsg (msgs, "msgs->incoming.id is now %d; msgs->incoming.length is %"TR_PRIuSIZE, id, (size_t)msgs->incoming.length);
if (id == BT_PIECE)
{
fireClientGotPieceData (msgs, n);
*setme_piece_bytes_read += n;
- dbgmsg (msgs, "got %zu bytes for block %u:%u->%u ... %d remain",
+ dbgmsg (msgs, "got %"TR_PRIuSIZE" bytes for block %u:%u->%u ... %d remain",
n, req->index, req->offset, req->length,
(int)(req->length - evbuffer_get_length (block_buffer)));
if (evbuffer_get_length (block_buffer) < req->length)
--msglen; /* id length */
- dbgmsg (msgs, "got BT id %d, len %d, buffer size is %zu", (int)id, (int)msglen, inlen);
+ dbgmsg (msgs, "got BT id %d, len %d, buffer size is %"TR_PRIuSIZE, (int)id, (int)msglen, inlen);
if (inlen < msglen)
return READ_LATER;
struct evbuffer * in = tr_peerIoGetReadBuffer (io);
const size_t inlen = evbuffer_get_length (in);
- dbgmsg (msgs, "canRead: inlen is %zu, msgs->state is %d", inlen, msgs->state);
+ dbgmsg (msgs, "canRead: inlen is %"TR_PRIuSIZE", msgs->state is %d", inlen, msgs->state);
if (!inlen)
{
if (haveMessages && !msgs->outMessagesBatchedAt) /* fresh batch */
{
- dbgmsg (msgs, "started an outMessages batch (length is %zu)", evbuffer_get_length (msgs->outMessages));
+ dbgmsg (msgs, "started an outMessages batch (length is %"TR_PRIuSIZE")", evbuffer_get_length (msgs->outMessages));
msgs->outMessagesBatchedAt = now;
}
else if (haveMessages && ((now - msgs->outMessagesBatchedAt) >= msgs->outMessagesBatchPeriod))
{
const size_t len = evbuffer_get_length (msgs->outMessages);
/* flush the protocol messages */
- dbgmsg (msgs, "flushing outMessages... to %p (length is %zu)", msgs->io, len);
+ dbgmsg (msgs, "flushing outMessages... to %p (length is %"TR_PRIuSIZE")", msgs->io, len);
tr_peerIoWriteBuf (msgs->io, msgs->outMessages, false);
msgs->clientSentAnythingAt = now;
msgs->outMessagesBatchedAt = 0;
/* check the piece if it needs checking... */
if (!err && tr_torrentPieceNeedsCheck (msgs->torrent, req.index))
if ((err = !tr_torrentCheckPiece (msgs->torrent, req.index)))
- tr_torrentSetLocalError (msgs->torrent, _("Please Verify Local Data! Piece #%zu is corrupt."), (size_t)req.index);
+ tr_torrentSetLocalError (msgs->torrent, _("Please Verify Local Data! Piece #%"TR_PRIuSIZE" is corrupt."), (size_t)req.index);
if (err)
{
evbuffer_add_uint32 (out, sizeof (uint8_t) + byte_count);
evbuffer_add_uint8 (out, BT_BITFIELD);
evbuffer_add (out, bytes, byte_count);
- dbgmsg (msgs, "sending bitfield... outMessage size is now %zu", evbuffer_get_length (out));
+ dbgmsg (msgs, "sending bitfield... outMessage size is now %"TR_PRIuSIZE, evbuffer_get_length (out));
pokeBatchPeriod (msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS);
tr_free (bytes);
evbuffer_add_uint8 (out, msgs->ut_pex_id);
evbuffer_add_buffer (out, payload);
pokeBatchPeriod (msgs, HIGH_PRIORITY_INTERVAL_SECS);
- dbgmsg (msgs, "sending a pex message; outMessage size is now %zu", evbuffer_get_length (out));
+ dbgmsg (msgs, "sending a pex message; outMessage size is now %"TR_PRIuSIZE, evbuffer_get_length (out));
dbgOutMessageLen (msgs);
evbuffer_free (payload);
}
else
{
- tr_logAddTorDbg (tor, "Couldn't load DND flags. DND list (%p) has %zu children; torrent has %d files",
+ tr_logAddTorDbg (tor, "Couldn't load DND flags. DND list (%p) has %"TR_PRIuSIZE" children; torrent has %d files",
list, tr_variantListSize (list), (int)n);
}
iovec[0].iov_len -= server->stream.avail_out;
#if 0
- fprintf (stderr, "compressed response is %.2f of original (raw==%zu bytes; compressed==%zu)\n",
+ fprintf (stderr, "compressed response is %.2f of original (raw==%"TR_PRIuSIZE" bytes; compressed==%"TR_PRIuSIZE")\n",
(double)evbuffer_get_length (out)/content_len,
content_len, evbuffer_get_length (out));
#endif
{
struct add_torrent_idle_data * data = user_data;
- dbgmsg ("torrentAdd: HTTP response code was %ld (%s); response length was %zu bytes",
+ dbgmsg ("torrentAdd: HTTP response code was %ld (%s); response length was %"TR_PRIuSIZE" bytes",
response_code, tr_webGetResponseStr (response_code), response_byte_count);
if (response_code==200 || response_code==221) /* http or ftp success.. */
if (usec < min)
usec = min;
tr_timerAdd (session->nowTimer, 0, usec);
- /* fprintf (stderr, "time %zu sec, %zu microsec\n", (size_t)tr_time (), (size_t)tv.tv_usec); */
+ /* fprintf (stderr, "time %"TR_PRIuSIZE" sec, %"TR_PRIuSIZE" microsec\n", (size_t)tr_time (), (size_t)tv.tv_usec); */
}
static void loadBlocklists (tr_session * session);
assert (tr_isSession (session));
- dbgmsg ("shutting down transmission session %p... now is %zu, deadline is %zu", session, (size_t)time (NULL), (size_t)deadline);
+ dbgmsg ("shutting down transmission session %p... now is %"TR_PRIuSIZE", deadline is %"TR_PRIuSIZE, session, (size_t)time (NULL), (size_t)deadline);
/* close the session */
tr_runInEventThread (session, sessionCloseImpl, session);
while ((session->shared || session->web || session->announcer || session->announcer_udp)
&& !deadlineReached (deadline))
{
- dbgmsg ("waiting on port unmap (%p) or announcer (%p)... now %zu deadline %zu",
+ dbgmsg ("waiting on port unmap (%p) or announcer (%p)... now %"TR_PRIuSIZE" deadline %"TR_PRIuSIZE,
session->shared, session->announcer, (size_t)time (NULL), (size_t)deadline);
tr_wait_msec (50);
}
while (session->events != NULL)
{
static bool forced = false;
- dbgmsg ("waiting for libtransmission thread to finish... now %zu deadline %zu", (size_t)time (NULL), (size_t)deadline);
+ dbgmsg ("waiting for libtransmission thread to finish... now %"TR_PRIuSIZE" deadline %"TR_PRIuSIZE, (size_t)time (NULL), (size_t)deadline);
tr_wait_msec (100);
if (deadlineReached (deadline) && !forced)
const bool allAreSeeds = seedProbability == 100;
if (allAreSeeds)
- tr_logAddTorDbg (tor, "Got %zu seeds from tracker", event->pexCount);
+ tr_logAddTorDbg (tor, "Got %"TR_PRIuSIZE" seeds from tracker", event->pexCount);
else
- tr_logAddTorDbg (tor, "Got %zu peers from tracker", event->pexCount);
+ tr_logAddTorDbg (tor, "Got %"TR_PRIuSIZE" peers from tracker", event->pexCount);
for (i = 0; i < event->pexCount; ++i)
tr_peerMgrAddPex (tor, TR_PEER_FROM_TRACKER, &event->pex[i], seedProbability);
{
const bool pass = tr_ioTestPiece (tor, pieceIndex);
- tr_deeplog_tor (tor, "[LAZY] tr_torrentCheckPiece tested piece %zu, pass==%d", (size_t)pieceIndex, (int)pass);
+ tr_deeplog_tor (tor, "[LAZY] tr_torrentCheckPiece tested piece %"TR_PRIuSIZE", pass==%d", (size_t)pieceIndex, (int)pass);
tr_torrentSetHasPiece (tor, pieceIndex, pass);
tr_torrentSetPieceChecked (tor, pieceIndex);
tor->anyDate = tr_time ();
p = tr_torBlockPiece (tor, block);
if (tr_torrentPieceIsComplete (tor, p))
{
- tr_logAddTorDbg (tor, "[LAZY] checking just-completed piece %zu", (size_t)p);
+ tr_logAddTorDbg (tor, "[LAZY] checking just-completed piece %"TR_PRIuSIZE, (size_t)p);
if (tr_torrentCheckPiece (tor, p))
{
bool
UTP_Write (struct UTPSocket *socket, size_t count)
{
- tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count);
- dbgmsg ("UTP_RBDrained (%p, %zu) was called.", socket, count);
+ tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p, %"TR_PRIuSIZE") was called.", socket, count);
+ dbgmsg ("UTP_RBDrained (%p, %"TR_PRIuSIZE") was called.", socket, count);
assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */
return false;
}
#endif
#endif
+#ifndef TR_PRIuSIZE
+ #ifdef _MSC_VER
+ #define TR_PRIuSIZE "Iu"
+ #else
+ #define TR_PRIuSIZE "zu"
+ #endif
+#endif
+
#if defined (WIN32) && defined (_MSC_VER)
#define inline __inline
#endif
size_t len;
const char * str;
tr_variantGetStr (v, &str, &len);
- evbuffer_add_printf (evbuf, "%zu:", len);
+ evbuffer_add_printf (evbuf, "%"TR_PRIuSIZE":", len);
evbuffer_add (evbuf, str, len);
}
if (data->source)
{
- tr_logAddError ("JSON parse failed in %s at pos %zu: %s -- remaining text \"%.16s\"",
+ tr_logAddError ("JSON parse failed in %s at pos %"TR_PRIuSIZE": %s -- remaining text \"%.16s\"",
data->source,
jsn->pos,
jsonsl_strerror (error),
}
else
{
- tr_logAddError ("JSON parse failed at pos %zu: %s -- remaining text \"%.16s\"",
+ tr_logAddError ("JSON parse failed at pos %"TR_PRIuSIZE": %s -- remaining text \"%.16s\"",
jsn->pos,
jsonsl_strerror (error),
buf);
}
evbuffer_add (task->response, ptr, byteCount);
- dbgmsg ("wrote %zu bytes to task %p's buffer", byteCount, task);
+ dbgmsg ("wrote %"TR_PRIuSIZE" bytes to task %p's buffer", byteCount, task);
return byteCount;
}
{
tr_variant * tier = tr_variantListAddList (announce_list, 1);
tr_variantListAddStr (tier, url);
- printf ("\tAdded \"%s\" to \"announce-list\" tier %zu\n", url, tr_variantListSize (announce_list));
+ printf ("\tAdded \"%s\" to \"announce-list\" tier %"TR_PRIuSIZE"\n", url, tr_variantListSize (announce_list));
changed = true;
}
}