Exemplo n.º 1
0
 // looks for "gpio" (0..16), "mode" (in..out), "pullup" (0..1), "store" (0..1) parameters in the http query
 // if "store=1" then the gpio configuration is stored in flash
 // "store" and "pullup" are optionals
 void MTD_FLASHMEM HTTPHelperConfiguration::GPIOConf(HTTPResponse* response)
 {
     char const* gpiostr = response->getRequest().query[STR_gpio];        
     char const* modestr = response->getRequest().query[STR_mode];        
     char const* pullupstr = response->getRequest().query[STR_pullup];
     bool pullup = pullupstr && f_strcmp(pullupstr, STR_1) == 0;
     char const* storestr = response->getRequest().query[STR_store];
     bool store = storestr && f_strcmp(storestr, STR_1) == 0;
     if (gpiostr && modestr)
     {
         uint8_t gpio = strtol(gpiostr, NULL, 10);
         bool mode = f_strcmp(modestr, STR_out) == 0;
         if (store)
         {
             ConfigurationManager::setGPIOParams(gpio, 
                                                 true, 
                                                 mode, 
                                                 pullup, 
                                                 false);
         }
         GPIO g(gpio);
         if (mode)
             g.modeOutput();
         else
             g.modeInput();
         g.enablePullUp(pullup);                            
     }
 }
Exemplo n.º 2
0
    void MTD_FLASHMEM HTTPGPIOResponseHTML::flush()
    {
        setStatus(STR_200_OK);
        addHeader(STR_Content_Type, STR_TEXTHTML);

        char const* cmd = getRequest().query[FSTR("cmd")];
        if (cmd && f_strcmp(cmd, FSTR("set")) == 0)
        {
            // set gpio
            HTTPHelperConfiguration::GPIOSetValue(this);
        }
        else if (cmd && f_strcmp(cmd, FSTR("conf")) == 0)
        {
            // conf gpio
            HTTPHelperConfiguration::GPIOConf(this);
        }
        
        char const* gpio = getRequest().query[STR_gpio];
        if (gpio)
        {
            uint8_t gpion = strtol(gpio, NULL, 10);
            addContent(GPIO(gpion).read()? STR_1 : STR_0);
        }
        
        HTTPResponse::flush();
    }
Exemplo n.º 3
0
 void MTD_FLASHMEM HTTPHelperConfiguration::setWiFiMode(HTTPTemplateResponse* response)
 {
     char const* Mode = response->getRequest().form[STR_Mode];
     if (f_strcmp(Mode, STR_bothsmode) == 0)
         ConfigurationManager::setWiFiMode(WiFi::ClientAndAccessPoint);
     else if (f_strcmp(Mode, STR_clientmode) == 0)
         ConfigurationManager::setWiFiMode(WiFi::Client);
     else if (f_strcmp(Mode, STR_apmode) == 0)
         ConfigurationManager::setWiFiMode(WiFi::AccessPoint);
 }
Exemplo n.º 4
0
 void MTD_FLASHMEM HTTPGPIOConfigurationResponse::flush()
 {
     if (getRequest().method == HTTPHandler::Post)
     {
         char const* gpio = getRequest().form[FSTR("GPIO")];
         if (getRequest().form[FSTR("configured")])
         {		
             // gpio enabled
             char const* mode     = getRequest().form[STR_mode];
             char const* pullUp   = getRequest().form[STR_pullup];
             ConfigurationManager::setGPIOParams(strtol(gpio, NULL, 10), true, f_strcmp(mode, STR_out) == 0, pullUp != NULL, false);
             ConfigurationManager::applyGPIO();
         }
         else if (gpio)
         {
             // gpio disabled (not configured)
             ConfigurationManager::setGPIOParams(strtol(gpio, NULL, 10), false, false, false, false);
         }
     }
     
     HTTPHelperConfiguration::GPIOSetValue(this);
     
     LinkedCharChunks* linkedChunks = addParamCharChunks(FSTR("GPIOS"));
     for (uint32_t i = 0; i != 16; ++i)
     {
         if (i != 1 && i != 3 && (i < 6 || i > 11))
         {
             bool configured, isOutput, pullUp, value;
             ConfigurationManager::getGPIOParams(i, &configured, &isOutput, &pullUp, &value);
             
             linkedChunks->addChunk(f_printf(FSTR("<tr> <td>%d</td> <td><form method='POST'>"), i), true);
             linkedChunks->addChunk(f_printf(FSTR("Enabled <input type='checkbox' name='configured' value='1' onclick=\"document.getElementById('GPIO%d').disabled=!this.checked\" %s>"), i, configured? STR_checked:STR_), true);
             linkedChunks->addChunk(f_printf(FSTR("<fieldset class='inline' id='GPIO%d' %s>"), i, configured? STR_:STR_disabled), true);
             linkedChunks->addChunk(f_printf(FSTR("<select name='mode'><option value='in' %s>IN</option><option value='out' %s>OUT</option></select>"), 
                                            isOutput? STR_:STR_selected, 
                                            isOutput? STR_selected:STR_), 
                                   true);
             linkedChunks->addChunk(f_printf(FSTR("     PullUp <input type='checkbox' name='pullup' value='1' %s> </fieldset>"), pullUp? STR_checked:STR_), true);
             linkedChunks->addChunk(f_printf(FSTR("<input type='hidden' name='GPIO' value='%d'>"), i), true);
             linkedChunks->addChunk(FSTR("<input type='submit' value='Save'></form></td>"));
             if (configured)
             {
                 if (isOutput)
                 {
                     linkedChunks->addChunk(f_printf(FSTR("<td><a href='confgpio?gpio=%d&val=%d&store=1' class='link_button2'>%s</a></td> </tr>"), i, !value, value? STR_HI:STR_LO), true);
                 }
                 else
                 {
                     linkedChunks->addChunk(f_printf(FSTR("<td>%s</td> </tr>"), GPIO(i).read()? STR_HI:STR_LO), true);
                 }
             }
             else
             {
                 linkedChunks->addChunk(FSTR("<td></td></tr>"));
             }
         }
     }			
         
     HTTPTemplateResponse::flush();
 }
Exemplo n.º 5
0
// filename can stay in Ram or Flash
bool MTD_FLASHMEM FlashFileSystem::find(char const* filename, char const** mimetype, void const** data, uint16_t* dataLength)
{
	char const* curc = (char const*)(FLASH_MAP_START + FLASHFILESYSTEM_POS);
	
	// check magic
	if (MAGIC != *((uint32_t const*)curc))
		return false;	// not found
	curc += 4;
	
	// find file
	while (true)
	{
		// filename length
		uint8_t filenamelen = getByte(curc);
		curc += 1;
		uint8_t mimetypelen = getByte(curc);
		curc += 1;
		uint16_t filecontentlen = getWord(curc); 
		curc += 2;
		if (filenamelen == 0)
			return false;	// not found
		// check filename
		if (f_strcmp(filename, curc) == 0)
		{
			// found
			*mimetype   = curc + filenamelen;
			*data       = (void*)(*mimetype + mimetypelen);
			*dataLength = filecontentlen;
			return true;
		}
		// bypass this file
		curc += filenamelen + mimetypelen + filecontentlen;			
	}
}
Exemplo n.º 6
0
 void MTD_FLASHMEM HTTPHelperConfiguration::setClientModeIP(HTTPTemplateResponse* response)
 {
     ConfigurationManager::setClientIPParams(f_strcmp(response->getRequest().form[STR_CLIPMOD], STR_stcIP) == 0,
                                             response->getRequest().form[STR_CLIP],
                                             response->getRequest().form[STR_CLMSK],
                                             response->getRequest().form[STR_CLGTW]);
 }
