10 #include "TPluginManager.h" 20 #define ut_user ut_name 23 #define UTMP_FILE "/etc/utmp" 29 #define STRUCT_UTMP struct utmpx 31 #if defined(__linux) && defined(__powerpc) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 90) 35 #define STRUCT_UTMP struct utmp 52 int hour =
static_cast<int>(realTime / 3600);
53 realTime -= hour * 3600;
54 int min =
static_cast<int>(realTime / 60);
57 <<
"bye,bye\t"<<
DCYAN<<getpwuid(getuid())->pw_name<<
RESET_COLOR<<
" after "<<hour<<
":" 58 <<std::setfill(
'0')<<std::setw(2)<<min<<
":"<<std::setprecision(3)<<std::fixed<<realTime
59 <<
" h:m:s"<<std::endl;
68 TThread::Initialize();
69 TObject::SetObjectStat(
false);
79 input->SetReturnFromRun(
true);
83 std::cerr<<e.
message<<std::endl;
85 }
catch(std::runtime_error& e) {
86 std::cerr<<e.what()<<std::endl;
87 std::cout<<
"Don't know how to handle this error, exiting "<<
argv[0]<<
"!"<<std::endl;
95 std::string grsi_path = getenv(
"GRSISYS");
96 if(grsi_path.length() > 0) {
100 grsi_path +=
".grsirc";
101 gEnv->ReadFile(grsi_path.c_str(), kEnvChange);
107 gPluginMgr->AddHandler(
"TGuiFactory",
"root",
"GROOTGuiFactory",
"Gui",
"GROOTGuiFactory()");
108 gPluginMgr->AddHandler(
"TBrowserImp",
"GRootBrowser",
"GRootBrowser",
"Gui",
109 "NewBrowser(TBrowser *,const char *,Int_t,Int_t,UInt_t,UInt_t");
110 gPluginMgr->AddHandler(
"TBrowserImp",
"GRootBrowser",
"GRootBrowser",
"Gui",
111 "NewBrowser(TBrowser *,const char *,Int_t,Int_t");
117 struct stat file_stats;
122 utmp = fopen(UTMP_FILE,
"r");
123 if(utmp ==
nullptr) {
127 fstat(fileno(utmp), &file_stats);
128 size = file_stats.st_size;
141 if(ferror(utmp) == 0) {
142 if(fclose(utmp) != EOF && n_read == size) {
158 if((ue->ut_name[0] != 0) && (strncmp(tty, ue->ut_line,
sizeof(ue->ut_line)) == 0)) {
170 if(getenv(
"DISPLAY") ==
nullptr) {
171 char* tty = ttyname(0);
175 if(utmp_entry !=
nullptr) {
176 size_t length =
sizeof(utmp_entry->ut_host);
177 auto* display =
new char[length + 15];
178 auto* host =
new char[length + 1];
179 strncpy(host, utmp_entry->ut_host, length);
180 host[
sizeof(utmp_entry->ut_host)] = 0;
182 if(strchr(host,
':') !=
nullptr) {
183 sprintf(display,
"DISPLAY=%s", host);
184 fprintf(stderr,
"*** DISPLAY not set, setting it to %s\n", host);
186 sprintf(display,
"DISPLAY=%s:0.0", host);
187 fprintf(stderr,
"*** DISPLAY not set, setting it to %s:0.0\n", host);
191 }
else if(utmp_entry->ut_addr != 0) {
193 if((he = gethostbyaddr(reinterpret_cast<const char*>(&utmp_entry->ut_addr),
sizeof(utmp_entry->ut_addr),
194 AF_INET)) !=
nullptr) {
195 sprintf(display,
"DISPLAY=%s:0.0", he->h_name);
196 fprintf(stderr,
"*** DISPLAY not set, setting it to %s:0.0\n", he->h_name);
static STRUCT_UTMP * SearchEntry(int, const char *)
int main(int argc, char **argv)
static TGRSIint * instance(int argc=0, char **argv=nullptr, void *options=nullptr, int numOptions=-1, bool noLogo=false, const char *appClassName="grsisort")
static STRUCT_UTMP * gUtmpContents
void SetGRSIPluginHandlers()