Browse Source

Merge commit '71378a4' into bfgminer

Conflicts:
	miner.c
Luke Dashjr 13 years ago
parent
commit
7447673b74
4 changed files with 37 additions and 18 deletions
  1. 13 1
      API-README
  2. 5 4
      api.c
  3. 18 13
      miner.c
  4. 1 0
      miner.h

+ 13 - 1
API-README

@@ -203,6 +203,8 @@ The list of requests - a (*) means it requires privileged access - and replies a
                none           There is no reply section just the STATUS section
                               stating success or failure saving the BFGMiner config
                               to filename
+                              The filename is optional and will use the cgminer
+                              default if not specified
 
  quit (*)      none           There is no status section but just a single "BYE"
                               reply before BFGMiner quits
@@ -284,7 +286,17 @@ miner.php - an example web page to access the API
 Feature Changelog for external applications using the API:
 
 
-API V1.10
+API V1.11
+
+Modified API commands:
+ 'save' no longer requires a filename (use default if not specified)
+
+'save' incorrectly returned status E (error) on success before.
+It now correctly returns S (success)
+
+----------
+
+API V1.10 (cgminer v2.4.1)
 
 Added API commands:
  'stats'

+ 5 - 4
api.c

@@ -161,7 +161,7 @@ static const char SEPARATOR = '|';
 #define SEPSTR "|"
 static const char GPUSEP = ',';
 
-static const char *APIVERSION = "1.10";
+static const char *APIVERSION = "1.11";
 static const char *DEAD = "Dead";
 static const char *SICK = "Sick";
 static const char *NOSTART = "NoStart";
@@ -465,7 +465,7 @@ struct CODES {
  { SEVERITY_SUCC,  MSG_GPUFAN,	PARAM_BOTH,	"Setting GPU %d fan to (%s) reported succeess" },
  { SEVERITY_ERR,   MSG_MISFN,	PARAM_NONE,	"Missing save filename parameter" },
  { SEVERITY_ERR,   MSG_BADFN,	PARAM_STR,	"Can't open or create save file '%s'" },
- { SEVERITY_ERR,   MSG_SAVED,	PARAM_STR,	"Configuration saved to file '%s'" },
+ { SEVERITY_SUCC,  MSG_SAVED,	PARAM_STR,	"Configuration saved to file '%s'" },
  { SEVERITY_ERR,   MSG_ACCDENY,	PARAM_STR,	"Access denied to '%s' command" },
  { SEVERITY_SUCC,  MSG_ACCOK,	PARAM_NONE,	"Privileged access OK" },
  { SEVERITY_SUCC,  MSG_ENAPOOL,	PARAM_POOL,	"Enabling pool %d:'%s'" },
@@ -1952,12 +1952,13 @@ static void devdetails(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
 
 void dosave(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
 {
+	char filename[PATH_MAX];
 	FILE *fcfg;
 	char *ptr;
 
 	if (param == NULL || *param == '\0') {
-		strcpy(io_buffer, message(MSG_MISFN, 0, NULL, isjson));
-		return;
+		default_save_file(filename);
+		param = filename;
 	}
 
 	fcfg = fopen(param, "w");

+ 18 - 13
miner.c

@@ -3034,6 +3034,23 @@ retry:
 }
 #endif
 
+void default_save_file(char *filename)
+{
+#if defined(unix)
+	if (getenv("HOME") && *getenv("HOME")) {
+	        strcpy(filename, getenv("HOME"));
+		strcat(filename, "/");
+	}
+	else
+		strcpy(filename, "");
+	strcat(filename, ".bfgminer/");
+	mkdir(filename, 0777);
+#else
+	strcpy(filename, "");
+#endif
+	strcat(filename, def_conf);
+}
+
 #ifdef HAVE_CURSES
 static void set_options(void)
 {
@@ -3102,19 +3119,7 @@ retry:
 		FILE *fcfg;
 		char *str, filename[PATH_MAX], prompt[PATH_MAX + 50];
 
-#if defined(unix)
-		if (getenv("HOME") && *getenv("HOME")) {
-		        strcpy(filename, getenv("HOME"));
-			strcat(filename, "/");
-		}
-		else
-			strcpy(filename, "");
-		strcat(filename, ".bfgminer/");
-		mkdir(filename, 0777);
-#else
-		strcpy(filename, "");
-#endif
-		strcat(filename, def_conf);
+		default_save_file(filename);
 		sprintf(prompt, "Config filename to write (Enter for default) [%s]", filename);
 		str = curses_input(prompt);
 		if (strcmp(str, "-1")) {

+ 1 - 0
miner.h

@@ -738,6 +738,7 @@ extern void kill_work(void);
 extern void switch_pools(struct pool *selected);
 extern void remove_pool(struct pool *pool);
 extern void write_config(FILE *fcfg);
+extern void default_save_file(char *filename);
 extern void log_curses(int prio, const char *f, va_list ap);
 extern void clear_logwin(void);
 extern bool pool_tclear(struct pool *pool, bool *var);