summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-30 21:23:44 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-30 21:23:44 +0100
commit6d183c02a50a42743c3031532f458ab5cea0685d (patch)
treed1463e8f53df26ec5f8c3c13a77880d11d3bc57f /config.c
parentef93f4d61f03faa0edd60f11c7790ad3b67b44d4 (diff)
Convert debugprint() from being to file/screen/disabled to always being to file with configurable verbosity.
Diffstat (limited to 'config.c')
-rw-r--r--config.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/config.c b/config.c
index b615fa2..756f832 100644
--- a/config.c
+++ b/config.c
@@ -48,7 +48,7 @@ int getconfstr(char *confname, char *filename, char* dest) {
// If we got here, then either we found the configuration option or we ran out of file
if (!found) {
- debugprint("Error reading configuration option '%s', did not find it in configuration file '%s'.\n", confname, filename);
+ debugprint(DEBUG_SOME, "Error reading configuration option '%s', did not find it in configuration file '%s'.\n", confname, filename);
fclose(fp);
return 0;
}
@@ -80,7 +80,7 @@ int getconfstr(char *confname, char *filename, char* dest) {
strncpy(dest, conf + 1, strlen(conf) - 2); // Copy result to destination string without quotes
dest[strlen(conf) - 2] = '\0'; // Null terminate
- debugprint("getconfstr(): returning '%s'.\n", dest);
+ debugprint(DEBUG_FULL, "getconfstr(): returning '%s'.\n", dest);
// Close fine and return success
fclose(fp);
@@ -107,21 +107,21 @@ int checkpassword(char *password, char *filename) {
char confpassword[MAXCHAR];
if (!getconfstr("password", filename, confpassword)) {
- debugprint("checkpassword(): error getting configuration option 'password' from configuration file '%s'.\n", filename);
+ debugprint(DEBUG_CRIT, "checkpassword(): error getting configuration option 'password' from configuration file '%s'.\n", filename);
return 0;
}
// Ensure passwords are the same length
if (strlen(password) != strlen(confpassword)) {
- debugprint("Password length mismatch!\n");
+ debugprint(DEBUG_SOME, "Password length mismatch!\n");
return 0;
}
// Ensure passwords match
if (strncmp(password, confpassword, strlen(password)) == 0) {
- debugprint("confpassword matches password.\n");
+ debugprint(DEBUG_FULL, "confpassword matches password.\n");
return 1;
} else {
- debugprint("confpassword does NOT match password!\n");
+ debugprint(DEBUG_SOME, "confpassword does NOT match password!\n");
return 0;
}
@@ -227,9 +227,9 @@ int createconfigfile(char *filename) {
"# Replay log goes to basedir/replay.log\n"
"replaylogging = \"1\"\n"
"\n"
- "# Debug output control (\"2\" for print to screen, \"1\" for print to file, or \"0\" for disabled)\n"
- "# (The debug file can be found in <basedir>/debug.txt)\n"
- "debug = \"1\"\n";
+ "# Debug verbosity (\"0\" for critical only, \"1\" for some extra info, \"2\" for full debug mode)\n"
+ "# (All output goes to <basedir>/debug.txt)\n"
+ "debug = \"2\"\n";
// Write complete string to file
if ((fprintf(fp, "%s", string)) < 0) {