Skip to content

Commit

Permalink
- Remove the crap known as tabs from C sources
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8625 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 13, 2011
1 parent b872312 commit 3940412
Show file tree
Hide file tree
Showing 90 changed files with 4,583 additions and 4,584 deletions.
5 changes: 2 additions & 3 deletions c_runtime/ModelicaExternalC/ModelicaTablesImpl.c
Expand Up @@ -20,7 +20,7 @@ int ModelicaTables_CombiTimeTable_init(const char* tableName, const char* fileNa
int extrapolation)
{
return omcTableTimeIni(startTime, startTime, smoothness, extrapolation,
tableName, fileName, table, nRow, nColumn, 0);
tableName, fileName, table, nRow, nColumn, 0);
}

void ModelicaTables_CombiTimeTable_close(int tableID)
Expand Down Expand Up @@ -52,8 +52,7 @@ int ModelicaTables_CombiTable1D_init(const char* tableName, const char* fileName
double const *table, int nRow, int nColumn,
int smoothness)
{
return omcTableTimeIni(0.0, 0.0, smoothness, 0, tableName, fileName,
table, nRow, nColumn, 0);
return omcTableTimeIni(0.0, 0.0, smoothness, 0, tableName, fileName, table, nRow, nColumn, 0);
}

void ModelicaTables_CombiTable1D_close(int tableID)
Expand Down
244 changes: 122 additions & 122 deletions c_runtime/interactive/client.cpp
Expand Up @@ -38,21 +38,21 @@ THREAD_RET_TYPE threadServerControl(void*)

while(run)
{
string message;

if(!s2.recv(message))
{
if (!shutDownInProgress)
{
cout << "threadServerControl: Failed to recieve message!" << endl; fflush(stdout);
return 0;
}
}

if (!shutDownInProgress)
{
cout << "Server recieved message: " << message << endl; fflush(stdout);
}
string message;

if(!s2.recv(message))
{
if (!shutDownInProgress)
{
cout << "threadServerControl: Failed to recieve message!" << endl; fflush(stdout);
return 0;
}
}

if (!shutDownInProgress)
{
cout << "Server recieved message: " << message << endl; fflush(stdout);
}
}
}

Expand All @@ -71,21 +71,21 @@ THREAD_RET_TYPE threadServerTransfer(void*)

while(run)
{
string message;

if(!s2.recv(message))
{
if (!shutDownInProgress)
{
cout << "threadServerTransfer: Failed to recieve message!" << endl; fflush(stdout);
return 0;
}
}

if (!shutDownInProgress)
{
cout << "Server recieved message: " << message << endl; fflush(stdout);
}
string message;

if(!s2.recv(message))
{
if (!shutDownInProgress)
{
cout << "threadServerTransfer: Failed to recieve message!" << endl; fflush(stdout);
return 0;
}
}

if (!shutDownInProgress)
{
cout << "Server recieved message: " << message << endl; fflush(stdout);
}
}
}

Expand All @@ -99,89 +99,89 @@ THREAD_RET_TYPE threadControlClient(void*)

for(; retries_left >= 0; --retries_left)
{
if(!s1.connect("127.0.0.1", 10501))
{
if(retries_left)
{
cout << "Connect failed, retrying to connect to 127.0.0.1:10501 after 2 seconds" << endl; fflush(stdout);
delay(2000);
continue;
}
else
{
cout << "Connect failed, max number of retries reached." << endl; fflush(stdout);
run = false;
cout << "Exiting..." << endl; fflush(stdout);
exit(1);
}
}

break;
if(!s1.connect("127.0.0.1", 10501))
{
if(retries_left)
{
cout << "Connect failed, retrying to connect to 127.0.0.1:10501 after 2 seconds" << endl; fflush(stdout);
delay(2000);
continue;
}
else
{
cout << "Connect failed, max number of retries reached." << endl; fflush(stdout);
run = false;
cout << "Exiting..." << endl; fflush(stdout);
exit(1);
}
}

break;
}


