Exemplo n.º 1
0
/*****************************************************************************
 * FUNCTION
 *  avk_pluto_nvram_test_reset_rec
 * DESCRIPTION
 *  test case of reset record
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
AVK_CASE(AVK_PLUTO_NVRAM_TEST_RESET_REC, AVK_PLUTO_NVRAM)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 error;
    S32 ret, i;
    kal_uint8 *dft_ptr;
    U8 buff[AVK_PLUTO_NVRAM_TEST_REC_SIZE];
    U8 buff_backup[AVK_PLUTO_NVRAM_TEST_REC_SIZE];
   
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ret = ReadRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff_backup, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT(ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE && error == NVRAM_READ_SUCCESS);
    
    ret = mmi_frm_reset_record(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, AVK_PLUTO_NVRAM_TEST_REC_LID, 1, 1);
    MMI_ASSERT(ret > 0);

    /* check reset operation correctness */
    MMI_ASSERT(nvram_get_default_value(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, &dft_ptr) == NVRAM_DEFAULT_VALUE_POINT);
    ret = ReadRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT(ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE && error == NVRAM_READ_SUCCESS);
    for (i = 0; i < AVK_PLUTO_NVRAM_TEST_REC_SIZE; i++)
    {
        MMI_ASSERT(buff[i] == dft_ptr[i]);
    }

    /* restore original data */
    ret = WriteRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff_backup, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT(ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE && error == NVRAM_WRITE_SUCCESS);
    AVK_CASE_RESULT(MMI_TRUE);
}
Exemplo n.º 2
0
/*****************************************************************************
 * FUNCTION
 *  avk_pluto_nvram_test_aync_write_record
 * DESCRIPTION
 *  test case of async write record
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
AVK_ASYN_CASE(AVK_PLUTO_NVRAM_TEST_ASYNC_WRITE_RECORD, AVK_PLUTO_NVRAM)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 error;
    S32 ret;
    U8 buff[AVK_PLUTO_NVRAM_TEST_REC_SIZE];
        
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ret = ReadRecord(AVK_PLUTO_NVRAM_TEST_REC_LID,
            1, 
            g_avk_pluto_nvram_cntx.buff_backup, 
            AVK_PLUTO_NVRAM_TEST_REC_SIZE, 
            &error);
    MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (error == NVRAM_READ_SUCCESS));
    mmi_frm_set_protocol_event_handler(
        MSG_ID_NVRAM_WRITE_CNF, 
        avk_pluto_nvram_async_write_handler, 
        MMI_TRUE);
    memset(buff, AVK_PLUTO_NVRAM_TEST_DATA_VAL, AVK_PLUTO_NVRAM_TEST_REC_SIZE);
    mmi_frm_write_async_record(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE);
}
Exemplo n.º 3
0
// Get the last record number in the log file and read it.
// This positions the cursor, so that we can begin reading 
// new records when the service notifies us that new records were 
// written to the log file.
static DWORD SeekToLastRecord(HANDLE hEventLog)
{
	DWORD status = ERROR_SUCCESS;
	DWORD dwLastRecordNumber = 0;
	PBYTE pRecord = NULL;  

	status = GetLastRecordNumber(hEventLog, &dwLastRecordNumber);
	if (ERROR_SUCCESS != status)
	{
		wprintf(L"GetLastRecordNumber failed.\n");
		goto cleanup;
	}

	status = ReadRecord(hEventLog, pRecord, dwLastRecordNumber, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ);
	if (ERROR_SUCCESS != status)
	{
		wprintf(L"ReadRecord failed seeking to record %lu.\n", dwLastRecordNumber);
		goto cleanup;
	}

cleanup:

	if (pRecord)
		free(pRecord);

	return status;
}
Exemplo n.º 4
0
/*****************************************************************************
 * FUNCTION
 *  avk_pluto_nvram_async_write_handler
 * DESCRIPTION
 *  handler for async write response
 * PARAMETERS
 *  write_cnf : [IN]  nvram write response
 * RETURNS
 *  0 : for protocal event, to diliver msg for other listener
 *  1 : stop diliver the msg for other listener
 *****************************************************************************/