Exemplo n.º 7
0
/****************************************************************************
Desc:
****************************************************************************/
FLMBOOL FlagSet::removeElem(
	FLMBYTE *	pElem)
{
	FLMBOOL 		bElemExisted = FALSE;

	for( FLMUINT uiLoop = 0; uiLoop < m_uiNumElems; uiLoop++)
	{
		if( f_strcmp( (char *)pElem, (char *)m_ppucElemArray[ uiLoop]) == 0)
		{
			bElemExisted = TRUE;
			if( uiLoop < m_uiNumElems - 1)
			{
				f_free( &m_ppucElemArray[ uiLoop]);
				
				f_memmove( &m_ppucElemArray[ uiLoop], 
					&m_ppucElemArray[ uiLoop + 1], 
					(m_uiNumElems - ( uiLoop + 1)) * sizeof( FLMBYTE *));
					
				f_memmove( &m_pbFlagArray[ uiLoop], 
					&m_pbFlagArray[ uiLoop + 1], 
					(m_uiNumElems - ( uiLoop + 1)) * sizeof( FLMBYTE *));
			}
			
			m_uiNumElems--;
		}
	}
	
	return( bElemExisted);
}
Exemplo n.º 8
0
void MTD_FLASHMEM HTTPHandler::dispatch() {
  for (uint32_t i = 0; i != m_routesCount; ++i) {
    if (f_strcmp(FSTR("*"), m_routes[i].page) == 0 ||
        t_strcmp(m_request.requestedPage, CharIterator(m_routes[i].page)) == 0) {
      (this->*m_routes[i].pageHandler)();
      return;
    }
  }
  // not found (routes should always have route "*" to handle 404 not found)
}
Exemplo n.º 9
0
//报告文件的类型
//fname:文件名
//返回值:文件类型编号.0XFF,表示无法识别.
u8 f_typetell(u8 *fname)
{
	u8 tbuf[5];
	u8 i=0,j;
	while(i<200)
	{
		i++;
		if(*fname=='\0')break;//偏移到了最后了.
		fname++;
	}
	if(i==200)return 0XFF;//错误的字符串.
	fname--;		//最后一个字符的位置
	for(i=0;i<5;i++)//复制后缀名
	{
		tbuf[4-i]=*fname;
		fname--;
	}
	if(tbuf[0]=='.')//后缀名为4个字节
	{
		tbuf[0]=f_upper(tbuf[1]);
		tbuf[1]=f_upper(tbuf[2]);
		tbuf[2]=f_upper(tbuf[3]);
		tbuf[3]=f_upper(tbuf[4]);
		tbuf[4]='\0';//加入结束符
	}else if(tbuf[1]=='.')//3个字节
	{
		tbuf[0]=f_upper(tbuf[2]);
		tbuf[1]=f_upper(tbuf[3]);
		tbuf[2]=f_upper(tbuf[4]);  
		tbuf[3]='\0';//加入结束符
	}else if(tbuf[2]=='.')//2个字节
	{
		tbuf[0]=f_upper(tbuf[3]);
		tbuf[1]=f_upper(tbuf[4]);   
		tbuf[2]='\0';//加入结束符
	}else if(tbuf[3]=='.')//1个字节
	{
		tbuf[0]=f_upper(tbuf[4]);    
		tbuf[1]='\0';//加入结束符
	}else return 0XFF;//未找到后缀名.
	for(i=0;i<4;i++)
	{
		for(j=0;j<13;j++)
		{
			if(*FILE_TYPE_TAB[i][j]==0)break;//此组已经没有可对比的成员了.
			if(f_strcmp((u8 *)FILE_TYPE_TAB[i][j],tbuf))//找到了
			{
				return (i<<4)|j;
			}
		}
	}
	return 0XFF;//没找到
		 			   
}
Exemplo n.º 10
0
/****************************************************************************
Desc: Given a data file name, returns the file's number
****************************************************************************/
RCODE F_MultiFileHdl::getFileNum(
	const char *	pszFileName,
	FLMUINT *		puiFileNum)
{
	FLMUINT		uiCnt = 0;
	FLMUINT		uiDigit;
	FLMUINT		uiFileNum = 0;
	RCODE			rc = NE_FLM_OK;

	if( f_strlen( pszFileName) != 11) // XXXXXXXX.64
	{
		rc = RC_SET( NE_FLM_IO_INVALID_FILENAME);
		goto Exit;
	}

	if( f_strcmp( &pszFileName[ 8], ".64") != 0)
	{
		rc = RC_SET( NE_FLM_IO_INVALID_FILENAME);
		goto Exit;
	}

	while( uiCnt < 8)
	{
		uiDigit = pszFileName[ uiCnt];
		if( uiDigit >= NATIVE_LOWER_A && uiDigit <= NATIVE_LOWER_F)
		{
			uiDigit = (FLMUINT)(uiDigit - NATIVE_LOWER_A) + 10;
		}
		else if( uiDigit >= NATIVE_UPPER_A && uiDigit <= NATIVE_UPPER_F)
		{
			uiDigit = (FLMUINT)(uiDigit - NATIVE_UPPER_A) + 10;
		}
		else if( uiDigit >= NATIVE_ZERO && uiDigit <= NATIVE_NINE)
		{
			uiDigit -= NATIVE_ZERO;
		}
		else
		{
			rc = RC_SET( NE_FLM_IO_INVALID_FILENAME);
			goto Exit;
		}

		uiFileNum <<= 4;
		uiFileNum += uiDigit;
		uiCnt++;
	}

	*puiFileNum = uiFileNum;

Exit:

	return( rc);
}
Exemplo n.º 11
0
FSTATIC FLMBOOL f_fileMeetsFindCriteria(
	F_IO_FIND_DATA *		pFindData)
{
	// Fail ".." (PARENT) and "." (CURRENT) directories.  Then,
	// if the file found possesses any of the search attributes, it's
	// a match.

	if( !((f_strcmp( pFindData->findBuffer.cFileName, "..") == 0) ||
    (f_strcmp( pFindData->findBuffer.cFileName, ".") == 0) ||
	 (!(pFindData->uiSearchAttrib & F_IO_FA_DIRECTORY) &&
		(pFindData->findBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))))
	{
		if( (pFindData->findBuffer.dwFileAttributes &
				pFindData->uiSearchAttrib) ||
			((pFindData->uiSearchAttrib & F_IO_FA_NORMAL) &&
				(pFindData->findBuffer.dwFileAttributes == 0)))
		{
			return( TRUE);
		}
	}

	return( FALSE);
}
Exemplo n.º 12
0
/****************************************************************************
Desc:
****************************************************************************/
FLMBOOL FlagSet::setElemFlag(
	FLMBYTE *	pElem)
{
	FLMBOOL 		bIsInSet = FALSE;

	for( FLMUINT uiLoop = 0; uiLoop < m_uiNumElems; uiLoop++)
	{
		if( f_strcmp( (char *)pElem, (char *)m_ppucElemArray[ uiLoop]) == 0 &&
			  !m_pbFlagArray [uiLoop])
		{
			m_pbFlagArray[ uiLoop] = TRUE;
			bIsInSet = TRUE;
			break;
		}
	}
	
	return( bIsInSet);
}
Exemplo n.º 13
0
 // looks for "gpio" (0..16), "val" (0..1) and "store" (0..1) parameters in the http query
 // if "store=1" then the gpio value is stored in flash
 // "store" is optional
 void MTD_FLASHMEM HTTPHelperConfiguration::GPIOSetValue(HTTPResponse* response)
 {
     char const* gpio = response->getRequest().query[STR_gpio];
     char const* val  = response->getRequest().query[FSTR("val")];
     char const* storestr = response->getRequest().query[STR_store];
     bool store = storestr && f_strcmp(storestr, STR_1) == 0;
     if (gpio && val)
     {
         uint8_t gpion = strtol(gpio, NULL, 10);
         bool newvalue = *val - '0';
         if (store)
         {
             bool configured, isOutput, pullUp, oldvalue;
             ConfigurationManager::getGPIOParams(gpion, &configured, &isOutput, &pullUp, &oldvalue);
             ConfigurationManager::setGPIOParams(gpion, configured, isOutput, pullUp, newvalue);                
         }
         GPIO(gpion).write(newvalue);
     }
 }
Exemplo n.º 14
0
/****************************************************************************
Desc:	Search through the list of INI_STRUCTs for a particular name
****************************************************************************/
INI_LINE * F_IniFile::findParam(
	const char *	pszParamName)
{
	INI_LINE *	pCurLine = m_pFirstLine;
	
	while( pCurLine)
	{
		if (pCurLine->pszParamName)
		{
			if (f_strcmp( pszParamName, pCurLine->pszParamName) == 0)
			{
				return pCurLine;
			}
		}

		pCurLine = pCurLine->pNext;
	}

	return( NULL);
}
Exemplo n.º 15
0
    void MTD_FLASHMEM DefaultHTTPHandler::dispatch()
    {
#if (FDV_INCLUDE_SERIALBINARY == 1)            
        if (ConfigurationManager::getSerialBinary() && ConfigurationManager::getSerialBinary()->isReady())
        {
            StringList* routes = ConfigurationManager::getSerialBinary()->getHTTPRoutes();
            if (routes)
            {                
                for (uint32_t i = 0; i != routes->size(); ++i)
                {
                    if (f_strcmp(FSTR("*"), routes->getItem(i)) == 0 || t_strcmp(getRequest().requestedPage, CharIterator(routes->getItem(i))) == 0)
                    {
                        ConfigurationManager::getSerialBinary()->send_CMD_HTTPREQUEST(i, this);
                        return;
                    }
                }
            }
        }
#endif            
        HTTPHandler::dispatch();
    }
