summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-27 23:01:11 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-27 23:01:11 +0100
commit31ce10b31198128de4983667820319a193adb976 (patch)
tree99ff7bc13815f25c13a8d994b7dc28d302e72225 /config.c
parent4b2cd5c4c349ea3e5683a6b2beb42c518d3ccef3 (diff)
Make debug output optional and disabled by default.
Diffstat (limited to 'config.c')
-rw-r--r--config.c20
1 files changed, 12 insertions, 8 deletions
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) {