static U8 avk_pluto_nvram_async_write_handler(void *write_cnf)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    nvram_write_cnf_struct *nvram_write_cnf;
    S16 error;
    S32 ret, i;
    U8 buff[AVK_PLUTO_NVRAM_TEST_REC_SIZE];
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    nvram_write_cnf = (nvram_write_cnf_struct *)write_cnf;
    if (nvram_write_cnf->file_idx == AVK_PLUTO_NVRAM_TEST_REC_LID)
    { 
        mmi_frm_clear_protocol_event_handler(MSG_ID_NVRAM_WRITE_CNF, avk_pluto_nvram_async_write_handler);
        MMI_ASSERT(nvram_write_cnf->result == NVRAM_IO_ERRNO_OK);
        memset(buff, AVK_PLUTO_NVRAM_TEST_DATA_VAL + 10, AVK_PLUTO_NVRAM_TEST_REC_SIZE);
        ret = ReadRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
        MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (error == NVRAM_READ_SUCCESS));
        for (i = 0; i < AVK_PLUTO_NVRAM_TEST_REC_SIZE; i++)
        {
            MMI_ASSERT(buff[i] == AVK_PLUTO_NVRAM_TEST_DATA_VAL);
        }
        ret = WriteRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, g_avk_pluto_nvram_cntx.buff_backup, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
        MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (error == NVRAM_WRITE_SUCCESS));
        AVK_CASE_RESULT(MMI_TRUE);
        AVK_ASYN_DONE();
        return 1;
    }
    return 0;
}
Exemplo n.º 5
0
static void
dumpXLog(char* fname)
{
	char	*fnamebase;

	printf("\n%s:\n\n", fname);
	/*
	 * Extract logfile id and segment from file name
	 */
	fnamebase = strrchr(fname, '/');
	if (fnamebase)
		fnamebase++;
	else
		fnamebase = fname;
	if (sscanf(fnamebase, "%8x%8x%8x", &logTLI, &logId, &logSeg) != 3)
	{
		fprintf(stderr, "Can't recognize logfile name '%s'\n", fnamebase);
		logTLI = logId = logSeg = 0;
	}
	logPageOff = -XLOG_BLCKSZ;		/* so 1st increment in readXLogPage gives 0 */
	logRecOff = 0;
	while (ReadRecord())
	{
		if(!transactions)
			dumpXLogRecord((XLogRecord *) readRecordBuf, false);
		else
			addTransaction((XLogRecord *) readRecordBuf);

		prevRecPtr = curRecPtr;
	}
	if(transactions)
		dumpTransactions();
}
Exemplo n.º 6
0
/*****************************************************************************
 * FUNCTION
 *  mmi_netset_access_user_ctrl_plmn_nvram
 * DESCRIPTION
 *  
 * PARAMETERS
 *  write_flag      [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_netset_access_user_ctrl_plmn_nvram(U8 write_flag)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 error;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (write_flag)
    {
        WriteRecord(
            NVRAM_EF_USER_CTRL_PLMN_LID,
            1,
            (void*)(&gUserCtrlPlmnList.PrefPLMN[0][0]),
            NVRAM_EF_USER_CTRL_PLMN_SIZE,
            &error);
    }
    else
    {
        ReadRecord(
            NVRAM_EF_USER_CTRL_PLMN_LID,
            1,
            (void*)(&gUserCtrlPlmnList.PrefPLMN[0][0]),
            NVRAM_EF_USER_CTRL_PLMN_SIZE,
            &error);
    }
}
Exemplo n.º 7
0
/*****************************************************************************
 * FUNCTION
 *  PmgInitExtMelodyStruct
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void PmgInitExtMelodyStruct(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 pError = NVRAM_READ_FAIL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ReadRecord(NVRAM_EF_EXT_MELODY_INFO_LID, 1, &gPmgExtMelodyInfo, sizeof(gPmgExtMelodyInfo), &pError);
    if (pError == NVRAM_READ_FAIL || gPmgExtMelodyInfo.TotleNum == 0xFF || gPmgExtMelodyInfo.ValidBit == 0xFF)
    {
        memset(&gPmgExtMelodyInfo, 0, sizeof(gPmgExtMelodyInfo));
        WriteRecord(NVRAM_EF_EXT_MELODY_INFO_LID, 1, &gPmgExtMelodyInfo, sizeof(gPmgExtMelodyInfo), &pError);
    }

#if 0   /* Scan all files to see if exist */
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* 0 */ 

}
Exemplo n.º 8
0
static long
SkipRecs(FILE	    *file,
	 long	    skip,
	 long	    size,
	 FieldSpec  **fields,
	 int	    arch)
{
    long    n;

    if (skip == 0)
	return 0;

    if (size != -1)
    {
	skiprec(file, skip, size);
	return skip;
    }
    else
    {
	for (n = 0; n < skip && ReadRecord(fields, arch, file); n++)
	{ }

	return n;
    }
}
Exemplo n.º 9
0
int PWSfileV1V2::ReadV2Header()
{
  m_hdr.m_nCurrentMajorVersion = 1;
  m_hdr.m_nCurrentMinorVersion = 0;
  CItemData header;
  // need to fallback to V17, since the header
  // is always written in this format
  VERSION sv = m_curversion;
  m_curversion = V17;
  int status = ReadRecord(header);
  // restore after reading V17-format header
  m_curversion = sv;
  if (status == SUCCESS) {
    const StringX version = header.GetPassword();
    // Compare to AltVersionString due to silly mistake
    // "2.0" as well as "pre-2.0" are actually 2.0. sigh.
    if (version == VersionString || version == AltVersionString) {
      status = SUCCESS;
      m_hdr.m_nCurrentMajorVersion = 2;
    } else
      status = WRONG_VERSION;
  }
  if (status == SUCCESS)
    m_hdr.m_prefString = header.GetNotes();
  return status;
}
Exemplo n.º 10
0
int main( int argc, char ** argv ) {

   char domain[ MYMAX ];
   int len = 0;
   unsigned int res;
   int a, i, j, k, l, n, t;

   res_init();

   len = res_query( argv[1], C_IN, T_MX, buff, MYMAX );

   printf( "MX records for gmail.com len =%d\n", len );

   a = ReadHeader();

   if ( getAnswerRecordCount() > 0 ) {
      printf("\n;; Answer section:\n");
      for ( i = 0; i < getAnswerRecordCount(); i++ ) {
         a = ReadRecord( a );
      }
   }

   if ( getAuthRecordCount() > 0 ) {
      printf("\n;; Authority section:\n");
      for ( i = 0; i < getAuthRecordCount(); i++ ) {
         a = ReadRecord( a );
      }
   }

   if ( getAdditionalRecordCount() > 0 ) {
      printf("\n;; Additional section:\n");
      for ( i = 0; i < getAdditionalRecordCount(); i++ ) {
         a = ReadRecord( a );
      }
   }

/*
   for( a=0; a < len; a++ ) {
      printf( "[ %d ] = %d, %c\n", a, buff[ a ], buff[ a ] );
   }

   for( ; a < len; a++ ) {
      printf( "buff[ %d ] = %d, %c\n", a, buff[ a ], buff[ a ] );
   }
*/   

}
Exemplo n.º 11
0
/*
	Prompts the user for a name to search for.
	Performs a case-sensitive string search
	for a record by that name on disk, and prints out
	related data when found, or a failure message
	if not found.

	Pass: name of file to load from
*/
void SearchByNameMenu(char *filename)
{
	FILE *f;
	struct employeeRecord *record;
	char buffer[1024];
	bool found = false;

	f = fopen(filename, "r");
	if (!f)
	{
		printf("File not found. Add some records first!\n");
		return;
	}

	printf("Enter the name: ");
	fgets(buffer, 1024, stdin);

	/* Remove the \n from the string */
	buffer[strlen(buffer) - 1] = '\0';

	while(!feof(f) && !found)
	{
		record = ReadRecord(f);
		if (record == NULL)
		{
			break;
		}

		record->name = ReadString(f, record->nameLength);
		if (record->name != NULL)
		{
			if(!strcmp(buffer,record->name))
			{
				found = 1;
				break;
			}
			free(record->name);
		}
		fseek(f, sizeof(char) * record->addressLength, SEEK_CUR);
		free(record);
	}

	if (found)
	{
		printf("Record found!\n");

		record->address = ReadString(f, record->addressLength);
		PrintRecord(record);

		fclose(f);
		free(record->name);
		free(record);
		return;
	}

	fclose(f);
	printf("Record not found in file.\n");
}
Exemplo n.º 12
0
/*****************************************************************************
 * FUNCTION
 *  InitCallHistoryContext
 * DESCRIPTION
 *  Init call history context
 * NA
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void InitCallHistoryContext(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 error;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    memset((U8*) chis_p, 0, sizeof(call_history_context_struct));
    ReadRecord(NVRAM_EF_CALL_TIME_LID, 1, (void*)&chis_p->last_call_time, sizeof(MYTIME), &error);

    ReadRecord(NVRAM_EF_CALL_TIME_LID, 2, (void*)&chis_p->total_out_time, sizeof(MYTIME), &error);

    ReadRecord(NVRAM_EF_CALL_TIME_LID, 3, (void*)&chis_p->total_in_time, sizeof(MYTIME), &error);

}
Exemplo n.º 13
0
XnStatus PlayerNode::ProcessRecord(XnBool bProcessPayload)
{
	//Read a record and handle it
	Record record(m_pRecordBuffer, RECORD_MAX_SIZE);
	XnStatus nRetVal = ReadRecord(record);
	XN_IS_STATUS_OK(nRetVal);
	nRetVal = HandleRecord(record, bProcessPayload);
	XN_IS_STATUS_OK(nRetVal);
	return XN_STATUS_OK;
}
Exemplo n.º 14
0
/*
	Prompts the user for an index to search for.
	Iterates through records stored on-disk and prints out
	related data when index is found, or a failure message
	if not found.

	Pass: name of file to load from
*/
void SearchByIndexMenu(char *filename)
{
	FILE *f;
	struct employeeRecord *record;
	char buffer[1024];
	int index, count = 0;
	bool found = false;

	f = fopen(filename, "r");
	if (!f)
	{
		printf("File not found. Add some records first!\n");
		return;
	}

	printf("Enter a record number: ");
	fgets(buffer, 1024, stdin);
	sscanf(buffer, "%d", &index);

	while(!feof(f) && !found)
	{
		record = ReadRecord(f);
		if (record == NULL)
		{
			break;
		}
		if(count == index)
		{
			found = 1;
			break;
		}

		fseek(f, sizeof(char) * (record->nameLength + record->addressLength), SEEK_CUR);
		free(record);
		count++;
	}

	if (found)
	{
		printf("Record found!\n");

		record->name = ReadString(f, record->nameLength);
		record->address = ReadString(f, record->addressLength); 
		PrintRecord(record);

		fclose(f);
		free(record->name);
		free(record->address);
		free(record);
		return;
	}

	fclose(f);
	printf("Couldn't find the record index %d. There are only %d records.\n", index, count);
}
Exemplo n.º 15
0
/*****************************************************************************
 * FUNCTION
 *  avk_pluto_nvram_test_access_record
 * DESCRIPTION
 *  test case of access nvram record; include ReadRecord and WriteRecord
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
AVK_CASE(AVK_PLUTO_NVRAM_TEST_ACCESS_RECORD, AVK_PLUTO_NVRAM)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 error;
    S32 ret, i;
    U8 buff[AVK_PLUTO_NVRAM_TEST_REC_SIZE] = {0};
    U8 buff_backup[AVK_PLUTO_NVRAM_TEST_REC_SIZE] = {0};
   
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* Try to reserve the data, but can not make sure if read operation is correct */
    ret = ReadRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (memcmp(buff, buff_backup, AVK_PLUTO_NVRAM_TEST_REC_SIZE) != 0) && (error == NVRAM_READ_SUCCESS));
    memcpy(buff_backup, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE);

    /* test if read and write operation is correct */
    memset(buff, AVK_PLUTO_NVRAM_TEST_DATA_VAL, AVK_PLUTO_NVRAM_TEST_REC_SIZE);
    ret = WriteRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (error == NVRAM_WRITE_SUCCESS));
    memset(buff, AVK_PLUTO_NVRAM_TEST_DATA_VAL + 10, sizeof(buff));
    ret = ReadRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (memcmp(buff, buff_backup, AVK_PLUTO_NVRAM_TEST_REC_SIZE) != 0) && (error == NVRAM_READ_SUCCESS));
    for (i = 0; i < AVK_PLUTO_NVRAM_TEST_REC_SIZE; i++)
    {
        MMI_ASSERT(buff[i] == AVK_PLUTO_NVRAM_TEST_DATA_VAL);
    }

    /*
     * if above case pass, We can confirm read and write operation is correct 
     * then restore the original record data
     */
    ret = WriteRecord(AVK_PLUTO_NVRAM_TEST_REC_LID, 1, buff_backup, AVK_PLUTO_NVRAM_TEST_REC_SIZE, &error);
    MMI_ASSERT((ret == AVK_PLUTO_NVRAM_TEST_REC_SIZE) && (error == NVRAM_WRITE_SUCCESS));
    AVK_CASE_RESULT(MMI_TRUE);
}
Exemplo n.º 16
0
/*****************************************************************************
* FUNCTION
*	SPOFInitNvRam
* DESCRIPTION
*   Read nvram data of SPOF
* PARAMETERS
*	None.
* RETURNS
*	None.
* GLOBALS AFFECTED
*	None
*****************************************************************************/
void SPOFInitNvRam(void) 
{
    S16 error;
	U8 nvram_buf[NVRAM_ALM_SPOF_DATA_SIZE];
    
    ReadRecord(NVRAM_EF_ALM_SPOF_DATA_LID, 2, &nvram_buf, NVRAM_ALM_SPOF_DATA_SIZE, &error);
    memcpy(g_spof_cntx.SPOFList,nvram_buf, sizeof(g_spof_cntx.SPOFList));

    /* zero initialized */
	if(g_spof_cntx.SPOFList[0].Hour > NUM_HRS_DAY)
		memset(&g_spof_cntx.SPOFList,0,sizeof(g_spof_cntx.SPOFList));
	
	/* no require to set any alarm */
}
// creates new CRecord object and fills it with the data of the record specified by inRecID
CRecord*	//** Thread Safe **
ADataStore::ReadRecord(RecIDT inRecID) {
	DB_DEBUG("ReadRecord("<<inRecID<<")");
	CRecord* theRec = (CRecord*)nil;
	long size = GetRecordSize(inRecID);
	if (size > 0) {
		temp_buffer(DatabaseRec, p, size);	// allocate a read buffer
		p->recID = inRecID;
		p->recSize = size;
		ReadRecord(p);
		theRec = MakeRecordObject(p);
	}
	return theRec;
}
Exemplo n.º 18
0
int LoadPersona(char *name, UFF *r)
{
	FILE *a=OpenUAF();
	int ct=0;
	while(ReadRecord(a,r)==1)
	{
		if(stricmp(name,r->uff_Name)==0)
		{
			CloseUAF(a);
			return(ct);
		}
		ct++;	/* Count records */
	}
	CloseUAF(a);
	return(-1);
}
Exemplo n.º 19
0
/*****************************************************************************
 * FUNCTION
 *  mmi_nfc_write_status
 * DESCRIPTION
 *  This function is to nfc status to nvram
 * PARAMETERS
 *  evt
 *
 *
 * RETURNS
 *  void
 *****************************************************************************/
