| 2006-09-08 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/option.c (nih_option_help): Allow the usage string to be |
| customised. |
| (nih_option_set_usage): Using this function. |
| * nih/option.h: Update. |
| * nih/tests/test_option.c (test_help): Test the usage string. |
| |
| * nih/main.c (nih_main_daemonise): Use program_name for the pid file. |
| * nih/main.h: Update. |
| |
| * nih/main.c (nih_main_daemonise): Add a daemonise function, |
| pretty standard really. |
| * nih/main.h: Update. |
| |
| 2006-09-07 Scott James Remnant <scott@netsplit.com> |
| |
| * AUTHORS: Mention the ChangeLog file. |
| |
| 2006-09-04 Scott James Remnant <scott@netsplit.com> |
| |
| * README: Add some documentation for the curious. |
| |
| * nih/file.c (nih_file_add_watch): Set nih_file_remove_watch as |
| the default destructor so that nih_free can be called or work in |
| a tree. |
| (nih_file_remove_watch): Modify to not call nih_free and work if |
| called multiple times. |
| |
| * nih/signal.c (nih_signal_set_default, nih_signal_set_ignore): |
| Set flags to zero when defaulting or ignoring signals. |
| * nih/tests/test_signal.c (test_set_default, test_set_ignore) |
| (test_reset): Modify test cases appropriately. |
| |
| * nih/hash.h: Add missing attribute for nih_hash_new |
| * nih/list.h: Add missing attribute for nih_list_new |
| |
| 2006-09-01 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/option.c (nih_option_group_help): Cast linelen to not induce |
| a warning. |
| |
| 2006-08-31 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_loop_interrupt): Always initialise the |
| interrupt pipe. |
| (nih_main_loop_init): Move interrupt pipe initialisation to here |
| so that it's always available. |
| (nih_main_loop): Drop the extra call to nih_signal_poll(). |
| |
| * nih/option.c (nih_option_get_short, nih_option_get_long): Allow |
| catch-all options. |
| * nih/tests/test_option.c (test_parser): Test catch-all options. |
| |
| * TODO: Update. |
| |
| * nih/option.c (nih_option_handle_arg): Free any existing option |
| value. |
| |
| 2006-08-30 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/option.c (nih_option_debug): Add a hidden --debug option that |
| sets the logging level up really high. |
| (nih_option_handle): Just compare the names rather than offset |
| within a list that can change. |
| * nih/option.h: Update. |
| * nih/tests/test_option.c (test_debug): Check that it works. |
| |
| * nih/option.c (nih_option_group_help): Output "Options" where we |
| only have the one group. |
| |
| * nih/option.c (nih_option_group_help): Don't output options without |
| help strings. |
| * nih/tests/test_option.c (test_help): Update. |
| |
| 2006-08-25 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/io.c (nih_io_watcher): Clean up the handling of the out of |
| memory condition while extending the buffer so that we just return |
| to be called again rather than end up performing some random action. |
| |
| 2006-08-24 Scott James Remnant <scott@netsplit.com> |
| |
| * nihify (src_dir): Also copy m4/Makefile.am |
| |
| * nih/file.c (nih_file_remove_watch): Raise the error before |
| performing other actions so errno is not lost. |
| |
| * nih/io.c (nih_io_watcher): Fix a pretty critical bug, we weren't |
| saving the value of errno so it was usually zero by the time we |
| looked at it. |
| |
| * nih/logging.c (nih_logger_syslog): Useful alternative to |
| nih_logger_printf. |
| * nih/logging.h: Update. |
| |
| 2006-08-23 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/tests/test_string.c: Add missing free calls. |
| |
| * nih/tests/test_io.c (test_watcher): Silence the error message. |
| * nih/tests/test_option.c (test_parser): Add some forgotten calls |
| to nih_free |
| |
| * nih/main.c (nih_main_init_full): Free the package string when |
| overwriting it. |
| |
| * nih/tests/test_logging.c: Keep a copy of the last message |
| otherwise we're reading free'd memory (again). |
| |
| * nih/tests/test_list.c: Memory cleanups. |
| |
| * nih/signal.c (nih_signal_set_default, nih_signal_set_ignore): |
| Don't initialise the signals list, there's no need. |
| |
| * nih/tests/test_hash.c: Various missing calls to nih_free. |
| |
| * nih/file.c (nih_file_remove_watch): Fix another wrong call to |
| nih_free. |
| |
| * nih/tests/test_child.c (test_poll): Free the watcher. |
| |
| * nih/file.c (nih_file_remove_watch): Remove from the containing |
| list before freeing. |
| * nih/tests/test_file.c (my_watcher): Make sure we copy the name |
| as it will be freed by the time we get back to the test. |
| |
| * nih/list.c (nih_list_free): Don't throw away the destructor |
| return value. |
| |
| * nih/tests/test_error.c: Further missing calls to nih_free |
| |
| * nih/tests/test_alloc.c: Correct a few missing nih_free's |
| |
| * nih/file.c (nih_file_map): Correct a thinko, have to mask |
| flags by O_ACCMODE and compare for equality to extract the open |
| access mode. |
| |
| 2006-08-22 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/file.c (nih_file_map, nih_file_unmap): Add an easier to use |
| wrapper around mmap() when we just want the file in memory. |
| * nih/file.h: Add prototypes. |
| * nih/tests/test_file.c (test_map): Test the functions. |
| |
| 2006-08-21 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/file.c: Wrap the inotify syscalls with something a little |
| friendlier to deal with. |
| * nih/file.h: Typedefs, structures and prototypes. |
| * nih/libnih.h: Include file.h |
| * nih/io.h: Correct typo in argument name. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link file.c |
| (nihinclude_HEADERS): Install file.h |
| (TESTS): Build and run file test cases |
| (test_file_SOURCES, test_file_LDFLAGS, test_file_LDADD): Details |
| for file test case binary |
| |
| 2006-08-19 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/option.c (nih_option_parser): Finish option processing when |
| the first non-option argument is found (command-mode) |
| * nih/option.h: Update. |
| * nih/tests/test_option.c (test_parser): Test command-mode. |
| |
| * nih/option.c: Implement a simple, yet flexible option parser. |
| * nih/option.h: Typedefs, structures and prototypes. |
| * nih/libnih.h: Include option.h |
| * nih/tests/test_option.c: Test it all pretty thoroughly. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link option.c |
| (nihinclude_HEADERS): Install option.h |
| (TESTS): Run the option test cases |
| (test_option_SOURCES, test_option_LDFLAGS, test_option_LDADD): |
| Details for the option test case binary. |
| * TODO: Update. |
| |
| * nih/string.c (nih_str_wrap): Implement a function to wrap a |
| string into the desired number of characters wide. |
| * nih/string.h: Update. |
| * nih/tests/test_string.c (test_str_wrap): Test the new function |
| to make sure it does the right things. |
| |
| 2006-08-18 Scott James Remnant <scott@netsplit.com> |
| |
| * TODO: Update. |
| |
| * nih/main.h (nih_main_init_gettext): Macro that expands to the |
| usual gettext initialisation spiel if ENABLE_NLS is set, or nothing |
| if not. |
| (nih_main_init): Expand nih_main_init_gettext as well, we almost |
| always want to do that, after all. |
| * nih/macros.h: Include locale.h if ENABLE_NLS is set, as that |
| contains setlocale, amongst other things. |
| * nih/tests/test_main.c (test_init_gettext): Check the macro does |
| the right things. |
| |
| * nih/io.h (NihIoCb): Rename to NihIoWatcher. |
| (NihIoReadCb): Rename to NihIoReader. |
| (NihIoCloseCb): Rename to NihIoCloseHandler. |
| (NihIoErrorCb): Rename to NihIoErrorHandler. |
| (NihIoWatch): Rename callback member to watcher. |
| (NihIo): Rename read_cb member to reader, close_cb member to |
| close_handler and error_cb member to error_handler. |
| * nih/io.c: Update to use new names. |
| (nih_io_cb): Rename to nih_io_watcher. |
| * nih/tests/test_io.c: Update to use new names. |
| |
| * TODO: Update. |
| |
| 2006-08-16 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_loop_add_func): Add a loop function |
| (nih_main_loop): Run the loop functions. |
| * nih/main.h (NihMainLoopCb, NihMainLoopFunc): Typedefs and |
| structures for main loop callbacks. |
| * nih/tests/test_main.c (test_main_loop_add_func): Check that |
| the loop function is allocated correctly. |
| (test_main_loop): Make sure it actually gets called. |
| |
| * nih/io.c (nih_io_cb): Add a couple of check assertions. |
| |
| * nih/macros.h (N_): Should be defined to be a no-op. |
| |
| 2006-08-14 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c (nih_realloc): Yet another fix to realloc, we |
| forgot to reinitialise our entry in the parent's children list in |
| the case of no parent. After fixing this and tracing the code, I |
| realised that the previous fix was inelegant and there is a way to |
| deal with children without modifying the pointers until after the |
| reallocation. Documented the reasoning in the function. |
| |
| * nih/io.c (nih_io_reopen): Report on the error rather than just |
| suppressing it. |
| (nih_io_error): Likewise, report on the error. |
| |
| 2006-08-12 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_loop_close): Drop this function |
| (nih_main_loop): Instead mark them close on exec. |
| * nih/main.h: Update. |
| |
| * nih/main.c (nih_main_loop): Change the main loop to use select |
| instead of poll, as its semantics are a lot easier to deal with. |
| We also use allow select to be interrupted by writing to a pipe |
| from the signal handlers, for when Linux gets around to supporting |
| SA_RESTART properly. |
| (nih_main_loop_interrupt): Write to the pipe so the select call gets |
| interrupted. |
| (nih_main_loop_exit): Interrupt the main loop, in case we're |
| waiting forever. |
| (nih_main_loop_close): Close the interrupt pipe, used in children. |
| * nih/main.h: Update. |
| * nih/io.c (nih_io_add_watch): Change type of events parameter. |
| (nih_io_poll_fds): Remove this function. |
| (nih_io_select_fds): And replace with this that sets the select |
| file descriptor sets instead. |
| (nih_io_handle_fds): Now receives select file descriptor sets, and |
| becomes rather more obvious in the process. Restore the previous |
| behaviour where a callback isn't called unless requests events |
| occur. |
| (nih_io_reopen): Always poll for reading so we pick up errors. |
| (nih_io_cb): Change type of events parameter and events settings. |
| (nih_io_write): Change event settings. |
| * nih/io.h: Update. |
| (NihIoEvents): replace the previous poll events with a new enum. |
| * nih/signal.c (nih_signal_handler): Interrupt the select call in |
| the main loop. |
| * nih/tests/test_io.c: Update with new test cases. |
| * nih/tests/test_child.c: Use select() rather than poll() |
| |
| * nih/tests/test_io.c (test_buffer_push, test_write): Correct |
| uninitialised return value. |
| |
| * nih/main.c (nih_main_loop): Correct a memory leak, we forgot |
| to clean up the poll fds list. |
| |
| * nih/io.c (nih_io_handle_fds): Always call the callback, even if |
| unexpected events happen, otherwise we'll miss ERR, HUP, etc. |
| (nih_io_shutdown): Allow a socket to be closed lazily, so we can |
| send (or receive) a whole bunch of stuff and expect the structure to |
| go away afterwards. |
| (nih_io_cb): If the shutdown flag has been marked and we run out |
| of things in either buffer, act as if one end was closed. |
| (nih_io_reopen): Mark sockets as not shutdown by default. |
| * nih/io.h: Update. |
| * nih/tests/test_io.c (test_shutdown): Test behaviour. |
| (test_handle_fds): Take out some of the tests due to changed |
| behaviour. While "clever" I think overall this is undesirable. |
| |
| * nih/io.c (nih_io_set_cloexec): Function to set the FD_CLOEXEC flag. |
| * nih/io.h: Update. |
| * nih/tests/test_io.c (test_set_cloexec): Test the function. |
| |
| 2006-08-11 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.h, nih/child.h, nih/hash.h, nih/logging.h, nih/signal.h, |
| nih/timer.h: Document arguments to function pointers. |
| |
| * nih/io.c: Add a whole bunch of code to provide us with a high- |
| throughput, async file/socket layer; largely copied from the |
| dircproxy code (well, it works!). This allows read and write calls |
| to happen inside the main loop based on whenever poll thinks either |
| is possible, while user space can just write what it likes or get |
| called when there's data in the recv buffer. |
| * nih/io.h: Add the new typedefs, structures and prototypes. |
| * nih/tests/test_io.c: Lots of test cases for this stuff. |
| |
| 2006-08-10 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c (nih_realloc): Fix a fairly critical bug, we weren't |
| dealing with the fact that the children list head can move; |
| do some fancy shifting to make that work. |
| |
| * nih/string.c (nih_str_split): Add a function to split a string |
| based on delimiters into an array. |
| * nih/string.h: Update. |
| * nih/tests/test_string.c (test_str_split): Test the new function. |
| |
| 2006-08-09 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/tests/test_child.c (test_poll): Add extra sleep calls for |
| safety. |
| |
| * nih/libnih.h: Include errors.h |
| |
| 2006-08-04 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/errors.h: Include errno.h for helpfulness. |
| |
| 2006-08-03 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/child.c (nih_child_add_watch): Also takes a parent now. |
| * nih/child.h: Update. |
| * nih/tests/test_child.c: Update. |
| |
| * nih/io.c (nih_io_add_watch): And once more, with feeling; takes |
| a parent for the watch. |
| * nih/io.h: Update. |
| * nih/tests/test_io.c: Update. |
| |
| * nih/signal.c (nih_signal_add_callback): Give this the same treatment, |
| it takes the parent for the signal callback. |
| * nih/signal.h: Update. |
| * nih/tests/test_signal.c: Update. |
| |
| * nih/timer.c (nih_timer_add_timeout, nih_timer_add_periodic) |
| (nih_timer_add_scheduled): Use nih_alloc properly by taking a parent |
| for the timer object and setting a destructor on it so that it's |
| automatically removed when the parent is freed. |
| * nih/timer.h: Update. |
| * nih/tests/test_timer.c: Update function calls. |
| * nih/tests/test_main.c (test_main_loop): Update also. |
| |
| * nih/list.c (nih_list_destructor): Add a destructor function that |
| just cuts the entry out of the list in preperation for being freed. |
| * nih/list.h: Update. |
| * nih/tests/test_list.c (test_destructor): Test the behaviour of |
| the new function. |
| |
| * nih/tests/test_error.c: Include fixes. |
| |
| 2006-08-02 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/signal.c (nih_signal_set_handler, nih_signal_set_default) |
| (nih_signal_set_ignore): Reset sa_flags so that we don't pass |
| uninitialised data for SIGALRM. |
| (nih_signal_reset): Add function to reset signals back to their |
| default state. |
| * nih/signal.h: Update. |
| * nih/tests/test_signal.c (test_reset): Add test case. |
| |
| * nih/error.c (nih_error_raise_system): Be a lot more careful in |
| this function! Save the value of errno in case we overwrite it |
| and call nih_error_init() |
| |
| * nih/signal.c (nih_signal_set_handler): Add the SA_NOCLDSTOP |
| signal for SIGCHLD. |
| |
| * nih/main.c (nih_main_loop): Drop the code that masked out the |
| child signal, it was inherently racy and there's no particular |
| reason to do it anyway since we use SA_RESTART in signal.c for |
| most things. |
| |
| * nih/signal.c (nih_signal_set_handler, nih_signal_set_default) |
| (nih_signal_set_ignore): don't set SA_RESTART for SIGALRM. |
| |
| * nih/signal.c (nih_signal_set_handler, nih_signal_set_default) |
| (nih_signal_set_ignore): use nih_return_system_error to make the |
| code rather cleaner. |
| |
| * nih/error.h (nih_return_error): Add missing doc for retval |
| (nih_return_system_error): Add additional useful function. |
| * nih/tests/test_error.c (test_return_system_error): Add test |
| case for the new macro. |
| |
| * nih/child.c (nih_child_poll): Convert to use waitid() so that |
| we can obtain the information about the dead child without reaping |
| it until we're done processing; useful because it means /proc/$PID |
| and the child itself is still around during the handlers. |
| * nih/child.h (NihReaper): Gains a new third argument that indicates |
| whether the child exited normally or was killed. |
| * nih/tests/test_child.c (test_poll): Update. |
| |
| * nihify: Add a few useful sanity checks so that it works with |
| relative paths and already-nihified directories. |
| |
| * m4/misc.m4: Remove older force code. |
| |
| * TODO: Updated. |
| |
| * m4/Makefile.am (dist_aclocal_DATA): Distribute misc.m4, long |
| missed. |
| |
| * nihify: Add useful script for symlinking into source trees until |
| we intend to get released. |
| |
| * HACKING: Correct typo (our -> out) |
| |
| 2006-07-28 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_term_signal): Handy signal callback. |
| * nih/main.h: Update. |
| * nih/tests/test_main.c (my_timeout): Cheat and ensure the latest |
| exit status is used. |
| |
| * nih/main.c (nih_main_loop): Implement a main loop by calling |
| various other functions in the right manner. |
| (nih_main_loop_exit): Function to break the main loop. |
| * nih/main.h: Update. |
| * nih/tests/test_main.c (test_main_loop): Add a trivial test case |
| for the main loop, it's damned difficult to test, but at least this |
| ensures the bases are touched. |
| |
| * nih/signal.c (nih_signal_poll): Add missing call to |
| nih_signal_init() |
| * nih/child.c (nih_child_poll): Add missing call to nih_child_init() |
| * nih/io.c (nih_io_poll_fds, nih_io_handle_fds): Add missing calls |
| to nih_io_init() |
| |
| * nih/io.c: Code for watching file descriptors and sockets for |
| events through poll(), but not actually the poll() call itself. |
| * nih/io.h: Typedefs, structures and prototypes. |
| * nih/libnih.h: Include io.h |
| * nih/tests/test_io.c: Test cases for I/O watches. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link io.c |
| (nihinclude_HEADERS): Install io.h |
| (TESTS): Build and run I/O test cases |
| (test_io_SOURCES, test_io_LDFLAGS, test_io_LDADD): Details for I/O |
| test case binary. |
| |
| * nih/tests/test_timer.c (test_poll): Free entry after testing. |
| |
| * nih/child.c (nih_child_poll): When the reaper is for a particular |
| process, be sure to remove it from the list. |
| * nih/tests/test_child.c (test_poll): Test for that. |
| |
| * nih/child.c: Simple bit of code to wait for children to |
| terminate and dispatch the reaper functions for them. |
| * nih/child.h: Typedefs, structures and prototypes. |
| * nih/libnih.h: Include child.h |
| * nih/tests/test_child.c: Test cases for child handling code. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link child.c |
| (nihinclude_HEADERS): Install child.h |
| (TESTS): Build and run child test cases |
| (test_child_SOURCES, test_child_LDFLAGS, test_child_LDADD): Details |
| for child test case binary. |
| |
| * nih/timer.c (nih_timer_add_timeout, nih_timer_add_periodic) |
| (nih_timer_add_scheduled): Change argument order so that the time |
| information is first, to match signal functions. |
| * nih/timer.h: Update. |
| * nih/tests/test_timer.c: Update. |
| |
| * nih/signal.h: Include the system signal.h for ease of use. |
| |
| * nih/signal.c: Code for handling signals inside the main loop, |
| rather than trying to fit delicate code in a signal handler; and |
| for making it generally easier to handle signals. |
| * nih/signal.h: Typedefs and prototypes. |
| * nih/libnih.h: Include signal.h |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link signal.c |
| (nihinclude_HEADERS): Install signal.h |
| (TESTS): Build and run signal test cases |
| (test_signal_SOURCES, test_signal_LDFLAGS, test_signal_LDADD): Details |
| for signal test case binary. |
| |
| 2006-07-27 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/timer.c: Code for timeouts, periodic and scheduled timers, |
| note that the actual scheduling part of scheduled timers it not |
| implemented yet (we need to think a bit more about it) |
| * nih/timer.h: Structures, macros and prototypes. |
| * nih/libnih.h: Include timer.h |
| * nih/tests/test_timer.c: Test cases for timer code. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link timer.c |
| (nihinclude_HEADERS): Install timer.h |
| (TESTS): Build and run timer test cases |
| (test_timer_SOURCES, test_timer_LDFLAGS, test_timer_LDADD): Details |
| for timer test case binary. |
| |
| * nih/alloc.c (nih_free): Use new safe list iteration macro. |
| |
| * nih/hash.c (nih_hash_add_unique, nih_hash_replace) |
| (nih_hash_search): Use new list iteration macros. |
| |
| * nih/list.h (NIH_LIST_FOREACH): New macro that expands to the usual |
| list iteration for loop, prevents mistakes. |
| (NIH_LIST_FOREACH_SAFE): Macro that does the same as above, but also |
| includes a "next" variable to allow safe iteration; especially useful |
| to prevent us getting this wrong! |
| * nih/tests/test_list.c (test_foreach, test_foreach_safe): Add test |
| cases for iteration. |
| |
| * nih/error.c (nih_error_init): Make inline and check value first. |
| (nih_error_raise, nih_error_raise_printf, nih_error_raise_again) |
| (nih_error_push_context): Unconditionally call nih_error_init. |
| |
| * nih/alloc.c (nih_alloc_init): Make inline and check value first. |
| (nih_alloc): Unconditionally call nih_alloc_init. |
| |
| * nih/logging.c (nih_log_init): Use the proper functions to |
| initialise details, check values first; also make inline. |
| (nih_log_message): Unconditionally call nih_log_init. |
| |
| * nih/Makefile.am (DEFS): Append to the default DEFS list, rather |
| than overriding, otherwise we lose HAVE_CONFIG_H |
| |
| * nih/macros.h: Check for ENABLE_NLS instead of HAVE_GETTEXT and |
| include libintl.h if defined as well. |
| |
| 2006-07-20 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/string.c (nih_strv_free): Add a function to free an array |
| of strings. |
| * nih/string.h: Update. |
| * nih/tests/test_string.c (test_strv_free): Test the function. |
| |
| * nih/error.c: Error handling code. |
| * nih/error.h: Structures, macros and prototypes. |
| * nih/errors.h: Error enum and message definitions. |
| * nih/libnih.h: Include error.h and errors.h |
| * nih/tests/test_error.c: Error handling test cases. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link error.h |
| (nihinclude_HEADERS): Install error.h |
| (TESTS): Build and run error handling test cases. |
| (test_error_SOURCES, test_error_LDFLAGS, test_error_LDADD): Binary |
| for error handling test cases. |
| |
| * nih/macros.h (NIH_MUST, NIH_MUST_NOT): Add handy macros to spin |
| until we get a true or false value from an assignment. Usually |
| used around a call to memory allocation functions that we can't |
| deal with failing. |
| |
| * nih/main.c (nih_main_package_string): Change package_string |
| to be a module-level static so it can be reset by a call to |
| nih_main_init_full. Always return if not NULL. |
| * nih/tests/test_main.c (test_package_string): Call nih_main_init_full |
| instead of futzing with variables so the static string is reset. |
| |
| * nih/alloc.c (nih_alloc_using, nih_alloc, nih_realloc) |
| (nih_alloc_size, nih_alloc_parent): Make various argument pointers |
| const. |
| * nih/alloc.h: Update. |
| |
| * nih/libnih.h, nih/logging.c, nih/main.c: Update to include |
| string.h not strutil.h |
| |
| * nih/strutil.c: Renamed to nih/string.c |
| * nih/strutil.h: Renamed to nih/string.h |
| * nih/tests/test_strutil.c: Renamed to nih/tests/test_string.h |
| * nih/Makefile.am (DEFAULT_INCLUDES): Override to stop automake doing |
| silly things like putting -I. in the pre-processor flags. |
| (libnih_la_SOURCES, nihinclude_HEADERS, TESTS) |
| (test_string_SOURCES, test_string_LDFLAGS, test_string_LDADD): Update. |
| |
| 2006-07-19 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.h, nih/logging.h, nih/strutil.h: Reformat attribute |
| declarations to not upset emacs indentation. |
| |
| 2006-07-17 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/strutil.c (nih_strdup): Implement an nih_alloc-based strdup. |
| (nih_strdup): and strndup. |
| * nih/strutil.h: Update. |
| * nih/tests/test_strutil.c: Test new functions. |
| |
| 2006-07-13 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c (nih_free): Remove the entry from the parent's list. |
| |
| * nih/logging.h (nih_assert): Reexpress to avoid polluting if |
| statements without an else. |
| |
| * nih/alloc.c (nih_realloc): Implement a function that reallocates |
| a block of memory with the original allocator. |
| (nih_alloc_init): Don't double-check the allocator. |
| * nih/alloc.h: Update. |
| * nih/tests/test_alloc.c (test_realloc): Check behaviour of realloc. |
| |
| * nih/alloc.c (NihAllocCtx): Drop the name pointer, we never used |
| that anyway. |
| (nih_alloc_using): Drop name parameter. |
| (nih_alloc_named): Rename to nih_alloc. |
| (nih_alloc_set_name): Drop this function. |
| (nih_alloc_name): And this one. |
| * nih/alloc.h (nih_new): Simplify. |
| (nih_alloc): Drop entirely now it's unneeded. |
| * nih/tests/test_alloc.c: Update. |
| * nih/tests/test_list.c (test_new): Test using nih_alloc_size |
| rather than nih_alloc_name. |
| |
| * nih/logging.h: Put the log priorities back in ascending order, |
| but use the zero to mean "unknown". Fix up the descriptions to be |
| a little more consistent. |
| * nih/logging.c: Rename max_priority back to min_priority so it |
| all makes more sense again. |
| (nih_log_init): Warning is the default minimum priority to show. |
| (nih_log_set_priority): Set minimum priority. |
| (nih_log_message): Discard messages below the minimum priority. |
| (nih_logger_printf): Use stderr when priority is greater than or |
| equal to warning. |
| * nih/tests/test_logging.c: Update to match. |
| |
| * nih/logging.c (nih_log_message): Use nih_vsprintf which makes the |
| function not core dump (always good, that). |
| |
| 2006-07-12 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_package_string): Use nih_sprintf and make |
| the function rather simpler. |
| |
| * nih/tests/test_alloc.c (main): Formatting fix. |
| |
| * nih/strutil.c (nih_sprintf): Function to wrap sprintf, allocating |
| the necessary space using nih_alloc first. |
| (nih_vsprintf): Function to wrap vsprintf, allocating the necessary |
| space using nih_alloc first. |
| * nih/strutil.h: Prototypes. |
| * nih/libnih.h: Include strutil.h |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link strutil.c |
| (nihinclude_HEADERS): Install strutil.h |
| (TESTS): Build and run strutil test cases |
| (test_strutil_SOURCES, test_strutil_LDFLAGS) |
| (test_strutil_LDADD): Binary for strutil test cases. |
| |
| 2006-07-05 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/logging.c (nih_log_message): Don't bother catching |
| vsnprintf's return value, C99 doesn't allow it to fail. |
| * nih/main.c (nih_main_package_string): Likewise for here. |
| |
| * nih/logging.c (nih_log_message): Don't use a static variable |
| for no apparent reason, just free afterwards. Catch vsnprintf and |
| malloc failing. |
| * nih/main.c (nih_main_package_string): Catch snprintf and realloc |
| failing here too. |
| |
| 2006-05-30 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/logging.h (nih_assert): Assertion macro that uses our logging |
| rather than stderr. |
| * nih/alloc.c, nih/hash.c, nih/list.c, nih/logging.c, nih/main.c: |
| Use nih_assert rather than assert. |
| * nih/Makefile.am (test_alloc_LDFLAGS, test_list_LDFLAGS) |
| (test_hash_LDFLAGS, test_main_LDFLAGS, test_logging_LDFLAGS): Link |
| libraries statically. |
| (test_alloc_LDADD, test_list_LDADD, test_hash_LDADD) |
| (test_main_LDADD, test_logging_LDADD): Just link to the library. |
| |
| * nih/macros.h (NIH_STRINGIFY): Correct typo (-s -> _s) |
| (NIH_LIKELY, NIH_UNLIKELY): Add branch prediction macros. |
| |
| 2006-05-29 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c (nih_alloc_init): Restore this function, it's better |
| style to keep variables in shared libraries as zero. |
| (nih_alloc_named): Call nih_alloc_init once more. |
| * nih/logging.h: Reorder such that NONE is the lowest value. |
| * nih/logging.c (min_priority): Rename to max_priority and set value |
| to NIH_LOG_NONE (zero). |
| (nih_log_init): Initialise the default logger and priority. |
| (nih_log_set_priority): Assert priority is greater than NONE. |
| (nih_log_message): Initialise the logging if necessary. |
| (nih_logger_printf): Check priority with <= |
| |
| * TODO: Update. |
| |
| * nih/logging.c: Code for formatting log messages and filtering |
| based on priority. |
| * nih/logging.h: Prototypes and macros. |
| * nih/libnih.h: Include logging.h |
| * nih/tests/test_logging.c: Logging test cases. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link logging.c |
| (nihinclude_HEADERS): Install logging.h |
| (TESTS): Build and run logging test cases. |
| (test_logging_SOURCES, test_logging_LDADD): Binary for logging |
| test cases. |
| |
| * nih/tests/test_main.c (test_package_string, test_suggest_help) |
| (test_version): Add missing comments before tests. |
| (test_suggest_help, test_version): Close the duplicated stdout/stderr |
| before leaving the test. |
| |
| * nih/alloc.h: Declare nih_alloc_named and nih_alloc_using with |
| the warn_unused_result and malloc attributes. |
| |
| 2006-05-27 Scott James Remnant <scott@netsplit.com> |
| |
| * m4/compiler.m4 (NIH_COMPILER_WARNINGS): Drop -pedantic as we |
| usually want gcc extensions (all the world IS gcc). |
| |
| 2006-05-26 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_init_full): Only take the basename of |
| the program name, not the full path. |
| (nih_main_package_string): Use an allocated piece of memory rather |
| than some on the stack, with C99-style snprintf to do the right thing |
| with it. |
| * nih/tests/test_main.c (test_init): Include check for basename. |
| (test_package_string): Drop tests involving basename here. |
| |
| * m4/compiler.m4 (NIH_TRY_C99): Macro that tries compiling |
| some code full of C99 features. |
| (NIH_C_C99): Use the above macro to determine whether the compiler |
| supports C99, or whether it can do it with a compiler flag. |
| * configure.ac: Make sure the compiler does C99. |
| |
| * nih/list.c: Add missing prototype for nih_list_cut. |
| * nih/hash.c: Add missing prototype for fnv_hash. |
| |
| * nih/macros.h (_, N_): Define gettext-wrapper macros if |
| HAVE_GETTEXT, otherwise define them to just expand to their string. |
| |
| * nih/main.h: Drop comments for global variables. |
| * nih/main.c: Provide proper docstrings for them here. |
| |
| * nih/alloc.c (nih_alloc_init): Drop this function, instead just |
| initialise the static variable directly. |
| (nih_alloc_set_allocator): Correct parameter name in docstring, |
| don't call nih_alloc_init (it's already initialised). |
| |
| 2006-05-24 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c (nih_main_package_string): Clarify documentation. |
| |
| 2006-05-23 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/main.c: Add code for the various little functions that we |
| usually call from main(). |
| * nih/main.h: Prototypes and macros. |
| * nih/libnih.h: Include main.h |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link main.c |
| (nihinclude_HEADERS): Install main.h |
| (TESTS): Build and run main test-cases |
| (test_main_SOURCES, test_main_LDADD): Code for main tests. |
| * m4/misc.m4 (AC_COPYRIGHT): Wraps the Autoconf AC_COPYRIGHT macro |
| but also defines PACKAGE_COPYRIGHT |
| * m4/compiler.m4: Temporary hack to make sure misc.m4 gets dragged |
| in as aclocal doesn't notice it, will go away once we get something |
| that aclocal will notice. |
| |
| 2006-04-26 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/hash.c: Add code for FNV hash tables that uses NihList for |
| the actual bins so is largely polymorphic. |
| * nih/hash.h: Prototypes, macros and structures. |
| * nih/macros.h: Include stdint.h as well, we use that a lot. |
| * nih/libnih.h: Include hash.h |
| * nih/tests/test_hash.c: Test cases for new hash table code. |
| * nih/Makefile.am (libnih_la_SOURCES): Build and link hash.c |
| (nihinclude_HEADERS): Install hash.h |
| (TESTS): Build and run hash table test-cases. |
| (test_hash_SOURCES, test_hash_LDADD): Code for hash table tests. |
| * TODO: Update. |
| |
| * nih/tests/test_list.c (test_empty): Fix faulty test case that |
| actually proved one-entry lists were showing up as empty! |
| * nih/list.h (NIH_LIST_EMPTY): Compare the next and previous pointers |
| against the list pointer itself! |
| |
| * nih/list.c (nih_list_cut): Add an inline function that does the |
| job of nih_list_remove without calling nih_list_init afterwards. |
| (nih_list_remove): Call nih_list_cut rather than modifying pointers. |
| (nih_list_free): Use nih_list_cut for efficiency, no point fixing |
| the pointers if we're just going to free it. |
| (nih_list_add, nih_list_add_after): Use nih_list_cut as the pointers |
| get modified afterwards anyway, more efficient this way. |
| |
| 2006-04-25 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/list.c: Remove unnecessary include of stdlib.h |
| |
| * nih/list.c (nih_list_new): Fix formatting of docstring. |
| * nih/alloc.c (nih_alloc_using, nih_alloc_parent): Fix formatting |
| of docstring. |
| (nih_alloc_named): Fix docstring to mention NULL can be returned. |
| * nih/tests/test_alloc.c, nih/tests/test_list.c: Add missing blank |
| line before includes. |
| |
| * nih/alloc.c (nih_alloc_using): Return NULL if the allocation |
| fails. |
| * nih/list.c (nih_list_new): Also return NULL if the allocation |
| fails. |
| |
| * nih/alloc.c (nih_alloc_set_allocator, nih_alloc_using) |
| (nih_free, nih_alloc_set_name, nih_alloc_set_destructor) |
| (nih_alloc_name, nih_alloc_size, nih_alloc_parent): Use assert |
| to uncover programming errors. |
| * nih/list.c (nih_list_init, nih_list_remove, nih_list_free) |
| (nih_list_add, nih_list_add_after): Use assert to uncover |
| programming errors. |
| (nih_list_new): Comment that nih_new may return NULL and we need |
| to make sure we catch that. |
| |
| 2006-04-24 Scott James Remnant <scott@netsplit.com> |
| |
| * m4/Makefile.am (dist_aclocal_DATA): Add missing \ |
| * nih/Makefile.am (INCLUDES): Include top_srcdir otherwise we |
| can't be built out of tree. |
| |
| * m4/Makefile.am (dist_aclocal_DATA): Install the m4 files into |
| the aclocal directory, not a package specific one. |
| * m4/compiler.m4, m4/linker.m4: Fix closing comment style. |
| |
| * TODO: Add TODO file. |
| * nih/list.h (NIH_LIST_EMPTY): Document what this actually does. |
| |
| 2006-04-19 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/list.c (nih_list_entry_new): Removed. This makes the list |
| code more focussed and generic, but also we'll nearly always want |
| the data member to be an nih_alloc child of the list, rather than |
| the other way around! |
| * nih/list.h (NihListEntry, nih_list_add_new) |
| (nih_list_add_new_after): Likewise, remove the structure and helper |
| macros; if we find ourselves wanting this, we can put it in a new |
| file and just make it polymorphic like we plan for hashes. |
| * nih/tests/test_list.c: Replace all uses of NihListEntry with plain |
| NihList, we never checked the data members anyway. |
| (test_entry_new): Remove test case. |
| (test_add): Remove test of nih_list_add_new macro. |
| (test_add_after): Remove test of nih_list_add_new_after macro. |
| (test_empty): Check macro works with any list entry. |
| (test_remove): Test removal of the last list entry, and removal |
| on an already empty list. |
| (test_free): Don't check the pointers of a block we've just freed! |
| |
| 2006-04-18 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c (nih_alloc_init): Call nih_alloc_set_allocator. |
| * nih/alloc.h (NihDestructor): Clarify docstring to not refer |
| to internal structures. |
| * nih/list.h (NIH_LIST_EMPTY): Add convenience macro for this |
| common operation. |
| * nih/tests/test_list.c (test_empty): Test the new macro. |
| |
| 2006-04-16 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/list.c (nih_list_new, nih_list_entry_new): Call nih_new rather |
| than malloc so the list can be a context for data members. |
| (nih_list_free): Call nih_free rather than free. |
| * nih/tests/test_list.c: Test cases should not be static. |
| (test_new, test_entry_new): Check the new object was allocated using |
| our nih_alloc function. |
| (test_remove): Test a second removal. |
| (destructor_called): Function to test whether destructor was called. |
| (test_free): Test now that we can use an NihDestructor. |
| * nih/Makefile.am (test_list_LDADD): Link alloc.o now that lists |
| depend on the allocator. |
| |
| * nih/list.c, nih/list.h: Fix docstrings to use references where |
| useful. Split functions into blocks separated by a newline. |
| |
| * nih/alloc.h: Update and fix formatting. |
| (NihAllocDestructor): Rename to NihDestructor. |
| * nih/alloc.c (nih_alloc_init): Make safe against repeated calls. |
| (nih_alloc_set_allocator): New function to set the default allocator, |
| overriding any set already. |
| (nih_alloc_set_destructor): Update type of destructor argument.. |
| (NihAllocCtx): Update type of destructor member. |
| * nih/tests/test_alloc.c (my_realloc): Wrapper around realloc so |
| we can check custom allocators are called properly. |
| (test_alloc_using): Test allocation with a custom allocator. |
| (test_free): Check that the block is freed using the allocator, |
| also update destructor checking. |
| (test_set_allocator): Test new allocator is used. |
| |
| * nih/alloc.c (nih_alloc_using): New one-shot function to use a given |
| realloc-style function to make a named block of memory of a given size. |
| (nih_alloc_named): Replace with a thin-wrapper around nih_alloc_using |
| that passes in the default allocator. |
| (NihAllocCtx): Add new allocator member to store the allocator used, |
| so we free with the right one. |
| (nih_alloc_init): Set the default allocator to realloc(). Drop |
| pool initialisation code. |
| (nih_free): Call the context's original allocator with zero size. |
| (used_pool, unused_pool, NIH_ALLOC_SMALLEST): Remove, these really |
| belong in distinct memory handling code. |
| (nih_alloc_set, nih_alloc_new): Drop functions only needed if we're |
| doing our own memory management. |
| (nih_alloc_size, nih_alloc_parent): Add a couple of useful functions. |
| * nih/alloc.h (NihAllocator): Typedef for allocator function prototype. |
| (nih_alloc): Rename to nih_new. |
| (nih_alloc_size): Rename to nih_alloc. |
| * nih/tests/test_alloc.c (test_alloc_named, test_new, test_alloc): Test |
| behaviour of standard functions with and without parents. |
| (destructor_called): Allow it to be called multiple times, change |
| to static to enforce modularity. |
| (child_destructor_called): Another function for testing multiple |
| destructors. |
| (test_free): Test nih_free using alloc destructors. |
| (test_alloc_set_name): Rename to just test_set_name for consistency. |
| |
| * nih/macros.h (NIH_STRINGIFY): Generic hack to turn a numeric |
| macro into a string. |
| * nih/alloc.h (nih_alloc, nih_alloc_size): Use generic NIH_STRINGIFY |
| macro instead of our home-cooked one. |
| |
| 2006-03-31 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c, nih/alloc.h, nih/list.c, nih/list.h, nih/macros.h, |
| nih/libnih.h, nih/tests/test_alloc.c, |
| nih/tests/test_list.c: Update FSF address in GPL header. |
| |
| 2006-03-03 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c, nih/alloc.h, nih/list.c, nih/list.h: Formatting fixes, |
| correct erroneous references to d_* functions and D* structures. |
| * nih/list.h: Correct docstring for nih_list_new and nih_list_entry_new |
| functions so that @data is described for the right one. |
| * nih/Makefile.am: Add blank line between SOURCES and LDFLAGS. |
| |
| 2005-09-29 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c, nih/alloc.h, nih/list.c, nih/list.h: Fix docstring |
| terminators to be **/ not */. |
| * nih/alloc.h: Align function parameters. |
| * nih/tests/test_alloc.c (test_alloc_set_name): Fix to return |
| ret and not zero all the time. |
| |
| 2005-08-29 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/alloc.c (NIH_ALLOC_SMALLEST): Set to the size of the |
| NihAllocCtx structure shifted left twice; this will divide evenly |
| into a page. |
| |
| * nih/alloc.c (nih_alloc_init): No need to pass NULL to nih_list_new. |
| (nih_alloc_new): No need to initialise data member of NihList structs |
| or cast children member. |
| (nih_alloc_named): Can cast NihList directly to NihAllocCtx now, |
| simplify difference test. |
| (nih_free): Use iter as variable name for clarity. |
| (nih_alloc_return_unused): Cast NihList directly to NihAllocCtx. |
| * nih/tests/test_alloc.c: Output "BAD:" instead of "FAIL:" |
| |
| * nih/list.h (NihList): Remove data pointer, it'll save us 4 bytes |
| where we want to make lists of structures that are always in lists. |
| (NihListEntry): Define new structure for those still wanting data |
| pointers. |
| (nih_list_add_new, nih_list_add_new_after): Use nih_list_entry_new. |
| * nih/list.c (nih_list_new): Remove argument and don't initialise |
| data pointer, this simply allocates and initialises the two-pointer |
| structure. |
| (nih_list_entry_new): New function to allocate and initialise an |
| NihListEntry structure. |
| * nih/tests/test_list.c: Output "BAD:" instead of "FAIL:" |
| (test_new): Test without data pointer. |
| (test_entry_new): Test with data pointer. |
| (test_add, test_add_after, test_remove): Mix and cast NihList and |
| NihListEntry properly. |
| |
| * nih/alloc.c: Implement a heirarchial allocator in a similar |
| style to halloc and talloc, but designed never to return data to |
| the system and re-use it instead. |
| * nih/alloc.h: Prototypes and macros for allocator. |
| * nih/libnih.h: Include allocator header. |
| * nih/tests/test_alloc.c: Test-cases for allocator. |
| * nih/macros.h (MIN, MAX): Define MIN and MAC macros if not already |
| available. |
| * nih/Makefile.am (libnih_la_SOURCES): Compile and link alloc.c |
| (nihinclude_HEADERS): Install alloc.h |
| (TESTS): Build and run the allocator test-cases. |
| (test_alloc_SOURCES, alloc_list_LDADD): Identify the test sources and |
| objects it needs. |
| |
| 2005-08-28 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/list.c (nih_list_init): Add new function for dealing with |
| statically allocated list entries, and initialising them. |
| (nih_list_new): Use nih_list_init() to initialise the list. |
| (nih_list_new): Use nih_list_init() to re-initialise the list |
| to a single-member. |
| * nih/list.h: Add prototype for nih_list_init. |
| (NihListIter): Remove the iterator structure, it turns |
| out to be harder work to try and use lists in an "all nodes are |
| interesting" manner; so we'll iterate them normally instead. |
| (NIH_LIST_FIRST, NIH_LIST_LAST): Remove iterator test functions. |
| (NIH_LIST_PREV, NIH_LIST_NEXT): Remove iterator change functions. |
| * nih/tests/test_list.c: Use NULL for nih_list_new in all functions. |
| (test_init): New test case for nih_list_init(). |
| (test_iterator): Removed iterator tests. |
| |
| 2005-08-21 Scott James Remnant <scott@netsplit.com> |
| |
| * nih/list.c: Add code for generic circular doubly-linked lists. |
| * nih/list.h: Prototypes and macros. |
| * nih/macros.h: Some generic macros. |
| * nih/libnih.h: Header to import everything. |
| * nih/tests/test_list.c: Test-cases for linked-list code. |
| * nih/Makefile.am (libnih_la_SOURCES): Link list.c in. |
| (nihincludedir): Define directory to contain header files to be |
| $includedir/nih. |
| (include_HEADERS): Install libnih.h into the main include directory. |
| (nihinclude_HEADERS): Install header files. |
| (TESTS): Build and run the list test-cases. |
| (test_list_SOURCES, test_list_LDADD): Identify the test sources and |
| objects it needs. |
| |
| * nih/libnih.ver: Add simple "everything beginning nih_* is global" |
| version script. |
| * nih/Makefile.am (libnih_la_LDFLAGS): Use the version script |
| if we can pass an argument to do that to the linker. |
| (EXTRA_DIST): Distribute the version script. |
| |
| 2005-07-09 Scott James Remnant <scott@netsplit.com> |
| |
| * m4/compiler.m4 (NIH_COMPILER_WARNINGS): Macro to add -Wall, |
| -Werror and -pedantic to CFLAGS and CXXFLAGS if using gcc or g++. |
| (NIH_COMPILER_OPTIMISATIONS): Macro to remove any optimisation |
| arguments from CFLAGS and CXXFLAGS and replace them with -O0 to |
| override any default level. |
| (NIH_COMPILER_COVERAGE): Macro to add compiler coverage testing |
| arguments to CFLAGS and CXXFLAGS. |
| * m4/linker.m4 (NIH_LINKER_OPTIMISATIONS): Macro to add -Wl,-O1 |
| to LDFLAGS to increase the optimisation of the linker hash tables. |
| (NIH_LINKER_VERSION_SCRIPT): Macro to test for the right argument |
| to pass a version script to the linker and define |
| HAVE_VERSION_SCRIPT and VERSION_SCRIPT_ARG. |
| * m4/Makefile.am (dist_pkgdata_DATA): Ship macros. |
| * configure.ac: Use new macros. |
| |
| * ChangeLog: Initial project infrastructure created. |
| |