carnold     2005/03/11 22:37:27

  Modified:    .        apriconv-build.xml aprutil-build.xml build.xml
               include/log4cxx/helpers msxml.h transcoder.h
               include/log4cxx/nt nteventlogappender.h
               src      msxml.cpp nteventlogappender.cpp
                        outputdebugstringappender.cpp transcoder.cpp
               tests/src/nt nteventlogappendertestcase.cpp
  Log:
  LOGCXX-10: no wchar_t support continued
  
  Revision  Changes    Path
  1.11      +11 -5     logging-log4cxx/apriconv-build.xml
  
  Index: apriconv-build.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/apriconv-build.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- apriconv-build.xml        11 Mar 2005 15:17:07 -0000      1.10
  +++ apriconv-build.xml        12 Mar 2005 06:37:27 -0000      1.11
  @@ -80,7 +80,8 @@
   <target name="win-init" depends="os-detect" if="is-windows">
       <property name="compiler" value="msvc"/>
       <property name="arch" value="win32"/>
  -    <property name="project.type" value="msvc6"/>
  +    <property name="project.type" value="msvc6"/>
  +    <property name="apriconv.mod.suffix" value=".so"/>
   </target>
   
   <target name="unix-init" depends="os-detect" if="is-unix">
  @@ -93,6 +94,7 @@
       </condition>
       <property name="arch" value="unix"/>
       <property name="project.type" value="cbuilderx"/>
  +    <property name="apriconv.mod.suffix" value=".so"/>
   </target>
   
   <target name="init" depends="win-init, unix-init">
  @@ -118,6 +120,9 @@
           <condition property="is-bcc" value="true">
               <equals arg1="${compiler}" arg2="bcc"/>
           </condition>
  +        <condition property="is-msvc" value="true">
  +            <equals arg1="${compiler}" arg2="msvc"/>
  +        </condition>
   
           <condition property="is-apr-shared" value="true">
               <equals arg1="${apr.lib.type}" arg2="shared"/>
  @@ -195,7 +200,7 @@
   <target name="build-module" depends="init">
       <basename file="${module.src}" property="module" suffix="c"/>
       <cc name="${compiler}"
  -        outfile="${apriconv.lib.dir}/${module}"
  +        outfile="${apriconv.lib.dir}/${module}${apriconv.mod.suffix}"
           subsystem="console"
           multithreaded="true"
           outtype="shared"
  @@ -206,7 +211,7 @@
           <includepath path="${apriconv.dir}/lib"/>
           <includepath path="${apr.include.dir}"/>
           <includepath path="${apr.include.dir}/private"/>
  -        <defineset define="API_DECLARE_EXPORT"/>
  +        <defineset define="API_DECLARE_STATIC" unless="is-apriconv-shared"/>
           <defineset define="APR_DECLARE_STATIC" unless="is-apr-shared"/>
           <defineset define="WIN32" if="is-windows"/>
           <defineset define="_HAVE_CONFIG_H _REENTRANT _GNU_SOURCE" 
if="is-gcc"/>
  @@ -214,8 +219,9 @@
           <libset libs="apriconv${lib-suffix}" dir="${apriconv.lib.dir}"/>
           <libset libs="apr-1${lib-suffix}" dir="${apr.lib.dir}"/>
           <libset libs="advapi32 ws2_32 mswsock rpcrt4" if="is-windows"/>
  -        <libset libs="cw32mt" if="is-bcc"/>
  -        <project type="${project.type}" outfile="${project.dir}/${module}" 
if="project.if"/>
  +        <libset libs="cw32mt" if="is-bcc"/>
  +        <linkerarg value="/export:iconv_module,DATA" if="is-msvc"/>
  +        <project type="${project.type}" 
outfile="${project.dir}/${module}${apriconv.mod.suffix}" if="project.if"/>
       </cc>
   </target>
   
  
  
  
  1.13      +2 -2      logging-log4cxx/aprutil-build.xml
  
  Index: aprutil-build.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/aprutil-build.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- aprutil-build.xml 11 Mar 2005 15:17:07 -0000      1.12
  +++ aprutil-build.xml 12 Mar 2005 06:37:27 -0000      1.13
  @@ -215,8 +215,8 @@
           <includepath path="${aprutil.dir}/xml/expat"/>
           <defineset define="APU_DECLARE_EXPORT" if="is-aprutil-shared"/>
           <defineset define="APU_DECLARE_STATIC" unless="is-aprutil-shared"/>
  -        <defineset define="API_DECLARE_STATIC" if="is-apriconv-shared"/>
  -        <defineset define="APR_DECLARE_STATIC" if="is-apr-shared"/>
  +        <defineset define="API_DECLARE_STATIC" unless="is-apriconv-shared"/>
  +        <defineset define="APR_DECLARE_STATIC" unless="is-apr-shared"/>
           <defineset define="WIN32" if="is-windows"/>
           <defineset define="_HAVE_CONFIG_H _REENTRANT _GNU_SOURCE" 
if="is-gcc"/>
           <compilerarg value="${pic-option}" if="pic-option"/>
  
  
  
  1.50      +10 -5     logging-log4cxx/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/build.xml,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- build.xml 11 Mar 2005 15:17:07 -0000      1.49
  +++ build.xml 12 Mar 2005 06:37:27 -0000      1.50
  @@ -181,7 +181,7 @@
       <property name="has-iconv" value="true"/>
       <condition property="has-expat" value="true">
            <not><isset property="is-mac"/></not>
  -    </condition>    
  +    </condition>
   </target>
   
   
  @@ -604,6 +604,7 @@
           <defineset define="_USRDLL DLL_EXPORTS" if="is-windows"/>
           <defineset define="LOG4CXX"/>
           <defineset define="APR_DECLARE_STATIC" if="apr-static"/>
  +        <defineset define="API_DECLARE_STATIC" if="apriconv-static"/>
           <defineset define="APU_DECLARE_STATIC" if="aprutil-static"/>
           <defineset define="WIN32" if="is-windows"/>
           <defineset if="is-utf8">
  @@ -620,13 +621,13 @@
           <libset libs="iconv" if="is-unix"/>
           <libset libs="${apr.lib.name}${lib-suffix}" dir="${apr.lib.dir}" 
