log4cplus
1.1.0
|
00001 // -*- C++ -*- 00002 // Module: Log4CPLUS 00003 // File: env.h 00004 // Created: 7/2010 00005 // Author: Vaclav Haisman 00006 // 00007 // 00008 // Copyright (C) 2010, Vaclav Haisman. All rights reserved. 00009 // 00010 // Redistribution and use in source and binary forms, with or without modifica- 00011 // tion, are permitted provided that the following conditions are met: 00012 // 00013 // 1. Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // 2. Redistributions in binary form must reproduce the above copyright notice, 00017 // this list of conditions and the following disclaimer in the documentation 00018 // and/or other materials provided with the distribution. 00019 // 00020 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00021 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00022 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00023 // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00024 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 00025 // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00026 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00027 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00029 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 00031 #ifndef LOG4CPLUS_INTERNAL_ENV_H 00032 #define LOG4CPLUS_INTERNAL_ENV_H 00033 00034 #include <log4cplus/config.hxx> 00035 00036 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00037 #pragma once 00038 #endif 00039 00040 #include <log4cplus/tstring.h> 00041 00042 #if defined (_WIN32) 00043 #include <log4cplus/config/windowsh-inc.h> 00044 #endif 00045 #ifdef LOG4CPLUS_HAVE_SYS_TYPES_H 00046 #include <sys/types.h> 00047 #endif 00048 #ifdef LOG4CPLUS_HAVE_UNISTD_H 00049 #include <unistd.h> 00050 #endif 00051 00052 00053 namespace log4cplus { namespace internal { 00054 00055 00056 bool get_env_var (tstring & value, tstring const & name); 00057 bool parse_bool (bool & val, tstring const & str); 00058 00059 inline 00060 #if defined (_WIN32) 00061 DWORD 00062 get_process_id () 00063 { 00064 return GetCurrentProcessId (); 00065 } 00066 00067 #elif defined (LOG4CPLUS_HAVE_GETPID) 00068 pid_t 00069 get_process_id () 00070 { 00071 return getpid (); 00072 } 00073 00074 #else 00075 int 00076 get_process_id () 00077 { 00078 return 0; 00079 } 00080 00081 #endif 00082 00083 00084 } } // namespace log4cplus { namespace internal { 00085 00086 00087 #endif // LOG4CPLUS_INTERNAL_ENV_H