Esempio n. 1
0
int main(int argc,char **argv)
    {
    if(argc != 5)
	{
	fprintf(stderr,"%s <bank public info> <private coin request> <signed coin request> <coin>\n",
		argv[0]);
	exit(1);
	}
    const char *szBankFile=argv[1];
    const char *szPrivateRequestFile=argv[2];
    const char *szSignatureFile=argv[3];
    const char *szCoinFile=argv[4];

    SetDumper(stderr);

    BIO *bioBank=BIO_new_file(szBankFile,"r");
    BIO *bioPrivateRequest=BIO_new_file(szPrivateRequestFile,"r");
    BIO *bioSignature=BIO_new_file(szSignatureFile,"r");
    BIO *bioCoin=BIO_new_file(szCoinFile,"w");

    PublicBank bank(bioBank);
    CoinRequest req(bioPrivateRequest);
    ReadNumber(bioSignature,"request=");
    BIGNUM *bnSignature=ReadNumber(bioSignature,"signature=");
    DumpNumber("signature=",bnSignature);
    Coin coin;
    req.ProcessResponse(&coin,bank,bnSignature);
    coin.WriteBIO(bioCoin);
    }
Esempio n. 2
0
File: asf.c Progetto: 5sw/stuff
void ParsePayload( const ParseInfo *info )
{
	printf( "\tParse payload...\n" );
	uint8_t tmp = ReadByte();
	
	uint8_t streamNumber = tmp & (BIT( 0 ) | BIT( 1 ) | BIT( 2 ) | BIT( 3 ) | BIT( 4 ) | BIT( 5 ) | BIT( 6 ));
	bool isKeyFrame = (tmp & BIT( 7 )) != 0;
	
	uint32_t mediaObjectNumber = ReadNumber( info->objectNumberLengthType );
	uint32_t offset = ReadNumber( info->offsetLengthType );
	uint32_t repLength = ReadNumber( info->repDataLengthType );
	
	printf( "\t\tStream number:                   %d\n", streamNumber );
	printf( "\t\tKey frame:                       %s\n", isKeyFrame ? "yes" : "no" );
	printf( "\t\tMedia object number:             %d\n", mediaObjectNumber );
	printf( "\t\tOffset into object:              %d\n", offset );
	printf( "\t\tReplicated data length:          %d\n", repLength );
	
	if (repLength >= 8) {
		printf( "\t\tReplicated data:\n" );
		printf( "\t\t\tMedia object size:           %d\n", ReadDWord() );
		printf( "\t\t\tPresentation time:           %d\n", ReadDWord() );
		printf( "\t\tSkipping rest of replicated data...\n" );
		cursor += repLength - 8;
	} else {
		cursor += repLength;
	}
	
	size_t headerSize = cursor - packetStart;
	size_t dataSize = packetSize - headerSize - 0;
	printf( "\t\tData offset: %ld\n", cursor - buffer );
	AddDataToObject( &currentObjects[streamNumber], offset, dataSize, cursor );
}
Esempio n. 3
0
int main()
{
	int a = ReadNumber();
	int b = ReadNumber();
	WriteAnswer(a + b);
	return 0;
}
Esempio n. 4
0
bool  PxMDecoder::readHeader()
{
    bool result = false;

    if( !m_buf.empty() )
    {
        if( !m_strm.open(m_buf) )
            return false;
    }
    else if( !m_strm.open( m_filename ))
        return false;

    try
    {
        int code = m_strm.getByte();
        if( code != 'P' )
            throw RBS_BAD_HEADER;

        code = m_strm.getByte();
        switch( code )
        {
        case '1': case '4': m_bpp = 1; break;
        case '2': case '5': m_bpp = 8; break;
        case '3': case '6': m_bpp = 24; break;
        default: throw RBS_BAD_HEADER;
        }

        m_binary = code >= '4';
        m_type = m_bpp > 8 ? CV_8UC3 : CV_8UC1;

        m_width = ReadNumber( m_strm, INT_MAX );
        m_height = ReadNumber( m_strm, INT_MAX );

        m_maxval = m_bpp == 1 ? 1 : ReadNumber( m_strm, INT_MAX );
        if( m_maxval > 65535 )
            throw RBS_BAD_HEADER;

        //if( m_maxval > 255 ) m_binary = false; nonsense
        if( m_maxval > 255 )
            m_type = CV_MAKETYPE(CV_16U, CV_MAT_CN(m_type));

        if( m_width > 0 && m_height > 0 && m_maxval > 0 && m_maxval < (1 << 16))
        {
            m_offset = m_strm.getPos();
            result = true;
        }
    }
    catch(...)
    {
    }

    if( !result )
    {
        m_offset = -1;
        m_width = m_height = -1;
        m_strm.close();
    }
    return result;
}
Esempio n. 5
0
TRect TTmCodeReader::ReadRect()
{
    TRect r;
    r.iTl.iX = ReadNumber();
    r.iTl.iY = ReadNumber();
    r.iBr.iX = r.iTl.iX + ReadNumber();
    r.iBr.iY = r.iTl.iY + ReadNumber();
    return r;
}
Esempio n. 6
0
void PublicBank::ReadBIO(BIO *bio)
    {
    m_pDH=DH_new();

    m_pDH->g=ReadNumber(bio,"g=");
    m_pDH->p=ReadNumber(bio,"p=");
    m_pDH->pub_key=ReadNumber(bio,"public=");

    Dump();
    }
