Browse Source

RPC: Build most of CONFIG "Device Code" by iterating over registered driver list

Luke Dashjr 12 years ago
parent
commit
ff394e3a4d
1 changed files with 19 additions and 52 deletions
  1. 19 52
      api.c

+ 19 - 52
api.c

@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/types.h>
 
 
 #include "compat.h"
 #include "compat.h"
+#include "deviceapi.h"
 #ifdef USE_LIBMICROHTTPD
 #ifdef USE_LIBMICROHTTPD
 #include "httpsrv.h"
 #include "httpsrv.h"
 #endif
 #endif
@@ -86,57 +87,6 @@ static const char *SCRYPTSTR = "scrypt";
 #endif
 #endif
 static const char *SHA256STR = "sha256";
 static const char *SHA256STR = "sha256";
 
 
-static const char *DEVICECODE = ""
-#ifdef HAVE_OPENCL
-			"GPU "
-#endif
-#ifdef USE_BITFORCE
-			"BFL "
-#endif
-#ifdef USE_BITFURY
-			"BFY "
-#endif
-#ifdef USE_BIGPIC
-			"BPM "
-#endif
-#ifdef USE_BFSB
-			"BSB "
-#endif
-#ifdef USE_ICARUS
-			"ICA "
-#endif
-#ifdef USE_LITTLEFURY
-			"LFY "
-#endif
-#ifdef USE_METABANK
-			"MBF "
-#endif
-#ifdef USE_NANOFURY
-			"NFY "
-#endif
-#ifdef USE_AVALON
-			"AVA "
-#endif
-#ifdef USE_LIBMICROHTTPD
-			"SGW "
-#endif
-#ifdef USE_LIBEVENT
-			"SSM "
-#endif
-#ifdef USE_X6500
-			"XBS "
-#endif
-#ifdef USE_ZTEX
-			"ZTX "
-#endif
-#ifdef USE_MODMINER
-			"MMQ "
-#endif
-#ifdef WANT_CPUMINE
-			"CPU "
-#endif
-			"";
-
 static const char *OSINFO =
 static const char *OSINFO =
 #if defined(__linux)
 #if defined(__linux)
 			"Linux";
 			"Linux";
@@ -1350,6 +1300,7 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
 	struct api_data *root = NULL;
 	struct api_data *root = NULL;
 	char buf[TMPBUFSIZ];
 	char buf[TMPBUFSIZ];
 	bool io_open;
 	bool io_open;
+	struct driver_registration *reg, *regtmp;
 	int gpucount = 0;
 	int gpucount = 0;
 	int pgacount = 0;
 	int pgacount = 0;
 	int cpucount = 0;
 	int cpucount = 0;
@@ -1391,7 +1342,23 @@ static void minerconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __
 	root = api_add_string(root, "ADL in use", adlinuse, false);
 	root = api_add_string(root, "ADL in use", adlinuse, false);
 	root = api_add_const(root, "Strategy", strategies[pool_strategy].s, false);
 	root = api_add_const(root, "Strategy", strategies[pool_strategy].s, false);
 	root = api_add_int(root, "Log Interval", &opt_log_interval, false);
 	root = api_add_int(root, "Log Interval", &opt_log_interval, false);
-	root = api_add_const(root, "Device Code", DEVICECODE, false);
+	
+	strcpy(buf, ""
+#ifdef USE_LIBMICROHTTPD
+			" SGW"
+#endif
+#ifdef USE_LIBEVENT
+			" SSM"
+#endif
+	);
+
+	BFG_FOREACH_DRIVER_BY_DNAME(reg, regtmp)
+	{
+		const struct device_drv * const drv = reg->drv;
+		tailsprintf(buf, sizeof(buf), " %s", drv->name);
+	}
+	root = api_add_const(root, "Device Code", &buf[1], true);
+	
 	root = api_add_const(root, "OS", OSINFO, false);
 	root = api_add_const(root, "OS", OSINFO, false);
 	root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
 	root = api_add_bool(root, "Failover-Only", &opt_fail_only, false);
 	root = api_add_int(root, "ScanTime", &opt_scantime, false);
 	root = api_add_int(root, "ScanTime", &opt_scantime, false);