1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-30 04:24:29 +00:00
stmbl/shared/config.c

36 lines
1.1 KiB
C
Raw Permalink Normal View History

2017-07-12 20:11:18 +00:00
#include "config.h"
#include "defines.h"
#include "string.h"
#include "commands.h"
extern config_template_t config_templates[];
extern const uint32_t num_of_config_templates;
2017-09-06 02:20:06 +00:00
void link(char *ptr) {
for(int i = 0; i < num_of_config_templates; i++) {
if(strlen(ptr) == strlen(config_templates[i].name) && !strncmp(config_templates[i].name, ptr, strlen(ptr))) {
hal_parse(config_templates[i].config);
return;
}
}
2017-07-12 20:11:18 +00:00
}
COMMAND("link", link, "load config template");
2017-09-06 02:20:06 +00:00
void show_config_template(char *ptr) {
for(int i = 0; i < num_of_config_templates; i++) {
if(strlen(ptr) == strlen(config_templates[i].name) && !strncmp(config_templates[i].name, ptr, strlen(ptr))) {
printf("\nHAL config template: %s\n", config_templates[i].name);
printf("%s\n", config_templates[i].config);
return;
}
}
printf("HAL config template %s not found\n", ptr);
printf("available templates:\n");
for(int i = 0; i < num_of_config_templates; i++) {
printf(" - %s\n", config_templates[i].name);
}
2017-07-12 20:11:18 +00:00
}
COMMAND("show_config", show_config_template, "show config templates");