From c9579598c5a1b49f7fe8e353623175bf8f3cc236 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 8 Aug 2024 12:45:05 -0400 Subject: Return of the INI refactor (#20) * 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 --- include/ini.h | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'include/ini.h') diff --git a/include/ini.h b/include/ini.h index 5c840f5..2992a37 100644 --- a/include/ini.h +++ b/include/ini.h @@ -7,6 +7,8 @@ #define INI_WRITE_RAW 0 ///< Dump INI data. Contents are not modified. #define INI_WRITE_PRESERVE 1 ///< Dump INI data. Template strings are +#define INI_READ_RAW 0 ///< Dump INI data. Contents are not modified. +#define INI_READ_RENDER 1 ///< Dump INI data. Template strings are #define INI_SETVAL_APPEND 0 #define INI_SETVAL_REPLACE 1 #define INI_SEARCH_EXACT 0 @@ -219,7 +221,7 @@ struct INIData *ini_getall(struct INIFILE *ini, char *section_name); * @return 0 on success * @return Non-zero on error */ -int ini_getval(struct INIFILE *ini, char *section_name, char *key, int type, union INIVal *result); +int ini_getval(struct INIFILE *ini, char *section_name, char *key, int type, int flags, union INIVal *result); /** * Write INIFILE sections and data to a file stream @@ -235,22 +237,22 @@ int ini_write(struct INIFILE *ini, FILE **stream, unsigned mode); */ void ini_free(struct INIFILE **ini); -int ini_getval_int(struct INIFILE *ini, char *section_name, char *key, int *state); -unsigned int ini_getval_uint(struct INIFILE *ini, char *section_name, char *key, int *state); -long ini_getval_long(struct INIFILE *ini, char *section_name, char *key, int *state); -unsigned long ini_getval_ulong(struct INIFILE *ini, char *section_name, char *key, int *state); -long long ini_getval_llong(struct INIFILE *ini, char *section_name, char *key, int *state); -unsigned long long ini_getval_ullong(struct INIFILE *ini, char *section_name, char *key, int *state); -float ini_getval_float(struct INIFILE *ini, char *section_name, char *key, int *state); -double ini_getval_double(struct INIFILE *ini, char *section_name, char *key, int *state); -bool ini_getval_bool(struct INIFILE *ini, char *section_name, char *key, int *state); -short ini_getval_short(struct INIFILE *ini, char *section_name, char *key, int *state); -unsigned short ini_getval_ushort(struct INIFILE *ini, char *section_name, char *key, int *state); -char ini_getval_char(struct INIFILE *ini, char *section_name, char *key, int *state); -unsigned char ini_getval_uchar(struct INIFILE *ini, char *section_name, char *key, int *state); -char *ini_getval_char_p(struct INIFILE *ini, char *section_name, char *key, int *state); -char *ini_getval_str(struct INIFILE *ini, char *section_name, char *key, int *state); -char **ini_getval_char_array_p(struct INIFILE *ini, char *section_name, char *key, int *state); -char **ini_getval_str_array(struct INIFILE *ini, char *section_name, char *key, int *state); -struct StrList *ini_getval_strlist(struct INIFILE *ini, char *section_name, char *key, char *tok, int *state); +int ini_getval_int(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +unsigned int ini_getval_uint(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +long ini_getval_long(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +unsigned long ini_getval_ulong(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +long long ini_getval_llong(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +unsigned long long ini_getval_ullong(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +float ini_getval_float(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +double ini_getval_double(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +bool ini_getval_bool(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +short ini_getval_short(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +unsigned short ini_getval_ushort(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +char ini_getval_char(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +unsigned char ini_getval_uchar(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +char *ini_getval_char_p(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +char *ini_getval_str(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +char *ini_getval_char_array_p(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +char *ini_getval_str_array(struct INIFILE *ini, char *section_name, char *key, int flags, int *state); +struct StrList *ini_getval_strlist(struct INIFILE *ini, char *section_name, char *key, char *tok, int flags, int *state); #endif //STASIS_INI_H -- cgit