/* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* implement a file store for embedded firmware images */ #include "AP_ROMFS.h" #include "tinf.h" #ifdef HAL_HAVE_AP_ROMFS_EMBEDDED_H #include #else const AP_ROMFS::embedded_file AP_ROMFS::files[] = {}; #endif /* find an embedded file */ const uint8_t *AP_ROMFS::find_file(const char *name, uint32_t &size) { for (uint16_t i=0; isource = compressed_data; d->source_limit = compressed_data + compressed_size - 4; // assume gzip format int res = uzlib_gzip_parse_header(d); if (res != TINF_OK) { free(decompressed_data); free(d); return nullptr; } d->dest = decompressed_data; d->destSize = decompressed_size; // we don't check CRC, as it just wastes flash space for constant // ROMFS data res = uzlib_uncompress(d); free(d); if (res != TINF_OK) { free(decompressed_data); return nullptr; } size = decompressed_size; return decompressed_data; }