mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-14 08:48:01 +00:00
Merge pull request #149 from kanoi/master
README/api.c add "When" the request was processed to STATUS
This commit is contained in:
commit
717a63f7f3
9
README
9
README
@ -594,9 +594,11 @@ An example request in both formats to set GPU 0 fan to 80%:
|
||||
The format of each reply (unless stated otherwise) is a STATUS section
|
||||
followed by an optional detail section
|
||||
|
||||
For API version 1.4:
|
||||
|
||||
The STATUS section is:
|
||||
|
||||
STATUS=X,Code=N,Msg=string,Description=string|
|
||||
STATUS=X,When=NNN,Code=N,Msg=string,Description=string|
|
||||
|
||||
STATUS=X Where X is one of:
|
||||
W - Warning
|
||||
@ -605,6 +607,9 @@ The STATUS section is:
|
||||
E - Error
|
||||
F - Fatal (code bug)
|
||||
|
||||
When=NNN
|
||||
Standard long time of request in seconds
|
||||
|
||||
Code=N
|
||||
Each unique reply has a unigue Code (See api.c - #define MSG_NNNNNN)
|
||||
|
||||
@ -615,7 +620,7 @@ The STATUS section is:
|
||||
This defaults to the cgminer version but is the value of --api-description
|
||||
if it was specified at runtime.
|
||||
|
||||
For API version 1.3:
|
||||
For API version 1.4:
|
||||
|
||||
The list of requests - a (*) means it requires privileged access - and replies are:
|
||||
|
||||
|
19
api.c
19
api.c
@ -152,7 +152,7 @@ static const char *COMMA = ",";
|
||||
static const char SEPARATOR = '|';
|
||||
static const char GPUSEP = ',';
|
||||
|
||||
static const char *APIVERSION = "1.3";
|
||||
static const char *APIVERSION = "1.4";
|
||||
static const char *DEAD = "Dead";
|
||||
static const char *SICK = "Sick";
|
||||
static const char *NOSTART = "NoStart";
|
||||
@ -371,6 +371,8 @@ static int my_thr_id = 0;
|
||||
static int bye = 0;
|
||||
static bool ping = true;
|
||||
|
||||
static time_t when = 0; // when the request occurred
|
||||
|
||||
struct IP4ACCESS {
|
||||
in_addr_t ip;
|
||||
in_addr_t mask;
|
||||
@ -411,9 +413,9 @@ static char *message(int messageid, int paramid, char *param2, bool isjson)
|
||||
}
|
||||
|
||||
if (isjson)
|
||||
sprintf(msg_buffer, JSON_START JSON_STATUS "{\"" _STATUS "\":\"%c\",\"Code\":%d,\"Msg\":\"", severity, messageid);
|
||||
sprintf(msg_buffer, JSON_START JSON_STATUS "{\"" _STATUS "\":\"%c\",\"When\":%lu,\"Code\":%d,\"Msg\":\"", severity, (unsigned long)when, messageid);
|
||||
else
|
||||
sprintf(msg_buffer, _STATUS "=%c,Code=%d,Msg=", severity, messageid);
|
||||
sprintf(msg_buffer, _STATUS "=%c,When=%lu,Code=%d,Msg=", severity, (unsigned long)when, messageid);
|
||||
|
||||
ptr = msg_buffer + strlen(msg_buffer);
|
||||
|
||||
@ -474,11 +476,11 @@ static char *message(int messageid, int paramid, char *param2, bool isjson)
|
||||
}
|
||||
|
||||
if (isjson)
|
||||
sprintf(msg_buffer, JSON_START JSON_STATUS "{\"" _STATUS "\":\"F\",\"Code\":-1,\"Msg\":\"%d\",\"Description\":\"%s\"}" JSON_CLOSE,
|
||||
messageid, opt_api_description);
|
||||
sprintf(msg_buffer, JSON_START JSON_STATUS "{\"" _STATUS "\":\"F\",\"When\":%lu,\"Code\":-1,\"Msg\":\"%d\",\"Description\":\"%s\"}" JSON_CLOSE,
|
||||
(unsigned long)when, messageid, opt_api_description);
|
||||
else
|
||||
sprintf(msg_buffer, _STATUS "=F,Code=-1,Msg=%d,Description=%s%c",
|
||||
messageid, opt_api_description, SEPARATOR);
|
||||
sprintf(msg_buffer, _STATUS "=F,When=%lu,Code=-1,Msg=%d,Description=%s%c",
|
||||
(unsigned long)when, messageid, opt_api_description, SEPARATOR);
|
||||
|
||||
return msg_buffer;
|
||||
}
|
||||
@ -1668,6 +1670,9 @@ void api(int api_thr_id)
|
||||
}
|
||||
|
||||
if (!SOCKETFAIL(n)) {
|
||||
// the time of the request in now
|
||||
when = time(NULL);
|
||||
|
||||
did = false;
|
||||
|
||||
if (*buf != ISJSON) {
|
||||
|
Loading…
Reference in New Issue
Block a user