mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 09:08:00 +02:00
cleaning the project
This commit is contained in:
66
slsReceiverSoftware/src/utilities.cpp
Normal file
66
slsReceiverSoftware/src/utilities.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int read_config_file(string fname, int *tcpip_port_no){
|
||||
|
||||
ifstream infile;
|
||||
string sLine,sargname;
|
||||
int iline = 0;
|
||||
int success = slsReceiverDefs::OK;
|
||||
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
while(infile.good()){
|
||||
getline(infile,sLine);
|
||||
iline++;
|
||||
|
||||
//VERBOSE_PRINT(sLine);
|
||||
|
||||
if(sLine.find('#')!=string::npos){
|
||||
//VERBOSE_PRINT( "Line is a comment ");
|
||||
continue;
|
||||
}
|
||||
else if(sLine.length()<2){
|
||||
//VERBOSE_PRINT("Empty line ");
|
||||
continue;
|
||||
}
|
||||
else{
|
||||
istringstream sstr(sLine);
|
||||
|
||||
//parameter name
|
||||
if(sstr.good())
|
||||
sstr >> sargname;
|
||||
|
||||
//tcp port
|
||||
if(sargname=="rx_tcpport"){
|
||||
if(sstr.good()) {
|
||||
sstr >> sargname;
|
||||
if(sscanf(sargname.c_str(),"%d",tcpip_port_no))
|
||||
cout<<"dataport:"<<tcpip_port_no<<endl;
|
||||
else{
|
||||
cout << "could not decode port in config file. Exiting." << endl;
|
||||
success = slsReceiverDefs::FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
infile.close();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user