Add api_add_int16 to API functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/api.c b/api.c
index e3dc72d..c63b934 100644
--- a/api.c
+++ b/api.c
@@ -878,6 +878,11 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
api_data->data = malloc(4);
*(uint8_t *)api_data->data = *(uint8_t *)data;
break;
+ case API_INT16:
+ /* Most OSs won't really alloc less than 4 */
+ api_data->data = malloc(4);
+ *(int16_t *)api_data->data = *(int16_t *)data;
+ break;
case API_UINT16:
/* Most OSs won't really alloc less than 4 */
api_data->data = malloc(4);
@@ -964,6 +969,11 @@ struct api_data *api_add_uint8(struct api_data *root, char *name, uint8_t *data,
return api_add_data_full(root, name, API_UINT8, (void *)data, copy_data);
}
+struct api_data *api_add_int16(struct api_data *root, char *name, uint16_t *data, bool copy_data)
+{
+ return api_add_data_full(root, name, API_INT16, (void *)data, copy_data);
+}
+
struct api_data *api_add_uint16(struct api_data *root, char *name, uint16_t *data, bool copy_data)
{
return api_add_data_full(root, name, API_UINT16, (void *)data, copy_data);
@@ -1160,6 +1170,9 @@ static struct api_data *print_data(struct io_data *io_data, struct api_data *roo
case API_UINT8:
snprintf(buf, sizeof(buf), "%u", *(uint8_t *)root->data);
break;
+ case API_INT16:
+ snprintf(buf, sizeof(buf), "%d", *(int16_t *)root->data);
+ break;
case API_UINT16:
snprintf(buf, sizeof(buf), "%u", *(uint16_t *)root->data);
break;
diff --git a/miner.h b/miner.h
index e0e7e52..ea588f2 100644
--- a/miner.h
+++ b/miner.h
@@ -1428,6 +1428,7 @@ enum api_data_type {
API_STRING,
API_CONST,
API_UINT8,
+ API_INT16,
API_UINT16,
API_INT,
API_UINT,