Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

winutils/XSECBinHTTPURIInputStream.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2005 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * XSEC
00019  *
00020  * XSECBinHTTPURIInputStream := Re-implementation of the Xerces
00021  *                              BinHTTPURLInputStream.  Allows us to make
00022  *                              some small changes to support the requirements
00023  *                              of XMLDSIG (notably re-directs)
00024  *
00025  * NOTE: Much code taken from Xerces, and the cross platform interfacing is
00026  * no-where near as nice.
00027  *
00028  * Author(s): Berin Lautenbach
00029  *
00030  * $Id: XSECBinHTTPURIInputStream.hpp,v 1.7 2005/02/03 13:56:22 milan Exp $
00031  *
00032  * $Log: XSECBinHTTPURIInputStream.hpp,v $
00033  * Revision 1.7  2005/02/03 13:56:22  milan
00034  * Apache licence fix.
00035  *
00036  * Revision 1.6  2004/04/21 10:14:49  blautenb
00037  * Clean windows build with overarching SimpleSOAPRequestor
00038  *
00039  * Revision 1.5  2004/04/16 12:07:23  blautenb
00040  * Skeleton code for XKMS MessageFactory
00041  *
00042  * Revision 1.4  2004/02/08 10:25:40  blautenb
00043  * Convert to Apache 2.0 license
00044  *
00045  * Revision 1.3  2003/09/11 11:11:05  blautenb
00046  * Cleaned up usage of Xerces namespace - no longer inject into global namespace in headers
00047  *
00048  * Revision 1.2  2003/07/05 10:30:38  blautenb
00049  * Copyright update
00050  *
00051  * Revision 1.1  2003/02/12 09:45:29  blautenb
00052  * Win32 Re-implementation of Xerces URIResolver to support re-directs
00053  *
00054  *
00055  */
00056 
00057 
00058 #ifndef XSECBINHTTPURIINPUTSTREAM_HEADER
00059 #define XSECBINHTTPURIINPUTSTREAM_HEADER
00060 
00061 #include <xsec/framework/XSECDefs.hpp>
00062 
00063 #include <xercesc/util/XMLUri.hpp>
00064 #include <xercesc/util/XMLExceptMsgs.hpp>
00065 #include <xercesc/util/BinInputStream.hpp>
00066 #include <xercesc/util/Mutexes.hpp>
00067 
00068 //
00069 // This class implements the BinInputStream interface specified by the XML
00070 // parser.
00071 //
00072 
00073 struct hostent;
00074 struct sockaddr;
00075 
00076 class XSECSOAPRequestorSimple;
00077 
00078 class DSIG_EXPORT XSECBinHTTPURIInputStream : public XERCES_CPP_NAMESPACE_QUALIFIER BinInputStream
00079 {
00080 public :
00081 
00082     XSECBinHTTPURIInputStream(const XERCES_CPP_NAMESPACE_QUALIFIER XMLUri&  urlSource);
00083     ~XSECBinHTTPURIInputStream();
00084 
00085     unsigned int curPos() const;
00086     unsigned int readBytes(XMLByte* const  toFill, const unsigned int    maxToRead);
00087 
00088     static void Cleanup();
00089 
00090     friend class XSECSOAPRequestorSimple;
00091 
00092 protected:
00093 
00094     /* 
00095      * These are called by other classes that use the loaded DLL
00096      *
00097      * Actually - this is cheating of the worst kind, but it
00098      * provides a quick way to make these calls available outside the library
00099      */
00100 
00101     static void ExternalInitialize(void);
00102 
00103     static hostent* gethostbyname(const char* name);
00104     static unsigned long inet_addr(const char* cp);
00105     static hostent* gethostbyaddr(const char* addr,int len,int type);
00106     static unsigned short htons(unsigned short hostshort);
00107     static unsigned short socket(int af,int type,int protocol);
00108     static int connect(unsigned short s,const sockaddr* name,int namelen);
00109     static int send(unsigned short s,const char* buf,int len,int flags);
00110     static int recv(unsigned short s,char* buf,int len,int flags);
00111     static int shutdown(unsigned int s,int how);
00112     static int closesocket(unsigned int socket);
00113 
00114 
00115 private :
00116     // -----------------------------------------------------------------------
00117     //  Private data members
00118     //
00119     //  fSocketHandle
00120     //      The socket representing the connection to the remote file.
00121     //      We deliberately did not define the type to be SOCKET, so as to
00122     //      avoid bringing in any Windows header into this file.
00123     //  fBytesProcessed
00124     //      Its a rolling count of the number of bytes processed off this
00125     //      input stream.
00126     //  fBuffer
00127     //      Holds the http header, plus the first part of the actual
00128     //      data.  Filled at the time the stream is opened, data goes
00129     //      out to user in response to readBytes().
00130     //  fBufferPos, fBufferEnd
00131     //      Pointers into fBuffer, showing start and end+1 of content
00132     //      that readBytes must return.
00133     // -----------------------------------------------------------------------
00134 
00135     unsigned int        fSocketHandle;
00136     unsigned int        fBytesProcessed;
00137     char                fBuffer[4000];
00138     char *              fBufferEnd;
00139     char *              fBufferPos;
00140     static bool         fInitialized;
00141     static XERCES_CPP_NAMESPACE_QUALIFIER XMLMutex*    fInitMutex;
00142 
00143     static void Initialize();
00144     unsigned int getSocketHandle(const XERCES_CPP_NAMESPACE_QUALIFIER XMLUri&  urlSource);
00145 
00146 };
00147 
00148 
00149 inline unsigned int XSECBinHTTPURIInputStream::curPos() const
00150 {
00151     return fBytesProcessed;
00152 }
00153 
00154 
00155 #endif // XSECBINHTTPURIINPUTSTREAM_HEADER

Generated on Sun Jul 3 17:37:27 2005 for XML-Security-C by  doxygen 1.4.2