static U8 mmi_nfc_get_nvram_status(void)
{

	/*----------------------------------------------------------------*/
	/* Local Variables												  */
	/*----------------------------------------------------------------*/
	S16 pError;
	U8  status;
	
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
	ReadRecord(NVRAM_EF_NFC_STATUS_LID, 1, &status, 1, &pError);
	g_mmi_nfc_status = status;
	return status;
}
Exemplo n.º 20
0
XnStatus PlayerNode::SeekToRecordByType(XnUInt32 nNodeID, RecordType type)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	Record record(m_pRecordBuffer, RECORD_MAX_SIZE);

	XnUInt32 nStartPos = TellStream();

	XnBool bFound = FALSE;
	XnUInt32 nPosBeforeRecord = 0;
	while (!bFound && nRetVal == XN_STATUS_OK)
	{
		nPosBeforeRecord = TellStream();

		nRetVal = ReadRecord(record);
		XN_IS_STATUS_OK(nRetVal);

		if ((record.GetType() == type) && (record.GetNodeID() == nNodeID))
		{
			bFound = TRUE;
		}
		else if (record.GetType() == RECORD_END)
		{
			nRetVal = XN_STATUS_NO_MATCH;
		}
		else
		{
			// if record has payload, skip it
			nRetVal = SkipRecordPayload(record);
		}
	}

	if (bFound)
	{
		// seek to before requested record
		nRetVal = SeekStream(XN_OS_SEEK_SET, nPosBeforeRecord);
		XN_IS_STATUS_OK(nRetVal);
	}
	else
	{
		// seek back to starting position
		SeekStream(XN_OS_SEEK_SET, nStartPos);
		return (nRetVal);
	}
	
	return (XN_STATUS_OK);
}
Exemplo n.º 21
0
nsresult nsTextAddress::ReadRecordNumber(nsIFile *aSrc, nsAString &aLine,
                                         int32_t rNum) {
  nsCOMPtr<nsIInputStream> inputStream;
  nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc);
  if (NS_FAILED(rv)) {
    IMPORT_LOG0("*** Error opening address file for reading\n");
    return rv;
  }

  int32_t rIndex = 0;
  uint64_t bytesLeft = 0;

  rv = inputStream->Available(&bytesLeft);
  if (NS_FAILED(rv)) {
    IMPORT_LOG0("*** Error checking address file for eof\n");
    inputStream->Close();
    return rv;
  }

  nsCOMPtr<nsIUnicharLineInputStream> lineStream;
  rv = GetUnicharLineStreamForFile(aSrc, inputStream,
                                   getter_AddRefs(lineStream));
  if (NS_FAILED(rv)) {
    IMPORT_LOG0("*** Error opening converter stream for importer\n");
    return rv;
  }

  bool more = true;

  while (more && (rIndex <= rNum)) {
    rv = ReadRecord(lineStream, aLine, &more);
    if (NS_FAILED(rv)) {
      inputStream->Close();
      return rv;
    }
    if (rIndex == rNum) {
      inputStream->Close();
      return NS_OK;
    }

    rIndex++;
  }

  return NS_ERROR_FAILURE;
}
Exemplo n.º 22
0
/*****************************************************************************
 * FUNCTION
 *  mmi_em_dcd_nw_param_init
 * DESCRIPTION
 *  Initialize the browser application whenever user enters into the wap menu
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
mmi_ret dcd_custom_init(mmi_event_struct *event)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
#ifdef __MMI_EM_MISC_DCD__
    S16 error;
#endif

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#ifdef __MMI_EM_MISC_DCD__
    ReadRecord(NVRAM_EF_DCD_EM_PARAM_DATA_LID, 1, g_em_dcd_nw_data_p, NVRAM_EF_DCD_EM_PARAM_DATA_SIZE, &error);
    if (error != NVRAM_READ_SUCCESS);
#endif

    return MMI_RET_OK;
}
Exemplo n.º 23
0
/*****************************************************************************
 * FUNCTION
 *  csb_frm_read_from_nvram
 * DESCRIPTION
 *  Reads the csn settings from NVRAM
 * PARAMETERS
 *       
 * RETURNS				void
 *****************************************************************************/
