Instead of using and checking malloc'd error strings formatted with asprintf and passed through a pointer in function arguments, use a global thread-local statically allocated error buffer with functions to set and get it.
This is more efficient, less error-prone, and easier to use than the old method, especially now that NM is larger (meaning that errors are returned through multiple layers) and parts of it are re-used in other things.
* Split browser actions from nickel_extra into nickel_browser
* Improved extensibility of nickel_setting action
Instead of nickel_setting:<setting> for toggling a setting and
nickel_setting:<setting>:<bool> for setting it explicitly, use
nickel_setting:<action>:<setting>.
Instead of returning a bool from `nm_global_config_update` indicating whether
the menu items were modified, return an int indicating the current config
revision which can then be compared against one stored as a property of the
menu.
This issue was found by @jackiew1. See #56 for more details.
This fixes an issue in ee0eb7ccf7 (#47).
Menu:
* Implemented menu item updating based on config file creation/deletion/modtime.
* Fixed ordering and separators for dynamically added actions.
* Simplified separator property setting.
* Fixed issue with item ordering on every second update (it keeps track by the item index based on the original menu, which changes after we add our items, so we actually need to remove our items before we find the item to prepend our new items to).
* Note: generators can't trigger updates yet, and are only updated when the config changes.
Config:
* Split config parsing and scanning into multiple steps.
* No more memory leaks on error.
* Properly handle memory allocation errors.
* Cleaner code.
* Less chance of making mistakes when adding features in the future.
* Also made if statements easier to read.
* Refactored config state and list management into separate functions.
* Extracted parsers for each config type into separate functions.
* Cleaned up whitespace.
* Rearranged variables.
* Fixed a few memory leaks and use-after-free issues for errors in the config parser.
* Fixed use-after-free of line in config parser.
* Moved config file filtering into scandir.
See #47 for details.
* Switched to new method for nickel_extras:web_browser.
* Added support for fw versions less than 4.11.11911 for nickel_extras:web_browser action.
* Added modal, URL, and CSS options to nickel_extras:web_browser.
* Implemented menu item generators (closes#4)
* Initialized sz to -1 for nm_generator_do
* Cleaned up extra semicolon in config.c
* Fixed typo in generator size check
* Switch to an enum for kfmon ipc errors codes.
* Also switch to a case switch in nm_kfmon_return_handler.
* Comment out the default case to have -Wswitch shout at you if you missed
one.
* Simplify pointer chasing loop.
* Explicitly mention KFMON_IPC_EAGAIN in the return_handler.
* Simplify some more.
* Make GCC happy.
* Slightly less convoluted.
* Alphabetical header order.
* Allow whitespace in cmd_spawn/cmd_output args
* Trim cmd no matter the content of the extra option field
* Don't mistake a stray colon in the actual command for a field separator
* Simplified quiet option for cmd_spawn, fixed up parsing
* Fixed case where option could start with, but not actually be, quiet.
* Fixed restoring the original command when no option is specified.
* Simplified code.
* Fixed typos in comments
Co-authored-by: Patrick Gaskin <patrick@pgaskin.net>