io->port = port;
io->socket = socket;
io->utp_socket = utp_socket;
- io->isIncoming = isIncoming != 0;
+ io->isIncoming = isIncoming;
io->timeCreated = tr_time ();
io->inbuf = evbuffer_new ();
io->outbuf = evbuffer_new ();
{
struct tr_datatype * d;
d = datatype_new ();
- d->isPieceData = isPieceData != 0;
+ d->isPieceData = isPieceData;
d->length = byteCount;
peer_io_push_datatype (io, d);
}
tr_sessionSetPexEnabled (tr_session * session, bool enabled)
{
assert (tr_isSession (session));
+ assert (tr_isBool (enabled));
- session->isPexEnabled = enabled != 0;
+ session->isPexEnabled = enabled;
}
bool
assert (tr_isSession (session));
assert (tr_isBool (enabled));
- if ((enabled != 0) != (session->isDHTEnabled != 0))
+ if (enabled != session->isDHTEnabled)
tr_runInEventThread (session, toggleDHTImpl, session);
}
assert (tr_isSession (session));
assert (tr_isBool (enabled));
- if ((enabled != 0) != (session->isUTPEnabled != 0))
+ if (enabled != session->isUTPEnabled)
tr_runInEventThread (session, toggle_utp, session);
}
assert (tr_isSession (session));
assert (tr_isBool (enabled));
- if ((enabled != 0) != (session->isLPDEnabled != 0))
+ if (enabled != session->isLPDEnabled)
tr_runInEventThread (session, toggleLPDImpl, session);
}
tr_list * l;
assert (tr_isSession (session));
+ assert (tr_isBool (isEnabled));
- session->isBlocklistEnabled = isEnabled != 0;
+ session->isBlocklistEnabled = isEnabled;
for (l=session->blocklists; l!=NULL; l=l->next)
tr_blocklistFileSetEnabled (l->data, isEnabled);
void
tr_ctorSetDeleteSource (tr_ctor * ctor, bool deleteSource)
{
- ctor->doDelete = deleteSource != 0;
- ctor->isSet_delete = 1;
+ assert (tr_isBool (deleteSource));
+
+ ctor->doDelete = deleteSource;
+ ctor->isSet_delete = true;
}
int
void
tr_ctorSetSave (tr_ctor * ctor, bool saveInOurTorrentsDir)
{
- ctor->saveInOurTorrentsDir = saveInOurTorrentsDir != 0;
+ assert (tr_isBool (saveInOurTorrentsDir));
+
+ ctor->saveInOurTorrentsDir = saveInOurTorrentsDir;
}
int
tr_ctorMode mode,
bool isPaused)
{
- struct optional_args * args = &ctor->optionalArgs[mode];
+ struct optional_args * args;
- args->isSet_paused = 1;
- args->isPaused = isPaused ? 1 : 0;
+ assert (ctor != NULL);
+ assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
+ assert (tr_isBool (isPaused));
+
+ args = &ctor->optionalArgs[mode];
+ args->isSet_paused = true;
+ args->isPaused = isPaused;
}
void
tr_ctorMode mode,
uint16_t peerLimit)
{
- struct optional_args * args = &ctor->optionalArgs[mode];
+ struct optional_args * args;
+
+ assert (ctor != NULL);
+ assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
- args->isSet_connected = 1;
+ args = &ctor->optionalArgs[mode];
+ args->isSet_connected = true;
args->peerLimit = peerLimit;
}
tr_ctorMode mode,
const char * directory)
{
- struct optional_args * args = &ctor->optionalArgs[mode];
+ struct optional_args * args;
+ assert (ctor != NULL);
+ assert ((mode == TR_FALLBACK) || (mode == TR_FORCE));
+
+ args = &ctor->optionalArgs[mode];
tr_free (args->downloadDir);
args->downloadDir = NULL;
- args->isSet_downloadDir = 0;
+ args->isSet_downloadDir = false;
if (directory && *directory)
{
- args->isSet_downloadDir = 1;
+ args->isSet_downloadDir = true;
args->downloadDir = tr_strdup (directory);
}
}
int
tr_ctorGetPaused (const tr_ctor * ctor, tr_ctorMode mode, bool * setmeIsPaused)
{
- int err = 0;
+ int err = 0;
const struct optional_args * args = &ctor->optionalArgs[mode];
if (!args->isSet_paused)
err = 1;
else if (setmeIsPaused)
- *setmeIsPaused = args->isPaused ? 1 : 0;
+ *setmeIsPaused = args->isPaused;
return err;
}
tr_ctorMode mode,
const char ** setmeDownloadDir)
{
- int err = 0;
+ int err = 0;
const struct optional_args * args = &ctor->optionalArgs[mode];
if (!args->isSet_downloadDir)