Ejemplo n.º 1
0
BOOL LLDataPackerAsciiBuffer::packF32(const F32 value, const char *name)
{
	BOOL success = TRUE;
	writeIndentedName(name);
	int numCopied = 0;
	if (mWriteEnabled)
	{
	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f\n", value);		/* Flawfinder: ignore */
	}
	else
	{
		numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%f\n", value);		/* Flawfinder: ignore */	
	}
	// snprintf returns number of bytes that would have been written
	// had the output not being truncated. In that case, it will
	// return either -1 or value >= passed in size value . So a check needs to be added
	// to detect truncation, and if there is any, only account for the
	// actual number of bytes written..and not what could have been
	// written.
	if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
	{
		numCopied = getBufferSize()-getCurrentSize();
		llwarns << "LLDataPackerAsciiBuffer::packF32: val truncated: " << llendl;
	}

	mCurBufferp += numCopied;
	return success;
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
// LLDataPackerAsciiBuffer implementation
//---------------------------------------------------------------------------
BOOL LLDataPackerAsciiBuffer::packString(const char *value, const char *name)
{
	BOOL success = TRUE;
	writeIndentedName(name);
	int numCopied = 0;
	if (mWriteEnabled) 
	{
		numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value);		/* Flawfinder: ignore */
	}
	else
	{
		numCopied = (S32)strlen(value) + 1; /*Flawfinder: ignore*/
	}

	// snprintf returns number of bytes that would have been written
	// had the output not being truncated. In that case, it will
	// return either -1 or value >= passed in size value . So a check needs to be added
	// to detect truncation, and if there is any, only account for the
	// actual number of bytes written..and not what could have been
	// written.
	if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
	{
		// *NOTE: I believe we need to mark a failure bit at this point.
	    numCopied = getBufferSize()-getCurrentSize();
		llwarns << "LLDataPackerAsciiBuffer::packString: string truncated: " << value << llendl;
	}
	mCurBufferp += numCopied;
	return success;
}
Ejemplo n.º 3
0
void LLDataPackerAsciiBuffer::writeIndentedName(const char *name)
{
	if (mIncludeNames)
	{
		int numCopied = 0;
		if (mWriteEnabled)
		{
			numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\t", name);	/* Flawfinder: ignore */
		}
		else
		{
			numCopied = (S32)strlen(name) + 1; 	/* Flawfinder: ignore */ //name + tab  	
		}

		// snprintf returns number of bytes that would have been written
		// had the output not being truncated. In that case, it will
		// return either -1 or value >= passed in size value . So a check needs to be added
		// to detect truncation, and if there is any, only account for the
		// actual number of bytes written..and not what could have been
		// written.
		if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
		{
			numCopied = getBufferSize()-getCurrentSize();
			llwarns << "LLDataPackerAsciiBuffer::writeIndentedName: truncated: " << llendl;
		}

		mCurBufferp += numCopied;
	}
}
Ejemplo n.º 4
0
BOOL LLDataPackerAsciiBuffer::packUUID(const LLUUID &value, const char *name)
{
	BOOL success = TRUE;
	writeIndentedName(name);

	int numCopied = 0;
	if (mWriteEnabled)
	{
		char tmp_str[64]; /* Flawfinder: ignore */ 
		value.toString(tmp_str);
	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", tmp_str);	/* Flawfinder: ignore */
	}
	else
	{
		numCopied = 64 + 1; // UUID + newline
	}
	// snprintf returns number of bytes that would have been written
	// had the output not being truncated. In that case, it will
	// return either -1 or value >= passed in size value . So a check needs to be added
	// to detect truncation, and if there is any, only account for the
	// actual number of bytes written..and not what could have been
	// written.
	if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
	{
	    numCopied = getBufferSize()-getCurrentSize();
		llwarns << "LLDataPackerAsciiBuffer::packUUID: truncated: " << llendl;
		success = FALSE;
	}
	mCurBufferp += numCopied;
	return success;
}
Ejemplo n.º 5
0
ArrayBag<ItemType> ArrayBag<ItemType>::Union(const ArrayBag<ItemType> secondBag)
{
   ArrayBag<ItemType> unionBag;
   getCurrentSize();
   int bigSize = itemCount + secondBag.getCurrentSize();
    //Begin C++ Interlude 3 HW
   if (bigSize > unionBag.DEFAULT_CAPACITY)
       throw std::out_of_range ("Union of these Bags exceeds Default Capacity");
    //End C++ Interlude 3 HW
   for (int i=0; i<getCurrentSize(); i++)
      unionBag.add(items[i]);
   for (int i=0; i<secondBag.getCurrentSize(); i++)
      unionBag.add(secondBag.items[i]);
   return unionBag;
}
Ejemplo n.º 6
0
ArrayBag<ItemType> ArrayBag<ItemType>::difference(const ArrayBag<ItemType> bag2)
{
   for (int i=0; i<getCurrentSize(); i++)
   {
      if (bag2.contains(items[i]))
      {
         remove(items[i]);
      }
       
   }
}
Ejemplo n.º 7
0
  ////////////////////////////////////////////////////////////////////////
  // ConnectionPool
  //
  Connection ConnectionPool::connect()
  {
    log_debug("ConnectionPool::connect()");

    log_debug("current pool-size " << getCurrentSize());

    unsigned max = getCurrentSize() * 2;

    for (unsigned n = 0; n < max; ++n)
    {
      Connection conn(new PoolConnection(pool.get()));

      if (conn.ping())
        return conn;

      // a pool-connection don't put itself back into the pool after a failed ping
      log_warn("drop dead connection from pool");
    }

    return Connection(new PoolConnection(pool.get()));
  }
