compuphase / minini Goto Github PK
View Code? Open in Web Editor NEWA small and portable INI file library with read/write support
Home Page: http://www.compuphase.com/minini.htm
License: Other
A small and portable INI file library with read/write support
Home Page: http://www.compuphase.com/minini.htm
License: Other
I have adapted this project for use with SPIFFS.
https://github.com/pellepl/spiffs
In order to do so, I needed to make a few changes.
I am willing to share my changes, but I am unsure if these changes are of interest. I believe the first change will break the reentrancy. Some locking mechanism is necessary to guarantee reentrancy after moving the buffers off of the call stack. Furthermore, removing support for case-insensitive search seems like a step in the wrong direction.
Please advise and thank you for your work.
-Tim
Xcodes analyser notes that the doxygen code for ini_getbool mentions the parameters Buffer and BufferSize, which are not present in the function definition, which appears to be true:
/** ini_getbool()
[...]
* \param Buffer a pointer to the buffer to copy into
* \param BufferSize the maximum number of characters to copy
[...]
int ini_getbool(const TCHAR *Section, const TCHAR *Key, int DefValue, const TCHAR *Filename)
I'm not really sure how to note that but I created a pull request here: #4
There are a lot of situations where we need to store data with a tiny file system (like SPIFFS) into an internal flash memory mounted directly in a board. There are another situations where with need to read/store ini configuration from an external SD Card.
In that case we need to be able to manage a multiple file system types in the same project.
Could be nice to add the possibility to manage multiple file system types in the same project.
What do you think about?
As discussed in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900579#54 , not providing source for PDF doc makes it impossible for anyone to edit it, thus blocks anyone who want to improve it or add doc for new API. Please consider providing its source.
We are using minIni in one of our TensorFlow extensions. Instead of copying minIni code directly into our code repo, it would be much better to have a release archive we can use as an http_archive, like the ones here:
https://github.com/tensorflow/io/blob/master/WORKSPACE#L184
Lines 23 to 25 in 51d636f
If an INI file contains a "subsection", then in the INI_CALLBACK
handler the section name is kind of unexpected. For example in the simple example
[section]
[[subsection]]
key = value
it is [subsection
, thus it seems minIni looks for the first right bracket.
[Hotkey]
# 切换激活/非激活输入法
TriggerKey=CTRL_SPACE
# 只在用额外切换键取消激活后才使用它进行切换
# 可选值:
# True False
#UseExtraTriggerKeyOnlyWhenUseItToInactivate=True
# 额外的激活输入法快捷键
some times i want remove "#" from "#UseExtraTriggerKeyOnlyWhenUseItToInactivate=True".
make "UseExtraTriggerKeyOnlyWhenUseItToInactivate=True" be usefull.
I am using minIni for embedded system (ESP32).
The compiler failed at _tcsnicmp --> strnicmp.
I see that this is defined when __linux is defined (_tcsnicmp --> strncasecmp).
My compiler is gcc which is similar to linux.
Could you add switch for gcc ?
Greetings.
Thanks for well formatted code.
I converted the code according to my FatFs as mentioned. Everything working perfect.
Only issue is, I am unable to put value and string with the functions ini_putl
& ini_puts
in config file.
After using the ini_puts
, the other files inside the sd card are renamed with different format.
Attached image for your reference.
Also, as per the document I have not defined the read-only in the header.
Suggest me where I am going wrong.
Just a suggestion for this nice library: user data should not be forced as const
.
Removing const
on UserData
in these lines is enough for this:
https://github.com/compuphase/minIni/blob/master/dev/minIni.h#L59 and line 60
https://github.com/compuphase/minIni/blob/master/dev/minIni.c#L461
Hello guys,
I've imported your repo as a submodule in my project and I've rewritten the minGlue.h.
Can you please add include guard around the minGlue.h?
Thanks
This code at beginning of save_strncpy has an error:
assert(dest <= source || dest >= source + maxlen);
Because maxlen is a target attribute I expect somewhat like in second part:
dest > source + strlen(source)
For example, ini_gets fails if Buffer placed in memory immediatelly after very short DefValue.
Also, I expect that dest should be filled by '\', when both option == QUOTE_ENQUOTE and dest == source.
I wonder if your INI file library could help to implement this feature.
More details - WinMerge/winmerge#1975
Currently the only pull parsing APIs are ini_get* which are suboptimal as they open, re-parse, and close the file on each invocation. ini_browse is efficient but offers only push-style API which requires caller to define a function and often an artificial context struct. Adding iterator-based API would give both -- efficiency and pull parsing which results in more natural caller code.
Proposed outline of the API:
struct ini_iter;
int ini_iteropen(struct ini_iter* it, const char* filename);
int ini_iternext(struct ini_iter* it);
int ini_iterclose(struct ini_iter* it);
Example of use:
struct ini_iter it;
for (ini_iteropen(&it, "test.ini"); ini_iternext(&it); ) {
printf("[%s] %s = %s\n", it.section, it.key, it.value);
}
ini_iterclose(&it);
I already looked at minini code and know how it could be implemented. I can take the effort but wanted to know first if such a design is welcome at all.
Leave a blank line between the two section segments?
I've been searching quite a bit for an easy to use C config file library that supports preserving comments.
If I have the following in my INI file.
[section:foo]
alpha=True ; comment preserved
beta=True ; until the value changes
And then use minIni to change the value of beta:
ini_puts("section:foo", "beta", "False", inifile2);
The comment on beta will be lost...
[section:foo]
alpha=True ; comment preserved
beta=False
Not every config value change will invalidate the meaning of the associated comment, and since minIni doesn't write comments, only the user should be writing comments... Would be very frustrating for the end user to loose some comments they thought were important when we rewrite config changes.
As a workaround, one idea that comes to mind is putting a prefix or a suffix or both on the subset of key values that your program will be re-writing, so that these values jump out to the user as odd in the config file and are less surprised when comments there disappear. The downside of this approach would be as your software evolves and a value goes from user only to program re-written with the same name, so not an ideal workaround.
Something like:
[section:foo]
normal_key = value ; description of normal key
$app_configured = other value ; maybe less surprising if this comment gets erased?
First of all thanks for the library.
One minor correction:
function
static int cache_flush(TCHAR *buffer, int *size, INI_FILETYPE *rfp, INI_FILETYPE *wfp, INI_FILEPOS *mark);
uses constant INI_BUFFERSIZE as a size of its argument buffer. This is the case while library is unmodified but it would be safer to pass size of a buffer as an argument.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.