void csb_frm_read_from_nvram(void)
{
	/*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
	S16 error = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

	/* Before reading from NVRAM, set the memory with NULL */
	memset(&g_CSB_struct.csb_settings, CSB_NULL, sizeof(csb_setting_struct));

	ReadRecord(NVRAM_EF_CSB_SETTINGS_LID, 
			1, 
			&g_CSB_struct.csb_settings, 
			sizeof(csb_setting_struct), 
			&error);
}
Exemplo n.º 24
0
/*****************************************************************************
 * FUNCTION
 *  srv_clog_ctime_read_record
 * DESCRIPTION
 *  
 * PARAMETERS
 *  data        [?]         
 *  index       [IN]        
 * RETURNS
 *  
 *****************************************************************************/
static S32 srv_clog_ctime_read_record(nvram_ef_clog_call_time_struct *data, U32 index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S16 err;
    S32 ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ret = ReadRecord(
            NVRAM_EF_CLOG_CALL_TIME_LID,
            (U16) (index + 1),
            (void*)data,
            sizeof(nvram_ef_clog_call_time_struct),
            &err);
    if (ret == sizeof(nvram_ef_clog_call_time_struct))
        return SRV_CLOG_RET_OK;
    return SRV_CLOG_RET_FAIL;
}
Exemplo n.º 25
0
void runs(Element *r)
{
    r = new Element[k];
    int *key = new int[k]; int *rn = new int[k]; int *l = new int[k];
    for (int i = 0; i < k; i++) {  // input records
	InputRecord(r[i]); rn[i] = 1;
    }
    InitializeLoserTree();
    q = l[0]; // tournament winner

    int rq = 1; int rc = 1; int rmax = 1; int LastKey = MAXINT;
    while(1) { // output runs
	if (rq != rc) { // end of run
	    output end of run marker;
	    if (rq > rmax) return;
	    else rc = rq;
	}
	// output record r[q]
	WriteRecord(r[q]); LastKey = key[q];
	// input new record into tree
	if (end of input) rn[q] = rmax + 1;
	else {
	    ReadRecord(r[q]);
	    if (key[q] < LastKey)  // new record belongs to next run
	       rn[q] = rmax = rq + 1;
	    else rn[q] = rc;
	}
	rq = rn[q];

	// adjust losers
	for (t = (k+q)/2; t; t /= 2;) // @[email protected] is initialized to be parent of @[email protected]
	    if ((rn[l[t]] < rq) || ((rn[l[t]] == rq) && (key[l[t]] < key[q])))
	    { // @[email protected] is the winner
		int temp = q; q = l[t]; l[t] = temp;
		rq = rn[q];
	    }
    }
    delete [] r; delete [] key;
    delete [] rn; delete [] l;
}
Exemplo n.º 26
0
nsresult nsTextAddress::ReadRecordNumber(nsIFile *aSrc, nsCString &aLine, PRInt32 rNum)
{
  nsCOMPtr<nsIInputStream> inputStream;
  nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc);
  if (NS_FAILED(rv)) {
    IMPORT_LOG0( "*** Error opening address file for reading\n");
    return rv;
  }

  PRInt32 rIndex = 0;
  PRUint32 bytesLeft = 0;

  rv = inputStream->Available(&bytesLeft);
  if (NS_FAILED(rv)) {
    IMPORT_LOG0( "*** Error checking address file for eof\n");
    inputStream->Close();
    return rv;
  }

  nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv));
  NS_ENSURE_SUCCESS(rv, rv);

  bool more = true;

  while (more && (rIndex <= rNum)) {
    rv = ReadRecord(lineStream, aLine, &more);
    if (NS_FAILED(rv)) {
      inputStream->Close();
      return rv;
    }
    if (rIndex == rNum) {
      inputStream->Close();
      return NS_OK;
    }

    rIndex++;
  }

  return NS_ERROR_FAILURE;
}
/**
 * TODO V Verify that an errors is detected if 2 nics are expected and only one found.
 */
