MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / PutString

Method PutString

src/tier1/utlbuffer.cpp:1252–1301  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Writes a null-terminated string -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1250// Writes a null-terminated string
1251//-----------------------------------------------------------------------------
1252void CUtlBuffer::PutString( const char* pString )
1253{
1254 if (!IsText())
1255 {
1256 if ( pString )
1257 {
1258 // Not text? append a null at the end.
1259 int nLen = V_strlen( pString ) + 1;
1260 Put( pString, nLen * sizeof(char) );
1261 return;
1262 }
1263 else
1264 {
1265 PUT_BIN_DATA(char, 0);
1266 }
1267 }
1268 else if (pString)
1269 {
1270 int nTabCount = ( m_Flags & AUTO_TABS_DISABLED ) ? 0 : m_nTab;
1271 if ( nTabCount > 0 )
1272 {
1273 if ( WasLastCharacterCR() )
1274 {
1275 PutTabs();
1276 }
1277
1278 const char* pEndl = strchr( pString, '\n' );
1279 while ( pEndl )
1280 {
1281 size_t nSize = (size_t)pEndl - (size_t)pString + sizeof(char);
1282 Put( pString, static_cast<int>( nSize ) );
1283 pString = pEndl + 1;
1284 if ( *pString )
1285 {
1286 PutTabs();
1287 pEndl = strchr( pString, '\n' );
1288 }
1289 else
1290 {
1291 pEndl = NULL;
1292 }
1293 }
1294 }
1295 size_t nLen = V_strlen( pString );
1296 if ( nLen )
1297 {
1298 Put( pString, static_cast<int>( nLen * sizeof(char) ) );
1299 }
1300 }
1301}
1302
1303
1304//-----------------------------------------------------------------------------

Callers 1

TestOpenSSHEd25519Function · 0.80

Calls 1

V_strlenFunction · 0.85

Tested by 1

TestOpenSSHEd25519Function · 0.64