From d75af94c21360dd76145fdfac8f2d08d6570c8e3 Mon Sep 17 00:00:00 2001 From: James David Berry <jberry@apache.org> Date: Tue, 11 Mar 2008 04:58:07 +0000 Subject: [PATCH] Delete obsolete MacOSURLAccess, which was pre-carbon support for net access on Mac OS, prior to Mac OS X. Since Xerces 3.0 does not attempt to work on systems prior to Mac OS X, these sources are being dumped, but are still available in the Xerces 2 branch. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@635801 13f79535-47bb-0310-9956-ffa450edef68 --- .../MacOSURLAccess/MacOSURLAccess.cpp | 69 ------- .../MacOSURLAccess/MacOSURLAccess.hpp | 67 ------ .../URLAccessBinInputStream.cpp | 195 ------------------ .../URLAccessBinInputStream.hpp | 76 ------- 4 files changed, 407 deletions(-) delete mode 100644 src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.cpp delete mode 100644 src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.hpp delete mode 100644 src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.cpp delete mode 100644 src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.hpp diff --git a/src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.cpp b/src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.cpp deleted file mode 100644 index 6c109ae1b..000000000 --- a/src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/* - * $Id$ - */ - - -#include <xercesc/util/XMLUni.hpp> -#include <xercesc/util/XMLUniDefs.hpp> -#include <xercesc/util/XMLString.hpp> -#include <xercesc/util/XMLExceptMsgs.hpp> -#include <xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.hpp> -#include <xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.hpp> - -XERCES_CPP_NAMESPACE_BEGIN - -const XMLCh -MacOSURLAccess::sMyID[] = -{ - chLatin_M, chLatin_a, chLatin_c, chLatin_O, chLatin_S, chLatin_U, - chLatin_R, chLatin_L, chLatin_A, chLatin_c, chLatin_c, chLatin_e, - chLatin_s, chLatin_s, - chNull -}; - - -MacOSURLAccess::MacOSURLAccess() -{ - // Ensure that we've got URLAccess - if (!URLAccessAvailable()) - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_InitFailed); -} - - -MacOSURLAccess::~MacOSURLAccess() -{ -} - - -BinInputStream* -MacOSURLAccess::makeNew(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/) -{ - if(httpInfo!=0 && httpInfo->fHTTPMethod!=XMLNetHTTPInfo::GET) - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_UnsupportedMethod); - // We just go ahead and try to create a URLAccess stream - // from this source. That's the correct place to verify - // whether or not we can really handle this URL type... - // if it throws, well, it throws ;) - BinInputStream* result = new (urlSource.getMemoryManager()) URLAccessBinInputStream(urlSource); - return result; -} - -XERCES_CPP_NAMESPACE_END - diff --git a/src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.hpp b/src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.hpp deleted file mode 100644 index d3f69f55b..000000000 --- a/src/xercesc/util/NetAccessors/MacOSURLAccess/MacOSURLAccess.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/* - * $Id$ - */ - -#if !defined(XERCESC_INCLUDE_GUARD_MACOSURLACCESS_HPP) -#define XERCESC_INCLUDE_GUARD_MACOSURLACCESS_HPP - - -#include <xercesc/util/XercesDefs.hpp> -#include <xercesc/util/XMLURL.hpp> -#include <xercesc/util/BinInputStream.hpp> -#include <xercesc/util/XMLNetAccessor.hpp> - -XERCES_CPP_NAMESPACE_BEGIN - -// -// This class is the wrapper for the Mac OS URLAccess code -// which provides access to network resources. -// It's being used here to add the ability to -// use HTTP URL's as the system id's in the XML decl clauses. -// - -class XMLUTIL_EXPORT MacOSURLAccess : public XMLNetAccessor -{ -public : - MacOSURLAccess(); - ~MacOSURLAccess(); - - BinInputStream* makeNew(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo=0); - const XMLCh* getId() const; - -private : - static const XMLCh sMyID[]; - - MacOSURLAccess(const MacOSURLAccess&); - MacOSURLAccess& operator=(const MacOSURLAccess&); - -}; - -inline const XMLCh* -MacOSURLAccess::getId() const -{ - return sMyID; -} - - -XERCES_CPP_NAMESPACE_END - - -#endif // MACOSURLACCESS_HPP diff --git a/src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.cpp b/src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.cpp deleted file mode 100644 index 2a57d4042..000000000 --- a/src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/* - * $Id$ - */ - - -#include <xercesc/util/XMLNetAccessor.hpp> -#include <xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.hpp> -#include <xercesc/util/XMLString.hpp> -#include <xercesc/util/XMLExceptMsgs.hpp> -#include <xercesc/util/Janitor.hpp> - -#include <cstdlib> -#include <cstring> - -XERCES_CPP_NAMESPACE_BEGIN - -URLAccessBinInputStream::URLAccessBinInputStream(const XMLURL& urlSource) - : mBytesProcessed(0), - mURLReference(NULL), - mBuffer(NULL), - mBufPos(NULL), - mBufAvailable(0) -{ - OSStatus status = noErr; - - // Get the full URL from the source - char* url = XMLString::transcode(urlSource.getURLText(), urlSource.getMemoryManager()); - ArrayJanitor<char> janBuf(url, urlSource.getMemoryManager()); - - // Create a URL reference from the URL - status = URLNewReference(url, &mURLReference); - - // Begin the transfer - if (status == noErr) - status = URLOpen( - mURLReference, - NULL, // FSSpec* (not reading to file) - 0, // URLOpenFlags - NULL, // URLNotifyUPP - 0, // URLEventMask - 0); // userContext - - // If we failed, we throw - switch (status) - { - case noErr: - break; - - case kURLInvalidURLError: - ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - break; - case kURLUnsupportedSchemeError: - ThrowXML(MalformedURLException, XMLExcepts::URL_UnsupportedProto); - break; - - default: - ThrowXML1(NetAccessorException, XMLExcepts::NetAcc_ConnSocket, urlSource.getURLText()); - break; - } -} - - - -URLAccessBinInputStream::~URLAccessBinInputStream() -{ - OSStatus status = noErr; - - // Release any buffer we've still got a hold of - if (status == noErr && mBuffer) - { - status = URLReleaseBuffer(mURLReference, mBuffer); - mBuffer = NULL; - } - - // Get the current state - URLState state = 0; - if (status == noErr) - status = URLGetCurrentState(mURLReference, &state); - - // Abort if we're not completed - if (status == noErr && state != kURLNullState && state != kURLCompletedState) - status = URLAbort(mURLReference); - - // Loop til we reach a terminal state. - // This may be unneeded by URLAccess, but the docs are - // not very good. - while ( - status == noErr - && state != kURLNullState - && state != kURLErrorOccurredState - && state != kURLCompletedState - ) - { - status = URLIdle(); - if (status == noErr) - status = URLGetCurrentState(mURLReference, &state); - } - - // Dispose the reference - status = URLDisposeReference(mURLReference); -} - - -// -// Call URLAccess to fullfill the read request. Since it -// passes us back buffers full of data, our object maintains -// a partial buffer across calls. -// -XMLSize_t -URLAccessBinInputStream::readBytes(XMLByte* const toFill - , const XMLSize_t maxToRead) -{ - OSStatus status = noErr; - - XMLByte* writePos = toFill; - std::size_t bytesDesired = maxToRead; - URLState state = kURLNullState; - - while ( // while... - status == noErr // there's been no error - && bytesDesired > 0 // more data is wanted - && (status = URLGetCurrentState(mURLReference, &state)) == noErr // we can get the state - && (state != kURLErrorOccurredState) // no error has occurred in the transaction - && (mBuffer || state != kURLCompletedState) // we have data still buffered or the request isn't complete - && (mBuffer || bytesDesired == maxToRead) // we have data still buffered or we've supplied absolutely none - ) - { - // Give time to URLAccess - status = URLIdle(); - - // If we've got buffered data, use it - if (status == noErr && mBuffer) - { - // Supply as much as we can from the buffer - std::size_t n = mBufAvailable; - if (n > bytesDesired) - n = bytesDesired; - - // If we've got data, copy it over and update our pointers - if (n > 0) - { - std::memcpy(writePos, mBufPos, n); - - writePos += n; - bytesDesired -= n; - - mBufPos += n; - mBufAvailable -= n; - - mBytesProcessed += n; - } - - // If we exhausted the buffer, release it - if (mBufAvailable == 0) - { - status = URLReleaseBuffer(mURLReference, mBuffer); - mBuffer = NULL; - } - } - - // If the buffer is exhausted, get a new one - if (status == noErr && !mBuffer) - { - status = URLGetBuffer(mURLReference, &mBuffer, &mBufAvailable); - if (status == noErr) - mBufPos = reinterpret_cast<char*>(mBuffer); - } - } - - // Throw on any error - if (status != noErr || state == kURLErrorOccurredState) - ThrowXML(NetAccessorException, XMLExcepts::NetAcc_ReadSocket); - - // Return number of bytes delivered - return maxToRead - bytesDesired; -} - -XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.hpp b/src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.hpp deleted file mode 100644 index 1046d907b..000000000 --- a/src/xercesc/util/NetAccessors/MacOSURLAccess/URLAccessBinInputStream.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -/* - * $Id$ - */ - -#if !defined(XERCESC_INCLUDE_GUARD_URLACCESSBININPUTSTREAM_HPP) -#define XERCESC_INCLUDE_GUARD_URLACCESSBININPUTSTREAM_HPP - - -#include <xercesc/util/XMLURL.hpp> -#include <xercesc/util/XMLExceptMsgs.hpp> -#include <xercesc/util/BinInputStream.hpp> - -#if defined(__APPLE__) - // Framework includes from ProjectBuilder - #include <Carbon/Carbon.h> -#else - // Classic includes otherwise - #include <URLAccess.h> -#endif - -XERCES_CPP_NAMESPACE_BEGIN - -// -// This class implements the BinInputStream interface specified by the XML -// parser. -// - -class XMLUTIL_EXPORT URLAccessBinInputStream : public BinInputStream -{ -public : - URLAccessBinInputStream(const XMLURL& urlSource); - ~URLAccessBinInputStream(); - - XMLFilePos curPos() const; - XMLSize_t readBytes - ( - XMLByte* const toFill - , const XMLSize_t maxToRead - ); - - -private : - unsigned int mBytesProcessed; - URLReference mURLReference; - void* mBuffer; // Current buffer from URLAccess (or NULL) - char* mBufPos; // Read position in buffer - Size mBufAvailable; // Bytes available -}; - - -inline XMLFilePos -URLAccessBinInputStream::curPos() const -{ - return mBytesProcessed; -} - -XERCES_CPP_NAMESPACE_END - -#endif // URLACCESSBININPUTSTREAM_HPP -- GitLab