示例#1
0
/*------------------------------------------------------------------*
 * MODIFICATIONS													*
 *	Date		Description							Author			*
 * ===========	==================================	===============	*
 *																	*
 *------------------------------------------------------------------*/
ZRESULT ZFilePacket::Build()
{
	BEG_FUNC("Build")(NULL);

	ZSP_FILE_PACKET	*vFile;

	if (mImageId == "" ||
		mImageDate == "" ||
		mImageName == "")
	{
		ZERROR("Necessary values have not been set (id/date/name)\n");
		return END_FUNC(ZERR_INVALID_STATUS);
	}

	/*
	 * Build the outgoing FLAG packet
	 */
	mPacketLen  = FILE_SIZE + mImageName.length();
	vFile = reinterpret_cast<ZSP_FILE_PACKET *>(BuildHeader());	
	memcpy(vFile->image_id, mImageId.c_str(), ZMIN(sizeof(vFile->image_id),
			mImageId.length()));
	vFile->image_format = htonl(mImageFormat);
	vFile->image_size	= htonl(mImageSize);	
	memcpy(vFile->image_date, mImageDate.c_str(), ZMIN(sizeof(vFile->image_date),
			mImageDate.length()));
	memcpy(&mRaw[FILE_SIZE], mImageName.c_str(), mImageName.length());\

	return END_FUNC(ZERR_SUCCESS);

}
示例#2
0
local int ziplocal_getByte(const zlib_filefunc_def* pzlib_filefunc_def,voidpf filestream,int *pi)

{
  unsigned char c;
  int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
  if (err==1)
    {
      *pi = (int)c;
      return ZIP_OK;
    }
  else
    {
      if (ZERROR(*pzlib_filefunc_def,filestream))
        return ZIP_ERRNO;
      else
        return ZIP_EOF;
    }
}
示例#3
0
文件: unzip.c 项目: Doodle-Jump/PC
static int unzlocal_getByte(const zlib_filefunc_def *pzlib_filefunc_def, void *filestream, int *pi)
{
  BYTE c;
  int err = (int)ZREAD(*pzlib_filefunc_def, filestream, &c, 1);

  if (err == 1)
  {
    *pi = (int)c;
    return UNZ_OK;
  }
  else
  {
    if (ZERROR(*pzlib_filefunc_def, filestream))
    {
      return UNZ_ERRNO;
    }
    else
    {
      return UNZ_EOF;
    }
  }
}
示例#4
0
/*------------------------------------------------------------------*
 * MODIFICATIONS													*
 *	Date		Description							Author			*
 * ===========	==================================	===============	*
 *																	*
 *------------------------------------------------------------------*/
ZRESULT ZDonePacket::Build()
{
	BEG_FUNC("Build")(NULL);

	ZSP_DONE_PACKET	*vDone;

	if (mImageId == "")
	{
		ZERROR("Necessary values have not been set (image id)\n");
		return END_FUNC(ZERR_INVALID_STATUS);
	}

	/*
	 * Build the outgoing DONE packet
	 */
	mPacketLen  = DONE_SIZE;
	vDone = reinterpret_cast<ZSP_DONE_PACKET *>(BuildHeader());	
	memcpy(vDone->image_id, mImageId.c_str(), ZMIN(mImageId.length(),
			sizeof(vDone->image_id)));

	return END_FUNC(ZERR_SUCCESS);
}