Merge remote branch 'gbartolini/gabriele-2010-12' into heroku

Conflicts:
	config.c
	dbutils.c
	dbutils.h
	repmgrd.c

Signed-off-by: Dan Farina <drfarina@acm.org>
This commit is contained in:
Dan Farina
2010-12-21 16:06:42 -08:00
6 changed files with 48 additions and 52 deletions

View File

@@ -11,11 +11,15 @@
#include "strutil.h"
void
parse_config(const char *config_file, char *cluster_name, int *node,
char *conninfo)
{
char *s, buff[1024];
char *s, buff[MAXLINELENGTH];
char name[MAXLEN];
char value[MAXLEN];
FILE *fp = fopen (config_file, "r");
if (fp == NULL)
@@ -24,9 +28,6 @@ parse_config(const char *config_file, char *cluster_name, int *node,
/* Read next line */
while ((s = fgets (buff, sizeof buff, fp)) != NULL)
{
char name[MAXLEN];
char value[MAXLEN];
/* Skip blank lines and comments */
if (buff[0] == '\n' || buff[0] == '#')
continue;
@@ -36,16 +37,16 @@ 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 (cluster_name, value, MAXLEN);
else if (strcmp(name, "node") == 0)
*node = atoi(value);
else if (strcmp(name, "conninfo") == 0)
strncpy(conninfo, value, MAXLEN);
strncpy (conninfo, value, MAXLEN);
else
printf("WARNING: %s/%s: Unknown name/value pair!\n",
name, value);
printf ("WARNING: %s/%s: Unknown name/value pair!\n", name, value);
}
/* Close file */
fclose (fp);
}
@@ -58,12 +59,12 @@ trim (char *s)
/* Trim and delimit right side */
while ( (isspace (*s2)) && (s2 >= s1) )
s2--;
--s2;
*(s2+1) = '\0';
/* Trim left side */
while ( (isspace (*s1)) && (s1 < s2) )
s1++;
++s1;
/* Copy finished string */
strcpy (s, s1);
@@ -73,14 +74,13 @@ trim (char *s)
void
parse_line(char *buff, char *name, char *value)
{
int i;
int j;
int i = 0;
int j = 0;
/*
* first we find the name of the parameter
*/
j = 0;
for (i = 0; i < MAXLEN; i++)
for ( ; i < MAXLEN; ++i)
{
if (buff[i] != '=')
name[j++] = buff[i];
@@ -89,12 +89,11 @@ parse_line(char *buff, char *name, char *value)
}
name[j] = '\0';
i++;
/*
* Now the value
*/
j = 0;
for ( ; i < MAXLEN; i++)
for ( ++i ; i < MAXLEN; ++i)
if (buff[i] == '\'')
continue;
else if (buff[i] != '\n')