Пример #1
0
IncomingConnection* Server::Accept() {
    if (_terminated) throw AcceptException();

    struct sockaddr_in *client_in = new struct sockaddr_in;
    struct sockaddr *clientptr = (struct sockaddr *) client_in;
    static socklen_t clientlen = sizeof(struct sockaddr_in);
    static int newsockfd = 0;
    bzero(client_in->sin_zero, 8 * sizeof(unsigned char));

    if ((newsockfd = accept(sockfd, clientptr, &clientlen)) < 0)
        throw AcceptException();

    Rebind();
    return new IncomingConnection(newsockfd, client_in);
}
Пример #2
0
nsScannerSubstring::nsScannerSubstring( const nsAString& s )
  : mBufferList(nsnull)
  , mIsDirty(PR_TRUE)
  {
    Rebind(s);
  }
Пример #3
0
// CRowset::FInit ------------------------------------------------------------
//
// @mfunc Initialize the rowset Object
//
// @rdesc Did the Initialization Succeed
//      @flag  TRUE | Initialization succeeded
//      @flag  FALSE | Initialization failed
//
BOOL CRowset::FInit
    (
    CFileIO *   pCFileio,		//@parm IN | pointer to Fileio object
	CBaseObj *	pParentBaseObj,	//@parm IN | pointer to Base Object creating the rowset
	WCHAR *		pwszFilePath,	//@parm IN | The File Path of the csv file
	WCHAR *		pwszDataSource	//@parm IN | The datasource path
    )
{
	// Asserts
	assert(pCFileio);
	assert(pParentBaseObj);
    assert(m_pUnkOuter);
    assert(pParentBaseObj);

    LPUNKNOWN pIUnknown = m_pUnkOuter;
    m_pFileio = pCFileio;

	m_pParentObj = pParentBaseObj;
	m_pParentObj->GetOuterUnknown()->AddRef();

    //--------------------
    // Get FileInfo
    //--------------------
    // Find # of columns in the result set.
    m_cCols = m_pFileio->GetColumnCnt();
    if( m_cCols <= 0 )
        return FALSE;

	m_cbRowSize = m_pFileio->GetRowSize();
    
    if (FAILED( CreateHelperFunctions()))
        return FALSE;
    
    m_cbTotalRowSize = m_pIBuffer->cbSlot;

    //--------------------
    // Perform binding
    //--------------------
    // Bind result set columns to the first row of the internal buffer.
    // For each column bind it's data as well as length. Leave space for
    // derived status info.
    // Note that we could defer binding, but this way we can check for
    // bad errors before we begin.
    // We may need to bind again if going back and forth
    // with GetNextRows.
    assert(m_rgbRowData);
    if (FAILED( Rebind((BYTE *) GetRowBuff( m_irowMin, TRUE ))))
        return FALSE;

    // allocate utility object that manages our properties
    m_pUtilProp = new CUtilProp();
	if (!m_pUtilProp)
		return FALSE;

    // Allocate contained interface objects
    // Note that our approach is simple - we always create *all* of the Rowset interfaces
    // If our properties were read\write (i.e., could be set), we would need to
    // consult properties to known which interfaces to create.
    // Also, none of our interfaces conflict. If any did conflict, then we could
    // not just blindly create them all.
    m_pIColumnsInfo             = new CImpIColumnsInfo( this, pIUnknown );
	m_pIConvertType				= new CImpIConvertType(this, pIUnknown);
    m_pIRowset                  = new CImpIRowset( this, pIUnknown );
    m_pIRowsetIdentity          = new CImpIRowsetIdentity( this, pIUnknown );
    m_pIRowsetInfo              = new CImpIRowsetInfo( this, pIUnknown );
	m_pIAccessor                = new CImpIAccessor( this, pIUnknown );
	m_pIGetRow					= new CImpIGetRow( this, pIUnknown );

	if (!m_pFileio->IsReadOnly())
		m_pIRowsetChange		= new CImpIRowsetChange( this, pIUnknown );

	if (m_pIAccessor && FAILED(m_pIAccessor->FInit(TRUE)))
		return FALSE;

	StringCchCopyW(m_wszFilePath, sizeof(m_wszFilePath)/sizeof(WCHAR), pwszFilePath);
	StringCchCopyW(m_wszDataSourcePath, sizeof(m_wszDataSourcePath)/sizeof(WCHAR), pwszDataSource);

    // if all interfaces were created, return success
    return (BOOL) (m_pIAccessor && m_pIColumnsInfo && m_pIConvertType &&
                   m_pIRowset && m_pIRowsetIdentity && m_pIRowsetInfo &&
				   ((m_pFileio->IsReadOnly() && !m_pIRowsetChange) ||
				    (!m_pFileio->IsReadOnly() && m_pIRowsetChange)) &&
					m_pIGetRow);
}