mirror of
https://github.com/pygos/pkg-utils.git
synced 2024-11-24 13:40:41 +01:00
David Oberhollenzer
1205ca0f3b
- Remove compressor registration interface. Doesn't work in a static library, since all the files containing no exported members are optimized away at link time. - Repack as seperate utility library. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
39 lines
751 B
C
39 lines
751 B
C
/* SPDX-License-Identifier: ISC */
|
|
#include <string.h>
|
|
|
|
#include "internal.h"
|
|
|
|
static compressor_t *compressors[] = {
|
|
[PKG_COMPRESSION_NONE] = &comp_none,
|
|
#ifdef WITH_ZLIB
|
|
[PKG_COMPRESSION_ZLIB] = &comp_zlib,
|
|
#endif
|
|
#ifdef WITH_LZMA
|
|
[PKG_COMPRESSION_LZMA] = &comp_lzma,
|
|
#endif
|
|
};
|
|
|
|
compressor_t *compressor_by_name(const char *name)
|
|
{
|
|
size_t i;
|
|
|
|
for (i = 0; i < sizeof(compressors) / sizeof(compressors[0]); ++i) {
|
|
if (compressors[i] == NULL)
|
|
continue;
|
|
if (strcmp(compressors[i]->name, name) == 0)
|
|
return compressors[i];
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
compressor_t *compressor_by_id(PKG_COMPRESSION id)
|
|
{
|
|
if ((int)id < 0)
|
|
return NULL;
|
|
|
|
if ((size_t)id >= sizeof(compressors) / sizeof(compressors[0]))
|
|
return NULL;
|
|
|
|
return compressors[id];
|
|
}
|