Esempio n. 7
0
bool Disasm::ParsePJL() {
	if (!Expect("\033%-12345X") || !SkipTo(") HP-PCL XL;")) return false;
	// version";"minor";" ... \n
	int32 version, minor;
	if (ReadNumber(version) && Expect(";") && ReadNumber(minor) && Expect(";") && SkipTo("\n")) {
		printf("PCL XL %d ; %d\n", (int)version, (int)minor);
		return true;
	}
	return false;	
}
bool Project_Engine::Parse_Str_Int(wchar_t* Text_Buffer, int Line_length, int &nPosition, int& nValue)//Buffer,Length of line,Position,ReturnValue
{
    wchar_t pwzNumber[20];
    bool bResult = ReadNumber(Text_Buffer, Line_length, nPosition, pwzNumber);
    nValue = (bResult) ? _wtoi(pwzNumber) : 0;
    return bResult;
}
Esempio n. 9
0
//===========================================================================
//
// Parameter:               -
// Returns:                 -
// Changes Globals:     -
//===========================================================================
bool ReadChar(fielddef_t * fd, void *p)
{
	idToken         token;
	idLexer         parser;
	idStr           string;

	if(!parser.ExpectAnyToken(&token))
	{
		return false;
	}

	//take literals into account
	if(token.type == TT_LITERAL)
	{
		string.StripQuotes();
		*(char *)p = token.string[0];
	}							//end if
	else
	{
		parser.UnreadToken(&token);
		if(!ReadNumber(fd, p))
		{
			return false;
		}
	}							//end if
	return true;
}								//end of the function ReadChar
bool Project_Engine::Parse_Str_Float(wchar_t* Text_Buffer, int Line_length, int &nPosition, float& fValue)
{
    wchar_t pwzNumber[20];
    bool bResult = ReadNumber(Text_Buffer, Line_length, nPosition, pwzNumber);
    fValue = (bResult) ? (float)_wtof(pwzNumber) : 0;
    return false;
}
Esempio n. 11
0
std::shared_ptr<CLuaArgument> CAccount::GetData(const std::string& strKey)
{
    CAccountData* pData = GetDataPointer(strKey);
    auto          pResult = std::make_shared<CLuaArgument>();

    if (pData)
    {
        if (pData->GetType() == LUA_TBOOLEAN)
        {
            pResult->ReadBool(pData->GetStrValue() == "true");
        }
        else if (pData->GetType() == LUA_TNUMBER)
        {
            pResult->ReadNumber(strtod(pData->GetStrValue().c_str(), NULL));
        }
        else
        {
            pResult->ReadString(pData->GetStrValue());
        }
    }
    else
    {
        pResult->ReadBool(false);
    }
    return pResult;
}
Esempio n. 12
0
CNum CInByte2::ReadNum()
{
  UInt64 value = ReadNumber();
  if (value > kNumMax)
    ThrowUnsupported();
  return (CNum)value;
}
Esempio n. 13
0
int main (void)
{
  unsigned long tmp;
  tmp = (ReadNumber() & 0x0ff0L) >> 4;
  DisplayNumber (tmp);
  return 0;
}
Esempio n. 14
0
void Datum::Reader::ReadTimestamp() {
    auto r = ReadTimestampComponent('-', "year");
    if(!r.first) return;
    long y = r.second;

    r = ReadTimestampComponent('-', "month");
    if(!r.first) return;
    long m = r.second;

    r = ReadTimestampComponent('T', "day");
    if(!r.first) return;
    long d = r.second;

    r = ReadTimestampComponent(':', "hour");
    if(!r.first) return;
    long h = r.second;

    r = ReadTimestampComponent(':', "minute");
    if(!r.first) return;
    long minute = r.second;

    ReadNumber();
    if(Red == nullptr)
        return;

    const Num* seconds = dynamic_cast<Num*>(Red.get());
    if(seconds == nullptr) {
        AddError("seconds were non-numeric");
        return; }

    long long s = seconds->Truncate();
    long double f = seconds->Fraction();

    Red.reset(new Timestamp(y, m, d, h, minute, (long)s, (double)f));
    return; }