int GetProcNetDev(struct NetInformationStructure * pNetInformationStruct) {
	int nStatus = 0;

	char szLine[MAX_STATISTICS_LINE] = "";
	char szNetString[PROC_STAT_ITEM_STRING_LENGTH] = "";

	TRACEF(5,(">>> GetProcNetDev()\n"));

	nStatus = OpenFile("/proc/net/dev");

	int nNetIndex = 0;
	// This whole construction, operates on the assumption that Nets are listed in ascending order in the file.
	while ((nStatus == 0) && (nNetIndex
			< pNetInformationStruct->nNumberOfNetsSupported)) {
		//  Read the NetN line
		nStatus = ReadRecord(szLine, MAX_STATISTICS_LINE);
		if (nStatus == 0) {
			// TODO V Find a more effecient way of doing this.
			if (pNetInformationStruct->cNicType == 'E') {
				// TODO C support nic named 'emX'.
				snprintf(szNetString, PROC_STAT_ITEM_STRING_LENGTH, "  eth%d:", nNetIndex);
			} else {
				// TODO N It defaults to 'B' but that might be wrong, handle it better, later.
				snprintf(szNetString, PROC_STAT_ITEM_STRING_LENGTH, "   br%d:",
						nNetIndex);
			}
			if (strncmp(szNetString, szLine, strlen(szNetString)) == 0) {
				TRACEF(7,("%s: '%s'\n", szNetString, szLine));
				InterpretNetLine(
						pNetInformationStruct->arNetStatisticsPointerArray[nNetIndex],
						szLine + strlen(szNetString));
				nNetIndex++;
			}
			TRACEF(7,("GetProcNetDev() nStatus=%d, nNetIndex=%d\n", nStatus, nNetIndex));
		} // endif status
	} // end while.
	CloseFile();

	return (nStatus);
} // end getprocstat.
// handle created is yours to do with as you will
handle	//** Thread Safe **
ADataStore::ReadRecordHandle(RecIDT inRecID) {
	handle h;
	long fullsize = GetRecordSize(inRecID);
	long size = fullsize - sizeof(DatabaseRec);
	if (size > 0) {
		h.resize(fullsize);
		h.lock();
		DatabaseRec* p = (DatabaseRec*) *h;
		p->recID = inRecID;
		p->recSize = fullsize;
		Try_{
			ReadRecord(p);
		}
		Catch_(err) {
			h.dispose();	// clean up our mess
			Throw_(err);
		}
		::BlockMoveData(&p->recData[0], p, size);
		h.unlock();
		h.resize(size);
	}
Exemplo n.º 29
0
nsresult nsTextAddress::ReadRecordNumber( nsIFileSpec *pSrc, char *pLine, PRInt32 bufferSz, char delim, PRInt32 *pLineLen, PRInt32 rNum)
{
    PRInt32    rIndex = 0;
    nsresult rv = pSrc->Seek( 0);
    if (NS_FAILED( rv))
        return( rv);
    
    PRBool    eof = PR_FALSE;

    while (!eof && (rIndex <= rNum)) {
        if (NS_FAILED( rv = ReadRecord( pSrc, pLine, bufferSz, delim, pLineLen)))
            return( rv);
        if (rIndex == rNum)
            return( NS_OK);
        rIndex++;
        rv = pSrc->Eof( &eof);
        if (NS_FAILED( rv))
            return( rv);
    }

    return( NS_ERROR_FAILURE);
}
Exemplo n.º 30
0
/**************************************************************

	FUNCTION NAME		: Msg_Adaption_PHB_Init_Ready

	PURPOSE				: Init First about the PHB of Adaption

	INPUT PARAMETERS	: void

	OUTPUT PARAMETERS	: nil

	RETURNS				: void

	REMARKS			:

**************************************************************/
void  Msg_Adaption_PHB_Init_Ready(void)
{
  
	UINT16 error = 0;
	INT32 index = 0;
	INT32 ret = 0;

	TBM_ENTRY(0x29e5);

	nMEusedSlot = 0;
	memset(pb_coolsand, 0x00, sizeof(CFW_PBK_ENTRY_INFO) * MAX_PB_PHONE_ENTRIES);
	
	ret = ReadRecord(NVRAM_PHB_NVRAM_LID, 1, 
		(void *)&pb_coolsand[1], sizeof(CFW_PBK_ENTRY_INFO) * MAX_PB_PHONE_ENTRIES, &error); 

	if (ret < 0)
	{
		mmi_trace(g_sw_ADP_PHB, TSTXT("PHB Init Msg_Adaption_PHB_Init_Ready FS_read error!\n"));
	}
	else
	{
		for (index = 1; index <= MAX_PB_PHONE_ENTRIES; index++)
		{
			if (pb_coolsand[index].nAppIndex != 0)
			{
				/* record total used index */
				MEUsedIndex[nMEusedSlot] = index;

				/* record total count */
				nMEusedSlot++;
			}
		}
		mmi_trace(g_sw_ADP_PHB, TSTXT("PHB Init Msg_Adaption_PHB_Init_Ready()***PhoneUsed:%d!\n"), nMEusedSlot);

	}

	TBM_EXIT(0x29e5);
}