if="apr.lib.dir"/>
           <libset libs="${apr.lib.name}${lib-suffix}" unless="apr.lib.dir"/>
  -        <libset libs="${aprutil.lib.name}${lib-suffix}" 
dir="${aprutil.lib.dir}" if="aprutil.lib.dir"/>
  -        <libset libs="${aprutil.lib.name}${lib-suffix}" 
unless="aprutil.lib.dir"/>
  -
           <libset libs="${apriconv.lib.name}${lib-suffix}"
                  dir="${apriconv.lib.dir}" if="apriconv.lib.dir"/>
           <libset libs="${apriconv.lib.name}${lib-suffix}"
                   unless="apriconv.lib.dir"/>
  +        <libset libs="${aprutil.lib.name}${lib-suffix}" 
dir="${aprutil.lib.dir}" if="aprutil.lib.dir"/>
  +        <libset libs="${aprutil.lib.name}${lib-suffix}" 
unless="aprutil.lib.dir"/>
  +
           <syslibset libs="pthread" if="is-unix"/>
           <project type="${project.type}" outfile="${project.dir}/log4cxx" 
if="project.if"/>
       </cc>
  @@ -651,7 +652,7 @@
           <defineset define="WIN32" if="is-windows"/>
           <defineset define="APR_DECLARE_STATIC" if="apr-static"/>
           <defineset define="APU_DECLARE_STATIC" if="aprutil-static"/>
  -        <defineset define="API_DECLARE_STATIC" if="iconv-static"/>
  +        <defineset define="API_DECLARE_STATIC" if="apriconv-static"/>
           <defineset if="is-utf8">
               <define name="LOG4CXX_LOGCHAR_IS_UTF8" value="1"/>
           </defineset>
  @@ -815,6 +816,8 @@
           <includepath path="${aprutil.include.dir}"/>
           <includepath path="${apriconv.include.dir}"/>
           <defineset define="APR_DECLARE_STATIC" if="apr-static"/>
  +        <defineset define="API_DECLARE_STATIC" if="apriconv-static"/>
  +        <defineset define="APU_DECLARE_STATIC" if="aprutil-static"/>
           <defineset define="WIN32" if="is-windows"/>
           <defineset if="is-utf8">
               <define name="LOG4CXX_LOGCHAR_IS_UTF8" value="1"/>
  @@ -870,6 +873,8 @@
           <includepath path="${aprutil.include.dir}"/>
           <includepath path="${apriconv.include.dir}"/>
           <defineset define="APR_DECLARE_STATIC" if="apr-static"/>
  +        <defineset define="API_DECLARE_STATIC" if="apriconv-static"/>
  +        <defineset define="APU_DECLARE_STATIC" if="aprutil-static"/>
           <defineset define="WIN32" if="is-windows"/>
           <defineset if="is-utf8">
               <define name="LOG4CXX_LOGCHAR_IS_UTF8" value="1"/>
  
  
  
  1.14      +1 -0      logging-log4cxx/include/log4cxx/helpers/msxml.h
  
  Index: msxml.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/msxml.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- msxml.h   15 Feb 2005 23:55:59 -0000      1.13
  +++ msxml.h   12 Mar 2005 06:37:27 -0000      1.14
  @@ -78,6 +78,7 @@
                           virtual XMLDOMElementPtr getDocumentElement();
                           virtual XMLDOMElementPtr getElementById(const 
LogString& tagName, const LogString& elementId);
   
  +                        static LogString decode(BSTR str);
                   protected:
                           MSXML::IXMLDOMDocumentPtr document;
                           bool mustCallCoUninitialize;
  
  
  
  1.10      +0 -6      logging-log4cxx/include/log4cxx/helpers/transcoder.h
  
  Index: transcoder.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/transcoder.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- transcoder.h      11 Mar 2005 06:34:49 -0000      1.9
  +++ transcoder.h      12 Mar 2005 06:37:27 -0000      1.10
  @@ -51,12 +51,6 @@
           decode(src.data(), src.length(), dst);
         }
   
  -      /**
  -      *   Determines if the buffer contains Unicode or multibyte
  -      *     and returns equivalent internal string.
  -      */
  -      static void decode(const void* src, size_t byteCount,
  -            LogString& dst);
   
         static LogString decode(const std::string& src) {
           LogString dst;
  
  
  
  1.19      +108 -108  logging-log4cxx/include/log4cxx/nt/nteventlogappender.h
  
  Index: nteventlogappender.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/nt/nteventlogappender.h,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- nteventlogappender.h      3 Mar 2005 19:27:44 -0000       1.18
  +++ nteventlogappender.h      12 Mar 2005 06:37:27 -0000      1.19
  @@ -1,114 +1,114 @@
  -/*
  - * Copyright 2003,2005 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -#ifndef _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
  -#define _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
  -
  -#include <log4cxx/appenderskeleton.h>
  -
  -
  -namespace log4cxx
  -{
  -        namespace nt
  -        {
  -                /**
  -                 * Appends log events to NT EventLog.
  -                 */
  -                class LOG4CXX_EXPORT NTEventLogAppender : public 
AppenderSkeleton
  -                {
  -                public:
  -                        DECLARE_LOG4CXX_OBJECT(NTEventLogAppender)
  -                        BEGIN_LOG4CXX_CAST_MAP()
  -                            LOG4CXX_CAST_ENTRY(NTEventLogAppender)
  -                            LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
  -                        END_LOG4CXX_CAST_MAP()
  -
  -                        NTEventLogAppender();
  -                        NTEventLogAppender(const LogString& server, const 
LogString& log,
  -                                const LogString& source, const LayoutPtr& 
layout);
  -
  -                        virtual ~NTEventLogAppender();
  -
  -                        virtual void activateOptions(log4cxx::helpers::Pool& 
p);
  -                        virtual void close();
  -                        virtual void setOption(const LogString& option, 
const LogString& value);
  -
  -                        /**
  -                         * The SocketAppender does not use a layout. Hence, 
this method
  -                         * returns <code>false</code>.
  -                         *
  -                         */
  -                         bool requiresLayout() const
  -                                { return true; }
  -
  -                        void setSource(const LogString& source)
  -                                { this->source.assign(source); }
  -
  -                        const LogString& getSource() const
  -                                { return source; }
  -
  -                        void setLog(const LogString& log)
  -                                { this->log.assign(log); }
  -
  -                        const LogString& getLog() const
  -                                { return log; }
  -
  -                        void setServer(const LogString& server)
  -                                { this->server.assign(server); }
  -
  -                        const LogString& getServer() const
  +/*
  + * Copyright 2003,2005 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#ifndef _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
  +#define _LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
  +
  +#include <log4cxx/appenderskeleton.h>
  +
  +
  +namespace log4cxx
  +{
  +        namespace nt
  +        {
  +                /**
  +                 * Appends log events to NT EventLog.
  +                 */
  +                class LOG4CXX_EXPORT NTEventLogAppender : public 
AppenderSkeleton
  +                {
  +                public:
  +                        DECLARE_LOG4CXX_OBJECT(NTEventLogAppender)
  +                        BEGIN_LOG4CXX_CAST_MAP()
  +                            LOG4CXX_CAST_ENTRY(NTEventLogAppender)
  +                            LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
  +                        END_LOG4CXX_CAST_MAP()
  +
  +                        NTEventLogAppender();
  +                        NTEventLogAppender(const LogString& server, const 
LogString& log,
  +                                const LogString& source, const LayoutPtr& 
layout);
  +
  +                        virtual ~NTEventLogAppender();
  +
  +                        virtual void activateOptions(log4cxx::helpers::Pool& 
p);
  +                        virtual void close();
  +                        virtual void setOption(const LogString& option, 
const LogString& value);
  +
  +                        /**
  +                         * The SocketAppender does not use a layout. Hence, 
this method
  +                         * returns <code>false</code>.
  +                         *
  +                         */
  +                         bool requiresLayout() const
  +                                { return true; }
  +
  +                        void setSource(const LogString& source)
  +                                { this->source.assign(source); }
  +
  +                        const LogString& getSource() const
  +                                { return source; }
  +
  +                        void setLog(const LogString& log)
  +                                { this->log.assign(log); }
  +
  +                        const LogString& getLog() const
  +                                { return log; }
  +
  +                        void setServer(const LogString& server)
  +                                { this->server.assign(server); }
  +
  +                        const LogString& getServer() const
                                   { return server; }
   
  -
  -                protected:
  -                        //
  -                        //   these typedef are proxies for the real Win32 
definitions
  -                        //     and need to be cast to the global definitions 
before
  -                        //     use with a Win32 API call
  -                        typedef void* HKEY;
  -                        typedef void SID;
  -                        typedef void* HANDLE;
  -
  -                        virtual void append(const spi::LoggingEventPtr& 
event, log4cxx::helpers::Pool& p);
  -                        static HKEY regGetKey(const std::wstring& subkey, 
unsigned long *disposition);
  -                        static void regSetString(HKEY hkey, const wchar_t* 
name, const wchar_t* value);
  -                        static void regSetDword(HKEY hkey, const wchar_t* 
name, unsigned long value);
  -                        unsigned short getEventType(const 
spi::LoggingEventPtr& event);
  -                        unsigned short getEventCategory(const 
spi::LoggingEventPtr& event);
  -                        /*
  -                         * Add this source with appropriate configuration 
keys to the registry.
  -                         */
  -                        void addRegistryInfo();
  -
  -                        // Data
  -                        LogString server;
  -                        LogString log;
  -                        LogString source;
  -                        HANDLE hEventLog;
  -                        SID * pCurrentUserSID;
  +
  +                protected:
  +                        //
  +                        //   these typedef are proxies for the real Win32 
definitions
  +                        //     and need to be cast to the global definitions 
before
  +                        //     use with a Win32 API call
  +                        typedef void* HKEY;
  +                        typedef void SID;
  +                        typedef void* HANDLE;
  +
  +                        virtual void append(const spi::LoggingEventPtr& 
event, log4cxx::helpers::Pool& p);
  +                        static HKEY regGetKey(const LogString& subkey, 
unsigned long *disposition);
  +                        static void regSetString(HKEY hkey, const wchar_t* 
name, const wchar_t* value);
  +                        static void regSetDword(HKEY hkey, const wchar_t* 
name, unsigned long value);
  +                        unsigned short getEventType(const 
spi::LoggingEventPtr& event);
  +                        unsigned short getEventCategory(const 
spi::LoggingEventPtr& event);
  +                        /*
  +                         * Add this source with appropriate configuration 
keys to the registry.
  +                         */
  +                        void addRegistryInfo();
  +
  +                        // Data
  +                        LogString server;
  +                        LogString log;
  +                        LogString source;
  +                        HANDLE hEventLog;
  +                        SID * pCurrentUserSID;
                           static LogString getErrorString(const LogString& 
function);
  -
  -                private:
  -                        NTEventLogAppender(const NTEventLogAppender&);
  -                        NTEventLogAppender& operator=(const 
NTEventLogAppender&);
  +
  +                private:
  +                        NTEventLogAppender(const NTEventLogAppender&);
  +                        NTEventLogAppender& operator=(const 
NTEventLogAppender&);
                   }; // class NTEventLogAppender
   
                   typedef helpers::ObjectPtrT<NTEventLogAppender> 
NTEventLogAppenderPtr;
  -
  -    }  // namespace nt
  -} // namespace log4cxx
  -
  -#endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
  +
  +    }  // namespace nt
  +} // namespace log4cxx
  +
  +#endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
  
  
  
  1.14      +34 -7     logging-log4cxx/src/msxml.cpp
  
  Index: msxml.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/msxml.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- msxml.cpp 15 Feb 2005 23:56:01 -0000      1.13
  +++ msxml.cpp 12 Mar 2005 06:37:27 -0000      1.14
  @@ -61,6 +61,7 @@
      return new MsXMLDOMDocument(document);
   }
   
  +
   // MsXMLDOMDocument
   
   MsXMLDOMDocument::MsXMLDOMDocument(MSXML::IXMLDOMDocumentPtr document)
  @@ -164,10 +165,16 @@
               len--;
            }
   
  -            std::wostringstream os;
  -            os << L"Count not open [" + fileName.getName() << L"] : "
  -                << (BSTR) reason << L"(file " << line << L", column "
  -                << linepos << L")";
  +            std::basic_ostringstream<logchar> os;
  +            os << LOG4CXX_STR("Count not open [")
  +               << fileName.getName()
  +               << LOG4CXX_STR("] : ")
  +               << decode(reason)
  +               << LOG4CXX_STR("(file ")
  +               << line
  +               << LOG4CXX_STR(", column ")
  +               << linepos
  +               << LOG4CXX_STR(")");
               LOGLOG_ERROR(os.str());
         }
   
  @@ -200,7 +207,8 @@
            MSXML::IXMLDOMNodePtr attrNode = map->getNamedItem(L"name");
            _bstr_t nodeValue = attrNode->nodeValue;
   
  -         if (elementId == (BSTR) nodeValue)
  +         LogString nodeStr = decode(nodeValue);
  +         if (elementId == nodeStr)
            {
               element = node;
               break;
  @@ -215,12 +223,32 @@
      return new MsXMLDOMElement(element);
   }
   
  +LogString MsXMLDOMDocument::decode(BSTR src) {
  +#if LOG4CXX_LOGCHAR_IS_WCHAR
  +    return src;
  +#else
  +    //
  +    //   extremely simplistic down-converter
  +    //      but should be sufficient for the needs of this class
  +    LogString dst;
  +    for (int i = 0; i < wcslen(src); i++) {
  +       if(src[i] <= 0x7F) {
  +         dst.append(1, (char) src[i]);
  +       } else {
  +         dst.append(1, '?');
  +       }
  +    }
  +    return dst;
  +#endif
  +}
  +
   // MsXMLDOMElement
   MsXMLDOMElement::MsXMLDOMElement(MSXML::IXMLDOMElementPtr element)
   : element(element)
   {
   }
   
  +
   XMLDOMNodeListPtr MsXMLDOMElement::getChildNodes()
   {
      MSXML::IXMLDOMNodeListPtr nodeList;
  @@ -239,8 +267,7 @@
   {
      try
      {
  -      _bstr_t tagName = element->tagName;
  -      return (BSTR)tagName;
  +      return MsXMLDOMDocument::decode(element->tagName);
      }
      catch(_com_error&)
      {
  
  
  
  1.17      +351 -308  logging-log4cxx/src/nteventlogappender.cpp
  
  Index: nteventlogappender.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/nteventlogappender.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- nteventlogappender.cpp    3 Mar 2005 19:27:44 -0000       1.16
  +++ nteventlogappender.cpp    12 Mar 2005 06:37:27 -0000      1.17
  @@ -1,177 +1,181 @@
  -/*
  - * Copyright 2003-2005 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -#if defined(WIN32) || defined(_WIN32)
  -
  -#include <windows.h>
  -#undef ERROR
  -#include <log4cxx/nt/nteventlogappender.h>
  -#include <log4cxx/spi/loggingevent.h>
  -#include <log4cxx/helpers/loglog.h>
  -#include <log4cxx/level.h>
  -#include <log4cxx/helpers/stringhelper.h>
  -#include <log4cxx/helpers/transcoder.h>
  +/*
  + * Copyright 2003-2005 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#if defined(WIN32) || defined(_WIN32)
  +
  +#include <windows.h>
  +#undef ERROR
  +#include <log4cxx/nt/nteventlogappender.h>
  +#include <log4cxx/spi/loggingevent.h>
  +#include <log4cxx/helpers/loglog.h>
  +#include <log4cxx/level.h>
  +#include <log4cxx/helpers/stringhelper.h>
  +#include <log4cxx/helpers/transcoder.h>
   #include <log4cxx/helpers/pool.h>
  -
  -using namespace log4cxx;
  -using namespace log4cxx::spi;
  -using namespace log4cxx::helpers;
  -using namespace log4cxx::nt;
  -
  -class CCtUserSIDHelper
  -{
  -public:
  -        static bool FreeSid(SID * pSid)
  -        {
  -                return ::HeapFree(GetProcessHeap(), 0, (LPVOID)pSid) != 0;
  -        }
  -
  -        static bool CopySid(SID * * ppDstSid, SID * pSrcSid)
  -        {
  -                bool bSuccess = false;
  -
  -                DWORD dwLength = ::GetLengthSid(pSrcSid);
  -                *ppDstSid = (SID *) ::HeapAlloc(GetProcessHeap(),
  -                 HEAP_ZERO_MEMORY, dwLength);
  -
  -                if (::CopySid(dwLength, *ppDstSid, pSrcSid))
  -                {
  -                        bSuccess = true;
  -                }
  -                else
  -                {
  -                        FreeSid(*ppDstSid);
  -                }
  -
  -                return bSuccess;
  -        }
  -
  -        static bool GetCurrentUserSID(SID * * ppSid)
  -        {
  -                bool bSuccess = false;
  -
  -                // Pseudohandle so don't need to close it
  -                HANDLE hProcess = ::GetCurrentProcess();
  -                HANDLE hToken = NULL;
  -                if (::OpenProcessToken(hProcess, TOKEN_QUERY, &hToken))
  -                {
  -                        // Get the required size
  -                        DWORD tusize = 0;
  -                        GetTokenInformation(hToken, TokenUser, NULL, 0, 
&tusize);
  -                        TOKEN_USER* ptu = (TOKEN_USER*)new BYTE[tusize];
  -
  -                        if (GetTokenInformation(hToken, TokenUser, 
(LPVOID)ptu, tusize, &tusize))
  -                        {
  -                                bSuccess = CopySid(ppSid, (SID 
*)ptu->User.Sid);
  -                        }
  -
  -                        CloseHandle(hToken);
  -                        delete [] ptu;
  -                }
  -
  -                return bSuccess;
  -        }
  -};
  -
  -IMPLEMENT_LOG4CXX_OBJECT(NTEventLogAppender)
  -
  -NTEventLogAppender::NTEventLogAppender() : hEventLog(NULL), 
pCurrentUserSID(NULL)
  -{
  -}
  -
  -NTEventLogAppender::NTEventLogAppender(const LogString& server, const 
LogString& log, const LogString& source, const LayoutPtr& layout)
  -: server(server), log(log), source(source), hEventLog(NULL), 
pCurrentUserSID(NULL)
  -{
  -        this->layout = layout;
  -        Pool pool;
  -        activateOptions(pool);
  -}
  -
  -NTEventLogAppender::~NTEventLogAppender()
  -{
  -        finalize();
  -}
  -
  -
  -void NTEventLogAppender::close()
  -{
  -        if (hEventLog != NULL)
  -        {
  -                ::DeregisterEventSource(hEventLog);
  -                hEventLog = NULL;
  -        }
  -
  -        if (pCurrentUserSID != NULL)
  -        {
  -                CCtUserSIDHelper::FreeSid((::SID*) pCurrentUserSID);
  -                pCurrentUserSID = NULL;
  -        }
  -}
  -
  -void NTEventLogAppender::setOption(const LogString& option, const LogString& 
value)
  -{
  -        if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SERVER"), 
LOG4CXX_STR("server")))
  -        {
  -                server = value;
  -        }
  -        else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOG"), 
LOG4CXX_STR("log")))
  -        {
  -                log = value;
  -        }
  -        else if (StringHelper::equalsIgnoreCase(option, 
LOG4CXX_STR("SOURCE"), LOG4CXX_STR("source")))
  -        {
  -                source = value;
  -        }
  -        else
  -        {
  -                AppenderSkeleton::setOption(option, value);
  -        }
  -}
  -
  -void NTEventLogAppender::activateOptions(Pool&)
  -{
  -        if (source.empty())
  -        {
  -                LogLog::warn(
  -             ((LogString) LOG4CXX_STR("Source option not set for appender 
["))
  -                + name + LOG4CXX_STR("]."));
  -                return;
  -        }
  -
  -        if (log.empty())
  -        {
  -                log = LOG4CXX_STR("Application");
  -        }
  -
  -        close();
  -
  -        // current user security identifier
  -        CCtUserSIDHelper::GetCurrentUserSID((::SID**) &pCurrentUserSID);
  -
  -        addRegistryInfo();
  -
  -        std::wstring wsource;
  -        Transcoder::encode(source, wsource);
  -        std::wstring wserver;
  -        const wchar_t* pServer = NULL;
  -        if (!server.empty()) {
  -            Transcoder::encode(server, wserver);
  -            pServer = wserver.c_str();
  +
  +using namespace log4cxx;
  +using namespace log4cxx::spi;
  +using namespace log4cxx::helpers;
  +using namespace log4cxx::nt;
  +
  +class CCtUserSIDHelper
  +{
  +public:
  +        static bool FreeSid(SID * pSid)
  +        {
  +                return ::HeapFree(GetProcessHeap(), 0, (LPVOID)pSid) != 0;
  +        }
  +
  +        static bool CopySid(SID * * ppDstSid, SID * pSrcSid)
  +        {
  +                bool bSuccess = false;
  +
  +                DWORD dwLength = ::GetLengthSid(pSrcSid);
  +                *ppDstSid = (SID *) ::HeapAlloc(GetProcessHeap(),
  +                 HEAP_ZERO_MEMORY, dwLength);
  +
  +                if (::CopySid(dwLength, *ppDstSid, pSrcSid))
  +                {
  +                        bSuccess = true;
  +                }
  +                else
  +                {
  +                        FreeSid(*ppDstSid);
  +                }
  +
  +                return bSuccess;
  +        }
  +
  +        static bool GetCurrentUserSID(SID * * ppSid)
  +        {
  +                bool bSuccess = false;
  +
  +                // Pseudohandle so don't need to close it
  +                HANDLE hProcess = ::GetCurrentProcess();
  +                HANDLE hToken = NULL;
  +                if (::OpenProcessToken(hProcess, TOKEN_QUERY, &hToken))
  +                {
  +                        // Get the required size
  +                        DWORD tusize = 0;
  +                        GetTokenInformation(hToken, TokenUser, NULL, 0, 
&tusize);
  +                        TOKEN_USER* ptu = (TOKEN_USER*)new BYTE[tusize];
  +
  +                        if (GetTokenInformation(hToken, TokenUser, 
(LPVOID)ptu, tusize, &tusize))
  +                        {
  +                                bSuccess = CopySid(ppSid, (SID 
*)ptu->User.Sid);
  +                        }
  +
  +                        CloseHandle(hToken);
  +                        delete [] ptu;
  +                }
  +
  +                return bSuccess;
  +        }
  +};
  +
  +IMPLEMENT_LOG4CXX_OBJECT(NTEventLogAppender)
  +
  +NTEventLogAppender::NTEventLogAppender() : hEventLog(NULL), 
pCurrentUserSID(NULL)
  +{
  +}
  +
  +NTEventLogAppender::NTEventLogAppender(const LogString& server, const 
LogString& log, const LogString& source, const LayoutPtr& layout)
  +: server(server), log(log), source(source), hEventLog(NULL), 
pCurrentUserSID(NULL)
  +{
  +        this->layout = layout;
  +        Pool pool;
  +        activateOptions(pool);
  +}
  +
  +NTEventLogAppender::~NTEventLogAppender()
  +{
  +        finalize();
  +}
  +
  +
  +void NTEventLogAppender::close()
  +{
  +        if (hEventLog != NULL)
  +        {
  +                ::DeregisterEventSource(hEventLog);
  +                hEventLog = NULL;
  +        }
  +
  +        if (pCurrentUserSID != NULL)
  +        {
  +                CCtUserSIDHelper::FreeSid((::SID*) pCurrentUserSID);
  +                pCurrentUserSID = NULL;
  +        }
  +}
  +
  +void NTEventLogAppender::setOption(const LogString& option, const LogString& 
value)
  +{
  +        if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SERVER"), 
LOG4CXX_STR("server")))
  +        {
  +                server = value;
           }
  -        hEventLog = ::RegisterEventSourceW(pServer, wsource.c_str());
  +        else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOG"), 
LOG4CXX_STR("log")))
  +        {
  +                log = value;
  +        }
  +        else if (StringHelper::equalsIgnoreCase(option, 
LOG4CXX_STR("SOURCE"), LOG4CXX_STR("source")))
  +        {
  +                source = value;
  +        }
  +        else
  +        {
  +                AppenderSkeleton::setOption(option, value);
  +        }
  +}
  +
  +void NTEventLogAppender::activateOptions(Pool&)
  +{
  +        if (source.empty())
  +        {
  +                LogLog::warn(
  +             ((LogString) LOG4CXX_STR("Source option not set for appender 
["))
  +                + name + LOG4CXX_STR("]."));
  +                return;
  +        }
  +
  +        if (log.empty())
  +        {
  +                log = LOG4CXX_STR("Application");
  +        }
  +
  +        close();
  +
  +        // current user security identifier
  +        CCtUserSIDHelper::GetCurrentUserSID((::SID**) &pCurrentUserSID);
  +
  +        addRegistryInfo();
  +
  +#if LOG4CXX_HAS_WCHAR_T
  +        LOG4CXX_ENCODE_WCHAR(wsource, source);
  +        LOG4CXX_ENCODE_WCHAR(wserver, server);
  +        hEventLog = ::RegisterEventSourceW(
  +            wserver.empty() ? NULL : wserver.c_str(),
  +            wsource.c_str());
  +#else
  +        LOG4CXX_ENCODE_CHAR(wsource, source);
  +        LOG4CXX_ENCODE_CHAR(wserver, server);
  +        hEventLog = ::RegisterEventSourceA(
  +            wserver.empty() ? NULL : wserver.c_str(),
  +            wsource.c_str());
  +#endif
           if (hEventLog == NULL) {
               LogString msg(LOG4CXX_STR("Cannot register NT EventLog -- 
server: '"));
               msg.append(server);
  @@ -180,141 +184,167 @@
               LogLog::error(msg);
               
LogLog::error(getErrorString(LOG4CXX_STR("RegisterEventSource")));
           }
  -}
  -
  -void NTEventLogAppender::append(const LoggingEventPtr& event, Pool& p)
  -{
  -        if (hEventLog == NULL)
  -        {
  -                LogLog::warn(LOG4CXX_STR("NT EventLog not opened."));
  -                return;
  -        }
  -
  -        LogString oss;
  -        layout->format(oss, event, p);
  -        std::wstring s;
  -        log4cxx::helpers::Transcoder::encode(oss, s);
  -        const wchar_t* msgs[1];
  -        msgs[0] = s.c_str() ;
  -        BOOL bSuccess = ::ReportEventW(
  -                hEventLog,
  -                getEventType(event),
  -                getEventCategory(event),
  -                0x1000,
  -                pCurrentUserSID,
  -                1,
  -                0,
  -            msgs,
  -                NULL);
  -
  -        if (!bSuccess)
  -        {
  -                LogLog::error(getErrorString(LOG4CXX_STR("ReportEvent")));
  -        }
  -}
  -
  -NTEventLogAppender::HKEY NTEventLogAppender::regGetKey(const std::wstring& 
subkey, DWORD *disposition)
  -{
  -        ::HKEY hkey = 0;
  -        RegCreateKeyExW((::HKEY) HKEY_LOCAL_MACHINE, subkey.c_str(), 0, NULL,
  -                REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
  -                &hkey, disposition);
  -        return hkey;
  -}
  -
  -void NTEventLogAppender::regSetString(HKEY hkey, const wchar_t*  name,
  -                                       const wchar_t* value)
  -{
  -        RegSetValueExW((::HKEY) hkey, name, 0, REG_SZ, (LPBYTE) value,
  -        wcslen(value)*sizeof(wchar_t));
  -}
  -
  -void NTEventLogAppender::regSetDword(HKEY hkey, const wchar_t* name, DWORD 
value)
  -{
  -        RegSetValueExW((::HKEY) hkey, name, 0, REG_DWORD, (LPBYTE)&value, 
sizeof(DWORD));
  -}
  -
  -/*
  - * Add this source with appropriate configuration keys to the registry.
  - */
  -void NTEventLogAppender::addRegistryInfo()
  -{
  -        DWORD disposition;
  -        ::HKEY hkey = 0;
  -    std::wstring subkey(L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\");
  -    Transcoder::encode(log, subkey);
  -    subkey += L"\\";
  -    Transcoder::encode(source, subkey);
  -
  -        hkey = (::HKEY) regGetKey(subkey, &disposition);
  -        if (disposition == REG_CREATED_NEW_KEY)
  -        {
  -                regSetString(hkey, L"EventMessageFile", 
L"NTEventLogAppender.dll");
  -                regSetString(hkey, L"CategoryMessageFile", 
L"NTEventLogAppender.dll");
  -                regSetDword(hkey,  L"TypesSupported", (DWORD)7);
  -                regSetDword(hkey,  L"CategoryCount", (DWORD)5);
  -        }
  -
  -        RegCloseKey(hkey);
  -        return;
  -}
  -
  -WORD NTEventLogAppender::getEventType(const LoggingEventPtr& event)
  -{
  -        WORD ret_val;
  -
  -        switch (event->getLevel()->toInt())
  -        {
  -        case Level::FATAL_INT:
  -        case Level::ERROR_INT:
  -                ret_val = EVENTLOG_ERROR_TYPE;
  -                break;
  -        case Level::WARN_INT:
  -                ret_val = EVENTLOG_WARNING_TYPE;
  -                break;
  -        case Level::INFO_INT:
  -        case Level::DEBUG_INT:
  -        default:
  -                ret_val = EVENTLOG_INFORMATION_TYPE;
  -                break;
  -        }
  -
  -        return ret_val;
  -}
  -
  -WORD NTEventLogAppender::getEventCategory(const LoggingEventPtr& event)
  -{
  -        WORD ret_val;
  -
  -        switch (event->getLevel()->toInt())
  -        {
  -        case Level::FATAL_INT:
  -                ret_val = 1;
  -                break;
  -        case Level::ERROR_INT:
  -                ret_val = 2;
  -                break;
  -        case Level::WARN_INT:
  -                ret_val = 3;
  -                break;
  -        case Level::INFO_INT:
  -                ret_val = 4;
  -                break;
  -        case Level::DEBUG_INT:
  -        default:
  -                ret_val = 5;
  -                break;
  -        }
  -
  -        return ret_val;
   }
   
  -LogString NTEventLogAppender::getErrorString(const LogString& function) 
  -{ 
  +void NTEventLogAppender::append(const LoggingEventPtr& event, Pool& p)
  +{
  +        if (hEventLog == NULL)
  +        {
  +                LogLog::warn(LOG4CXX_STR("NT EventLog not opened."));
  +                return;
  +        }
  +
  +        LogString oss;
  +        layout->format(oss, event, p);
  +#if LOG4CXX_HAS_WCHAR_T
  +        LOG4CXX_ENCODE_WCHAR(s, oss);
  +        const wchar_t* msgs[1];
  +        msgs[0] = s.c_str() ;
  +        BOOL bSuccess = ::ReportEventW(
  +                hEventLog,
  +                getEventType(event),
  +                getEventCategory(event),
  +                0x1000,
  +                pCurrentUserSID,
  +                1,
  +                0,
  +                msgs,
  +                NULL);
  +#else
  +        LOG4CXX_ENCODE_CHAR(s, oss);
  +        const char* msgs[1];
  +        msgs[0] = s.c_str() ;
  +        BOOL bSuccess = ::ReportEventA(
  +                hEventLog,
  +                getEventType(event),
  +                getEventCategory(event),
  +                0x1000,
  +                pCurrentUserSID,
  +                1,
  +                0,
  +                msgs,
  +                NULL);
  +#endif
  +
  +        if (!bSuccess)
  +        {
  +                LogLog::error(getErrorString(LOG4CXX_STR("ReportEvent")));
  +        }
  +}
  +
  +NTEventLogAppender::HKEY NTEventLogAppender::regGetKey(
  +     const LogString& subkey, DWORD *disposition)
  +{
  +        ::HKEY hkey = 0;
  +#if LOG4CXX_HAS_WCHAR_T
  +        LOG4CXX_ENCODE_WCHAR(wstr, subkey);
  +        RegCreateKeyExW((::HKEY) HKEY_LOCAL_MACHINE, wstr.c_str(), 0, NULL,
  +                REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
  +                &hkey, disposition);
  +#else
  +        LOG4CXX_ENCODE_CHAR(str, subkey);
  +        RegCreateKeyExA((::HKEY) HKEY_LOCAL_MACHINE, str.c_str(), 0, NULL,
  +                REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
  +                &hkey, disposition);
  +#endif
  +        return hkey;
  +}
  +
  +void NTEventLogAppender::regSetString(HKEY hkey, const wchar_t*  name,
  +                                       const wchar_t* value)
  +{
  +        RegSetValueExW((::HKEY) hkey, name, 0, REG_SZ, (LPBYTE) value,
  +        wcslen(value)*sizeof(wchar_t));
  +}
  +
  +void NTEventLogAppender::regSetDword(HKEY hkey, const wchar_t* name, DWORD 
value)
  +{
  +        RegSetValueExW((::HKEY) hkey, name, 0, REG_DWORD, (LPBYTE)&value, 
sizeof(DWORD));
  +}
  +
  +/*
  + * Add this source with appropriate configuration keys to the registry.
  + */
  +void NTEventLogAppender::addRegistryInfo()
  +{
  +        DWORD disposition;
  +        ::HKEY hkey = 0;
  +        LogString 
subkey(LOG4CXX_STR("SYSTEM\\CurrentControlSet\\Services\\EventLog\\"));
  +        subkey.append(log);
  +        subkey.append(1, LOG4CXX_STR('\\'));
  +        subkey.append(source);
  +
  +        hkey = (::HKEY) regGetKey(subkey, &disposition);
  +        if (disposition == REG_CREATED_NEW_KEY)
  +        {
  +                regSetString(hkey, L"EventMessageFile", 
L"NTEventLogAppender.dll");
  +                regSetString(hkey, L"CategoryMessageFile", 
L"NTEventLogAppender.dll");
  +                regSetDword(hkey,  L"TypesSupported", (DWORD)7);
  +                regSetDword(hkey,  L"CategoryCount", (DWORD)5);
  +        }
  +
  +        RegCloseKey(hkey);
  +        return;
  +}
  +
  +WORD NTEventLogAppender::getEventType(const LoggingEventPtr& event)
  +{
  +        WORD ret_val;
  +
  +        switch (event->getLevel()->toInt())
  +        {
  +        case Level::FATAL_INT:
  +        case Level::ERROR_INT:
  +                ret_val = EVENTLOG_ERROR_TYPE;
  +                break;
  +        case Level::WARN_INT:
  +                ret_val = EVENTLOG_WARNING_TYPE;
  +                break;
  +        case Level::INFO_INT:
  +        case Level::DEBUG_INT:
  +        default:
  +                ret_val = EVENTLOG_INFORMATION_TYPE;
  +                break;
  +        }
  +
  +        return ret_val;
  +}
  +
  +WORD NTEventLogAppender::getEventCategory(const LoggingEventPtr& event)
  +{
  +        WORD ret_val;
  +
  +        switch (event->getLevel()->toInt())
  +        {
  +        case Level::FATAL_INT:
  +                ret_val = 1;
  +                break;
  +        case Level::ERROR_INT:
  +                ret_val = 2;
  +                break;
  +        case Level::WARN_INT:
  +                ret_val = 3;
  +                break;
  +        case Level::INFO_INT:
  +                ret_val = 4;
  +                break;
  +        case Level::DEBUG_INT:
  +        default:
  +                ret_val = 5;
  +                break;
  +        }
  +
  +        return ret_val;
  +}
  +
  +LogString NTEventLogAppender::getErrorString(const LogString& function)
  +{
       Pool p;
       enum { MSGSIZE = 5000 };
  +
  +#if LOG4CXX_HAS_WCHAR_T
       wchar_t* lpMsgBuf = (wchar_t*) p.palloc(MSGSIZE * sizeof(wchar_t));
  -    DWORD dw = GetLastError(); 
  +    DWORD dw = GetLastError();
   
       FormatMessageW(
           FORMAT_MESSAGE_FROM_SYSTEM,
  @@ -323,16 +353,29 @@
           MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
           lpMsgBuf,
           MSGSIZE, NULL );
  +    size_t msgLen = wcslen(lpMsgBuf);
  +#else
  +    char* lpMsgBuf = (char*) p.palloc(MSGSIZE);
  +    DWORD dw = GetLastError();
   
  -    std::wstring sysmsg(lpMsgBuf);
  +    FormatMessageA(
  +        FORMAT_MESSAGE_FROM_SYSTEM,
  +        NULL,
  +        dw,
  +        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  +        lpMsgBuf,
  +        MSGSIZE, NULL );
  +
  +    size_t msgLen = strlen(lpMsgBuf);
  +#endif
   
       LogString msg(function);
       msg.append(LOG4CXX_STR(" failed with error "));
       StringHelper::toString((size_t) dw, p, msg);
       msg.append(LOG4CXX_STR(": "));
  -    Transcoder::decode(sysmsg, msg);
  +    Transcoder::decode(lpMsgBuf, msgLen, msg);
  +
  +    return msg;
  +}
   
  -    return msg; 
  -}
  -
  -#endif // WIN32
  +#endif // WIN32
  
  
  
  1.10      +6 -2      logging-log4cxx/src/outputdebugstringappender.cpp
  
  Index: outputdebugstringappender.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/outputdebugstringappender.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- outputdebugstringappender.cpp     15 Feb 2005 23:56:01 -0000      1.9
  +++ outputdebugstringappender.cpp     12 Mar 2005 06:37:27 -0000      1.10
  @@ -33,9 +33,13 @@
   {
           LogString buf;
           layout->format(buf, event, p);
  -        std::wstring wstr;
  -        log4cxx::helpers::Transcoder::encode(buf, wstr);
  +#if LOG4CXX_HAS_WCHAR_T
  +        LOG4CXX_ENCODE_WCHAR(wstr, buf);
           ::OutputDebugStringW(wstr.c_str());
  +#else
  +        LOG4CXX_ENCODE_CHAR(str, buf);
  +        ::OutputDebugStringA(str.c_str());
  +#endif
   }
   
   #endif
  
  
  
  1.13      +1 -1      logging-log4cxx/src/transcoder.cpp
  
  Index: transcoder.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/transcoder.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- transcoder.cpp    11 Mar 2005 06:34:49 -0000      1.12
  +++ transcoder.cpp    12 Mar 2005 06:37:27 -0000      1.13
  @@ -238,12 +238,12 @@
            }
         }
   
  +     public:
         ~Xlater() {
           apr_xlate_close(encoder);
           apr_xlate_close(decoder);
         }
   
  -    public:
         static const Xlater& getLocaleCharset() {
           static Xlater localeCharset(APR_LOCALE_CHARSET);
           return localeCharset;
  
  
  
  1.5       +51 -51    
logging-log4cxx/tests/src/nt/nteventlogappendertestcase.cpp
  
  Index: nteventlogappendertestcase.cpp
  ===================================================================
  RCS file: 
/home/cvs/logging-log4cxx/tests/src/nt/nteventlogappendertestcase.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- nteventlogappendertestcase.cpp    9 Mar 2005 17:38:25 -0000       1.4
  +++ nteventlogappendertestcase.cpp    12 Mar 2005 06:37:27 -0000      1.5
  @@ -1,56 +1,56 @@
  -/*
  - * Copyright 2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -#if defined(_WIN32)
  -#include <cppunit/TestFixture.h>
  -#include <cppunit/extensions/HelperMacros.h>
  -#include <log4cxx/nt/nteventlogappender.h>
  +/*
  + * Copyright 2004,2005 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#if defined(_WIN32)
  +#include <cppunit/TestFixture.h>
  +#include <cppunit/extensions/HelperMacros.h>
  +#include <log4cxx/nt/nteventlogappender.h>
   #include "../appenderskeletontestcase.h"
   #include <apr_time.h>
   #include "windows.h"
   #include <log4cxx/logger.h>
   #include <log4cxx/spi/loggingevent.h>
   #include <log4cxx/patternlayout.h>
  -#include "../insertwide.h"
  -
  -using namespace log4cxx;
  +#include "../insertwide.h"
  +
  +using namespace log4cxx;
   using namespace log4cxx::helpers;
  -using namespace log4cxx::nt;
  +using namespace log4cxx::nt;
   using namespace log4cxx::spi;
  -
  -/**
  -   Unit tests of log4cxx::nt::NTEventLogAppender
  - */
  -class NTEventLogAppenderTestCase : public AppenderSkeletonTestCase
  -{
  -   CPPUNIT_TEST_SUITE(NTEventLogAppenderTestCase);
  -                //
  -                //    tests inherited from AppenderSkeletonTestCase
  -                //
  -                CPPUNIT_TEST(testDefaultThreshold);
  -                CPPUNIT_TEST(testSetOptionThreshold);
  +
  +/**
  +   Unit tests of log4cxx::nt::NTEventLogAppender
  + */
  +class NTEventLogAppenderTestCase : public AppenderSkeletonTestCase
  +{
  +   CPPUNIT_TEST_SUITE(NTEventLogAppenderTestCase);
  +                //
  +                //    tests inherited from AppenderSkeletonTestCase
  +                //
  +                CPPUNIT_TEST(testDefaultThreshold);
  +                CPPUNIT_TEST(testSetOptionThreshold);
                   CPPUNIT_TEST(testHelloWorld);
  -
  -   CPPUNIT_TEST_SUITE_END();
  -
  -
  -public:
  -
  -        AppenderSkeleton* createAppenderSkeleton() const {
  -          return new log4cxx::nt::NTEventLogAppender();
  +
  +   CPPUNIT_TEST_SUITE_END();
  +
  +
  +public:
  +
  +        AppenderSkeleton* createAppenderSkeleton() const {
  +          return new log4cxx::nt::NTEventLogAppender();
           }
   
           void testHelloWorld() {
  @@ -64,7 +64,7 @@
                  CPPUNIT_ASSERT(stat);
                  expectedId += oldest;
              }
  - 
  +
   
               Pool p;
               DWORD expectedTime = apr_time_sec(apr_time_now());
  @@ -74,7 +74,7 @@
                   LayoutPtr layout(new PatternLayout(LOG4CXX_STR("%c - 
%m%n")));
                   appender->setLayout(layout);
                   appender->activateOptions(p);
  -                LoggerPtr logger(Logger::getLogger(L"org.foobar"));
  +                LoggerPtr logger(Logger::getLogger("org.foobar"));
   
                   LoggingEventPtr event(new LoggingEvent(
                       logger, Level::INFO, LOG4CXX_STR("Hello,  World"), 
LOG4CXX_LOCATION));
  @@ -91,8 +91,8 @@
               CloseEventLog(hEventLog);
               CPPUNIT_ASSERT(stat);
               CPPUNIT_ASSERT_EQUAL(expectedId, actualId);
  -        }
  -};
  -
  -CPPUNIT_TEST_SUITE_REGISTRATION(NTEventLogAppenderTestCase);
  -#endif
  +        }
  +};
  +
  +CPPUNIT_TEST_SUITE_REGISTRATION(NTEventLogAppenderTestCase);
  +#endif
  
  
  

Reply via email to