{"id":22966288,"url":"https://github.com/ethanuppal/config","last_synced_at":"2025-08-13T08:32:55.991Z","repository":{"id":175607887,"uuid":"648794520","full_name":"ethanuppal/config","owner":"ethanuppal","description":"A simple library for parsing configuration files.","archived":true,"fork":false,"pushed_at":"2024-03-17T05:23:25.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T04:31:21.026Z","etag":null,"topics":["config","library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethanuppal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-06-02T20:42:21.000Z","updated_at":"2024-07-09T06:49:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"59a2793c-8481-4717-9300-40c1853eb946","html_url":"https://github.com/ethanuppal/config","commit_stats":null,"previous_names":["ethanuppal/config"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ethanuppal/config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanuppal%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanuppal%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanuppal%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanuppal%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethanuppal","download_url":"https://codeload.github.com/ethanuppal/config/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanuppal%2Fconfig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270210405,"owners_count":24545863,"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","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["config","library"],"created_at":"2024-12-14T20:18:28.318Z","updated_at":"2025-08-13T08:32:55.719Z","avatar_url":"https://github.com/ethanuppal.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# config\n\nConfig is a simple library for parsing configuration files.\n\n```\n# This is a configuration file\n\nKEY = VALUE                 # This is an example setting\nMy\\=Setting = Potato = Food # You can escape the delimiter\n\n# You can even have custom delimiters\nOUTPUT:c++\n```\n\n## Install\n\n### Unix-like systems (macOS, Linux, etc.)\n\n```bash\ngit clone https://github.com/ethanuppal/config \\\n    \u0026\u0026 cd config \\\n    \u0026\u0026 make install\n```\n\nThis command will install the static (`libconfig.a`) and dynamic (`libconfig.so`) libraries in `/usr/local/lib` and the header file `\u003cconfig/config.h\u003e` in `/usr/local/include`.\n\nRun `make uninstall` to uninstall the library.\n\n### Windows\n\nIf you have `clang` and `make` installed, you can run the following commands in `bash` or similar:\n\n```bash\ngit clone https://github.com/ethanuppal/config \\\n    \u0026\u0026 cd config \\\n    \u0026\u0026 make all\n```\n\nThis will build the static and dynamic libraries in the current directory.\n\n## Usage\n\n### Section contents\n\n* Example\n* Callback\n* Parsing files\n* Configuring config\n\n### Example\n\nThe directory [test/](test) has a working example with:\n\n* [config.txt](test/config.txt): A sample configuation file\n* [main.c](test/main.c): A program that uses config to parse it\n\n### Callback\n\nCreate a callback for when config finds a new variable as follows (in order that it be of type `conf_parse_handler_t`). The parameters besides `user_data` are read-only and valid for only as long as config is parsing, so be sure to copy them if you want to use it outside of the callback.\n\n```c\nvoid callback(const char *var, const char *data, void *user_data) {\n    myapi_t *api = (myapi_t*)user_data;\n    if (strcmp(var, \"PATH\") == 0) {\n        api-\u003epath = data;\n    }\n}\n```\n\nThen call `conf_parse_file` or `conf_parse_text` with the appropriate arguments.\n\n### Parsing files\n\n#### `conf_parse_file`\n\n```c\nint conf_parse_file(FILE* f, conf_parse_handler_t handler, void* user_data);\n```\nParses the given file as a configuration file.\n\nParam | Description\n----- | -----------\n`f` | The configution file handle.\n`handler` | The callback for when a variable is found.\n`user_data` | Optional data passed to the callback.\n\n#### `conf_parse_text`\n\n```c\nint conf_parse_text(const char* s, conf_parse_handler_t handler, void* user_data);\n```\nParses the given text as a configuation file.\n\nParam | Description\n----- | -----------\n`s` | A string in config syntax.\n`handler` | The callback for when a variable is found.\n`user_data` | Optional data passed to the callback.\n\n### Configuring config\n\n#### `conf_set_comments`\n\n```c\nvoid conf_set_comments(const char* comments);\n```\nTells config what comments look like.\n\nParam | Description\n----- | -----------\n`comments` | A list of characters. Any line starting with these characters will be ignores. Empty lines are automatically ignored.\n\nIf this function is not invoked, config will behave as if it was run as\n```c\nconf_set_comments(\"\\n#\");\n```\n\nExample:\n```c\n// Ignore lines starting with, spaces, tabs, exclamation points, and hashtags.\nconf_set_comments(\" \\t#!\");\n```\n\n#### `conf_set_delimiters`\n\n```c\nvoid conf_set_delimiters(const char* delimiters, char escape);\n```\nTells config what the variable delimiters look like.\n\nParam | Description\n----- | -----------\n`delimiters` | A list of variable delimiters.\n`escape` | An optional escape character. Set this to 0 if you don't want any escaping. If specified, variable names can include a delimiter character provided it is prefixed with the escape character. It will show up in the callback without the escape. A sequence of two escape characters will show up as a single one.\n\nIf this function is not invoked, config will behave as if it was run as\n```c\nconf_set_delimiters(\"=\", '\\\\');\n```\n\nExample 1:\n```c\n// Variables defined with '=', escapes with '\\'\nconf_set_delimiters(\"=\", '\\\\');\n```\n\nExample 2:\n```c\n// Variables defined with ':', no escaping\nconf_set_delimiters(\":\", 0);\n```\n\n#### `conf_set_trimming`\n\n```c\nvoid conf_set_trimming(const char* whitespace);\n```\nTells config whether to trim leading and trailing whitespace from entries.\n\nParam | Description\n----- | -----------\n`whitespace` | A list of characters to trim. If this value is `NULL`, trimming is disabled.\n\nIf this function is not invoked, config will behave as if it was run as\n```c\nconf_set_trimming(\" \\t\");\n```\n\nExample:\n```\n// Disable trimming\nconf_set_trimming(NULL);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanuppal%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethanuppal%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanuppal%2Fconfig/lists"}