Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:16

0001 #include <cstdlib>
0002 #include <cstdio>
0003 #include <cstring>
0004 #include <csignal>
0005 
0006 #include "OPTICKS_LOG.hh"
0007 
0008 /**
0009 SEnvTest
0010 =========
0011 
0012 Dump envvars matching the prefix, or all when no prefix.
0013 Used for checking "fabricated" ctest, ie ctest without its own 
0014 executable, but instead with its own environment. 
0015 
0016 **/
0017 
0018 int main(int argc, char** argv, char** envp)
0019 {
0020     OPTICKS_LOG(argc, argv) ;
0021 
0022     const char* prefix = argc > 1 ? argv[1] : NULL ; 
0023 
0024     LOG(debug) << " prefix " << ( prefix ? prefix : "NONE" ); 
0025 
0026     while(*envp)
0027     {
0028         if(prefix != NULL && strncmp(*envp, prefix, strlen(prefix)) == 0) 
0029         { 
0030             LOG(info) << *envp ;  
0031         } 
0032         envp++ ; 
0033     }
0034 
0035    
0036     const char* vars = R"(
0037 HOME
0038 USER
0039 BASH_SOURCE
0040 SCRIPT
0041 PWD
0042 GEOM
0043 )" ; 
0044  
0045     std::stringstream ss;  
0046     ss.str(vars)  ;
0047     std::string s;
0048     while (std::getline(ss, s, '\n')) 
0049     {   
0050         if(s.empty()) continue ; 
0051         const char* k = s.c_str(); 
0052         const char* v = getenv(k) ; 
0053         std::cout 
0054             << std::setw(20) << k 
0055             << " : " 
0056             << ( v ? v : "-" )
0057             << std::endl 
0058             ; 
0059     }
0060 
0061 
0062     std::raise(SIGINT); // hari kari : for ctest debugging  
0063 
0064     return 0 ; 
0065 }