Move verification config to nyx config

This commit is contained in:
CTCaer
2020-04-30 02:00:33 +03:00
parent 63be93be64
commit 08c81fe1f8
6 changed files with 101 additions and 62 deletions

View File

@@ -30,6 +30,7 @@
#include "../utils/util.h"
extern hekate_config h_cfg;
extern nyx_config n_cfg;
void set_default_configuration()
{
@@ -53,6 +54,11 @@ void set_default_configuration()
sd_power_cycle_time_start = 0;
}
void set_nyx_default_configuration()
{
n_cfg.verification = 1;
}
int create_config_entry()
{
if (!sd_mount())
@@ -96,9 +102,6 @@ int create_config_entry()
f_puts("\nbootwait=", &fp);
itoa(h_cfg.bootwait, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nverification=", &fp);
itoa(h_cfg.verification, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\nbacklight=", &fp);
itoa(h_cfg.backlight, lbuf, 10);
f_puts(lbuf, &fp);
@@ -169,3 +172,28 @@ int create_config_entry()
return 0;
}
int create_nyx_config_entry()
{
if (!sd_mount())
return 1;
char lbuf[32];
FIL fp;
// Make sure that bootloader folder exists.
f_mkdir("bootloader");
if (f_open(&fp, "bootloader/nyx.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
return 1;
// Add config entry.
f_puts("[config]\nverification=", &fp);
itoa(n_cfg.verification, lbuf, 10);
f_puts(lbuf, &fp);
f_puts("\n", &fp);
f_close(&fp);
sd_unmount(false);
return 0;
}

View File

@@ -25,7 +25,6 @@ typedef struct _hekate_config
u32 autoboot;
u32 autoboot_list;
u32 bootwait;
u32 verification;
u32 backlight;
u32 autohosoff;
u32 autonogc;
@@ -41,7 +40,14 @@ typedef struct _hekate_config
u32 errors;
} hekate_config;
typedef struct _nyx_config
{
u32 verification;
} nyx_config;
void set_default_configuration();
void set_nyx_default_configuration();
int create_config_entry();
int create_nyx_config_entry();
#endif /* _CONFIG_H_ */

View File

@@ -55,12 +55,9 @@ u32 _find_section_name(char *lbuf, u32 lblen, char schar)
ini_sec_t *_ini_create_section(link_t *dst, ini_sec_t *csec, char *name, u8 type)
{
if (csec)
{
list_append(dst, &csec->link);
csec = NULL;
}
csec = (ini_sec_t *)malloc(sizeof(ini_sec_t));
csec = (ini_sec_t *)calloc(sizeof(ini_sec_t), 1);
csec->name = _strdup(name);
csec->type = type;
@@ -154,7 +151,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
{
u32 i = _find_section_name(lbuf, lblen, '=');
ini_kv_t *kv = (ini_kv_t *)malloc(sizeof(ini_kv_t));
ini_kv_t *kv = (ini_kv_t *)calloc(sizeof(ini_kv_t), 1);
kv->key = _strdup(&lbuf[0]);
kv->val = _strdup(&lbuf[i + 1]);
list_append(&csec->kvs, &kv->link);