LPCTSTR CRKey::GetSz(LPCTSTR pName, LPCTSTR pDefault) {_STTEX(); // Get the reg object if ( pName == NULL ) pName = ""; LPREGVALUE prv = (LPREGVALUE)Find( pName ); return GetSz( prv, pDefault ); }
std::string& CRKey::EncodeJson( std::string &s, int tabs ) { tabstr( s, tabs ); s += "{\r\n"; int n = 0; LPREGVALUE prv = NULL; while ( ( prv = (LPREGVALUE)GetNext( prv ) ) != NULL ) { // Separator if ( n++ ) s += ",\r\n"; tabstr( s, tabs + 1 ); // Key s += "\""; s += EncodeJsonStr( prv->cpkey ); s += "\": "; // Value s += "\""; if ( prv->type == REG_BINARY ) s += EncodeJsonStr( std::string( (const char *)prv->data, prv->size ) ); else s += EncodeJsonStr( GetSz( prv ) ); s += "\""; } // end while s += "\r\n"; tabstr( s, tabs ); s += "}"; return s; }
main() { setmode(fileno(stdin), O_BINARY); for (;;) { GetSz(); PutPhrase(); /* phrases */ PutWordsPunct(); /* words including punctuation */ PutWords(); /* words without punctuation */ } }
BOOL CRKey::EncodeHttpHeaders(CPipe *pPipe) {_STTEX(); // Add each value LPREGVALUE prv = NULL; while ( ( prv = (LPREGVALUE)GetNext( prv ) ) != NULL ) { // Write separator if needed // if ( pPipe->GetBufferSize() ) pPipe->Write( "\r\n" ); pPipe->Write( prv->cpkey ); pPipe->Write( ": " ); pPipe->Write( GetSz( prv ) ); pPipe->Write( "\r\n" ); } // end while return TRUE; }
BOOL CRKey::Save( CScsPropertyBag *pPb ) { if ( !pPb ) return FALSE; LPREGVALUE prv = NULL; while ( ( prv = (LPREGVALUE)GetNext( prv ) ) != NULL ) { // Write binary buffers if ( REG_BINARY == prv->type ) (*pPb)[ prv->cpkey ] = CScsPropertyBag::t_String( (LPCTSTR)prv->pbdata, prv->size ); else (*pPb)[ prv->cpkey ] = CScsPropertyBag::t_String( GetSz( prv ) ); } // end while return TRUE; }
BOOL CRKey::Replace(CPipe *out, LPDWORD op, LPCTSTR in, DWORD dwin, LPCTSTR pBegin, LPCTSTR pEnd, LPSTR pBreak, CVar *params, LPDWORD pdwBreak, char sep) {_STTEX(); // Sanity check if ( out == NULL || in == NULL ) return FALSE; // No break yet if ( pBreak != NULL ) *pBreak = 0; DWORD s = 0, i = 0; const char *strrep = pBegin; if ( strrep == NULL ) strrep = "<!--$$$"; DWORD dwrep = strlen( strrep ); const char *endrep = pEnd; if ( endrep == NULL ) endrep = "-->"; DWORD dwendrep = strlen( endrep ); // Pick up where we left off if ( pdwBreak != NULL ) s = i = *pdwBreak; while ( i < dwin ) { // Check for replace token if ( ( dwin - i ) > dwrep && *(LPDWORD)&in[ i ] == *(LPDWORD)strrep && !strnicmp( &in[ i ], strrep, dwrep ) ) { // Write out good data if ( i != s ) { out->Write( (LPVOID)&in[ s ], i - s ); } // end if DWORD x = 0; char token[ CWF_STRSIZE ]; // Skip replace flag i += dwrep; // Skip white space while ( i < dwin && ( in[ i ] <= ' ' || in[ i ] > '~' ) ) i++; if ( i >= dwin ) return TRUE; // Copy token while ( in[ i ] > ' ' && in[ i ] <= '~' && strnicmp( &in[ i ], endrep, dwendrep ) ) { if ( x < sizeof( token ) - 1 ) token[ x++ ] = in[ i ]; i++; } token[ x ] = 0; DWORD p = i; // Skip to end of replace tag while ( i < dwin && strnicmp( &in[ i ], endrep, dwendrep ) && in[ i ] != 0 ) i++; // Read in vars if any if ( i > p && params != NULL ) params->ReadInline( (LPBYTE)&in[ s ], i - p, sep ); // Skip end tag if ( !strnicmp( &in[ i ], endrep, dwendrep ) ) i += dwendrep; // Point to start of good data s = i; LPREGVALUE prv = (LPREGVALUE)IFind( token ); if ( prv != NULL ) { // Check for break if ( pBreak != NULL && prv->type == 0 ) { if ( pdwBreak != NULL ) *pdwBreak = i; strcpy( pBreak, token ); return TRUE; } // end if // Write out the replace value else out->Write( GetSz( prv ) ); } // end if else // Break { if ( pdwBreak != NULL ) *pdwBreak = i; strcpy( pBreak, token ); return TRUE; } // end else } // end if // Next i++; } // end while // Write out what's left of the data if ( i > s ) { out->Write( (LPVOID)&in[ s ], i - s ); } // end if return FALSE; }
BOOL CRKey::EncodeUrl(CPipe *pPipe, DWORD dwEncoding, char chSepNameVal, char chSepValues) {_STTEX(); // Add each value TMem< char > buf; LPREGVALUE prv = NULL; while ( ( prv = (LPREGVALUE)GetNext( prv ) ) != NULL ) { // Write separator if needed if ( pPipe->GetBufferSize() ) pPipe->Write( &chSepValues, 1 ); switch( dwEncoding ) { case 0 : { // Write the key pPipe->Write( prv->cpkey, prv->ksize ); // Separator pPipe->Write( &chSepNameVal, 1 ); // Write raw value if ( REG_BINARY == prv->type ) pPipe->Write( prv->pbdata, prv->size ); else pPipe->Write( GetSz( prv ) ); } break; case 1 : { // Write the name if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( strlen( prv->cpkey ) ) ) ) { buf.Zero(); CCfgFile::CanonicalizeBuffer( buf, prv->bpkey, strlen( prv->cpkey ) ); pPipe->Write( buf ); } // end if // Separator pPipe->Write( &chSepNameVal, 1 ); // Write binary buffers if ( REG_BINARY == prv->type ) { // Binary encoding if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( prv->size ) ) ) { buf.Zero(); CCfgFile::CanonicalizeBuffer( buf, prv->pbdata, prv->size ); pPipe->Write( buf ); } // end if } // end if else { // Write the name LPCTSTR val = GetSz( prv ); if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( strlen( val ) ) ) ) { buf.Zero(); CCfgFile::CanonicalizeBuffer( buf, (LPBYTE)val, strlen( val ) ); pPipe->Write( buf ); } // end if } // end if } break; case 2 : { TMem< char > buf2; // Write the name if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( strlen( prv->cpkey ) ) ) ) { buf.Zero(); CCfgFile::CanonicalizeBuffer( buf, prv->bpkey, strlen( prv->cpkey ) ); pPipe->Write( buf ); } // end if // Separator pPipe->Write( &chSepNameVal, 1 ); // Write binary buffers if ( REG_BINARY == prv->type ) { // Binary encoding if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( prv->size ) ) ) { buf.Zero(); CCfgFile::CanonicalizeBuffer( buf, prv->pbdata, prv->size ); } // end if } // end if else { // Write the name LPCTSTR val = GetSz( prv ); if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( strlen( val ) ) ) ) { buf.Zero(); CCfgFile::CanonicalizeBuffer( buf, (LPBYTE)val, strlen( val ) ); } // end if } // end if // Encoded again then add to buffer if ( buf2.grow( CCfgFile::GetMinCanonicalizeBufferSize( strlen( buf.ptr() ) ) ) ) { buf2.Zero(); CCfgFile::CanonicalizeBuffer( buf2, (LPBYTE)buf.ptr(), strlen( buf.ptr() ) ); pPipe->Write( buf2 ); } // end if } break; } // end switch } // end while return TRUE; }
JavascriptString* string = JavascriptString::NewCopySzFromArena(stringBuffer, scriptContext, scriptContext->GeneralAllocator()); return string; } // End Entry Points void JavascriptSIMDFloat32x4::ToStringBuffer(SIMDValue& value, __out_ecount(countBuffer) wchar_t* stringBuffer, size_t countBuffer, ScriptContext* scriptContext) { JavascriptString *s0, *s1, *s2, *s3; s0 = JavascriptNumber::ToStringRadix10((double)value.f32[0], scriptContext); s1 = JavascriptNumber::ToStringRadix10((double)value.f32[1], scriptContext); s2 = JavascriptNumber::ToStringRadix10((double)value.f32[2], scriptContext); s3 = JavascriptNumber::ToStringRadix10((double)value.f32[3], scriptContext); swprintf_s(stringBuffer, countBuffer, L"SIMD.Float32x4(%s, %s, %s, %s)", s0->GetSz(), s1->GetSz(), s2->GetSz(), s3->GetSz()); } Var JavascriptSIMDFloat32x4::Copy(ScriptContext* requestContext) { return JavascriptSIMDFloat32x4::New(&this->value, requestContext); } __inline Var JavascriptSIMDFloat32x4::GetSignMask() { int signMask = SIMDFloat32x4Operation::OpGetSignMask(value); return TaggedInt::ToVarUnchecked(signMask); } }