Esempio n. 15
0
//===========================================================================
//
// Parameter:               -
// Returns:                 -
// Changes Globals:     -
//===========================================================================
qboolean ReadChar( source_t *source, fielddef_t *fd, void *p )
{
	token_t token;

	if ( !PC_ExpectAnyToken( source, &token ) )
	{
		return 0;
	}

	//take literals into account
	if ( token.type == TT_LITERAL )
	{
		StripSingleQuotes( token.string );
		* ( char * ) p = token.string[ 0 ];
	} //end if
	else
	{
		PC_UnreadLastToken( source );

		if ( !ReadNumber( source, fd, p ) )
		{
			return 0;
		}
	} //end if

	return 1;
} //end of the function ReadChar
Esempio n. 16
0
File: asf.c Progetto: 5sw/stuff
void ParsePayloadHeader( uint8_t flags )
{
	printf( "\tParsing payload parsing information...\n" );
	bool multiplePayloads = (flags & BIT( 0 )) != 0;
	int sequenceType = (flags & (BIT( 1 ) | BIT( 2 ))) >> 1;
	int paddingLengthType = (flags & (BIT( 3 ) | BIT( 4 ))) >> 3;
	int packetLengthType = (flags & (BIT( 5 ) | BIT( 6 ))) >> 5;
	bool ecPresent = (flags & BIT( 7 )) != 0;
	
	printf( "\tMultiple Payloads                    %s\n", multiplePayloads ? "yes" : "no" );
	printf( "\tSequence type:                       %d\n", sequenceType );
	printf( "\tPadding length type:                 %d\n", paddingLengthType );
	printf( "\tPacket length type:                  %d\n", packetLengthType );
	printf( "\tEC present:                          %s\n", ecPresent ? "yes" : "no" );
	
	uint8_t propertyFlags = ReadByte();
	
	ParseInfo info;
	info.repDataLengthType = propertyFlags & (BIT( 0 ) | BIT( 1 ));
	info.offsetLengthType = (propertyFlags & (BIT( 2 ) | BIT( 3 ))) >> 2;
	info.objectNumberLengthType = (propertyFlags & (BIT( 4 ) | BIT( 5 ))) >> 4;
	int streamNumberLengthType = (propertyFlags & (BIT( 6 ) | BIT( 7 ))) >> 6;
	
	printf( "\tRepl. data length type               %d\n", info.repDataLengthType );
	printf( "\tOffset into media object length type %d\n", info.offsetLengthType );
	printf( "\tMedia object number lengtht type     %d\n", info.objectNumberLengthType );
	printf( "\tStream Number Length Type            %d\n", streamNumberLengthType );
	
	uint32_t packetLength = ReadNumber( packetLengthType );
	printf( "\tPacket length:                       %d\n", packetLength );
	
	uint32_t sequence = ReadNumber( sequenceType );
	printf( "\tSequence number:                     %d\n", sequence );
	
	uint32_t paddingLength = ReadNumber( paddingLengthType );
	printf( "\tPadding length:                      %d\n", paddingLength );
	
	uint32_t sendTime = ReadDWord();
	printf( "\tSend time:                           %d\n", sendTime );
	
	uint16_t duration = ReadWord();
	printf( "\tDuration:                            %d\n", duration );
	
	if (multiplePayloads) ParseMultiplePayloads( &info );
	else ParsePayload( &info );
}
Esempio n. 17
0
void CoinRequest::ReadBIO(BIO *bio)
    {
    PublicCoinRequest::ReadBIO(bio);
    m_coin.ReadBIO(bio);
    m_bnBlindingFactor=ReadNumber(bio,"blinding=");

    Dump();
    }
