Browse Source

Add the ability to display a hexadecimal 32 bit unsigned integer to the API.

port-ckolivas
Con Kolivas 11 years ago committed by Noel Maersk
parent
commit
90cc93c6cc
  1. 12
      api.c
  2. 2
      miner.h

12
api.c

@ -729,6 +729,10 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
api_data->data = (void *)malloc(sizeof(uint32_t)); api_data->data = (void *)malloc(sizeof(uint32_t));
*((uint32_t *)(api_data->data)) = *((uint32_t *)data); *((uint32_t *)(api_data->data)) = *((uint32_t *)data);
break; break;
case API_HEX32:
api_data->data = (void *)malloc(sizeof(uint32_t));
*((uint32_t *)(api_data->data)) = *((uint32_t *)data);
break;
case API_UINT64: case API_UINT64:
api_data->data = (void *)malloc(sizeof(uint64_t)); api_data->data = (void *)malloc(sizeof(uint64_t));
*((uint64_t *)(api_data->data)) = *((uint64_t *)data); *((uint64_t *)(api_data->data)) = *((uint64_t *)data);
@ -815,6 +819,11 @@ struct api_data *api_add_uint32(struct api_data *root, char *name, uint32_t *dat
return api_add_data_full(root, name, API_UINT32, (void *)data, copy_data); return api_add_data_full(root, name, API_UINT32, (void *)data, copy_data);
} }
struct api_data *api_add_hex32(struct api_data *root, char *name, uint32_t *data, bool copy_data)
{
return api_add_data_full(root, name, API_HEX32, (void *)data, copy_data);
}
struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data) struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data)
{ {
return api_add_data_full(root, name, API_UINT64, (void *)data, copy_data); return api_add_data_full(root, name, API_UINT64, (void *)data, copy_data);
@ -958,6 +967,9 @@ static struct api_data *print_data(struct api_data *root, char *buf, bool isjson
case API_UINT32: case API_UINT32:
sprintf(buf, "%"PRIu32, *((uint32_t *)(root->data))); sprintf(buf, "%"PRIu32, *((uint32_t *)(root->data)));
break; break;
case API_HEX32:
snprintf(buf, sizeof(buf), "0x%08x", *((uint32_t *)(root->data)));
break;
case API_UINT64: case API_UINT64:
sprintf(buf, "%"PRIu64, *((uint64_t *)(root->data))); sprintf(buf, "%"PRIu64, *((uint64_t *)(root->data)));
break; break;

2
miner.h

@ -1441,6 +1441,7 @@ enum api_data_type {
API_INT, API_INT,
API_UINT, API_UINT,
API_UINT32, API_UINT32,
API_HEX32,
API_UINT64, API_UINT64,
API_DOUBLE, API_DOUBLE,
API_ELAPSED, API_ELAPSED,
@ -1477,6 +1478,7 @@ extern struct api_data *api_add_uint16(struct api_data *root, char *name, uint16
extern struct api_data *api_add_int(struct api_data *root, char *name, int *data, bool copy_data); extern struct api_data *api_add_int(struct api_data *root, char *name, int *data, bool copy_data);
extern struct api_data *api_add_uint(struct api_data *root, char *name, unsigned int *data, bool copy_data); extern struct api_data *api_add_uint(struct api_data *root, char *name, unsigned int *data, bool copy_data);
extern struct api_data *api_add_uint32(struct api_data *root, char *name, uint32_t *data, bool copy_data); extern struct api_data *api_add_uint32(struct api_data *root, char *name, uint32_t *data, bool copy_data);
extern struct api_data *api_add_hex32(struct api_data *root, char *name, uint32_t *data, bool copy_data);
extern struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data); extern struct api_data *api_add_uint64(struct api_data *root, char *name, uint64_t *data, bool copy_data);
extern struct api_data *api_add_double(struct api_data *root, char *name, double *data, bool copy_data); extern struct api_data *api_add_double(struct api_data *root, char *name, double *data, bool copy_data);
extern struct api_data *api_add_elapsed(struct api_data *root, char *name, double *data, bool copy_data); extern struct api_data *api_add_elapsed(struct api_data *root, char *name, double *data, bool copy_data);

Loading…
Cancel
Save