1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
24f645668Schristos Contributed by Oracle.
34f645668Schristos
44f645668Schristos This file is part of GNU Binutils.
54f645668Schristos
64f645668Schristos This program is free software; you can redistribute it and/or modify
74f645668Schristos it under the terms of the GNU General Public License as published by
84f645668Schristos the Free Software Foundation; either version 3, or (at your option)
94f645668Schristos any later version.
104f645668Schristos
114f645668Schristos This program is distributed in the hope that it will be useful,
124f645668Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
134f645668Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144f645668Schristos GNU General Public License for more details.
154f645668Schristos
164f645668Schristos You should have received a copy of the GNU General Public License
174f645668Schristos along with this program; if not, write to the Free Software
184f645668Schristos Foundation, 51 Franklin Street - Fifth Floor, Boston,
194f645668Schristos MA 02110-1301, USA. */
204f645668Schristos
214f645668Schristos #include "config.h"
224f645668Schristos #include <stdio.h>
234f645668Schristos #include <stdlib.h>
244f645668Schristos #include <strings.h>
254f645668Schristos
264f645668Schristos #include "DbeSession.h"
274f645668Schristos #include "DbeApplication.h"
284f645668Schristos #include "LoadObject.h"
294f645668Schristos #include "Experiment.h"
304f645668Schristos #include "PreviewExp.h"
314f645668Schristos #include "Function.h"
324f645668Schristos #include "Hist_data.h"
334f645668Schristos #include "Module.h"
344f645668Schristos #include "DataObject.h"
354f645668Schristos #include "Sample.h"
364f645668Schristos #include "CallStack.h"
374f645668Schristos #include "Print.h"
384f645668Schristos #include "util.h"
394f645668Schristos #include "libgen.h"
404f645668Schristos #include "i18n.h"
414f645668Schristos
424f645668Schristos DbeApplication *theDbeApplication;
434f645668Schristos
DbeApplication(int argc,char * argv[],char * _run_dir)444f645668Schristos DbeApplication::DbeApplication (int argc, char *argv[], char* _run_dir)
454f645668Schristos : Application (argc, argv, _run_dir)
464f645668Schristos {
474f645668Schristos theDbeApplication = this;
484f645668Schristos ipcMode = false;
494f645668Schristos rdtMode = false;
504f645668Schristos if (argc > 1)
514f645668Schristos if (strcmp (argv[1], NTXT ("-IPC")) == 0
524f645668Schristos || strcmp (argv[1], NTXT ("-DIPC")) == 0)
534f645668Schristos ipcMode = true;
544f645668Schristos lic_found = 0;
554f645668Schristos lic_err = NULL;
564f645668Schristos
574f645668Schristos // Instantiate a session
584f645668Schristos (void) new DbeSession (settings, ipcMode, rdtMode);
594f645668Schristos }
604f645668Schristos
~DbeApplication()614f645668Schristos DbeApplication::~DbeApplication ()
624f645668Schristos {
634f645668Schristos delete dbeSession;
644f645668Schristos theDbeApplication = NULL;
654f645668Schristos }
664f645668Schristos
674f645668Schristos Vector<char*> *
initApplication(char * fdhome,char * licpath,ProgressFunc func)684f645668Schristos DbeApplication::initApplication (char *fdhome, char *licpath, ProgressFunc func)
694f645668Schristos {
704f645668Schristos // set the home directory
714f645668Schristos if (fdhome != NULL)
724f645668Schristos set_run_dir (fdhome);
734f645668Schristos
744f645668Schristos // Set progress function
754f645668Schristos set_progress_func (func);
764f645668Schristos
774f645668Schristos // Get license
784f645668Schristos char *license_err = NULL;
794f645668Schristos char *sts;
804f645668Schristos if (licpath != NULL)
814f645668Schristos {
824f645668Schristos lic_found = 0;
834f645668Schristos if (lic_found == 0)
844f645668Schristos {
854f645668Schristos lic_err = dbe_strdup (DbeApplication::get_version ());
864f645668Schristos sts = dbe_strdup (GTXT ("OK"));
874f645668Schristos }
884f645668Schristos else if (lic_found == 2)
894f645668Schristos {
904f645668Schristos lic_err = dbe_strdup (license_err);
914f645668Schristos sts = dbe_strdup (GTXT ("WARN"));
924f645668Schristos }
934f645668Schristos else if (lic_found == 3)
944f645668Schristos {
954f645668Schristos lic_err = dbe_strdup (license_err);
964f645668Schristos sts = dbe_strdup (GTXT ("FATAL"));
974f645668Schristos }
984f645668Schristos else
994f645668Schristos {
1004f645668Schristos lic_err = dbe_strdup (license_err);
1014f645668Schristos sts = dbe_strdup (GTXT ("ERROR"));
1024f645668Schristos }
1034f645668Schristos }
1044f645668Schristos else
1054f645668Schristos {
1064f645668Schristos lic_err = dbe_strdup (DbeApplication::get_version ());
1074f645668Schristos sts = dbe_strdup (GTXT ("OK"));
1084f645668Schristos }
1094f645668Schristos Vector<char*> *data = new Vector<char*>(2);
1104f645668Schristos data->store (0, sts);
1114f645668Schristos data->store (1, lic_err);
1124f645668Schristos return data;
1134f645668Schristos }
114