Esempio n. 18
0
static SRes SkipData(CSzData *sd)
{
  UInt64 size;
  RINOK(ReadNumber(sd, &size));
  if (size > sd->Size)
    return SZ_ERROR_ARCHIVE;
  SKIP_DATA(sd, size);
  return SZ_OK;
}
Esempio n. 19
0
std::shared_ptr<CLuaArgument> CAccountManager::GetAccountData( CAccount* pAccount, const char* szKey )
{
    if ( !pAccount->IsRegistered () )
    {
        return pAccount->GetData ( szKey );
    }

    // Check cache first
    if ( pAccount->HasData ( szKey ) )
    {
        return pAccount->GetData ( szKey );
    }

    //Get the user ID
    int iUserID = pAccount->GetID();
    //create a new registry result for the query return
    CRegistryResult result;

    //Select the value and type from the database where the user is our user and the key is the required key
    m_pDatabaseManager->QueryWithResultf ( m_hDbConnection, &result, "SELECT value,type from userdata where userid=? and key=? LIMIT 1", SQLITE_INTEGER, iUserID, SQLITE_TEXT, szKey );

    // Default result is nil
    auto pResult = std::make_shared<CLuaArgument> ();

    //Do we have any results?
    if ( result->nRows > 0 )
    {
        const CRegistryResultRow& row = result->Data.front();

        const char* szValue = (const char *)row[0].pVal;
        int iType = static_cast < int > ( row[1].nVal );

        // Cache value for next get
        pAccount->SetData ( szKey, szValue, iType );

        //Account data is stored as text so we don't need to check what type it is just return it
        if ( iType == LUA_TBOOLEAN )
        {
            SString strResult = szValue;
            pResult->ReadBool ( strResult == "true" );
        }
        else
        if ( iType == LUA_TNUMBER )
            pResult->ReadNumber ( strtod ( szValue, NULL ) );
        else
            pResult->ReadString ( szValue );
    }
    else
    {
        //No results
        pResult->ReadBool ( false );
    }

    return pResult;
}
Esempio n. 20
0
File: 7zIn.cpp Progetto: bks/qz7
void CInArchive::ReadPackInfo(
    UInt64 &dataOffset,
    CRecordVector<UInt64> &packSizes,
    CRecordVector<bool> &packCRCsDefined,
    CRecordVector<UInt32> &packCRCs)
{
    dataOffset = ReadNumber();
    CNum numPackStreams = ReadNum();

    WaitAttribute(NID::kSize);
    packSizes.Clear();
    packSizes.Reserve(numPackStreams);
    for (CNum i = 0; i < numPackStreams; i++)
        packSizes.Add(ReadNumber());

    UInt64 type;
    for (;;)
    {
        type = ReadID();
        if (type == NID::kEnd)
            break;
        if (type == NID::kCRC)
        {
            ReadHashDigests(numPackStreams, packCRCsDefined, packCRCs);
            continue;
        }
        SkeepData();
    }
    if (packCRCsDefined.IsEmpty())
    {
        packCRCsDefined.Reserve(numPackStreams);
        packCRCsDefined.Clear();
        packCRCs.Reserve(numPackStreams);
        packCRCs.Clear();
        for (CNum i = 0; i < numPackStreams; i++)
        {
            packCRCsDefined.Add(false);
            packCRCs.Add(0);
        }
    }
}
Esempio n. 21
0
void TLexer::Read() {
    char c;
    std::string value = "";
    while (true) {
        c = GetChar();
        if (FileEOF()) {
            break;
        }
        value += c;
        switch (c) {
            case 34: {
                ReadString(value);
                break;
            }

            case 39: {
                ReadSymbol(value);
                break;
            }

            case '.' : {
                FindToken(State_Point, value);
                break;
            }

            case '(': {
                FindToken(State_Lbkt,value);
                break;
            }

            case ')': {
                FindToken(State_Rbkt,value);
                break;
            }
            case '#': {
                ReadSharp(value);
                break;
            }
            default: {
                if (isspecial(c) || isalpha(c)) {
                    ReadIdent(value);
                } else if (isdigit(c)) {
                    ReadNumber(value);
                } else if (IsEndToken(c)) {
                    value.erase(value.size() - 1, value.size());
                }
                break;
            }
        }
    }
    value = "EOF";
    FindToken(State_EOF, value);
}
Esempio n. 22
0
void CInArchive::ReadUnpackInfo(
    const CObjectVector<CByteBuffer> *dataVector,
    CObjectVector<CFolder> &folders)
{
  WaitAttribute(NID::kFolder);
  CNum numFolders = ReadNum();

  {
    CStreamSwitch streamSwitch;
    streamSwitch.Set(this, dataVector);
    folders.Clear();
    folders.Reserve(numFolders);
    for (CNum i = 0; i < numFolders; i++)
    {
      folders.Add(CFolder());
      GetNextFolderItem(folders.Back());
    }
  }

  WaitAttribute(NID::kCodersUnpackSize);

  CNum i;
  for (i = 0; i < numFolders; i++)
  {
    CFolder &folder = folders[i];
    CNum numOutStreams = folder.GetNumOutStreams();
    folder.UnpackSizes.Reserve(numOutStreams);
    for (CNum j = 0; j < numOutStreams; j++)
      folder.UnpackSizes.Add(ReadNumber());
  }

  for (;;)
  {
    UInt64 type = ReadID();
    if (type == NID::kEnd)
      return;
    if (type == NID::kCRC)
    {
      CBoolVector crcsDefined;
      CRecordVector<UInt32> crcs;
      ReadHashDigests(numFolders, crcsDefined, crcs);
      for (i = 0; i < numFolders; i++)
      {
        CFolder &folder = folders[i];
        folder.UnpackCRCDefined = crcsDefined[i];
        folder.UnpackCRC = crcs[i];
      }
      continue;
    }
    SkipData();
  }
}
Esempio n. 23
0
void Graph::InitGraph(FILE *fp) {
	int i,j,k;
	edge *e;
   sol_cn=cn;

   for (i=0; i<vn; i++) {
		label[i]=i;
   }
   
   for (i=0; i<vn; i++) {
		labelB[i]=i;
   }

	for (i=0; i<cn; i++) {
		L[i].en=0;
      L[i].c=i;
      L[i].root=NULL;
   }
					// Add edges in the empty graph:
	for (i=0; i<vn-1; i++) {
		for (j=i+1; j<vn; j++) {
			//if (i==j) continue;
			k=ReadNumber(fp);
			if (k==cn) continue;
					// Add color k for edge (i,j):
			e=new edge;
			e->u=i;
         e->v=j;
         e->c=k;
         e->next=L[k].root;
         L[k].root=e;
         L[k].en++;
		}
	}

   if (Demo==1){
   	printf("\ncolor(frequency): ");
		for (i=0; i<cn; i++) printf("%d(%d) ",L[i].c,L[i].en);
		printf("\n");
   	getch();
   }
   
   //q_sortGF(0, cn - 1);

   if (Demo==1){
   	printf("\n-- SORTED -- color(frequency): ");
		for (i=0; i<cn; i++) printf("%d(%d) ",L[i].c,L[i].en);
		printf("\n\n");
   	getch();
   }
}
Esempio n. 24
0
	JsonValue * JsonParser::ReadValue(JsonValue * parent)
	{
		if (*cur_ == '"')
		{
			return ReadString(parent);
		}
		else if (IsDigit(*cur_) || *cur_ == '-')
		{
			return ReadNumber(parent);
		}
		else if (IsAlpha(*cur_))
		{
			std::string keyword;
			ParseIdentifier(keyword);

			if (keyword == "null")
			{
				return 0;
			}
			if (keyword == "true")
			{
				return new JsonBooleanValue(parent, true);
			}
			else if (keyword == "false")
			{
				return new JsonBooleanValue(parent, false);
			}
			else
			{
				throw Error(
					row_,
					column_ - keyword.length(),
					FormatString("Invalid bareword \"%s\", while value expected", keyword.c_str())
				);
			}
		}
		else if (*cur_ == '[')
		{
			return ReadArray(parent);
		}
		else if (*cur_ == '{')
		{
			return ReadObject(parent);
		}
		else
		{
			RaiseError("Invalid symbol, while value expected");
			return 0;
		}
	}
