2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2010 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/types.h>
2N/A#include <grub/misc.h>
2N/A#include <grub/decompressor.h>
2N/A
2N/A#include "xz.h"
2N/A#include "xz_stream.h"
2N/A
2N/Avoid
2N/Agrub_decompress_core (void *src, void *dst, unsigned long srcsize,
2N/A unsigned long dstsize)
2N/A{
2N/A struct xz_dec *dec;
2N/A struct xz_buf buf;
2N/A
2N/A find_scratch (src, dst, srcsize, dstsize);
2N/A
2N/A dec = xz_dec_init (GRUB_DECOMPRESSOR_DICT_SIZE);
2N/A
2N/A buf.in = src;
2N/A buf.in_pos = 0;
2N/A buf.in_size = srcsize;
2N/A buf.out = dst;
2N/A buf.out_pos = 0;
2N/A buf.out_size = dstsize;
2N/A
2N/A while (buf.in_pos != buf.in_size)
2N/A {
2N/A enum xz_ret xzret;
2N/A xzret = xz_dec_run (dec, &buf);
2N/A switch (xzret)
2N/A {
2N/A case XZ_MEMLIMIT_ERROR:
2N/A case XZ_FORMAT_ERROR:
2N/A case XZ_OPTIONS_ERROR:
2N/A case XZ_DATA_ERROR:
2N/A case XZ_BUF_ERROR:
2N/A return;
2N/A default:
2N/A break;
2N/A }
2N/A }
2N/A}