Root/cgminer/patches/000-update-cgminer-api.patch

Source at commit 8b7a89168c777ee394adff8070b29581ebf46ba8 created 7 years 1 month ago.
By Xiangfu, cgmienr: add a webui, update to 2.10.5
1diff --git a/api-example.c b/api-example.c
2index 13b8f2d..dd40545 100755
3--- a/api-example.c
4+++ b/api-example.c
5@@ -145,6 +145,7 @@
6 static const char SEPARATOR = '|';
7 static const char COMMA = ',';
8 static const char EQ = '=';
9+static int ONLY = 0;
10 
11 void display(char *buf)
12 {
13@@ -242,9 +243,13 @@ int callapi(char *command, char *host, short int port)
14             buf[p] = '\0';
15         }
16 
17- printf("Reply was '%s'\n", buf);
18+ if (!ONLY)
19+ printf("Reply was '%s'\n", buf);
20+ else
21+ printf("%s\n", buf);
22 
23- display(buf);
24+ if (!ONLY)
25+ display(buf);
26     }
27 
28     CLOSESOCKET(sock);
29@@ -274,6 +279,7 @@ int main(int argc, char *argv[])
30     char *host = "127.0.0.1";
31     short int port = 4028;
32     char *ptr;
33+ int i = 1;
34 
35     if (argc > 1)
36         if (strcmp(argv[1], "-?") == 0
37@@ -283,20 +289,26 @@ int main(int argc, char *argv[])
38             return 1;
39         }
40 
41- if (argc > 1) {
42- ptr = trim(argv[1]);
43+ if (argc > 1)
44+ if (strcmp(argv[1], "-o") == 0) {
45+ ONLY = 1;
46+ i = 2;
47+ }
48+
49+ if (argc > i) {
50+ ptr = trim(argv[i++]);
51         if (strlen(ptr) > 0)
52             command = ptr;
53     }
54 
55- if (argc > 2) {
56- ptr = trim(argv[2]);
57+ if (argc > i) {
58+ ptr = trim(argv[i++]);
59         if (strlen(ptr) > 0)
60             host = ptr;
61     }
62 
63- if (argc > 3) {
64- ptr = trim(argv[3]);
65+ if (argc > i) {
66+ ptr = trim(argv[i]);
67         if (strlen(ptr) > 0)
68             port = atoi(ptr);
69     }
70

Archive Download this file



interactive