You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
/*
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2025-12-01 Administrator the first version
|
|
*/
|
|
#ifndef APPLICATIONS_INI_INI_H_
|
|
#define APPLICATIONS_INI_INI_H_
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
#define MAX_LINE_LENGTH 256
|
|
#define MAX_KEY_LENGTH 64
|
|
#define MAX_VALUE_LENGTH 128
|
|
#define MAX_SECTION_LENGTH 64
|
|
|
|
typedef struct {
|
|
char key[MAX_KEY_LENGTH];
|
|
char value[MAX_VALUE_LENGTH];
|
|
} INI_Entry;
|
|
|
|
typedef struct {
|
|
char section[MAX_SECTION_LENGTH];
|
|
INI_Entry *entries;
|
|
int entry_count;
|
|
int entry_capacity;
|
|
} INI_Section;
|
|
|
|
typedef struct {
|
|
INI_Section *sections;
|
|
int section_count;
|
|
int section_capacity;
|
|
} INI_File;
|
|
|
|
extern INI_File* ini_init();
|
|
extern void ini_free(INI_File *ini);
|
|
extern int ini_parse(INI_File *ini, const char *filename);
|
|
extern int ini_set_value(INI_File *ini, const char *section, const char *key, const char *value);
|
|
extern int ini_save(INI_File *ini, const char *filename);
|
|
extern int ini_delete_key(INI_File *ini, const char *section, const char *key);
|
|
extern char* ini_get_value(INI_File *ini, const char *section, const char *key);
|
|
extern int ini_get_int(INI_File *ini, const char *section, const char *key, int default_value);
|
|
extern double ini_get_double(INI_File *ini, const char *section, const char *key, double default_value);
|
|
extern int ini_get_bool(INI_File *ini, const char *section, const char *key, int default_value);
|
|
|
|
#endif /* APPLICATIONS_INI_INI_H_ */
|
|
|