while(true)
{
string message;
cout << "Enter operation to be sent to server: " << endl; fflush(stdout);
if (!fileName) // no file, read from stdin
{
cin >> message;
}
else // some file, read from it
{
if (!fileStream->eof())
{
(*fileStream) >> message;
}
else
{
cout << "End of commands file: " << fileName->c_str() << " has been reached!" << endl; fflush(stdout);
cout << "Sending \"end\" to the server and exiting ..." << endl; fflush(stdout);
message = "";
}
}

if (!message.empty())
{
if (!message.compare(0,5,"delay")) // delay
{
// we have a delay in the text, see how much
string delayTime = message.substr(5,message.size()-5);
cout << "Command to delay the client for: " << delayTime << " seconds." << endl; fflush(stdout);
delay(atoi(delayTime.c_str()) * 1000);
cout << "End delay of " << delayTime << " seconds." << endl; fflush(stdout);
}
else // send the message
{
cout << "Message to be send: " << message << endl; fflush(stdout);

// set the shutDownInProgress flag so we don't get failure on receive messages
// from the transfer thread and server control thread
if(message.compare(0, 8, "shutdown") == 0)
{
shutDownInProgress = 1;
}

if(!s1.send(message))
{
cout << "Failed to send message!" << endl; fflush(stdout);
break;
}

if(message.compare(0, 8, "shutdown") == 0)
{
cout << "Shuting down in 2 seconds .... due to shutdown message: " << message << endl; fflush(stdout);
shutDownInProgress = 1;
delay(2000);
break;
}
}
}
else
{
cout << "Message: [is empty]" << endl; fflush(stdout);
}
string message;
cout << "Enter operation to be sent to server: " << endl; fflush(stdout);
if (!fileName) // no file, read from stdin
{
cin >> message;
}
else // some file, read from it
{
if (!fileStream->eof())
{
(*fileStream) >> message;
}
else
{
cout << "End of commands file: " << fileName->c_str() << " has been reached!" << endl; fflush(stdout);
cout << "Sending \"end\" to the server and exiting ..." << endl; fflush(stdout);
message = "";
}
}

if (!message.empty())
{
if (!message.compare(0,5,"delay")) // delay
{
// we have a delay in the text, see how much
string delayTime = message.substr(5,message.size()-5);
cout << "Command to delay the client for: " << delayTime << " seconds." << endl; fflush(stdout);
delay(atoi(delayTime.c_str()) * 1000);
cout << "End delay of " << delayTime << " seconds." << endl; fflush(stdout);
}
else // send the message
{
cout << "Message to be send: " << message << endl; fflush(stdout);

// set the shutDownInProgress flag so we don't get failure on receive messages
// from the transfer thread and server control thread
if(message.compare(0, 8, "shutdown") == 0)
{
shutDownInProgress = 1;
}

if(!s1.send(message))
{
cout << "Failed to send message!" << endl; fflush(stdout);
break;
}

if(message.compare(0, 8, "shutdown") == 0)
{
cout << "Shuting down in 2 seconds .... due to shutdown message: " << message << endl; fflush(stdout);
shutDownInProgress = 1;
delay(2000);
break;
}
}
}
else
{
cout << "Message: [is empty]" << endl; fflush(stdout);
}
}

run = false;
Expand All @@ -192,19 +192,19 @@ int main(int argc, char **argv)
{
if (argc == 2)
{
if (strcmp(argv[1], "-help") == 0 && strcmp(argv[1], "/?") == 0)
{
cout << "usage: client [file-with-commands.txt] [-help|/?]" << endl; fflush(stdout);
exit(1);
}
fileName = new string(argv[1]);
fileStream = new fstream(fileName->c_str(), fstream::in);
if (fileStream->fail())
{
cout << "Unable to open file: " << fileName->c_str() << "!" << endl; fflush(stdout);
cout << "usage: client [file-with-commands.txt] [-help|/?]" << endl; fflush(stdout);
exit(1);
}
if (strcmp(argv[1], "-help") == 0 && strcmp(argv[1], "/?") == 0)
{
cout << "usage: client [file-with-commands.txt] [-help|/?]" << endl; fflush(stdout);
exit(1);
}
fileName = new string(argv[1]);
fileStream = new fstream(fileName->c_str(), fstream::in);
if (fileStream->fail())
{
cout << "Unable to open file: " << fileName->c_str() << "!" << endl; fflush(stdout);
cout << "usage: client [file-with-commands.txt] [-help|/?]" << endl; fflush(stdout);
exit(1);
}
}

Thread serverControl;
Expand All @@ -224,7 +224,7 @@ int main(int argc, char **argv)

if (fileName)
{
fileStream->close();
fileStream->close();
}

return 0;
Expand Down

0 comments on commit 3940412

Please sign in to comment.