astyle cleanup run after recent merges

This commit is contained in:
Greg Smith
2011-02-10 18:55:51 -05:00
parent c3af4274ae
commit 0130420947
6 changed files with 144 additions and 123 deletions

View File

@@ -28,7 +28,8 @@ parse_config(const char* config_file, t_configuration_options* options)
FILE *fp = fopen (config_file, "r"); FILE *fp = fopen (config_file, "r");
if (fp == NULL) { if (fp == NULL)
{
fprintf(stderr, _("Could not find configuration file '%s'\n"), config_file); fprintf(stderr, _("Could not find configuration file '%s'\n"), config_file);
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }

View File

@@ -22,7 +22,8 @@
#include "repmgr.h" #include "repmgr.h"
typedef struct { typedef struct
{
char cluster_name[MAXLEN]; char cluster_name[MAXLEN];
int node; int node;
char conninfo[MAXLEN]; char conninfo[MAXLEN];

30
log.c
View File

@@ -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); printf("Logger initialisation (Level: %s, Facility: %s)\n", level, facility);
#endif #endif
if (!ident) { if (!ident)
{
ident = DEFAULT_IDENT; ident = DEFAULT_IDENT;
} }
if (level && *level) { if (level && *level)
{
l = detect_log_level(level); l = detect_log_level(level);
#ifdef REPMGR_DEBUG #ifdef REPMGR_DEBUG
printf("Assigned level for logger: %d\n", l); printf("Assigned level for logger: %d\n", l);
@@ -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); 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); f = detect_log_facility(facility);
#ifdef REPMGR_DEBUG #ifdef REPMGR_DEBUG
printf("Assigned facility for logger: %d\n", f); printf("Assigned facility for logger: %d\n", f);
#endif #endif
if (f == 0) { if (f == 0)
{
/* No syslog requested, just stderr */ /* No syslog requested, just stderr */
#ifdef REPMGR_DEBUG #ifdef REPMGR_DEBUG
printf(_("Use stderr for logging\n")); printf(_("Use stderr for logging\n"));
#endif #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); stderr_log_warning(_("Cannot detect log facility %s (use any of LOCAL0, LOCAL1, ..., LOCAL7, USER or STDERR)\n"), facility);
} }
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG
else { else
{
syslog_facility = f; syslog_facility = f;
log_type = REPMGR_SYSLOG; log_type = REPMGR_SYSLOG;
} }
@@ -149,11 +155,13 @@ int detect_log_level(const char* level)
int detect_log_facility(const char* facility) int detect_log_facility(const char* facility)
{ {
int local = 0; int local = 0;
if (!strncmp(facility, "LOCAL", 5) && strlen(facility) == 6) { if (!strncmp(facility, "LOCAL", 5) && strlen(facility) == 6)
{
local = atoi (&facility[5]); local = atoi (&facility[5]);
switch(local) { switch (local)
{
case 0: case 0:
return LOG_LOCAL0; return LOG_LOCAL0;
break; break;
@@ -181,10 +189,12 @@ int detect_log_facility(const char* facility)
} }
} }
else if (!strcmp(facility, "USER")) { else if (!strcmp(facility, "USER"))
{
return LOG_USER; return LOG_USER;
} }
else if (!strcmp(facility, "STDERR")) { else if (!strcmp(facility, "STDERR"))
{
return 0; return 0;
} }

View File

@@ -270,7 +270,8 @@ main(int argc, char **argv)
parse_config(runtime_options.config_file, &options); parse_config(runtime_options.config_file, &options);
if (need_a_node) { if (need_a_node)
{
if (options.node == -1) if (options.node == -1)
{ {
@@ -539,7 +540,8 @@ do_standby_register(void)
/* check if there is a master in this cluster */ /* check if there is a master in this cluster */
master_conn = getMasterConnection(conn, options.node, options.cluster_name, &master_id); master_conn = getMasterConnection(conn, options.node, options.cluster_name, &master_id);
if (!master_conn) { if (!master_conn)
{
log_err(_("A master must be defined before configuring a slave\n")); log_err(_("A master must be defined before configuring a slave\n"));
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }
@@ -886,14 +888,16 @@ do_standby_clone(void)
log_info("standby clone: master control file '%s'\n", master_control_file); log_info("standby clone: master control file '%s'\n", master_control_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_control_file, local_control_file, false); r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_control_file, local_control_file, false);
if (r != 0) { if (r != 0)
{
log_warning("standby clone: failed copying master control file '%s'\n", master_control_file); log_warning("standby clone: failed copying master control file '%s'\n", master_control_file);
goto stop_backup; goto stop_backup;
} }
log_info("standby clone: master data directory '%s'\n", master_data_directory); log_info("standby clone: master data directory '%s'\n", master_data_directory);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_data_directory, runtime_options.dest_dir, true); r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_data_directory, runtime_options.dest_dir, true);
if (r != 0) { if (r != 0)
{
log_warning("standby clone: failed copying master data directory '%s'\n", master_data_directory); log_warning("standby clone: failed copying master data directory '%s'\n", master_data_directory);
goto stop_backup; goto stop_backup;
} }
@@ -916,7 +920,8 @@ do_standby_clone(void)
strncpy(tblspc_dir, PQgetvalue(res, i, 0), MAXFILENAME); strncpy(tblspc_dir, PQgetvalue(res, i, 0), MAXFILENAME);
log_info("standby clone: master tablespace '%s'\n", tblspc_dir); log_info("standby clone: master tablespace '%s'\n", tblspc_dir);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, tblspc_dir, tblspc_dir, true); r = copy_remote_files(runtime_options.host, runtime_options.remote_user, tblspc_dir, tblspc_dir, true);
if (r != 0) { if (r != 0)
{
log_warning("standby clone: failed copying tablespace directory '%s'\n", tblspc_dir); log_warning("standby clone: failed copying tablespace directory '%s'\n", tblspc_dir);
goto stop_backup; goto stop_backup;
} }
@@ -924,21 +929,24 @@ do_standby_clone(void)
log_info("standby clone: master config file '%s'\n", master_config_file); log_info("standby clone: master config file '%s'\n", master_config_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_config_file, runtime_options.dest_dir, false); r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_config_file, runtime_options.dest_dir, false);
if (r != 0) { if (r != 0)
{
log_warning("standby clone: failed copying master config file '%s'\n", master_config_file); log_warning("standby clone: failed copying master config file '%s'\n", master_config_file);
goto stop_backup; goto stop_backup;
} }
log_info("standby clone: master hba file '%s'\n", master_hba_file); log_info("standby clone: master hba file '%s'\n", master_hba_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_hba_file, runtime_options.dest_dir, false); r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_hba_file, runtime_options.dest_dir, false);
if (r != 0) { if (r != 0)
{
log_warning("standby clone: failed copying master hba file '%s'\n", master_hba_file); log_warning("standby clone: failed copying master hba file '%s'\n", master_hba_file);
goto stop_backup; goto stop_backup;
} }
log_info("standby clone: master ident file '%s'\n", master_ident_file); log_info("standby clone: master ident file '%s'\n", master_ident_file);
r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_ident_file, runtime_options.dest_dir, false); r = copy_remote_files(runtime_options.host, runtime_options.remote_user, master_ident_file, runtime_options.dest_dir, false);
if (r != 0) { if (r != 0)
{
log_warning("standby clone: failed copying master ident file '%s'\n", master_ident_file); log_warning("standby clone: failed copying master ident file '%s'\n", master_ident_file);
goto stop_backup; goto stop_backup;
} }

View File

@@ -58,7 +58,8 @@
#define ERR_PROMOTED 8 #define ERR_PROMOTED 8
/* Run time options type */ /* Run time options type */
typedef struct { typedef struct
{
char dbname[MAXLEN]; char dbname[MAXLEN];
char host[MAXLEN]; char host[MAXLEN];