Last sync 2016.04.01
[deliverable/titan.core.git] / mctr2 / mctr / config_data.cc
1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Kovacs, Ferenc
11 * Raduly, Csaba
12 *
13 ******************************************************************************/
14 #include "config_data.h"
15 #include "../../common/memory.h"
16
17 void config_data::add_host(char *group_name, char *host_name)
18 {
19 group_list = (group_item*)Realloc(group_list,
20 ++group_list_len * sizeof(group_item));
21 // We take copies because the same group_name pointer may be supplied
22 // more than once (group:host is a one-to-many relationship).
23 // This would result in double-free.
24 // Copying the host_name is not strictly necessary; done for symmetry.
25 group_list[group_list_len-1].group_name = mcopystr(group_name);
26 // We need NULL here, not empty string.
27 group_list[group_list_len-1].host_name = host_name ? mcopystr(host_name) : NULL;
28 }
29
30 void config_data::add_component(char *host_or_grp, char *comp)
31 {
32 component_list = (component_item*)Realloc(component_list,
33 ++component_list_len * sizeof(component_item));
34 component_list[component_list_len-1].host_or_group = host_or_grp;
35 component_list[component_list_len-1].component = comp;
36 }
37
38 void config_data::add_exec(const execute_list_item& exec_item)
39 {
40 execute_list = (execute_list_item *)Realloc(execute_list,
41 (execute_list_len + 1) * sizeof(*execute_list));
42 execute_list[execute_list_len++] = exec_item;
43 }
44
45 void config_data::set_log_file(char *f)
46 {
47 if (log_file_name != NULL)
48 Free(log_file_name);
49 log_file_name = f;
50 }
51
52 void config_data::clear()
53 {
54 Free(config_read_buffer);
55 config_read_buffer = NULL;
56
57 Free(log_file_name);
58 log_file_name = NULL;
59
60 for(int r = 0; r < execute_list_len; r++) {
61 Free(execute_list[r].module_name);
62 Free(execute_list[r].testcase_name);
63 }
64 Free(execute_list);
65 execute_list = NULL;
66 execute_list_len = 0;
67
68 for(int r = 0; r < group_list_len; r++) {
69 Free(group_list[r].group_name);
70 Free(group_list[r].host_name);
71 }
72 Free(group_list);
73 group_list = NULL;
74 group_list_len = 0;
75
76 for(int r = 0; r < component_list_len; r++) {
77 Free(component_list[r].host_or_group);
78 Free(component_list[r].component);
79 }
80 Free(component_list);
81 component_list = NULL;
82 component_list_len = 0;
83
84 Free(local_addr);
85 local_addr = NULL;
86
87 tcp_listen_port = 0;
88 num_hcs = -1;
89 kill_timer = 10.0;
90 unix_sockets_enabled =
91 #ifdef WIN32
92 false // Unix domain socket communication on Cygwin is painfully slow
93 #else
94 true
95 #endif
96 ;
97 }
This page took 0.055316 seconds and 5 git commands to generate.