1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2001,2008 Oracle.  All rights reserved.
5 *
6 * $Id: RepConfigInfo.cpp,v 1.7 2008/01/08 20:58:27 bostic Exp $
7 */
8
9#include "RepConfigInfo.h"
10
11RepConfigInfo::RepConfigInfo()
12{
13	start_policy = DB_REP_ELECTION;
14	home = "TESTDIR";
15	got_listen_address = false;
16	totalsites = 0;
17	priority = 100;
18	verbose = false;
19	other_hosts = NULL;
20}
21
22RepConfigInfo::~RepConfigInfo()
23{
24	// release any other_hosts structs.
25	if (other_hosts != NULL) {
26		REP_HOST_INFO *CurItem = other_hosts;
27		while (CurItem->next != NULL)
28		{
29			REP_HOST_INFO *TmpItem = CurItem;
30			free(CurItem);
31			CurItem = TmpItem;
32		}
33		free(CurItem);
34	}
35	other_hosts = NULL;
36}
37
38void RepConfigInfo::addOtherHost(char* host, int port, bool peer)
39{
40	REP_HOST_INFO *newinfo;
41	newinfo = (REP_HOST_INFO*)malloc(sizeof(REP_HOST_INFO));
42	newinfo->host = host;
43	newinfo->port = port;
44	newinfo->peer = peer;
45	if (other_hosts == NULL) {
46		other_hosts = newinfo;
47		newinfo->next = NULL;
48	} else {
49		newinfo->next = other_hosts;
50		other_hosts = newinfo;
51	}
52}
53