From 31ce10b31198128de4983667820319a193adb976 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 27 May 2019 23:01:11 +0100 Subject: Make debug output optional and disabled by default. --- config.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index 9716d8f..9b69682 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) { - printf("Error reading configuration option '%s', did not find it in configuration file '%s'.\n", confname, filename); + debugprint("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 - printf("getconfstr(): returning '%s'.\n", dest); + debugprint("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)) { - printf("checkpassword(): error getting configuration option 'password' from configuration file '%s'.\n", filename); + debugprint("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)) { - printf("Password length mismatch!\n"); + debugprint("Password length mismatch!\n"); return 0; } // Ensure passwords match if (strncmp(password, confpassword, strlen(password)) == 0) { - printf("confpassword matches password.\n"); + debugprint("confpassword matches password.\n"); return 1; } else { - printf("confpassword does NOT match password!\n"); + debugprint("confpassword does NOT match password!\n"); return 0; } @@ -167,7 +167,7 @@ int createconfigfile(char *filename) { "# realname = \"Mr Bla Bouncer\"\n" "#\n" "# Shell expansion is not supported, so do not try and specify e.g.\n" - "# \"~/.blabouncer/\" or \"%HOME/.blabouncer/\", instead use \"/home/foo/.blabouncer\"\n" + "# \"~/.blabouncer/\" or \"$HOME/.blabouncer/\", instead use \"/home/foo/.blabouncer\"\n" "\n" "nick = \"blabounce\"\n" "nick2 = \"bbounce2\"\n" @@ -222,7 +222,11 @@ int createconfigfile(char *filename) { "\n" "# Enable replay logging (\"1\" for yes or \"0\" for no)\n" "# Replay log goes to basedir/replay.log\n" - "replaylogging = \"1\"\n"; + "replaylogging = \"1\"\n" + "\n" + "# Debug output control (\"2\" for print to screen, \"1\" for print to file, or \"0\" for disabled)\n" + "# (Note: print to file not yet implemented)\n" + "debug = \"0\"\n"; // Write complete string to file if ((fprintf(fp, string)) < 0) { -- cgit v1.2.3