axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hawk...@apache.org
Subject cvs commit: ws-axis/c/src/platforms/unix PlatformSpecificUnix.hpp
Date Thu, 13 Jan 2005 17:03:06 GMT
hawkeye     2005/01/13 09:03:06

  Modified:    c/src/platforms/windows PlatformSpecificWindows.hpp
               c/src/platforms/os400 PlatformSpecificOS400.hpp
               c/src/platforms/aix PlatformSpecificAIX.hpp
               c/src/transport/axis2 Channel.cpp
               c/src/platforms/unix PlatformSpecificUnix.hpp
  Added:       c/src/platforms/windows PlatformSpecificWindows.cpp
  Log:
  Get errno when client can't connect to server.
  
  Revision  Changes    Path
  1.10      +19 -0     ws-axis/c/src/platforms/windows/PlatformSpecificWindows.hpp
  
  Index: PlatformSpecificWindows.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/platforms/windows/PlatformSpecificWindows.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PlatformSpecificWindows.hpp	11 Jan 2005 14:14:38 -0000	1.9
  +++ PlatformSpecificWindows.hpp	13 Jan 2005 17:03:05 -0000	1.10
  @@ -21,6 +21,7 @@
   //#define _WIN32_WINNT 0x0400
   #define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
   #include <windows.h>
  +#include <string>
   
   // =============================================================
   // Default paths to shared library/DLLs and files
  @@ -69,6 +70,24 @@
   // Miscellaneous
   // =============================================================
   #define PLATFORM_SLEEP(x) Sleep(0);
  +
  +/**
  + * Get the last error code from the system.
  + * Please ensure that this is a thread safe implementation
  + * and that it returns a long
  + * @return long the lsat error message for this thread
  + */
  +#define GETLASTERROR() GetLastError();
  +
  +/**
  + * From the last error number get a sensible std::string representing it
  + * @param errorNumber the error Number you are trying to get a message for
  + * @return the error message. NOTE: The caller is responsible for deleting the returned
string
  + */
  +#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) getPlatformErrorMessage(errorNumber);
  +
  +std::string* getPlatformErrorMessage(long errorNumber);
  +
   
   #endif
   
  
  
  
  1.1                  ws-axis/c/src/platforms/windows/PlatformSpecificWindows.cpp
  
  Index: PlatformSpecificWindows.cpp
  ===================================================================
  /*
   *   Copyright 2004-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.
   */
  
  
  #include "PlatformSpecificWindows.hpp"
  #include <stdio.h>
  
  
  
  std::string* getPlatformErrorMessage(long errorNumber)
  {
  	std::string* returningString = new std::string();
      LPVOID lpMsgBuf;
  
  	FormatMessage(
  	FORMAT_MESSAGE_ALLOCATE_BUFFER | 
  	FORMAT_MESSAGE_FROM_SYSTEM,
  	NULL,
  	errorNumber,
  	MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  	(LPTSTR) &lpMsgBuf,
  	0, NULL );
  
  	returningString->append((LPTSTR)lpMsgBuf);
      LocalFree(lpMsgBuf);
  		    
      return returningString;
  }
  
  
  
  
  
  1.10      +17 -0     ws-axis/c/src/platforms/os400/PlatformSpecificOS400.hpp
  
  Index: PlatformSpecificOS400.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/platforms/os400/PlatformSpecificOS400.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PlatformSpecificOS400.hpp	11 Jan 2005 14:14:12 -0000	1.9
  +++ PlatformSpecificOS400.hpp	13 Jan 2005 17:03:06 -0000	1.10
  @@ -68,6 +68,23 @@
   #include <unistd.h>
   #define PLATFORM_SLEEP(x) sleep(0);
   
  +/**
  + * Get the last error code from the system.
  + * Please ensure that this is a thread safe implementation
  + * and that it returns a long
  + * @return long the lsat error message for this thread
  + */
  +#define GETLASTERROR -1;
  +
  +
  +/**
  + * From the last error number get a sensible std::string representing it
  + * @param errorNumber the error Number you are trying to get a message for
  + * @return the error message. NOTE: The caller is responsible for deleting the returned
string
  + */
  +#include <string>
  +#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string();
  +
   #endif
   
   
  
  
  
  1.8       +21 -0     ws-axis/c/src/platforms/aix/PlatformSpecificAIX.hpp
  
  Index: PlatformSpecificAIX.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/platforms/aix/PlatformSpecificAIX.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PlatformSpecificAIX.hpp	11 Jan 2005 14:13:56 -0000	1.7
  +++ PlatformSpecificAIX.hpp	13 Jan 2005 17:03:06 -0000	1.8
  @@ -75,6 +75,27 @@
   #include <unistd.h>
   #define PLATFORM_SLEEP(x) sleep(0);
   
  +
  +
  +/**
  + * Get the last error code from the system.
  + * Please ensure that this is a thread safe implementation
  + * and that it returns a long
  + * @return long the lsat error message for this thread
  + */
  +#define GETLASTERROR errno;
  +
  +
  +/**
  + * From the last error number get a sensible std::string representing it
  + * @param errorNumber the error Number you are trying to get a message for
  + * @return the error message. NOTE: The caller is responsible for deleting the returned
string
  + */
  +#include <string>
  +#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber));
  +
  +
  +
   #endif
   
   
  
  
  
  1.15      +15 -30    ws-axis/c/src/transport/axis2/Channel.cpp
  
  Index: Channel.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/transport/axis2/Channel.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Channel.cpp	10 Jan 2005 17:12:22 -0000	1.14
  +++ Channel.cpp	13 Jan 2005 17:03:06 -0000	1.15
  @@ -22,9 +22,11 @@
   
   #include "Platform.h"
   #include "Channel.h"
  +#include "../../platforms/PlatformAutoSense.hpp"
   #include <iostream>
   #include <stdio.h>
   
  +
   using namespace std;
   /**
    * Create a Channel & initialize
  @@ -174,43 +176,26 @@
   		{
   			// Cannot open a channel to the remote end, shutting down the
   			// channel and then throw an exception.
  -#ifdef WIN32
  -			// Before we do anything else get the last error message;
  -			// I'd like to put the getting of the error message into platform specifics but not
sure how !
  -			// I think it would be nicer to make the platform specifics a class and not just macros.
  -			// That way we could have e.g. char* Windows#getLastErrorMessage()
  -			long dw = GetLastError();
  -#endif
  -			closeChannel();
   
  -#ifdef WIN32
  -			TCHAR szBuf[200]; 
  -		    LPVOID lpMsgBuf;
  +			// Before we do anything else get the last error message;
  +			long dw = GETLASTERROR()
   
  -			FormatMessage(
  -			FORMAT_MESSAGE_ALLOCATE_BUFFER | 
  -			FORMAT_MESSAGE_FROM_SYSTEM,
  -			NULL,
  -			dw,
  -			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  -			(LPTSTR) &lpMsgBuf,
  -			0, NULL );
  +			closeChannel();
  +			
  +			string* message = PLATFORM_GET_ERROR_MESSAGE(dw);
   
  -			sprintf(szBuf, 
  -				"failed to open connection to server:\n \
  +			char fullMessage[600];
  +			sprintf(fullMessage,
  +				"Failed to open connection to server: \n \
   				hostname='%s'\n\
   				port='%d'\n\
   				Error Message='%s'\
  -				Error Code='%d'\n",                     \
  -				m_URL.getHostName(), m_URL.getPort(), lpMsgBuf, dw); 
  - 
  -
  -		    LocalFree(lpMsgBuf);
  +				Error Code='%d'\n",
  +				m_URL.getHostName(), m_URL.getPort(), message->c_str(), dw);
  +				
  +			delete(message);
   
  -			throw AxisTransportException( SERVER_TRANSPORT_SOCKET_CONNECT_ERROR, szBuf);
  -#endif
  -			// else we don't know how to do this for non-windows platforms
  -			throw AxisTransportException( SERVER_TRANSPORT_SOCKET_CONNECT_ERROR);
  +			throw AxisTransportException( CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED, fullMessage);
   		}
   
       }
  
  
  
  1.11      +17 -0     ws-axis/c/src/platforms/unix/PlatformSpecificUnix.hpp
  
  Index: PlatformSpecificUnix.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/platforms/unix/PlatformSpecificUnix.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PlatformSpecificUnix.hpp	11 Jan 2005 14:14:26 -0000	1.10
  +++ PlatformSpecificUnix.hpp	13 Jan 2005 17:03:06 -0000	1.11
  @@ -75,6 +75,23 @@
   #include <unistd.h>
   #define PLATFORM_SLEEP(x) sleep(0);
   
  +/**
  + * Get the last error code from the system.
  + * Please ensure that this is a thread safe implementation
  + * and that it returns a long
  + * @return long the lsat error message for this thread
  + */
  +#define GETLASTERROR errno;
  +
  +
  +/**
  + * From the last error number get a sensible std::string representing it
  + * @param errorNumber the error Number you are trying to get a message for
  + * @return the error message. NOTE: The caller is responsible for deleting the returned
string
  + */
  +#include <string>
  +#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber));
  +
   #endif
   
   
  
  
  

Mime
View raw message