]> granicus.if.org Git - transmission/blobdiff - utils/remote.c
Update to Uncrustify 0.68.1
[transmission] / utils / remote.c
index 23dce8eb928e25bcbd7789e52bbb03c74af962bc..a8ae16c158b72916b62d2ff9684db64061883dd5 100644 (file)
@@ -238,15 +238,15 @@ enum
 static char const* getUsage(void)
 {
     return MY_NAME " " LONG_VERSION_STRING "\n"
-           "A fast and easy BitTorrent client\n"
-           "https://transmissionbt.com/\n"
-           "\n"
-           "Usage: " MY_NAME " [host] [options]\n"
-           "       " MY_NAME " [port] [options]\n"
-           "       " MY_NAME " [host:port] [options]\n"
-           "       " MY_NAME " [http(s?)://host:port/transmission/] [options]\n"
-           "\n"
-           "See the man page for detailed explanations and many examples.";
+        "A fast and easy BitTorrent client\n"
+        "https://transmissionbt.com/\n"
+        "\n"
+        "Usage: " MY_NAME " [host] [options]\n"
+        "       " MY_NAME " [port] [options]\n"
+        "       " MY_NAME " [host:port] [options]\n"
+        "       " MY_NAME " [http(s?)://host:port/transmission/] [options]\n"
+        "\n"
+        "See the man page for detailed explanations and many examples.";
 }
 
 /***
@@ -271,7 +271,8 @@ static tr_option opts[] =
     { 'c', "incomplete-dir", "Where to store new torrents until they're complete", "c", 1, "<dir>" },
     { 'C', "no-incomplete-dir", "Don't store incomplete torrents in a different location", "C", 0, NULL },
     { 'b', "debug", "Print debugging information", "b", 0, NULL },
-    { 'd', "downlimit", "Set the max download speed in "SPEED_K_STR " for the current torrent(s) or globally", "d", 1, "<speed>" },
+    { 'd', "downlimit", "Set the max download speed in "SPEED_K_STR " for the current torrent(s) or globally", "d", 1,
+        "<speed>" },
     { 'D', "no-downlimit", "Disable max download speed for the current torrent(s) or globally", "D", 0, NULL },
     { 'e', "cache", "Set the maximum size of the session's memory cache (in " MEM_M_STR ")", "e", 1, "<size>" },
     { 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL },
@@ -317,8 +318,10 @@ static tr_option opts[] =
     { 950, "seedratio", "Let the current torrent(s) seed until a specific ratio", "sr", 1, "ratio" },
     { 951, "seedratio-default", "Let the current torrent(s) use the global seedratio settings", "srd", 0, NULL },
     { 952, "no-seedratio", "Let the current torrent(s) seed regardless of ratio", "SR", 0, NULL },
-    { 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
-    { 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
+    { 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio",
+        "gsr", 1, "ratio" },
+    { 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio",
+        "GSR", 0, NULL },
     { 710, "tracker-add", "Add a tracker to a torrent", "td", 1, "<tracker>" },
     { 712, "tracker-remove", "Remove a tracker from a torrent", "tr", 1, "<trackerId>" },
     { 's', "start", "Start the current torrent(s)", "s", 0, NULL },
@@ -336,7 +339,8 @@ static tr_option opts[] =
     { 831, "no-utp", "Disable uTP for peer connections", NULL, 0, NULL },
     { 'v', "verify", "Verify the current torrent(s)", "v", 0, NULL },
     { 'V', "version", "Show version number and exit", "V", 0, NULL },
-    { 'w', "download-dir", "When used in conjunction with --add, set the new torrent's download folder. Otherwise, set the default download folder", "w", 1, "<path>" },
+    { 'w', "download-dir", "When used in conjunction with --add, set the new torrent's download folder. "
+        "Otherwise, set the default download folder", "w", 1, "<path>" },
     { 'x', "pex", "Enable peer exchange (PEX)", "x", 0, NULL },
     { 'X', "no-pex", "Disable peer exchange (PEX)", "X", 0, NULL },
     { 'y', "lpd", "Enable local peer discovery (LPD)", "y", 0, NULL },
@@ -1033,7 +1037,8 @@ static void printDetails(tr_variant* top)
                 }
             }
 
-            if (tr_variantDictFindInt(t, TR_KEY_peersConnected, &i) && tr_variantDictFindInt(t, TR_KEY_peersGettingFromUs, &j) &&
+            if (tr_variantDictFindInt(t, TR_KEY_peersConnected, &i) &&
+                tr_variantDictFindInt(t, TR_KEY_peersGettingFromUs, &j) &&
                 tr_variantDictFindInt(t, TR_KEY_peersSendingToUs, &k))
             {
                 printf("  Peers: connected to %" PRId64 ", uploading to %" PRId64 ", downloading from %" PRId64 "\n", i, j, k);
@@ -1126,7 +1131,8 @@ static void printDetails(tr_variant* top)
 
             printf("LIMITS & BANDWIDTH\n");
 
-            if (tr_variantDictFindBool(t, TR_KEY_downloadLimited, &boolVal) && tr_variantDictFindInt(t, TR_KEY_downloadLimit, &i))
+            if (tr_variantDictFindBool(t, TR_KEY_downloadLimited, &boolVal) &&
+                tr_variantDictFindInt(t, TR_KEY_downloadLimit, &i))
             {
                 printf("  Download Limit: ");
 
@@ -1230,8 +1236,10 @@ static void printFileList(tr_variant* top)
                     char const* filename;
                     tr_variant* file = tr_variantListChild(files, j);
 
-                    if (tr_variantDictFindInt(file, TR_KEY_length, &length) && tr_variantDictFindStr(file, TR_KEY_name, &filename, NULL) &&
-                        tr_variantDictFindInt(file, TR_KEY_bytesCompleted, &have) && tr_variantGetInt(tr_variantListChild(priorities, j), &priority) &&
+                    if (tr_variantDictFindInt(file, TR_KEY_length, &length) &&
+                        tr_variantDictFindStr(file, TR_KEY_name, &filename, NULL) &&
+                        tr_variantDictFindInt(file, TR_KEY_bytesCompleted, &have) &&
+                        tr_variantGetInt(tr_variantListChild(priorities, j), &priority) &&
                         tr_variantGetInt(tr_variantListChild(wanteds, j), &wanted))
                     {
                         char sizestr[64];
@@ -1277,12 +1285,15 @@ static void printPeersImpl(tr_variant* peers)
         int64_t rateToPeer;
         tr_variant* d = tr_variantListChild(peers, i);
 
-        if (tr_variantDictFindStr(d, TR_KEY_address, &address, NULL) && tr_variantDictFindStr(d, TR_KEY_clientName, &client, NULL) &&
-            tr_variantDictFindReal(d, TR_KEY_progress, &progress) && tr_variantDictFindStr(d, TR_KEY_flagStr, &flagstr, NULL) &&
-            tr_variantDictFindInt(d, TR_KEY_rateToClient, &rateToClient) && tr_variantDictFindInt(d, TR_KEY_rateToPeer, &rateToPeer))
+        if (tr_variantDictFindStr(d, TR_KEY_address, &address, NULL) &&
+            tr_variantDictFindStr(d, TR_KEY_clientName, &client, NULL) &&
+            tr_variantDictFindReal(d, TR_KEY_progress, &progress) &&
+            tr_variantDictFindStr(d, TR_KEY_flagStr, &flagstr, NULL) &&
+            tr_variantDictFindInt(d, TR_KEY_rateToClient, &rateToClient) &&
+            tr_variantDictFindInt(d, TR_KEY_rateToPeer, &rateToPeer))
         {
-            printf("%-40s  %-12s  %-5.1f %6.1f  %6.1f  %s\n", address, flagstr, (progress * 100.0), rateToClient / (double)tr_speed_K,
-                rateToPeer / (double)tr_speed_K, client);
+            printf("%-40s  %-12s  %-5.1f %6.1f  %6.1f  %s\n", address, flagstr, (progress * 100.0),
+                rateToClient / (double)tr_speed_K, rateToPeer / (double)tr_speed_K, client);
         }
     }
 }
@@ -1351,7 +1362,8 @@ static void printPieces(tr_variant* top)
             size_t rawlen;
             tr_variant* torrent = tr_variantListChild(torrents, i);
 
-            if (tr_variantDictFindRaw(torrent, TR_KEY_pieces, &raw, &rawlen) && tr_variantDictFindInt(torrent, TR_KEY_pieceCount, &j))
+            if (tr_variantDictFindRaw(torrent, TR_KEY_pieces, &raw, &rawlen) &&
+                tr_variantDictFindInt(torrent, TR_KEY_pieceCount, &j))
             {
                 assert(j >= 0);
                 printPiecesImpl(raw, rawlen, (size_t)j);
@@ -1392,8 +1404,8 @@ static void printTorrentList(tr_variant* top)
         double total_down = 0;
         char haveStr[32];
 
-        printf("%-4s   %-4s  %9s  %-8s  %6s  %6s  %-5s  %-11s  %s\n", "ID", "Done", "Have", "ETA", "Up", "Down", "Ratio", "Status",
-            "Name");
+        printf("%-4s   %-4s  %9s  %-8s  %6s  %6s  %-5s  %-11s  %s\n", "ID", "Done", "Have", "ETA", "Up", "Down", "Ratio",
+            "Status", "Name");
 
         for (int i = 0, n = tr_variantListSize(list); i < n; ++i)
         {
@@ -1408,10 +1420,14 @@ static void printTorrentList(tr_variant* top)
             char const* name;
             tr_variant* d = tr_variantListChild(list, i);
 
-            if (tr_variantDictFindInt(d, TR_KEY_eta, &eta) && tr_variantDictFindInt(d, TR_KEY_id, &id) &&
-                tr_variantDictFindInt(d, TR_KEY_leftUntilDone, &leftUntilDone) && tr_variantDictFindStr(d, TR_KEY_name, &name, NULL) &&
-                tr_variantDictFindInt(d, TR_KEY_rateDownload, &down) && tr_variantDictFindInt(d, TR_KEY_rateUpload, &up) &&
-                tr_variantDictFindInt(d, TR_KEY_sizeWhenDone, &sizeWhenDone) && tr_variantDictFindInt(d, TR_KEY_status, &status) &&
+            if (tr_variantDictFindInt(d, TR_KEY_eta, &eta) &&
+                tr_variantDictFindInt(d, TR_KEY_id, &id) &&
+                tr_variantDictFindInt(d, TR_KEY_leftUntilDone, &leftUntilDone) &&
+                tr_variantDictFindStr(d, TR_KEY_name, &name, NULL) &&
+                tr_variantDictFindInt(d, TR_KEY_rateDownload, &down) &&
+                tr_variantDictFindInt(d, TR_KEY_rateUpload, &up) &&
+                tr_variantDictFindInt(d, TR_KEY_sizeWhenDone, &sizeWhenDone) &&
+                tr_variantDictFindInt(d, TR_KEY_status, &status) &&
                 tr_variantDictFindReal(d, TR_KEY_uploadRatio, &ratio))
             {
                 char etaStr[16];
@@ -1790,9 +1806,9 @@ static void printSession(tr_variant* top)
                     tr_strlcpy(buf, "Unlimited", sizeof(buf));
                 }
 
-                printf("  Upload speed limit: %s (%s limit: %s; %s turtle limit: %s)\n", buf, upEnabled ? "Enabled" : "Disabled",
-                    tr_formatter_speed_KBps(buf2, upLimit, sizeof(buf2)), altEnabled ? "Enabled" : "Disabled",
-                    tr_formatter_speed_KBps(buf3, altUp, sizeof(buf3)));
+                printf("  Upload speed limit: %s (%s limit: %s; %s turtle limit: %s)\n", buf,
+                    upEnabled ? "Enabled" : "Disabled", tr_formatter_speed_KBps(buf2, upLimit, sizeof(buf2)),
+                    altEnabled ? "Enabled" : "Disabled", tr_formatter_speed_KBps(buf3, altUp, sizeof(buf3)));
 
                 if (altEnabled)
                 {
@@ -1807,14 +1823,14 @@ static void printSession(tr_variant* top)
                     tr_strlcpy(buf, "Unlimited", sizeof(buf));
                 }
 
-                printf("  Download speed limit: %s (%s limit: %s; %s turtle limit: %s)\n", buf, downEnabled ? "Enabled" : "Disabled",
-                    tr_formatter_speed_KBps(buf2, downLimit, sizeof(buf2)), altEnabled ? "Enabled" : "Disabled",
-                    tr_formatter_speed_KBps(buf3, altDown, sizeof(buf3)));
+                printf("  Download speed limit: %s (%s limit: %s; %s turtle limit: %s)\n", buf,
+                    downEnabled ? "Enabled" : "Disabled", tr_formatter_speed_KBps(buf2, downLimit, sizeof(buf2)),
+                    altEnabled ? "Enabled" : "Disabled", tr_formatter_speed_KBps(buf3, altDown, sizeof(buf3)));
 
                 if (altTimeEnabled)
                 {
-                    printf("  Turtle schedule: %02d:%02d - %02d:%02d  ", (int)(altBegin / 60), (int)(altBegin % 60), (int)(altEnd / 60),
-                        (int)(altEnd % 60));
+                    printf("  Turtle schedule: %02d:%02d - %02d:%02d  ", (int)(altBegin / 60), (int)(altBegin % 60),
+                        (int)(altEnd / 60), (int)(altEnd % 60));
 
                     if ((altDay & TR_SCHED_SUN) != 0)
                     {
@@ -1895,8 +1911,10 @@ static void printSessionStats(tr_variant* top)
             printf("  Duration:   %s\n", tr_strltime(buf, secs, sizeof(buf)));
         }
 
-        if (tr_variantDictFindDict(args, TR_KEY_cumulative_stats, &d) && tr_variantDictFindInt(d, TR_KEY_sessionCount, &sessions) &&
-            tr_variantDictFindInt(d, TR_KEY_uploadedBytes, &up) && tr_variantDictFindInt(d, TR_KEY_downloadedBytes, &down) &&
+        if (tr_variantDictFindDict(args, TR_KEY_cumulative_stats, &d) &&
+            tr_variantDictFindInt(d, TR_KEY_sessionCount, &sessions) &&
+            tr_variantDictFindInt(d, TR_KEY_uploadedBytes, &up) &&
+            tr_variantDictFindInt(d, TR_KEY_downloadedBytes, &down) &&
             tr_variantDictFindInt(d, TR_KEY_secondsActive, &secs))
         {
             printf("\nTOTAL\n");
@@ -1918,7 +1936,8 @@ static int processResponse(char const* rpcurl, void const* response, size_t len)
 
     if (debug)
     {
-        fprintf(stderr, "got response (len %d):\n--------\n%*.*s\n--------\n", (int)len, (int)len, (int)len, (char const*)response);
+        fprintf(stderr, "got response (len %d):\n--------\n%*.*s\n--------\n", (int)len, (int)len, (int)len,
+            (char const*)response);
     }
 
     if (tr_variantFromJson(&top, response, len) != 0)
@@ -1985,7 +2004,8 @@ static int processResponse(char const* rpcurl, void const* response, size_t len)
                         int64_t i;
                         tr_variant* b = &top;
 
-                        if (tr_variantDictFindDict(&top, ARGUMENTS, &b) && tr_variantDictFindDict(b, TR_KEY_torrent_added, &b) &&
+                        if (tr_variantDictFindDict(&top, ARGUMENTS, &b) &&
+                            tr_variantDictFindDict(b, TR_KEY_torrent_added, &b) &&
                             tr_variantDictFindInt(b, TR_KEY_id, &i))
                         {
                             tr_snprintf(id, sizeof(id), "%" PRId64, i);