mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Move ini functions to ini.h/c
This commit is contained in:
parent
bdacce048d
commit
f301c9f4c9
@ -4,6 +4,8 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "ini.h"
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -126,6 +128,18 @@ ini_atoi(string)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ini_is_true(const char *value)
|
||||
{
|
||||
int i = ini_atoi(value);
|
||||
if (i) return true;
|
||||
if (strlen(value) != 4) return false;
|
||||
if ((value[0] != 'T') && (value[0] != 't')) return false;
|
||||
if ((value[1] != 'R') && (value[1] != 'r')) return false;
|
||||
if ((value[2] != 'U') && (value[2] != 'u')) return false;
|
||||
if ((value[3] != 'E') && (value[3] != 'e')) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
|
||||
@ -16,6 +16,7 @@ https://github.com/benhoyt/inih
|
||||
#define __INI_H__
|
||||
|
||||
int ini_atoi(const char *string);
|
||||
bool ini_is_true(const char *value);
|
||||
|
||||
/* Make this header file easier to include in C++ code */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -280,20 +280,6 @@ typedef struct openmv_config {
|
||||
wifi_dbg_config_t wifi_dbg_config;
|
||||
} openmv_config_t;
|
||||
|
||||
extern char *strncpy(char *dst, const char *src, size_t n);
|
||||
|
||||
static bool ini_handler_callback_is_true(const char *value)
|
||||
{
|
||||
int i = ini_atoi(value);
|
||||
if (i) return true;
|
||||
if (strlen(value) != 4) return false;
|
||||
if ((value[0] != 'T') && (value[0] != 't')) return false;
|
||||
if ((value[1] != 'R') && (value[1] != 'r')) return false;
|
||||
if ((value[2] != 'U') && (value[2] != 'u')) return false;
|
||||
if ((value[3] != 'E') && (value[3] != 'e')) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int ini_handler_callback(void *user, const char *section, const char *name, const char *value)
|
||||
{
|
||||
openmv_config_t *openmv_config = (openmv_config_t *) user;
|
||||
@ -301,7 +287,7 @@ int ini_handler_callback(void *user, const char *section, const char *name, cons
|
||||
#define MATCH(s, n) ((strcmp(section, (s)) == 0) && (strcmp(name, (n)) == 0))
|
||||
|
||||
if (MATCH("BootSettings", "REPLUart")) {
|
||||
if (ini_handler_callback_is_true(value)) {
|
||||
if (ini_is_true(value)) {
|
||||
mp_obj_t args[2] = {
|
||||
MP_OBJ_NEW_SMALL_INT(3), // UART Port
|
||||
MP_OBJ_NEW_SMALL_INT(115200) // Baud Rate
|
||||
|
||||
Loading…
Reference in New Issue
Block a user