Commit dbc4dcda09092e34a18ed80f7d7e2429ad293c50

Con Kolivas 2014-03-01T14:25:26

Add api_add_int16 to API functions.

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,