Example #1
0
LIB_EXPORT rc_t CC KFileMakeBzip2ForRead (const struct KFile **pnew_obj,
                                          const struct KFile *compfile)
{
    rc_t rc;

    if ( pnew_obj == NULL || compfile == NULL )
        return RC ( rcFS, rcFile, rcConstructing, rcParam, rcNull );

    else
    {
        KBZipFile *obj;

        *pnew_obj = NULL;

        obj = (KBZipFile*) calloc(1,sizeof(KBZipFile));
        if (!obj)
        {
            rc = RC (rcFS, rcFile, rcConstructing, rcMemory, rcExhausted);
            LOGERR (klogErr, rc, "memory exhausted building bzip2 "
                    "file object");
        }
        else
        {
            rc = KFileInit(&obj->dad, (const KFile_vt*) &KBZipFile_vt_v1,
                           "KBZipFile", "no-name", true, false);
            if (rc == 0)
            {
                bz_stream * strm;
                int zret;

                strm = &obj->strm;
                zret = BZ2_bzDecompressInit (strm, 1, /* verbosity */
                                             0); /* small */

                switch (zret)
                {
                case BZ_OK:
                    obj->completed = true;
                    rc = KFileAddRef (compfile);
                    if (rc == 0)
                    {
                        obj->file = (KFile *)compfile;
                        *pnew_obj = &obj->dad;
                        return 0;
                    }
                    break;

                case BZ_CONFIG_ERROR:
                    rc = RC (rcFS, rcFile, rcConstructing, rcLibrary,
                             rcCorrupt);
                    LOGERR (klogFatal, rc, "bzip2 library miscompiled");
                    break;

                case BZ_PARAM_ERROR:
                    rc = RC (rcFS, rcFile, rcConstructing, rcParam, rcInvalid);
                    LOGERR (klogInt, rc, "coding error bzip2 file object");
                    break;

                case BZ_MEM_ERROR:
                    rc = RC (rcFS, rcFile, rcConstructing, rcMemory,
                             rcExhausted);
                    LOGERR (klogErr, rc, "memory exhausted building bzip2 "
                            "file object");
                    break;

                default:
                    rc = RC (rcFS, rcFile, rcConstructing, rcLibrary,
                             rcUnexpected);
                    LOGERR (klogFatal, rc, "bzip2 library return unexpected "
                            "error");
                    break;

                }
            }
        }
        KBZipFileDestroy (obj);
    }
    return rc;
}
Example #2
0
bool CDX10Shader::Execute(std::vector<ID3D10RenderTargetView*> *vecRT, unsigned int vertexIndexStep)
{
	ID3D10Device* pDevice = m_rendererSystem->GetDevice();
	ID3D10RenderTargetView* oldRTV = 0;
	ID3D10DepthStencilView* oldDSV = 0;

	if (vecRT!=NULL && !vecRT->empty())
		pDevice->OMGetRenderTargets(1, &oldRTV, &oldDSV);

	D3D10_TECHNIQUE_DESC techDesc;
	m_effect.GetTechnique()->GetDesc(&techDesc);
	unsigned int cPasses = techDesc.Passes;

	unsigned int stride = m_vertsize;
	unsigned int offset = 0;
	ID3D10Buffer* buffer = m_vb.GetVertexBuffer();
	pDevice->IASetVertexBuffers(0, 1, &buffer, &stride, &offset);
	if (m_vb.m_type == D3DVertexBuffer::INDEXED_BUFFER) 
	{
		pDevice->IASetIndexBuffer(m_vb.GetIndexBuffer(), DXGI_FORMAT_R32_UINT, 0);
		pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
	} else 
	{
		pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
	}

	pDevice->IASetInputLayout(m_inputLayout);
	for (unsigned int iPass = 0; iPass < cPasses; iPass++)
	{
		if (!m_effect.BeginPass(iPass)) 
		{
			LOGERR("Failed to apply and begin pass %u in technique %s", iPass, techDesc.Name);
			break;
		}

		if (vecRT != NULL && vecRT->size() > iPass)
			pDevice->OMSetRenderTargets(1, &(*vecRT)[iPass], NULL);

		if (m_vb.m_type == D3DVertexBuffer::INDEXED_BUFFER && m_primitivesCount > 0) 
			for (int i = 0; i < m_primitivesCount; i++) 
				pDevice->DrawIndexed(m_indexCount, 0, iPass*vertexIndexStep+i*((m_vbsize/m_vertsize)/m_primitivesCount));
		else
			pDevice->Draw(m_primitivesCount, iPass*vertexIndexStep);
	}

	if (oldRTV != 0) 
	{
		if (oldDSV != 0) 
		{
			pDevice->OMSetRenderTargets(1, &oldRTV, oldDSV);
			oldRTV->Release();
			oldRTV->Release();
		} else 
		{
			pDevice->OMSetRenderTargets(1, &oldRTV, NULL);
			oldRTV->Release();
		}
	}
	pDevice->RSSetViewports(1, &m_rendererSystem->GetViewPort());
	return true;
}
Example #3
0
static
rc_t KBZipFileReadInt (KBZipFile * self, void * buffer, size_t bsize, size_t * pnumread)
{
    bz_stream temp;     /* store some values here during a reinit after stream end */
    bz_stream * strm;   /* alias for the object's bzip stream object */
    size_t bleft = bsize;
    size_t num_read;
    size_t tot_read = 0;
    rc_t rc = 0;

    BZIP_DEBUG (("---------------\n%s: Enter requesting bsize %lu\n", __func__, bsize));

    strm = &self->strm;

    for (tot_read = 0; tot_read < bsize ; )
    {
        char * this_out;
        size_t src_read;
        int zret;
        bool bin;
        bool bout;
        bool end;

        bin = (strm->avail_in != 0);

        BZIP_DEBUG (("%s: loop start tot_read %zu\n", __func__, tot_read));

        strm->next_out = this_out = (char*)buffer + tot_read;
        strm->avail_out = bsize - tot_read;

        BZIP_DEBUG(("%s: call Decompress\n", __func__));

        BZIP_DBGSTREAM (strm, "before BZ2_bzDecompress");

        zret = BZ2_bzDecompress(strm);

        BZIP_DBGSTREAM (strm, "after BZ2_bzDecompress");

        switch (zret)
        {
            /* unexpected error returns from zlib */
        default:
            BZIP_DEBUG (("%s: undocumented error return in bzip Decompress\n", __func__));
            rc = RC (rcFS, rcFile, rcReading, rcFile, rcUnknown);
            PLOGERR (klogErr,
                     (klogErr, rc, "unknown error decompressing BZip2 file "
                      "error code '$(EC)'", "EC=%d", zret));
            return rc;

            /* known unfixable errors */
        case BZ_PARAM_ERROR:
            BZIP_DEBUG (("%s: internal programming error - bad parameters\n", __func__));
            rc = RC (rcFS, rcFile, rcReading, rcSelf, rcInvalid);
            if (strm == NULL)
                BZIP_DEBUG (("%s: strm is NULL\n", __func__));
            else
            {
                if (strm->state == NULL)
                    BZIP_DEBUG (("%s: strm->state is NULL\n", __func__));
                if (strm->avail_out < 1)
                    BZIP_DEBUG (("%s: strm->avail_out < 1\n", __func__));
            }
            LOGERR (klogInt, rc, "bzip strm structure bad");
            return rc;

        case BZ_DATA_ERROR:
            BZIP_DEBUG (("%s: data integrity error in bzip stream\n", __func__));
            rc = RC (rcFS, rcFile, rcReading, rcData, rcCorrupt);
            LOGERR (klogErr, rc, "bzip stream data error");
            return rc;

        case BZ_DATA_ERROR_MAGIC:
            BZIP_DEBUG (("%s: data magic bytes error in bzip stream\n", __func__));
            rc = RC (rcFS, rcFile, rcReading, rcData, rcIncorrect);
            LOGERR (klogErr, rc, "bzip stream not a bzip stream");
            return rc;

        case BZ_MEM_ERROR:
            BZIP_DEBUG (("%s: memory exhausted during BZip decompress\n", __func__));
            rc = RC (rcFS, rcFile, rcReading, rcMemory, rcExhausted);
            LOGERR (klogErr, rc, "not enough memory available during bzip decompress");
            return rc;

        case BZ_STREAM_END:
            BZIP_DEBUG (("%s: BZ_STREAM_END\n", __func__));
            end = true;
            num_read = strm->next_out - this_out;
            bout = (num_read != 0);
            BZIP_DEBUG (("%s: num_read %zu\n", __func__, num_read));
            self->completed = true;
            BZIP_DBGSTREAM (strm, "before BZ2_bzDecompressEnd");
            zret = BZ2_bzDecompressEnd(strm);
            BZIP_DBGSTREAM (strm, "after BZ2_bzDecompressEnd");
            if (zret == BZ_OK)
            {
                temp = *strm;
                memset (strm, 0, sizeof *strm);
                zret = BZ2_bzDecompressInit (strm, 1, 0);
                BZIP_DBGSTREAM (strm, "after BZ2_bzDecompressInit");
                strm->next_in = temp.next_in;
                strm->avail_in = temp.avail_in;
/*                 strm->next_out = temp.next_out; */
/*                 strm->avail_out = temp.avail_out; */
                strm->total_in_lo32 = temp.total_in_lo32;
                strm->total_in_hi32 = temp.total_in_hi32;
                strm->total_out_lo32 = temp.total_out_lo32;
                strm->total_out_hi32 = temp.total_out_hi32;
                BZIP_DBGSTREAM (strm, "after restore");
            }
            switch (zret)
            {
            case BZ_OK:
                break;
            default:
                return RC (rcFS, rcFile, rcReading, rcFile, rcUnknown);
            }
            goto read_more;

        case BZ_OK:
            BZIP_DEBUG (("%s: BZ_OK\n", __func__));
            end = false;
            num_read = strm->next_out - this_out;
            bout = (num_read != 0);
            BZIP_DEBUG (("%s: num_read %zu\n", __func__, num_read));

        read_more:
            /* if we wanted more on this read, read some more compressed */
            tot_read += num_read;
            if (strm->avail_in == 0)
            {
                rc = KFileRead (self->file, self->filePosition, self->buff, 
                                sizeof self->buff, &src_read);
                if (rc)
                    return rc;

                BZIP_DEBUG (("%s: KFileRead read %u\n", __func__, src_read));

                if (src_read == 0)
                {
                    BZIP_DEBUG (("%s: end %u in %u out %u\n", __func__, end, bin, bout));
                
                    if (!end && bin && !bout)
                        rc = RC (rcFS, rcFile, rcReading, rcData, rcInsufficient);
                    goto done;
                }
                strm->avail_in = src_read;
                self->filePosition += src_read;
                strm->next_in = self->buff;

                /* if src_read == 0 but we are not at BZ_STREAM_END
                 * we have an error
                 */
                if (src_read == 0)
                    bleft = 0;
            }
            break;
        }
        if (rc)
            break;
        BZIP_DEBUG (("%s: loop end tot_read %zu\n", __func__, tot_read));
    }
done:
    BZIP_DEBUG (("%s: returning tot_read %zu\n\n\n", __func__, tot_read));
    *pnumread = tot_read;
    return rc;
}
Example #4
0
bool InterceptLog::GetReturnValue(ParameterType pType, const FunctionRetValue & retVal, bool isPointer, ParamValue &value)
{
  //Test if we are getting a pointer
  if(isPointer)
  {
    //Get the pointer value
    retVal.Get(value.pointerValue);

    //Return true
    return true;
  }

  //Determine the type to return
  switch(pType)
  {
    case(PT_enum):
      retVal.Get(value.enumValue);
      break;
    case(PT_bitfield):
      retVal.Get(value.bitfieldValue);
      break;

    case(PT_void):
      break;

    case(PT_byte):
      retVal.Get(value.byteValue);
      break;
    case(PT_short):
      retVal.Get(value.shortValue);
      break;

    case(PT_int):
      retVal.Get(value.intValue);
      break;
    case(PT_sizei):
      retVal.Get(value.sizeiValue);
      break;

    case(PT_ubyte):
      retVal.Get(value.ubyteValue);
      break;
    case(PT_boolean):
      retVal.Get(value.booleanValue);
      break;

    case(PT_ushort):
      retVal.Get(value.ushortValue);
      break;

    case(PT_uint):
      retVal.Get(value.uintValue);
      break;
    case(PT_handle):
      retVal.Get(value.uintValue);
      break;

    case(PT_char):
      retVal.Get(value.charValue);
      break;

    case(PT_intptr):
      retVal.Get(value.intptrValue);
      break;

    case(PT_sizeiptr):
      retVal.Get(value.sizeiptrValue);
      break;

    case(PT_sync):
      retVal.Get(value.syncValue);
      break;

    // Float types and int64 types are not really allowed via the assembly wrappers currently - but there are some hard coded exceptions
    case(PT_float):
      retVal.Get(value.floatValue);
      break;

    case(PT_int64):
      retVal.Get(value.int64Value);
      break;

    case(PT_uint64):
      retVal.Get(value.uint64Value);
      break;

/* If these types are ever return types, will need to update the wrapper asm (esp. float types on x64)
    case(PT_double):
      retVal.Get(value.doubleValue);
      break;
*/
    default:
      LOGERR(("InterceptLog::GetReturnValue - Unhandled return value in function of type %d",(int)pType));
      return false;
  }
 

  return true;
}
Example #5
0
string InterceptLog::ConvertParam(const ParamValue &data, bool isPointer,const ParameterData *paramData)
{
  string retString;

  //If the data is a custom type, attempt to handle it
  if(paramData->IsCustomType() && 
     ConvertCustomParam(data,isPointer,paramData,retString))
  {
    return retString;
  }

  //If this is a pointer, out-put the address
  if(isPointer)
  {
    //Just get the pointer's address 
    StringPrintF(retString,"%p",data.pointerValue);
  }
  else
  {

    //Do a big switch statement
    ParameterType pType=paramData->GetGLType();
    switch(pType)
    {
      case(PT_enum):
        {
          //Get the enum data
          const EnumData * enumData=functionTable->GetEnumData(paramData->index);

          //If the index is invalid, Just print the hex values
          if(enumData ==NULL)
          {
            StringPrintF(retString,"0x%04x", data.enumValue);
          }
          else
          {
            retString = enumData->GetDisplayString(data.enumValue);
          }
        }
        break;

      case(PT_bitfield):
        {
          //Get the enum data
          const EnumData * enumData=functionTable->GetEnumData(paramData->index);

          //If the index is invalid, Just print the hex values
          if(enumData ==NULL)
          {
            StringPrintF(retString,"0x%04x", data.bitfieldValue);
          }
          else
          {
            retString = enumData->GetDisplayString(data.bitfieldValue);
          }
        }
        break;

      case(PT_boolean):
        {
          int num = data.booleanValue;

          //Check the value
          if(num == 0)
          {
            retString = "false";
          }
          else if(num == 1)
          {
            retString = "true";
          }
          else
          {
            StringPrintF(retString,"Invalid boolean %u",num);
          }
          break;
        }

      case(PT_void):
        break;

      case(PT_byte):
        {
          StringPrintF(retString,"%d",data.byteValue);
          break;
        }

      case(PT_short):
        {
          StringPrintF(retString,"%d",data.shortValue);
          break;
        }

      case(PT_int):
        {
          StringPrintF(retString,"%d",data.intValue);
          break;
        }

      case(PT_sizei):
        {
          CASSERT(sizeof(data.sizeiValue) == sizeof(int), __Update_type_printf__);
          StringPrintF(retString,"%d",data.sizeiValue);
          break;
        }

      case(PT_ubyte):
        {
          StringPrintF(retString,"%u",data.ubyteValue);
          break;
        }

      case(PT_char):
        {
          StringPrintF(retString,"%c",data.charValue);
          break;
        }

      case(PT_ushort):
        {
          StringPrintF(retString,"%u",data.ushortValue);
          break;
        }

      case(PT_uint):
      case(PT_handle):
        {
          StringPrintF(retString,"%u",data.uintValue);
          break;
        }

      case(PT_intptr):
        {
          ostringstream s1;
          s1 << data.intptrValue;
          retString = s1.str();
          break;
        }

      case(PT_sizeiptr):
        {
          ostringstream s1;
          s1 << data.sizeiptrValue;
          retString = s1.str();
          break;
        }

      case(PT_int64):
        {
          ostringstream s1;
          s1 << data.int64Value;
          retString = s1.str();
          break;
        }

      case(PT_uint64):
        {
          ostringstream s1;
          s1 << data.uint64Value;
          retString = s1.str();
          break;
        }

      case(PT_sync):
        {
          ostringstream s1;
          s1 << data.syncValue;
          retString = s1.str();
          break;
        }

      case(PT_float):
        {
          StringPrintF(retString,"%f",data.floatValue);
          break;
        }

      case(PT_double):
        {
          StringPrintF(retString,"%f",data.doubleValue);
          break;
        }

      default:
        LOGERR(("InterceptLog::ConvertParam - Unhandled parameter in function of type %d",(int)pType));
    }
  }

  return retString;
}
Example #6
0
void InterceptLog::GetFunctionString(const FunctionData *funcData,uint index, const FunctionArgs & args, string &retString)
{
  //Append the function name first
  retString = funcData->GetName() + "(";

  //Get a copy of the arguments
  FunctionArgs newArgs(args);

  //Loop for all the parameters
  for(uint i=0;i<funcData->parameterArray.size();i++)
  {
//	  LOGERR(("arg.size()=%d\n",funcData->parameterArray.size()));
    //Get the parameter
    const ParameterData * paramData = &funcData->parameterArray[i];
	LOGERR(("The paramDateName:%d, %s\n",paramData->type,paramData->paramName.c_str()));

    //Determine if we are processing pointers
    bool isPointer=false;
    if(paramData->pointerCount > 0 || paramData->length != -1)
    {
      isPointer=true;
    }
	//Get the value	
	ParamValue value;
	
	////¼Ó²âÊÔÖ¸Õë
	if(strcmp((funcData->GetName()).c_str(),"glLightfv")==0&&isPointer){
		 const GLfloat* V; newArgs.Get(V);
		value.pointerValue =(void*) V;
		LOGERR(("The length of this parametre is : lengh = %d\n ,Count = %d\n ", paramData->length,paramData->pointerCount));
		LOGERR(("glLightfv:%f,%f,%f,%f\n",V[0],V[1],V[2],V[3]));
		//LOGERR(("²ÎÊýÐòºÅ%d\n",i))

	}
	////²âÊÔÖ¸ÕëÍê±Ï
    else if(!GetNextValue(paramData->GetGLType(),newArgs,isPointer, value))
    {
      break;
    }


    //Test if this is an array value
    if(paramData->length != -1)
    {
      bool isArrayOfPointers = false;

      //Test for an array of pointers
      if(paramData->pointerCount > 0)
      {
        isArrayOfPointers = true;
      }

      //Assign the array
      void * array =  value.pointerValue;

      //Loop and print the array
      retString += "[";
      for(uint i2=0;i2<(uint)paramData->length;i2++)
      {
        //Get the value from the array
        if(!GetNextArrayValue(paramData->GetGLType(),&array,isArrayOfPointers, value))
        {
          break;
        }
       
        //Convert and print the value
        retString += ConvertParam(value,isArrayOfPointers,paramData);
        
        //Add a comma
        if(i2 != (uint)(paramData->length - 1))
        {
          retString += ",";
        }
      }
      retString += "]";
    }
    else
    {
      //Just get the single value
      retString += ConvertParam(value,isPointer,paramData);
    }

    //Add a comma if there are more parameters
    if(i != funcData->parameterArray.size() - 1)
    {
      retString += ",";
    }
  }

  //If there are no parameters (unknown function)
  if(funcData->parameterArray.size() == 0)
  {
    retString += " ??? ";
  }

  //Close the bracket
  retString += ")";
}
Example #7
0
bool InterceptLog::GetNextArrayValue(ParameterType pType, void **array, bool isPointer, ParamValue &value)
{
  //The value to increment the array by
  uint arrayInc;

  //Check for NULL arrays
  if(*array == NULL)
  {
    LOGERR(("InterceptLog::GetNextArrayValue - Passing NULL as array parameter?"));
    return false;
  }

  //Test if we are getting a pointer (is an array of pointers)
  if(isPointer)
  {
    arrayInc = sizeof(void *);
    value.pointerValue = *((void**)(*array)); 
  }
  else
  {

    //Determine the type to return
    switch(pType)
    {
      case(PT_enum):
        value.enumValue = *((GLenum*)(*array));
        arrayInc = sizeof(GLenum);
        break;

      case(PT_bitfield):
        value.bitfieldValue = *((GLbitfield*)(*array));
        arrayInc = sizeof(GLbitfield);
        break;

      case(PT_void):
        arrayInc = 0;
        break;

      case(PT_byte):
        value.byteValue = *((GLbyte*)(*array));
        arrayInc = sizeof(GLbyte);
        break;

      case(PT_short):
        value.shortValue = *((GLshort*)(*array));
        arrayInc = sizeof(GLshort);
        break;

      case(PT_int):
        value.intValue = *((GLint*)(*array));
        arrayInc = sizeof(GLint);
        break;

      case(PT_sizei):
        value.sizeiValue = *((GLsizei*)(*array));
        arrayInc = sizeof(GLsizei);
        break;

      case(PT_ubyte):
        value.ubyteValue = *((GLubyte*)(*array));
        arrayInc = sizeof(GLubyte);
        break;

      case(PT_char):
        value.charValue = *((GLchar*)(*array));
        arrayInc = sizeof(GLchar);
        break;

      case(PT_boolean):
        value.booleanValue = *((GLboolean*)(*array));
        arrayInc = sizeof(GLboolean);
        break;

      case(PT_ushort):
        value.ushortValue = *((GLushort*)(*array));
        arrayInc = sizeof(GLushort);
        break;

      case(PT_uint):
      case(PT_handle): 
        value.uintValue = *((GLuint*)(*array));
        arrayInc = sizeof(GLuint);
        break;

      case(PT_intptr):
        value.intptrValue = *((GLintptr*)(*array));
        arrayInc = sizeof(GLintptr);
        break;

      case(PT_sizeiptr):
        value.sizeiptrValue = *((GLsizeiptr*)(*array));
        arrayInc = sizeof(GLsizeiptr);
        break;

      case(PT_int64):
        value.int64Value = *((GLint64*)(*array));
        arrayInc = sizeof(GLint64);
        break;

      case(PT_uint64):
        value.uint64Value = *((GLuint64*)(*array));
        arrayInc = sizeof(GLuint64);
        break;

      case(PT_sync):
        value.syncValue = *((GLsync*)(*array));
        arrayInc = sizeof(GLsync);
        break;

      case(PT_float):
        value.floatValue = *((GLfloat*)(*array));
        arrayInc = sizeof(GLfloat);
        break;

      case(PT_double):
        value.doubleValue = *((GLdouble*)(*array));
        arrayInc = sizeof(GLdouble);
        break;

      default:
        LOGERR(("InterceptLog::GetNextArrayValue - Unhandled parameter in function of type %d",(int)pType));
        return false;
    }
  } 

  //Increment the array
  *array = ((char *)(*array) + arrayInc);

  return true;
}
Example #8
0
bool InterceptLog::GetNextValue(ParameterType pType, FunctionArgs &args, bool isPointer, ParamValue &value)
{
  //Test if we are getting a pointer
  if(isPointer)
  {
    //Get the pointer value
    args.Get(value.pointerValue);
	LOGERR(("This pointer date  %p\n",value.pointerValue));
	//LOGERR(("The 1st element of the pointer is %f\n",*(value.pointerValue)));

    //Return true
    return true;
  }

  //Determine the type to return
  switch(pType)
  {
    case(PT_enum):
      args.Get(value.enumValue);
      break;
    case(PT_bitfield):
      args.Get(value.bitfieldValue);
      break;

    case(PT_void):
      break;

    case(PT_byte):
      args.Get(value.byteValue);
      break;
    case(PT_short):
      args.Get(value.shortValue);
      break;

    case(PT_int):
      args.Get(value.intValue);
      break;
    case(PT_sizei):
      args.Get(value.sizeiValue);
      break;

    case(PT_ubyte):
      args.Get(value.ubyteValue);
      break;

    case(PT_char):
      args.Get(value.charValue);
      break;

    case(PT_boolean):
      args.Get(value.booleanValue);
      break;

    case(PT_ushort):
      args.Get(value.ushortValue);
      break;

    case(PT_uint):
      args.Get(value.uintValue);
      break;
    case(PT_handle):
      args.Get(value.uintValue);
      break;

    case(PT_float):
      args.Get(value.floatValue);
       //LOGERR(("this is a float data %f\n",value.floatValue));
      break;

    case(PT_double):
      args.Get(value.doubleValue);
	  //LOGERR(("this is a double data %f\n",value.doubleValue));
      break;

    case(PT_intptr):
      args.Get(value.intptrValue);
      break;

    case(PT_sizeiptr):
      args.Get(value.sizeiptrValue);
      break;

    case(PT_int64):
      args.Get(value.int64Value);
      break;

    case(PT_uint64):
      args.Get(value.uint64Value);
      break;

    case(PT_sync):
      args.Get(value.syncValue);
      break;

    default:
      LOGERR(("InterceptLog::GetNextValue - Unhandled parameter in function of type %d",(int)pType));
      return false;
  }
 

  return true;
}
Example #9
0
static
rc_t run ()
{
    const KFile * in;
    rc_t rc = 0;

    do {
        uint64_t in_pos = 0;
        size_t num_read;
        char buffer [8 * 1024];

        rc = KFileMakeStdIn (&in);
        if (rc) break;

        for ( ;; )
        {
            VPath * path;

            rc = KOutMsg ("Enter a system specific path: ");
            if (rc) break;

            memset (buffer, 0, sizeof buffer);

            rc = KFileRead (in, in_pos, buffer, sizeof buffer, &num_read);

            if (rc)
            {
                LOGERR (klogFatal, rc, "error with KFileRead");
                break;
            }

            if (num_read == 0) break;

            in_pos += num_read;
            
            if (buffer[num_read-1] == '\n')
                buffer[num_read-1] = '\0';
            if (buffer[num_read-2] == '\r')
                buffer[num_read-2] = '\0';

            rc = VPathMakeSysPath (&path, buffer);
            if (rc)
            {
                LOGERR (klogErr, rc, "error with MakeSysPath");
                break;
            }

            memset (buffer, 0, sizeof buffer);

            rc = VPathReadPath (path, buffer, sizeof buffer, &num_read);
            if (rc)
            {
                LOGERR (klogErr, rc, "error wth ReadPath");
                break;
            }

            rc = KOutMsg ("VPath path is '%s' size '%zu'\n\n", buffer, num_read);
            if (rc)
            {
                LOGERR (klogErr, rc, "error with KOuMsg");
                break;
            }
        }
    } while (0);
    return rc;
}
Example #10
0
static
rc_t nenctool (const char * srcstr, const char * dststr, bool force)
{
    VFSManager * mgr;
    rc_t rc;

    rc = VFSManagerMake (&mgr);
    if (rc)
        LOGERR (klogInt, rc, "failed to create file system manager");
    else
    {
        VPath * srcpath;

        rc = VFSManagerMakePath (mgr, &srcpath, "%s", srcstr);
        if (rc)
            PLOGERR (klogErr,
                     (klogErr, rc, "Failed to parse source path '$(path)'",
                      "path=%s", srcstr));
        else
        {
            VPath * dstpath;

            rc = VFSManagerMakePath (mgr, &dstpath, "%s", dststr);
            if (rc)
                PLOGERR (klogErr,
                         (klogErr, rc, "Failed to parse destination path '$(path)'",
                          "path=%s", dststr));
            else
            {
                const KFile * srcfile;

                rc = VFSManagerOpenFileRead (mgr, &srcfile, srcpath);
                if (rc)
                    PLOGERR (klogErr,
                             (klogErr, rc, "Failed to open source path '$(path)'",
                              "path=%s", srcstr));
                else
                {
                    KFile * dstfile;

                    rc = VFSManagerCreateFile (mgr, &dstfile, false, 0666,
                                               kcmParents | (force ? kcmInit : kcmCreate),
                                               dstpath);
                    if (rc)
                        PLOGERR (klogErr,
                                 (klogErr, rc, "failed to open destination path '$(path)'",
                                  "path=%s", dststr));
                    else
                    {
                        rc = copy_file (srcstr, dststr, srcfile, dstfile);
                        if (rc)
                        {
                            PLOGERR (klogErr,
                                     (klogErr, rc, "failed to copy '$(S)' to '$(D)'",
                                      "S=%s,D=%s", srcstr, dststr));

                            VFSManagerRemove (mgr, true, dstpath);
                        }

                        KFileRelease (dstfile);
                    }
                    KFileRelease (srcfile);
                }
                VPathRelease (dstpath);
            }
            VPathRelease (srcpath);
        }
        VFSManagerRelease (mgr);
    }
    return rc;
}