mirror of
https://github.com/nasa/trick.git
synced 2024-12-22 06:27:49 +00:00
19025d77ad
Reorganized. Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory. Created a libexec directory that holds all of the executables that users don't need to execute directly. Changed all of the executables remaining in bin to start with "trick-". In the sim_services directories changed all source files to find the Trick headers in their new location. Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level. Moved the makefiles, docs, man, and other architecture independent files into a top level share directory. Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on. refs #63
71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
|
|
#include <string.h>
|
|
#include <sstream>
|
|
|
|
#include "trick/MessageLCout.hh"
|
|
|
|
Trick::MessageLCout::MessageLCout() {
|
|
enabled = 1 ;
|
|
subs['a'] = "4" ;
|
|
subs['e'] = "3" ;
|
|
subs['f'] = "ph" ;
|
|
subs['g'] = "9" ;
|
|
subs['l'] = "1" ;
|
|
subs['o'] = "0" ;
|
|
subs['s'] = "5" ;
|
|
subs['t'] = "7" ;
|
|
|
|
seed = 0 ;
|
|
|
|
name = "lcout" ;
|
|
}
|
|
|
|
void Trick::MessageLCout::update( unsigned int level , std::string header , std::string message ) {
|
|
if (!enabled) {
|
|
return;
|
|
}
|
|
if ( level == 1337 ) {
|
|
std::string in_string ;
|
|
std::string temp_string ;
|
|
unsigned int ii , jj ;
|
|
|
|
in_string = header + message ;
|
|
|
|
for ( ii = 0 ; ii < in_string.size() ; ii++ ) {
|
|
seed += in_string[ii] * ii ;
|
|
}
|
|
srandom(seed) ;
|
|
for ( ii = 0 ; ii < in_string.size() ; ii++ ) {
|
|
if ( random() < RAND_MAX * 0.3 ) {
|
|
if ( subs.find((char)tolower(in_string[ii])) != subs.end()) {
|
|
//temp_string += subs[(char)tolower(in_string[ii])] ;
|
|
std::string replace_str = subs[(char)tolower(in_string[ii])] ;
|
|
for ( jj = 0 ; jj < replace_str.size() ; jj++ ) {
|
|
if ( random() < RAND_MAX * 0.5 ) {
|
|
temp_string += toupper(replace_str[jj]) ;
|
|
} else {
|
|
temp_string += tolower(replace_str[jj]) ;
|
|
}
|
|
}
|
|
} else {
|
|
temp_string += in_string[ii] ;
|
|
}
|
|
} else {
|
|
if ( random() < RAND_MAX * 0.3 ) {
|
|
temp_string += toupper(in_string[ii]) ;
|
|
} else {
|
|
temp_string += tolower(in_string[ii]) ;
|
|
}
|
|
}
|
|
}
|
|
std::cout << temp_string << std::flush ;
|
|
} else if ( level < 100 ) {
|
|
// Building the final string in a temporary stream ensures an automic call to cout, which prevents
|
|
// multithreaded sims from interleaving header and message elements.
|
|
std::ostringstream oss;
|
|
oss << header << message ;
|
|
std::cout << oss.str() << std::flush ;
|
|
}
|
|
}
|
|
|