int main(int /*nArgs*/, const char* /*paszArgs*/[]) { try { std::auto_ptr< ::samples::binarydata::KeyGenerator > pKeyGenerator(::staff::ServiceFactory::Inst().GetService< ::samples::binarydata::KeyGenerator >()); STAFF_ASSERT(pKeyGenerator.get(), "Cannot get client for service samples.binarydata.KeyGenerator!"); // Invoke Your service here: staff::hexBinary tHexKey = pKeyGenerator->GenerateHexKey(0x12345678); staff::LogInfo() << "Generated HexKey: " << tHexKey.ToString(); staff::LogInfo() << "HexKey is valid: " << pKeyGenerator->ValidateHexKey(tHexKey); // do some actions with binary data here staff::LogInfo() << "dump of HexKey:"; OutputData(tHexKey.GetBytes()); // do the same with base64 staff::base64Binary tBase64Key = pKeyGenerator->GenerateBase64Key(0x12345678); staff::LogInfo() << "GenerateBase64Key result: " << tBase64Key.ToString(); staff::LogInfo() << "Base64Key is valid: " << pKeyGenerator->ValidateBase64Key(tBase64Key); // do some actions with binary data here staff::LogInfo() << "dump of Base64Key:"; OutputData(tBase64Key.GetBytes()); } STAFF_CATCH_ALL return 0; }
// Constructor of OutputDataWarehouse; initializes the OutputData structures for 'variable' based output types OutputDataWarehouse::OutputDataWarehouse() : OutputMapWrapper<OutputData>(), _has_show_list(false) { _map["nodal"] = OutputData(); _map["elemental"] = OutputData(); _map["scalars"] = OutputData(); _map["postprocessors"] = OutputData(); _map["vector_postprocessors"] = OutputData(); }
/* Output a line ** ------------- */ PRIVATE void display_line (HText * text, HTLine * line) { #ifdef CURSES int y, x; waddstr(w_text, SPACES(line->offset)); waddstr(w_text, line->data); getyx(w_text, y, x); if (y < DISPLAY_LINES-1) { wmove(w_text, ++y, 0); } #else if (!text->target) { #ifdef CYRILLIC /* HWL 18/7/94: applied patch from [email protected] (Anton Tropashko) */ a_print(SPACES(line->offset),H,stdout); a_print(line->data,H,stdout); fputc('\n',stdout); #else OutputData(LineMode_getView(text->pLm), "%s%s\n", SPACES(line->offset), line->data); #endif } else { PUTS(SPACES(line->offset)); PUTS(line->data); PUTC('\n'); } #endif }
void TapeImage_HandleBlock0x010(SAMPLE_BUFFER *pBuffer, char *pBlockDataPtr) { TZX_DATA_SIGNAL_DESCRIPTION DataDescription; /* setup pilot tone */ OutputWaves(pBuffer, 2168, 3220); /* sync pulse 1 */ OutputPulse(pBuffer, 667); /* sync pulse 2 */ OutputPulse(pBuffer, 735); /* data */ DataDescription.LengthOfOneBitPulseInTStates = 1710; DataDescription.LengthOfZeroBitPulseInTStates = 855; DataDescription.pData = pBlockDataPtr + 0x04; DataDescription.Length = TapeImage_GetWord(pBlockDataPtr+0x02); DataDescription.NumberOfBitsUsedInLastByte = 8; OutputData(pBuffer, &DataDescription); /* pause after block */ OutputPause(pBuffer, TapeImage_GetWord(pBlockDataPtr + 0x00)); }
void TapeImage_HandleBlock0x011(SAMPLE_BUFFER *pBuffer, char *pBlockDataPtr) { TZX_DATA_SIGNAL_DESCRIPTION DataDescription; /* setup pilot tone */ OutputWaves(pBuffer, TapeImage_GetWord(pBlockDataPtr+0), TapeImage_GetWord(pBlockDataPtr+0x0a)); /* sync pulse 1 */ OutputPulse(pBuffer, TapeImage_GetWord(pBlockDataPtr+2)); /* sync pulse 2 */ OutputPulse(pBuffer, TapeImage_GetWord(pBlockDataPtr+4)); /* data */ DataDescription.LengthOfOneBitPulseInTStates = TapeImage_GetWord(pBlockDataPtr + 0x08); DataDescription.LengthOfZeroBitPulseInTStates = TapeImage_GetWord(pBlockDataPtr + 0x06); DataDescription.pData = pBlockDataPtr + 0x012; DataDescription.Length = TapeImage_GetValue(pBlockDataPtr + 0x0f, 3); DataDescription.NumberOfBitsUsedInLastByte = TapeImage_GetByte(pBlockDataPtr + 0x0c); OutputData(pBuffer, &DataDescription); /* pause after block */ OutputPause(pBuffer, TapeImage_GetWord(pBlockDataPtr + 0x0d)); }
int main() { int data[MaxN]; int scale; InputData(data,&scale); QSort(data,0,scale-1); OutputData(data,scale); return 0; }
/* Fill the screen with blank after the file ** -------------------------- */ PRIVATE void fill_screen (HText * text, int n) { if (n<=0 || n>1000) return; /* Large value means no pagination */ if (text->target) return; #ifdef CURSES waddstr(w_text, end_mark); wclrtobot(w_text); wrefresh(w_text); #else #ifndef VIOLA if (!text->target) OutputData(LineMode_getView(text->pLm), "%s\n", end_mark); else { PUTS(end_mark); PUTC('\n'); } n--; for (; n; n--) { if (!text->target) OutputData(LineMode_getView(text->pLm), "\n"); else PUTC('\n'); } #endif #endif /* Not CURSES */ }
/* Handle Block 0x014 - Pure Data*/ void TapeImage_HandleBlock0x014(SAMPLE_BUFFER *pBuffer, char *pBlockDataPtr) { TZX_DATA_SIGNAL_DESCRIPTION DataDescription; /* data */ DataDescription.LengthOfOneBitPulseInTStates = TapeImage_GetWord(pBlockDataPtr + 0x02); DataDescription.LengthOfZeroBitPulseInTStates = TapeImage_GetWord(pBlockDataPtr + 0x00); DataDescription.pData = pBlockDataPtr + 0x0a; DataDescription.Length = TapeImage_GetValue(pBlockDataPtr + 0x07, 3); DataDescription.NumberOfBitsUsedInLastByte = TapeImage_GetByte(pBlockDataPtr + 0x04); OutputData(pBuffer, &DataDescription); /* pause after block */ OutputPause(pBuffer, TapeImage_GetWord(pBlockDataPtr + 0x05)); }
void cScenarioArmEval::Update(double time_elapsed) { cScenarioArm::Update(time_elapsed); UpdateTrackError(); if (mErrSampleCount == mMaxSamples) { if (mOutputFile != "") { OutputResult(mOutputFile); } } if (mOutputData) { OutputData(); } }
/* Output the title line ** --------------------- */ PRIVATE void display_title (HText * text) { const char * title = HTAnchor_title(text->node_anchor); char percent[20], format[20]; if (text->lines > (DISPLAY_LINES-1)) { #ifdef NOPE sprintf(percent, " (p%d of %d)", (text->top_of_screen/(DISPLAY_LINES-1)) + 1, (text->lines-1)/(DISPLAY_LINES-1) + 1); sprintf(percent, " (%d%%)", 100*(text->top_of_screen+DISPLAY_LINES-1)/ /* Seen */ (text->lines)); /* Total */ #else sprintf(percent, " (%d/%d)", text->top_of_screen+DISPLAY_LINES-1, /* Seen */ text->lines); /* Total */ #endif } else { percent[0] = 0; /* Null string */ } sprintf(format, "%%%d.%ds%%s\n", /* Generate format string */ (int)(HTScreenWidth-strlen(percent)), (int)(HTScreenWidth-strlen(percent)) ); #ifdef CURSES mvwprintw(w_top, 0, 0, format, title, percent); wrefresh(w_top); #else if (!text->target) OutputData(LineMode_getView(text->pLm), format, title, percent); else { char * line; if ((line = (char *) HT_MALLOC(HTScreenWidth+10)) == NULL) HT_OUTOFMEM("display_titile"); sprintf(line, format, title, percent); PUTS(line); HT_FREE(line); } #endif }
void ProcFile( FILE *fp, bool is_intel ) /**************************************/ { byte cksum; byte hdr[ 3 ]; unsigned_16 page_len; unsigned_32 offset; const char *recname; unsigned_32 total_padding; int raw_dump; int i; int first; IsPharLap = FALSE; IsMS386 = FALSE; IsIntel = is_intel; RecNum = 0; page_len = 0; RecBuff = NULL; RecMaxLen = 0; total_padding = 0; Lnames = NULL; Xnames = NULL; Segdefs = NULL; Grpdefs = NULL; first = 1; for(;;) { raw_dump = DumpRaw; offset = ftell( fp ); if( fread( hdr, 1, 3, fp ) != 3 ) break; cksum = hdr[ 0 ]; cksum += hdr[ 1 ]; cksum += hdr[ 2 ]; RecLen = hdr[ 1 ] | ( hdr[ 2 ] << 8 ); ResizeBuff( RecLen ); RecPtr = RecBuff; if( fread( RecBuff, RecLen, 1, fp ) == 0 ) { break; } cksum += checkSumBuff(); IsMS386 = hdr[ 0 ] & 1; if( IsMS386 ) { IsIntel = FALSE; } no_disp = ( rec_count == 0 ) ? FALSE : TRUE; for( i = 0; i < rec_count; i++ ) { if( rec_type[ i ] == ( hdr[ 0 ] & ~1 )) { no_disp = FALSE; break; } } recname = RecNumberToName( hdr[ 0 ] ); cksum = -( cksum - RecBuff[ RecLen - 1 ] ); Output( CRLF "%s%s(%2) recnum:%u, offset:%X, len:%x, chksum:%b(%2)" CRLF, recname, IsMS386 ? "386" : "", hdr[ 0 ], ++RecNum, offset, RecLen, RecBuff[ RecLen - 1 ], cksum ); RecLen--; if( setjmp( BailOutJmp ) == 0 ) { switch( hdr[ 0 ] & ~1 ) { case CMD_RHEADR: ProcRHeadr(); break; case CMD_ENDREC: ProcEndRec(); break; case CMD_THEADR: ProcTHeadr( first ); first = 0; break; case CMD_LHEADR: ProcLHeadr(); break; case CMD_COMENT: ProcComent(); break; case CMD_MODEND: ProcModEnd(); if( page_len != 0 ) { offset = ftell( fp ); offset = page_len - offset % page_len; if( offset != page_len ) { total_padding += offset; fseek( fp, offset, SEEK_CUR ); } } first = 1; break; case CMD_STATIC_EXTDEF: /* fall through */ case CMD_EXTDEF: ProcExtNames(); break; case CMD_STATIC_PUBDEF: /* fall through */ case CMD_PUBDEF: ProcPubDefs(); break; case CMD_LOCSYM: ProcLocSyms(); break; case CMD_LINNUM: ProcLinNums(); break; case CMD_LLNAME: /* fall through */ case CMD_LNAMES: ProcLNames( &Nameindex ); break; case CMD_SEGDEF: ProcSegDefs(); break; case CMD_GRPDEF: ProcGrpDef(); break; case CMD_FIXUP: ProcFixup(); break; case CMD_LEDATA: ProcLedata(); break; case CMD_LIDATA: ProcLidata(); break; case CMD_LIBNAM: ProcNames( &Libindex ); break; case CMD_STATIC_COMDEF: /* fall through */ case CMD_COMDEF: ProcComDef(); break; case CMD_BAKPAT: ProcBackPat(); break; case CMD_CEXTDF: ProcComExtDef(); break; case CMD_COMDAT: ProcComDat(); break; case CMD_LINSYM: ProcLineSym(); break; case CMD_ALIAS: ProcAlias(); break; case CMD_NBKPAT: ProcNameBackPat(); break; case CMD_VERNUM: ProcVerNum(); break; case CMD_VENDEXT: ProcVendExt(); break; case LIB_HEADER_REC: if( hdr[ 0 ] & 1 ) { /* LIB_TRAILER_REC */ ProcLibTrailer( fp ); fseek( fp, 0L, SEEK_END ); page_len = 0; } else { page_len = RecLen + 4; ProcLibHeader(); } break; default: if( !raw_dump ) { OutputData( 0L, 0L ); } break; } } else { /* something bailed out... */ if( raw_dump ) { Output( INDENT "Error at offset %x" CRLF, (unsigned_32)(pointer_int)RecOffset ); } else if( !EndRec() ) { Output( INDENT "Remainder of record follows:" CRLF ); OutputData( (unsigned_32)RecOffset(), 0L ); } else { Output( INDENT "End of record" CRLF ); } } if( raw_dump ) { RecPtr = RecBuff; Output( "====================RAW DUMP===============================================" CRLF ); OutputData( 0L, 0L ); Output( "====================RAW DUMP===============================================" CRLF ); } } if( total_padding > 0 ) { Output( CRLF "total padding=%X" CRLF, total_padding ); } if( TranslateIndex) { PrintNames(); } FreeGrpdefs(); FreeSegdefs(); FreeLnames(); FreeXnames(); free( RecBuff ); }
void APlayerConnectionHandler::UpdatePlayerIncome(int8 PlayerID, int32 Income) { int32 ClientID = GetClientID(PlayerID); SendData(ClientID, OutputData(SC_Income, Income)); }
void APlayerConnectionHandler::UpdatePlayerLives(int8 PlayerID, int32 Lives) { int32 ClientID = GetClientID(PlayerID); SendData(ClientID, OutputData(SC_Lives, Lives)); }
void APlayerConnectionHandler::UpdatePlayerMoney(int8 PlayerID, int32 Money) { int32 ClientID = GetClientID(PlayerID); SendData(ClientID, OutputData(SC_AmountOfMoney, Money)); }
/** Toggle page break global. This turns on and off prompting to Quit or hit any key to continue when a command is about to scroll the screen with its output Argv[0] - "hexdump"[.#] # is optional 1,2, or 4 for width Argv[1] - Device or File to dump. Argv[2] - Optional offset to start dumping Argv[3] - Optional number of bytes to dump @param Argc Number of command arguments in Argv @param Argv Array of strings that represent the parsed command line. Argv[0] is the command name @return EFI_SUCCESS **/ EFI_STATUS EFIAPI EblHexdumpCmd ( IN UINTN Argc, IN CHAR8 **Argv ) { EFI_OPEN_FILE *File; VOID *Location; UINTN Size; UINTN Width; UINTN Offset = 0; EFI_STATUS Status; UINTN Chunk = HEXDUMP_CHUNK; if ((Argc < 2) || (Argc > 4)) { return EFI_INVALID_PARAMETER; } Width = WidthFromCommandName (Argv[0], 1); if ((Width != 1) && (Width != 2) && (Width != 4)) { return EFI_INVALID_PARAMETER; } File = EfiOpen (Argv[1], EFI_FILE_MODE_READ, 0); if (File == NULL) { return EFI_NOT_FOUND; } Location = AllocatePool (Chunk); Size = (Argc > 3) ? AsciiStrHexToUintn (Argv[3]) : EfiTell (File, NULL); Offset = 0; if (Argc > 2) { Offset = AsciiStrHexToUintn (Argv[2]); if (Offset > 0) { // Make sure size includes the part of the file we have skipped Size += Offset; } } Status = EfiSeek (File, Offset, EfiSeekStart); if (EFI_ERROR (Status)) { goto Exit; } for (; Offset + HEXDUMP_CHUNK <= Size; Offset += Chunk) { Chunk = HEXDUMP_CHUNK; Status = EfiRead (File, Location, &Chunk); if (EFI_ERROR(Status)) { AsciiPrint ("Error reading file content\n"); goto Exit; } Status = OutputData (Location, Chunk, Width, File->BaseOffset + Offset); if (EFI_ERROR(Status)) { if (Status == EFI_END_OF_FILE) { Status = EFI_SUCCESS; } goto Exit; } } // Any left over? if (Offset < Size) { Chunk = Size - Offset; Status = EfiRead (File, Location, &Chunk); if (EFI_ERROR(Status)) { AsciiPrint ("Error reading file content\n"); goto Exit; } Status = OutputData (Location, Chunk, Width, File->BaseOffset + Offset); if (EFI_ERROR(Status)) { if (Status == EFI_END_OF_FILE) { Status = EFI_SUCCESS; } goto Exit; } } Exit: EfiClose (File); FreePool (Location); return EFI_SUCCESS; }