Ejemplo n.º 8
0
ArrayBag<ItemType> ArrayBag<ItemType>::intersection(const ArrayBag<ItemType> bag2)
{
   ArrayBag<ItemType> interBag;
   for (int i=0; i<getCurrentSize(); i++)
   {
      if (bag2.contains(items[i]))
      {
         interBag.add(items[i]);
      }
   }
   return interBag;
}
Ejemplo n.º 9
0
BOOL LLDataPackerAsciiBuffer::packBinaryDataFixed(const U8 *value, S32 size, const char *name)
{
	BOOL success = TRUE;
	writeIndentedName(name);
	
	if (mWriteEnabled)
	{
		S32 i;
		int numCopied = 0;
		BOOL bBufferFull = FALSE;
		for (i = 0; i < size && !bBufferFull; i++)
		{
			numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]);	/* Flawfinder: ignore */
			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
			{
			    numCopied = getBufferSize()-getCurrentSize();
				llwarns << "LLDataPackerAsciiBuffer::packBinaryDataFixed: data truncated: " << llendl;
			    bBufferFull = TRUE;
			}
			mCurBufferp += numCopied;

		}
		if (!bBufferFull)
		{
			numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n");	/* Flawfinder: ignore */
			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
			{
				numCopied = getBufferSize()-getCurrentSize();
				llwarns << "LLDataPackerAsciiBuffer::packBinaryDataFixed: newline truncated: " << llendl;
			}
			
			mCurBufferp += numCopied;
		}
	}
	else
	{
		int numCopied = 2 * size + 1; //hex bytes plus newline 
		if (numCopied > getBufferSize()-getCurrentSize())
		{
			numCopied = getBufferSize()-getCurrentSize();
		}   
		mCurBufferp += numCopied;
	}
	return success;
}
Ejemplo n.º 10
0
void osgParticle::Particle::setUpTexCoordsAsPartOfConnectedParticleSystem(ParticleSystem* ps)
{
    if (getPreviousParticle()!=Particle::INVALID_INDEX)
    {
        update(0.0, false);

        Particle* previousParticle = ps->getParticle(getPreviousParticle());
        const osg::Vec3& previousPosition = previousParticle->getPosition();
        const osg::Vec3& newPosition = getPosition();
        float distance = (newPosition-previousPosition).length();
        float s_coord_delta = 0.5f*distance/getCurrentSize();
        float s_coord = previousParticle->_s_coord + s_coord_delta;

        setTextureTile(1,1,0);
        _cur_tile = 0;
        _s_coord = s_coord;
        _t_coord = 0.0f;
    }
}
Ejemplo n.º 11
0
 virtual DataSpace<DIM> getCurrentDataSpace()
 {
     return getCurrentDataSpace(getCurrentSize());
 }
Ejemplo n.º 12
0
BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const char *name)
{
	BOOL success = TRUE;
	writeIndentedName(name);
	
	int numCopied = 0;
	if (mWriteEnabled)
	{
		numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%010d ", size);	/* Flawfinder: ignore */

		// snprintf returns number of bytes that would have been
		// written had the output not being truncated. In that case,
		// it will retuen >= passed in size value.  so a check needs
		// to be added to detect truncation, and if there is any, only
		// account for the actual number of bytes written..and not
		// what could have been written.
		if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
		{
			numCopied = getBufferSize()-getCurrentSize();
			llwarns << "LLDataPackerAsciiBuffer::packBinaryData: number truncated: " << size << llendl;
		}
		mCurBufferp += numCopied;


		S32 i;
		BOOL bBufferFull = FALSE;
		for (i = 0; i < size && !bBufferFull; i++)
		{
			numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]);	/* Flawfinder: ignore */
			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
			{
				numCopied = getBufferSize()-getCurrentSize();
				llwarns << "LLDataPackerAsciiBuffer::packBinaryData: data truncated: " << llendl;
				bBufferFull = TRUE;
			}
			mCurBufferp += numCopied;
		}

		if (!bBufferFull)
		{
			numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n");	/* Flawfinder: ignore */
			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
		    	{
				numCopied = getBufferSize()-getCurrentSize();
				llwarns << "LLDataPackerAsciiBuffer::packBinaryData: newline truncated: " << llendl;
		    	}
		    	mCurBufferp += numCopied;
		}
	}
	else
	{
		// why +10 ?? XXXCHECK
		numCopied = 10 + 1; // size plus newline
		numCopied += size;
		if (numCopied > getBufferSize()-getCurrentSize())
		{
			numCopied = getBufferSize()-getCurrentSize();
		}   
		mCurBufferp += numCopied;
	}
	
	return success;
}