You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.3 KiB

  1. // -*- C++ -*-
  2. // Module: Log4CPLUS
  3. // File: env.h
  4. // Created: 7/2010
  5. // Author: Vaclav Haisman
  6. //
  7. //
  8. // Copyright (C) 2010, Vaclav Haisman. All rights reserved.
  9. //
  10. // Redistribution and use in source and binary forms, with or without modifica-
  11. // tion, are permitted provided that the following conditions are met:
  12. //
  13. // 1. Redistributions of source code must retain the above copyright notice,
  14. // this list of conditions and the following disclaimer.
  15. //
  16. // 2. Redistributions in binary form must reproduce the above copyright notice,
  17. // this list of conditions and the following disclaimer in the documentation
  18. // and/or other materials provided with the distribution.
  19. //
  20. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  21. // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22. // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  24. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  25. // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  27. // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #ifndef LOG4CPLUS_INTERNAL_ENV_H
  31. #define LOG4CPLUS_INTERNAL_ENV_H
  32. #include <log4cplus/config.hxx>
  33. #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
  34. #pragma once
  35. #endif
  36. #include <log4cplus/tstring.h>
  37. #if defined (_WIN32)
  38. #include <log4cplus/config/windowsh-inc.h>
  39. #endif
  40. #ifdef LOG4CPLUS_HAVE_SYS_TYPES_H
  41. #include <sys/types.h>
  42. #endif
  43. #ifdef LOG4CPLUS_HAVE_UNISTD_H
  44. #include <unistd.h>
  45. #endif
  46. namespace log4cplus { namespace internal {
  47. bool get_env_var (tstring & value, tstring const & name);
  48. bool parse_bool (bool & val, tstring const & str);
  49. inline
  50. #if defined (_WIN32)
  51. DWORD
  52. get_process_id ()
  53. {
  54. return GetCurrentProcessId ();
  55. }
  56. #elif defined (LOG4CPLUS_HAVE_GETPID)
  57. pid_t
  58. get_process_id ()
  59. {
  60. return getpid ();
  61. }
  62. #else
  63. int
  64. get_process_id ()
  65. {
  66. return 0;
  67. }
  68. #endif
  69. } } // namespace log4cplus { namespace internal {
  70. #endif // LOG4CPLUS_INTERNAL_ENV_H