mirror of
https://github.com/nasa/trick.git
synced 2025-01-18 02:40:08 +00:00
parent
e86027f825
commit
21c01a5454
@ -126,7 +126,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
so much easier in perl! */
|
so much easier in perl! */
|
||||||
|
|
||||||
/* find the ICG field */
|
/* find the ICG field */
|
||||||
ret = regcomp( ®_expr , "(ICG:)" , REG_EXTENDED | REG_ICASE ) ;
|
regcomp( ®_expr , "(ICG:)" , REG_EXTENDED | REG_ICASE ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
@ -136,7 +136,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
|
|
||||||
/* find the end of the ICG field */
|
/* find the end of the ICG field */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(\\))" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(\\))" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
|
|
||||||
/* test for NoComment */
|
/* test for NoComment */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(NOCOMMENT)$" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(NOCOMMENT)$" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
|
|
||||||
/* test for No */
|
/* test for No */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(NO)$" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(NO)$" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
|||||||
start += strlen("trick_exclude_typename") ;
|
start += strlen("trick_exclude_typename") ;
|
||||||
std::string temp_str = th_str.substr(start) ;
|
std::string temp_str = th_str.substr(start) ;
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "^\\s*\\{\\s*(\\S+)\\s*\\}" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "^\\s*\\{\\s*(\\S+)\\s*\\}" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , temp_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , temp_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret == 0 ) {
|
if ( ret == 0 ) {
|
||||||
@ -230,7 +230,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
|||||||
so much easier in perl! */
|
so much easier in perl! */
|
||||||
|
|
||||||
/* find the start of the ICG_IGNORE_TYPES field */
|
/* find the start of the ICG_IGNORE_TYPES field */
|
||||||
ret = regcomp( ®_expr , "(ICG[ _]IGNORE[ _]TYPE(S)?:)" , REG_EXTENDED | REG_ICASE ) ;
|
regcomp( ®_expr , "(ICG[ _]IGNORE[ _]TYPE(S)?:)" , REG_EXTENDED | REG_ICASE ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
@ -240,7 +240,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
|||||||
|
|
||||||
/* find the end of the ICG_IGNORE_TYPES field */
|
/* find the end of the ICG_IGNORE_TYPES field */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(\\)\\s*\\))" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(\\)\\s*\\))" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "trick/map_trick_units_to_udunits.hh"
|
#include "trick/map_trick_units_to_udunits.hh"
|
||||||
|
|
||||||
extern llvm::cl::opt< bool > units_truth_is_scary ;
|
extern llvm::cl::opt< bool > units_truth_is_scary ;
|
||||||
|
extern llvm::cl::opt< int > debug_level ;
|
||||||
|
|
||||||
static ut_system * get_u_system() {
|
static ut_system * get_u_system() {
|
||||||
|
|
||||||
@ -85,20 +86,18 @@ std::string FieldDescription::get_regex_field(std::string input , const char * e
|
|||||||
regex_t reg_expr ;
|
regex_t reg_expr ;
|
||||||
regmatch_t pmatch[10] ;
|
regmatch_t pmatch[10] ;
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , expr , REG_EXTENDED ) ;
|
regcomp( ®_expr , expr , REG_EXTENDED ) ;
|
||||||
//std::cout << "regcomp ret = " << ret << std::endl ;
|
|
||||||
ret = regexec( ®_expr , input.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , input.c_str() , 10 , pmatch , 0 ) ;
|
||||||
//std::cout << "regexec ret = " << ret << std::endl ;
|
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret == 0 ) {
|
if ( ret == 0 ) {
|
||||||
//std::cout << "pmatch range = " << pmatch[index].rm_so << " " << pmatch[index].rm_eo << std::endl ;
|
if(debug_level >= 4) std::cout << "pmatch range = " << pmatch[index].rm_so << " " << pmatch[index].rm_eo << std::endl ;
|
||||||
if ( pmatch[index].rm_so != -1 ) {
|
if ( pmatch[index].rm_so != -1 ) {
|
||||||
return input.substr(pmatch[index].rm_so , pmatch[index].rm_eo - pmatch[index].rm_so ) ;
|
return input.substr(pmatch[index].rm_so , pmatch[index].rm_eo - pmatch[index].rm_so ) ;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (debug_level >= 4){
|
||||||
//char error_msg[1024] ;
|
char error_msg[1024] ;
|
||||||
//regerror( ret , ®_expr , (char *)error_msg , 1024 ) ;
|
regerror( ret , ®_expr , (char *)error_msg , 1024 ) ;
|
||||||
//std::cerr << error_msg << std::endl ;
|
std::cerr << error_msg << std::endl ;
|
||||||
}
|
}
|
||||||
return std::string() ;
|
return std::string() ;
|
||||||
}
|
}
|
||||||
@ -127,21 +126,21 @@ void FieldDescription::parseComment(std::string comment) {
|
|||||||
|
|
||||||
// remove open comment chars
|
// remove open comment chars
|
||||||
comment = get_regex_field(comment , "^(//|/\\*)(.*)" , 2) ;
|
comment = get_regex_field(comment , "^(//|/\\*)(.*)" , 2) ;
|
||||||
//std::cout << "1. " << comment << std::endl ;
|
if(debug_level >= 4) std::cout << "1. " << comment << std::endl ;
|
||||||
|
|
||||||
// remove optional doxygen comment chars
|
// remove optional doxygen comment chars
|
||||||
// Note: I had to use [ \t\n\r] for \s because the Mac don't understand!
|
// Note: I had to use [ \t\n\r] for \s because the Mac don't understand!
|
||||||
comment = get_regex_field(comment , "^((\\*|!)<)?[ \t\n\r]*(.*)" , 3) ;
|
comment = get_regex_field(comment , "^((\\*|!)<)?[ \t\n\r]*(.*)" , 3) ;
|
||||||
//std::cout << "2. " << comment << std::endl ;
|
if(debug_level >= 4) std::cout << "2. " << comment << std::endl ;
|
||||||
|
|
||||||
// remove optional doxygen keyword
|
// remove optional doxygen keyword
|
||||||
comment = get_regex_field(comment , "(\\\\[a-zA-Z0-9]+)?[ \t\n\r]*(.*)" , 2) ;
|
comment = get_regex_field(comment , "(\\\\[a-zA-Z0-9]+)?[ \t\n\r]*(.*)" , 2) ;
|
||||||
//std::cout << "3. " << comment << std::endl ;
|
if(debug_level >= 4) std::cout << "3. " << comment << std::endl ;
|
||||||
|
|
||||||
ret_str = get_regex_field(comment , "@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}]" , 1) ;
|
ret_str = get_regex_field(comment , "@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}]" , 1) ;
|
||||||
if ( ! ret_str.empty()) {
|
if ( ! ret_str.empty()) {
|
||||||
chkpnt_io = io_map[ret_str] ;
|
chkpnt_io = io_map[ret_str] ;
|
||||||
//std::cout << "go for trick_chkpnt_io " << io << std::endl ;
|
if(debug_level >= 4) std::cout << "go for trick_chkpnt_io " << io << std::endl ;
|
||||||
chkpnt_io_found = true ;
|
chkpnt_io_found = true ;
|
||||||
comment = get_regex_field(comment , "(.*)@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}]" , 1) +
|
comment = get_regex_field(comment , "(.*)@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}]" , 1) +
|
||||||
get_regex_field(comment , "@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}](.*)" , 2) ;
|
get_regex_field(comment , "@?trick_chkpnt_io[\\({]([^\\)}]+)[\\)}](.*)" , 2) ;
|
||||||
@ -150,7 +149,7 @@ void FieldDescription::parseComment(std::string comment) {
|
|||||||
ret_str = get_regex_field(comment , "@?trick_io[\\({]([^\\)}]+)[\\)}]" , 1) ;
|
ret_str = get_regex_field(comment , "@?trick_io[\\({]([^\\)}]+)[\\)}]" , 1) ;
|
||||||
if ( ! ret_str.empty()) {
|
if ( ! ret_str.empty()) {
|
||||||
io = io_map[ret_str] ;
|
io = io_map[ret_str] ;
|
||||||
//std::cout << "go for trick_io " << io << std::endl ;
|
if(debug_level >= 4) std::cout << "go for trick_io " << io << std::endl ;
|
||||||
io_found = true ;
|
io_found = true ;
|
||||||
comment = get_regex_field(comment , "(.*)@?trick_io[\\({]([^\\)}]+)[\\)}]" , 1) +
|
comment = get_regex_field(comment , "(.*)@?trick_io[\\({]([^\\)}]+)[\\)}]" , 1) +
|
||||||
get_regex_field(comment , "@?trick_io[\\({]([^\\)}]+)[\\)}](.*)" , 2) ;
|
get_regex_field(comment , "@?trick_io[\\({]([^\\)}]+)[\\)}](.*)" , 2) ;
|
||||||
@ -200,28 +199,28 @@ void FieldDescription::parseComment(std::string comment) {
|
|||||||
if ( ! io_found ) {
|
if ( ! io_found ) {
|
||||||
// Note: I had to use [ \t\n\r] for \s because the Mac don't understand!
|
// Note: I had to use [ \t\n\r] for \s because the Mac don't understand!
|
||||||
ret_str = get_regex_field(comment , "^[ \t\n\r]*(\\*io|\\*oi|\\*i|\\*o|\\*\\*)" , 1) ;
|
ret_str = get_regex_field(comment , "^[ \t\n\r]*(\\*io|\\*oi|\\*i|\\*o|\\*\\*)" , 1) ;
|
||||||
//std::cout << "3. " << ret_str << std::endl ;
|
if(debug_level >= 4) std::cout << "3. " << ret_str << std::endl ;
|
||||||
if ( ! ret_str.empty()) {
|
if ( ! ret_str.empty()) {
|
||||||
io = io_map[ret_str] ;
|
io = io_map[ret_str] ;
|
||||||
//std::cout << "stand-alone io " << io << std::endl ;
|
if(debug_level >= 4) std::cout << "stand-alone io " << io << std::endl ;
|
||||||
io_found = true ;
|
io_found = true ;
|
||||||
comment = get_regex_field(comment , "^[ \t\n\r]*(\\*io|\\*oi|\\*i|\\*o|\\*\\*)[ \t\n\r]*(.*)" , 2) ;
|
comment = get_regex_field(comment , "^[ \t\n\r]*(\\*io|\\*oi|\\*i|\\*o|\\*\\*)[ \t\n\r]*(.*)" , 2) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::cout << "3. " << comment << std::endl ;
|
if(debug_level >= 4) std::cout << "3. " << comment << std::endl ;
|
||||||
if ( ! units_found ) {
|
if ( ! units_found ) {
|
||||||
ret_str = get_regex_field(comment , "^[ \t\n\r]*\\(([^\\)]*)\\)" , 1) ;
|
ret_str = get_regex_field(comment , "^[ \t\n\r]*\\(([^\\)]*)\\)" , 1) ;
|
||||||
if ( ! ret_str.empty()) {
|
if ( ! ret_str.empty()) {
|
||||||
units = ret_str ;
|
units = ret_str ;
|
||||||
//std::cout << "stand-alone units " << units << std::endl ;
|
if(debug_level >= 4) std::cout << "stand-alone units " << units << std::endl ;
|
||||||
units_found = true ;
|
units_found = true ;
|
||||||
comment = get_regex_field(comment , "^[ \t\n\r]*\\(([^\\)]*)\\)(.*)" , 2) ;
|
comment = get_regex_field(comment , "^[ \t\n\r]*\\(([^\\)]*)\\)(.*)" , 2) ;
|
||||||
} else {
|
} else {
|
||||||
ret_str = get_regex_field(comment , "^[ \t\n\r]*([^ \t\n\r)]*)" , 1) ;
|
ret_str = get_regex_field(comment , "^[ \t\n\r]*([^ \t\n\r)]*)" , 1) ;
|
||||||
if ( ! ret_str.empty()) {
|
if ( ! ret_str.empty()) {
|
||||||
units = ret_str ;
|
units = ret_str ;
|
||||||
//std::cout << "stand-alone units " << units << " " << comment << std::endl ;
|
if(debug_level >= 4) std::cout << "stand-alone units " << units << " " << comment << std::endl ;
|
||||||
units_found = true ;
|
units_found = true ;
|
||||||
comment = get_regex_field(comment , "^[ \t\n\r]*([^ \t\n\r)]*)(.*)" , 2) ;
|
comment = get_regex_field(comment , "^[ \t\n\r]*([^ \t\n\r)]*)(.*)" , 2) ;
|
||||||
}
|
}
|
||||||
|
@ -64,16 +64,19 @@ bool isInUserOrTrickCode( clang::CompilerInstance & ci , clang::SourceLocation s
|
|||||||
|
|
||||||
std::string getFileName( clang::CompilerInstance & ci , clang::SourceLocation sl , HeaderSearchDirs & hsd ) {
|
std::string getFileName( clang::CompilerInstance & ci , clang::SourceLocation sl , HeaderSearchDirs & hsd ) {
|
||||||
clang::FileID fid = ci.getSourceManager().getFileID(sl) ;
|
clang::FileID fid = ci.getSourceManager().getFileID(sl) ;
|
||||||
|
std::string file_name;
|
||||||
|
char* resolved_path;
|
||||||
if ( ! fid.isInvalid() ) {
|
if ( ! fid.isInvalid() ) {
|
||||||
const clang::FileEntry * fe = ci.getSourceManager().getFileEntryForID(fid) ;
|
const clang::FileEntry * fe = ci.getSourceManager().getFileEntryForID(fid) ;
|
||||||
if ( fe != NULL ) {
|
if ( fe != NULL ) {
|
||||||
char * resolved_path = almostRealPath( fe->getName() ) ;
|
char * resolved_path = almostRealPath( fe->getName() ) ;
|
||||||
if ( resolved_path != NULL and hsd.isPathInUserDir(resolved_path)) {
|
if ( resolved_path != NULL and hsd.isPathInUserDir(resolved_path)) {
|
||||||
return std::string(resolved_path) ;
|
file_name.append(resolved_path);
|
||||||
|
}
|
||||||
|
free(resolved_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return file_name;
|
||||||
return std::string() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -20,7 +20,7 @@ double eval(stack * stk, stack1 * no)
|
|||||||
{
|
{
|
||||||
|
|
||||||
stack1 nos = NULL;
|
stack1 nos = NULL;
|
||||||
double x, y, z;
|
double x = 0.0, y = 0.0, z = 0.0;
|
||||||
char ch;
|
char ch;
|
||||||
ldiv_t ldivt;
|
ldiv_t ldivt;
|
||||||
while (!empty(*stk)) {
|
while (!empty(*stk)) {
|
||||||
@ -224,7 +224,7 @@ double eval(stack * stk, stack1 * no)
|
|||||||
nos = push1(nos, z);
|
nos = push1(nos, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nos = pop1(nos, &z);
|
pop1(nos, &z);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("\n%lf", z);
|
printf("\n%lf", z);
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,8 +52,8 @@ void funcsub(char *str)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("\n%s", equation);
|
printf("\n%s", equation);
|
||||||
#endif
|
#endif
|
||||||
len = strlen(equation);
|
|
||||||
comp = 0;
|
comp = 0;
|
||||||
|
len = strlen(equation);
|
||||||
for (test = 0; test < (len - 1); test++) {
|
for (test = 0; test < (len - 1); test++) {
|
||||||
if ((isalpha(equation[test])) &&
|
if ((isalpha(equation[test])) &&
|
||||||
((isalpha(equation[test + 1]))
|
((isalpha(equation[test + 1]))
|
||||||
@ -65,7 +65,6 @@ void funcsub(char *str)
|
|||||||
while (comp == 1) {
|
while (comp == 1) {
|
||||||
start = 0;
|
start = 0;
|
||||||
comp = 0;
|
comp = 0;
|
||||||
len = strlen(equation);
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i == 0) {
|
while (i == 0) {
|
||||||
if ((isalpha(equation[start])) &&
|
if ((isalpha(equation[start])) &&
|
||||||
@ -107,7 +106,6 @@ void funcsub(char *str)
|
|||||||
start = start + offset;
|
start = start + offset;
|
||||||
temp[tstart] = '(';
|
temp[tstart] = '(';
|
||||||
tstart++;
|
tstart++;
|
||||||
ch1 = equation[start];
|
|
||||||
while (ch1 != ',') {
|
while (ch1 != ',') {
|
||||||
if (ch1 == '\0') {
|
if (ch1 == '\0') {
|
||||||
/* No second argument found */
|
/* No second argument found */
|
||||||
|
@ -32,7 +32,6 @@ stack takeinput(stack stk, char *equation, double value)
|
|||||||
if (eqp_errno) {
|
if (eqp_errno) {
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
i = 0;
|
|
||||||
len = strlen(equation);
|
len = strlen(equation);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ch = equation[i];
|
ch = equation[i];
|
||||||
|
@ -54,7 +54,7 @@ Csv::Csv(char * file_name , char * param_name ) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( !strcmp(start_unit + 1,"--") ) {
|
if ( !strcmp(start_unit + 1,"--") ) {
|
||||||
unitStr_ = strdup(start_unit + 1) ;
|
unitStr_ = start_unit + 1;
|
||||||
} else {
|
} else {
|
||||||
unitStr_ = map_trick_units_to_udunits(start_unit + 1) ;
|
unitStr_ = map_trick_units_to_udunits(start_unit + 1) ;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ int Delta::get( double * time , double * value )
|
|||||||
return ret ;
|
return ret ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dsg_.getLastRead(dataStream1_, time, &val1);
|
dsg_.getLastRead(dataStream1_, time, &val1);
|
||||||
ret = dsg_.getLastRead(dataStream2_, time, &val2);
|
ret = dsg_.getLastRead(dataStream2_, time, &val2);
|
||||||
|
|
||||||
*value = val1 - val2 ;
|
*value = val1 - val2 ;
|
||||||
@ -66,7 +66,7 @@ int Delta::peek( double * time , double * value )
|
|||||||
int ret ;
|
int ret ;
|
||||||
double val1, val2 ;
|
double val1, val2 ;
|
||||||
|
|
||||||
ret = dsg_.getLastRead(dataStream1_, time, &val1);
|
dsg_.getLastRead(dataStream1_, time, &val1);
|
||||||
ret = dsg_.getLastRead(dataStream2_, time, &val2);
|
ret = dsg_.getLastRead(dataStream2_, time, &val2);
|
||||||
|
|
||||||
*value = val1 - val2 ;
|
*value = val1 - val2 ;
|
||||||
|
@ -57,11 +57,11 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
|||||||
short version;
|
short version;
|
||||||
short magic;
|
short magic;
|
||||||
int data_type, bytes, field_data_type, field_bytes;
|
int data_type, bytes, field_data_type, field_bytes;
|
||||||
int size, type;
|
int size = 0, type = 0;
|
||||||
int array_type, array_bytes, array_flags[2];
|
int array_type, array_bytes, array_flags[2];
|
||||||
int array_complex, array_class ;
|
int array_complex, array_class ;
|
||||||
int dim_type, dim_bytes, num_dims;
|
int dim_type, dim_bytes, num_dims;
|
||||||
int * dims;
|
int * dims = nullptr;
|
||||||
int name_bytes;
|
int name_bytes;
|
||||||
char * name, * field_name, * variable_name;
|
char * name, * field_name, * variable_name;
|
||||||
int real_type, real_bytes;
|
int real_type, real_bytes;
|
||||||
@ -166,7 +166,10 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_dims = dim_bytes / 4;
|
num_dims = dim_bytes / 4;
|
||||||
|
// delete dangling pointer
|
||||||
|
if(dims) {
|
||||||
|
delete [] dims;
|
||||||
|
}
|
||||||
dims = new int[num_dims];
|
dims = new int[num_dims];
|
||||||
for (ii = 0; ii < num_dims; ii++) {
|
for (ii = 0; ii < num_dims; ii++) {
|
||||||
fread(&dims[ii], 4, 1, fp_) ;
|
fread(&dims[ii], 4, 1, fp_) ;
|
||||||
@ -232,12 +235,12 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
|||||||
name = new char[strlen(variable_name)];
|
name = new char[strlen(variable_name)];
|
||||||
strcpy(name, variable_name);
|
strcpy(name, variable_name);
|
||||||
field_found = true;
|
field_found = true;
|
||||||
delete field_name;
|
delete [] field_name;
|
||||||
delete variable_name;
|
delete [] variable_name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete field_name;
|
delete [] field_name;
|
||||||
delete variable_name;
|
delete [] variable_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_found) {
|
if (field_found) {
|
||||||
@ -300,7 +303,10 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_dims = dim_bytes / 4;
|
num_dims = dim_bytes / 4;
|
||||||
|
// delete dangling pointer
|
||||||
|
if(dims) {
|
||||||
|
delete [] dims;
|
||||||
|
}
|
||||||
dims = new int[num_dims];
|
dims = new int[num_dims];
|
||||||
for (ii = 0; ii < num_dims; ii++) {
|
for (ii = 0; ii < num_dims; ii++) {
|
||||||
fread(&dims[ii], 4, 1, fp_) ;
|
fread(&dims[ii], 4, 1, fp_) ;
|
||||||
@ -342,7 +348,7 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
|||||||
// Everythig else we skip
|
// Everythig else we skip
|
||||||
temp_ptr = new char[field_bytes];
|
temp_ptr = new char[field_bytes];
|
||||||
fread(temp_ptr, field_bytes, 1, fp_) ;
|
fread(temp_ptr, field_bytes, 1, fp_) ;
|
||||||
delete temp_ptr;
|
delete [] temp_ptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
real_bytes = 0;
|
real_bytes = 0;
|
||||||
@ -516,15 +522,15 @@ MatLab::MatLab(char * file_name, char * param_name, char * time_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !found) {
|
if ( !found) {
|
||||||
delete dims;
|
delete [] dims;
|
||||||
}
|
}
|
||||||
delete name;
|
delete [] name;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Everythig else we skip
|
// Everythig else we skip
|
||||||
temp_ptr = new char[bytes];
|
temp_ptr = new char[bytes];
|
||||||
fread(temp_ptr, bytes, 1, fp_) ;
|
fread(temp_ptr, bytes, 1, fp_) ;
|
||||||
delete temp_ptr;
|
delete [] temp_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -647,7 +653,7 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
|||||||
int array_type, array_bytes, array_flags[2];
|
int array_type, array_bytes, array_flags[2];
|
||||||
int array_complex, array_class;
|
int array_complex, array_class;
|
||||||
int dim_type, dim_bytes, num_dims;
|
int dim_type, dim_bytes, num_dims;
|
||||||
int * dims;
|
int * dims = nullptr;
|
||||||
int name_bytes;
|
int name_bytes;
|
||||||
char * name, * field_name, * variable_name;
|
char * name, * field_name, * variable_name;
|
||||||
int real_type, real_bytes;
|
int real_type, real_bytes;
|
||||||
@ -697,6 +703,9 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
|||||||
swap = 0;
|
swap = 0;
|
||||||
} else if (magic == 0x494d) {
|
} else if (magic == 0x494d) {
|
||||||
swap = 1;
|
swap = 1;
|
||||||
|
} else {
|
||||||
|
std::cerr << "ERROR: MatLab.cpp swap magic is invalid, default to byte swap == false" << std::endl;
|
||||||
|
swap = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
param_found = time_found = false;
|
param_found = time_found = false;
|
||||||
@ -749,7 +758,10 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
num_dims = dim_bytes / 4;
|
num_dims = dim_bytes / 4;
|
||||||
|
// delete dangling pointer
|
||||||
|
if(dims) {
|
||||||
|
delete [] dims;
|
||||||
|
}
|
||||||
dims = new int[num_dims];
|
dims = new int[num_dims];
|
||||||
for (ii = 0; ii < num_dims; ii++) {
|
for (ii = 0; ii < num_dims; ii++) {
|
||||||
fread(&dims[ii], 4, 1, fp) ;
|
fread(&dims[ii], 4, 1, fp) ;
|
||||||
@ -814,12 +826,12 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
|||||||
name = new char[strlen(variable_name)];
|
name = new char[strlen(variable_name)];
|
||||||
strcpy(name, variable_name);
|
strcpy(name, variable_name);
|
||||||
field_found = true;
|
field_found = true;
|
||||||
delete field_name;
|
delete [] field_name;
|
||||||
delete variable_name;
|
delete [] variable_name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delete field_name;
|
delete [] field_name;
|
||||||
delete variable_name;
|
delete [] variable_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_found) {
|
if (field_found) {
|
||||||
@ -880,8 +892,8 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
delete name;
|
delete [] name;
|
||||||
delete dims;
|
delete [] dims;
|
||||||
|
|
||||||
if (param_found && time_found) {
|
if (param_found && time_found) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -921,7 +933,7 @@ int MatLabLocateParam(char * file_name, char * param_name, char * time_name) {
|
|||||||
// Everythig else we skip
|
// Everythig else we skip
|
||||||
temp_ptr = new char[bytes];
|
temp_ptr = new char[bytes];
|
||||||
fread(temp_ptr, bytes, 1, fp) ;
|
fread(temp_ptr, bytes, 1, fp) ;
|
||||||
delete temp_ptr;
|
delete [] temp_ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ MatLab4::MatLab4(char * file_name , char * param_name , char * time_name ) {
|
|||||||
int temp ;
|
int temp ;
|
||||||
int endian ;
|
int endian ;
|
||||||
int mat_size ;
|
int mat_size ;
|
||||||
int type , size ;
|
int type = 0, size = 0;
|
||||||
int mat_type ;
|
int mat_type ;
|
||||||
int my_byte_order ;
|
int my_byte_order ;
|
||||||
div_t div_result ;
|
div_t div_result ;
|
||||||
@ -162,7 +162,7 @@ MatLab4::MatLab4(char * file_name , char * param_name , char * time_name ) {
|
|||||||
time_found = true ;
|
time_found = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete temp_ptr ;
|
delete [] temp_ptr ;
|
||||||
|
|
||||||
// skip to next parameter
|
// skip to next parameter
|
||||||
fseek( fp_ , row * column * size * ( 1 + imaginary ) , SEEK_CUR ) ;
|
fseek( fp_ , row * column * size * ( 1 + imaginary ) , SEEK_CUR ) ;
|
||||||
@ -364,6 +364,10 @@ int MatLab4LocateParam( char *file_name , char *param_name , char *time_name ) {
|
|||||||
case 5:
|
case 5:
|
||||||
size = 1 ;
|
size = 1 ;
|
||||||
break ;
|
break ;
|
||||||
|
default :
|
||||||
|
std::cerr << "Matlab4 " << __FUNCTION__ << "ERROR: invalid matrix size" << std::endl;
|
||||||
|
size = -1 ;
|
||||||
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread( &row , 4 , 1 , fp ) ;
|
fread( &row , 4 , 1 , fp ) ;
|
||||||
@ -395,11 +399,11 @@ int MatLab4LocateParam( char *file_name , char *param_name , char *time_name ) {
|
|||||||
|
|
||||||
if ( param_found && time_found ) {
|
if ( param_found && time_found ) {
|
||||||
fclose(fp) ;
|
fclose(fp) ;
|
||||||
delete temp_ptr ;
|
delete[] temp_ptr ;
|
||||||
return(1) ;
|
return(1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete temp_ptr ;
|
delete[] temp_ptr ;
|
||||||
|
|
||||||
// skip to next parameter
|
// skip to next parameter
|
||||||
fseek( fp , row * column * size * ( 1 + imaginary ) , SEEK_CUR ) ;
|
fseek( fp , row * column * size * ( 1 + imaginary ) , SEEK_CUR ) ;
|
||||||
|
@ -158,7 +158,7 @@ TrickBinary::TrickBinary(char * file_name , char * param_name ) {
|
|||||||
|
|
||||||
if ( ! strcmp( name_ptr , param_name )) {
|
if ( ! strcmp( name_ptr , param_name )) {
|
||||||
if ( !strcmp(units_ptr,"--") ) {
|
if ( !strcmp(units_ptr,"--") ) {
|
||||||
unitStr_ = strdup(units_ptr) ;
|
unitStr_ = units_ptr ;
|
||||||
} else {
|
} else {
|
||||||
unitStr_ = map_trick_units_to_udunits(units_ptr) ;
|
unitStr_ = map_trick_units_to_udunits(units_ptr) ;
|
||||||
}
|
}
|
||||||
@ -374,7 +374,7 @@ int TrickBinaryReadByteOrder( FILE* fp ) {
|
|||||||
const int file_type_len = 10 ;
|
const int file_type_len = 10 ;
|
||||||
char file_type[file_type_len + 1] ;
|
char file_type[file_type_len + 1] ;
|
||||||
int my_byte_order ;
|
int my_byte_order ;
|
||||||
int swap ;
|
int swap = 0;
|
||||||
|
|
||||||
memset(file_type, 0 , 10 ) ;
|
memset(file_type, 0 , 10 ) ;
|
||||||
fread(file_type , file_type_len , 1 , fp ) ;
|
fread(file_type , file_type_len , 1 , fp ) ;
|
||||||
@ -581,6 +581,6 @@ int TrickBinaryLocateParam( const char * file_name , const char * param_name ) {
|
|||||||
for ( ii = 0 ; ii < num_vars ; ii++ ) {
|
for ( ii = 0 ; ii < num_vars ; ii++ ) {
|
||||||
delete[] var_names[ii] ;
|
delete[] var_names[ii] ;
|
||||||
}
|
}
|
||||||
|
delete[] var_names;
|
||||||
return(found) ;
|
return(found) ;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,6 @@ int LogData::countNumBinaryFiles(char *pathToBinaryData)
|
|||||||
fprintf(stderr, "Couldn't open \"%s\" for reading. \n",
|
fprintf(stderr, "Couldn't open \"%s\" for reading. \n",
|
||||||
pathToBinaryData);
|
pathToBinaryData);
|
||||||
fprintf(stderr, "Maybe LogGroup Constructor not called.\n");
|
fprintf(stderr, "Maybe LogGroup Constructor not called.\n");
|
||||||
closedir(dirp);
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,9 +390,10 @@ int LogData::openCurrBinaryFile()
|
|||||||
|
|
||||||
// Do sanity check on file
|
// Do sanity check on file
|
||||||
if (access(file, F_OK | R_OK) == -1) {
|
if (access(file, F_OK | R_OK) == -1) {
|
||||||
printf("ERROR: Search for parameter exhausted."
|
fprintf(stderr, "ERROR: Search for parameter exhausted."
|
||||||
" Or \"%s\" is not readable or doesn't exist. \n",
|
" Or \"%s\" is not readable or doesn't exist. \n",
|
||||||
file);
|
file);
|
||||||
|
delete [] file;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
// Close previous binary file if not first file to open
|
// Close previous binary file if not first file to open
|
||||||
@ -509,7 +509,10 @@ int LogData::getSizeRecord()
|
|||||||
for (i = 0; i < nVars_; i++) {
|
for (i = 0; i < nVars_; i++) {
|
||||||
sizeRec = sizeRec + vars[i]->getSize();
|
sizeRec = sizeRec + vars[i]->getSize();
|
||||||
}
|
}
|
||||||
|
if(sizeRec <= 0) {
|
||||||
|
std::cerr << "ERROR: LogData::getSizeRecord() is zero or negative, may cause divide-by-zero. Exiting." << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
return (sizeRec);
|
return (sizeRec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,7 +574,7 @@ char *LogData::getNextRecord()
|
|||||||
if (currBinExtension_ < nBinFiles_) {
|
if (currBinExtension_ < nBinFiles_) {
|
||||||
// Open up next bin file, and get first rec
|
// Open up next bin file, and get first rec
|
||||||
openCurrBinaryFile();
|
openCurrBinaryFile();
|
||||||
ret = fread(currRecord_, sr, 1, fp_);
|
fread(currRecord_, sr, 1, fp_);
|
||||||
return (currRecord_);
|
return (currRecord_);
|
||||||
} else {
|
} else {
|
||||||
// We are at end of log data (no more recs)
|
// We are at end of log data (no more recs)
|
||||||
@ -1313,7 +1316,10 @@ int LogGroup::getValueAtTime( const char *paramName,
|
|||||||
// Get the value at time
|
// Get the value at time
|
||||||
rr = log[yLogIdx]->getValueAtTime(tIdx, time,
|
rr = log[yLogIdx]->getValueAtTime(tIdx, time,
|
||||||
yIdx, &vv) ;
|
yIdx, &vv) ;
|
||||||
|
// If value with timestamp found
|
||||||
|
if(rr > 0){
|
||||||
*value = vv ;
|
*value = vv ;
|
||||||
|
}
|
||||||
|
|
||||||
return(rr);
|
return(rr);
|
||||||
|
|
||||||
@ -1471,7 +1477,6 @@ int LogGroup::getHeaders()
|
|||||||
fprintf(stderr, "ERROR: Couldn't open \"%s\" for reading. \n",
|
fprintf(stderr, "ERROR: Couldn't open \"%s\" for reading. \n",
|
||||||
pathToBinaryData_);
|
pathToBinaryData_);
|
||||||
fprintf(stderr, "Maybe LogGroup constructer wasn't done. \n");
|
fprintf(stderr, "Maybe LogGroup constructer wasn't done. \n");
|
||||||
closedir(dirp);
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
// Count num headers, and max file name length in RUN dir
|
// Count num headers, and max file name length in RUN dir
|
||||||
|
@ -17,6 +17,19 @@
|
|||||||
#include "trick/units_conv.h"
|
#include "trick/units_conv.h"
|
||||||
#include "trick/map_trick_units_to_udunits.hh"
|
#include "trick/map_trick_units_to_udunits.hh"
|
||||||
|
|
||||||
|
// index labels for char arrays
|
||||||
|
enum strIndex {
|
||||||
|
LINE,
|
||||||
|
STR1,
|
||||||
|
STR2,
|
||||||
|
STR3,
|
||||||
|
STR4,
|
||||||
|
NUM_STR
|
||||||
|
};
|
||||||
|
|
||||||
|
// helper function to free memory before successful or unsuccessful return
|
||||||
|
void shutdown(FILE*, char**, char*);
|
||||||
|
|
||||||
/* A private function for parsing log header files.
|
/* A private function for parsing log header files.
|
||||||
* This is responsible for initialize the Log classes as well
|
* This is responsible for initialize the Log classes as well
|
||||||
*/
|
*/
|
||||||
@ -25,17 +38,13 @@ int LogGroup::parseLogHeaders()
|
|||||||
|
|
||||||
int nVars;
|
int nVars;
|
||||||
int lineNum;
|
int lineNum;
|
||||||
char *line;
|
char** strs = new char*[NUM_STR];
|
||||||
char *str1;
|
|
||||||
char *str2;
|
|
||||||
char *str3;
|
|
||||||
char *str4;
|
|
||||||
char *headerName;
|
char *headerName;
|
||||||
int i;
|
int i;
|
||||||
int headerSize;
|
int headerSize;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
LogData *currLogData;
|
LogData *currLogData = 0;
|
||||||
Var *currVar;
|
Var *currVar;
|
||||||
|
|
||||||
|
|
||||||
@ -54,6 +63,8 @@ int LogGroup::parseLogHeaders()
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\nERROR:\nCouldn't open file \"%s\" \n",
|
"\nERROR:\nCouldn't open file \"%s\" \n",
|
||||||
headerName);
|
headerName);
|
||||||
|
delete[] strs;
|
||||||
|
delete[] headerName;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
// Allocate strings, we know that buffers can't be
|
// Allocate strings, we know that buffers can't be
|
||||||
@ -63,15 +74,13 @@ int LogGroup::parseLogHeaders()
|
|||||||
fseek(fp_, 0, SEEK_END);
|
fseek(fp_, 0, SEEK_END);
|
||||||
headerSize = ftell(fp_);
|
headerSize = ftell(fp_);
|
||||||
::rewind(fp_);
|
::rewind(fp_);
|
||||||
line = new char[headerSize + 1]; // Not sure about +1 :)
|
for(int i = 0; i < NUM_STR; i++){
|
||||||
str1 = new char[headerSize + 1];
|
strs[i] = new char[headerSize + 1]; // Not sure about +1 :)
|
||||||
str2 = new char[headerSize + 1];
|
}
|
||||||
str3 = new char[headerSize + 1];
|
|
||||||
str4 = new char[headerSize + 1];
|
|
||||||
|
|
||||||
// Parse rest of file
|
// Parse rest of file
|
||||||
lineNum = 0;
|
lineNum = 0;
|
||||||
while (fgets(line, headerSize, fp_) != NULL) {
|
while (fgets(strs[LINE], headerSize, fp_) != NULL) {
|
||||||
|
|
||||||
lineNum++;
|
lineNum++;
|
||||||
|
|
||||||
@ -79,10 +88,10 @@ int LogGroup::parseLogHeaders()
|
|||||||
or
|
or
|
||||||
<log_file_name> byte_order is [lit|big]_endian
|
<log_file_name> byte_order is [lit|big]_endian
|
||||||
*/
|
*/
|
||||||
if ( sscanf(line, "%s %s %s %s", str1, str2, str3, str4) == 4 ) {
|
if ( sscanf(strs[LINE], "%s %s %s %s", strs[STR1], strs[STR2], strs[STR3], strs[STR4]) == 4 ) {
|
||||||
|
|
||||||
// Byte order statement and top of a log group?
|
// Byte order statement and top of a log group?
|
||||||
if (!strcmp(str2, "byte_order")) {
|
if (!strcmp(strs[STR2], "byte_order")) {
|
||||||
|
|
||||||
LogData *ld = new LogData;
|
LogData *ld = new LogData;
|
||||||
log.push_back(ld);
|
log.push_back(ld);
|
||||||
@ -90,10 +99,10 @@ int LogGroup::parseLogHeaders()
|
|||||||
nGroups_++;
|
nGroups_++;
|
||||||
|
|
||||||
// New binary file
|
// New binary file
|
||||||
currLogData->setBinaryFileName(str1);
|
currLogData->setBinaryFileName(strs[STR1]);
|
||||||
|
|
||||||
// Set byte order
|
// Set byte order
|
||||||
if (!strcmp(str4, "big_endian")) {
|
if (!strcmp(strs[STR4], "big_endian")) {
|
||||||
currLogData->dataByteOrder = 1;
|
currLogData->dataByteOrder = 1;
|
||||||
} else {
|
} else {
|
||||||
currLogData->dataByteOrder = 0;
|
currLogData->dataByteOrder = 0;
|
||||||
@ -102,7 +111,7 @@ int LogGroup::parseLogHeaders()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check for binary file name mismatches
|
// Check for binary file name mismatches
|
||||||
if (strcmp(str1, currLogData->getBinaryFileName())) {
|
if (currLogData && strcmp(strs[STR1], currLogData->getBinaryFileName())) {
|
||||||
printf("ERROR: Parsing log header \"%s\".\n"
|
printf("ERROR: Parsing log header \"%s\".\n"
|
||||||
" Line %d. Binary file name "
|
" Line %d. Binary file name "
|
||||||
"mismatch with \"%s\".\n"
|
"mismatch with \"%s\".\n"
|
||||||
@ -110,6 +119,7 @@ int LogGroup::parseLogHeaders()
|
|||||||
"specification.\n\n",
|
"specification.\n\n",
|
||||||
headerName, lineNum,
|
headerName, lineNum,
|
||||||
currLogData->getBinaryFileName());
|
currLogData->getBinaryFileName());
|
||||||
|
shutdown(fp_, strs, headerName);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
// New variable
|
// New variable
|
||||||
@ -121,11 +131,12 @@ int LogGroup::parseLogHeaders()
|
|||||||
currLogData->setNumVars(nVars);
|
currLogData->setNumVars(nVars);
|
||||||
|
|
||||||
// Set Type
|
// Set Type
|
||||||
if (currVar->setType(str2) < 0) {
|
if (currVar->setType(strs[STR2]) < 0) {
|
||||||
printf("ERROR: In log header \"%s\".\n"
|
printf("ERROR: In log header \"%s\".\n"
|
||||||
" Line %d. Type \"%s\" is "
|
" Line %d. Type \"%s\" is "
|
||||||
"not supported.\n",
|
"not supported.\n",
|
||||||
headerName, lineNum, str2);
|
headerName, lineNum, strs[STR2]);
|
||||||
|
shutdown(fp_, strs, headerName);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,43 +145,47 @@ int LogGroup::parseLogHeaders()
|
|||||||
{
|
{
|
||||||
char new_units_spec[100];
|
char new_units_spec[100];
|
||||||
new_units_spec[0] = 0;
|
new_units_spec[0] = 0;
|
||||||
if ( convert_units_spec (str3, new_units_spec) != 0 ) {
|
if ( convert_units_spec (strs[STR3], new_units_spec) != 0 ) {
|
||||||
printf (" ERROR: Attempt to convert old units-spec, \"%s\" failed.\n\n",str3);
|
printf (" ERROR: Attempt to convert old units-spec, \"%s\" failed.\n\n",strs[STR3]);
|
||||||
|
shutdown(fp_, strs, headerName);
|
||||||
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
delete [] str3;
|
delete [] strs[STR3];
|
||||||
len = strlen(new_units_spec);
|
len = strlen(new_units_spec);
|
||||||
str3 = new char[len + 1] ;
|
strs[STR3] = new char[len + 1] ;
|
||||||
strcpy(str3, new_units_spec);
|
strcpy(strs[STR3], new_units_spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Unit class
|
// Initialize Unit class
|
||||||
if ( ! strcmp(str3,"--")) {
|
if ( ! strcmp(strs[STR3],"--")) {
|
||||||
currVar->setUnit(str3);
|
currVar->setUnit(strs[STR3]);
|
||||||
} else {
|
} else {
|
||||||
currVar->setUnit(map_trick_units_to_udunits(str3));
|
currVar->setUnit(map_trick_units_to_udunits(strs[STR3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Var Name
|
// Set Var Name
|
||||||
currVar->setVarName(str4) ;
|
currVar->setVarName(strs[STR4]) ;
|
||||||
if (currVar->getSize() < 0) {
|
if (currVar->getSize() < 0) {
|
||||||
printf("ERROR: In log header \"%s\".\n"
|
printf("ERROR: In log header \"%s\".\n"
|
||||||
" Line %d. Problem with var "
|
" Line %d. Problem with var "
|
||||||
"name \"%s\" . \n",
|
"name \"%s\" . \n",
|
||||||
headerName, lineNum, str4);
|
headerName, lineNum, strs[STR4]);
|
||||||
|
shutdown(fp_, strs, headerName);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
shutdown(fp_, strs, headerName);
|
||||||
fclose(fp_);
|
|
||||||
delete[]line;
|
|
||||||
delete[]str1;
|
|
||||||
delete[]str2;
|
|
||||||
delete[]str3;
|
|
||||||
delete[]str4;
|
|
||||||
delete[]headerName;
|
|
||||||
}
|
}
|
||||||
|
delete[] strs;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shutdown (FILE* fp_, char** strs, char* headerName) {
|
||||||
|
fclose(fp_);
|
||||||
|
for(int i = 0; i < NUM_STR; i++) {
|
||||||
|
delete[] strs[i];
|
||||||
|
}
|
||||||
|
delete[] headerName;
|
||||||
|
}
|
||||||
|
@ -466,6 +466,7 @@ int Var::getDimOffset( const char* param ) {
|
|||||||
if ( offset < 0 ) {
|
if ( offset < 0 ) {
|
||||||
fprintf(stderr, "ERROR: Integer overflow "
|
fprintf(stderr, "ERROR: Integer overflow "
|
||||||
"calculating offset!\n");
|
"calculating offset!\n");
|
||||||
|
VAR_DELETE;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,12 +657,13 @@ int Var::calcNumDimensions() {
|
|||||||
if ( varName_[i] == ']' ) {
|
if ( varName_[i] == ']' ) {
|
||||||
cerr << "ERROR: Missing open bracket in"
|
cerr << "ERROR: Missing open bracket in"
|
||||||
<< varName_ << endl ;
|
<< varName_ << endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( varName_[i] == '[' ) {
|
if ( varName_[i] == '[' ) {
|
||||||
|
|
||||||
j = 0;
|
|
||||||
while ( varName_[i] != ']' ) {
|
while ( varName_[i] != ']' ) {
|
||||||
|
|
||||||
i++ ;
|
i++ ;
|
||||||
@ -670,6 +672,8 @@ int Var::calcNumDimensions() {
|
|||||||
if ( i == stringLen ) {
|
if ( i == stringLen ) {
|
||||||
cerr << "ERROR: Missing close bracket in"
|
cerr << "ERROR: Missing close bracket in"
|
||||||
<< varName_ << endl ;
|
<< varName_ << endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 ) ;
|
return( -1 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,11 +690,15 @@ int Var::calcNumDimensions() {
|
|||||||
cerr << "ERROR: Missing close "
|
cerr << "ERROR: Missing close "
|
||||||
<< "bracket in "
|
<< "bracket in "
|
||||||
<< varName_ << endl ;
|
<< varName_ << endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 ) ;
|
return( -1 ) ;
|
||||||
}
|
}
|
||||||
if ( j > 7 ) {
|
if ( j > 7 ) {
|
||||||
printf("ERROR: Dimension spec "
|
printf("ERROR: Dimension spec "
|
||||||
"too long.\n");
|
"too long.\n");
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 ) ;
|
return( -1 ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -715,6 +723,8 @@ int Var::calcNumDimensions() {
|
|||||||
<< " in "
|
<< " in "
|
||||||
<< varName_
|
<< varName_
|
||||||
<< endl ;
|
<< endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 ) ;
|
return( -1 ) ;
|
||||||
}
|
}
|
||||||
if ( j > 7 ) {
|
if ( j > 7 ) {
|
||||||
@ -723,6 +733,8 @@ int Var::calcNumDimensions() {
|
|||||||
<< "in "
|
<< "in "
|
||||||
<< varName_
|
<< varName_
|
||||||
<< endl ;
|
<< endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 ) ;
|
return( -1 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,6 +750,8 @@ int Var::calcNumDimensions() {
|
|||||||
cerr << "ERROR: Dimension has syntax "
|
cerr << "ERROR: Dimension has syntax "
|
||||||
<< "error with "
|
<< "error with "
|
||||||
<< varName_ << endl ;
|
<< varName_ << endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 ) ;
|
return( -1 ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -746,6 +760,8 @@ int Var::calcNumDimensions() {
|
|||||||
cerr << "ERROR: Bad syntax in dimension "
|
cerr << "ERROR: Bad syntax in dimension "
|
||||||
<< "specification for "
|
<< "specification for "
|
||||||
<< varName_ << endl ;
|
<< varName_ << endl ;
|
||||||
|
delete[] dim1 ;
|
||||||
|
delete[] dim2 ;
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../..)
|
TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../..)
|
||||||
|
|
||||||
|
TRICK_CXXFLAGS += -std=c++11
|
||||||
|
|
||||||
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||||
|
|
||||||
LIB_DIR = lib_${TRICK_HOST_CPU}
|
LIB_DIR = lib_${TRICK_HOST_CPU}
|
||||||
|
@ -315,6 +315,7 @@ RK2MidpointGeneralizedStepSecondOrderODEIntegrator::integrate (
|
|||||||
step_factor = 1.0;
|
step_factor = 1.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
step_factor = 1.0;
|
step_factor = 1.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +259,10 @@ static char *getCompositeSubReference(
|
|||||||
// Calculate the array indices for the right-side.
|
// Calculate the array indices for the right-side.
|
||||||
for (j = num_fixed_dims - 1; j >= 0; j--) {
|
for (j = num_fixed_dims - 1; j >= 0; j--) {
|
||||||
size *= A[i].index[j].size;
|
size *= A[i].index[j].size;
|
||||||
|
if(!size) {
|
||||||
|
std::cerr << "Checkpoint Agent " << __FUNCTION__ << " ERROR: divide by zero during array indices calculation" << std::endl;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
my_index[j] = (int) ((offset % size) / last_size);
|
my_index[j] = (int) ((offset % size) / last_size);
|
||||||
offset -= last_size * my_index[j];
|
offset -= last_size * my_index[j];
|
||||||
last_size = size;
|
last_size = size;
|
||||||
@ -613,8 +617,9 @@ void Trick::ClassicCheckPointAgent::write_singleton( std::ostream& chkpnt_os, vo
|
|||||||
src_addr = (char*)address + offset * sizeof(short);
|
src_addr = (char*)address + offset * sizeof(short);
|
||||||
value = *(short*)src_addr;
|
value = *(short*)src_addr;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << __FUNCTION__ << " enumeration size error." << std::endl;
|
std::cerr << __FUNCTION__ << ": enumeration size error." << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
|
value = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum_attr = (ENUM_ATTR*)attr->attr;
|
enum_attr = (ENUM_ATTR*)attr->attr;
|
||||||
|
@ -121,6 +121,7 @@ void Trick::PythonPrint::write_singleton( std::ostream& chkpnt_os, void* address
|
|||||||
} else {
|
} else {
|
||||||
std::cerr << __FUNCTION__ << " enumeration size error." << std::endl;
|
std::cerr << __FUNCTION__ << " enumeration size error." << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
|
value = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum_attr = (ENUM_ATTR*)attr->attr;
|
enum_attr = (ENUM_ATTR*)attr->attr;
|
||||||
|
@ -393,7 +393,7 @@ int Trick::DataRecordGroup::init() {
|
|||||||
drb->ref_searched = true ;
|
drb->ref_searched = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = write_header() ;
|
write_header() ;
|
||||||
|
|
||||||
// call format specific initialization to open destination and write header
|
// call format specific initialization to open destination and write header
|
||||||
ret = format_specific_init() ;
|
ret = format_specific_init() ;
|
||||||
|
@ -129,7 +129,7 @@ int Trick::IPPython::init() {
|
|||||||
|
|
||||||
/* Read and parse the input file. */
|
/* Read and parse the input file. */
|
||||||
if ( verify_input ) {
|
if ( verify_input ) {
|
||||||
ret = PyRun_SimpleString("sys.settrace(trick.traceit)") ;
|
PyRun_SimpleString("sys.settrace(trick.traceit)") ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (ret = PyRun_SimpleFile(input_fp, input_file.c_str())) != 0 ) {
|
if ( (ret = PyRun_SimpleFile(input_fp, input_file.c_str())) != 0 ) {
|
||||||
|
@ -207,12 +207,13 @@ int Trick::JITInputFile::run(std::string file_name , std::string run_function )
|
|||||||
if ( call_me == NULL ) {
|
if ( call_me == NULL ) {
|
||||||
std::string error_message = "JITInputfile could not find function " + run_function ;
|
std::string error_message = "JITInputfile could not find function " + run_function ;
|
||||||
exec_terminate_with_return(-1 , __FILE__ , __LINE__ , error_message.c_str() ) ;
|
exec_terminate_with_return(-1 , __FILE__ , __LINE__ , error_message.c_str() ) ;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// We found the function, call it!
|
// We found the function, call it!
|
||||||
ret = (*call_me)() ;
|
ret = (*call_me)() ;
|
||||||
|
|
||||||
return ret ;
|
return ret ;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@ Trick::JSONVariableServerThread::JSONVariableServerThread(TCDevice * listen_dev)
|
|||||||
*/
|
*/
|
||||||
Trick::JSONVariableServerThread::~JSONVariableServerThread() {
|
Trick::JSONVariableServerThread::~JSONVariableServerThread() {
|
||||||
delete [] incoming_msg ;
|
delete [] incoming_msg ;
|
||||||
delete this ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4,6 +4,8 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.tricklib
|
|||||||
|
|
||||||
-include Makefile_deps
|
-include Makefile_deps
|
||||||
|
|
||||||
|
TRICK_CXXFLAGS += -std=c++11
|
||||||
|
|
||||||
ifeq ($(HAVE_GSL),1)
|
ifeq ($(HAVE_GSL),1)
|
||||||
TRICK_CXXFLAGS += -D_HAVE_GSL
|
TRICK_CXXFLAGS += -D_HAVE_GSL
|
||||||
ifneq ($(GSL_HOME),/usr)
|
ifneq ($(GSL_HOME),/usr)
|
||||||
|
@ -77,6 +77,9 @@ std::string Trick::MonteVarFile::get_next_value() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the next value.
|
// Get the next value.
|
||||||
|
if(temp_str) {
|
||||||
|
free(temp_str);
|
||||||
|
}
|
||||||
temp_str = strdup(line.c_str());
|
temp_str = strdup(line.c_str());
|
||||||
token = strtok(temp_str, " \t");
|
token = strtok(temp_str, " \t");
|
||||||
|
|
||||||
@ -94,8 +97,12 @@ std::string Trick::MonteVarFile::get_next_value() {
|
|||||||
ss << name << " = " << token;
|
ss << name << " = " << token;
|
||||||
else
|
else
|
||||||
ss << name << " = " << "trick.attach_units(\"" << unit << "\", " << token << ")";
|
ss << name << " = " << "trick.attach_units(\"" << unit << "\", " << token << ")";
|
||||||
|
if(temp_str) {
|
||||||
|
free(temp_str);
|
||||||
|
temp_str = nullptr;
|
||||||
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
|
||||||
}
|
}
|
||||||
char string[100];
|
char string[100];
|
||||||
sprintf(string, "Trick:MonteVarFile the input file \"%s\" is not open for reading", file_name.c_str());
|
sprintf(string, "Trick:MonteVarFile the input file \"%s\" is not open for reading", file_name.c_str());
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||||
|
|
||||||
# Flags passed to the preprocessor.
|
# Flags passed to the preprocessor.
|
||||||
TRICK_CXXFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wall -Wextra -DGTEST_HAS_TR1_TUPLE=0
|
TRICK_CXXFLAGS += -I$(GTEST_HOME)/include -I$(TRICK_HOME)/include -g -Wall -Wextra -DGTEST_HAS_TR1_TUPLE=0 -std=c++11
|
||||||
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick -ltrick_pyip -ltrick_comm -ltrick_math -ltrick_mm -ltrick_units
|
TRICK_LIBS = -L${TRICK_LIB_DIR} -ltrick -ltrick_pyip -ltrick_comm -ltrick_math -ltrick_mm -ltrick_units
|
||||||
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main
|
TRICK_EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void * Trick::VariableServerListenThread::thread_body() {
|
|||||||
std::string version;
|
std::string version;
|
||||||
char * user_name ;
|
char * user_name ;
|
||||||
|
|
||||||
int mcast_socket ;
|
int mcast_socket = 0;
|
||||||
struct sockaddr_in mcast_addr ;
|
struct sockaddr_in mcast_addr ;
|
||||||
struct sockaddr_in mcast_addr_legacy ;
|
struct sockaddr_in mcast_addr_legacy ;
|
||||||
|
|
||||||
@ -177,8 +177,7 @@ void * Trick::VariableServerListenThread::thread_body() {
|
|||||||
vst->create_thread() ;
|
vst->create_thread() ;
|
||||||
vst->wait_for_accept() ;
|
vst->wait_for_accept() ;
|
||||||
pthread_mutex_unlock(&restart_pause) ;
|
pthread_mutex_unlock(&restart_pause) ;
|
||||||
} else {
|
} else if ( broadcast ) {
|
||||||
if ( broadcast ) {
|
|
||||||
sprintf(buf1 , "%s\t%hu\t%s\t%d\t%s\t%s\t%s\t%s\t%s\t%hu\n" , listen_dev.hostname , (unsigned short)listen_dev.port ,
|
sprintf(buf1 , "%s\t%hu\t%s\t%d\t%s\t%s\t%s\t%s\t%s\t%hu\n" , listen_dev.hostname , (unsigned short)listen_dev.port ,
|
||||||
user_name , (int)getpid() , command_line_args_get_default_dir() , command_line_args_get_cmdline_name() ,
|
user_name , (int)getpid() , command_line_args_get_default_dir() , command_line_args_get_cmdline_name() ,
|
||||||
command_line_args_get_input_file() , version.c_str() , user_tag.c_str(), (unsigned short)listen_dev.port ) ;
|
command_line_args_get_input_file() , version.c_str() , user_tag.c_str(), (unsigned short)listen_dev.port ) ;
|
||||||
@ -188,8 +187,6 @@ void * Trick::VariableServerListenThread::thread_body() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +86,10 @@ int Trick::VariableServerThread::copy_sim_data() {
|
|||||||
curr_var->size = wcslen((wchar_t *)curr_var->address) * sizeof(wchar_t);
|
curr_var->size = wcslen((wchar_t *)curr_var->address) * sizeof(wchar_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(curr_var->address != NULL) {
|
||||||
memcpy( curr_var->buffer_in , curr_var->address , curr_var->size ) ;
|
memcpy( curr_var->buffer_in , curr_var->address , curr_var->size ) ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Indicate that sim data has been written and is now ready in the buffer_in's of the vars variable list.
|
// Indicate that sim data has been written and is now ready in the buffer_in's of the vars variable list.
|
||||||
var_data_staged = true;
|
var_data_staged = true;
|
||||||
|
@ -36,7 +36,7 @@ void * Trick::VariableServerThread::thread_body() {
|
|||||||
vs->add_vst( pthread_self() , this ) ;
|
vs->add_vst( pthread_self() , this ) ;
|
||||||
|
|
||||||
if ( listen_dev->socket_type == SOCK_STREAM ) {
|
if ( listen_dev->socket_type == SOCK_STREAM ) {
|
||||||
ret = tc_accept(listen_dev, &connection);
|
tc_accept(listen_dev, &connection);
|
||||||
tc_blockio(&connection, TC_COMM_ALL_OR_NOTHING);
|
tc_blockio(&connection, TC_COMM_ALL_OR_NOTHING);
|
||||||
}
|
}
|
||||||
connection_accepted = true ;
|
connection_accepted = true ;
|
||||||
@ -141,7 +141,7 @@ void * Trick::VariableServerThread::thread_body() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( copy_mode == VS_COPY_ASYNC ) {
|
if ( copy_mode == VS_COPY_ASYNC ) {
|
||||||
ret = copy_sim_data() ;
|
copy_sim_data() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (write_mode == VS_WRITE_ASYNC) or
|
if ( (write_mode == VS_WRITE_ASYNC) or
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
int tc_init_mcast_client(TCDevice * mcast_client_device)
|
int tc_init_mcast_client(TCDevice * mcast_client_device)
|
||||||
{
|
{
|
||||||
if (!mcast_client_device) {
|
if (!mcast_client_device) {
|
||||||
trick_error_report(mcast_client_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ int tc_init_mcast_server(TCDevice * mcast_server_device)
|
|||||||
const unsigned int yes = 1;
|
const unsigned int yes = 1;
|
||||||
|
|
||||||
if (!mcast_server_device) {
|
if (!mcast_server_device) {
|
||||||
trick_error_report(mcast_server_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ int tc_init_udp_client(TCDevice * udp_client_device)
|
|||||||
memset(&sockin, 0 , sizeof(struct sockaddr_in)) ;
|
memset(&sockin, 0 , sizeof(struct sockaddr_in)) ;
|
||||||
|
|
||||||
if (!udp_client_device) {
|
if (!udp_client_device) {
|
||||||
trick_error_report(udp_client_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ int tc_init_udp_server( /* RETURN: -- 0 for success */
|
|||||||
unsigned int yes = 1;
|
unsigned int yes = 1;
|
||||||
|
|
||||||
if (!udp_server_device) {
|
if (!udp_server_device) {
|
||||||
trick_error_report(udp_server_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ int tsm_disconnect(TSMDevice * shm_device)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = TSM_SUCCESS;
|
|
||||||
|
|
||||||
// if we had a read/write lock, destroy it first
|
// if we had a read/write lock, destroy it first
|
||||||
if (shm_device->rwlock_addr != NULL) {
|
if (shm_device->rwlock_addr != NULL) {
|
||||||
ret = pthread_rwlockattr_destroy(&shm_device->rwlattr);
|
ret = pthread_rwlockattr_destroy(&shm_device->rwlattr);
|
||||||
|
@ -26,14 +26,15 @@ void DeleteTblEntry(TBLENTRY * entry)
|
|||||||
/* create an iterator */
|
/* create an iterator */
|
||||||
StrMapIterator *SMI_Create(MapStrToPtr * pTable)
|
StrMapIterator *SMI_Create(MapStrToPtr * pTable)
|
||||||
{
|
{
|
||||||
StrMapIterator *pIter = (StrMapIterator *) malloc(sizeof(StrMapIterator));
|
StrMapIterator *pIter;
|
||||||
|
|
||||||
|
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
fprintf(stderr, "Table is NULL");
|
fprintf(stderr, "Table is NULL");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pIter = (StrMapIterator *) malloc(sizeof(StrMapIterator));
|
||||||
|
|
||||||
pIter->m_pTable = pTable;
|
pIter->m_pTable = pTable;
|
||||||
pIter->m_Index = 0; /* set the current index of the list array to 0 */
|
pIter->m_Index = 0; /* set the current index of the list array to 0 */
|
||||||
pIter->m_ListPos = NULL; /* set the position reference to null indicating there is not a current element */
|
pIter->m_ListPos = NULL; /* set the position reference to null indicating there is not a current element */
|
||||||
|
@ -11,8 +11,12 @@ bstNode *bstFind(void *info, BST * bst)
|
|||||||
{
|
{
|
||||||
bstNode *current;
|
bstNode *current;
|
||||||
|
|
||||||
if (bst == NULL && info == NULL) {
|
if (bst == NULL) {
|
||||||
fprintf(stderr, "Queue is empty");
|
fprintf(stderr, "bst is not allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (info == NULL) {
|
||||||
|
fprintf(stderr, "info is invalid pointer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +101,12 @@ void *bstDelete(bstNode * node, BST * bst)
|
|||||||
bstNode **parentspointer;
|
bstNode **parentspointer;
|
||||||
|
|
||||||
|
|
||||||
if (node == NULL && bst == NULL) {
|
if (bst == NULL) {
|
||||||
fprintf(stderr, "Queue is empty");
|
fprintf(stderr, "bst is not allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (node == NULL) {
|
||||||
|
fprintf(stderr, "node is invalid pointer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +115,7 @@ void *bstDelete(bstNode * node, BST * bst)
|
|||||||
return (node);
|
return (node);
|
||||||
}
|
}
|
||||||
bst->nodes--; /* decrement the node counter */
|
bst->nodes--; /* decrement the node counter */
|
||||||
if (node->parent != NULL) { /* if node is not the root, *//* then get the address of the parent's pointer to node */
|
if (node && node->parent != NULL) { /* if node is not the root, *//* then get the address of the parent's pointer to node */
|
||||||
if (node->parent->left == node)
|
if (node->parent->left == node)
|
||||||
parentspointer = &(node->parent->left);
|
parentspointer = &(node->parent->left);
|
||||||
else
|
else
|
||||||
@ -201,12 +209,16 @@ bstNode *bstInsert(void *info, BST * bst)
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
|
|
||||||
if (bst == NULL && info == NULL) {
|
if (bst == NULL) {
|
||||||
fprintf(stderr, "Queue is empty");
|
fprintf(stderr, "bst is not allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (info == NULL) {
|
||||||
|
fprintf(stderr, "info is invalid pointer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bst->init) {
|
if (bst && !bst->init) {
|
||||||
bstInit(bst);
|
bstInit(bst);
|
||||||
}
|
}
|
||||||
newNode = (bstNode *) malloc(sizeof(bstNode)); /* allocate memory for the node */
|
newNode = (bstNode *) malloc(sizeof(bstNode)); /* allocate memory for the node */
|
||||||
|
Loading…
Reference in New Issue
Block a user