diff --git a/Common/GmshSocket.h b/Common/GmshSocket.h index 9ab9ad90c335f08af887cde824b1ebd1fc651f8a..7686c333ab65a15e2a326667dd0a049a7e0b3069 100644 --- a/Common/GmshSocket.h +++ b/Common/GmshSocket.h @@ -40,20 +40,20 @@ class GmshSocket{ // receive data from a machine with a different byte ordering, and // we swap the bytes in the payload) enum MessageType{ - START = 1, - STOP = 2, - INFO = 10, - WARNING = 11, - ERROR = 12, - PROGRESS = 13, - MERGE_FILE = 20, - PARSE_STRING = 21, - SPEED_TEST = 30, - OPTION_1 = 100, - OPTION_2 = 101, - OPTION_3 = 102, - OPTION_4 = 103, - OPTION_5 = 104}; + GMSH_START = 1, + GMSH_STOP = 2, + GMSH_INFO = 10, + GMSH_WARNING = 11, + GMSH_ERROR = 12, + GMSH_PROGRESS = 13, + GMSH_MERGE_FILE = 20, + GMSH_PARSE_STRING = 21, + GMSH_SPEED_TEST = 30, + GMSH_OPTION_1 = 100, + GMSH_OPTION_2 = 101, + GMSH_OPTION_3 = 102, + GMSH_OPTION_4 = 103, + GMSH_OPTION_5 = 104}; protected: // the socket descriptor int _sock; @@ -147,18 +147,18 @@ class GmshSocket{ // send body _SendData(str, len); } - void Info(const char *str){ SendString(INFO, str); } - void Warning(const char *str){ SendString(WARNING, str); } - void Error(const char *str){ SendString(ERROR, str); } - void Progress(const char *str){ SendString(PROGRESS, str); } - void MergeFile(const char *str){ SendString(MERGE_FILE, str); } - void ParseString(const char *str){ SendString(PARSE_STRING, str); } - void SpeedTest(const char *str){ SendString(SPEED_TEST, str); } + void Info(const char *str){ SendString(GMSH_INFO, str); } + void Warning(const char *str){ SendString(GMSH_WARNING, str); } + void Error(const char *str){ SendString(GMSH_ERROR, str); } + void Progress(const char *str){ SendString(GMSH_PROGRESS, str); } + void MergeFile(const char *str){ SendString(GMSH_MERGE_FILE, str); } + void ParseString(const char *str){ SendString(GMSH_PARSE_STRING, str); } + void SpeedTest(const char *str){ SendString(GMSH_SPEED_TEST, str); } void Option(int num, const char *str) { if(num < 1) num = 1; if(num > 5) num = 5; - SendString(OPTION_1 + num - 1, str); + SendString(GMSH_OPTION_1 + num - 1, str); } int ReceiveHeader(int *type, int *len) { @@ -197,7 +197,9 @@ class GmshSocket{ } void ShutdownSocket(int s) { +#if !defined(WIN32) || defined(__CYGWIN__) shutdown(s, SHUT_RDWR); +#endif } }; @@ -269,9 +271,9 @@ class GmshClient : public GmshSocket { #else sprintf(tmp, "%d", _getpid()); #endif - SendString(START, tmp); + SendString(GMSH_START, tmp); } - void Stop(){ SendString(STOP, "Goodbye!"); } + void Stop(){ SendString(GMSH_STOP, "Goodbye!"); } void Disconnect(){ CloseSocket(_sock); } }; diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index b674befc1889e4b9ade944f4bf3eb5e51e5452b0..166d53dbb677bc940d4e3c6950e5c3b6c2a50365 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -165,7 +165,8 @@ static void file_remote_cb(Fl_Widget *w, void *data) else if(str == "stop"){ if(GmshRemote::get(99)->getServer()){ Msg::Info("Stopping remote Gmsh server"); - GmshRemote::get(99)->getServer()->SendString(GmshSocket::STOP, "DISCONNECTING!"); + GmshRemote::get(99)->getServer()->SendString + (GmshSocket::GMSH_STOP, "DISCONNECTING!"); } else{ Msg::Error("Cannot stop remote Gmsh: server not running"); diff --git a/Fltk/solverWindow.cpp b/Fltk/solverWindow.cpp index d2f854eec8b7ccee155ed8f7026e2305e1a58a8a..e8b322075e43b6a39bffbd5921c3075cee02c6b0 100644 --- a/Fltk/solverWindow.cpp +++ b/Fltk/solverWindow.cpp @@ -140,53 +140,53 @@ void GmshRemote::run(std::string args) char *message = new char[length + 1]; if(server->ReceiveString(length, message)){ switch (type) { - case GmshSocket::START: + case GmshSocket::GMSH_START: _pid = atoi(message); _server = server; break; - case GmshSocket::STOP: + case GmshSocket::GMSH_STOP: _pid = -1; _server = 0; break; - case GmshSocket::PROGRESS: + case GmshSocket::GMSH_PROGRESS: Msg::StatusBar(2, false, "%s %s", name.c_str(), message); break; - case GmshSocket::OPTION_1: + case GmshSocket::GMSH_OPTION_1: if(initOption[0]){ optionValue[0].clear(); initOption[0] = false; } optionValue[0].push_back(message); break; - case GmshSocket::OPTION_2: + case GmshSocket::GMSH_OPTION_2: if(initOption[1]){ optionValue[1].clear(); initOption[1] = false; } optionValue[1].push_back(message); break; - case GmshSocket::OPTION_3: + case GmshSocket::GMSH_OPTION_3: if(initOption[2]){ optionValue[2].clear(); initOption[2] = false; } optionValue[2].push_back(message); break; - case GmshSocket::OPTION_4: + case GmshSocket::GMSH_OPTION_4: if(initOption[3]){ optionValue[3].clear(); initOption[3] = false; } optionValue[3].push_back(message); break; - case GmshSocket::OPTION_5: + case GmshSocket::GMSH_OPTION_5: if(initOption[4]){ optionValue[4].clear(); initOption[4] = false; } optionValue[4].push_back(message); break; - case GmshSocket::MERGE_FILE: + case GmshSocket::GMSH_MERGE_FILE: if(mergeViews) { int n = PView::list.size(); MergeFile(message); @@ -195,20 +195,20 @@ void GmshRemote::run(std::string args) FlGui::instance()->menu->setContext(menu_post, 0); } break; - case GmshSocket::PARSE_STRING: + case GmshSocket::GMSH_PARSE_STRING: ParseString(message); drawContext::global()->draw(); break; - case GmshSocket::INFO: + case GmshSocket::GMSH_INFO: Msg::Direct("%-8.8s: %s", name.c_str(), message); break; - case GmshSocket::WARNING: + case GmshSocket::GMSH_WARNING: Msg::Direct(2, "%-8.8s: %s", name.c_str(), message); break; - case GmshSocket::ERROR: + case GmshSocket::GMSH_ERROR: Msg::Direct(1, "%-8.8s: %s", name.c_str(), message); break; - case GmshSocket::SPEED_TEST: + case GmshSocket::GMSH_SPEED_TEST: Msg::Info("got %d Mb message in %g seconds", strlen(message) / 1024 / 1024, GetTimeInSeconds() - timer); break; @@ -368,7 +368,7 @@ static void solver_choose_mesh_cb(Fl_Widget *w, void *data) static int numPercentS(std::string &in) { int n = 0; - for(int i = 0; i < in.size() - 1; i++) { + for(int i = 0; i < (int)in.size() - 1; i++) { if(in[i] == '%' && in[i + 1] == 's') { i++; n++; @@ -410,7 +410,7 @@ solverWindow::solverWindow(int solverIndex, int deltaFontSize) FL_NORMAL_SIZE -= deltaFontSize; int numOptions = GmshRemote::get(solverIndex)->optionName.size(); - for(int i = 0; i < GmshRemote::get(solverIndex)->optionName.size(); i++){ + for(unsigned int i = 0; i < GmshRemote::get(solverIndex)->optionName.size(); i++){ if(GmshRemote::get(solverIndex)->optionName[i].empty()){ numOptions = i; break; @@ -479,7 +479,7 @@ solverWindow::solverWindow(int solverIndex, int deltaFontSize) } static int arg[5][5][2]; - for(int i = 0; i < GmshRemote::get(solverIndex)->buttonName.size(); i++) { + for(unsigned int i = 0; i < GmshRemote::get(solverIndex)->buttonName.size(); i++) { if(GmshRemote::get(solverIndex)->buttonName[i].size()){ arg[solverIndex][i][0] = solverIndex; arg[solverIndex][i][1] = i;