mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
strtok is not thread safe..used to set receiver udp ip etc to detector, fixed
This commit is contained in:
@ -6186,8 +6186,6 @@ int slsDetector::configureMAC(){
|
||||
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
char arg[6][50]={"","","","","",""};
|
||||
char cword[50]="", *pcword;
|
||||
string sword;
|
||||
int retval=-1;
|
||||
|
||||
|
||||
@ -6232,50 +6230,74 @@ int slsDetector::configureMAC(){
|
||||
std::cout<< "IP/MAC Addresses valid "<< std::endl;
|
||||
#endif
|
||||
|
||||
//converting IPaddress to hex.
|
||||
pcword = strtok (arg[0],".");
|
||||
while (pcword != NULL) {
|
||||
sprintf(arg[0],"%02x",atoi(pcword));
|
||||
strcat(cword,arg[0]);
|
||||
pcword = strtok (NULL, ".");
|
||||
|
||||
{
|
||||
//converting IPaddress to hex
|
||||
stringstream ss(arg[0]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, '.')) {
|
||||
sprintf(cword,"%s%02x",cword,atoi(s.c_str()));
|
||||
}
|
||||
bzero(arg[0], 50);
|
||||
strcpy(arg[0],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp ip:"<<arg[0]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting MACaddress to hex.
|
||||
sword.assign(arg[1]);
|
||||
strcpy(arg[1],"");
|
||||
stringstream sstr(sword);
|
||||
while(getline(sstr,sword,':'))
|
||||
strcat(arg[1],sword.c_str());
|
||||
}
|
||||
|
||||
{
|
||||
//converting MACaddress to hex
|
||||
stringstream ss(arg[1]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, ':')) {
|
||||
sprintf(cword,"%s%s",cword,s.c_str());
|
||||
}
|
||||
bzero(arg[1], 50);
|
||||
strcpy(arg[1],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver mac:"<<arg[1]<<"."<<std::endl;
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port:"<<arg[2]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting server MACaddress to hex.
|
||||
sword.assign(arg[3]);
|
||||
strcpy(arg[3],"");
|
||||
stringstream ssstr(sword);
|
||||
while(getline(ssstr,sword,':'))
|
||||
strcat(arg[3],sword.c_str());
|
||||
|
||||
{
|
||||
stringstream ss(arg[3]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, ':')) {
|
||||
sprintf(cword,"%s%s",cword,s.c_str());
|
||||
}
|
||||
bzero(arg[3], 50);
|
||||
strcpy(arg[3],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"detecotor mac:"<<arg[3]<<"."<<std::endl;
|
||||
#endif
|
||||
//converting IPaddress to hex.
|
||||
strcpy(cword,"");
|
||||
pcword = strtok (arg[4],".");
|
||||
while (pcword != NULL) {
|
||||
sprintf(arg[4],"%02x",atoi(pcword));
|
||||
strcat(cword,arg[4]);
|
||||
pcword = strtok (NULL, ".");
|
||||
}
|
||||
|
||||
{
|
||||
//converting IPaddress to hex
|
||||
stringstream ss(arg[4]);
|
||||
char cword[50]="";
|
||||
bzero(cword, 50);
|
||||
string s;
|
||||
while (getline(ss, s, '.')) {
|
||||
sprintf(cword,"%s%02x",cword,atoi(s.c_str()));
|
||||
}
|
||||
bzero(arg[4], 50);
|
||||
strcpy(arg[4],cword);
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"detector ip:"<<arg[4]<<"."<<std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<<"receiver udp port2:"<<arg[5]<<"."<<std::endl;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user