Esempio n. 25
0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean ReadChar(source_t *source, fielddef_t *fd, void *p)
{
	token_t token;

	if (!PC_ExpectAnyToken(source, &token)) return (qboolean)0; // ***GREGS_VC9_PORT_MOD*** -- added typecast(s)

	//take literals into account
	if (token.type == TT_LITERAL)
	{
		StripSingleQuotes(token.string);
		*(char *) p = token.string[0];
	} //end if
	else
	{
		PC_UnreadLastToken(source);
		if (!ReadNumber(source, fd, p)) return (qboolean)0; // ***GREGS_VC9_PORT_MOD*** -- added typecast(s)
	} //end if
	return (qboolean)1; // ***GREGS_VC9_PORT_MOD*** -- added typecast(s)
} //end of the function ReadChar
Esempio n. 26
0
bool wxSimpleHtmlParser::ParseAttributes(wxSimpleHtmlTag* tag)
{
    // Parse attributes of a tag header until we reach >
    while (!IsTagEndBracket(GetChar(m_pos)) && !Eof())
    {
        EatWhitespace();

        wxString attrName, attrValue;

        if (IsString())
        {
            ReadString(attrName, TRUE);
            tag->AppendAttribute(attrName, wxEmptyString);
        }
        else if (IsNumeric(GetChar(m_pos)))
        {
            ReadNumber(attrName, TRUE);
            tag->AppendAttribute(attrName, wxEmptyString);
        }
        else
        {
            // Try to read an attribute name/value pair, or at least a name
            // without the value
            ReadLiteral(attrName, TRUE);
            EatWhitespace();

            if (GetChar(m_pos) == wxT('='))
            {
                m_pos ++;
                EatWhitespace();

                if (IsString())
                    ReadString(attrValue, TRUE);
                else if (!Eof() && !IsTagEndBracket(GetChar(m_pos)))
                    ReadLiteral(attrValue, TRUE);
            }
            if (!attrName.IsEmpty())
                tag->AppendAttribute(attrName, attrValue);
        }
    }
    return TRUE;
}
Esempio n. 27
0
void Read_Data(){
	int i,j,k;

   for (i=0; i<n-1; i++){	//my convenction, vertexes da from a n-1
   	for(j=i+1; j<n; j++){	//my convenction, vertexes da from a n-1
      	k=ReadNumber(Data_File);
         Color_Matrix[i][j]=k;
       }
   }
   if (Demo==1){
   	printf("Color_Matrix:\n");
   	for (i=0; i<n-1; i++){
   		for(j=i+1; j<n; j++){
      		printf("%d ",Color_Matrix[i][j]);
      	}
      	printf("\n");
   	}
   	printf("\n");
      getch();
   }
}
Esempio n. 28
0
static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value)
{
  Byte firstByte;
  UInt64 value64;
  if (sd->Size == 0)
    return SZ_ERROR_ARCHIVE;
  firstByte = *sd->Data;
  if ((firstByte & 0x80) == 0)
  {
    *value = firstByte;
    sd->Data++;
    sd->Size--;
    return SZ_OK;
  }
  RINOK(ReadNumber(sd, &value64));
  if (value64 >= (UInt32)0x80000000 - 1)
    return SZ_ERROR_UNSUPPORTED;
  if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 4)))
    return SZ_ERROR_UNSUPPORTED;
  *value = (UInt32)value64;
  return SZ_OK;
}
Esempio n. 29
0
int main()
{
    // TODO: don't declare variable on separate line +

    std::cout << "SIZE = ";
    int size = ReadNumber();
    if (size) {
        std::vector<bool> sieve = CreatingASieve(size);
        SievingSieve(sieve);

        // TODO: print set elements
        std::set<int> setOfPrimeNumbers = GetPrimesSet(sieve);
        size_t count = setOfPrimeNumbers.size();
        std::cout << count << std::endl;
        std::cout << std::endl;
        OutSetPrime(setOfPrimeNumbers);
    }
    else
    {
        std::cout << "Invalid input" << std::endl;
    }
    return 0;
}
Esempio n. 30
0
void UnassembleCommand(void) {
  int count = 8; // Default instruction count to display
  Sb(); if (IsDwDebugNumeric(NextCh())) {Uaddr = ReadInstructionAddress("U"); Wl();}
  Sb(); if (IsDwDebugNumeric(NextCh())) {count = ReadNumber(0);}
  Sb(); if (!DwEoln()) {Wsl("Unrecognised parameters on unassemble command.");}

  int firstByte = Uaddr;
  int limitByte = min(firstByte + count*4, FlashSize()); // Allow for up to 2 words per instruction
  int length    = limitByte - firstByte;

  if (length <= 0) {Fail("Nothing to disassemble.");}

  u8 buf[length+2];
  DwReadFlash(firstByte, length, buf);
  buf[length] = 0; buf[length+1] = 0;

  while (1) {
    Uaddr += DisassembleInstruction(Uaddr, &buf[Uaddr-firstByte]);
    count--;
    if (count <= 0  ||  Uaddr >= FlashSize()) {return;}
    Wl();
  }
}