Code Monkey home page Code Monkey logo

minini's People

Contributors

compuphase avatar jhert0 avatar tbeu avatar yangfl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minini's Issues

Minor: Documentation for ini_getbool mentions nonexisting parameters

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

Improve support for "subsections"

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.

Glue for SPIFFS

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.

  1. Statically allocate the LocalBuffers to reduce call stack usage.
  2. Remove case-insensitive search as it is not C99 compatible.
  3. Add a wrapper function to SPIFFS file read API to behave like fgets.

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

minGlue.h missing include guard

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

Does not compile for embedded platform

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 ?

wrong assert in save_strncpy

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.

Handling multiple file system types

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?

hope can add "delete a line of comments ‘#’ "

[Hotkey]
# 切换激活/非激活输入法
TriggerKey=CTRL_SPACE
# 只在用额外切换键取消激活后才使用它进行切换
# 可选值:
# True False
#UseExtraTriggerKeyOnlyWhenUseItToInactivate=True
# 额外的激活输入法快捷键

some times i want remove "#" from "#UseExtraTriggerKeyOnlyWhenUseItToInactivate=True".

make "UseExtraTriggerKeyOnlyWhenUseItToInactivate=True" be usefull.

Writing to File

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.
ini_puts

Also, as per the document I have not defined the read-only in the header.

Suggest me where I am going wrong.

Consider preserving comments when re-writing values?

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?

Cannot cmpare a character correctly

image
As shown in the above figure, when I run the demo, I locate that it can't work normally here. I use visual studio2015. I don't know why this happens. Thank you!

Code style in cache_flush() function

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.

Leaking file descriptors

static inline int ini_openwrite(const char *filename, INI_FILETYPE *file) {
if ((*file = fopen((filename), "r+")) == NULL
&& (*file = fopen((filename), "w")) == NULL)

the file descriptor returned by the first fopen ends up being leaked

Iterator API

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.