1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : Basics_Utils.cxx
21 // Autor : Alexander A. BORODIN
25 #include "Basics_Utils.hxx"
36 namespace Kernel_Utils
38 std::string GetHostname()
43 while (ls < 10000 && r)
47 r = gethostname(s, ls-1);
71 strcpy(s, "localhost");
74 // remove all after '.'
75 char *aDot = (strchr(s,'.'));
76 if (aDot) aDot[0] = '\0';
83 Localizer::Localizer()
85 myCurLocale = setlocale(LC_NUMERIC, 0);
86 setlocale(LC_NUMERIC, "C");
89 Localizer::~Localizer()
91 setlocale(LC_NUMERIC, myCurLocale.c_str());
94 std::string GetGUID( GUIDtype type )
100 guid = "FFFFFFFF-D9CD-11d6-945D-1050DA506788"; break;
102 guid = "C08F3C95-F112-4023-8776-78F1427D0B6D"; break;
109 void print_traceback()
116 size = backtrace (array, 40);
117 strings = backtrace_symbols (array, size);
119 for (i = 0; i < size; i++)
121 std::cerr << strings[i] << std::endl;
127 #if (_MSC_VER >= 1400) // Visual Studio 2005
129 int setenv(const char *name, const char *value, int rewrite)
\r
131 std::stringstream sstr;
\r
132 sstr<<name<<'='<<value;
\r
133 if(rewrite || std::string(getenv(name)).length() == 0)
\r
134 return _putenv(sstr.str().c_str());
\r