aboutsummaryrefslogtreecommitdiff
path: root/src/ini.c
Commit message (Collapse)AuthorAgeFilesLines
* Refactor directory structureJoseph Hunkeler2024-10-141-678/+0
| | | | | * Move core library sources into src/lib/core * Move command-line programs into src/cli
* ini.c: fix realloc(s)Joseph Hunkeler2024-10-091-8/+8
|
* Add template convience functions (and bug fixes) (#29)Joseph Hunkeler2024-08-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * Die when render variable is NULL * This was caught when a call to {{ func:xyz() }} lacked opening/closing parenthesis * Scripts in tests should only render template strings right before execution * Remove conda version pin * This avoids updating conda in the base environment * This also avoids pitfalls associated with newly released (always broken) versions of conda * Add two template convenience functions * get_junitxml_result_auto() * get_basetemp_result_auto() * Handle rendering error for test script * Rename functions * get_junitxml_result_auto -> junitxml_file * get_basetemp_result_auto -> basetemp_dir * Thank you, @zacharyburnett
* More unit tests (and fixing bugs) (#23)Joseph Hunkeler2024-08-121-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add test_artifactory.c to suite * Add test_ini_getval_wrapper to ini.c * basic ini_getval_TYPE() conversion checks * bugfix: use strtof in INIVAL_TYPE_FLOAT case * Include stdio.h to pull in FILE structure * bugfix: free data at index during strlist_set operation * Previous behavior of setting the pointer to NULL introduced a subtle memory leak * Set strlist error when index it out of range * Import private delivery functions required for mock context creation * Remove static declaration * populate_delivery_cfg() * Add test_junitxml.c * Fix duplicate define value for JUNIT_RESULT_STATE_ERROR * Add static junit test data * Copy test data to current test directory
* Return of the INI refactor (#20)Joseph Hunkeler2024-08-081-94/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Continuation of #19 * Fixes always_update_base_environment override bug added by PR #19 * Finish type hinting implementation * ini_getval_* functions now able to affect rendering mode using INI_READ_RAW and INI_READ_RENDER * Created pointers to deeply nested structures to increase readability * Output from ini_write() is more consistent, with fewer errant spaces and line feeds * Fixes accidental regression in #19. INIVAL_TYPE_STR_ARRAY never produced an array of pointers to char. This needs to be corrected in the future. i.e. It has always generated a new-line delimited string, not a StrList, or array. * Fix strlist_append_tokenize * original pointer is no longer modified * token strings are stripped of leading space before appending to the list * Use defines instead of magic numbers * delivery_init: add render_mode argument * test_conda: Add render mode * test_ini: Add render mode * Only add conda packages and wheels to the image * docker images are saved to the packages directory and will be consumed by the image if present. * Render template variables after bootstrapping the delivery
* Refactor ini getter and setter usage (#19)Joseph Hunkeler2024-08-071-10/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add handler for space-delimited lists * This needs attention, however. The INI writer has no way to know a list with spaces is a list; this happens in the value conversion functions. * Add type_hint member to INIData structure. At some point support with be added for all INIVAL_TYPE_* defines. Right now it's only used with arrays. * Zero out line buffer in ini_open after each iteration * Do not strip raw INI data. Let the conversion functions handle it * Add spaces to key value pairs in rendered INI output. * Add ini_getvar_TYPE() functions * These replace the functionality of static conv_TYPE() functions in delivery.c * Add support for missing types: U/CHAR, U/SHORT, STRLIST * ini_getval: expand template variables immediately before processing the output * Strip leading space to avoid issues with string comparisons against the result * ini_getval: Return copies, not the original. * This forces one to use ini_setval to replace/append values to the data array(s). It's safer this way. * fix_tox_conf(): Use ini_getval and ini_setval instead of modifying the original pointers directly * Tests: Free resources * Replace ini_getval(), ini_getval_required() and conv_*() usage * Now using ini_getval_TYPE() functions and ini_setval() * Remove unused helper functions and variables * download() returns long, not int * actions: update apt cache
* Add github.c and github.h (#9)Joseph Hunkeler2024-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add github.c and github.h * Implements get_github_release_notes() * Remove unused variables * Fix circular dependency on tplfunc_frame * Remove predeclaration of tplfunc_frame * tpl_register_func accepts pointer to void instead * tpl_register_func sets maximum number of arguments * Frame is generated within tpl_register_func * Improve template function error handling and return/output management * Remove redundant extern statement * Include github.h and template_func_proto.h in core.h * Expose get_github_release_notes_tplfunc_entrypoint function to template engine * Add template_func_proto.c and template_func_proto.h * Replace free() with guard variant * Fix test_template::test_tpl_register_func * Fix tests * Fix tests * cmd should be at least PATH_MAX in size. * Magic number caused failure to install conda with a long installation path * Implement get_github_release_notes_auto function that bases release note data off test contexts * Disable overwriting releases by default * Add automatic release note generation function call to release_notes.md.in * Fix test_tpl_register_func() * Add enough space for tar command plus a path * Fix circular include * Github functions do not require access to core.h anyway * Add comments to union * Update README to mention template function availability * Add EnvCtl structure * Add runtime checks to avoid running all the way to the end only to be met with a configuration error. * Rename GITHUB to GH * Development docs pre-rough-draft
* Rebrand OhMyCal (OMC) as STASIS (#7)Joseph Hunkeler2024-06-211-6/+6
|
* Unit tests (#6)Joseph Hunkeler2024-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial commit of unit tests [WIP] * Address shortcomings and bugs flushed out by unit tests * Enable unit testing in CI workflow * Enable verbose ctests * Handle lack of __FILE_NAME__ define * Only podman support `run --arch` argument * Skip docker build testing if CI system cannot pull an image * Remove errant call to puts() * Identify local repo user * Fix missing xmllint * NULL terminate arrays * Fix filename assignment in is_url mode * Break loop when expected lines are exhausted * strcmp_array expects NULL terminated array. Iterating by size in this case passes NULL to strcmp leading to an invalid read * Remove debug printf statements * Disable a few warnings for tests * Workaround for ctest junit xml truncation * Update checkout@v4 * Prevent false-positive result * Return zero on error * Fix strlist_remove function * Value argument can be constant * Fix test to match changes to startswith and endswith * Add test_ini.c * Fix redaction code to accept NULL pointers in array * And let the caller specify the length of the array of strings to redact. * Redactions now occur directly on authentication strings rather than their command line arguments * Fix BUILD_TESTING_DEBUG * Adds missing -D argument
* Stop iteration on matchJoseph Hunkeler2024-04-151-0/+3
|
* Add ini_has_key() and expose ini_section_search() functionJoseph Hunkeler2024-04-151-9/+53
| | | | * ini_section_search now has three matching modes _EXACT, _BEGINS, and _SUBSTR
* Add ini_setval() functionJoseph Hunkeler2024-04-151-0/+18
|
* Fix invalid read on operatorJoseph Hunkeler2024-04-121-1/+5
| | | | * If no data exists beyond the operator, set the value to an empty string
* Fix size of data array in sectionJoseph Hunkeler2024-04-121-4/+4
| | | | * Fix realloc error handler
* Changes to ini_write() behavior:Joseph Hunkeler2024-04-021-7/+20
| | | | | | * Caller can choose to dump raw unmodified key/value pairs, or render all values through the template engine * Fixes spurious line feeds injected into the output stream * Uses LINE_SEP instead of "\n"
* Lock output behind DEBUG defineJoseph Hunkeler2024-04-021-0/+9
|
* Close handleJoseph Hunkeler2024-03-251-0/+1
|
* Fix up section->data reallocJoseph Hunkeler2024-03-241-4/+17
| | | | * Add error handling
* Duplicate keys and values instead of copying their pointers.Joseph Hunkeler2024-03-221-15/+31
| | | | * ini_open uses the stack instead of malloc
* Fix size of realloc'd dataJoseph Hunkeler2024-03-221-6/+12
| | | | * Fix up error handling for relloc'd data
* Move collapse_whitespace to utils.c / utils.hJoseph Hunkeler2024-03-221-11/+0
|
* Replace ini_show with ini_writeJoseph Hunkeler2024-03-141-4/+23
| | | | * One can still display the ini configuration by using ini_show(iniptr, stdout);
* Use do/while in guard_* macros to make them behave more like functionsJoseph Hunkeler2024-03-101-11/+11
|
* Fixes several memory leaksJoseph Hunkeler2024-02-261-1/+0
|
* * Fix segmentation fault in ini_data_get() when section_name is not foundJoseph Hunkeler2024-01-301-25/+25
| | | | | | * Rename ini_section_record() to ini_section_create() * Remove unnecessary trigger from unquote() * Rename long_data to multiline_data to visually clarify what's going on
* guard_free() all pointersJoseph Hunkeler2023-12-101-14/+11
|
* Remove trailing whitespace from key nameJoseph Hunkeler2023-12-101-2/+4
|
* Fix segfault when section is not presentJoseph Hunkeler2023-12-101-0/+4
|
* Fix segfault on invalid section nameJoseph Hunkeler2023-12-101-0/+7
|
* Bugfix: Test for a comment first, then act accordingly, instead of testing ↵Joseph Hunkeler2023-11-211-3/+3
| | | | only when a variable is being read
* Fixes:Joseph Hunkeler2023-11-201-47/+53
| | | | | | | | | * ini_section_record() returns status now * Reading long data variables (multi-line arrays) behaves consistently Refactor: * ini_data_record() is now ini_data_append()
* Implements slightly improved error handlingJoseph Hunkeler2023-11-201-8/+17
| | | | | | | * Return status from conda_ and delivery_ functions * Caller prints meaningful error, and handles it * Enable warnings during compilation * Squelch format-truncation warning -- those strings are extremely unlikely to overflow (famous last words)
* Replaces BUFSIZ with OMC_BUFSIZJoseph Hunkeler2023-11-201-4/+4
|
* Rebrand for the last timeJoseph Hunkeler2023-11-201-1/+1
| | | | | * Shorten OHMYCAL to OMC * Rename ohmycal.h to omc.h
* Only truncate value when length is greater than zeroJoseph Hunkeler2023-10-311-67/+6
| | | | * Remove unused code/comments
* Initial commitJoseph Hunkeler2023-10-261-0/+409