コード例 #1
0
void test_untar_chunks_from_memory(void)
{
  rtems_status_code sc;
  rtems_printer     printer;
  int rv;
  Untar_ChunkContext ctx;
  unsigned long counter = 0;
  char *buffer = (char *)TARFILE_START;
  size_t buflen = TARFILE_SIZE;

  puts( "" );

  rtems_print_printer_printf(&printer);

  /* make a directory to untar it into */
  rv = mkdir( "/dest2", 0777 );
  rtems_test_assert( rv == 0 );

  rv = chdir( "/dest2" );
  rtems_test_assert( rv == 0 );

  printf( "Untaring chunks from memory - " );
  Untar_ChunkContext_Init(&ctx);
  do {
    sc = Untar_FromChunk_Print(&ctx, &buffer[counter], (size_t)1 , &printer);
    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    counter ++;
  } while (counter < buflen);
  printf("successful\n");

  /******************/
  printf( "========= /dest2/home/test_file =========\n" );
  test_cat( "/dest2/home/test_file", 0, 0 );

  /******************/
  printf( "========= /dest2/home/test_script =========\n" );
  test_cat( "/dest2/home/test_script", 0, 0 );
  test_untar_check_mode("/dest2/home/test_script", 0755);

  /******************/
  printf( "========= /dest2/symlink =========\n" );
  test_cat( "/dest2/symlink", 0, 0 );

}
コード例 #2
0
ファイル: untar_tgz.c プロジェクト: AoLaD/rtems
int Untar_GzChunkContext_Init(
  Untar_GzChunkContext *ctx,
  void *inflateBuffer,
  size_t inflateBufferSize
)
{
  int ret;
  int status = UNTAR_SUCCESSFUL;

  Untar_ChunkContext_Init(&ctx->base);
  ctx->inflateBuffer = inflateBuffer;
  ctx->inflateBufferSize = inflateBufferSize;
  memset(&ctx->strm, 0, sizeof(ctx->strm));
  ret = inflateInit2(&ctx->strm, 32 + MAX_WBITS);
  if (ret != Z_OK){
    status = UNTAR_FAIL;
  }
  return status;
}