/**
* @file bad_magic.cpp
* @brief Broken fixture: API table with a wrong magic constant
*
* Contract-complete, but its declared table opens with garbage instead
* of the spec magic. libdpm-core must refuse it at validation step 5.
*
* Part of the Dark Horse Linux Package Manager (DPM)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
#include
namespace {
struct table_header {
uint32_t magic;
uint32_t size;
};
struct manifest_entry {
const char* api_name;
int table_version;
const char* symbol;
};
struct manifest {
uint32_t count;
const manifest_entry* entries;
};
} // namespace
struct badmagic_api_v1_s {
table_header hdr;
int (*ping)(void);
};
static int ping(void)
{
return 0;
}
extern "C" {
extern const struct badmagic_api_v1_s badmagic_api_v1;
const struct badmagic_api_v1_s badmagic_api_v1 = {
{ 0xDEADBEEFu, sizeof(struct badmagic_api_v1_s) },
ping,
};
}
extern "C" const char* dpm_module_version(void)
{
return "1.0.0";
}
extern "C" const char* dpm_module_description(void)
{
return "Fixture with a bad table magic.";
}
extern "C" const char* dpm_module_core_min(void)
{
return "0.1.0";
}
extern "C" const void* dpm_module_manifest(void)
{
static const manifest_entry entries[] = {
{ "badmagic", 1, "badmagic_api_v1" },
};
static const manifest m = { 1, entries };
return &m;
}
extern "C" int dpm_module_execute(void* ctx, const char* command,
int argc, char** argv)
{
(void)ctx;
(void)command;
(void)argc;
(void)argv;
return 0;
}