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