mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 23:56:29 +00:00
Merge remote-tracking branch 'tbrs/master' into heroku
Grab the configuration struct changes. It was expeditious to un-do some of my by-hand line-wrapping that avoids 80 character limit, though. Conflicts: config.c config.h repmgr.c repmgr.h repmgrd.c
This commit is contained in:
40
config.c
40
config.c
@@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
void
|
||||
parse_config(const char *config_file, char *cluster_name, int *node,
|
||||
parse_config(const char *config_file, repmgr_config *config)
|
||||
char *conninfo)
|
||||
{
|
||||
char *s, buff[MAXLINELENGTH];
|
||||
@@ -32,9 +32,17 @@ parse_config(const char *config_file, char *cluster_name, int *node,
|
||||
|
||||
FILE *fp = fopen (config_file, "r");
|
||||
|
||||
if (fp == NULL)
|
||||
return;
|
||||
|
||||
if (fp == NULL) {
|
||||
fprintf(stderr, _("Could not find configuration file '%s'\n"), config_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Initialize */
|
||||
memset(config->cluster_name, 0, sizeof(config->cluster_name));
|
||||
config->node = -1;
|
||||
memset(config->conninfo, 0, sizeof(config->conninfo));
|
||||
memset(config->rsync_options, 0, sizeof(config->rsync_options));
|
||||
|
||||
/* Read next line */
|
||||
while ((s = fgets (buff, sizeof buff, fp)) != NULL)
|
||||
{
|
||||
@@ -47,18 +55,34 @@ parse_config(const char *config_file, char *cluster_name, int *node,
|
||||
|
||||
/* Copy into correct entry in parameters struct */
|
||||
if (strcmp(name, "cluster") == 0)
|
||||
strncpy (cluster_name, value, MAXLEN);
|
||||
strncpy (config->cluster_name, value, MAXLEN);
|
||||
else if (strcmp(name, "node") == 0)
|
||||
*node = atoi(value);
|
||||
config->node = atoi(value);
|
||||
else if (strcmp(name, "conninfo") == 0)
|
||||
strncpy (conninfo, value, MAXLEN);
|
||||
strncpy (config->conninfo, value, MAXLEN);
|
||||
else if (strcmp(name, "rsync_options") == 0)
|
||||
strncpy (config->rsync_options, value, QUERY_STR_LEN);
|
||||
else
|
||||
printf ("WARNING: %s/%s: Unknown name/value pair!\n", name, value);
|
||||
}
|
||||
|
||||
|
||||
/* Close file */
|
||||
fclose (fp);
|
||||
|
||||
/* Check config settings */
|
||||
if (strnlen(config->cluster_name, MAXLEN)==0)
|
||||
{
|
||||
fprintf(stderr, "Cluster name is missing. "
|
||||
"Check the configuration file.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (config->node == -1)
|
||||
{
|
||||
fprintf(stderr, "Node information is missing. "
|
||||
"Check the configuration file.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
|
||||
Reference in New Issue
Block a user