Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
rmain.cxx
Go to the documentation of this file.
1// @(#)root/main:$Id$
2// Author: Fons Rademakers 02/03/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// RMain //
15// //
16// Main program used to create RINT application. //
17// //
18//////////////////////////////////////////////////////////////////////////
19
20#include "TRint.h"
21#include "RConfigure.h"
22#include "snprintf.h"
23#ifdef _MSC_VER
24#include <process.h>
25#define execv _execv
26#else
27#include <unistd.h>
28#endif
29
30#define ROOTNBBINARY "rootnb.exe"
31
32void handle_notebook_option(int argc, char **argv)
33{
34 char **argvv;
35 char arg0[kMAXPATHLEN];
36 int notebook = 0; // index of --notebook args, all other args will be re-directed to nbmain
37 int i;
38 for (i = 1; i < argc; i++) {
39 if (!strcmp(argv[i], "--notebook")) { notebook = i; break; }
40 }
41 if (notebook > 0) {
42 // Build command
43#ifdef ROOTBINDIR
44 if (std::getenv("ROOTIGNOREPREFIX"))
45#endif
46 snprintf(arg0, sizeof(arg0), "%s/bin/%s", std::getenv("ROOTSYS"), ROOTNBBINARY);
47#ifdef ROOTBINDIR
48 else
49 snprintf(arg0, sizeof(arg0), "%s/%s", ROOTBINDIR, ROOTNBBINARY);
50#endif
51
52 int numnbargs = 1 + (argc - notebook);
53
54 argvv = new char* [numnbargs+1];
55 argvv[0] = arg0;
56 for (i = 1; i < numnbargs; i++)
57 argvv[i] = argv[notebook + i];
58 argvv[numnbargs] = nullptr;
59
60 // Execute ROOT notebook binary
61 execv(arg0, argvv);
62
63 // Exec failed
64 fprintf(stderr, "%s: can't start ROOT notebook -- this option is only available when building with CMake, please check that %s exists\n",
65 argv[0], arg0);
66
67 delete [] argvv;
68
69 exit(1);
70 }
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Create an interactive ROOT application
75
76int main(int argc, char **argv)
77{
78 handle_notebook_option(argc, argv);
79
80 TRint *theApp = new TRint("Rint", &argc, argv, /*options*/ nullptr, /*numOptions*/ 0, /*noLogo*/ kFALSE,
81 /*exitOnUnknownArgs*/ kTRUE);
82
83 // and enter the event loop...
84 theApp->Run();
85
86 delete theApp;
87
88 return 0;
89}
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kMAXPATHLEN
Definition Rtypes.h:61
#define snprintf
Definition civetweb.c:1579
Definition TRint.h:31
void Run(Bool_t retrn=kFALSE) override
Main application eventloop.
Definition TRint.cxx:388
int main()
#define ROOTNBBINARY
Definition rmain.cxx:30
void handle_notebook_option(int argc, char **argv)
Definition rmain.cxx:32