| collection.h | | collection.h | |
| | | | |
| skipping to change at line 799 | | skipping to change at line 799 | |
| * @return ENOMEM - No memory. | | * @return ENOMEM - No memory. | |
| * | | * | |
| */ | | */ | |
| int col_get_item(struct collection_item *ci, | | int col_get_item(struct collection_item *ci, | |
| const char *property_to_find, | | const char *property_to_find, | |
| int type, | | int type, | |
| int mode_flags, | | int mode_flags, | |
| struct collection_item **item); | | struct collection_item **item); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Search function to get one of the duplicate items. | |
| | | * | |
| | | * Convenience function to get an individual item out of the list of duplic | |
| | | ates. | |
| | | * Caller should be aware that this is not a copy of the item | |
| | | * but the pointer to actual item stored in the collection. | |
| | | * The returned pointer should never be altered or freed by caller | |
| | | * of the function. | |
| | | * The caller should be sure that the collection does not go out of scope | |
| | | * while the pointer to its data is in use. | |
| | | * Working with the internals of the collection item structure directly | |
| | | * may cause problems in future if the internal implementation changes. | |
| | | * If collection to search or property to find is NULL function returns NUL | |
| | | L. | |
| | | * | |
| | | * Use \ref getitem "item management" functions to work with the item. | |
| | | * | |
| | | * @param[in] ci Collection object to traverse. | |
| | | * @param[in] subcollection Name of the sub collection to find | |
| | | * item in. If NULL, the top level collection | |
| | | * is used. One can use "foo!bar!baz" | |
| | | * notation to identify the sub collection. | |
| | | * @param[in] property_to_find Name of the property to find. | |
| | | * @param[in] type Type filter. Only properties | |
| | | * of the given type will match. | |
| | | * Can be 0 to indicate that all | |
| | | * types should be evaluated. | |
| | | * @param[in] idx Index of the duplicate to find. | |
| | | * 0 - any first instance | |
| | | * positive - N-th instance (index is 0-based) | |
| | | * negative - last instance | |
| | | * @param[in] exact If 0 then if index above is greater than | |
| | | * actual number of duplicates the last duplic | |
| | | ate | |
| | | * if be returned. | |
| | | * If non-zero the funtion will return ENOENT | |
| | | * in case the index is greater than actual | |
| | | * number of duplicates. | |
| | | * @param[out] item Pointer to found item or NULL | |
| | | * if item is not found. | |
| | | * @return 0 No errors. | |
| | | * @return EINVAL Invalid argument. | |
| | | * @return ENOENT Item is not found. | |
| | | */ | |
| | | int col_get_dup_item(struct collection_item *ci, | |
| | | const char *subcollection, | |
| | | const char *property_to_find, | |
| | | int type, | |
| | | int idx, | |
| | | int exact, | |
| | | struct collection_item **item); | |
| | | | |
| | | /** | |
| * @brief Sort collection. | | * @brief Sort collection. | |
| * | | * | |
| * If the sub collections are included in sorting | | * If the sub collections are included in sorting | |
| * each collection is sorted separately (this is not a global sort). | | * each collection is sorted separately (this is not a global sort). | |
| * It might be dangerous to sort sub collections if | | * It might be dangerous to sort sub collections if | |
| * sub collection is not owned by the current collection. | | * sub collection is not owned by the current collection. | |
| * If it is a reference to an external collection | | * If it is a reference to an external collection | |
| * there might be an issue. To skip the collections that | | * there might be an issue. To skip the collections that | |
| * externally referenced use \ref COL_SORT_MYSUB flag. | | * externally referenced use \ref COL_SORT_MYSUB flag. | |
| * Keep in mind that if a collection is referenced | | * Keep in mind that if a collection is referenced | |
| | | | |
| skipping to change at line 2303 | | skipping to change at line 2353 | |
| * For "extract" or "delete": | | * For "extract" or "delete": | |
| * - Delete or extract N-th duplicate property. | | * - Delete or extract N-th duplicate property. | |
| * Index is zero based. | | * Index is zero based. | |
| * The property name is taken from the refprop. | | * The property name is taken from the refprop. | |
| * If index is greater than number of duplicate | | * If index is greater than number of duplicate | |
| * properties in the sequence ENOENT is returned. | | * properties in the sequence ENOENT is returned. | |
| * | | * | |
| */ | | */ | |
| #define COL_DSP_NDUP 7 | | #define COL_DSP_NDUP 7 | |
| /** | | /** | |
|
| | | * @brief Use last among nonsequential duplicates | |
| | | * | |
| | | * This mode applies to the list of duplicates that might be scattered | |
| | | * across the collection | |
| | | * | |
| | | * For "insert": | |
| | | * - Add property as the last dup of the given property. | |
| | | * The property name is taken from the item | |
| | | * and the value refprop is ignored. | |
| | | * | |
| | | * For "extract" or "delete": | |
| | | * - Delete or extract the last duplicate of the property. | |
| | | * The property name is taken from the refprop. | |
| | | * Extracts or deletes last duplicate property in the uninterrupted | |
| | | * sequence of properties with the same name. | |
| | | * The property will be extracted or deleted if found | |
| | | * regardless of whether there are any duplicates or not. | |
| | | */ | |
| | | #define COL_DSP_LASTDUPNS 8 | |
| | | /** | |
| | | * @brief Use N-th among nonsequential duplicates | |
| | | * | |
| | | * This mode applies only to the list of duplicate | |
| | | * properties that are going one after another. | |
| | | * | |
| | | * For "insert": | |
| | | * - Add property as a N-th dup of the given property. | |
| | | * The property name is taken from the item | |
| | | * and the value refprop is ignored. | |
| | | * Index is zero based. | |
| | | * The COL_DSP_NDUPNS is used in case of the multi value property | |
| | | * to add a new property with the same name into specific place | |
| | | * in the list of properties with the same name. | |
| | | * The index of 0 will mean to add the property before the first | |
| | | * instance of the property with the same name. | |
| | | * If the property does not exist ENOENT will be returned. | |
| | | * If the index is greater than the last property with the same | |
| | | * name the item will be added immediately after last | |
| | | * property with the same name. | |
| | | * | |
| | | * For "extract" or "delete": | |
| | | * - Delete or extract N-th duplicate property. | |
| | | * Index is zero based. | |
| | | * The property name is taken from the refprop. | |
| | | * If index is greater than number of duplicate | |
| | | * properties in the sequence ENOENT is returned. | |
| | | * | |
| | | */ | |
| | | #define COL_DSP_NDUPNS 9 | |
| | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup insflags Flags used in insert item functions | | * @defgroup insflags Flags used in insert item functions | |
| * | | * | |
| * Flags that can be used with insert functions. | | * Flags that can be used with insert functions. | |
| * | | * | |
| * In future can more flags might be added. | | * In future can more flags might be added. | |
| * | | * | |
| | | | |
| skipping to change at line 2508 | | skipping to change at line 2608 | |
| * This function is useful if you want to modify the item that | | * This function is useful if you want to modify the item that | |
| * you got as a result of \ref iterfunc "iterating" through | | * you got as a result of \ref iterfunc "iterating" through | |
| * collection or by calling \ref col_get_item. | | * collection or by calling \ref col_get_item. | |
| * Previous type and data of the item is destroyed. | | * Previous type and data of the item is destroyed. | |
| * | | * | |
| * If you want to rename an item provide a new name in the property | | * If you want to rename an item provide a new name in the property | |
| * argument otherwise keep it NULL. | | * argument otherwise keep it NULL. | |
| * | | * | |
| * If you want the data to remain unchanged use 0 as a length parameter. | | * If you want the data to remain unchanged use 0 as a length parameter. | |
| * | | * | |
|
| * If item is a reference or a collection the call will return an error. | | * If the item is a reference or a collection and you attempt to change | |
| | | * the data, i.e. length is not 0, the call will return an error EINVAL. | |
| | | * If the item is a reference or a collection it can only be renamed. | |
| * | | * | |
| * The are several convenience function that are wrappers | | * The are several convenience function that are wrappers | |
| * around this function. For more information | | * around this function. For more information | |
| * see \ref modwrap "item modification wrappers". | | * see \ref modwrap "item modification wrappers". | |
| * | | * | |
| * @param[in] item Item to modify. | | * @param[in] item Item to modify. | |
| * @param[in] property Property name. Use NULL to leave the property | | * @param[in] property Property name. Use NULL to leave the property | |
| * unchanged. | | * unchanged. | |
| * @param[in] type See \ref coltypes "types" for more information. | | * @param[in] type See \ref coltypes "types" for more information. | |
| * @param[in] data New value. | | * @param[in] data New value. | |
| | | | |
| skipping to change at line 2838 | | skipping to change at line 2940 | |
| * @return ENOSYS Unknown disposition value. | | * @return ENOSYS Unknown disposition value. | |
| */ | | */ | |
| int col_remove_item(struct collection_item *ci, | | int col_remove_item(struct collection_item *ci, | |
| const char *subcollection, | | const char *subcollection, | |
| int disposition, | | int disposition, | |
| const char *refprop, | | const char *refprop, | |
| int idx, | | int idx, | |
| int type); | | int type); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Remove item from the collection. | |
| | | * | |
| | | * Function internally calls \ref col_extract_item and then | |
| | | * \ref col_delete_item for the extracted item. | |
| | | * | |
| | | * Function is similar to \ref col_delete_property function | |
| | | * but allows more specific information about what item (property) | |
| | | * to remove. | |
| | | * | |
| | | * The header will not be considered for deletion. | |
| | | * | |
| | | * @param[in] ci Collection object. | |
| | | * @param[in] subcollection Name of the sub collection to remove | |
| | | * item from. If NULL, the top level collection | |
| | | * is used. One can use "foo!bar!baz" | |
| | | * notation to identify the sub collection. | |
| | | * @param[in] disposition Constant that controls how the relative | |
| | | * position of the item to remove is determined | |
| | | . | |
| | | * For more information see \ref dispvalues | |
| | | * "disposition constants". | |
| | | * @param[in] refprop Name of the property to relate to. | |
| | | * This can be used to specify that function | |
| | | * should remove next item after the item | |
| | | * with this name. Leave NULL if the | |
| | | * disposition you are using does not | |
| | | * relate to an item in the collection. | |
| | | * @param[in] idx Index of the property to remove. | |
| | | * Useful for multi-value properties where | |
| | | * several properties have same name in a row. | |
| | | * @param[in] type Type filter. Only the item of the matching | |
| | | * type will be used. It can be a bit mask of | |
| | | * more than one type. Use 0 if you do not | |
| | | * need to filter by type. | |
| | | * @param[in] cb Callback to use. | |
| | | * @param[in] custom_data Caller defined data that can be passed | |
| | | * to the callback. | |
| | | * | |
| | | * @return 0 - Item was successfully removed. | |
| | | * @return ENOMEM - No memory. | |
| | | * @return EINVAL - The value of some of the arguments is invalid. | |
| | | * @return ENOENT - Sub collection is not found. | |
| | | * The position can't be determined. For example | |
| | | * deleting next item after item with name "foo" | |
| | | * will cause this error if item "foo" is the last | |
| | | * item in the collection. There are other cases | |
| | | * when this error can be returned but the common | |
| | | * theme is that something was not found. | |
| | | * @return ENOSYS Unknown disposition value. | |
| | | */ | |
| | | int col_remove_item_with_cb(struct collection_item *ci, | |
| | | const char *subcollection, | |
| | | int disposition, | |
| | | const char *refprop, | |
| | | int idx, | |
| | | int type, | |
| | | col_item_cleanup_fn cb, | |
| | | void *custom_data); | |
| | | | |
| | | /** | |
| * @brief Remove item from the current collection. | | * @brief Remove item from the current collection. | |
| * | | * | |
| * Function is similar to the \ref col_remove_item. | | * Function is similar to the \ref col_remove_item. | |
| * It acts exactly the same as \ref col_remove_item when the | | * It acts exactly the same as \ref col_remove_item when the | |
| * subcollection parameter of the \ref col_remove_item is set to NULL. | | * subcollection parameter of the \ref col_remove_item is set to NULL. | |
| * | | * | |
| * @param[in] ci Collection object. | | * @param[in] ci Collection object. | |
| * @param[in] disposition Constant that controls how the relative | | * @param[in] disposition Constant that controls how the relative | |
| * position of the item to remove is determined
. | | * position of the item to remove is determined
. | |
| * For more information see \ref dispvalues | | * For more information see \ref dispvalues | |
| | | | |
| skipping to change at line 3011 | | skipping to change at line 3172 | |
| * There is currently no function to create an item aside and | | * There is currently no function to create an item aside and | |
| * then insert it into the collection so the col_delete_item | | * then insert it into the collection so the col_delete_item | |
| * has only one use. In future this may change. | | * has only one use. In future this may change. | |
| * | | * | |
| * @param[in] item Item to delete. | | * @param[in] item Item to delete. | |
| * | | * | |
| */ | | */ | |
| void col_delete_item(struct collection_item *item); | | void col_delete_item(struct collection_item *item); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Delete extracted item with callback. | |
| | | * | |
| | | * This function is similar to \ref col_delete_item but allows | |
| | | * passing a callback function so that value stored in the collection can | |
| | | * be properly distroyed. | |
| | | * | |
| | | * @param[in] item Item to delete. | |
| | | * @param[in] cb Callback to use. | |
| | | * @param[in] custom_data Caller defined data that can be passed | |
| | | to the callback. | |
| | | * | |
| | | */ | |
| | | void col_delete_item_with_cb(struct collection_item *item, | |
| | | col_item_cleanup_fn cb, | |
| | | void *custom_data); | |
| | | | |
| | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup iterfunc Iterator interface | | * @defgroup iterfunc Iterator interface | |
| * | | * | |
| * The functions in this section allow iterating | | * The functions in this section allow iterating | |
| * through a collection in a loop where the caller | | * through a collection in a loop where the caller | |
| * implements the loop. It is different from the search and | | * implements the loop. It is different from the search and | |
| * traverse functions described in other sections because those | | * traverse functions described in other sections because those | |
| | | | |
End of changes. 5 change blocks. |
| 1 lines changed or deleted | | 183 lines changed or added | |
|
| ini_configobj.h | | ini_configobj.h | |
| | | | |
| skipping to change at line 131 | | skipping to change at line 131 | |
| * @defgroup structures Structures | | * @defgroup structures Structures | |
| * | | * | |
| * All structures used in the interface should be treated as internal opaqu
e objects. | | * All structures used in the interface should be treated as internal opaqu
e objects. | |
| * | | * | |
| * @{ | | * @{ | |
| * | | * | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| | | * @defgroup bomType Types of configutration file encodings | |
| | | * | |
| | | * Constants that define how configuration file is encoded. | |
| | | * | |
| | | * @{ | |
| | | */ | |
| | | /** Enumeration of the encoding types. */ | |
| | | | |
| | | enum index_utf_t { | |
| | | INDEX_UTF32BE = 0, /**< The file is encoded in 'big-endian' 32-bit */ | |
| | | INDEX_UTF32LE = 1, /**< The file is encoded in 'little-endian' 32-bit | |
| | | */ | |
| | | INDEX_UTF16BE = 2, /**< The file is encoded in 'big-endian' 16-bit */ | |
| | | INDEX_UTF16LE = 3, /**< The file is encoded in 'little-endian' 16-bit | |
| | | */ | |
| | | INDEX_UTF8 = 4, /**< The file is encoded in standard UTF8 but has B | |
| | | OM */ | |
| | | INDEX_UTF8NOBOM = 5 /**< The file is encoded in standard UTF8 without B | |
| | | OM */ | |
| | | }; | |
| | | | |
| | | /** | |
| | | * @} | |
| | | */ | |
| | | | |
| | | /** | |
| * @defgroup errorlevel Error tolerance constants | | * @defgroup errorlevel Error tolerance constants | |
| * | | * | |
| * Constants in this section define what to do if | | * Constants in this section define what to do if | |
| * error or warning encountered while parsing the INI file. | | * error or warning encountered while parsing the INI file. | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
| /** Enumeration of error levels. */ | | /** Enumeration of error levels. */ | |
| enum ERR_LEVEL { | | enum ERR_LEVEL { | |
| INI_STOP_ON_ANY = 0, /**< Fail if any problem is detected. */ | | INI_STOP_ON_ANY = 0, /**< Fail if any problem is detected. */ | |
| | | | |
| skipping to change at line 376 | | skipping to change at line 398 | |
| INI_GET_FIRST_VALUE, /**< Get the first value (default). */ | | INI_GET_FIRST_VALUE, /**< Get the first value (default). */ | |
| INI_GET_NEXT_VALUE, /**< Look for the next value in the section */ | | INI_GET_NEXT_VALUE, /**< Look for the next value in the section */ | |
| INI_GET_LAST_VALUE /**< Look for the last value in the section */ | | INI_GET_LAST_VALUE /**< Look for the last value in the section */ | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
|
| | | * @defgroup augment Constants and structures related to augmentation. | |
| | | * | |
| | | * @{ | |
| | | */ | |
| | | | |
| | | /** Structure to pass access check parameters to augmentation function. | |
| | | * | |
| | | */ | |
| | | struct access_check { | |
| | | uint32_t flags; /**< Define what to check. | |
| | | * One can check file | |
| | | * permissions with mask, | |
| | | * uid, and gid of the file. | |
| | | * See \ref accesscheck constants. | |
| | | */ | |
| | | uid_t uid; /**< Expected uid of the file. */ | |
| | | gid_t gid; /**< Expected gid of the file.*/ | |
| | | mode_t mode; /**< Expected mode of the file. */ | |
| | | mode_t mask; /**< Mask to use in the mode check. | |
| | | * Mask is always adjusted to | |
| | | * include at least S_IRWXU, | |
| | | * S_IRWXG and S_IRWXO. | |
| | | */ | |
| | | }; | |
| | | | |
| | | /** Enumeration of augmentation modes. */ | |
| | | enum augmode { | |
| | | INI_AUG_ANY = 0, /**< Allow any augmentation. */ | |
| | | INI_AUG_ADD = 1, /**< Allow only new sections. */ | |
| | | INI_AUG_OVER = 2 /**< Allow section updates. */ | |
| | | }; | |
| | | | |
| | | /** | |
| | | * @} | |
| | | */ | |
| | | | |
| | | /** | |
| * @brief Name of the default section. | | * @brief Name of the default section. | |
| * | | * | |
| * This is the name of the implied section where orphan key-value | | * This is the name of the implied section where orphan key-value | |
| * pairs will be put. | | * pairs will be put. | |
| */ | | */ | |
| #define INI_DEFAULT_SECTION "default" | | #define INI_DEFAULT_SECTION "default" | |
| | | | |
| /** | | /** | |
| * @defgroup structures Structures | | * @defgroup structures Structures | |
| * @{ | | * @{ | |
| | | | |
| skipping to change at line 407 | | skipping to change at line 466 | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup ini_core Core interface functions | | * @defgroup ini_core Core interface functions | |
| * | | * | |
| * Functions in this section allow manipulation with the configuration file
, | | * Functions in this section allow manipulation with the configuration file
, | |
| * parsing data from the configuration file and storing it in a configurati
on | | * parsing data from the configuration file and storing it in a configurati
on | |
| * object, merging configuration objects and other operations. | | * object, merging configuration objects and other operations. | |
| * | | * | |
|
| * This interface is currently incomplete as it does not allow: | | * For functions to create or alter configuration object in memory | |
| * - constructing configuration in memory | | * see \ref ini_mod. | |
| * - altering existing configuration by adding, modifying or removing secti | | | |
| ons | | | |
| * and keys. | | | |
| * | | * | |
| * @{ | | * @{ | |
| * | | * | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @brief Create a configuration object. | | * @brief Create a configuration object. | |
| * | | * | |
| * Allocates an object that will store configuration data. | | * Allocates an object that will store configuration data. | |
| * Configuration object is populated by parsing a file. | | * Configuration object is populated by parsing a file. | |
| | | | |
| skipping to change at line 544 | | skipping to change at line 601 | |
| * @brief Close configuration file and free all data | | * @brief Close configuration file and free all data | |
| * | | * | |
| * Closes file and frees the context. | | * Closes file and frees the context. | |
| * | | * | |
| * @param[in] file_ctx Configuration file object. | | * @param[in] file_ctx Configuration file object. | |
| * | | * | |
| */ | | */ | |
| void ini_config_file_destroy(struct ini_cfgfile *file_ctx); | | void ini_config_file_destroy(struct ini_cfgfile *file_ctx); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Save configuration in a backup configuration file | |
| | | * | |
| | | * Creates a backup version of the data in a given configuration file. | |
| | | * It is expected that file context was created by some open or reopen | |
| | | * function first. Then the caller can make this call to save the data | |
| | | * aside before parsing the configuration file and making changes to it. | |
| | | * | |
| | | * The caller can specify a backup directory to save the file in. | |
| | | * If directory is not specified then a current working directory will | |
| | | * be used. If the directory is invalid or caller does not have access to i | |
| | | t | |
| | | * an error will be returned. | |
| | | * | |
| | | *>The template specifies the file name to use for the backup. | |
| | | *>For example: | |
| | | *> my_file.conf.%d.save | |
| | | *> my_file%d.conf.bak | |
| | | *>The template can contain only one '%d' placeholder. This placeholder | |
| | | * will be replaced by a number. If previously created backup files | |
| | | * are found in the given directory. The function will start with 1 and wil | |
| | | l | |
| | | * try to find an available unused file name in the given directory | |
| | | * up until it reaches the limit specified in the max_num argument. | |
| | | * Function will return EEXIST if it runs out of attempts to save the file. | |
| | | * | |
| | | * The caller can optionally pass an access structure. The access structure | |
| | | * would specify what mode and ownership to use for the newly created file. | |
| | | * If the access structure is not specified the access data of the original | |
| | | * file context will be used. If file object does not have stats explicitly | |
| | | * read at the time when the object is created then the stats will be colle | |
| | | cted | |
| | | * but not saved. If the file was a memory mapped file and no access | |
| | | * structure is passed in, the function will use effective UID and GID of t | |
| | | he | |
| | | * running process and mode will be set to: S_IFREG | S_IRUSR | S_IWUSR | |
| | | * | |
| | | * @param[in] file_ctx File context of the file to backup. | |
| | | * @param[in] backup_dir Path to backup directory. Can be NULL. | |
| | | * @param[in] backup_tpl File name template with %d placeholder. | |
| | | * @param[in] backup_access Optional access overwrite structure. | |
| | | * See \ref access_check for more details. | |
| | | * @param[in] max_num Maximum number of retries to try to cre | |
| | | ate | |
| | | * a specific backup file. | |
| | | * | |
| | | * @return 0 - Success. | |
| | | * @return EINVAL - Invalid parameter. | |
| | | * @return EIXIST - All possible backup file names are already taken. | |
| | | * @return ENOMEM - No memory. | |
| | | * | |
| | | * Function can return other errors that standard libc functions line open, | |
| | | * chmod, and chown return. | |
| | | */ | |
| | | int ini_config_file_backup(struct ini_cfgfile *file_ctx, | |
| | | const char *backup_dir, | |
| | | const char *backup_tpl, | |
| | | struct access_check *backup_access, | |
| | | unsigned max_num); | |
| | | | |
| | | /** | |
| | | * @brief Change permissions and ownership of the file | |
| | | * | |
| | | * Function changes access mode and permissions of the file associated | |
| | | * with the given context. If there is no file associated with the context | |
| | | * because the context is created using a memory buffer, then the function | |
| | | * will return an error EINVAL. | |
| | | * | |
| | | * @param[in] file_ctx File context of the file to change acce | |
| | | ss. | |
| | | * @param[in] new_access Structure that defines what access shou | |
| | | ld | |
| | | * be set on the file. | |
| | | * See \ref access_check for more details. | |
| | | * | |
| | | * @return 0 - Success. | |
| | | * @return EINVAL - Invalid parameter. | |
| | | * | |
| | | * Function can return other errors that standard chmod and chown | |
| | | * functions return. | |
| | | */ | |
| | | int ini_config_change_access(struct ini_cfgfile *file_ctx, | |
| | | struct access_check *new_access); | |
| | | | |
| | | /** | |
| | | * @brief Save configuration in a file | |
| | | * | |
| | | * Function is a wrapper around \ref ini_config_save_as with | |
| | | * argument filename as NULL. | |
| | | * | |
| | | * For more information see \ref ini_config_save_as. | |
| | | */ | |
| | | int ini_config_save(struct ini_cfgfile *file_ctx, | |
| | | struct access_check *new_access, | |
| | | struct ini_cfgobj *ini_config); | |
| | | | |
| | | /* Save configuration in a file using existing context but with a new name | |
| | | */ | |
| | | /** | |
| | | * @brief Save configuration with a new name. | |
| | | * | |
| | | * Function uses an existing file context but a new file name. | |
| | | * The file context will be used to perform operation to save file. | |
| | | * By default the ownership, mode and BOM of the new file will be derived | |
| | | * from the existing context. The rest of the context will be reinitialized | |
| | | . | |
| | | * Configuration will be serialized and saved in the file using encoding | |
| | | * specified by BOM type. The BOM prefix will also be added if needed. | |
| | | * After saving the file the function initializes the context and reads the | |
| | | * file back. At this moment the file context is ready for the parsing | |
| | | * again. | |
| | | * | |
| | | * @param[in] file_ctx File context to use for saving. | |
| | | * @param[in] filename Name of the file to save into. If NULL | |
| | | * the file name of the context will be us | |
| | | ed. | |
| | | * If the context was originally created | |
| | | * as a memory mapped configuration buffer | |
| | | * and filename is NULL the function will | |
| | | * return error EINVAL. | |
| | | * @param[in] new_access Structure that defines what access shou | |
| | | ld | |
| | | * be set on the file. | |
| | | * See \ref access_check for more details. | |
| | | * @param[in] ini_config Configuration to save. | |
| | | * | |
| | | * @return 0 - Success. | |
| | | * @return EINVAL - Invalid parameter. | |
| | | * | |
| | | * Function can return other errors that standard open, chmod and chown | |
| | | * functions return. | |
| | | */ | |
| | | int ini_config_save_as(struct ini_cfgfile *file_ctx, | |
| | | const char *filename, | |
| | | struct access_check *new_access, | |
| | | struct ini_cfgobj *ini_config); | |
| | | | |
| | | /** | |
| | | * @brief Return the encoding indicator. | |
| | | * | |
| | | * When the file object is created the configuration data is inspected for | |
| | | * encoding indicator called BOM. This function returns a constant that | |
| | | * indicates what type of BOM was detected. | |
| | | * | |
| | | * @param[in] file_ctx File context. | |
| | | * | |
| | | * Function returns the constant of type enum index_utf_t. | |
| | | */ | |
| | | enum index_utf_t ini_config_get_bom(struct ini_cfgfile *file_ctx); | |
| | | | |
| | | /** | |
| | | * @brief Set the encoding indicator. | |
| | | * | |
| | | * When the file object is created the configuration data is inspected for | |
| | | * encoding indicator called BOM. The BOM indicator is recorded in the file | |
| | | * object and used when the file is saved. If the caller wants to change | |
| | | * the encoding before saving he can use this function to alter the BOM typ | |
| | | e. | |
| | | * | |
| | | * @param[in] file_ctx File context. | |
| | | * @param[in] bom BOM type indicator to set. | |
| | | * | |
| | | * | |
| | | * @return 0 - Success. | |
| | | * @return EINVAL - Invalid parameter. | |
| | | */ | |
| | | int ini_config_set_bom(struct ini_cfgfile *file_ctx, enum index_utf_t bom); | |
| | | | |
| | | /** | |
| * @brief Check parsing errors count | | * @brief Check parsing errors count | |
| * | | * | |
| * Query the configuration file object about | | * Query the configuration file object about | |
| * how many parsing errors were found during last | | * how many parsing errors were found during last | |
| * parsing operation. | | * parsing operation. | |
| * | | * | |
| * @param[in] ini_config Configuration object. | | * @param[in] ini_config Configuration object. | |
| * | | * | |
| * @return Number of errors. | | * @return Number of errors. | |
| */ | | */ | |
| | | | |
| skipping to change at line 775 | | skipping to change at line 988 | |
| * @return 0 - Success. | | * @return 0 - Success. | |
| * @return EINVAL - Invalid parameter. | | * @return EINVAL - Invalid parameter. | |
| * @return ENOMEM - No memory. | | * @return ENOMEM - No memory. | |
| */ | | */ | |
| int ini_config_merge(struct ini_cfgobj *first, | | int ini_config_merge(struct ini_cfgobj *first, | |
| struct ini_cfgobj *second, | | struct ini_cfgobj *second, | |
| uint32_t collision_flags, | | uint32_t collision_flags, | |
| struct ini_cfgobj **result); | | struct ini_cfgobj **result); | |
| | | | |
| /** | | /** | |
|
| | | * @brief Augment configuration | |
| | | * | |
| | | * Function merges the main configuration file | |
| | | * with the configuration file snippets | |
| | | * read from a specified directory. | |
| | | * | |
| | | * @param[in] base_cfg A configuration object | |
| | | * that will be augmented. | |
| | | * @param[in] path Path to a directory where | |
| | | * configuration snippets | |
| | | * will be read from. | |
| | | * @param[in] patterns List of regular expressions | |
| | | * that the name of a snippet file | |
| | | * has to match to be considered | |
| | | * for merge. | |
| | | * @param[in] sections List of regular expressions | |
| | | * that the section names in the snippet | |
| | | * file need to match. If file contains | |
| | | * sections that do not match any patterns | |
| | | * the file is skipped and error is recorded. | |
| | | * @param[in] check_perm Pointer to structure that | |
| | | * holds criteria for the | |
| | | * access check. | |
| | | * @param[in] error_level Flags that control actions | |
| | | * in case of parsing error in a snippet file. | |
| | | * @param[in] collision_flags These flags control how the potential | |
| | | * collisions between keys and sections | |
| | | * within the snippet file will be handled. | |
| | | * For more information | |
| | | * see collision flag definitions. | |
| | | * @param[in] parse_flags Flags that control parsing process, | |
| | | * for example how to handle spaces at | |
| | | * the beginning of the line. | |
| | | * @param[in] merge_flags Flags that control handling | |
| | | * of the duplicate sections or keys | |
| | | * during merging of the snippets. | |
| | | * They are different from the collision flags | |
| | | * because duplicate sections and keys inside | |
| | | * are snippets most likely will be handled as | |
| | | * 'last value wins' while during merge | |
| | | * the attempt to overwrite | |
| | | * a specific section might be treated as | |
| | | * an error. | |
| | | * @param[out] result_cfg A new configuration object, | |
| | | * the result of the merge. | |
| | | * @param[out] error_list List of strings that | |
| | | * contains all encountered | |
| | | * errors. | |
| | | * It can be NULL, in this case list of errors | |
| | | * is not populated. | |
| | | * @param[out] success_list List of strings that | |
| | | * contains file names of snippets that were | |
| | | * successfully merged. | |
| | | * It can be NULL, in this case list of files | |
| | | * is not populated. | |
| | | * | |
| | | * @return 0 - Success. | |
| | | * @return EINVAL - Invalid parameter. | |
| | | * @return ENOMEM - No memory. | |
| | | */ | |
| | | int ini_config_augment(struct ini_cfgobj *base_cfg, | |
| | | const char *path, | |
| | | const char *patterns[], | |
| | | const char *sections[], | |
| | | struct access_check *check_perm, | |
| | | int error_level, | |
| | | uint32_t collision_flags, | |
| | | uint32_t parse_flags, | |
| | | uint32_t merge_flags, | |
| | | struct ini_cfgobj **result_cfg, | |
| | | struct ref_array **error_list, | |
| | | struct ref_array **success_list); | |
| | | | |
| | | /** | |
| * @brief Set the folding boundary | | * @brief Set the folding boundary | |
| * | | * | |
| * Set the folding boundary for multiline values. | | * Set the folding boundary for multiline values. | |
| * Use before serializing and saving to a file if the | | * Use before serializing and saving to a file if the | |
| * default boundary of 80 characters does not work for you. | | * default boundary of 80 characters does not work for you. | |
| * | | * | |
| * @param[in] ini_config Configuration object. | | * @param[in] ini_config Configuration object. | |
| * @param[in] boundary Wrapping boundary. | | * @param[in] boundary Wrapping boundary. | |
| * | | * | |
| * @return 0 - Success. | | * @return 0 - Success. | |
| | | | |
| skipping to change at line 807 | | skipping to change at line 1094 | |
| * @param[in] ini_config Configuration object. | | * @param[in] ini_config Configuration object. | |
| * @param[out] sbobj Serialized configuration. | | * @param[out] sbobj Serialized configuration. | |
| * | | * | |
| * @return 0 - Success. | | * @return 0 - Success. | |
| * @return EINVAL - Invalid parameter. | | * @return EINVAL - Invalid parameter. | |
| * @return ENOMEM - No memory. | | * @return ENOMEM - No memory. | |
| */ | | */ | |
| int ini_config_serialize(struct ini_cfgobj *ini_config, | | int ini_config_serialize(struct ini_cfgobj *ini_config, | |
| struct simplebuffer *sbobj); | | struct simplebuffer *sbobj); | |
| | | | |
|
| /* TODO: Functions that add, modify or delete sections and values in | | /* Functions that add, modify or delete sections and values in | |
| * the configuration object. | | * the configuration object can be found in section \ref ini_mod. | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @} | | * @} | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @defgroup ini_section_and_attr Section and attribute management | | * @defgroup ini_section_and_attr Section and attribute management | |
| * | | * | |
| * Functions in this section allow getting the lists of | | * Functions in this section allow getting the lists of | |
| | | | |
End of changes. 6 change blocks. |
| 7 lines changed or deleted | | 309 lines changed or added | |
|