Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
astyle cleanup run after recent merges
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Smith authored and Greg Smith committed Feb 10, 2011
1 parent c3af427 commit 0130420
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 123 deletions.
7 changes: 4 additions & 3 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ parse_config(const char* config_file, t_configuration_options* options)

FILE *fp = fopen (config_file, "r");

if (fp == NULL) {
if (fp == NULL)
{
fprintf(stderr, _("Could not find configuration file '%s'\n"), config_file);
exit(ERR_BAD_CONFIG);
}

/* Initialize */
memset(options->cluster_name, 0, sizeof(options->cluster_name));
options->node = -1;
memset(options->conninfo, 0, sizeof(options->conninfo));
memset(options->rsync_options, 0, sizeof(options->rsync_options));

/* Read next line */
while ((s = fgets (buff, sizeof buff, fp)) != NULL)
{
Expand Down
5 changes: 3 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

#include "repmgr.h"

typedef struct {
typedef struct
{
char cluster_name[MAXLEN];
int node;
char conninfo[MAXLEN];
char loglevel[MAXLEN];
char logfacility[MAXLEN];
char rsync_options[QUERY_STR_LEN];
char rsync_options[QUERY_STR_LEN];
} t_configuration_options;

void parse_config(const char* config_file, t_configuration_options* options);
Expand Down
78 changes: 44 additions & 34 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ bool logger_init(const char* ident, const char* level, const char* facility)
printf("Logger initialisation (Level: %s, Facility: %s)\n", level, facility);
#endif

if (!ident) {
if (!ident)
{
ident = DEFAULT_IDENT;
}

if (level && *level) {
if (level && *level)
{
l = detect_log_level(level);
#ifdef REPMGR_DEBUG
printf("Assigned level for logger: %d\n", l);
Expand All @@ -73,24 +75,28 @@ bool logger_init(const char* ident, const char* level, const char* facility)
stderr_log_warning(_("Cannot detect log level %s (use any of DEBUG, INFO, NOTICE, WARNING, ERR, ALERT, CRIT or EMERG)\n"), level);
}

if (facility && *facility) {
if (facility && *facility)
{

f = detect_log_facility(facility);
#ifdef REPMGR_DEBUG
printf("Assigned facility for logger: %d\n", f);
#endif

if (f == 0) {
if (f == 0)
{
/* No syslog requested, just stderr */
#ifdef REPMGR_DEBUG
printf(_("Use stderr for logging\n"));
#endif
}
else if (f == -1) {
else if (f == -1)
{
stderr_log_warning(_("Cannot detect log facility %s (use any of LOCAL0, LOCAL1, ..., LOCAL7, USER or STDERR)\n"), facility);
}
#ifdef HAVE_SYSLOG
else {
else
{
syslog_facility = f;
log_type = REPMGR_SYSLOG;
}
Expand Down Expand Up @@ -149,42 +155,46 @@ int detect_log_level(const char* level)
int detect_log_facility(const char* facility)
{
int local = 0;
if (!strncmp(facility, "LOCAL", 5) && strlen(facility) == 6) {
if (!strncmp(facility, "LOCAL", 5) && strlen(facility) == 6)
{

local = atoi (&facility[5]);

switch(local) {
case 0:
return LOG_LOCAL0;
break;
case 1:
return LOG_LOCAL1;
break;
case 2:
return LOG_LOCAL2;
break;
case 3:
return LOG_LOCAL3;
break;
case 4:
return LOG_LOCAL4;
break;
case 5:
return LOG_LOCAL5;
break;
case 6:
return LOG_LOCAL6;
break;
case 7:
return LOG_LOCAL7;
break;
switch (local)
{
case 0:
return LOG_LOCAL0;
break;
case 1:
return LOG_LOCAL1;
break;
case 2:
return LOG_LOCAL2;
break;
case 3:
return LOG_LOCAL3;
break;
case 4:
return LOG_LOCAL4;
break;
case 5:
return LOG_LOCAL5;
break;
case 6:
return LOG_LOCAL6;
break;
case 7:
return LOG_LOCAL7;
break;
}

}
else if (!strcmp(facility, "USER")) {
else if (!strcmp(facility, "USER"))
{
return LOG_USER;
}
else if (!strcmp(facility, "STDERR")) {
else if (!strcmp(facility, "STDERR"))
{
return 0;
}

Expand Down

0 comments on commit 0130420

Please sign in to comment.