Commit 5542761f5d0e44a8c0ff5142151b354749fc2c16

Con Kolivas 2014-02-01T23:36:25

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

diff --git a/api.c b/api.c
index a05468c..c71dad9 100644
--- a/api.c
+++ b/api.c
@@ -889,6 +889,10 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
 				api_data->data = (void *)malloc(sizeof(uint32_t));
 				*((uint32_t *)(api_data->data)) = *((uint32_t *)data);
 				break;
+			case API_HEX32:
+				api_data->data = (void *)malloc(sizeof(uint32_t));
+				*((uint32_t *)(api_data->data)) = *((uint32_t *)data);
+				break;
 			case API_UINT64:
 				api_data->data = (void *)malloc(sizeof(uint64_t));
 				*((uint64_t *)(api_data->data)) = *((uint64_t *)data);
@@ -974,6 +978,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);
 }
 
+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)
 {
 	return api_add_data_full(root, name, API_UINT64, (void *)data, copy_data);
@@ -1157,6 +1166,9 @@ static struct api_data *print_data(struct io_data *io_data, struct api_data *roo
 			case API_UINT32:
 				snprintf(buf, sizeof(buf), "%"PRIu32, *((uint32_t *)(root->data)));
 				break;
+			case API_HEX32:
+				snprintf(buf, sizeof(buf), "0x%08x", *((uint32_t *)(root->data)));
+				break;
 			case API_UINT64:
 				snprintf(buf, sizeof(buf), "%"PRIu64, *((uint64_t *)(root->data)));
 				break;
diff --git a/miner.h b/miner.h
index 9618018..8d1d733 100644
--- a/miner.h
+++ b/miner.h
@@ -1409,6 +1409,7 @@ enum api_data_type {
 	API_INT,
 	API_UINT,
 	API_UINT32,
+	API_HEX32,
 	API_UINT64,
 	API_DOUBLE,
 	API_ELAPSED,
@@ -1444,6 +1445,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_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_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_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);