1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-22 12:41:53 +02:00
openwrt-packages/cgminer/patches/000-update-cgminer-api.patch

70 lines
1.3 KiB
Diff
Raw Permalink Normal View History

2013-03-02 11:24:35 +02:00
diff --git a/api-example.c b/api-example.c
index 13b8f2d..dd40545 100755
--- a/api-example.c
+++ b/api-example.c
@@ -145,6 +145,7 @@
static const char SEPARATOR = '|';
static const char COMMA = ',';
static const char EQ = '=';
+static int ONLY = 0;
void display(char *buf)
{
@@ -242,9 +243,13 @@ int callapi(char *command, char *host, short int port)
buf[p] = '\0';
}
- printf("Reply was '%s'\n", buf);
+ if (!ONLY)
+ printf("Reply was '%s'\n", buf);
+ else
+ printf("%s\n", buf);
- display(buf);
+ if (!ONLY)
+ display(buf);
}
CLOSESOCKET(sock);
@@ -274,6 +279,7 @@ int main(int argc, char *argv[])
char *host = "127.0.0.1";
short int port = 4028;
char *ptr;
+ int i = 1;
if (argc > 1)
if (strcmp(argv[1], "-?") == 0
@@ -283,20 +289,26 @@ int main(int argc, char *argv[])
return 1;
}
- if (argc > 1) {
- ptr = trim(argv[1]);
+ if (argc > 1)
+ if (strcmp(argv[1], "-o") == 0) {
+ ONLY = 1;
+ i = 2;
+ }
+
+ if (argc > i) {
+ ptr = trim(argv[i++]);
if (strlen(ptr) > 0)
command = ptr;
}
- if (argc > 2) {
- ptr = trim(argv[2]);
+ if (argc > i) {
+ ptr = trim(argv[i++]);
if (strlen(ptr) > 0)
host = ptr;
}
- if (argc > 3) {
- ptr = trim(argv[3]);
+ if (argc > i) {
+ ptr = trim(argv[i]);
if (strlen(ptr) > 0)
port = atoi(ptr);
}