Prusa MINI Firmware overview
|
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "ini.h"
|
static char * | rstrip (char *s) |
|
static char * | lskip (const char *s) |
|
static char * | find_chars_or_comment (const char *s, const char *chars) |
|
static char * | strncpy0 (char *dest, const char *src, size_t size) |
|
int | ini_parse_stream (ini_reader reader, void *stream, ini_handler handler, void *user) |
|
int | ini_parse_file (FILE *file, ini_handler handler, void *user) |
|
int | ini_parse (const char *filename, ini_handler handler, void *user) |
|
static char * | ini_reader_string (char *str, int num, void *stream) |
|
int | ini_parse_string (const char *string, ini_handler handler, void *user) |
|
◆ MAX_SECTION
◆ MAX_NAME
◆ HANDLER
#define HANDLER |
( |
|
u, |
|
|
|
s, |
|
|
|
n, |
|
|
|
v |
|
) |
| handler(u, s, n, v) |
◆ rstrip()
static char* rstrip |
( |
char * |
s | ) |
|
|
static |
40 char* p = s + strlen(s);
41 while (p > s && isspace((
unsigned char)(*--p)))
◆ lskip()
static char* lskip |
( |
const char * |
s | ) |
|
|
static |
49 while (*s && isspace((
unsigned char)(*s)))
◆ find_chars_or_comment()
static char* find_chars_or_comment |
( |
const char * |
s, |
|
|
const char * |
chars |
|
) |
| |
|
static |
59 #if INI_ALLOW_INLINE_COMMENTS
61 while (*s && (!chars || !strchr(chars, *s)) &&
63 was_space = isspace((
unsigned char)(*s));
67 while (*s && (!chars || !strchr(chars, *s))) {
◆ strncpy0()
static char* strncpy0 |
( |
char * |
dest, |
|
|
const char * |
src, |
|
|
size_t |
size |
|
) |
| |
|
static |
77 strncpy(dest, src,
size - 1);
78 dest[
size - 1] =
'\0';
◆ ini_parse_stream()
94 #if INI_ALLOW_REALLOC && !INI_USE_STACK
115 #if INI_HANDLER_LINENO
116 #define HANDLER(u, s, n, v) handler(u, s, n, v, lineno)
118 #define HANDLER(u, s, n, v) handler(u, s, n, v)
122 while (reader(line, (
int)max_line, stream) !=
NULL) {
123 #if INI_ALLOW_REALLOC && !INI_USE_STACK
124 offset = strlen(line);
125 while (offset == max_line - 1 && line[offset - 1] !=
'\n') {
129 new_line = realloc(line, max_line);
135 if (reader(line + offset, (
int)(max_line - offset), stream) ==
NULL)
139 offset += strlen(line + offset);
147 if (lineno == 1 && (
unsigned char)
start[0] == 0xEF &&
148 (
unsigned char)
start[1] == 0xBB &&
149 (
unsigned char)
start[2] == 0xBF) {
158 #if INI_ALLOW_MULTILINE
159 else if (*prev_name && *
start &&
start > line) {
166 else if (*
start ==
'[') {
173 #if INI_CALL_HANDLER_ON_NEW_SECTION
186 if (*
end ==
'=' || *
end ==
':') {
190 #if INI_ALLOW_INLINE_COMMENTS
195 value =
lskip(value);
205 #if INI_ALLOW_NO_VALUE
216 #if INI_STOP_ON_FIRST_ERROR
◆ ini_parse_file()
◆ ini_parse()
241 file = fopen(filename,
"r");
◆ ini_reader_string()
static char* ini_reader_string |
( |
char * |
str, |
|
|
int |
num, |
|
|
void * |
stream |
|
) |
| |
|
static |
253 const char* ctx_ptr = ctx->
ptr;
254 size_t ctx_num_left = ctx->
num_left;
258 if (ctx_num_left == 0 ||
num < 2)
261 while (
num > 1 && ctx_num_left != 0) {
◆ ini_parse_string()
#define HANDLER(u, s, n, v)
char *(* ini_reader)(char *str, int num, void *stream)
Definition: ini.h:40
#define INI_INITIAL_ALLOC
Definition: ini.h:122
bool error
Definition: auto_build.py:637
size_t num_left
Definition: ini.c:34
start
Definition: g29_auto.py:150
#define INI_MAX_LINE
Definition: ini.h:109
static char * lskip(const char *s)
Definition: ini.c:47
#define NULL
Definition: usbd_def.h:53
end
Definition: createSpeedLookupTable.py:33
u8_t num
Definition: netif.h:309
int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler, void *user)
Definition: ini.c:83
int ini_parse_file(FILE *file, ini_handler handler, void *user)
Definition: ini.c:230
char name[2]
Definition: netif.h:307
static char * find_chars_or_comment(const char *s, const char *chars)
Definition: ini.c:57
#define INI_START_COMMENT_PREFIXES
Definition: ini.h:88
static char * ini_reader_string(char *str, int num, void *stream)
Definition: ini.c:251
#define INI_INLINE_COMMENT_PREFIXES
Definition: ini.h:98
const char * ptr
Definition: ini.c:33
static char * strncpy0(char *dest, const char *src, size_t size)
Definition: ini.c:75
static char * rstrip(char *s)
Definition: ini.c:38
#define MAX_NAME
Definition: ini.c:29
#define MAX_SECTION
Definition: ini.c:28
static png_bytep size_t size
Definition: pngwrite.c:2170