Sync with 5.3.0
[deliverable/titan.core.git] / mctr2 / mctr / config_data.cc
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 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 #include "config_data.h"
9 #include "../../common/memory.h"
10
11 void config_data::add_host(char *group_name, char *host_name)
12 {
13 group_list = (group_item*)Realloc(group_list,
14 ++group_list_len * sizeof(group_item));
15 // We take copies because the same group_name pointer may be supplied
16 // more than once (group:host is a one-to-many relationship).
17 // This would result in double-free.
18 // Copying the host_name is not strictly necessary; done for symmetry.
19 group_list[group_list_len-1].group_name = mcopystr(group_name);
20 // We need NULL here, not empty string.
21 group_list[group_list_len-1].host_name = host_name ? mcopystr(host_name) : NULL;
22 }
23
24 void config_data::add_component(char *host_or_grp, char *comp)
25 {
26 component_list = (component_item*)Realloc(component_list,
27 ++component_list_len * sizeof(component_item));
28 component_list[component_list_len-1].host_or_group = host_or_grp;
29 component_list[component_list_len-1].component = comp;
30 }
31
32 void config_data::add_exec(const execute_list_item& exec_item)
33 {
34 execute_list = (execute_list_item *)Realloc(execute_list,
35 (execute_list_len + 1) * sizeof(*execute_list));
36 execute_list[execute_list_len++] = exec_item;
37 }
38
39 void config_data::set_log_file(char *f)
40 {
41 if (log_file_name != NULL)
42 Free(log_file_name);
43 log_file_name = f;
44 }
45
46 void config_data::clear()
47 {
48 Free(config_read_buffer);
49 config_read_buffer = NULL;
50
51 Free(log_file_name);
52 log_file_name = NULL;
53
54 for(int r = 0; r < execute_list_len; r++) {
55 Free(execute_list[r].module_name);
56 Free(execute_list[r].testcase_name);
57 }
58 Free(execute_list);
59 execute_list = NULL;
60 execute_list_len = 0;
61
62 for(int r = 0; r < group_list_len; r++) {
63 Free(group_list[r].group_name);
64 Free(group_list[r].host_name);
65 }
66 Free(group_list);
67 group_list = NULL;
68 group_list_len = 0;
69
70 for(int r = 0; r < component_list_len; r++) {
71 Free(component_list[r].host_or_group);
72 Free(component_list[r].component);
73 }
74 Free(component_list);
75 component_list = NULL;
76 component_list_len = 0;
77
78 Free(local_addr);
79 local_addr = NULL;
80
81 tcp_listen_port = 0;
82 num_hcs = -1;
83 kill_timer = 10.0;
84 unix_sockets_enabled =
85 #ifdef WIN32
86 false // Unix domain socket communication on Cygwin is painfully slow
87 #else
88 true
89 #endif
90 ;
91 }
This page took 0.091089 seconds and 5 git commands to generate.