{"id":13492582,"url":"https://github.com/ndevilla/iniparser","last_synced_at":"2025-10-22T02:50:21.582Z","repository":{"id":1023355,"uuid":"851288","full_name":"ndevilla/iniparser","owner":"ndevilla","description":"ini file parser","archived":false,"fork":false,"pushed_at":"2025-01-07T18:08:59.000Z","size":379,"stargazers_count":1003,"open_issues_count":6,"forks_count":433,"subscribers_count":72,"default_branch":"main","last_synced_at":"2025-01-26T09:25:28.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gitlab.com/iniparser/iniparser","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ndevilla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-08-20T14:25:29.000Z","updated_at":"2025-01-17T01:44:55.000Z","dependencies_parsed_at":"2024-01-31T09:02:51.390Z","dependency_job_id":"7fc9883b-7bb2-446c-b58b-cb847ef32de6","html_url":"https://github.com/ndevilla/iniparser","commit_stats":{"total_commits":85,"total_committers":29,"mean_commits":"2.9310344827586206","dds":0.7176470588235294,"last_synced_commit":"deb85ad4936d4ca32cc2260ce43323d47936410d"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndevilla%2Finiparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndevilla%2Finiparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndevilla%2Finiparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndevilla%2Finiparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndevilla","download_url":"https://codeload.github.com/ndevilla/iniparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246012676,"owners_count":20709491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:07.272Z","updated_at":"2025-10-22T02:50:16.537Z","avatar_url":"https://github.com/ndevilla.png","language":"C","readme":"[![pipeline status](https://gitlab.com/iniparser/iniparser/badges/main/pipeline.svg)](https://gitlab.com/iniparser/iniparser/-/commits/main)\n[![latest release](https://gitlab.com/iniparser/iniparser/-/badges/release.svg)](https://gitlab.com/iniparser/iniparser/-/releases)\n\n# iniParser 4 #\n\nChanges in May 2024:\nWe moved to [iniparser/iniparser](https://gitlab.com/iniparser/iniparser)!\nGo there for:\n\n- [New Issues](https://gitlab.com/iniparser/iniparser/-/issues/new)\n- [Merge Requests](https://gitlab.com/iniparser/iniparser/-/merge_requests/new)\n\nChanges in March 2024:\n\\@lmoellendorf took over maintenance for this project.\n\n- [X] The objective was to get all known issues fixed and released as v4.2.\n- [X] After that, this project has been frozen on Github as v4.2.1 and\n- [ ] development should continue as v5, ~probably~ on gitlab.\n- [X] Pointers have been updated.\n\nThanks a million times to Lars for his tremendous work and help in keeping this\nlibrary alive!\n\nMany thanks to \\@touilleman for his exceptional contributions and efforts for\nmaintaining this project for a decade. Manu, you rock!\n\n## Overview\n\nThis modules offers parsing of ini files from C.\n\nKey features:\n\n - Small : around 1500 sloc inside 4 files (2 .c and 2 .h)\n - Portable : no dependancies, written in `-pedantic` C\n - Fully re-entrant : easy to make it thread-safe (just surround\n   library calls by mutex)\n\n## Installation\n\niniParser is available in a number of package repositories:\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/iniparser.svg)](https://repology.org/project/iniparser/versions)\n\n## MinGW\n\nIn the instructions below, replace `make all` by `ninja` if you are using\nMinGW as build system. Of course you will need to install\n[ninja](https://ninja-build.org/) to use it.\n\n## Building project\n\nThis project uses CMake as build system. Use these command at the root or the\nproject to get the static (i.e. `libiniparser.a`) and shared (i.e.\n`libiniparser.so`) libraries compiled:\n\n```\nmkdir build\ncd build\ncmake ..\nmake all\n```\n\nThere are some CMake option which are `OFF` by default:\n\n- `BUILD_TESTING`\n- `BUILD_EXAMPLES`\n- `BUILD_DOCS`\n\nThese CMake options are `ON` by default:\n\n- `BUILD_SHARED_LIBS`\n- `BUILD_STATIC_LIBS`\n\nFrom within build directory execute `ccmake ..` to see all.\n\n\n## Tests\n\n```\nmkdir build\ncd build\ncmake -DBUILD_TESTING ..\nmake all\n```\n\nWhile still in the build project you can run the tests by calling `ctest`.\nTest output can be found in build directory under\n`Testing/Temporary/LastTest.log`.\n\nEach time `cmake` is executed in an empty build directory it will try to clone\nthe unit test framework [Unity](https://www.throwtheswitch.org/unity).\nTo avoid unnecessary downloads you may place a copy outside your build\ndirectory and point cmake to it.\n\nTo do so first clone Unity in a project of your choice:\n\n```\ngit clone https://github.com/throwtheswitch/unity.git\n```\nNow change into your build directory and pass `FETCHCONTENT_SOURCE_DIR_UNITY`\nto `cmake` (adjust the path to unity to your local setup):\n```\nmkdir build\ncd build\ncmake -DBUILD_TESTING -DFETCHCONTENT_SOURCE_DIR_UNITY=../../3rparty/unity ..\nmake all\n```\nNow CMake will try to use the sources in this directory and fall back to\ncloning if it cannot find them there.\n\n\n## Examples\n\nTo build the examples:\n\n```\nmkdir build\ncd build\ncmake -DBUILD_EXAMPLES ..\nmake all\n```\n\nFrom the build directory run the examples with:\n\n - `./iniexample`\n - `./iniwrite`\n - `./parse ../example/twisted.ini`\n\n\n## Documentation\n\nThe library is completely documented in its header file.\n\nTo build the documentation [doxygen](https://www.doxygen.org/index.html) has be\ninstalled. Documentation can build and be found in build directory under\n`html`:\n\n```\nmkdir build\ncd build\ncmake -DBUILD_DOCS ..\nmake all\n```\n\nOpen the file `html/index.html` with any HTML-capable browser.\n\nOr see the [complete documentation](https://iniparser.gitlab.io/iniparser/)\nonline.\n\n\n## License\n\nThis software is released under MIT License.\nSee [LICENSE](LICENSE) for more details\n\n\n## Versions\n\n[![latest release](https://gitlab.com/iniparser/iniparser/-/badges/release.svg)](https://gitlab.com/iniparser/iniparser/-/releases)\n\n- Since v4.2.x [Semantic Versioning](https://semver.org/) is applied.\n- Version 4.0 introduced breaking changes in the api.\n- Older versions 3.1 and 3.2 with the legacy api are available as tags.\n\n\n## FAQ\n\nSee [FAQ-en.md](FAQ-en.md) in this directory for answers to Frequently Asked\nQuestions.\n\n还有简化中国翻译在[FAQ-zhcn.md](FAQ-zhcn.md).\n\n\n## Details\n\n### Introduction\n\niniParser is a simple C library offering ini file parsing services.\nThe library is pretty small (less than 1500 lines of C) and robust, and does\nnot depend on any other external library to compile. It is written in C and\nshould compile on most platforms without difficulty.\n\n\n### What is an ini file?\n\nAn ini file is an ASCII file describing simple parameters (character strings,\nintegers, floating-point values or booleans) in an explicit format, easy to use\nand modify for users.\n\nAn ini file is segmented into Sections, declared by the following syntax:\n\n```ini\n[Section Name]\n```\n\ni.e. the section name enclosed in square brackets, alone on a line. Sections\nnames are allowed to contain any character but square brackets or linefeeds.\n\nIn any section are zero or more variables, declared with the following syntax:\n\n```ini\nKey = value ; comment\n```\n\nThe key is any string (possibly containing blanks). The value is any character\non the right side of the equal sign. Values can be given enclosed with quotes.\nIf no quotes are present, the value is understood as containing all characters\nbetween the first and the last non-blank characters before the comment. The\nfollowing declarations are identical:\n\n```ini\nHello = \"this is a long string value\" ; comment\nHello = this is a long string value ; comment\n```\n\nThe semicolon and comment at the end of the line are optional. If there is a\ncomment, it starts from the first character after the semicolon up to the end\nof the line.\n\nMulti-line values can be provided by ending the line with a backslash (`\\`).\n\n```ini\nMultiple = Line 1 \\\nLine 2 \\\nLine 3 \\\nLine 4 ; comment\n```\n\nThis would yield: \"multiple\" \u003c- \"Line1 Line2 Line3 Line4\"\n\nComments in an ini file are:\n\n- Lines starting with a hash sign\n- Blank lines (only blanks or tabs)\n- Comments given on value lines after the semicolon (if present)\n\n\n### Using the library\n\nTo use the library in your programs, add the following line on top of your\nmodule:\n\n```c\n#include \"iniparser.h\"\n```\n\nAnd link your program with the iniParser library by adding `-liniparser` to the\ncompile line.\n\nSee the file example/example.c for an example.\n\niniParser is an C library. If you want to compile it with a C++ compiler have\nto include the extern \"C\" hack to include the header:\n\n```c\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n#include \"iniparser.h\"\n#ifdef __cplusplus\n}\n#endif\n```\nComments are discarded by the parser. Then sections are identified, and in each\nsection a new entry is created for every keyword found. The keywords are stored\nwith the following syntax:\n\n```c\n[Section]\nKeyword = value ; comment\n```\n\nis converted to the following key pair:\n\n```c\n(\"section:keyword\", \"value\")\n```\n\nThis means that if you want to retrieve the value that was stored in the\nsection called `Pizza`, in the keyword `Cheese`, you would make a request to\nthe dictionary for `\"pizza:cheese\"`. All section and keyword names are\nconverted to lowercase before storage in the structure. The value side is\nconserved as it has been parsed, though.\n\nSection names are also stored in the structure. They are stored using as key\nthe section name, and a NULL associated value. They can be queried through\n`iniparser_find_entry()`.\n\nTo launch the parser, use the function called `iniparser_load()`, which takes\nan input file name and returns a newly allocated `dictionary` structure. This\nlatter object should remain opaque to the user and only accessed through the\nfollowing accessor functions:\n\n- `iniparser_getstring()`\n- `iniparser_getint()`\n- `iniparser_getdouble()`\n- `iniparser_getboolean()`\n\nFinally, discard this structure using `iniparser_freedict()`.\n\nAll values parsed from the ini file are stored as strings. The accessors are\njust converting these strings to the requested type on the fly, but you could\nbasically perform this conversion by yourself after having called the string\naccessor.\n\nNotice that `iniparser_getboolean()` will return an integer (0 or 1), trying to\nmake sense of what was found in the file. Strings starting with \"y\", \"Y\", \"t\",\n\"T\" or \"1\" are considered true values (return 1), strings starting with \"n\",\n\"N\", \"f\", \"F\", \"0\" are considered false (return 0). This allows some\nflexibility in handling of boolean answers.\n\nIf you want to add extra information into the structure that was not present in\nthe ini file, you can use `iniparser_set()` to insert a string.\n\nIf you want to add a section to the structure, add a key with a NULL value.\nExample:\n\n```c\niniparser_set(ini, \"section\", NULL);\niniparser_set(ini, \"section:key1\", NULL);\niniparser_set(ini, \"section:key2\", NULL);\n```\n\n\n### A word about the implementation\n\nThe dictionary structure is a pretty simple dictionary implementation which\nmight find some uses in other applications. If you are curious, look into the\nsource.\n\n\n### Known defects\n\nThe dictionary structure is extremely unefficient for searching as keys are\nsorted in the same order as they are read from the ini file, which is\nconvenient when dumping back to a file. The simplistic first-approach linear\nsearch implemented there can become a bottleneck if you have a very large\nnumber of keys.\n\nPeople who need to load large amounts of data from an ini file should\ndefinitely turn to more appropriate solutions: sqlite3 or similar. There are\notherwise many other dictionary implementations available on the net to replace\nthis one.\n","funding_links":[],"categories":["Configuration","C","Structured File Processing","结构化文件处理","Uncategorized","Parsers ##"],"sub_categories":["INI","Uncategorized","Web Frameworks ###"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndevilla%2Finiparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndevilla%2Finiparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndevilla%2Finiparser/lists"}