X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FUtils%2FOpUtil.cxx;h=7e0dc3c7d2fb5d25ab6769b168f1ab9d06ee7fc9;hb=20c132438f5b8f7337bf35272989b10eb003d71c;hp=28f95b6605baec85cbe6556e5e7c6661239d2c63;hpb=1bd1d38e86c39b13e265f8ff534fc1463c25fef3;p=modules%2Fkernel.git diff --git a/src/Utils/OpUtil.cxx b/src/Utils/OpUtil.cxx index 28f95b660..7e0dc3c7d 100644 --- a/src/Utils/OpUtil.cxx +++ b/src/Utils/OpUtil.cxx @@ -1,78 +1,48 @@ -// SALOME Utils : general SALOME's definitions and tools +// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// SALOME Utils : general SALOME's definitions and tools // File : OpUtil.cxx // Module : SALOME - -#include "utilities.h" +// #include "OpUtil.hxx" -#include -#include +#include -#ifndef WNT -#include -#else -#include -#endif -using namespace std; -//int gethostname(char *name, size_t len); +#if !defined(SALOME_LIGHT) -std::string GetHostname() -{ - int ls = 100, r = 1; - char *s; +#include "Utils_SINGLETON.hxx" +#include "Utils_ORB_INIT.hxx" - while (ls < 10000 && r) { - ls *= 2; - s = new char[ls]; - r = gethostname(s, ls-1); - switch (r) - { - case 0: - break; - default: -#ifdef EINVAL - case EINVAL: -#endif -#ifdef ENAMETOOLONG - case ENAMETOOLONG: -#endif - delete [] s; - continue; - } - } - - if (r != 0) { - s = new char[50]; - strcpy(s, "localhost"); - } - - // remove all after '.' - char *aDot = (strchr(s,'.')); - if (aDot) aDot[0] = '\0'; +namespace +{ + std::recursive_mutex mutex; //!< mutex to protect access to static data +} - string p = s; - delete [] s; - return p; +UTILS_EXPORT CORBA::ORB_var KERNEL::GetRefToORB() +{ + std::lock_guard g(mutex); + ORB_INIT &init = *SINGLETON_::Instance(); + CORBA::ORB_var orb = init(); + return orb; } +#endif