Exemplo n.º 16
0
/****************************************************************************
Desc:
****************************************************************************/
RCODE IRegressionTestImpl::truncatedValueFromStoreDefectTest( void)
{
	RCODE					rc = NE_XFLM_OK;
	FLMBOOL				bTransBegun = FALSE;
	FLMBOOL				bDibCreated = FALSE;
	FLMUINT				uiRootId = 0;
	FLMUINT				uiTextValId = 0;
	FLMUINT				uiNumVal1Id = 0;
	FLMUINT				uiNumVal2Id = 0;
	FLMUINT				uiNumVal3Id = 0;
	FLMUINT				uiBinValId = 0;
	FLMBYTE				pucBinVal[] = BIN_VAL;
	FLMUINT64			ui64RootId = 0;
	FLMUINT				uiNameId = 0;
	IF_DOMNode *		pRootNode = NULL;
	IF_DOMNode *		pValNode = NULL;

	beginTest( 	
		"Truncated Value From Store Defect Test",
		"Make sure values make it back from disk intact",
		"Add values to database/close database/open database/verify values",
		"");

	if ( RC_BAD( rc = initCleanTestState( DB_NAME_STR)))
	{
		goto Exit;
	}
	bDibCreated = TRUE;

	if ( RC_BAD( rc = m_pDb->transBegin( XFLM_UPDATE_TRANS)))
	{
		MAKE_ERROR_STRING( "transBegin failed", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = TRUE;

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"root",
		XFLM_NODATA_TYPE,
		&uiRootId)))
	{
		MAKE_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"text_val",
		XFLM_TEXT_TYPE,
		&uiTextValId)))
	{
		MAKE_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"uint64_val",
		XFLM_NUMBER_TYPE,
		&uiNumVal1Id)))
	{
		MAKE_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"int64_val",
		XFLM_NUMBER_TYPE,
		&uiNumVal2Id)))
	{
		MAKE_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"uint_val",
		XFLM_NUMBER_TYPE,
		&uiNumVal3Id)))
	{
		MAKE_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"bin_val",
		XFLM_BINARY_TYPE,
		&uiBinValId)))
	{
		MAKE_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createRootElement(
		XFLM_DATA_COLLECTION,
		uiRootId,
		&pRootNode)))
	{
		MAKE_ERROR_STRING( "createRootElement failed.", m_szDetails, rc);
		goto Exit;
	}
	
	if( RC_BAD( rc = pRootNode->getNodeId( m_pDb, &ui64RootId)))
	{
		goto Exit;
	}

	if ( RC_BAD( rc = pRootNode->createNode( m_pDb,
		ELEMENT_NODE, uiTextValId, XFLM_FIRST_CHILD,	&pValNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pValNode->setUTF8( m_pDb, 
		(FLMBYTE *)TEXT_VAL, f_strlen( TEXT_VAL))))
	{
		MAKE_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pRootNode->createNode( m_pDb,
		ELEMENT_NODE, uiNumVal1Id, XFLM_FIRST_CHILD,	&pValNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pValNode->setUINT64( m_pDb, UINT64_VAL)))
	{
		MAKE_ERROR_STRING( "setUINT64 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pRootNode->createNode( m_pDb,
		ELEMENT_NODE, uiNumVal2Id, XFLM_FIRST_CHILD,	&pValNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pValNode->setINT64( m_pDb, INT64_VAL)))
	{
		MAKE_ERROR_STRING( "setINT64 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pRootNode->createNode( m_pDb,
		ELEMENT_NODE, uiNumVal3Id, XFLM_FIRST_CHILD,	&pValNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pValNode->setUINT( m_pDb, UINT_VAL)))
	{
		MAKE_ERROR_STRING( "setUINT failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pRootNode->createNode( m_pDb,
		ELEMENT_NODE, uiBinValId, XFLM_FIRST_CHILD,	&pValNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pValNode->setBinary( m_pDb, pucBinVal, BIN_VAL_LEN, TRUE)))
	{
		MAKE_ERROR_STRING( "setBinary failed", m_szDetails, rc);
		goto Exit;
	}

	// close the database to force the values to disk

	if ( RC_BAD( rc = m_pDb->transCommit()))
	{
		goto Exit;
	}
	bTransBegun = FALSE;

	pRootNode->Release();
	pRootNode = NULL;
	pValNode->Release();
	pValNode = NULL;
	m_pDb->Release();
	m_pDb = NULL;

	if( RC_BAD( rc = m_pDbSystem->dbOpen( DB_NAME_STR, NULL, NULL, 
		NULL, FALSE, &m_pDb)))
	{
		MAKE_ERROR_STRING( "dbOpen failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->transBegin( XFLM_READ_TRANS)))
	{
		MAKE_ERROR_STRING( "transBegin failed", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = TRUE;

	if ( RC_BAD( rc = m_pDb->getNode(
		XFLM_DATA_COLLECTION, ui64RootId, &pRootNode)))
	{
		MAKE_ERROR_STRING( "getNode failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pRootNode->getFirstChild(
		m_pDb, &pValNode)))
	{
		MAKE_ERROR_STRING( "getFirstChild failed", m_szDetails, rc);
		goto Exit;
	}

	for(;;)
	{
		if ( RC_BAD( rc = pValNode->getNameId( m_pDb, &uiNameId)))
		{
			MAKE_ERROR_STRING( "getNameId failed", m_szDetails, rc);
			goto Exit;
		}

		if ( uiNameId == uiTextValId)
		{
			char szTemp[100];

			if ( RC_BAD( rc = pValNode->getUTF8( 
				m_pDb, (FLMBYTE *)szTemp, sizeof( szTemp), 
				0, sizeof(szTemp) -1)))
			{
				MAKE_ERROR_STRING( "getUTF8 failed", m_szDetails, rc);
				goto Exit;
			}

			if ( f_strcmp( szTemp, TEXT_VAL) != 0)
			{
				rc = RC_SET( NE_XFLM_DATA_ERROR);
				MAKE_ERROR_STRING( "Unexpected text value found", m_szDetails, rc);
				goto Exit;
			}
			// flag this name id as visited
			uiTextValId = 0;
		}
		else if ( uiNameId == uiNumVal1Id)
		{
			FLMUINT64	ui64Temp;

			if ( RC_BAD( rc = pValNode->getUINT64( m_pDb, &ui64Temp)))
			{
				MAKE_ERROR_STRING( "getUINT64 Failed", m_szDetails, rc);
				goto Exit;
			}

			if ( ui64Temp != UINT64_VAL)
			{
				rc = RC_SET( NE_XFLM_DATA_ERROR);
				MAKE_ERROR_STRING( "Unexpected uint64 value found", m_szDetails, rc);
				goto Exit;
			}
			uiNumVal1Id = 0;
		}
		else if ( uiNameId == uiNumVal2Id)
		{
			FLMINT64	i64Temp;

			if ( RC_BAD( rc = pValNode->getINT64( m_pDb, &i64Temp)))
			{
				goto Exit;
			}

			if ( i64Temp != INT64_VAL)
			{
				rc = RC_SET( NE_XFLM_DATA_ERROR);
				MAKE_ERROR_STRING( "Unexpected int64 value found", m_szDetails, rc);
				goto Exit;
			}
			uiNumVal2Id = 0;
		}
		else if ( uiNameId == uiNumVal3Id)
		{
			FLMUINT	uiTemp;

			if ( RC_BAD( rc = pValNode->getUINT( m_pDb, &uiTemp)))
			{
				MAKE_ERROR_STRING( "getUINT failed", m_szDetails, rc);
				goto Exit;
			}

			if ( uiTemp != UINT_VAL)
			{
				rc = RC_SET( NE_XFLM_DATA_ERROR);
				MAKE_ERROR_STRING( "Unexpected uint value found", m_szDetails, rc);
				goto Exit;
			}
			uiNumVal3Id = 0;
		}
		else if ( uiNameId == uiBinValId)
		{
			FLMBYTE	pucTemp[BIN_VAL_LEN];
			FLMUINT	uiTmp;

			if ( RC_BAD( rc = pValNode->getBinary( 
				m_pDb,
				pucTemp,
				0,
				sizeof(pucTemp),
				&uiTmp)))
			{
				MAKE_FLM_ERROR_STRING( "getBinary failed.", m_szDetails, rc);
				goto Exit;
			}

			if ( uiTmp != BIN_VAL_LEN ||
				f_memcmp( pucTemp, pucBinVal, uiTmp) != 0)
			{
				rc = RC_SET( NE_XFLM_DATA_ERROR);
				MAKE_ERROR_STRING( "Unexpected binary value found", m_szDetails, rc);
				goto Exit;
			}
			uiBinValId = 0;
		}
		else
		{
			rc = RC_SET( NE_XFLM_DATA_ERROR);
			MAKE_ERROR_STRING( "Unexpected node found", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pValNode->getNextSibling( m_pDb, &pValNode)))
		{
			if ( rc != NE_XFLM_DOM_NODE_NOT_FOUND || uiTextValId ||
				uiNumVal1Id || uiNumVal2Id || uiNumVal3Id || uiBinValId)
			{
				rc = RC_SET( NE_XFLM_DATA_ERROR);
				MAKE_ERROR_STRING( "Node not found", m_szDetails, rc);
				goto Exit;
			}
			else
			{
				rc = NE_XFLM_OK;
				break;
			}
		}
	}

	endTest("PASS");

Exit:

	if( pRootNode)
	{
		pRootNode->Release();
	}

	if( pValNode)
	{
		pValNode->Release();
	}

	if( RC_BAD( rc))
	{
		endTest("FAIL");
	}

	if( bTransBegun)
	{
		if( RC_OK( rc))
		{
			rc = m_pDb->transCommit();
		}
		else
		{
			m_pDb->transAbort();
		}
	}

	shutdownTestState( DB_NAME_STR, bDibCreated);
	return( rc);
}
Exemplo n.º 17
0
/****************************************************************************
Desc:
****************************************************************************/
RCODE IRegressionTestImpl::leftoverIndexKeyDefectTest( void)
{
	RCODE					rc = NE_XFLM_OK;
	IF_DataVector *	pSearchKey = NULL;
	IF_DOMNode *		pNode = NULL;
	FLMBOOL				bDibCreated = FALSE;
	FLMBOOL				bTransBegun = FALSE;
	IF_DOMNode *		pDoc = NULL;
	IF_DOMNode *		pAttr = NULL;
	IF_DOMNode *		pIndex = NULL;
	IF_DOMNode *		pComp = NULL;
	FLMUINT				uiIxValName = 0;
	char					szBuf[100];
	FLMUINT				uiTmp;

	beginTest(
		"Unlink Node Bad Ix Key Defect Test",
		"",
		"Self-explanatory",
		"");

	if ( RC_BAD( rc = initCleanTestState( DB_NAME_STR)))
	{
		goto Exit;
	}
	bDibCreated = TRUE;

	if ( RC_BAD( rc = m_pDb->transBegin( XFLM_UPDATE_TRANS)))
	{
		MAKE_ERROR_STRING( "transBegin failed.", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = TRUE;

	if ( RC_BAD( rc = m_pDb->createElementDef( 
		NULL, "indexed val", XFLM_TEXT_TYPE, &uiIxValName)))
	{
		MAKE_ERROR_STRING( "createElementDef failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createDocument( 
		XFLM_DATA_COLLECTION,
		&pDoc)))
	{
		MAKE_ERROR_STRING( "createDocument failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pDoc->createNode( 
		m_pDb, ELEMENT_NODE, uiIxValName, XFLM_FIRST_CHILD,
		&pNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->documentDone( pDoc)))
	{
		MAKE_ERROR_STRING( "documentDone failed.", m_szDetails, rc);
		goto Exit;
	}

	// create an index definition that references the elem we made

	if ( RC_BAD( rc = m_pDb->createRootElement(
		XFLM_DICT_COLLECTION,
		ELM_INDEX_TAG,
		&pIndex)))
	{
		MAKE_ERROR_STRING( "createRootElement failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pIndex->createAttribute( m_pDb, ATTR_NAME_TAG, &pAttr)))
	{
		MAKE_ERROR_STRING( "createAttribute failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pAttr->setUTF8( m_pDb, 
		(FLMBYTE *)"index_2")))
	{
		MAKE_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pIndex->createAttribute( m_pDb, ATTR_DICT_NUMBER_TAG, &pAttr)))
	{
		MAKE_ERROR_STRING( "createAttribute failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pAttr->setUINT( m_pDb, 123)))
	{
		MAKE_ERROR_STRING( "setUINT failed.", m_szDetails, rc);
		goto Exit;
	}

	// xflaim:ElementPath must have one or more xflaim:ElementComponent
	// or one or more xflaim:AttributeComponent sub-elements

	if ( RC_BAD( rc = pIndex->createNode(
		m_pDb,
		ELEMENT_NODE,
		ELM_ELEMENT_COMPONENT_TAG,
		XFLM_FIRST_CHILD,
		&pComp)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pComp->createAttribute(
		m_pDb,
		ATTR_DICT_NUMBER_TAG,
		&pAttr)))
	{
		MAKE_ERROR_STRING( "createAttribute failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pAttr->setUINT( m_pDb, uiIxValName)))
	{
		MAKE_ERROR_STRING( "setUINT failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pComp->createAttribute(
		m_pDb,
		ATTR_KEY_COMPONENT_TAG,
		&pAttr)))
	{
		MAKE_ERROR_STRING( "createAttribute failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pAttr->setUINT( m_pDb, 1)))
	{
		MAKE_ERROR_STRING( "setUINT failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pComp->createAttribute(
		m_pDb,
		ATTR_REQUIRED_TAG,
		&pAttr)))
	{
		MAKE_ERROR_STRING( "createAttribute failed.", m_szDetails, rc);
		goto Exit;

	}

	if ( RC_BAD( rc = pAttr->setUINT( m_pDb, 1)))
	{
		MAKE_ERROR_STRING( "setUINT failed.", m_szDetails, rc);
		goto Exit;
	}

	if (RC_BAD( rc = m_pDb->documentDone( pIndex)))
	{
		MAKE_ERROR_STRING( "documentDone failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDbSystem->createIFDataVector( &pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "createIFDataVector failed", m_szDetails, rc);
		goto Exit;
	}

	// we should now have one empty key for this index

	if ( RC_BAD( rc = m_pDb->keyRetrieve( 123, NULL, XFLM_FIRST, pSearchKey)))
	{
		MAKE_ERROR_STRING( "keyRetrieve failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( pSearchKey->getDataLength( 0) != 0)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "Invalid key found.", m_szDetails, rc);
		goto Exit;
	}

	// now set a value

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb,
		(FLMBYTE *)"new value")))
	{
		MAKE_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->documentDone( pDoc)))
	{
		MAKE_ERROR_STRING( "documentDone failed.", m_szDetails, rc);
		goto Exit;
	}

	// we should have a key with the new value in it

	if ( RC_BAD( rc = m_pDb->keyRetrieve( 123, NULL, XFLM_FIRST, pSearchKey)))
	{
		MAKE_ERROR_STRING( "keyRetrieve failed.", m_szDetails, rc);
		goto Exit;
	}

	uiTmp = sizeof( szBuf);
	if ( RC_BAD( rc = pSearchKey->getUTF8( 0, (FLMBYTE *)szBuf, &uiTmp)))
	{
		MAKE_ERROR_STRING( "getUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( f_strcmp( szBuf, "new value") != 0)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "invalid key found.", m_szDetails, rc);
		goto Exit;
	}

	// now delete pNode

	if ( RC_BAD( rc = pNode->deleteNode( m_pDb)))
	{
		MAKE_ERROR_STRING( "deleteNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->documentDone( pDoc)))
	{
		MAKE_ERROR_STRING( "documentDone failed.", m_szDetails, rc);
		goto Exit;
	}

	// there should be no key now

	if ( RC_OK( rc = m_pDb->keyRetrieve( 123, NULL, XFLM_FIRST, pSearchKey)))
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "Invalid key found.", m_szDetails, rc);
		goto Exit;
	}

	if ( rc != NE_XFLM_EOF_HIT)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "Unexpected rc from keyRetrieve", m_szDetails, rc);
		goto Exit;
	}

	// create the node again and stream in the data. This will force the
	// creation of a DATA_NODE to hold the data

	if ( RC_BAD( rc = pDoc->createNode( 
		m_pDb, ELEMENT_NODE, uiIxValName, XFLM_FIRST_CHILD,
		&pNode)))
	{
		MAKE_ERROR_STRING( "createNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb, 
		(FLMBYTE *)"Streamed ", 9, FALSE)))
	{
		MAKE_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb, 
		(FLMBYTE *)"in ", 3, FALSE)))
	{
		MAKE_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb,
		(FLMBYTE *)"value", 5, TRUE)))
	{
		MAKE_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->documentDone( pDoc)))
	{
		MAKE_ERROR_STRING( "documentDone failed.", m_szDetails, rc);
		goto Exit;
	}

	// we should have a new key now

	if ( RC_BAD( rc = m_pDb->keyRetrieve( 123, NULL, XFLM_FIRST, pSearchKey)))
	{
		MAKE_ERROR_STRING( "keyRetrieve failed.", m_szDetails, rc);
		goto Exit;
	}

	uiTmp = sizeof( szBuf);
	if ( RC_BAD( rc = pSearchKey->getUTF8( 0, (FLMBYTE *)szBuf, &uiTmp)))
	{
		MAKE_ERROR_STRING( "getUTF8 failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( f_strcmp( szBuf, "Streamed in value") != 0)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "invalid key found.", m_szDetails, rc);
		goto Exit;
	}

	// delete the node

	if ( RC_BAD( rc = pNode->deleteNode( m_pDb)))
	{
		MAKE_ERROR_STRING( "deleteNode failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->documentDone( pDoc)))
	{
		MAKE_ERROR_STRING( "documentDone failed.", m_szDetails, rc);
		goto Exit;
	}

	// we should have no key left

	if ( RC_OK( rc = m_pDb->keyRetrieve( 123, NULL, XFLM_FIRST, pSearchKey)))
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "Invalid key found.", m_szDetails, rc);
		goto Exit;
	}

	if ( rc != NE_XFLM_EOF_HIT)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_ERROR_STRING( "Unexpected rc from keyRetrieve", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->transCommit()))
	{
		MAKE_ERROR_STRING( "commitTrans failed.", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = FALSE;

	endTest("PASS");


Exit:

	if( pSearchKey)
	{
		pSearchKey->Release();
	}

	if( pNode)
	{
		pNode->Release();
	}

	if( pAttr)
	{
		pAttr->Release();
	}

	if( pIndex)
	{
		pIndex->Release();
	}

	if( pDoc)
	{
		pDoc->Release();
	}

	if( pComp)
	{
		pComp->Release();
	}

	if( RC_BAD( rc))
	{
		endTest("FAIL");
	}

	if( bTransBegun)
	{
		if( RC_OK( rc))
		{
			rc = m_pDb->transCommit();
		}
		else
		{
			m_pDb->transAbort();
		}
	}

	shutdownTestState( DB_NAME_STR, bDibCreated);
	return( rc);
}
Exemplo n.º 18
0
/****************************************************************************
Desc:
****************************************************************************/
RCODE IRegressionTestImpl::compoundIndexedValueDeleteTest( void)
{

	RCODE					rc = NE_XFLM_OK;
	IF_DataVector *	pSearchKey = NULL;
	FLMBOOL				bTransBegun = FALSE;
	FLMBOOL				bDibCreated = FALSE;
	IF_DOMNode *		pRoot = NULL;
	IF_DOMNode *		pNode = NULL;
	FLMUINT				uiFooId = 0;
	FLMUINT				uiBarId = 0;
	char					szBuf[100];
	FLMUINT				uiTemp = 0;
	const char *		pszIndex = 
	"<xflaim:Index "
			"xmlns:xflaim=\"http://www.novell.com/XMLDatabase/Schema\" "
			"xflaim:name=\"foo+bar_IX\" "
			"xflaim:DictNumber=\"99\">"
			"<xflaim:ElementComponent xflaim:name=\"foo\" "
				"xflaim:KeyComponent=\"1\" >"
				"<xflaim:ElementComponent "
					"xflaim:name=\"bar\" "
					"xflaim:KeyComponent=\"2\" "
					"xflaim:IndexOn=\"value\">"
				"</xflaim:ElementComponent>"
			"</xflaim:ElementComponent>"
		"</xflaim:Index>";

	beginTest( 	
		"Compound Indexed Value Delete Test",
		"",
		"Self-explanatory",
		"");

	if ( RC_BAD( rc = initCleanTestState( DB_NAME_STR)))
	{
		goto Exit;
	}
	bDibCreated = TRUE;

	if ( RC_BAD( rc = m_pDb->transBegin( XFLM_UPDATE_TRANS)))
	{
		MAKE_ERROR_STRING( "beginTrans failed.", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = TRUE;

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"foo",
		XFLM_NODATA_TYPE,
		&uiFooId)))
	{
		MAKE_FLM_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createElementDef(
		NULL,
		"bar",
		XFLM_TEXT_TYPE,
		&uiBarId)))
	{
		MAKE_FLM_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createRootElement( 
		XFLM_DATA_COLLECTION, uiFooId, &pRoot)))
	{
		MAKE_FLM_ERROR_STRING( "createRootElement failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pRoot->createNode( 
		m_pDb, ELEMENT_NODE, uiBarId, XFLM_FIRST_CHILD, &pNode)))
	{
		MAKE_FLM_ERROR_STRING( "createNode failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb, 
		(FLMBYTE *)"bar ", 4, FALSE)))
	{
		MAKE_FLM_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb, (FLMBYTE *)"value", 5, TRUE)))
	{
		MAKE_FLM_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = importBuffer( pszIndex, XFLM_DICT_COLLECTION)))
	{
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->transCommit()))
	{
		MAKE_FLM_ERROR_STRING( "transCommit failed", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = FALSE;

	if ( RC_BAD( rc = m_pDbSystem->createIFDataVector( &pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "createIFDataVector failed", m_szDetails, rc);
		goto Exit;
	}

	// A key better have been generated...

	if ( RC_BAD( rc = m_pDb->keyRetrieve(
		99, NULL, XFLM_FIRST | XFLM_MATCH_DOC_ID, pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "No index keys generated", m_szDetails, rc);
		goto Exit;
	}

	uiTemp = sizeof( szBuf);
	if ( RC_BAD( rc = pSearchKey->getUTF8( 1, (FLMBYTE *)szBuf, &uiTemp)))
	{
		MAKE_FLM_ERROR_STRING( "getUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( f_strcmp( szBuf, "bar value") != 0)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_FLM_ERROR_STRING( "unexpected index key value", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->transBegin( XFLM_UPDATE_TRANS)))
	{
		MAKE_FLM_ERROR_STRING( "transBegin failed", m_szDetails, rc);
		goto Exit;
	}
	bTransBegun = TRUE;

	if ( RC_BAD( rc = pNode->deleteNode( m_pDb)))
	{
		MAKE_FLM_ERROR_STRING( "deleteNode failed", m_szDetails, rc);
		goto Exit;
	}

	// There better be no second component now

	if ( RC_BAD( rc = m_pDb->keyRetrieve(
		99, NULL, XFLM_FIRST | XFLM_MATCH_DOC_ID, pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "No index keys generated", m_szDetails, rc);
		goto Exit;
	}

	uiTemp = sizeof( szBuf);
	if ( RC_OK( rc = pSearchKey->getUTF8( 1, (FLMBYTE *)szBuf, &uiTemp)))
	{
		MAKE_FLM_ERROR_STRING( "getUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( rc == NE_XFLM_NOT_FOUND)
	{
		rc = NE_XFLM_OK;
	}
	else
	{
		goto Exit;
	}

	endTest("PASS");

Exit:

	if ( RC_BAD( rc))
	{
		endTest("FAIL");
	}

	if ( pSearchKey)
	{
		pSearchKey->Release();
	}

	if ( pNode)
	{
		pNode->Release();
	}

	if ( pRoot)
	{
		pRoot->Release();
	}

	if ( bTransBegun)
	{
		if ( RC_OK( rc))
		{
			rc = m_pDb->transCommit();
		}
		else
		{
			m_pDb->transAbort();
		}
	}

	shutdownTestState( DB_NAME_STR, bDibCreated);
	return rc;
}
Exemplo n.º 19
0
/****************************************************************************
Desc:
****************************************************************************/
RCODE IRegressionTestImpl::rflRecoverDefectTests( void)
{
	RCODE						rc = NE_XFLM_OK;
	IF_Backup *				pBackup = NULL;
	IF_DOMNode *			pNode = NULL;
	FLMUINT					uiDefNum;
	FLMBOOL					bStartedTrans = FALSE;
	FLMBOOL					bDibCreated = FALSE;
	FLMUINT					uiEncDef = 0;
	IF_DataVector *		pSearchKey = NULL;
	char						szTmp[ 100];
	FLMUINT					uiTmp = 0;
	const char *			pszIndex = "<xflaim:Index "
			"xmlns:xflaim=\"http://www.novell.com/XMLDatabase/Schema\" "
			"xflaim:name=\"text_val_IX\" "
			"xflaim:DictNumber=\"99\">"
			"<xflaim:ElementComponent xflaim:name=\"text_val\" "
					"xflaim:KeyComponent=\"1\" "
					"xflaim:Required=\"yes\" "
					"xflaim:type=\"string\" "
					"xflaim:IndexOn=\"value\" />"
		"</xflaim:Index>";

	beginTest( 					
		"RFL Recover Defect Test",
		"Ensure a bug that was causing a corruption when replaying set text value "
		"operations of zero length has been fixed/Ensure a bug that was causing indexes "
		"to not be updated when recovering node update packets has been fixed",
		"",
		"No Additional Details.");

	if ( RC_BAD( rc = initCleanTestState( DB_NAME_STR)))
	{
		MAKE_FLM_ERROR_STRING( "Failed to initialize test state.", m_szDetails, rc);
		goto Exit;
	}
	bDibCreated = TRUE;

	if( RC_BAD( rc = m_pDb->setRflKeepFilesFlag( TRUE)))
	{
		MAKE_FLM_ERROR_STRING( "setRflKeepFilesFlag failed", m_szDetails, rc);
		goto Exit;
	}

	// Backup the database

	if( RC_BAD( rc = m_pDb->backupBegin( XFLM_FULL_BACKUP,
		XFLM_READ_TRANS, 0, &pBackup)))
	{
		MAKE_FLM_ERROR_STRING( "backupBegin failed", m_szDetails, rc);
		goto Exit;
	}

	if( RC_BAD( rc = pBackup->backup( BACKUP_NAME_STR,
		NULL, NULL, NULL, NULL)))
	{
		MAKE_FLM_ERROR_STRING( "backup failed", m_szDetails, rc);
		goto Exit;
	}

	pBackup->Release();
	pBackup = NULL;
	
	// Start an update transaction

	if( RC_BAD( rc = m_pDb->transBegin( XFLM_UPDATE_TRANS)))
	{
		MAKE_FLM_ERROR_STRING( "transBegin failed", m_szDetails, rc);
		goto Exit;
	}
	bStartedTrans = TRUE;

	// Create some schema definitions

	uiDefNum = 0;
	if( RC_BAD( rc = m_pDb->createElementDef(
		NULL, "text_val", XFLM_TEXT_TYPE, &uiDefNum)))
	{
		MAKE_FLM_ERROR_STRING( "createElementDef failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->createRootElement(
		XFLM_DATA_COLLECTION,
		uiDefNum,
		&pNode)))
	{
		MAKE_FLM_ERROR_STRING( "createRootElement failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( m_pDb, (FLMBYTE *)"")))
	{
		MAKE_FLM_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	// Create an index on text_val

	if ( RC_BAD( rc = importBuffer( pszIndex, XFLM_DICT_COLLECTION)))
	{
		goto Exit;
	}

	// create an encryption definition

#ifdef FLM_USE_NICI
	if ( RC_BAD( rc = m_pDb->createEncDef("aes", "aes_def", 0, &uiEncDef)))
	{
		MAKE_FLM_ERROR_STRING( "createEncDef failed", m_szDetails, rc);
		goto Exit;
	}
#endif

	// modify the node value a few times with encryption. 
	// This will generate node update packets

	if ( RC_BAD( rc = pNode->setUTF8( 
		m_pDb, (FLMBYTE *)"text_val_1", 0, TRUE, uiEncDef)))
	{
		MAKE_FLM_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( 
		m_pDb, (FLMBYTE *)"text_val_2", 0, TRUE, uiEncDef)))
	{
		MAKE_FLM_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = pNode->setUTF8( 
		m_pDb, (FLMBYTE *)"text_val_3", 0, TRUE, uiEncDef)))
	{
		MAKE_FLM_ERROR_STRING( "setUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	// validate the key

	if ( RC_BAD( rc = m_pDbSystem->createIFDataVector( &pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "createIFDataVector failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->keyRetrieve(
		99, NULL, XFLM_FIRST | XFLM_MATCH_DOC_ID, pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "No index keys generated", m_szDetails, rc);
		goto Exit;
	}

	uiTmp = sizeof(szTmp);
	if ( RC_BAD( rc = pSearchKey->getUTF8( 0, (FLMBYTE *)szTmp, &uiTmp)))
	{
		MAKE_FLM_ERROR_STRING( "getUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	pSearchKey->Release();
	pSearchKey = NULL;

	if ( f_strcmp( szTmp, "text_val_3") != 0)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_FLM_ERROR_STRING( "Invalid key found", m_szDetails, rc);
		goto Exit;
	}

	// Commit the transaction

	if( RC_BAD( rc = m_pDb->transCommit()))
	{
		MAKE_FLM_ERROR_STRING( "transCommit failed", m_szDetails, rc);
		goto Exit;
	}
	bStartedTrans = FALSE;

	m_pDb->Release();
	m_pDb = NULL;

	if( RC_BAD( rc = m_pDbSystem->closeUnusedFiles( 0)))
	{
		MAKE_FLM_ERROR_STRING( "closeUnusedFiles failed", m_szDetails, rc);
		goto Exit;
	}

	// Remove the database

	if( RC_BAD( rc = m_pDbSystem->dbRemove( DB_NAME_STR, NULL, NULL, FALSE)))
	{
		MAKE_FLM_ERROR_STRING( "dbRemove failed", m_szDetails, rc);
		goto Exit;
	}

	// Restore the database
	
	if( RC_BAD( rc = m_pDbSystem->dbRestore( DB_NAME_STR,
		NULL, NULL, BACKUP_NAME_STR, NULL, NULL, NULL)))
	{
		MAKE_FLM_ERROR_STRING( "dbRestore failed", m_szDetails, rc);
		goto Exit;
	}

	if( RC_BAD( rc = m_pDbSystem->dbOpen( DB_NAME_STR, NULL, NULL, 
		NULL, FALSE, &m_pDb)))
	{
		MAKE_FLM_ERROR_STRING( "dbOpen failed", m_szDetails, rc);
		goto Exit;
	}

	// Validate the key for the index to make sure it was restored properly

	if ( RC_BAD( rc = m_pDbSystem->createIFDataVector( &pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "createIFDataVector failed", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = m_pDb->keyRetrieve(
		99, NULL, XFLM_FIRST | XFLM_MATCH_DOC_ID, pSearchKey)))
	{
		MAKE_FLM_ERROR_STRING( "No index keys generated", m_szDetails, rc);
		goto Exit;
	}

	uiTmp = sizeof(szTmp);
	if ( RC_BAD( rc = pSearchKey->getUTF8( 0, (FLMBYTE *)szTmp, &uiTmp)))
	{
		MAKE_FLM_ERROR_STRING( "getUTF8 failed", m_szDetails, rc);
		goto Exit;
	}

	if ( f_strcmp( szTmp, "text_val_3") != 0)
	{
		rc = RC_SET( NE_XFLM_DATA_ERROR);
		MAKE_FLM_ERROR_STRING( "Invalid key found", m_szDetails, rc);
		goto Exit;
	}

	endTest("PASS");

Exit:

	if ( RC_BAD( rc))
	{
		endTest("FAIL");
	}

	if (bStartedTrans)
	{
		m_pDb->transAbort();
	}

	if ( pSearchKey)
	{
		pSearchKey->Release();
	}

	if( pBackup)
	{
		pBackup->Release();
	}

	if( pNode)
	{
		pNode->Release();
	}

	shutdownTestState( DB_NAME_STR, bDibCreated);
	return rc;
}
Exemplo n.º 20
0
/****************************************************************************
Desc:		This routine is used to see if a file is already in use somewhere.
			This is only called for files which are opened directly by the
			application.
Notes:	This routine assumes that the global mutex is locked, but it
			may unlock and re-lock the mutex if needed.
****************************************************************************/
RCODE F_DbSystem::findDatabase(
	const char *	pszDbPath,
	const char *	pszDataDir,
	F_Database **	ppDatabase)
{
	RCODE				rc = NE_XFLM_OK;
	F_BUCKET *		pBucket;
	FLMUINT			uiBucket;
	FLMBOOL			bMutexLocked = TRUE;
	F_Database *	pDatabase;
	char				szDbPathStr1 [F_PATH_MAX_SIZE];
	char				szDbPathStr2 [F_PATH_MAX_SIZE];
	F_SEM				hWaitSem = F_SEM_NULL;

	*ppDatabase = NULL;

	// Normalize the path to a string before looking for it.
	// NOTE: On non-UNIX, non-WIN platforms, this will basically convert
	// the string to upper case.

	if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString( 
		pszDbPath, szDbPathStr1)))
	{
		goto Exit;
	}

Retry:

	*ppDatabase = NULL;

	if( !bMutexLocked)
	{
		f_mutexLock( gv_XFlmSysData.hShareMutex);
		bMutexLocked = TRUE;
	}

	pBucket = gv_XFlmSysData.pDatabaseHashTbl;
	uiBucket = f_strHashBucket( szDbPathStr1, pBucket, FILE_HASH_ENTRIES);
	pDatabase = (F_Database *)pBucket [uiBucket].pFirstInBucket;
	while (pDatabase)
	{
		// Compare the strings.  On non-Unix platforms we must use
		// f_stricmp, because case does not matter for file names
		// on those platforms.

#ifdef FLM_UNIX
		if( f_strcmp( szDbPathStr1, pDatabase->m_pszDbPath) == 0)
#else
		if( f_stricmp( szDbPathStr1, pDatabase->m_pszDbPath) == 0)
#endif
		{

			// Make sure data paths match.

			if (pszDataDir && *pszDataDir)
			{
				if (RC_BAD( rc = gv_XFlmSysData.pFileSystem->pathToStorageString(
					pszDataDir, szDbPathStr2)))
				{
					goto Exit;
				}
				
				if (pDatabase->m_pszDataDir)
				{
					// f_stricmp must be used on non-unix platforms because file
					// names are case insensitive on those platforms.
#ifdef FLM_UNIX
					if (f_strcmp( pDatabase->m_pszDataDir, szDbPathStr2) != 0)
#else
					if (f_stricmp( pDatabase->m_pszDataDir, szDbPathStr2) != 0)
#endif
					{
						rc = RC_SET( NE_XFLM_DATA_PATH_MISMATCH);
						goto Exit;
					}
				}
				else
				{
					rc = RC_SET( NE_XFLM_DATA_PATH_MISMATCH);
					goto Exit;
				}
			}
			else if (pDatabase->m_pszDataDir)
			{
				rc = RC_SET( NE_XFLM_DATA_PATH_MISMATCH);
				goto Exit;
			}
			*ppDatabase = pDatabase;
			break;
		}
		pDatabase = pDatabase->m_pNext;
	}

	if (*ppDatabase && pDatabase->m_uiFlags & DBF_BEING_CLOSED)
	{
		if( RC_BAD( rc = f_semCreate( &hWaitSem)))
		{
			goto Exit;
		}
		
		// Put ourselves into the notify list and then re-try
		// the lookup when we wake up

		if (RC_BAD( rc = f_notifyWait( gv_XFlmSysData.hShareMutex, hWaitSem,
			NULL, &pDatabase->m_pCloseNotifies)))
		{
			goto Exit;
		}
		
		f_semDestroy( &hWaitSem);

		// The mutex will be locked at this point.  Re-try the lookup.
		// IMPORTANT NOTE: pDatabase will have been destroyed by this
		// time.  DO NOT use it for anything!

		goto Retry;
	}

Exit:

	if( hWaitSem != F_SEM_NULL)
	{
		f_semDestroy( &hWaitSem);
	}

	// Make sure the global mutex is re-locked before exiting

	if( !bMutexLocked)
	{
		f_mutexLock( gv_XFlmSysData.hShareMutex);
	}
	

	return( rc);
}
Exemplo n.º 21
0
bool TestExtString::test_strcmp() {
  VERIFY(f_strcmp("a", "b") < 0);
  VERIFY(f_strcmp("a", "A") > 0);
  return Count(true);
}
Exemplo n.º 22
0
RCODE FTKAPI F_DirHdl::createDir(
	const char *	pszDirPath)
{
	RCODE					rc = NE_FLM_OK;
	char *				pszParentDir = NULL;
	IF_FileSystem *	pFileSystem = f_getFileSysPtr();

	if( RC_BAD( rc = f_alloc( F_PATH_MAX_SIZE, &pszParentDir)))
	{
		goto Exit;
	}

	// Discover the parent directory of the given one

	if( RC_BAD( rc = pFileSystem->pathReduce( pszDirPath, 
		pszParentDir, NULL)))
	{
		goto Exit;
	}

	// If pathReduce couldn't reduce the path at all, then an
	// invalid path was supplied.

	if( f_strcmp( pszDirPath, pszParentDir) == 0)
	{
		rc = RC_SET( NE_FLM_IO_INVALID_FILENAME);
		goto Exit;
	}

	// If a parent directory was found, and it doesn't already exist, create it

	if( *pszParentDir)
	{
		// If the "parent" is actually a regular file we need to return an error

		if( RC_OK( pFileSystem->doesFileExist( pszParentDir)))
		{
			if( !pFileSystem->isDir( pszParentDir))
			{
				rc = RC_SET( NE_FLM_IO_ACCESS_DENIED);
				goto Exit;
			}
		}
		else if( RC_BAD( rc = createDir( pszParentDir)))
		{
			goto Exit;
		}
	}

#if defined( FLM_WIN)

	if( !CreateDirectory((LPTSTR)pszDirPath, NULL))
	{
		rc = f_mapPlatformError( GetLastError(), NE_FLM_CREATING_FILE);
	}

#elif defined( FLM_UNIX) || defined( FLM_LIBC_NLM)

	if( mkdir( (char *)pszDirPath, 0777) == -1)
	{
		rc = f_mapPlatformError( errno, NE_FLM_CREATING_FILE);
	}

#endif

Exit:

	if( pszParentDir)
	{
		f_free( &pszParentDir);
	}
	
	return( rc);
}
Exemplo n.º 23
0
RCODE f_fileFindFirst(
	char *				pszSearchPath,
   FLMUINT				uiSearchAttrib,
	F_IO_FIND_DATA	*	pFindData,
   char *				pszFoundPath,
	FLMUINT *			puiFoundAttrib)
{
	RCODE					rc = NE_FLM_OK;
	char 					szTmpPath[ F_PATH_MAX_SIZE];
	FSTATIC char		pszWildCard[] = {'*',0};
	int					iRetVal;
	IF_FileSystem *	pFileSystem = f_getFileSysPtr();

	if( !pszSearchPath)
	{
		rc = RC_SET( NE_FLM_IO_PATH_NOT_FOUND);
		goto Exit;
	}

	f_strcpy( szTmpPath, pszSearchPath);
	if( RC_BAD( rc = pFileSystem->pathAppend( szTmpPath, pszWildCard)))
	{
		goto Exit;
	}

	f_memset( pFindData, 0, sizeof( F_IO_FIND_DATA));
	if( uiSearchAttrib & F_IO_FA_DIRECTORY)
	{
		pFindData->mode_flag |= S_IFDIR;
	}

	if( uiSearchAttrib & F_IO_FA_RDONLY)
	{
		pFindData->mode_flag |= S_IREAD;
	}

	iRetVal = Find1( (char*)szTmpPath, pFindData);

	if( iRetVal != 0)
	{
		// If there were no more files found then return no more files
		// instead of mapping to error path not found or io error.
		// To return no more files ret_val is ENOENT (set in Find2)
		// and errno is not set

		if( iRetVal == ENOENT && errno == 0)
		{
			rc = RC_SET( NE_FLM_IO_NO_MORE_FILES);
		}
		else
		{
			rc = f_mapPlatformError( errno, NE_FLM_READING_FILE);
		}
		
		goto Exit;
	}

	// filter out ".." (PARENT) and "." (CURRENT) directories
	
	if( uiSearchAttrib & F_IO_FA_DIRECTORY )
	{
		while( (f_strcmp( pFindData->name, "..") == 0) ||
			   (f_strcmp( pFindData->name, ".") == 0))
		{
			if( (iRetVal = Find2( pFindData)) != 0)
			{
				// If there were no more files found then return no more files
				// instead of mapping to error path not found or io error.
				// To return no more files ret_val is ENOENT (set in Find2)
				// and errno is not set
				
				if( iRetVal == ENOENT && errno == 0)
				{
					rc = RC_SET( NE_FLM_IO_NO_MORE_FILES);
				}
				else
				{
					rc = f_mapPlatformError( errno, NE_FLM_READING_FILE);
				}
				
				goto Exit;
			}
		}
	}

	// Append the file name to the path name
	
	f_strcpy( pszFoundPath, pszSearchPath);
	
	if( RC_BAD( rc = pFileSystem->pathAppend( pszFoundPath, 
		(char *)pFindData->name)))
	{
		goto Exit;
	}

	*puiFoundAttrib = (FLMUINT)ReturnAttributes(
			pFindData->FileStat.st_mode, pszFoundPath);

	// Save the search path in the NE_FLM_IO_FIND_DATA struct
	// for a find next call

	f_strcpy( pFindData->search_path, pszSearchPath);

Exit:

	return( rc);
}
Exemplo n.º 24
0
/****************************************************************************
Desc:
****************************************************************************/
int main( 
	int				argc,
	char ** 			argv)
{
	RCODE				rc = FERR_OK;
	IFlmTest *		pTest = NULL;
	unsigned int	i = 1;
	ArgList *		pArgs = NULL;
	TEST_INFO		testInfo;
	
	if( RC_BAD( rc = FlmStartup()))
	{
		goto Exit;
	}
	
	if( (pArgs = f_new ArgList) == NULL)
	{
		rc = RC_SET( FERR_MEM);
		goto Exit;
	}
	
#ifdef FLM_NLM
	f_conInit( 0, 0, "FLAIM Unit Test");
#endif	

	if( argc > 1)
	{
		if( (f_strcmp( argv[1], "--help") == 0) || 
			 (f_strcmp( argv[1], "-h") == 0))
		{
			printHelp();
			goto Exit;
		}
	}

	pArgs->expandArgs( argv, argc);

	while( i < pArgs->getNumEntries())
	{
		if( (*pArgs)[i][0] != '-')
		{
			goto Exit;
		}
				
		if( ((*pArgs)[i][1] == 'l') || ((*pArgs)[i][1] == 'L'))
		{
			testInfo.bLog = true;
			f_strcpy( testInfo.pszLogfile, &((*pArgs)[i][2]));
		}
		else if( ((*pArgs)[i][1] == 'd') || ((*pArgs)[i][1] == 'D'))
		{
			testInfo.bDisplay = true;
		}
		else if( ((*pArgs)[i][1] == 'c') || ((*pArgs)[i][1] == 'C'))
		{
			f_strcpy( testInfo.pszConfig, &((*pArgs)[i][2]));
		}
		else if( ((*pArgs)[i][1] == 'b') || ((*pArgs)[i][1] == 'B'))
		{
			f_strcpy( testInfo.pszBuild, &((*pArgs)[i][2]));
		}
		else if( ((*pArgs)[i][1] == 'u') || ((*pArgs)[i][1] == 'U'))
		{
			f_strcpy( testInfo.pszUser, &((*pArgs)[i][2]));
		}
		else
		{
			f_conPrintf( "\nInvalid parameter");
			printHelp();
			goto Exit;
		}
		
		i++;
	}

	f_conPrintf( "Running %s\n", argv[0]);

	if( RC_BAD( rc = getTest( &pTest)))
	{
		f_conPrintf( "ERROR: Unable to create test instance\n");
		goto Exit;
	}

	if( pTest->init( testInfo.bLog, testInfo.pszLogfile, testInfo.bDisplay,
		testInfo.pszConfig, testInfo.pszEnvironment,
		testInfo.pszBuild, testInfo.pszUser) != 0)
	{
		f_conPrintf( "\nTest initialization failed");
		goto Exit;
	}

	if( RC_BAD( rc = pTest->execute()))
	{
		goto Exit;
	}
	
Exit:

	if( pTest)
	{
		pTest->Release();
	}
	
	if( pArgs)
	{
		pArgs->Release();
	}
	
#ifdef FLM_NLM
	f_conPrintf( "\nPress any key to exit ... ");
	f_conGetKey();
#endif

#ifdef FLM_NLM
	f_conExit();
#endif
	FlmShutdown();

	return( (int)rc);
}
Exemplo n.º 25
0
/****************************************************************************
Desc:
****************************************************************************/
RCODE	SortKeyTestImpl::verifyQuery( 
	const char *		pszQuery, 
	char*					ppszNames[][ 2],
	IF_Query *			pQuery,
	FLMUINT				uiNumNames,
	FLMBOOL				bFirstAscending,
	FLMBOOL				bLastAscending,
	FLMBOOL				bDocsIndexed,
	FLMBOOL				bIxFirstAscending,
	FLMBOOL				bIxLastAscending)
{
	RCODE					rc = NE_XFLM_OK;
	IF_DOMNode *		pResultNode = NULL;
	IF_DOMNode *		pFirstNameNode = NULL;
	IF_DOMNode *		pLastNameNode = NULL;
	FLMUINT				uiLoop;
	FLMUINT				uiPos;
	char					szBuf[ 100];
	IF_DataVector *	pSearchKey = NULL;
	char					szTestName[ 200];
	static FLMUINT		uiCallCount = 0;
	const char *		pszTestNameFormat = 
		"Verify Query #%u "
		"(%s/First Name Asc == %u/Last Name Asc ==%u/%s)";


	uiCallCount++;

	f_sprintf( szTestName, pszTestNameFormat, uiCallCount,
		pszQuery, (unsigned)bFirstAscending, (unsigned)bLastAscending,
		"positioning");

	beginTest( szTestName, 
		"Ensure queries return proper results in proper order",
		"No Additional Info",
		"");

	// positioning tests

	if ( RC_BAD( rc = pQuery->setupQueryExpr( m_pDb, pszQuery)))
	{
		MAKE_FLM_ERROR_STRING( "setupQueryExpr failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( bDocsIndexed && 
		(bFirstAscending == bIxFirstAscending && 
		bLastAscending == bIxLastAscending))
	{
		pQuery->setIndex( IX_NUM);
	}

	if ( RC_BAD( rc = pQuery->enablePositioning()))
	{
		MAKE_FLM_ERROR_STRING( "enablePositioning failed.", m_szDetails, rc);
		goto Exit;
	}

	if ( RC_BAD( rc = createSortKey( 
		pQuery, bFirstAscending, bLastAscending)))
	{
		goto Exit;
	}

	for( uiLoop = 0; uiLoop < uiNumNames; uiLoop++)
	{

		if ( RC_BAD( rc = pQuery->positionTo( 
			m_pDb, &pResultNode, 0, uiLoop)))
		{
			MAKE_FLM_ERROR_STRING( "positionTo failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pResultNode->getFirstChild( m_pDb, &pFirstNameNode)))
		{
			MAKE_FLM_ERROR_STRING( "getFirstChild failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pFirstNameNode->getNextSibling( m_pDb, &pLastNameNode)))
		{
			MAKE_FLM_ERROR_STRING( "getNextSibling failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pFirstNameNode->getUTF8( m_pDb, 
			(FLMBYTE *)szBuf, sizeof( szBuf), 0, sizeof( szBuf) - 1)))
		{
			MAKE_FLM_ERROR_STRING( "getUTF8 failed.", m_szDetails, rc);
			goto Exit;
		} 

		if ( f_strcmp( szBuf, ppszNames[uiLoop][0]) != 0)
		{
			rc = RC_SET( NE_XFLM_FAILURE);
			MAKE_FLM_ERROR_STRING( "Unexpected value.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pLastNameNode->getUTF8( m_pDb, 
			(FLMBYTE *)szBuf, sizeof( szBuf), 0, sizeof( szBuf) - 1)))
		{
			MAKE_FLM_ERROR_STRING( "getUTF8 failed.", m_szDetails, rc);
			goto Exit;
		} 

		if ( f_strcmp( szBuf, ppszNames[uiLoop][1]) != 0)
		{
			rc = RC_SET( NE_XFLM_FAILURE);
			MAKE_FLM_ERROR_STRING( "Unexpected value.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pQuery->getPosition( m_pDb, &uiPos)))
		{
			MAKE_FLM_ERROR_STRING( "getPosition failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( uiPos != uiLoop)
		{
			rc = RC_SET( NE_XFLM_FAILURE);
			MAKE_FLM_ERROR_STRING( "Unexpected position", m_szDetails, rc);
			goto Exit;
		}

	}

	endTest("PASS");

	f_sprintf( szTestName, pszTestNameFormat, uiCallCount,
		pszQuery, (unsigned)bFirstAscending, (unsigned)bLastAscending,
		"search key positioning");

	beginTest( szTestName, 
		"Ensure queries return proper results in proper order",
		"No Additional Info",
		"");
		
	if( RC_BAD( rc = m_pDbSystem->createIFDataVector( &pSearchKey)))
	{
		goto Exit;
	}

	// positioning tests 2

	for( uiLoop = 0; uiLoop < uiNumNames; uiLoop++)
	{

		if ( uiLoop == 0)
		{
			if ( RC_BAD( rc = pQuery->positionTo( 
				m_pDb, &pResultNode, 0, pSearchKey, XFLM_FIRST)))
			{
				MAKE_FLM_ERROR_STRING( "positionTo failed.", m_szDetails, rc);
				goto Exit;
			}
		}
		else
		{
			if ( RC_BAD( rc = pSearchKey->setUTF8( 0, 
				(FLMBYTE *)ppszNames[uiLoop][0])))
			{
				MAKE_FLM_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
				goto Exit;
			}

			if ( RC_BAD( rc = pSearchKey->setUTF8( 1, 
				(FLMBYTE *)ppszNames[uiLoop][1])))
			{
				MAKE_FLM_ERROR_STRING( "setUTF8 failed.", m_szDetails, rc);
				goto Exit;
			}

			if ( RC_BAD( rc = pQuery->positionTo( 
				m_pDb, &pResultNode, 0, pSearchKey, XFLM_EXACT)))
			{
				MAKE_FLM_ERROR_STRING( "positionTo failed.", m_szDetails, rc);
				goto Exit;
			}
		}

		if ( RC_BAD( rc = pResultNode->getFirstChild( m_pDb, &pFirstNameNode)))
		{
			MAKE_FLM_ERROR_STRING( "getFirstChild failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pFirstNameNode->getNextSibling( m_pDb, &pLastNameNode)))
		{
			MAKE_FLM_ERROR_STRING( "getNextSibling failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pFirstNameNode->getUTF8( m_pDb,
			(FLMBYTE *)szBuf, sizeof( szBuf), 0, sizeof( szBuf) - 1)))
		{
			MAKE_FLM_ERROR_STRING( "getUTF8 failed.", m_szDetails, rc);
			goto Exit;
		} 

		if ( f_strcmp( szBuf, ppszNames[uiLoop][0]) != 0)
		{
			rc = RC_SET( NE_XFLM_FAILURE);
			MAKE_FLM_ERROR_STRING( "Unexpected value.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pLastNameNode->getUTF8( m_pDb, 
			(FLMBYTE *)szBuf, sizeof( szBuf), 0, sizeof( szBuf) - 1)))
		{
			MAKE_FLM_ERROR_STRING( "getUTF8 failed.", m_szDetails, rc);
			goto Exit;
		} 

		if ( f_strcmp( szBuf, ppszNames[uiLoop][1]) != 0)
		{
			rc = RC_SET( NE_XFLM_FAILURE);
			MAKE_FLM_ERROR_STRING( "Unexpected value.", m_szDetails, rc);
			goto Exit;
		}

		if ( RC_BAD( rc = pQuery->getPosition( m_pDb, &uiPos)))
		{
			MAKE_FLM_ERROR_STRING( "getPosition failed.", m_szDetails, rc);
			goto Exit;
		}

		if ( uiPos != uiLoop)
		{
			rc = RC_SET( NE_XFLM_FAILURE);
			MAKE_FLM_ERROR_STRING( "Unexpected position", m_szDetails, rc);
			goto Exit;
		}
	}

	endTest("PASS");

Exit:

	if( RC_BAD( rc))
	{
		endTest("FAIL");
	}

	if( pResultNode)
	{
		pResultNode->Release();
	}

	if( pFirstNameNode)
	{
		pFirstNameNode->Release();
	}

	if( pLastNameNode)
	{
		pLastNameNode->Release();
	}
	
	if( pSearchKey)
	{
		pSearchKey->Release();
	}

	return rc;
}