aboutsummaryrefslogtreecommitdiff
path: root/gprofng/src/DbeApplication.cc
blob: b659a0fa0f770ccdf99e140e0ba97e678115d446 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* Copyright (C) 2021-2023 Free Software Foundation, Inc.
   Contributed by Oracle.

   This file is part of GNU Binutils.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */

#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#include "DbeSession.h"
#include "DbeApplication.h"
#include "LoadObject.h"
#include "Experiment.h"
#include "PreviewExp.h"
#include "Function.h"
#include "Hist_data.h"
#include "Module.h"
#include "DataObject.h"
#include "Sample.h"
#include "CallStack.h"
#include "Print.h"
#include "util.h"
#include "libgen.h"
#include "i18n.h"

DbeApplication *theDbeApplication;

DbeApplication::DbeApplication (int argc, char *argv[], char* _run_dir)
: Application (argc, argv, _run_dir)
{
  theDbeApplication = this;
  ipcMode = false;
  rdtMode = false;
  if (argc > 1)
    if (strcmp (argv[1], NTXT ("-IPC")) == 0
	|| strcmp (argv[1], NTXT ("-DIPC")) == 0)
      ipcMode = true;
  lic_found = 0;
  lic_err = NULL;

  // Instantiate a session
  (void) new DbeSession (settings, ipcMode, rdtMode);
}

DbeApplication::~DbeApplication ()
{
  delete dbeSession;
  theDbeApplication = NULL;
}

Vector<char*> *
DbeApplication::initApplication (char *fdhome, char *licpath, ProgressFunc func)
{
  // set the home directory
  if (fdhome != NULL)
    set_run_dir (fdhome);

  // Set progress function
  set_progress_func (func);

  // Get license
  char *license_err = NULL;
  char *sts;
  if (licpath != NULL)
    {
      lic_found = 0;
      if (lic_found == 0)
	{
	  lic_err = dbe_strdup (DbeApplication::get_version ());
	  sts = dbe_strdup (GTXT ("OK"));
	}
      else if (lic_found == 2)
	{
	  lic_err = dbe_strdup (license_err);
	  sts = dbe_strdup (GTXT ("WARN"));
	}
      else if (lic_found == 3)
	{
	  lic_err = dbe_strdup (license_err);
	  sts = dbe_strdup (GTXT ("FATAL"));
	}
      else
	{
	  lic_err = dbe_strdup (license_err);
	  sts = dbe_strdup (GTXT ("ERROR"));
	}
    }
  else
    {
      lic_err = dbe_strdup (DbeApplication::get_version ());
      sts = dbe_strdup (GTXT ("OK"));
    }
  Vector<char*> *data = new Vector<char*>(2);
  data->store (0, sts);
  data->store (1, lic_err);
  return data;
}