File: config_data.cc

package info (click to toggle)
eclipse-titan 8.2.0-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 103,544 kB
  • sloc: cpp: 271,008; ansic: 33,683; yacc: 23,419; makefile: 15,483; lex: 9,204; java: 4,848; perl: 4,555; sh: 2,242; xml: 1,378; javascript: 85; awk: 48; php: 32; python: 13
file content (97 lines) | stat: -rw-r--r-- 2,830 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/******************************************************************************
 * Copyright (c) 2000-2021 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Kovacs, Ferenc
 *   Raduly, Csaba
 *
 ******************************************************************************/
#include "config_data.h"
#include "../../common/memory.h"

void config_data::add_host(char *group_name, char *host_name)
{
  group_list = (group_item*)Realloc(group_list,
    ++group_list_len * sizeof(group_item));
  // We take copies because the same group_name pointer may be supplied
  // more than once (group:host is a one-to-many relationship).
  // This would result in double-free.
  // Copying the host_name is not strictly necessary; done for symmetry.
  group_list[group_list_len-1].group_name = mcopystr(group_name);
  // We need NULL here, not empty string.
  group_list[group_list_len-1].host_name  = host_name ? mcopystr(host_name) : NULL;
}

void config_data::add_component(char *host_or_grp, char *comp)
{
  component_list = (component_item*)Realloc(component_list,
    ++component_list_len * sizeof(component_item));
  component_list[component_list_len-1].host_or_group = host_or_grp;
  component_list[component_list_len-1].component     = comp;
}

void config_data::add_exec(const execute_list_item& exec_item)
{
  execute_list = (execute_list_item *)Realloc(execute_list,
    (execute_list_len + 1) * sizeof(*execute_list));
  execute_list[execute_list_len++] = exec_item;
}

void config_data::set_log_file(char *f)
{
  if (log_file_name != NULL)
	Free(log_file_name);
  log_file_name = f;
}

void config_data::clear()
{
  Free(config_read_buffer);
  config_read_buffer = NULL;

  Free(log_file_name);
  log_file_name = NULL;

  for(int r = 0; r < execute_list_len; r++) {
    Free(execute_list[r].module_name);
    Free(execute_list[r].testcase_name);
  }
  Free(execute_list);
  execute_list = NULL;
  execute_list_len = 0;

  for(int r = 0; r < group_list_len; r++) {
    Free(group_list[r].group_name);
    Free(group_list[r].host_name);
  }
  Free(group_list);
  group_list = NULL;
  group_list_len = 0;

  for(int r = 0; r < component_list_len; r++) {
    Free(component_list[r].host_or_group);
    Free(component_list[r].component);
  }
  Free(component_list);
  component_list = NULL;
  component_list_len = 0;

  Free(local_addr);
  local_addr = NULL;

  tcp_listen_port = 0;
  num_hcs = -1;
  kill_timer = 10.0;
  unix_sockets_enabled =
#ifdef WIN32
  false // Unix domain socket communication on Cygwin is painfully slow
#else
  true
#endif
  ;
}