1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
2 Contributed by Oracle.
3
4 This file is part of GNU Binutils.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
20
21 #include "config.h"
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <strings.h>
25
26 #include "DbeSession.h"
27 #include "DbeApplication.h"
28 #include "LoadObject.h"
29 #include "Experiment.h"
30 #include "PreviewExp.h"
31 #include "Function.h"
32 #include "Hist_data.h"
33 #include "Module.h"
34 #include "DataObject.h"
35 #include "Sample.h"
36 #include "CallStack.h"
37 #include "Print.h"
38 #include "util.h"
39 #include "libgen.h"
40 #include "i18n.h"
41
42 DbeApplication *theDbeApplication;
43
DbeApplication(int argc,char * argv[],char * _run_dir)44 DbeApplication::DbeApplication (int argc, char *argv[], char* _run_dir)
45 : Application (argc, argv, _run_dir)
46 {
47 theDbeApplication = this;
48 ipcMode = false;
49 rdtMode = false;
50 if (argc > 1)
51 if (strcmp (argv[1], NTXT ("-IPC")) == 0
52 || strcmp (argv[1], NTXT ("-DIPC")) == 0)
53 ipcMode = true;
54 lic_found = 0;
55 lic_err = NULL;
56
57 // Instantiate a session
58 (void) new DbeSession (settings, ipcMode, rdtMode);
59 }
60
~DbeApplication()61 DbeApplication::~DbeApplication ()
62 {
63 delete dbeSession;
64 theDbeApplication = NULL;
65 }
66
67 Vector<char*> *
initApplication(char * fdhome,char * licpath,ProgressFunc func)68 DbeApplication::initApplication (char *fdhome, char *licpath, ProgressFunc func)
69 {
70 // set the home directory
71 if (fdhome != NULL)
72 set_run_dir (fdhome);
73
74 // Set progress function
75 set_progress_func (func);
76
77 // Get license
78 char *license_err = NULL;
79 char *sts;
80 if (licpath != NULL)
81 {
82 lic_found = 0;
83 if (lic_found == 0)
84 {
85 lic_err = dbe_strdup (DbeApplication::get_version ());
86 sts = dbe_strdup (GTXT ("OK"));
87 }
88 else if (lic_found == 2)
89 {
90 lic_err = dbe_strdup (license_err);
91 sts = dbe_strdup (GTXT ("WARN"));
92 }
93 else if (lic_found == 3)
94 {
95 lic_err = dbe_strdup (license_err);
96 sts = dbe_strdup (GTXT ("FATAL"));
97 }
98 else
99 {
100 lic_err = dbe_strdup (license_err);
101 sts = dbe_strdup (GTXT ("ERROR"));
102 }
103 }
104 else
105 {
106 lic_err = dbe_strdup (DbeApplication::get_version ());
107 sts = dbe_strdup (GTXT ("OK"));
108 }
109 Vector<char*> *data = new Vector<char*>(2);
110 data->store (0, sts);
111 data->store (1, lic_err);
112 return data;
113 }
114