blob: cae31fd008d13452c72962e62a8d66e1fc3838a7 [file] [log] [blame]
Scott James Remnant9489e8b2007-03-13 16:56:33 +000012007-03-13 Scott James Remnant <scott@netsplit.com>
2
3 * nih/io.h: Change int_data type to a plain old int; there's no
4 reason for it to be a fixed width type, and we may as well think
5 about supporting ILP64 in case someone does something silly one day.
6
Scott James Remnant0c2a7092007-03-11 12:56:21 +000072007-03-11 Scott James Remnant <scott@netsplit.com>
8
Scott James Remnantc2f21802007-03-11 18:57:40 +00009 * m4/compiler.m4: Don't check for __thread unless --enable-threading
10 given to configure, instead define it to empty.
11
Scott James Remnant0c2a7092007-03-11 12:56:21 +000012 * TODO: Update.
13
Scott James Remnant674fbd52007-03-09 12:56:40 +0000142007-03-09 Scott James Remnant <scott@netsplit.com>
15
16 * nih/logging.c: Make the current log priority available globally
17 through the nih_log_priority variable.
18 * nih/logging.h: Update.
19
Scott James Remnant44f3efb2007-03-08 12:07:16 +0000202007-03-08 Scott James Remnant <scott@netsplit.com>
21
22 * nih/macros.h (_n): Add a macro to wrap ngettext() for plural forms.
23
Scott James Remnant52911582007-03-02 11:26:15 +0000242007-03-02 Scott James Remnant <scott@netsplit.com>
25
26 * nih/tests/test_watch.c: Skip these tests if inotify is not
27 available, since there's not much we can do.
28
Scott James Remnant3820ef02007-02-16 16:15:18 +0000292007-02-16 Scott James Remnant <scott@netsplit.com>
30
Scott James Remnant7d72c6a2007-02-16 18:25:04 +000031 * nih/tree.c (nih_tree_next, nih_tree_prev): Add non-recursive
32 functions to iterate a tree in-order either forwards or backwards.
33 * nih/tree.h (NIH_TREE_FOREACH): Standard macro for wrapping
34 nih_tree_next and turning it into a for loop.
35 * nih/tests/test_tree.c (test_next, test_foreach, test_prev): Test
36 things with a complex tree to see whether they work out ok.
37
Scott James Remnantb365aa92007-02-16 16:15:24 +000038 * nih/list.h: Fix formatting and ordering.
39 * nih/list.c: Fix function ordering.
40
Scott James Remnant3820ef02007-02-16 16:15:18 +000041 * nih/tree.c: Add generic code to implement pure binary trees.
42 * nih/tree.h: Structures, typedefs and prototypes.
43 * nih/tests/test_tree.c: Binary tree test suite.
44 * nih/libnih.h: Include tree.h
45 * nih/Makefile.am (libnih_la_SOURCES): Build and link tree.c
46 (nihinclude_HEADERS): Install tree.h
47 (TESTS): Build and run binary tree test suite.
48 (test_tree_SOURCES, test_tree_LDFLAGS, test_tree_LDADD): Details for
49 binary tree test suite binary.
50
Scott James Remnantbcfe9c52007-02-15 17:02:00 +0000512007-02-15 Scott James Remnant <scott@netsplit.com>
52
53 * nih/watch.c (INOTIFY_EVENTS): Use IN_CLOSE_WRITE instead of
54 IN_MODIFY; since that guarantees the file has actually been closed,
55 and is probably on the filesystem now.
56
Scott James Remnant7b820c92007-02-13 15:38:16 +0000572007-02-13 Scott James Remnant <scott@netsplit.com>
58
Scott James Remnant24a7f322007-02-13 18:00:04 +000059 * nih/signal.c: Add SIGUNUSED to the list of signals that might not
60 exist.
61
Scott James Remnant482c5f52007-02-13 15:42:53 +000062 * nih/tests/test_option.c (test_parser): gcc doesn't like using
63 variables inside fixed for loops, so initialise it deliberately.
64 * nih/tests/test_command.c (test_help): Was mistakenly repeatedly
65 opening output.
66 (test_parser): Similar for loop issue.
67
Scott James Remnant7b820c92007-02-13 15:38:16 +000068 * nih/signal.c: Update signal name list, some signals don't exist on
69 sparc and some turn up unexpectedly.
70
Johan Kiviniemi2b336122007-02-11 17:27:19 +0200712007-02-11 Johan Kiviniemi <johan@kiviniemi.name>
72
73 * nih/hash.h (NIH_HASH_FOREACH, NIH_HASH_FOREACH_SAFE): Added missing
Scott James Remnantdbd6c3b2007-02-11 17:01:25 +000074 parenthesis around hash, in case it's a complicated expression with
75 unsurprising precedence results.
Johan Kiviniemi2b336122007-02-11 17:27:19 +020076
Scott James Remnant005d6b32007-02-11 13:48:25 +0000772007-02-11 Scott James Remnant <scott@netsplit.com>
78
Scott James Remnantc3c2cd92007-02-11 16:36:03 +000079 * nih/config.c (nih_config_skip_whitespace): It turns out that when
80 parsing, it's often useful to skip any whitespace while retaining the
81 "step over newlines" behaviour. Seperate it out into its own
82 function.
83 (nih_config_next_token): Call the new function.
84 * nih/config.h: Add prototype.
85 * nih/tests/test_config.c (test_skip_whitespace): Check the function
86
Scott James Remnant66869da2007-02-11 14:04:01 +000087 * nih/config.c: Remove macro definitions
88 * nih/config.h: and make them public instead
89 * nih/tests/test_config.c: Use macros.
90
Scott James Remnant7c91a1b2007-02-11 14:00:51 +000091 * nih/config.c (nih_config_next_token): Strange hybrid function,
92 it behaves like next_arg() but accepts the same arguments as token();
93 it skips whitespace, but only if the initial whitespace character is
94 in the delim argument.
95 (nih_config_next_arg): This becomes a wrapper around next_token.
96 * nih/config.h: Add prototype.
97 * nih/tests/test_config.c (test_next_token): Check the new function.
98
Scott James Remnant005d6b32007-02-11 13:48:25 +000099 * nih/config.c (nih_config_next_token): Rename to nih_config_token,
100 since this doesn't behave like the next_arg() function, and we want
101 a similar token function that behaves like that.
102 * nih/config.h: Update.
103 * nih/tests/test_config.c (test_next_token): Rename and update.
104
Scott James Remnanta65f90a2007-02-09 04:54:25 +00001052007-02-09 Scott James Remnant <scott@netsplit.com>
106
Scott James Remnant0b041a82007-02-09 17:30:41 +0000107 * nih/hash.h (NIH_HASH_FOREACH_SAFE): Oops, s/list/hash/
108
Scott James Remnant58386032007-02-09 17:02:20 +0000109 * nih/hash.h (NIH_HASH_FOREACH, NIH_HASH_FOREACH_SAFE): Add macros
110 to iterate over an entire hash table.
111 * nih/tests/test_hash.c (test_foreach, test_foreach_safe): Test the
112 macros.
113
Scott James Remnantd2ea67d2007-02-09 16:46:45 +0000114 * nih/hash.c (nih_hash_string_key): Add a useful function to return
115 the first member after the list header.
116 * nih/hash.h: Add prototype.
117 * nih/tests/test_hash.c (test_string_key): Add test case.
118
Scott James Remnanta65f90a2007-02-09 04:54:25 +0000119 * nih/file.c (nih_file_is_packaging): Check for common packaging
120 filenames -- I swore I wrote this, but I can't find it.
121 (nih_file_ignore): Ignore packaging files.
122 * nih/file.h: Update.
123 * nih/tests/test_file.c (test_is_packaging, test_ignore): Test.
124
Scott James Remnant6538fed2007-02-07 02:12:14 +00001252007-02-07 Scott James Remnant <scott@netsplit.com>
126
127 * nih/logging.c (nih_logger_printf): Change printf logger to not
128 prefix anything intended for stdout.
129 * nih/logging.h: Rearrange.
130 * nih/tests/test_logging.c (test_logger_printf): Make sure that
131 we don't prefix the program name for messages that go to stdout.
132
Scott James Remnant5467de22007-02-06 11:40:33 +00001332007-02-06 Scott James Remnant <scott@netsplit.com>
134
Scott James Remnant5ddca832007-02-06 23:39:10 +0000135 * nih/signal.c (nih_signal_from_name): Table changed to not contain
136 SIG, so this now strips it off the front if present.
137 * nih/tests/test_signal.c (test_to_name): Strip SIG from the front
138 (test_from_name): Check that we can omit SIG from the front.
139
Scott James Remnanta0574372007-02-06 23:33:41 +0000140 * nih/signal.c (nih_signal_to_name, nih_signal_from_name): Functions
141 annoyingly missing from the standard library; convert signal names
142 and numbers between each other (e.g. SIGTERM -> 15).
143 * nih/signal.h: Add prototypes.
144 * nih/tests/test_signal.c (test_to_name, test_from_name): Put the
145 new functions through their paces.
146
Scott James Remnantc16ef2a2007-02-06 14:26:20 +0000147 * nih/string.c (nih_str_array_add, nih_str_array_addn): Correct leak
148 when array allocation fails.
149
Scott James Remnantc2c42f52007-02-06 13:14:24 +0000150 * nih/string.c (nih_str_array_add, nih_str_array_addn)
151 (nih_str_array_addp): Allow the array pointed to to be NULL, after all,
152 realloc works anyway. Also allow len to be NULL, in which case, we
153 count the elements automatically.
154 * nih/tests/test_string.c (test_array_addp): Update test cases.
155
Scott James Remnanteadc99e2007-02-06 12:44:12 +0000156 * nih/config.c (nih_config_parse_args): Use nih_str_array functions.
157 * nih/file.c (nih_dir_walk_scan): Use nih_str_array functions.
158 * nih/option.c (nih_option_parser): Use nih_str_array functions.
159 (nih_option_add_arg): Drop this function now.
160
Scott James Remnantf953c4e2007-02-06 12:28:58 +0000161 * nih/string.c (nih_str_array_addp): Yet another variation on a theme;
162 this one saves duplicating allocs, which is always messy.
163 (nih_str_array_addn): Wrap around the above function.
164 (nih_str_array_add): Make this a wrapper around addp instead.
165 * nih/string.h: Update.
166 * nih/tests/test_string.c (test_array_addp): Check that one works.
167
Scott James Remnantd55a13e2007-02-06 12:13:41 +0000168 * nih/string.c (nih_str_split): Use nih_str_array functions.
169
Scott James Remnanta839df52007-02-06 12:09:48 +0000170 * nih/string.c (nih_str_array_addn): Add a version of nih_str_array_add
171 that calls nih_strndup instead of nih_strdup.
172 (nih_str_array_add): turn into a thin wrapper around the above.
173 * nih/string.h: Update.
174 * nih/tests/test_string.c (test_array_addn): Test new function.
175
Scott James Remnant7d2b90d2007-02-06 12:06:36 +0000176 * nih/string.c (nih_str_array_add): Flip array and parent arguments
177 to make it more like realloc.
178 * nih/string.h: Update.
179 * nih/tests/test_string.c (test_array_add): Update.
180
Scott James Remnant3e7d9052007-02-06 12:03:20 +0000181 * nih/string.c (nih_str_array_new, nih_str_array_add): Functions
182 to handle the common cases of arrays of strings.
183 * nih/string.h: Update.
184 * nih/tests/test_string.c (test_array_new, test_array_add): Test.
185
Scott James Remnant5467de22007-02-06 11:40:33 +0000186 * nih/watch.c (nih_watch_handle): Never assert on data received from
187 an untrusted source (well, the kernel, anyway). Also make sure nobody
188 sneaks a '/' into the name of an inotify event.
189
Scott James Remnant15fbe672007-02-05 22:13:28 +00001902007-02-05 Scott James Remnant <scott@netsplit.com>
191
192 * nih/string.c (nih_vsprintf): Make sure vsnprintf never returns
193 a negative value; C99 says it can't, of course, but Kees was
194 paranoid.
195
Scott James Remnant0f9e01c2007-02-03 11:31:59 +00001962007-02-03 Scott James Remnant <scott@netsplit.com>
197
Scott James Remnant6dd43892007-02-03 23:42:26 +0000198 * nih/watch.c (nih_watch_new): Tidy up ENOMEM loop.
199
Scott James Remnant97943972007-02-03 18:36:14 +0000200 * nih/tests/test_file.c (test_dir_walk): Fix leak of directory caused
201 by not removing a symlink.
202 * nih/tests/test_watch.c (test_new, test_add): Fix leaks of
203 directories caused by not changing permissions back so we can unlink
204 under them.
205
Scott James Remnant8630d282007-02-03 17:24:11 +0000206 * nih/watch.h (NihCreateHandler, NihModifyHandler): Add stat argument.
207 * nih/watch.c (nih_watch_handle): stat any object created or modified,
208 and pass the stat buf to the handler function.
209 (nih_watch_add_visitor): Pass stat argument here too.
210
211 * nih/tests/test_watch.c: Add arguments.
212
Scott James Remnant28d252e2007-02-03 15:35:38 +0000213 * nih/option.c (nih_option_int): Function to parse integer values
214 on the command line.
215 * nih/option.h: Add prototype.
216 * nih/tests/test_option.c (test_int): test case for it.
217
Scott James Remnant0f9e01c2007-02-03 11:31:59 +0000218 * nih/file.c (nih_file_is_hidden, nih_file_is_backup)
219 (nih_file_is_swap, nih_file_is_rcs): Functions to match common
220 file types by their path.
221 (nih_file_ignore): Function to combine calls to all of the above.
222 * nih/file.h: Add prototypes.
223 * nih/tests/test_file.c: Add test cases for the new functions.
224 * TODO: Update.
225
Scott James Remnant98b9ddb2007-02-02 16:24:37 +00002262007-02-02 Scott James Remnant <scott@netsplit.com>
227
Scott James Remnantbfe1c792007-02-02 19:34:09 +0000228 * TODO: Update.
229
Scott James Remnant700ea522007-02-02 19:31:41 +0000230 * nih/watch.c (nih_watch_new): Add a create argument to avoid
231 walking a directory tree twice; store in the structure.
232 (nih_watch_add_visitor): Call the create handler if necessary.
233 * nih/watch.h: Update structure to include member and prototype.
234 * nih/tests/test_watch.c (test_new): Check that, when called with
235 create, the handler is called for each file that exists.
236 (test_reader): Check that a directory is recursed when moved in
237 or created with existing files.
238
Scott James Remnant0b2a85f2007-02-02 17:29:40 +0000239 * nih/tests/test_watch.c (test_reader): Add test case for watching
240 sub-directories again.
241
Scott James Remnant387453f2007-02-02 17:22:07 +0000242 * nih/watch.c (nih_watch_new, nih_watch_add): Make safe against
243 ENOMEM; otherwise it's just tricky to decide when it's good and bad
244 to throw things out.
245 * nih/tests/test_watch.c: Update test cases accordingly.
246
Scott James Remnantf88eeff2007-02-02 17:12:05 +0000247 * nih/watch.c (nih_watch_add): It's not an error for subdirs to be
248 TRUE when we get passed a filename.
249 * nih/tests/test_watch.c (test_add): Check that it works.
250
Scott James Remnantd1e8b402007-02-02 17:04:38 +0000251 * nih/file.c (nih_dir_walk): Initialise ret to zero, otherwise
252 can return an uninitialised value when walking an empty directory.
253
Scott James Remnant9a371792007-02-02 17:01:43 +0000254 * nih/tests/test_child.c (test_poll): Reap the child we kill,
255 otherwise the next test might fail sometimes.
256
Scott James Remnant80598b72007-02-02 16:58:49 +0000257 * nih/watch.c (nih_watch_add): Make being unable to recurse into
258 sub-directories to watch them an error.
259 * nih/tests/test_watch.c (test_new, test_add): Update test cases.
260
Scott James Remnant98b9ddb2007-02-02 16:24:37 +0000261 * nih/file.c (nih_dir_walk): Rework this function to support
262 detection of directory loops, and reporting of errors with a callback
263 handler rather than just aborting the walk.
264 (nih_dir_walk_scan): Build up a sorted list of paths under a directory,
265 filtered with the filter function. Split out because it has different
266 error handling semantics.
267 (nih_dir_walk_visit): Visit a single path and if it's a directory,
268 descend into it.
269 * nih/file.h (NihFileVisitor): Add arguments to pass the top-level
270 directory and the stat buffer of the path (to avoid stating the same
271 things multiple times).
272 (NihFileErrorHandler): Duplicate prototype for the error handler.
273 * nih/errors.h (NIH_DIR_LOOP_DETECTED): Add new error.
274 * nih/tests/test_file.c (test_dir_walk): Update test cases, improving
275 test coverage at the same time.
276 * nih/watch.c (nih_watch_add_visitor): Update to check the stat
277 passed to the visitor, as well as accept the directory name,
278
Scott James Remnante9a05d92007-02-01 17:21:06 +00002792007-02-01 Scott James Remnant <scott@netsplit.com>
280
Scott James Remnante0a13802007-02-01 17:24:25 +0000281 * nih/tests/test_io.c: Replace NIH_ZERO in test cases with assert0
282
Scott James Remnantde33f512007-02-01 17:21:27 +0000283 * nih/tests/test_main.c (test_main_loop): Eliminate use of NIH_MUST
284 * nih/tests/test_io.c (test_watcher): Remove unnecessary NIH_MUST
285
Scott James Remnante9a05d92007-02-01 17:21:06 +0000286 * nih/test.h (assert0): Add an assert wrapper for the common
287 alternate case.
288
Scott James Remnant3e483602007-01-30 11:01:21 +00002892007-01-30 Scott James Remnant <scott@netsplit.com>
290
Scott James Remnant45352972007-01-30 12:17:59 +0000291 * nih/io.c (nih_io_buffer_resize): Always keep a buffer filled with
292 zeros when we extend it, so we never pass uninitialised data to
293 syscalls.
294
Scott James Remnant0d1d4202007-01-30 12:07:27 +0000295 * m4/misc.m4 (NIH_INIT): Detect valgrind/valgrind.h
296 * nih/tests/test_signal.c: Detect valgrind and don't check the error
297 values from trying to set SIG_DFL or SIG_IGN for SIGKILL; which for
298 no readily apparent reason, works under valgrind.
299
Scott James Remnantd78b8142007-01-30 11:51:59 +0000300 * HACKING: Add newline to end of file.
301
Scott James Remnant5db54262007-01-30 11:48:42 +0000302 * nih/test.h (TEST_ALLOC_SAFE): Add macro to guard allocations so
303 they aren't counted.
304 * nih/tests/test_file.c (my_visitor, test_dir_walk): Use
305 TEST_ALLOC_SAFE instead of changing the allocator by hand.
306 * nih/tests/test_io.c (test_watcher): Use TEST_ALLOC_SAFE instead of
307 changing the allocator by hand,
308
Scott James Remnant3a116132007-01-30 11:41:19 +0000309 * nih/macros.h (NIH_MUST_NOT): Rename to NIH_ZERO
310 * nih/io.c (nih_io_message_recv): Use NIH_ZERO, instead of == 0
311 * nih/main.c (nih_main_loop_init): Use NIH_ZERO, instead of == 0
312 * nih/tests/test_io.c: Use NIH_ZERO not NIH_MUST...== 0
313
Scott James Remnant6939ebb2007-01-30 11:32:05 +0000314 * nih/tests/test_io.c (test_watcher): Ensure that we don't ignore
315 the return value from nih_io_printf; but also don't fail it.
316
Scott James Remnant97536742007-01-30 11:29:44 +0000317 * HACKING: Clarify that returning to indicate insufficient memory
318 warrants warn_unused_result.
319
Scott James Remnant08463f32007-01-30 11:28:21 +0000320 * nih/io.h: Add warn_unused_result attribute to nih_io_printf.
321 * nih/string.c: Correct doc strings.
322
Scott James Remnant0d01e7f2007-01-30 11:10:44 +0000323 * nih/string.c (nih_vsprintf): We need to copy the arguments before
324 iterating either time, otherwise we could return NULL after moving
325 the current argument off the end.
326
Scott James Remnant3e483602007-01-30 11:01:21 +0000327 * TODO: Update.
328
Scott James Remnantf7d81e92007-01-22 09:51:17 +08003292007-01-22 Scott James Remnant <scott@netsplit.com>
330
Scott James Remnant6d0c2982007-01-22 05:22:20 +0000331 * nih/io.c (nih_io_reopen): Raises an error (usually ENOMEM), since
332 it can also raise EBADF.
333 * nih/tests/test_io.c (test_reopen): Make sure ENOMEM is raised.
334 * nih/watch.c: New watch API, this is a little higher level than
335 what previously existing in nih/file.c; but is substantially easier
336 to use and should cover all of the corner cases.
337 (INOTIFY_EVENTS): inotify events we always watch for.
338 (nih_watch_new): The master function; this creates a new inotify
339 instance and adds a watch for a path in it.
340 (nih_watch_handle_by_wd): Obtain a watch handle by descriptor
341 (nih_watch_handle_by_path): Obtain a watch handle by path
342 (nih_watch_add): Another useful function, adds a second path to
343 an existing watch; normally used just for sub-directories, but
344 possible for anything.
345 (nih_watch_add_visitor): nih_dir_walk() callback that calls the above
346 (nih_watch_free): Free a watch, and the associated NihIo; closing the
347 inotify descriptor.
348 (nih_watch_reader): Reader function; handles the incoming stream of
349 inotify events by locating the watch handle and dispatching through
350 (nih_watch_handle): this function which handles all the various
351 event ordering corner-cases and dispatches to the watch functions
352 proper.
353 * nih/watch.h: Typedefs, structures and prototypes for the new watch
354 API.
355 * nih/tests/test_watch.c: Test suite for the watch code; covers most
356 of the paths -- though malloc checking here is tricky and could do
357 with improving later.
358 * nih/libnih.h: Include nih/watch.h
359 * nih/Makefile.am (libnih_la_SOURCES): Build and link watch.c
360 (nihinclude_HEADERS): Install watch.h
361 (TESTS): Build and run watch test suite
362 (test_watch_SOURCES, test_watch_LDFLAGS, test_watch_LDADD): Details
363 for watch test suite binary.
364
Scott James Remnanta8b296e2007-01-22 03:59:51 +0000365 * nih/file.c: Strip out anything related to inotify, leaving us
366 with just three functions; nih_file_map(), nih_file_unmap() and
367 nih_dir_walk(). Others that will turn up here will be matching
368 and filtering functions.
369 * nih/file.h: Strip out typedefs, structures and prototypes for
370 anything watch-related; add attributes to functions as necessary.
371 * nih/tests/test_file.c: Remove watch-related test cases, and
372 use TEST_ALLOC_FAIL for test_dir_walk().
373
Scott James Remnant9508a7c2007-01-22 03:01:24 +0000374 * nih/tests/test_io.c (test_shutdown): Test NIH_IO_MESSAGE using
375 AF_UNIX socketpairs, not pipes.
376
Scott James Remnant4a5db842007-01-22 02:47:50 +0000377 * HACKING: Document the requirements for function attributes and
378 using TEST_ALLOC_FAIL in test cases.
379 * TODO: Update.
380
Scott James Remnantb73a3e52007-01-22 02:38:28 +0000381 * nih/tests/test_signal.c (test_set_handler): Check that SIGCHLD
382 gets the SA_NOCLDSTOP flag, and that SIGKILL returns an error.
383 (test_set_default, test_set_ignore): Check SIGKILL returns error.
384
Scott James Remnant7568b082007-01-22 02:37:57 +0000385 * nih/tests/test_option.c (test_parser): Check that duplicated
386 options result in the previous string being freed.
387
Scott James Remnant397ca832007-01-22 02:27:25 +0000388 * nih/main.c (nih_main_daemonise): SIGHUP can always be ignored.
389
Scott James Remnant13c76e12007-01-22 02:27:03 +0000390 * nih/tests/test_io.c (test_reopen): Make sure that we can't reopen
391 a closed file descriptor.
392 (test_set_nonblock, test_set_cloexec): Check with closed descriptors.
393
Scott James Remnant47e438c2007-01-22 02:18:10 +0000394 * nih/config.c: When we call nih_config_skip_comment, we can usually
395 assert that this will never fail; so do so.
396
Scott James Remnanta1788542007-01-22 02:07:49 +0000397 * nih/tests/test_command.c (test_help): Check a few missing pieces
398 of the command help output to make sure it's right.
399
Scott James Remnant4afd8c42007-01-22 01:56:32 +0000400 * nih/file.c (nih_dir_walk): Correct doc string to indicate that
401 this function raises errors.
402
Scott James Remnantf7d81e92007-01-22 09:51:17 +0800403 * nih/alloc.h: Fix prototype orders.
404 * nih/child.h: Add attributes to important return values.
405 * nih/config.c: Add attributes to important return values.
406 * nih/config.h: Add attributes to important return values.
407 * nih/error.h: Add attributes to important return values.
408 * nih/io.h: Add attributes to important return values.
409 * nih/main.h: Add attributes to important return values.
410 * nih/signal.h: Add attributes to important return values.
411 * nih/string.h: Add attributes to important return values.
412 * nih/timer.h: Add attributes to important return values.
413 * nih/io.c (nih_io_reopen): Don't ignore failure to ignore SIGPIPE.
414 (nih_io_set_cloexec, nih_io_set_nonblock): The only useful errors
415 returned is EBADF, so just return -1 for that.
416 * nih/main.c (nih_main_daemonise): Don't ignore failure to ignore
417 SIGHUP.
418 * nih/signal.c (nih_signal_set_handler, nih_signal_set_default)
419 (nih_signal_set_ignore): The only useful error sigaction returns
420 is EINVAL, so just return -1.
421 (nih_signal_reset): Ignore EINVAL errors.
422 * nih/tests/test_io.c: Use NIH_MUST around function calls that
423 can fail.
424 * nih/tests/test_main.c: Use NIH_MUST around function calls that
425 can fail.
426
Scott James Remnantdb1ce702007-01-21 19:49:36 +08004272007-01-21 Scott James Remnant <scott@netsplit.com>
428
429 * nih/test.h (TEST_ALLOC_FAIL): Macro that loops over a block of code
430 as many times as malloc is called within it, causing each malloc in
431 turn to be failed so we can increase code coverage.
432 (nih_test_allocator): Support function for the above; allows dumping
433 of malloc calls.
434 * nih/tests/test_child.c (test_add_watch): Use TEST_ALLOC_FAIL
435 and call nih_child_poll() first to not debug the init function
436 (test_poll): Remove race conditions by making sure the signal
437 has reached the child using waitid(). Test the "child we don't
438 know about has died" branch, along with waitid returning 0 with no
439 pid (needs a child process).
440 * nih/tests/test_command.c (test_parser, test_help): Use
441 TEST_ALLOC_FAIL
442 * nih/tests/test_config.c (test_next_arg, test_parse_args)
443 (test_parse_command, test_parse_block): Use TEST_ALLOC_FAIL
444 * nih/tests/test_error.c (test_raise, test_raise_printf)
445 (test_push_context, test_return_error): Use TEST_ALLOC_FAIL, to
446 make sure allocations are retried.
447 (test_pop_context): Split out from test_push_context.
448 * nih/tests/test_hash.c (test_new): Use TEST_ALLOC_FAIL
449 * nih/tests/test_io.c (test_add_watch, test_buffer_new)
450 (test_buffer_resize, test_buffer_pop, test_buffer_shrink)
451 (test_buffer_push, test_message_new, test_message_add_control)
452 (test_message_recv, test_message_send, test_reopen, test_watcher)
453 (test_read, test_write, test_get, test_printf): Use TEST_ALLOC_FAIL
454 liberally, make sure every code path involving a malloc gets tested.
455 * nih/tests/test_list.c (test_new): Use TEST_ALLOC_FAIL
456 * nih/tests/test_logging.c (test_log_message): Use TEST_ALLOC_FAIL
457 * nih/tests/test_main.c (test_main_loop_add_func): Use TEST_ALLOC_FAIL
458 (test_package_string): Use TEST_ALLOC_FAIL and also check repeated
459 calls return the same string.
460 (test_version): Use TEST_ALLOC_FAIL to check that allocation can
461 never fail.
462 * nih/tests/test_option.c (test_parser, test_version, test_help):
463 Use TEST_ALLOC_FAIL to make sure we behave
464 * nih/tests/test_signal.c (test_add_handler): Use TEST_ALLOC_FAIL
465 and call nih_signal_poll() first to not debug the init function
466 * nih/tests/test_string.c (test_sprintf, test_vsprintf)
467 (test_strdup, test_strndup, test_str_split, test_str_wrap)
468 (test_str_screen_wrap): Use TEST_ALLOC_FAIL
469 (test_str_screen_width): Check that we discard an illegal columns
470 variable.
471 * nih/tests/test_timer.c (test_add_timeout, test_add_periodic)
472 (test_add_scheduled): Use TEST_ALLOC_FAIL and call nih_timer_poll()
473 first to make sure we don't debug the init function
474 * nih/config.c (nih_config_next_arg, nih_config_parse_args)
475 (nih_config_parse_command, nih_config_parse_block): Allow us to fail
476 reading a configuration file because we run out of memory; it's not
477 that important.
478 * nih/io.c (nih_io_get): Catch failure to remove the string, and
479 don't remove the delimiter if that happens.
480 (nih_io_printf): Fix doc, this returns zero, not a length.
481 * nih/io.h: Fix prototype of nih_io_printf
482 * nih/logging.c (nih_log_message): Potentially failing message output
483 is crazy; loop until the alloc succeeds.
484 * nih/option.c (nih_option_handle): Free the options and arguments
485 before exiting; not really necessary, but makes valgrind happier.
486 * nih/string.c (nih_strndup): Failed to correctly detect a failed
487 allocation.
488 (nih_str_split): Correct some mistakes with allocations not
489 being checked.
490 * nih/libnih.supp: Add tmpfile.
491 * TODO: Update.
492
Scott James Remnant9156abc2007-01-11 02:05:14 +00004932007-01-11 Scott James Remnant <scott@netsplit.com>
494
495 * nih/file.h (NihDirWatch): New structure that defines a high-level
496 watch on a directory with various handlers to be called.
497 (NihCreateHandler, NihChangeHandler, NihDeleteHandler): Typedefs.
498 * nih/file.c (nih_dir_add_watch): Function to create an NihDirWatch
499 structure and fill it in.
500 (nih_dir_add_file_watch): Add a watch on a single directory,
501 catching errors and logging a warning if we can't watch it.
502 (nih_dir_watcher): Deal with inotify events within a directory tree,
503 taking care of issues such as re-organising of the directory structure
504 without ending up with duplicate watches.
505 (nih_file_reader): Only call the first matching watcher; we hit a
506 limitation in the inotify API caused by our usage of a single
507 descriptor. Will fix that shortly.
508 * nih/tests/test_file.c (test_dir_add_watch): Test that we can add
509 watches and have everything filled in nicely.
510
Scott James Remnant097784a2007-01-10 19:12:15 +00005112007-01-10 Scott James Remnant <scott@netsplit.com>
512
Scott James Remnanta33dcf12007-01-10 23:26:10 +0000513 * nih/file.c (nih_dir_walk): Function to walk a directory tree
514 calling a function for each object found.
515 * nih/file.h (NihFileFilter, NihFileVisitor): typedefs for
516 function pointers used for nih_dir_walk.
517 * nih/tests/test_file.c (test_walk): Test the walker.
518
Scott James Remnant38c45552007-01-10 22:51:57 +0000519 * nih/file.c (nih_file_reader): Pass the cookie to the watcher.
520 * nih/file.h (NihFileWatcher): Add cookie argument.
521 * nih/tests/test_file.c (test_add_watch): Check the cookie is
522 passed for a rename.
523
Scott James Remnant097784a2007-01-10 19:12:15 +0000524 * nih/file.c (nih_file_add_watch): Fix this to not add the inotify
525 watch unless it can allocate memory to handle it.
526
Scott James Remnantf3a62482007-01-09 16:16:47 +00005272007-01-09 Scott James Remnant <scott@netsplit.com>
528
Scott James Remnantf075fd82007-01-09 20:11:58 +0000529 * nih/config.c (nih_config_get_stanza): Catch entries with a zero
530 length name, and return one instead of NULL if it exists.
531 * nih/tests/test_config.c (test_parse_stanza): Make sure that ""
532 in a stanza table acts as a catch-all.
533
Scott James Remnantf3a62482007-01-09 16:16:47 +0000534 * nih/test.h (TEST_FILENAME): Use dashes not colons, to make things
535 more clear.
536
Scott James Remnante5234c22007-01-08 11:39:23 +00005372007-01-08 Scott James Remnant <scott@netsplit.com>
538
Scott James Remnant623868b2007-01-08 13:19:30 +0000539 * nih/config.c (nih_config_has_token): add a very small test function
540 so parsers can peek to see whether there is a next argument or not.
541 (nih_config_skip_comment, nih_config_parse_args)
542 (nih_config_parse_file): Use the new test function to make it more
543 obvious what we're doing.
544 * nih/config.h: Add prototype.
545 * nih/tests/test_config.c (test_has_token): Add test cases.
546
Scott James Remnant32d5be82007-01-08 12:45:09 +0000547 * nih/config.c: Allow all functions to be called with a zero length
548 file, we're completely guarded against pos going past the length,
549 so this cannot be a bad thing. Plus this allows zero-length tokens
550 to be extracted trivially.
551 (nih_config_next_arg): Raise an error if called in a position where
552 there is no argument. If you want to speculatively check for args,
553 peek first.
554 (nih_config_parse_stanza): No need to check for an empty stanza now,
555 nih_config_next_arg() handles that for us.
556 (nih_config_skip_comment): Function to allow us to skip only a
557 comment, while raising an error if we hit anything else.
558 (nih_config_parse_args, nih_config_parse_command): Skip comment only,
559 to guard against parser errors.
560 * nih/config.h: Update.
561 * nih/tests/test_config.c (test_next_arg): Check the new error is
562 raised, instead of the empty string being returned.
563 (test_parse_stanza): Check the expected token error is raised.
564 (test_skip_comment): Test the new function.
565 * nih/errors.h: Add new errors.
566
Scott James Remnant4e6f18f2007-01-08 11:39:42 +0000567 * nih/errors.h: Fix capitalisation of error messages.
568
Scott James Remnante5234c22007-01-08 11:39:23 +0000569 * nih/tests/test_config.c (test_parse_command): Add missing free
570 calls to strings obtained.
571
Scott James Remnant14962b32007-01-07 03:35:15 +00005722007-01-07 Scott James Remnant <scott@netsplit.com>
573
Scott James Remnantbf7ed8e2007-01-07 21:36:32 +0000574 * nih/config.c: Convert this file to use size_t where appropriate
575 instead of ssize_t, and raise exceptions for parsing errors rather
576 than logging them.
577 (nih_config_parse): Check a size is not greater then SSIZE_MAX (2GB)
578 to avoid overflows.
579 * nih/config.h: Update prototypes and handler function typedef.
580 * nih/errors.h: Add new error codes and strings.
581 * nih/tests/test_config.c: Adjust test cases.
582
Scott James Remnant2dad8692007-01-07 11:36:43 +0000583 * nih/config.c (nih_config_parse_file): Function to parse a mapped
584 file or string line-by-line starting from the given position.
585 (nih_config_parse): Function to map a file into memory and parse it
586 * nih/config.h: Add prototypes.
587 * nih/tests/test_config.c (test_parse_file): Test the function with
588 a small variety of different valid files.
589 (test_parse): Check we can parse a file, and get an error if it
590 doesn't exist.
591
Scott James Remnanta10a7742007-01-07 03:41:56 +0000592 * nih/config.c (nih_config_parse_stanza): Take a data pointer and
593 pass it to the handler, otherwise we can't fill in structures.
594 * nih/config.h: Update.
595 * nih/tests/test_config.c (test_parse_stanza): Check the data
596 pointer is passed properly.
597
Scott James Remnant91e0f502007-01-07 03:38:17 +0000598 * nih/tests/test_option.c (test_version, test_help): Capture the
599 return value from nih_option_parser, as we've set gcc attributes to
600 not let us do otherwise.
601
Scott James Remnant14962b32007-01-07 03:35:15 +0000602 * nih/config.h: Add structures, typedefs and macros to allow lists
603 of configuration stanzas to be built up.
604 * nih/config.c (nih_config_parse_args): Split argument parsing into
605 (nih_config_next_arg): This new function that wraps next_token and
606 also skips following whitespace.
607 (nih_config_next_line): Another new function that skips to the end
608 of the line, replacing severael copies of this code.
609 (nih_config_get_stanza): Simple function to find a stanza in a table
610 by its name.
611 (nih_config_parse_stanza): Simple stanza dispatch function; parses an
612 argument at the current position, looks it up in the table, then
613 calls the function.
614 * nih/tests/test_config.c (test_next_arg): Check this function works,
615 we know it does because it was covered by other tests, but it's worth
616 having its own as well.
617 (test_next_line): Check this function works too.
618 (test_parse_stanza): Make sure the dispatcher works properly.
619 * nih/config.c: Write from the code that was used for upstart,
620 making them exported functions to act as a configuration file kit.
621 (nih_config_parse_args): Fix a bug where lineno wasn't incremented
622 for an embedded newline in between arguments. Fix another bug where
623 a line containing only whitespace or whitespace and a comment would
624 hit an assertion - not a problem in practice, but it's a bug.
625 * nih/config.h: Function prototypes.
626 * nih/libnih.h: Include config.h
627 * nih/tests/test_config.c: Write an all new test suite that tests
628 the individual parsing functions for their functionality, rather
629 than trying to squeeze it into something larger.
630 * nih/Makefile.am (libnih_la_SOURCES): Build and link config.c
631 (nihinclude_HEADERS): Install config.h
632 (TESTS): Build and run config test suite
633 (test_config_SOURCES, test_config_LDFLAGS, test_config_LDADD): Config
634 test suite binary details.
635
Scott James Remnant939ff8e2007-01-06 19:28:37 +00006362007-01-06 Scott James Remnant <scott@netsplit.com>
637
Scott James Remnant14962b32007-01-07 03:35:15 +0000638 * nih/tests/test_io.c (test_watcher): Missing a priority that needed
639 changing to message.
640
Scott James Remnant68e6f922007-01-06 21:14:37 +0000641 * nih/command.h: Warn against unused results.
642
Scott James Remnant397a0602007-01-06 21:14:13 +0000643 * nih/option.h: Warn against unused results.
644
Scott James Remnant939ff8e2007-01-06 19:28:37 +0000645 * nih/logging.h (NihLogLevel): Add a message level between info
646 and warn, as we can't just re-use warn as that goes to stderr!
647 (nih_message): Change to use the new message level.
648 * nih/logging.c (nih_logger_syslog): Output messages at the notice
649 level, rather than the warning level.
650 (nih_log_init): Change the default priority to message.
651 * nih/tests/test_logging.c (test_log_message): Check that messages
652 are logged with the new message priority; reset to the new default.
653 (test_logger_printf): Make sure that ordinary messages go to stdout
654 and warning messages go to stderr.
655 (test_set_logger, test_set_priority): Reset to the new default.
656 * nih/tests/test_option.c (test_quiet, test_verbose, test_debug):
657 Check that messages are also logged, as well as warning; and set
658 the new default priority.
659 * nih/tests/test_error.c (test_raise_again, test_push_context):
660 Set log priority to the new default.
661 * nih/tests/test_io.c (test_watcher): Reset priority to the new
662 default.
663
Scott James Remnantcd88dd32007-01-05 17:42:36 +00006642007-01-05 Scott James Remnant <scott@netsplit.com>
665
Scott James Remnant095a9072007-01-05 18:47:11 +0000666 * nih/tests/test_io.c (test_shutdown): Uncomment the test for
667 shutdown when all messages are processed by the watcher.
668
Scott James Remnant0bab1432007-01-05 18:41:31 +0000669 * nih/io.c (nih_io_message_recv): Remove note about the remote end
670 being closed; when in message mode, this doesn't usually happen.
671 (nih_io_watcher): Only check for a zero length return if we're in
672 stream mode, otherwise it just means we got a zero length message.
673 (nih_io_watcher_read): Accept zero length messages and return them.
674 * nih/tests/test_io.c (test_watcher): Remove tests that tried to
675 mix a message-mode io and a dgram socket, that way lies disaster.
676
Scott James Remnanta2e399e2007-01-05 17:56:38 +0000677 * nih/io.c (nih_io_watcher_read, nih_io_watcher_write): Initialise
678 len to zero, as valgrind can be fussy about this when we call things
679 directly.
680
Scott James Remnantcd88dd32007-01-05 17:42:36 +0000681 * nih/io.h (NihIoMessage): Add a user data field to the message
682 structure so we can carry the pid around when queuing notification
683 messages in upstart.
684
Scott James Remnant12d53b02007-01-02 15:29:33 +00006852007-01-02 Scott James Remnant <scott@netsplit.com>
686
Scott James Remnantf1d97b52007-01-02 18:46:01 +0000687 * nih/alloc.h, nih/child.h, nih/command.h, nih/file.h, nih/hash.h:
688 nih/io.h, nih/logging.h, nih/main.h, nih/option.h, nih/signal.h:
689 nih/timer.h: Give names for all arguments in function pointer typedefs
690 so the documentation strings make more sense.
691
Scott James Remnant45b62a82007-01-02 16:51:24 +0000692 * nih/test.h (TEST_EQ_MEM, TEST_NE_MEM): Cast argument for number
693 of bytes to size_t.
694
Scott James Remnant12d53b02007-01-02 15:29:33 +0000695 * configure.ac (AC_COPYRIGHT): Update copyright to 2007.
696
Scott James Remnant2a001292006-12-29 10:36:40 +00006972006-12-29 Scott James Remnant <scott@netsplit.com>
698
Scott James Remnant7a21d4e2006-12-29 11:55:11 +0000699 * nih/errors.h: Drop the NIH_IO_MESSAGE_TRUNCATED error.
700
Scott James Remnante5032252006-12-29 11:54:25 +0000701 * nih/io.h (NihIoMessage): Rename msg_buf member to data, and change
702 ctrl_buf member to be an array of cmsg structures called control.
703 * nih/io.c: Update references to NihIoMessage members.
704 (nih_io_message_push_control): Rename to nih_io_message_add_control
705 (nih_io_message_add_control): Rewrite to add the control message
706 header onto the end of an array, rather than a control buffer,
707 (nih_io_message_recv): After receiving the message, extract all
708 control messages and put them into the array.
709 (nih_io_message_send): Take control messages from the array into a
710 single buffer and send them.
711
712 * nih/tests/test_io.c: Update references to NihIoMessage members.
713 (test_message_new): Check that the control member is initialised to
714 a one-element array containing NULL.
715 (test_message_push_control): Rename to test_message_add_control.
716 (test_message_add_control): Check the array is extended.
717
Scott James Remnant2a001292006-12-29 10:36:40 +0000718 * nih/io.c (nih_io_message_recv): Loop over a call to recvmsg() with
719 MSG_PEEK in its arguments to avoid ever returning truncated messages.
720 * nih/tests/test_io.c (test_message_recv): Adjust test for truncated
721 messages to make sure they do in fact work.
722 (test_watcher): Remove the oversized message error check.
723
Scott James Remnant0a10bc42006-12-21 00:24:05 +00007242006-12-21 Scott James Remnant <scott@netsplit.com>
725
Scott James Remnant209c9b12006-12-21 18:21:47 +0000726 * nih/tests/test_option.c (test_verbose): Add missing call to free
727 args.
728
Scott James Remnant5c5f7a92006-12-21 17:47:43 +0000729 * nih/io.c (nih_io_message_send): Change to return the ssize_t
730 received from sendmsg(), rather than an int.
731 (nih_io_watcher_read): Move read functionality out of
732 nih_io_watcher into a separate function that can deal with both
733 stream and message mode.
734 (nih_io_watcher_write): Move write functionality out of nih_io_watcher
735 into a separate function that can deal with both stream and message
736 mode.
737 (nih_io_watcher): Call the separate functions, and handle calling
738 the reader when in message mode. In addition, we now check the
739 error code when writing to a socket as well; there are useful errors
740 there (like ECONNREFUSED).
741 * nih/io.h: Update prototype of nih_io_message_send.
742 * nih/tests/test_io.c (test_message_send): Update return checks.
743 (test_watcher): Test that the error handled can now be called when
744 writing data to a socket, as well as just when reading. Test
745 message mode behaviour.
746
Scott James Remnantbe45d1f2006-12-21 01:00:11 +0000747 * nih/io.c (nih_io_send_message): Watch socket for writability.
748 (nih_io_write): Extend this function to work in message mode;
749 it allocates a new message, stores the data in that buffer, and
750 adds it to the send queue.
751 (nih_io_printf): Remove restriction that this only be called in
752 stream mode; the fact this calls nih_io_write is sufficient to
753 ensure correct behaviour.
754 * nih/tests/test_io.c (test_send_message): Check that we're testing
755 for writability.
756 (test_write): Test that this works in message mode.
757 (test_printf): Check that this works too, even though this only
758 really calls nih_io_write.
759
Scott James Remnant292fec22006-12-21 00:42:36 +0000760 * nih/io.c (nih_io_get): Extend so that this can operate in message
761 mode on the oldest message in the queue.
762 * nih/tests/test_io.c (test_get): Check that this works properly
763 in message mode; complete with shutdown check.
764
Scott James Remnant0a10bc42006-12-21 00:24:05 +0000765 * nih/io.c (nih_io_message_new): Do not assign a default list
766 destructor, it's not in a hidden list and there are bad consequences
767 of freeing a child with a default destructor if the list its in gets
768 freed first; new rule - default destructors only if the list is hidden
769 and never freed!
770 (nih_io_closed, nih_io_shutdown): Don't call the close handler if
771 the structure is already marked to be closed; there seems little
772 point, and we could accidentally call it multiple times.
773 (nih_io_read_message, nih_io_read, nih_io_get): Check whether we
774 need to shutdown the socket here, in case the watcher isn't polled
775 again.
776 * nih/tests/test_io.c (test_shutdown): Check that shutdown works
777 with message-mode structures (part of this disabled for now).
778 (test_read_message, test_read, test_get): Check that a shutdown
779 socket is closed when these are called.
780
Scott James Remnant6618ee62006-12-20 12:28:33 +00007812006-12-20 Scott James Remnant <scott@netsplit.com>
782
Scott James Remnant594cae02006-12-20 23:26:52 +0000783 * nih/io.c (nih_io_read): Extend so that it can be called in
784 message mode, it reads from the first message until it has been
785 exhausted; at which point it frees the message and the next call
786 would read from the next.
787 * nih/tests/test_io.c (test_read): Check that the new functionality
788 works properly.
789
Scott James Remnant5d10da02006-12-20 22:53:53 +0000790 * nih/io.c (nih_io_first_message): Simple static function to obtain
791 the oldest message in the receive queue.
792 (nih_io_read_message, nih_io_send_message): Functions to take the
793 oldest message out of the receive queue and append a message to the
794 send queue.
795 * nih/io.h: Add prototypes.
796 * nih/tests/test_io.c (test_read_message, test_send_message): Check
797 the new functions do what they say on the tin.
798
Scott James Remnanteb098222006-12-20 14:24:03 +0000799 General clean-up of nih_io, fixing a few API issues and making it
800 more suitable for using in message mode.
801
802 * nih/io.c (nih_io_buffer_pop, nih_io_buffer_shrink): Remove the
803 silly restrictions that these cannot be called with a length greater
804 than the buffer size, instead just truncate it to the buffer size.
805 (nih_io_buffer_pop): Length is now updated to the actual number of
806 bytes being returned.
807 (nih_io_message_add_control): Rename to nih_io_message_push_control.
808 (nih_io_message_recv): Change the len parameter to a pointer that's
809 updated with the actual number of bytes read.
810 (nih_io_stream_watcher): Rename back to nih_io_watcher.
811 (nih_io_reopen): Use a single watcher function again, initialise close
812 to NULL. Treat failure to set a descriptor non-blocking as a failure
813 to open; otherwise we'll end up screwing up the main loop.
814 (nih_io_watcher): Remove the restriction that this is only called
815 when in the stream mode. Leave data in the receive buffer if there's
816 no reader function, it's now valid to query the buffer size and read
817 by other means. Catch the ENOMEM error and ignore it. Set and keep
818 an eye on the structure close member, if it is TRUE before we return,
819 close the socket. This also means we check for shutdown sockets in
820 the case of error, which we probably should have done.
821 (nih_io_maybe_shutdown): Rename to nih_io_shutdown_check.
822 (nih_io_close): If the close member of the structure is not NULL
823 we're inside a watcher function, so need to set the variable this
824 points to to TRUE instead of closing or freeing the structure.
825 (nih_io_read): Change the len parameter to be updated with the
826 actual number of bytes being returned.
827 * nih/io.h: Renamed function prototype. Updated documentation for
828 function typedefs to clarify that they may all call nih_io_close,
829 but may not call nih_free.
830 * nih/errors.h: Rename NIH_TRUNCATED_MESSAGE to
831 NIH_IO_MESSAGE_TRUNCATED, we should probably namespace these.
832 * nih/tests/test_io.c (test_buffer_pop, test_buffer_shrink): Check
833 that we can pop or shrink the entire buffer if we ask for more.
834 (test_message_add_control): Rename to test_push_control.
835 (test_message_recv): Check that the cases of remote end closed,
836 error received or truncated message are handled properly.
837 (test_message_send): Check that an error is handled.
838 (test_stream_watcher): Rename back to test_watcher.
839 (test_reopen): Check that the socket is not being shutdown or closed.
840 (test_shutdown): Drain the buffer before calling handle on it, as
841 it's not done automatically now.
842 (test_close): Check that a lazy close is performed if io->close is
843 not NULL.
844 * nih/file.c (nih_file_reader): Update call to nih_io_read.
845
Scott James Remnant6618ee62006-12-20 12:28:33 +0000846 * nih/logging.h (nih_assert_notreached): Rename to
847 nih_assert_not_reached, this was annoying me.
848
Scott James Remnant73caada2006-12-19 17:59:48 +00008492006-12-19 Scott James Remnant <scott@netsplit.com>
850
Scott James Remnant610ec392006-12-19 22:14:17 +0000851 * nih/io.c (nih_io_read, nih_io_write, nih_io_get, nih_io_printf):
852 Ensure the NihIo structure is in stream mode; as these only really
853 make sense if there's a limitless buffer.
854
Scott James Remnant54cbe382006-12-19 21:39:28 +0000855 * nih/tests/test_io.c (test_shutdown): Make sure the socket is
856 shut down immediately.
857 * nih/io.c (nih_io_shutdown): Bugfix, should close the socket
858 immediately if there's nothing in the queue, otherwise it may
859 hang around forever if it never polls.
860
Scott James Remnant499cf162006-12-19 21:28:19 +0000861 * nih/io.c (nih_io_reopen): Receive the type from the arguments,
862 instead of hard-coding to be stream. Set up the structure accordingly.
863 * nih/io.h: Update prototype.
864 * nih/tests/test_io.c (test_reopen): Check message mode is allocated
865 properly.
866 * nih/file.c (nih_file_init): Open in stream mode.
867
Scott James Remnant687f1f82006-12-19 21:10:30 +0000868 * nih/io.c (nih_io_message_new): Catch failure to allocate message
869 or control buffer.
870 (nih_io_message_add_control): No need to try and allocate the control
871 buffer here.
872 (nih_io_message_recv): Only need to resize the buffers here as well.
873 (nih_io_message_send): No need to deal with there being no message
874 or control buffer here either.
875 * nih/tests/test_io.c: Fix test assumptions based on above.
876 * nih/libnih.supp: Add missing nih_io_init suppression.
877
878 * nih/tests/test_io.c (test_message_add_control): Non need to check
879 allocation of the buffer itself.
880
Scott James Remnant332f2b02006-12-19 20:40:51 +0000881 * nih/io.c (nih_io_message_add_control): Function to add a control
882 message to the control buffer, to save mucking around with difficult
883 bits ourselves.
884 * nih/io.h: Add prototype.
885 * nih/tests/test_io.c (test_message_add_control): Check that it
886 works properly.
887
Scott James Remnant054bbbc2006-12-19 18:14:32 +0000888 * nih/io.c (nih_io_buffer_shrink): Make an exported function, resize
889 the buffer once done to save on memory.
890 (nih_io_buffer_pop, nih_io_stream_watcher): No need to explicitly
891 resize here now, as it gets called from shrink.
892 * nih/io.h: Add prototype.
893 * nih/tests/test_io.c (test_buffer_shrink): Test shrink.
894
Scott James Remnant73caada2006-12-19 17:59:48 +0000895 * nih/io.c (nih_io_message_recv, nih_io_message_send): Functions
896 to send and receive a message over a socket, hiding the difficult
897 bits of dealing with msghdr/iovec.
898 (nih_io_get_family): Function to detect the family of a socket.
899 * nih/io.h: Update.
900 * nih/errors.h: Add truncated message error.
901 * nih/tests/test_io.c (test_message_recv, test_message_send): Check
902 that we can send and receive messages by using socket pairs.
903 (test_get_family): Check that we can get the families of the standard
904 three socket types.
905
Scott James Remnant85a241a2006-12-18 14:48:39 +00009062006-12-18 Scott James Remnant <scott@netsplit.com>
907
908 * nih/io.h (NihIoMessage): Structure that represents an individual
909 message in a queue; has a buffer for the message, and for ancillary
910 control data, as well as an address that the message is being sent
911 to or received from.
912 (NihIoType): Enum to select whether an NihIo structure is in stream
913 mode or message mode.
914 (NihIo): Add a type member to select whether this is in stream or
915 message mode, and a union to select whether we're using buffers
916 or message queues.
917 * nih/io.c (nih_io_message_new): Allocate an NihIoMessage and its
918 child buffers.
919 (nih_io_reopen): Initialise the type to NIH_IO_STREAM.
920 (nih_io_watcher): Rename to nih_io_stream_watcher.
921 * nih/tests/test_io.c (test_message_new): Check that the new message
922 structure is initialised properly.
923 (test_reopen): Check that we get a stream structure by default.
924 (test_watcher): Rename to test_stream_watcher.
925
Scott James Remnantd79e0ae2006-12-17 14:23:52 +00009262006-12-17 Scott James Remnant <scott@netsplit.com>
927
Scott James Remnant8b5bec62006-12-17 18:53:24 +0000928 * nih/logging.h (nih_assert_notreached): Add an assertion for the
929 use in default bits of switches, etc.
930
Scott James Remnantd614c612006-12-17 16:52:31 +0000931 * nih/test.h (TEST_EQ_U, TEST_NE_U): Versions of the original macros
932 that cast to size_t for display, instead of ssize_t.
933
Scott James Remnantd79e0ae2006-12-17 14:23:52 +0000934 * nih/tests/test_logging.c, nih/tests/test_string.c: Set local
935 variables to avoid gcc thinking that they may be unused when
936 using TEST_DIVERT_*.
937
Scott James Remnant5a34b9c2006-12-14 11:39:27 +00009382006-12-14 Scott James Remnant <scott@netsplit.com>
939
940 * HACKING: Correct some typos.
941
Scott James Remnant104bb082006-12-13 18:19:48 +00009422006-12-13 Scott James Remnant <scott@netsplit.com>
943
944 * nih/test.h (TEST_FILENAME): Wrap with do { ... } while (0)
945 in case this gets used as a single line statement.
946
Scott James Remnantd4d63c62006-12-13 18:05:21 +00009472006-12-13 Johan Kiviniemi <johan@kiviniemi.name>
948
949 * nih/test.h (TEST_FILE_RESET): Wrap with do { ... } while (0)
950 in case this gets used as a single line statement.
951
Scott James Remnantc5f31372006-12-13 16:54:12 +00009522006-12-13 Scott James Remnant <scott@netsplit.com>
953
954 * nihify: Link to the nih ChangeLog.
955
Scott James Remnant724bf552006-12-12 11:20:40 +00009562006-12-12 Scott James Remnant <scott@netsplit.com>
957
Scott James Remnant1a003362006-12-12 17:18:11 +0000958 * nih/test.h (TEST_CHILD_WAIT, TEST_CHILD_RELEASE): Sometimes the
959 primitive "when the child is running" locking provided by TEST_CHILD
960 isn't sufficient, and we actually need to perform some actions in
961 the child before we let the parent carry on. These two macros
962 allow that.
963
Scott James Remnant1edabdd2006-12-12 12:24:44 +0000964 * nih/libnih.supp: Include a valgrind suppressions file.
965 * nih/Makefile.am (EXTRA_DIST): Distribute the suppressions file.
966
Scott James Remnant561f23e2006-12-12 12:06:22 +0000967 * nih/tests/test_alloc.c (test_realloc): Fix missing free.
968
Scott James Remnant724bf552006-12-12 11:20:40 +0000969 * configure.ac (AM_GNU_GETTEXT_VERSION): Quote version number.
970
Scott James Remnant50b58d52006-12-09 10:19:58 +00009712006-12-09 Scott James Remnant <scott@netsplit.com>
972
973 * nih/test.h (TEST_DIVERT_STDOUT_FD, TEST_DIVERT_STDERR_FD): Flush
974 before dup2ing the original file descriptor back, otherwise we end
975 up with the content still in the buffer later.
976
Scott James Remnanta8d6d842006-12-08 17:07:13 +00009772006-12-08 Scott James Remnant <scott@netsplit.com>
978
Scott James Remnant7e75a6a2006-12-08 18:11:05 +0000979 * HACKING: Document that test cases are expected.
980
Scott James Remnanta4710a42006-12-08 18:05:43 +0000981 * nih/tests/test_command.c: Port to the new test framework.
982
Scott James Remnant7f798c92006-12-08 17:23:37 +0000983 * nih/tests/test_option.c: Drop unused include.
984
Scott James Remnanta8d6d842006-12-08 17:07:13 +0000985 * nih/tests/test_option.c: Port to the new test framework.
986
Scott James Remnant000e9a42006-12-07 11:43:37 +00009872006-12-07 Scott James Remnant <scott@netsplit.com>
988
Scott James Remnant4aa61bc2006-12-07 17:42:19 +0000989 * nih/tests/test_io.c: Port to the new test framework.
990
Scott James Remnant5c797d92006-12-07 16:00:15 +0000991 * nih/tests/test_hash.c: Drop use of assert.
992
Scott James Remnant43819d32006-12-07 13:39:30 +0000993 * nih/tests/test_timer.c (test_poll): Formatting fix.
994
Scott James Remnant52959212006-12-07 13:28:58 +0000995 * nih/tests/test_string.c: Port to the new test framework.
996
Scott James Remnant07dfc472006-12-07 13:28:45 +0000997 * nih/test.h (TEST_DIVERT_STDOUT_FD, TEST_DIVERT_STDERR_FD): Macros
998 to divert to a file descriptor instead of a file.
999 (TEST_DIVERT_STDOUT, TEST_DIVERT_STDERR): Redefine as wrappers around
1000 the new macros.
1001
Scott James Remnantec3da3f2006-12-07 12:57:11 +00001002 * nih/tests/test_timer.c: Port to the new test framework.
1003
Scott James Remnantc7cab092006-12-07 12:45:19 +00001004 * nih/tests/test_signal.c: Port to the new test framework.
1005
Scott James Remnant3ca38802006-12-07 12:14:32 +00001006 * nih/tests/test_main.c: Port to the new test framework.
1007
Scott James Remnant8b786d32006-12-07 12:12:02 +00001008 * nih/test.h: Cast strlen return value to int when used to give
1009 the length of a string in printf.
1010
Scott James Remnante65ede72006-12-07 11:43:50 +00001011 * nih/tests/test_logging.c: Port to the new test framework.
1012
Scott James Remnant000e9a42006-12-07 11:43:37 +00001013 * nih/test.h (TEST_DIVERT_STDOUT, TEST_DIVERT_STDERR): Crazy macros
1014 to divert stdout or stderr to a different file, making sure it's
1015 flushed before both dups.
1016 (TEST_EQ_STRN, TEST_NE_STRN): Functions to check a string up to a
1017 particular point.
1018 (TEST_FILE_EQ, TEST_FILE_EQ_N, TEST_FILE_NE, TEST_FILE_NE_N):
1019 Functions to grab a line from a file and check it against a string.
1020 (TEST_FILE_END): Function to determine end of file.
1021 (TEST_FILE_RESET): Another function so I don't need to remember the
1022 runes to flush, rewind and truncate a file.
1023
Scott James Remnantc81a2552006-12-06 13:40:16 +000010242006-12-06 Scott James Remnant <scott@netsplit.com>
1025
Scott James Remnante43ba4c2006-12-06 16:30:57 +00001026 * nih/tests/test_file.c: Port to the new test framework.
1027
Scott James Remnant257f2232006-12-06 16:29:50 +00001028 * nih/test.h (TEST_EQ_MEM, TEST_NE_MEM): Tests that wrap memcmp.
1029 (TEST_FILENAME): Macro to generate a filename.
1030
Scott James Remnant787f2372006-12-06 15:57:32 +00001031 * nih/tests/test_error.c: Port to the new test framework.
1032
Scott James Remnant881b8a12006-12-06 15:36:27 +00001033 * nih/tests/test_alloc.c, nih/tests/test_list.c, nih/tests/test_hash.c:
1034 Undo over-zealous removing of includes.
1035
Scott James Remnantac8e7a12006-12-06 15:33:45 +00001036 * nih/tests/test_child.c: Port to the new test framework.
1037
Scott James Remnant6e450a92006-12-06 15:31:17 +00001038 * nih/test.h (TEST_CHILD): Macro to spawn an interlocked child
1039 process, so we don't keep having to remember how to.
1040
Scott James Remnantc81a2552006-12-06 13:40:16 +00001041 * nih/test.h (TEST_ALLOC_SIZE, TEST_ALLOC_PARENT): Include the
1042 expression that generated the pointer, as well as the pointer.
1043 (TEST_LIST_EMPTY, TEST_LIST_NOT_EMPTY): Check whether a list is
1044 empty or not.
1045 * nih/tests/test_list.c (test_empty, test_foreach_safe): Use the
1046 new list test macros instead of TEST_TRUE/TEST_FALSE.
1047 * nih/tests/test_hash.c (test_new): Likewise.
1048
Scott James Remnantafcf58b2006-12-05 12:22:33 +000010492006-12-05 Scott James Remnant <scott@netsplit.com>
1050
Scott James Remnant27a4c112006-12-05 23:37:30 +00001051 * nih/tests/test_hash.c: Port to the new test framework.
1052
Scott James Remnantf119d692006-12-05 21:38:02 +00001053 * nih/tests/test_list.c: Port to the new test framework.
1054
Scott James Remnantc051f682006-12-05 20:50:25 +00001055 * nih/tests/test_alloc.c: Port to the new test framework.
1056 (test_set_allocator): Test that the allocator is called with zero
1057 as the argument.
1058
Scott James Remnant8107b442006-12-05 20:49:36 +00001059 * nih/test.h: Include config.h on behalf of the test suites.
1060
Scott James Remnant9d4deb32006-12-05 20:48:53 +00001061 * nih/test.h (TEST_EQ_STR, TEST_NE_STR): String comparison tests.
1062
Scott James Remnantfd51d012006-12-05 19:59:04 +00001063 * nih/test.h (TEST_FAILED): abort is much better than exit
1064
Scott James Remnant8884c312006-12-05 19:11:27 +00001065 * nih/test.h (INIT_TEST): Drop this, we'll just return directly.
1066 (TEST_FAILED): Return directly on failure.
1067 (CALL_TEST): Drop this again.
1068
Scott James Remnantd91c3132006-12-05 19:01:26 +00001069 * nih/test.h (CALL_TEST): Add "call a function" macro.
1070
Scott James Remnant67a9b5c2006-12-05 18:58:35 +00001071 * nih/test.h: Macros that implement a simple test framework based
1072 on the patterns I was using anyway.
1073 * nih/Makefile.am (nihinclude_HEADERS): Install nih/test.h
1074
Scott James Remnant83c77862006-12-05 14:44:47 +00001075 * nih/tests/test_command.c (test_parser, test_help): flush stdout
1076 or stderr before calling dup2().
1077
Scott James Remnant5149f692006-12-05 14:42:45 +00001078 * nih/tests/test_option.c (test_parser, test_version, test_help):
1079 flush stdout or stderr before calling dup2().
1080
Scott James Remnantde99cbb2006-12-05 14:40:13 +00001081 * nih/tests/test_io.c: Formatting fix.
1082
Scott James Remnant10630ad2006-12-05 14:38:01 +00001083 * nih/file.c (nih_file_map): Tidy up; in particular don't allow
1084 opening in just write mode, seeing as that doesn't work.
1085 * nih/tests/test_file.c (test_unmap): Test unmap separately.
1086 (test_map): Update for new checks.
1087
Scott James Remnant73eab772006-12-05 14:22:15 +00001088 * nih/file.c (nih_file_add_watch): No need to set ENOMEM if
1089 nih_new fails, that will be already set.
1090 (nih_file_reader): Clarify why nih_io_read must return a pointer.
1091
Scott James Remnant6e927882006-12-05 14:06:04 +00001092 * nih/tests/test_string.c (test_str_screen_width)
1093 (test_str_screen_wrap): flush stdout before calling dup2().
1094
Scott James Remnante5fca7a2006-12-05 14:02:18 +00001095 * nih/tests/test_main.c (test_suggest_help, test_version): flush
1096 stdout or stderr before calling dup2().
1097
Scott James Remnantf7a83e02006-12-05 13:59:30 +00001098 * nih/tests/test_logging.c (test_logger_printf): flush stdout or
1099 stderr before calling dup2(), otherwise we don't know which stream
1100 the buffered output will be going to.
1101
Scott James Remnant32965ca2006-12-05 13:25:09 +00001102 * nih/tests/test_error.c (test_push_context): Check that unhandled
1103 errors within a context are notified and freed if the context is
1104 popped.
1105
Scott James Remnantb862b9a2006-12-05 13:11:49 +00001106 * nih/alloc.c (nih_alloc_reparent): Function to reparent a pointer
1107 to a new parent or just orphan it.
1108 * nih/alloc.h: Update.
1109 * nih/tests/test_alloc.c (test_reparent): Make sure it works.
1110
Scott James Remnant82a3f312006-12-05 12:48:22 +00001111 * nih/tests/test_alloc.c (test_alloc_using): Check that this works
1112 properly if the allocator returns NULL.
1113 (test_realloc): A few cases to check here; make sure that it works
1114 if the pointer to realloc is NULL, actually test the children
1115 reparenting code here and test the reallocator returning NULL.
1116
Scott James Remnantafcf58b2006-12-05 12:22:33 +00001117 * README: Correct typo.
1118
Scott James Remnantdd9fe392006-11-12 11:21:00 -080011192006-11-12 Scott James Remnant <scott@netsplit.com>
1120
Scott James Remnant049d7c92006-11-12 16:36:40 -08001121 * nih/Makefile.am (INCLUDES, DEFS): Drop these two variables
1122 (AM_CPPFLAGS): in favour of this combined variable.
1123
Scott James Remnant12758ed2006-11-12 15:48:41 -08001124 * configure.ac (AM_INIT_AUTOMAKE): Include nostdinc so we don't get
1125 Automake's broken default includes.
1126 * nih/Makefile.am (INCLUDES): Include $top_builddir and $top_srcdir,
1127 everything else wants relative paths from there.
1128 (DEFAULT_INCLUDES): Drop override now we don't need it.
1129
Scott James Remnantdd9fe392006-11-12 11:21:00 -08001130 * m4/compiler.m4 (NIH_C_THREAD): Define a macro in the manner of
1131 AC_C_CONST that will #define __thread to empty if it isn't supported
1132 by the compiler.
1133 * m4/misc.m4 (NIH_INIT): libnih uses __thread.
1134
Scott James Remnant3262cee2006-10-13 14:25:07 +010011352006-10-13 Scott James Remnant <scott@netsplit.com>
1136
1137 * nih/command.h: Adjust type of NihCommandAction to include const.
1138 * nih/tests/test_command.c (my_action): Update.
1139
Scott James Remnantb5d843c2006-10-12 15:09:15 +010011402006-10-12 Scott James Remnant <scott@netsplit.com>
1141
1142 * configure.ac: Expand AC_GNU_SOURCE so we get _GNU_SOURCE and so
1143 that gettext doesn't complain.
1144 (AM_GNU_GETTEXT_VERSION): Increase to 0.15
1145 (AC_PREREQ): Increase to 2.60
1146 * HACKING: Update autoconf and gettext requirements.
1147
Scott James Remnant24ba6282006-10-11 11:43:22 +010011482006-10-11 Scott James Remnant <scott@netsplit.com>
1149
Scott James Remnant297f6362006-10-11 17:36:28 +01001150 * nih/string.c (nih_str_screen_wrap): Don't quite fill the screen,
1151 instead leave a character spare as it looks somehow neater that way.
1152 * nih/option.c (nih_option_group_help): Likewise.
1153 * nih/tests/test_string.c (test_str_screen_wrap): Update tests.
1154 * nih/tests/test_option.c (test_help): Fix wrapping test.
1155
Scott James Remnant7674efd2006-10-11 16:49:32 +01001156 * TODO: Update.
1157
Scott James Remnantec11a812006-10-11 16:44:23 +01001158 * nih/command.c: Implement a command parser that uses the first
1159 non-option argument (or program name) and selects different help
1160 and options based on that.
1161 * nih/command.h: Structures and prototypes.
1162 * nih/libnih.h: Include command.h
1163 * nih/tests/test_command.c: Test suite for command parser.
1164 * nih/Makefile.am (libnih_la_SOURCES): Build and link command.c
1165 (nihinclude_HEADERS): Install command.h
1166 (TESTS): Build and run command test cases
1167 (test_command_SOURCES, test_command_LDFLAGS, test_command_LDADD):
1168 Details for command test suite binary.
1169
Scott James Remnanta4febfc2006-10-11 15:48:30 +01001170 * nih/tests/test_option.c: Keep a copy of last_option otherwise
1171 it's freed while we're not around.
1172
Scott James Remnant55a98742006-10-11 14:09:55 +01001173 * nih/option.c (nih_option_set_footer): Add a footer string.
1174 (nih_option_help): Also add the footer string.
1175 * nih/option.h: Update.
1176 * nih/tests/test_option.c (test_help): Check the footer.
1177
Scott James Remnant9dfd41d2006-10-11 14:00:37 +01001178 * nih/option.c (nih_option_set_usage_stem): Add function to set
1179 the "[OPTION]..." bit of the usage line.
1180 (nih_option_help): Use the usage stem if set.
1181 * nih/option.h: Update.
1182 * nih/tests/test_option.c (test_help): Check the usage stem.
1183
Scott James Remnantb6902592006-10-11 12:35:24 +01001184 * nih/option.c (nih_option_join): Add function to combine two lists
1185 of options.
1186 (nih_option_parser): Join the options and default_options lists,
1187 don't play with arrays of lists.
1188 (nih_option_get_short, nih_option_get_long): Simply by just iterating
1189 the one array.
1190 (nih_option_help, nih_option_group_help): Again simply by just
1191 iterating the one array.
1192 * nih/option.h: Update.
1193 * nih/tests/test_option.c (test_parser): Don't check addresses of
1194 options as they've moved.
1195
Scott James Remnantcf9d1bd2006-10-11 11:48:33 +01001196 * nih/option.c (nih_option_set_usage, nih_option_set_synopsis)
1197 (nih_option_set_help): Allow NULL to be set to override existing
1198 strings.
1199
Scott James Remnant24ba6282006-10-11 11:43:22 +01001200 * nih/option.c (nih_option_help): Make static.
1201 * nih/option.h: Update.
1202
Scott James Remnant48890942006-10-10 12:28:39 +010012032006-10-10 Scott James Remnant <scott@netsplit.com>
1204
Scott James Remnant28a55e92006-10-10 18:29:29 +01001205 * TODO: Update.
1206
Scott James Remnant6b000dd2006-10-10 18:29:11 +01001207 * nih/option.c (nih_option_group_help): Use a factor of the screen
1208 width when formatting help options, but keep at least 20 chars
1209 visible at all times.
1210
Scott James Remnant9a196642006-10-10 18:24:37 +01001211 * nih/string.c (nih_str_screen_width): Add function to return just
1212 the screen width.
1213 (nih_str_screen_wrap): Use that function.
1214 * nih/string.h: Update.
1215 * nih/tests/test_string.c (test_str_screen_width): Check function.
1216
Scott James Remnantd1342ff2006-10-10 18:10:48 +01001217 * nih/option.c (nih_option_set_synopsis): Function to set a synopsis
1218 string that follows the usage.
1219 (nih_option_set_help): Function to set the help string that follows
1220 the options.
1221 (nih_option_help): Output synopsis and help strings.
1222 * nih/option.h: Update.
1223 * nih/tests/test_option.c (test_help): Check behaviour
1224
Scott James Remnant110e57a2006-10-10 17:42:58 +01001225 * TODO: Update.
1226
Scott James Remnant34caaa32006-10-10 17:35:07 +01001227 * nih/main.c (nih_main_version): Use nih_str_screen_wrap to output
1228 the GPL preamble bit.
1229 * nih/tests/test_main.c (test_version): Unset COLUMNS just in case.
1230
Scott James Remnantd2644582006-10-10 17:29:15 +01001231 * nih/string.c (nih_str_screen_wrap): Add wrapper around
1232 nih_str_wrap that obtains the screen width and uses that for len.
1233 * nih/string.h: Add prototype.
1234 * nih/tests/test_string.c (test_str_screen_wrap): Test new function.
1235 * nih/Makefile.am (test_string_LDADD): Link with -lutil so we can
1236 use openpty in our "fake terminal" tests.
1237
Scott James Remnant1f880f22006-10-10 16:52:46 +01001238 * nih/tests/test_option.c: Fix minor test case memory leak.
1239
Scott James Remnant981fa8e2006-10-10 16:48:32 +01001240 * nih/tests/test_child.c (test_poll, test_poll): Use better
1241 interlocks then usleep.
1242
Scott James Remnant5fadcfa2006-10-10 16:42:44 +01001243 * nih/tests/test_option.c (main): Enable test of --debug, oops.
1244
Scott James Remnantad5cc382006-10-10 16:39:39 +01001245 * nih/main.c (nih_main_daemonise): Document why this is better than
1246 daemon(), and thus not nih.
1247 * nih/tests/test_main.c (test_daemonise): Test the daemonise
1248 function works properly.
1249
Scott James Remnant1e5829a2006-10-10 15:53:13 +01001250 * nih/timer.h: Fix comments.
1251
1252 * nih/hash.c (nih_hash_new): This needs a parent pointer too.
1253 * nih/hash.h: Update prototype.
1254 * nih/tests/test_hash.c: Update test cases.
1255
Scott James Remnant6a8ebf62006-10-10 15:42:23 +01001256 * nih/child.c: Clarify child_watches item types.
1257 * nih/file.c: Clarify file_watches item types.
1258 * nih/io.c: Clarify io_watches item types.
1259 * nih/main.c: Clarify loop_functions item types.
1260 * nih/timer.c: Clarify timers item types.
1261
Scott James Remnant65f621b2006-10-10 15:39:57 +01001262 * nih/signal.h (NihSignalCb): Rename to NihSignalHandler.
1263 (NihSignal): Change callback name to handler and type
1264 to NihSignalHandler.
1265 * nih/signal.c (nih_signal_add_callback): Rename to
1266 nih_signal_add_handler.
1267 * nih/tests/test_signal.c: Update.
1268
Scott James Remnant602eda42006-10-10 15:33:56 +01001269 * nih/list.c (nih_list_new): Take a parent pointer like everything
1270 else, showing its age slightly.
1271 * nih/list.h: Update prototype.
1272 * nih/tests/test_list.c: Update test cases.
1273 * nih/child.c (nih_child_init): Pass NULL to nih_list_new().
1274 * nih/error.c (nih_error_init): Pass NULL to nih_list_new().
1275 * nih/file.c (nih_file_init): Pass NULL to nih_list_new().
1276 * nih/io.c (nih_io_init): Pass NULL to nih_list_new().
1277 * nih/main.c (nih_main_loop_init): Pass NULL to nih_list_new().
1278 * nih/signal.c (nih_signal_init): Pass NULL to nih_list_new().
1279 * nih/timer.c (nih_timer_init): Pass NULL to nih_list_new().
1280 * nih/tests/test_hash.c: Pass NULL to nih_list_new().
1281
Scott James Remnant9180a362006-10-10 15:29:05 +01001282 * nih/alloc.c, nih/alloc.h, nih/child.c, nih/child.h, nih/error.c,
1283 nih/error.h, nih/file.c, nih/file.h, nih/hash.c, nih/hash.h,
1284 nih/io.c, nih/io.h, nih/list.c, nih/list.h, nih/main.c, nih/main.h,
1285 nih/option.c, nih/option.h, nih/signal.c, nih/signal.h, nih/string.c,
1286 nih/string.h, nih/timer.c, nih/timer.h: Clean up documentation and
1287 parent return values.
1288
Scott James Remnant32682c82006-10-10 14:42:20 +01001289 * HACKING: Detail function documentation requirement and format.
1290
Scott James Remnant48890942006-10-10 12:28:39 +01001291 * nih/tests/test_signal.c (test_set_default, test_set_ignore)
1292 (test_reset): amd64 seems to set the SA_NODEFER flag even when
1293 you pass zero, so just check we clear important bits.
1294
Scott James Remnantc945ac62006-09-27 21:24:37 +010012952006-09-27 Scott James Remnant <scott@netsplit.com>
1296
1297 * m4/misc.m4 (NIH_INIT): Add easier macro for using libnih.
1298 * m4/compiler.m4: Remove hack to include misc.m4
1299 * configure.ac: Drop the macro set and replace with NIH_INIT
1300 * README: Update.
1301 * nihify: Warn if NIH_INIT not present.
1302
Scott James Remnanta20ab6d2006-09-25 21:57:30 +010013032006-09-25 Scott James Remnant <scott@netsplit.com>
1304
Scott James Remnant01389422006-09-25 21:59:00 +01001305 * TODO (main): Update.
1306
Scott James Remnanta20ab6d2006-09-25 21:57:30 +01001307 * nih/logging.h (nih_message): Add nih_message as an alias for
1308 nih_warn.
1309 * nih/tests/test_logging.c (test_log_message): Check new macro.
1310
Scott James Remnant3cdf5c52006-09-20 04:28:07 +010013112006-09-20 Michael Biebl <mbiebl@gmail.com>
1312
1313 * nih/tests/test_file.c: Include nih/inotify.h when sys/inotify.h
1314 is not available.
1315
Scott James Remnant4f654222006-09-19 17:54:11 +010013162006-09-19 Michael Biebl <mbiebl@gmail.com>
1317
1318 * nih/Makefile.am (nihinclude_HEADERS): Install inotify.h just in
1319 case it's required
1320
Scott James Remnanta8530bb2006-09-18 19:41:39 +010013212006-09-18 Michael Biebl <mbiebl@gmail.com>
1322
1323 * configure.ac: Check for sys/inotify.h
1324 * nih/inotify.h: Taken from udev, this defines the syscalls
1325 and flags, etc. for inotify on glibc 2.3
1326 * nih/file.c, nih/file.h: Include nih/inotify.h if we do not have
1327 sys/inotify.h
1328
Scott James Remnantc3477262006-09-13 16:54:49 +010013292006-09-13 Scott James Remnant <scott@netsplit.com>
1330
1331 * nih/child.c (nih_child_poll): Zero the siginfo_t struct before
1332 every call to waitid(), the kernel doesn't do it for us when
1333 running the compat syscall (but does for the native one *sigh).
1334
Scott James Remnant2e513b62006-09-08 03:39:18 +010013352006-09-08 Scott James Remnant <scott@netsplit.com>
1336
Scott James Remnant24865e32006-09-08 17:50:11 +01001337 * TODO: Update.
1338
Scott James Remnant29910f92006-09-08 03:49:20 +01001339 * nih/option.c (nih_option_help): Allow the usage string to be
1340 customised.
1341 (nih_option_set_usage): Using this function.
1342 * nih/option.h: Update.
1343 * nih/tests/test_option.c (test_help): Test the usage string.
1344
Scott James Remnant7f9a4362006-09-08 03:42:45 +01001345 * nih/main.c (nih_main_daemonise): Use program_name for the pid file.
1346 * nih/main.h: Update.
1347
Scott James Remnant2e513b62006-09-08 03:39:18 +01001348 * nih/main.c (nih_main_daemonise): Add a daemonise function,
1349 pretty standard really.
1350 * nih/main.h: Update.
1351
Scott James Remnant1f38a002006-09-07 21:26:09 +010013522006-09-07 Scott James Remnant <scott@netsplit.com>
1353
1354 * AUTHORS: Mention the ChangeLog file.
1355
Scott James Remnant17252362006-09-04 07:15:40 +010013562006-09-04 Scott James Remnant <scott@netsplit.com>
1357
Scott James Remnant4dc16742006-09-04 07:46:00 +01001358 * README: Add some documentation for the curious.
1359
Scott James Remnant1c7d2df2006-09-04 07:25:17 +01001360 * nih/file.c (nih_file_add_watch): Set nih_file_remove_watch as
1361 the default destructor so that nih_free can be called or work in
1362 a tree.
1363 (nih_file_remove_watch): Modify to not call nih_free and work if
1364 called multiple times.
1365
Scott James Remnantf81341b2006-09-04 07:18:08 +01001366 * nih/signal.c (nih_signal_set_default, nih_signal_set_ignore):
1367 Set flags to zero when defaulting or ignoring signals.
1368 * nih/tests/test_signal.c (test_set_default, test_set_ignore)
1369 (test_reset): Modify test cases appropriately.
1370
Scott James Remnant17252362006-09-04 07:15:40 +01001371 * nih/hash.h: Add missing attribute for nih_hash_new
1372 * nih/list.h: Add missing attribute for nih_list_new
1373
Scott James Remnant8f7df052006-09-01 19:47:47 +010013742006-09-01 Scott James Remnant <scott@netsplit.com>
1375
1376 * nih/option.c (nih_option_group_help): Cast linelen to not induce
1377 a warning.
1378
Scott James Remnant133ff0e2006-08-31 02:01:57 +010013792006-08-31 Scott James Remnant <scott@netsplit.com>
1380
Scott James Remnant4816f9a2006-09-01 03:07:51 +01001381 * nih/main.c (nih_main_loop_interrupt): Always initialise the
1382 interrupt pipe.
1383 (nih_main_loop_init): Move interrupt pipe initialisation to here
1384 so that it's always available.
1385 (nih_main_loop): Drop the extra call to nih_signal_poll().
1386
Scott James Remnant420cffe2006-08-31 23:50:46 +01001387 * nih/option.c (nih_option_get_short, nih_option_get_long): Allow
1388 catch-all options.
1389 * nih/tests/test_option.c (test_parser): Test catch-all options.
1390
Scott James Remnant4593ff22006-08-31 18:57:06 +01001391 * TODO: Update.
1392
Scott James Remnant133ff0e2006-08-31 02:01:57 +01001393 * nih/option.c (nih_option_handle_arg): Free any existing option
1394 value.
1395
Scott James Remnant5b5c2e02006-08-30 01:57:36 +010013962006-08-30 Scott James Remnant <scott@netsplit.com>
1397
Scott James Remnant99dada92006-08-30 16:12:47 +01001398 * nih/option.c (nih_option_debug): Add a hidden --debug option that
1399 sets the logging level up really high.
1400 (nih_option_handle): Just compare the names rather than offset
1401 within a list that can change.
1402 * nih/option.h: Update.
1403 * nih/tests/test_option.c (test_debug): Check that it works.
1404
Scott James Remnantaa352032006-08-30 02:05:40 +01001405 * nih/option.c (nih_option_group_help): Output "Options" where we
1406 only have the one group.
1407
Scott James Remnant5b5c2e02006-08-30 01:57:36 +01001408 * nih/option.c (nih_option_group_help): Don't output options without
1409 help strings.
1410 * nih/tests/test_option.c (test_help): Update.
1411
Scott James Remnantc3aaba82006-08-25 14:41:29 +020014122006-08-25 Scott James Remnant <scott@netsplit.com>
1413
1414 * nih/io.c (nih_io_watcher): Clean up the handling of the out of
1415 memory condition while extending the buffer so that we just return
1416 to be called again rather than end up performing some random action.
1417
Scott James Remnant59f3e4f2006-08-24 02:23:24 +020014182006-08-24 Scott James Remnant <scott@netsplit.com>
1419
Scott James Remnant4ff39ce2006-08-24 02:53:51 +02001420 * nihify (src_dir): Also copy m4/Makefile.am
1421
Scott James Remnant55a481d2006-08-24 02:31:01 +02001422 * nih/file.c (nih_file_remove_watch): Raise the error before
1423 performing other actions so errno is not lost.
1424
Scott James Remnant0a63a3d2006-08-24 02:23:48 +02001425 * nih/io.c (nih_io_watcher): Fix a pretty critical bug, we weren't
1426 saving the value of errno so it was usually zero by the time we
1427 looked at it.
1428
Scott James Remnant59f3e4f2006-08-24 02:23:24 +02001429 * nih/logging.c (nih_logger_syslog): Useful alternative to
1430 nih_logger_printf.
1431 * nih/logging.h: Update.
1432
Scott James Remnant377333d2006-08-23 19:47:28 +020014332006-08-23 Scott James Remnant <scott@netsplit.com>
1434
Scott James Remnant19972312006-08-23 21:55:49 +02001435 * nih/tests/test_string.c: Add missing free calls.
1436
Scott James Remnant61e45472006-08-23 21:51:33 +02001437 * nih/tests/test_io.c (test_watcher): Silence the error message.
1438 * nih/tests/test_option.c (test_parser): Add some forgotten calls
1439 to nih_free
1440
Scott James Remnant94e37682006-08-23 21:43:41 +02001441 * nih/main.c (nih_main_init_full): Free the package string when
1442 overwriting it.
1443
Scott James Remnanta82b0092006-08-23 21:39:00 +02001444 * nih/tests/test_logging.c: Keep a copy of the last message
1445 otherwise we're reading free'd memory (again).
1446
Scott James Remnantf8880bb2006-08-23 21:34:20 +02001447 * nih/tests/test_list.c: Memory cleanups.
1448
Scott James Remnant5bc46912006-08-23 21:30:12 +02001449 * nih/signal.c (nih_signal_set_default, nih_signal_set_ignore):
1450 Don't initialise the signals list, there's no need.
1451
Scott James Remnanta26ebc22006-08-23 20:47:20 +02001452 * nih/tests/test_hash.c: Various missing calls to nih_free.
1453
Scott James Remnant0344eb42006-08-23 20:41:11 +02001454 * nih/file.c (nih_file_remove_watch): Fix another wrong call to
1455 nih_free.
1456
Scott James Remnante5f85e32006-08-23 20:33:34 +02001457 * nih/tests/test_child.c (test_poll): Free the watcher.
1458
Scott James Remnantc3912272006-08-23 20:26:39 +02001459 * nih/file.c (nih_file_remove_watch): Remove from the containing
1460 list before freeing.
1461 * nih/tests/test_file.c (my_watcher): Make sure we copy the name
1462 as it will be freed by the time we get back to the test.
1463
Scott James Remnantb5f985a2006-08-23 20:21:39 +02001464 * nih/list.c (nih_list_free): Don't throw away the destructor
1465 return value.
1466
Scott James Remnanta790a312006-08-23 20:01:04 +02001467 * nih/tests/test_error.c: Further missing calls to nih_free
1468
Scott James Remnant85f10472006-08-23 19:56:34 +02001469 * nih/tests/test_alloc.c: Correct a few missing nih_free's
1470
Scott James Remnant377333d2006-08-23 19:47:28 +02001471 * nih/file.c (nih_file_map): Correct a thinko, have to mask
1472 flags by O_ACCMODE and compare for equality to extract the open
1473 access mode.
1474
Scott James Remnantecce6282006-08-22 12:23:07 +020014752006-08-22 Scott James Remnant <scott@netsplit.com>
1476
1477 * nih/file.c (nih_file_map, nih_file_unmap): Add an easier to use
1478 wrapper around mmap() when we just want the file in memory.
1479 * nih/file.h: Add prototypes.
1480 * nih/tests/test_file.c (test_map): Test the functions.
1481
Scott James Remnant097a7e12006-08-21 01:25:23 +020014822006-08-21 Scott James Remnant <scott@netsplit.com>
1483
1484 * nih/file.c: Wrap the inotify syscalls with something a little
1485 friendlier to deal with.
1486 * nih/file.h: Typedefs, structures and prototypes.
1487 * nih/libnih.h: Include file.h
1488 * nih/io.h: Correct typo in argument name.
1489 * nih/Makefile.am (libnih_la_SOURCES): Build and link file.c
1490 (nihinclude_HEADERS): Install file.h
1491 (TESTS): Build and run file test cases
1492 (test_file_SOURCES, test_file_LDFLAGS, test_file_LDADD): Details
1493 for file test case binary
1494
Scott James Remnant0cf12e82006-08-19 17:41:41 +010014952006-08-19 Scott James Remnant <scott@netsplit.com>
1496
Scott James Remnantabcffd82006-08-19 19:10:02 +01001497 * nih/option.c (nih_option_parser): Finish option processing when
1498 the first non-option argument is found (command-mode)
1499 * nih/option.h: Update.
1500 * nih/tests/test_option.c (test_parser): Test command-mode.
1501
Scott James Remnant4dcce342006-08-19 18:59:07 +01001502 * nih/option.c: Implement a simple, yet flexible option parser.
1503 * nih/option.h: Typedefs, structures and prototypes.
1504 * nih/libnih.h: Include option.h
1505 * nih/tests/test_option.c: Test it all pretty thoroughly.
1506 * nih/Makefile.am (libnih_la_SOURCES): Build and link option.c
1507 (nihinclude_HEADERS): Install option.h
1508 (TESTS): Run the option test cases
1509 (test_option_SOURCES, test_option_LDFLAGS, test_option_LDADD):
1510 Details for the option test case binary.
1511 * TODO: Update.
1512
Scott James Remnant0cf12e82006-08-19 17:41:41 +01001513 * nih/string.c (nih_str_wrap): Implement a function to wrap a
1514 string into the desired number of characters wide.
1515 * nih/string.h: Update.
1516 * nih/tests/test_string.c (test_str_wrap): Test the new function
1517 to make sure it does the right things.
1518
Scott James Remnant13b0e072006-08-18 18:50:11 +010015192006-08-18 Scott James Remnant <scott@netsplit.com>
1520
Scott James Remnant293072c2006-08-18 20:37:51 +01001521 * TODO: Update.
1522
Scott James Remnant034abdf2006-08-18 20:36:40 +01001523 * nih/main.h (nih_main_init_gettext): Macro that expands to the
1524 usual gettext initialisation spiel if ENABLE_NLS is set, or nothing
1525 if not.
1526 (nih_main_init): Expand nih_main_init_gettext as well, we almost
1527 always want to do that, after all.
1528 * nih/macros.h: Include locale.h if ENABLE_NLS is set, as that
1529 contains setlocale, amongst other things.
1530 * nih/tests/test_main.c (test_init_gettext): Check the macro does
1531 the right things.
1532
Scott James Remnant104d3dc2006-08-18 19:48:17 +01001533 * nih/io.h (NihIoCb): Rename to NihIoWatcher.
1534 (NihIoReadCb): Rename to NihIoReader.
1535 (NihIoCloseCb): Rename to NihIoCloseHandler.
1536 (NihIoErrorCb): Rename to NihIoErrorHandler.
1537 (NihIoWatch): Rename callback member to watcher.
1538 (NihIo): Rename read_cb member to reader, close_cb member to
1539 close_handler and error_cb member to error_handler.
1540 * nih/io.c: Update to use new names.
1541 (nih_io_cb): Rename to nih_io_watcher.
1542 * nih/tests/test_io.c: Update to use new names.
1543
Scott James Remnant13b0e072006-08-18 18:50:11 +01001544 * TODO: Update.
1545
Scott James Remnanteeaebb62006-08-16 00:49:21 +010015462006-08-16 Scott James Remnant <scott@netsplit.com>
1547
Scott James Remnant10a9f972006-08-16 16:49:38 +01001548 * nih/main.c (nih_main_loop_add_func): Add a loop function
1549 (nih_main_loop): Run the loop functions.
1550 * nih/main.h (NihMainLoopCb, NihMainLoopFunc): Typedefs and
1551 structures for main loop callbacks.
1552 * nih/tests/test_main.c (test_main_loop_add_func): Check that
1553 the loop function is allocated correctly.
1554 (test_main_loop): Make sure it actually gets called.
1555
Scott James Remnantc4697552006-08-16 03:56:22 +01001556 * nih/io.c (nih_io_cb): Add a couple of check assertions.
1557
Scott James Remnanteeaebb62006-08-16 00:49:21 +01001558 * nih/macros.h (N_): Should be defined to be a no-op.
1559
Scott James Remnant5cabc802006-08-14 00:16:18 +010015602006-08-14 Scott James Remnant <scott@netsplit.com>
1561
Scott James Remnanta3b77692006-08-14 21:10:57 +01001562 * nih/alloc.c (nih_realloc): Yet another fix to realloc, we
1563 forgot to reinitialise our entry in the parent's children list in
1564 the case of no parent. After fixing this and tracing the code, I
1565 realised that the previous fix was inelegant and there is a way to
1566 deal with children without modifying the pointers until after the
1567 reallocation. Documented the reasoning in the function.
1568
Scott James Remnant5cabc802006-08-14 00:16:18 +01001569 * nih/io.c (nih_io_reopen): Report on the error rather than just
1570 suppressing it.
1571 (nih_io_error): Likewise, report on the error.
1572
Scott James Remnantf2642c42006-08-12 00:50:21 +010015732006-08-12 Scott James Remnant <scott@netsplit.com>
1574
Scott James Remnantf0766ce2006-08-12 19:41:55 +01001575 * nih/main.c (nih_main_loop_close): Drop this function
1576 (nih_main_loop): Instead mark them close on exec.
1577 * nih/main.h: Update.
1578
Scott James Remnantf0857b02006-08-12 19:37:47 +01001579 * nih/main.c (nih_main_loop): Change the main loop to use select
1580 instead of poll, as its semantics are a lot easier to deal with.
1581 We also use allow select to be interrupted by writing to a pipe
1582 from the signal handlers, for when Linux gets around to supporting
1583 SA_RESTART properly.
1584 (nih_main_loop_interrupt): Write to the pipe so the select call gets
1585 interrupted.
1586 (nih_main_loop_exit): Interrupt the main loop, in case we're
1587 waiting forever.
1588 (nih_main_loop_close): Close the interrupt pipe, used in children.
1589 * nih/main.h: Update.
1590 * nih/io.c (nih_io_add_watch): Change type of events parameter.
1591 (nih_io_poll_fds): Remove this function.
1592 (nih_io_select_fds): And replace with this that sets the select
1593 file descriptor sets instead.
1594 (nih_io_handle_fds): Now receives select file descriptor sets, and
1595 becomes rather more obvious in the process. Restore the previous
1596 behaviour where a callback isn't called unless requests events
1597 occur.
1598 (nih_io_reopen): Always poll for reading so we pick up errors.
1599 (nih_io_cb): Change type of events parameter and events settings.
1600 (nih_io_write): Change event settings.
1601 * nih/io.h: Update.
1602 (NihIoEvents): replace the previous poll events with a new enum.
1603 * nih/signal.c (nih_signal_handler): Interrupt the select call in
1604 the main loop.
1605 * nih/tests/test_io.c: Update with new test cases.
1606 * nih/tests/test_child.c: Use select() rather than poll()
1607
Scott James Remnantf6bc0c52006-08-12 14:48:57 +01001608 * nih/tests/test_io.c (test_buffer_push, test_write): Correct
1609 uninitialised return value.
1610
Scott James Remnant1e6b91b2006-08-12 02:26:28 +01001611 * nih/main.c (nih_main_loop): Correct a memory leak, we forgot
1612 to clean up the poll fds list.
1613
Scott James Remnantf75da132006-08-12 01:58:37 +01001614 * nih/io.c (nih_io_handle_fds): Always call the callback, even if
1615 unexpected events happen, otherwise we'll miss ERR, HUP, etc.
1616 (nih_io_shutdown): Allow a socket to be closed lazily, so we can
1617 send (or receive) a whole bunch of stuff and expect the structure to
1618 go away afterwards.
1619 (nih_io_cb): If the shutdown flag has been marked and we run out
1620 of things in either buffer, act as if one end was closed.
1621 (nih_io_reopen): Mark sockets as not shutdown by default.
1622 * nih/io.h: Update.
1623 * nih/tests/test_io.c (test_shutdown): Test behaviour.
1624 (test_handle_fds): Take out some of the tests due to changed
1625 behaviour. While "clever" I think overall this is undesirable.
1626
Scott James Remnantf2642c42006-08-12 00:50:21 +01001627 * nih/io.c (nih_io_set_cloexec): Function to set the FD_CLOEXEC flag.
1628 * nih/io.h: Update.
1629 * nih/tests/test_io.c (test_set_cloexec): Test the function.
1630
Scott James Remnant60d62fb2006-08-11 23:03:39 +010016312006-08-11 Scott James Remnant <scott@netsplit.com>
1632
Scott James Remnantaf2d3b52006-08-11 23:08:24 +01001633 * nih/alloc.h, nih/child.h, nih/hash.h, nih/logging.h, nih/signal.h,
1634 nih/timer.h: Document arguments to function pointers.
1635
Scott James Remnant60d62fb2006-08-11 23:03:39 +01001636 * nih/io.c: Add a whole bunch of code to provide us with a high-
1637 throughput, async file/socket layer; largely copied from the
1638 dircproxy code (well, it works!). This allows read and write calls
1639 to happen inside the main loop based on whenever poll thinks either
1640 is possible, while user space can just write what it likes or get
1641 called when there's data in the recv buffer.
1642 * nih/io.h: Add the new typedefs, structures and prototypes.
1643 * nih/tests/test_io.c: Lots of test cases for this stuff.
1644
Scott James Remnantedc05792006-08-10 03:12:48 +010016452006-08-10 Scott James Remnant <scott@netsplit.com>
1646
Scott James Remnant3cbb3a12006-08-10 03:28:32 +01001647 * nih/alloc.c (nih_realloc): Fix a fairly critical bug, we weren't
1648 dealing with the fact that the children list head can move;
1649 do some fancy shifting to make that work.
1650
Scott James Remnantedc05792006-08-10 03:12:48 +01001651 * nih/string.c (nih_str_split): Add a function to split a string
1652 based on delimiters into an array.
1653 * nih/string.h: Update.
1654 * nih/tests/test_string.c (test_str_split): Test the new function.
1655
Scott James Remnant5ae01a92006-08-09 17:48:05 +010016562006-08-09 Scott James Remnant <scott@netsplit.com>
1657
Scott James Remnant61edf232006-08-09 17:48:15 +01001658 * nih/tests/test_child.c (test_poll): Add extra sleep calls for
1659 safety.
1660
Scott James Remnant5ae01a92006-08-09 17:48:05 +01001661 * nih/libnih.h: Include errors.h
1662
Scott James Remnanta984d772006-08-04 05:29:36 +010016632006-08-04 Scott James Remnant <scott@netsplit.com>
1664
1665 * nih/errors.h: Include errno.h for helpfulness.
1666
Scott James Remnant76fb5ab2006-08-03 19:12:48 +010016672006-08-03 Scott James Remnant <scott@netsplit.com>
1668
Scott James Remnant06054ae2006-08-03 19:43:46 +01001669 * nih/child.c (nih_child_add_watch): Also takes a parent now.
1670 * nih/child.h: Update.
1671 * nih/tests/test_child.c: Update.
1672
Scott James Remnanta34d4162006-08-03 19:25:16 +01001673 * nih/io.c (nih_io_add_watch): And once more, with feeling; takes
1674 a parent for the watch.
1675 * nih/io.h: Update.
1676 * nih/tests/test_io.c: Update.
1677
Scott James Remnantee7c3442006-08-03 19:22:35 +01001678 * nih/signal.c (nih_signal_add_callback): Give this the same treatment,
1679 it takes the parent for the signal callback.
1680 * nih/signal.h: Update.
1681 * nih/tests/test_signal.c: Update.
1682
Scott James Remnant6840fe32006-08-03 19:20:03 +01001683 * nih/timer.c (nih_timer_add_timeout, nih_timer_add_periodic)
1684 (nih_timer_add_scheduled): Use nih_alloc properly by taking a parent
1685 for the timer object and setting a destructor on it so that it's
1686 automatically removed when the parent is freed.
1687 * nih/timer.h: Update.
1688 * nih/tests/test_timer.c: Update function calls.
1689 * nih/tests/test_main.c (test_main_loop): Update also.
1690
Scott James Remnantfade70e2006-08-03 19:14:42 +01001691 * nih/list.c (nih_list_destructor): Add a destructor function that
1692 just cuts the entry out of the list in preperation for being freed.
1693 * nih/list.h: Update.
1694 * nih/tests/test_list.c (test_destructor): Test the behaviour of
1695 the new function.
1696
Scott James Remnant76fb5ab2006-08-03 19:12:48 +01001697 * nih/tests/test_error.c: Include fixes.
1698
Scott James Remnant441e1ac2006-08-02 02:29:50 +010016992006-08-02 Scott James Remnant <scott@netsplit.com>
1700
Scott James Remnant30f01912006-08-02 18:47:34 +01001701 * nih/signal.c (nih_signal_set_handler, nih_signal_set_default)
1702 (nih_signal_set_ignore): Reset sa_flags so that we don't pass
1703 uninitialised data for SIGALRM.
1704 (nih_signal_reset): Add function to reset signals back to their
1705 default state.
1706 * nih/signal.h: Update.
1707 * nih/tests/test_signal.c (test_reset): Add test case.
1708
Scott James Remnant11afc022006-08-02 18:38:51 +01001709 * nih/error.c (nih_error_raise_system): Be a lot more careful in
1710 this function! Save the value of errno in case we overwrite it
1711 and call nih_error_init()
1712
Scott James Remnant81cb8c62006-08-02 08:40:47 +01001713 * nih/signal.c (nih_signal_set_handler): Add the SA_NOCLDSTOP
1714 signal for SIGCHLD.
1715
Scott James Remnant3f16fca2006-08-02 08:20:54 +01001716 * nih/main.c (nih_main_loop): Drop the code that masked out the
1717 child signal, it was inherently racy and there's no particular
1718 reason to do it anyway since we use SA_RESTART in signal.c for
1719 most things.
1720
Scott James Remnanta6194c42006-08-02 08:11:09 +01001721 * nih/signal.c (nih_signal_set_handler, nih_signal_set_default)
1722 (nih_signal_set_ignore): don't set SA_RESTART for SIGALRM.
1723
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001724 * nih/signal.c (nih_signal_set_handler, nih_signal_set_default)
1725 (nih_signal_set_ignore): use nih_return_system_error to make the
Scott James Remnant468da982006-08-02 05:17:51 +01001726 code rather cleaner.
1727
1728 * nih/error.h (nih_return_error): Add missing doc for retval
1729 (nih_return_system_error): Add additional useful function.
1730 * nih/tests/test_error.c (test_return_system_error): Add test
1731 case for the new macro.
1732
Scott James Remnant8b11f492006-08-02 02:59:24 +01001733 * nih/child.c (nih_child_poll): Convert to use waitid() so that
1734 we can obtain the information about the dead child without reaping
1735 it until we're done processing; useful because it means /proc/$PID
1736 and the child itself is still around during the handlers.
1737 * nih/child.h (NihReaper): Gains a new third argument that indicates
1738 whether the child exited normally or was killed.
1739 * nih/tests/test_child.c (test_poll): Update.
1740
Scott James Remnantd2dd1b52006-08-02 02:51:40 +01001741 * nihify: Add a few useful sanity checks so that it works with
1742 relative paths and already-nihified directories.
1743
Scott James Remnantc4bb1092006-08-02 02:46:02 +01001744 * m4/misc.m4: Remove older force code.
1745
Scott James Remnant1dd73a62006-08-02 02:44:19 +01001746 * TODO: Updated.
1747
Scott James Remnante4704622006-08-02 02:40:53 +01001748 * m4/Makefile.am (dist_aclocal_DATA): Distribute misc.m4, long
1749 missed.
1750
Scott James Remnantd2dd1b52006-08-02 02:51:40 +01001751 * nihify: Add useful script for symlinking into source trees until
1752 we intend to get released.
Scott James Remnant8ec197b2006-08-02 02:40:33 +01001753
Scott James Remnant441e1ac2006-08-02 02:29:50 +01001754 * HACKING: Correct typo (our -> out)
1755
Scott James Remnant70bc30c2006-07-28 02:46:48 +010017562006-07-28 Scott James Remnant <scott@netsplit.com>
1757
Scott James Remnant1c5b6242006-07-28 06:38:45 +01001758 * nih/main.c (nih_main_term_signal): Handy signal callback.
1759 * nih/main.h: Update.
1760 * nih/tests/test_main.c (my_timeout): Cheat and ensure the latest
1761 exit status is used.
1762
Scott James Remnant52832a02006-07-28 06:33:01 +01001763 * nih/main.c (nih_main_loop): Implement a main loop by calling
1764 various other functions in the right manner.
1765 (nih_main_loop_exit): Function to break the main loop.
1766 * nih/main.h: Update.
1767 * nih/tests/test_main.c (test_main_loop): Add a trivial test case
1768 for the main loop, it's damned difficult to test, but at least this
1769 ensures the bases are touched.
1770
Scott James Remnant1d5b1902006-07-28 06:16:35 +01001771 * nih/signal.c (nih_signal_poll): Add missing call to
1772 nih_signal_init()
1773 * nih/child.c (nih_child_poll): Add missing call to nih_child_init()
1774 * nih/io.c (nih_io_poll_fds, nih_io_handle_fds): Add missing calls
1775 to nih_io_init()
1776
Scott James Remnante22dea52006-07-28 06:11:37 +01001777 * nih/io.c: Code for watching file descriptors and sockets for
1778 events through poll(), but not actually the poll() call itself.
1779 * nih/io.h: Typedefs, structures and prototypes.
1780 * nih/libnih.h: Include io.h
1781 * nih/tests/test_io.c: Test cases for I/O watches.
1782 * nih/Makefile.am (libnih_la_SOURCES): Build and link io.c
1783 (nihinclude_HEADERS): Install io.h
1784 (TESTS): Build and run I/O test cases
1785 (test_io_SOURCES, test_io_LDFLAGS, test_io_LDADD): Details for I/O
1786 test case binary.
1787
Scott James Remnant29299932006-07-28 06:11:26 +01001788 * nih/tests/test_timer.c (test_poll): Free entry after testing.
1789
Scott James Remnant88f04592006-07-28 04:32:33 +01001790 * nih/child.c (nih_child_poll): When the reaper is for a particular
1791 process, be sure to remove it from the list.
1792 * nih/tests/test_child.c (test_poll): Test for that.
1793
Scott James Remnantc5bfa472006-07-28 04:21:36 +01001794 * nih/child.c: Simple bit of code to wait for children to
1795 terminate and dispatch the reaper functions for them.
1796 * nih/child.h: Typedefs, structures and prototypes.
1797 * nih/libnih.h: Include child.h
1798 * nih/tests/test_child.c: Test cases for child handling code.
1799 * nih/Makefile.am (libnih_la_SOURCES): Build and link child.c
1800 (nihinclude_HEADERS): Install child.h
1801 (TESTS): Build and run child test cases
1802 (test_child_SOURCES, test_child_LDFLAGS, test_child_LDADD): Details
1803 for child test case binary.
1804
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001805 * nih/timer.c (nih_timer_add_timeout, nih_timer_add_periodic)
1806 (nih_timer_add_scheduled): Change argument order so that the time
Scott James Remnant37e8eb52006-07-28 02:52:06 +01001807 information is first, to match signal functions.
1808 * nih/timer.h: Update.
1809 * nih/tests/test_timer.c: Update.
1810
Scott James Remnantee5dec72006-07-28 02:48:43 +01001811 * nih/signal.h: Include the system signal.h for ease of use.
1812
Scott James Remnant70bc30c2006-07-28 02:46:48 +01001813 * nih/signal.c: Code for handling signals inside the main loop,
1814 rather than trying to fit delicate code in a signal handler; and
1815 for making it generally easier to handle signals.
1816 * nih/signal.h: Typedefs and prototypes.
1817 * nih/libnih.h: Include signal.h
1818 * nih/Makefile.am (libnih_la_SOURCES): Build and link signal.c
1819 (nihinclude_HEADERS): Install signal.h
1820 (TESTS): Build and run signal test cases
1821 (test_signal_SOURCES, test_signal_LDFLAGS, test_signal_LDADD): Details
1822 for signal test case binary.
1823
Scott James Remnant3a0f8782006-07-27 18:39:54 +010018242006-07-27 Scott James Remnant <scott@netsplit.com>
1825
Scott James Remnant4eeca5e2006-07-27 23:28:00 +01001826 * nih/timer.c: Code for timeouts, periodic and scheduled timers,
1827 note that the actual scheduling part of scheduled timers it not
1828 implemented yet (we need to think a bit more about it)
1829 * nih/timer.h: Structures, macros and prototypes.
1830 * nih/libnih.h: Include timer.h
1831 * nih/tests/test_timer.c: Test cases for timer code.
1832 * nih/Makefile.am (libnih_la_SOURCES): Build and link timer.c
1833 (nihinclude_HEADERS): Install timer.h
1834 (TESTS): Build and run timer test cases
1835 (test_timer_SOURCES, test_timer_LDFLAGS, test_timer_LDADD): Details
1836 for timer test case binary.
1837
Scott James Remnant2bd715e2006-07-27 22:58:33 +01001838 * nih/alloc.c (nih_free): Use new safe list iteration macro.
1839
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001840 * nih/hash.c (nih_hash_add_unique, nih_hash_replace)
1841 (nih_hash_search): Use new list iteration macros.
Scott James Remnant7f12ab62006-07-27 22:58:15 +01001842
Scott James Remnant48eb8972006-07-27 22:57:27 +01001843 * nih/list.h (NIH_LIST_FOREACH): New macro that expands to the usual
1844 list iteration for loop, prevents mistakes.
1845 (NIH_LIST_FOREACH_SAFE): Macro that does the same as above, but also
1846 includes a "next" variable to allow safe iteration; especially useful
1847 to prevent us getting this wrong!
1848 * nih/tests/test_list.c (test_foreach, test_foreach_safe): Add test
1849 cases for iteration.
1850
Scott James Remnantc2b73bc2006-07-27 18:49:27 +01001851 * nih/error.c (nih_error_init): Make inline and check value first.
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001852 (nih_error_raise, nih_error_raise_printf, nih_error_raise_again)
1853 (nih_error_push_context): Unconditionally call nih_error_init.
Scott James Remnantc2b73bc2006-07-27 18:49:27 +01001854
Scott James Remnant361a64b2006-07-27 18:48:02 +01001855 * nih/alloc.c (nih_alloc_init): Make inline and check value first.
1856 (nih_alloc): Unconditionally call nih_alloc_init.
1857
Scott James Remnantc840e392006-07-27 18:47:21 +01001858 * nih/logging.c (nih_log_init): Use the proper functions to
1859 initialise details, check values first; also make inline.
1860 (nih_log_message): Unconditionally call nih_log_init.
1861
Scott James Remnantc2e442b2006-07-27 18:40:22 +01001862 * nih/Makefile.am (DEFS): Append to the default DEFS list, rather
1863 than overriding, otherwise we lose HAVE_CONFIG_H
1864
Scott James Remnant3a0f8782006-07-27 18:39:54 +01001865 * nih/macros.h: Check for ENABLE_NLS instead of HAVE_GETTEXT and
1866 include libintl.h if defined as well.
1867
Scott James Remnant0efbb8f2006-07-20 02:30:05 +010018682006-07-20 Scott James Remnant <scott@netsplit.com>
1869
Scott James Remnanta56ead62006-07-20 02:54:06 +01001870 * nih/string.c (nih_strv_free): Add a function to free an array
1871 of strings.
1872 * nih/string.h: Update.
1873 * nih/tests/test_string.c (test_strv_free): Test the function.
1874
Scott James Remnant81616de2006-07-20 02:41:06 +01001875 * nih/error.c: Error handling code.
1876 * nih/error.h: Structures, macros and prototypes.
1877 * nih/errors.h: Error enum and message definitions.
1878 * nih/libnih.h: Include error.h and errors.h
1879 * nih/tests/test_error.c: Error handling test cases.
1880 * nih/Makefile.am (libnih_la_SOURCES): Build and link error.h
1881 (nihinclude_HEADERS): Install error.h
1882 (TESTS): Build and run error handling test cases.
1883 (test_error_SOURCES, test_error_LDFLAGS, test_error_LDADD): Binary
1884 for error handling test cases.
1885
Scott James Remnant15802c22006-07-20 02:40:30 +01001886 * nih/macros.h (NIH_MUST, NIH_MUST_NOT): Add handy macros to spin
1887 until we get a true or false value from an assignment. Usually
1888 used around a call to memory allocation functions that we can't
1889 deal with failing.
1890
Scott James Remnant9d80a0f2006-07-20 02:38:29 +01001891 * nih/main.c (nih_main_package_string): Change package_string
1892 to be a module-level static so it can be reset by a call to
1893 nih_main_init_full. Always return if not NULL.
1894 * nih/tests/test_main.c (test_package_string): Call nih_main_init_full
1895 instead of futzing with variables so the static string is reset.
1896
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001897 * nih/alloc.c (nih_alloc_using, nih_alloc, nih_realloc)
1898 (nih_alloc_size, nih_alloc_parent): Make various argument pointers
Scott James Remnant533137c2006-07-20 02:37:00 +01001899 const.
1900 * nih/alloc.h: Update.
1901
Scott James Remnant36a43502006-07-20 02:35:37 +01001902 * nih/libnih.h, nih/logging.c, nih/main.c: Update to include
1903 string.h not strutil.h
1904
Scott James Remnant0efbb8f2006-07-20 02:30:05 +01001905 * nih/strutil.c: Renamed to nih/string.c
1906 * nih/strutil.h: Renamed to nih/string.h
1907 * nih/tests/test_strutil.c: Renamed to nih/tests/test_string.h
1908 * nih/Makefile.am (DEFAULT_INCLUDES): Override to stop automake doing
1909 silly things like putting -I. in the pre-processor flags.
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001910 (libnih_la_SOURCES, nihinclude_HEADERS, TESTS)
1911 (test_string_SOURCES, test_string_LDFLAGS, test_string_LDADD): Update.
Scott James Remnant0efbb8f2006-07-20 02:30:05 +01001912
Scott James Remnante7bb3092006-07-19 23:18:32 +010019132006-07-19 Scott James Remnant <scott@netsplit.com>
1914
1915 * nih/alloc.h, nih/logging.h, nih/strutil.h: Reformat attribute
1916 declarations to not upset emacs indentation.
1917
Scott James Remnant06424b42006-07-17 21:12:55 +010019182006-07-17 Scott James Remnant <scott@netsplit.com>
1919
1920 * nih/strutil.c (nih_strdup): Implement an nih_alloc-based strdup.
1921 (nih_strdup): and strndup.
1922 * nih/strutil.h: Update.
1923 * nih/tests/test_strutil.c: Test new functions.
1924
Scott James Remnantab30a422006-07-13 01:54:58 +010019252006-07-13 Scott James Remnant <scott@netsplit.com>
1926
Scott James Remnantbda41e12006-07-13 22:41:30 +01001927 * nih/alloc.c (nih_free): Remove the entry from the parent's list.
1928
Scott James Remnantb51443b2006-07-13 22:40:33 +01001929 * nih/logging.h (nih_assert): Reexpress to avoid polluting if
1930 statements without an else.
1931
Scott James Remnantcaa78bf2006-07-13 22:40:15 +01001932 * nih/alloc.c (nih_realloc): Implement a function that reallocates
1933 a block of memory with the original allocator.
1934 (nih_alloc_init): Don't double-check the allocator.
1935 * nih/alloc.h: Update.
1936 * nih/tests/test_alloc.c (test_realloc): Check behaviour of realloc.
1937
Scott James Remnant45ff4952006-07-13 22:11:09 +01001938 * nih/alloc.c (NihAllocCtx): Drop the name pointer, we never used
1939 that anyway.
1940 (nih_alloc_using): Drop name parameter.
1941 (nih_alloc_named): Rename to nih_alloc.
1942 (nih_alloc_set_name): Drop this function.
1943 (nih_alloc_name): And this one.
1944 * nih/alloc.h (nih_new): Simplify.
1945 (nih_alloc): Drop entirely now it's unneeded.
1946 * nih/tests/test_alloc.c: Update.
1947 * nih/tests/test_list.c (test_new): Test using nih_alloc_size
1948 rather than nih_alloc_name.
1949
Scott James Remnant26b95ff2006-07-13 02:07:18 +01001950 * nih/logging.h: Put the log priorities back in ascending order,
1951 but use the zero to mean "unknown". Fix up the descriptions to be
1952 a little more consistent.
1953 * nih/logging.c: Rename max_priority back to min_priority so it
1954 all makes more sense again.
1955 (nih_log_init): Warning is the default minimum priority to show.
1956 (nih_log_set_priority): Set minimum priority.
1957 (nih_log_message): Discard messages below the minimum priority.
1958 (nih_logger_printf): Use stderr when priority is greater than or
1959 equal to warning.
1960 * nih/tests/test_logging.c: Update to match.
1961
Scott James Remnantab30a422006-07-13 01:54:58 +01001962 * nih/logging.c (nih_log_message): Use nih_vsprintf which makes the
1963 function not core dump (always good, that).
1964
Scott James Remnant76586af2006-07-12 23:40:14 +010019652006-07-12 Scott James Remnant <scott@netsplit.com>
1966
Scott James Remnant595e01b2006-07-12 23:41:05 +01001967 * nih/main.c (nih_main_package_string): Use nih_sprintf and make
1968 the function rather simpler.
1969
Scott James Remnant0e32c792006-07-12 23:40:35 +01001970 * nih/tests/test_alloc.c (main): Formatting fix.
1971
Scott James Remnant76586af2006-07-12 23:40:14 +01001972 * nih/strutil.c (nih_sprintf): Function to wrap sprintf, allocating
1973 the necessary space using nih_alloc first.
1974 (nih_vsprintf): Function to wrap vsprintf, allocating the necessary
1975 space using nih_alloc first.
1976 * nih/strutil.h: Prototypes.
1977 * nih/libnih.h: Include strutil.h
1978 * nih/Makefile.am (libnih_la_SOURCES): Build and link strutil.c
1979 (nihinclude_HEADERS): Install strutil.h
1980 (TESTS): Build and run strutil test cases
Scott James Remnantd4b03b92006-08-02 08:15:26 +01001981 (test_strutil_SOURCES, test_strutil_LDFLAGS)
1982 (test_strutil_LDADD): Binary for strutil test cases.
Scott James Remnant76586af2006-07-12 23:40:14 +01001983
Scott James Remnant4944c0c2006-07-05 04:02:24 +010019842006-07-05 Scott James Remnant <scott@netsplit.com>
1985
Scott James Remnantd236e772006-07-05 13:49:50 +01001986 * nih/logging.c (nih_log_message): Don't bother catching
1987 vsnprintf's return value, C99 doesn't allow it to fail.
1988 * nih/main.c (nih_main_package_string): Likewise for here.
1989
Scott James Remnant4944c0c2006-07-05 04:02:24 +01001990 * nih/logging.c (nih_log_message): Don't use a static variable
1991 for no apparent reason, just free afterwards. Catch vsnprintf and
1992 malloc failing.
1993 * nih/main.c (nih_main_package_string): Catch snprintf and realloc
1994 failing here too.
1995
Scott James Remnant0d136982006-05-30 14:28:49 +010019962006-05-30 Scott James Remnant <scott@netsplit.com>
1997
Scott James Remnantbeea0672006-05-30 14:59:16 +01001998 * nih/logging.h (nih_assert): Assertion macro that uses our logging
1999 rather than stderr.
2000 * nih/alloc.c, nih/hash.c, nih/list.c, nih/logging.c, nih/main.c:
2001 Use nih_assert rather than assert.
Scott James Remnantd4b03b92006-08-02 08:15:26 +01002002 * nih/Makefile.am (test_alloc_LDFLAGS, test_list_LDFLAGS)
2003 (test_hash_LDFLAGS, test_main_LDFLAGS, test_logging_LDFLAGS): Link
Scott James Remnantbeea0672006-05-30 14:59:16 +01002004 libraries statically.
Scott James Remnantd4b03b92006-08-02 08:15:26 +01002005 (test_alloc_LDADD, test_list_LDADD, test_hash_LDADD)
2006 (test_main_LDADD, test_logging_LDADD): Just link to the library.
Scott James Remnantbeea0672006-05-30 14:59:16 +01002007
Scott James Remnant0d136982006-05-30 14:28:49 +01002008 * nih/macros.h (NIH_STRINGIFY): Correct typo (-s -> _s)
2009 (NIH_LIKELY, NIH_UNLIKELY): Add branch prediction macros.
2010
Scott James Remnantb31cf302006-05-29 17:59:02 +010020112006-05-29 Scott James Remnant <scott@netsplit.com>
2012
Scott James Remnantbdcdadc2006-05-29 19:15:12 +01002013 * nih/alloc.c (nih_alloc_init): Restore this function, it's better
2014 style to keep variables in shared libraries as zero.
2015 (nih_alloc_named): Call nih_alloc_init once more.
2016 * nih/logging.h: Reorder such that NONE is the lowest value.
2017 * nih/logging.c (min_priority): Rename to max_priority and set value
2018 to NIH_LOG_NONE (zero).
2019 (nih_log_init): Initialise the default logger and priority.
2020 (nih_log_set_priority): Assert priority is greater than NONE.
2021 (nih_log_message): Initialise the logging if necessary.
2022 (nih_logger_printf): Check priority with <=
2023
Scott James Remnant712e14f2006-05-29 18:51:50 +01002024 * TODO: Update.
2025
Scott James Remnantbcf76612006-05-29 18:51:29 +01002026 * nih/logging.c: Code for formatting log messages and filtering
2027 based on priority.
2028 * nih/logging.h: Prototypes and macros.
2029 * nih/libnih.h: Include logging.h
2030 * nih/tests/test_logging.c: Logging test cases.
2031 * nih/Makefile.am (libnih_la_SOURCES): Build and link logging.c
2032 (nihinclude_HEADERS): Install logging.h
2033 (TESTS): Build and run logging test cases.
2034 (test_logging_SOURCES, test_logging_LDADD): Binary for logging
2035 test cases.
2036
Scott James Remnantd4b03b92006-08-02 08:15:26 +01002037 * nih/tests/test_main.c (test_package_string, test_suggest_help)
2038 (test_version): Add missing comments before tests.
Scott James Remnant1b60ce12006-05-29 18:42:37 +01002039 (test_suggest_help, test_version): Close the duplicated stdout/stderr
2040 before leaving the test.
2041
Scott James Remnantb31cf302006-05-29 17:59:02 +01002042 * nih/alloc.h: Declare nih_alloc_named and nih_alloc_using with
2043 the warn_unused_result and malloc attributes.
2044
Scott James Remnant502c0562006-05-27 12:15:25 +010020452006-05-27 Scott James Remnant <scott@netsplit.com>
2046
2047 * m4/compiler.m4 (NIH_COMPILER_WARNINGS): Drop -pedantic as we
2048 usually want gcc extensions (all the world IS gcc).
2049
Scott James Remnant3a9480e2006-05-26 17:18:45 +010020502006-05-26 Scott James Remnant <scott@netsplit.com>
2051
Scott James Remnantb374f2c2006-05-26 17:53:11 +01002052 * nih/main.c (nih_main_init_full): Only take the basename of
2053 the program name, not the full path.
2054 (nih_main_package_string): Use an allocated piece of memory rather
2055 than some on the stack, with C99-style snprintf to do the right thing
2056 with it.
2057 * nih/tests/test_main.c (test_init): Include check for basename.
2058 (test_package_string): Drop tests involving basename here.
2059
Scott James Remnantb0087122006-05-26 17:44:09 +01002060 * m4/compiler.m4 (NIH_TRY_C99): Macro that tries compiling
2061 some code full of C99 features.
2062 (NIH_C_C99): Use the above macro to determine whether the compiler
2063 supports C99, or whether it can do it with a compiler flag.
2064 * configure.ac: Make sure the compiler does C99.
2065
Scott James Remnant6c7870a2006-05-26 17:42:30 +01002066 * nih/list.c: Add missing prototype for nih_list_cut.
2067 * nih/hash.c: Add missing prototype for fnv_hash.
2068
Scott James Remnant13cd7a82006-05-26 17:34:38 +01002069 * nih/macros.h (_, N_): Define gettext-wrapper macros if
2070 HAVE_GETTEXT, otherwise define them to just expand to their string.
2071
Scott James Remnant88d73e82006-05-26 17:34:16 +01002072 * nih/main.h: Drop comments for global variables.
2073 * nih/main.c: Provide proper docstrings for them here.
2074
Scott James Remnant3a9480e2006-05-26 17:18:45 +01002075 * nih/alloc.c (nih_alloc_init): Drop this function, instead just
2076 initialise the static variable directly.
2077 (nih_alloc_set_allocator): Correct parameter name in docstring,
2078 don't call nih_alloc_init (it's already initialised).
2079
Scott James Remnant2fbdd9e2006-05-24 10:42:39 +010020802006-05-24 Scott James Remnant <scott@netsplit.com>
2081
2082 * nih/main.c (nih_main_package_string): Clarify documentation.
2083
Scott James Remnant8017ccf2006-05-23 09:12:43 +010020842006-05-23 Scott James Remnant <scott@netsplit.com>
2085
2086 * nih/main.c: Add code for the various little functions that we
2087 usually call from main().
2088 * nih/main.h: Prototypes and macros.
2089 * nih/libnih.h: Include main.h
2090 * nih/Makefile.am (libnih_la_SOURCES): Build and link main.c
2091 (nihinclude_HEADERS): Install main.h
2092 (TESTS): Build and run main test-cases
2093 (test_main_SOURCES, test_main_LDADD): Code for main tests.
2094 * m4/misc.m4 (AC_COPYRIGHT): Wraps the Autoconf AC_COPYRIGHT macro
2095 but also defines PACKAGE_COPYRIGHT
2096 * m4/compiler.m4: Temporary hack to make sure misc.m4 gets dragged
2097 in as aclocal doesn't notice it, will go away once we get something
2098 that aclocal will notice.
2099
Scott James Remnant839c8f02006-04-26 16:58:50 +010021002006-04-26 Scott James Remnant <scott@netsplit.com>
2101
Scott James Remnantb643f5e2006-04-26 18:32:44 +01002102 * nih/hash.c: Add code for FNV hash tables that uses NihList for
2103 the actual bins so is largely polymorphic.
2104 * nih/hash.h: Prototypes, macros and structures.
2105 * nih/macros.h: Include stdint.h as well, we use that a lot.
2106 * nih/libnih.h: Include hash.h
2107 * nih/tests/test_hash.c: Test cases for new hash table code.
2108 * nih/Makefile.am (libnih_la_SOURCES): Build and link hash.c
2109 (nihinclude_HEADERS): Install hash.h
2110 (TESTS): Build and run hash table test-cases.
2111 (test_hash_SOURCES, test_hash_LDADD): Code for hash table tests.
2112 * TODO: Update.
2113
Scott James Remnante8c06532006-04-26 17:32:02 +01002114 * nih/tests/test_list.c (test_empty): Fix faulty test case that
2115 actually proved one-entry lists were showing up as empty!
2116 * nih/list.h (NIH_LIST_EMPTY): Compare the next and previous pointers
2117 against the list pointer itself!
2118
Scott James Remnant839c8f02006-04-26 16:58:50 +01002119 * nih/list.c (nih_list_cut): Add an inline function that does the
2120 job of nih_list_remove without calling nih_list_init afterwards.
2121 (nih_list_remove): Call nih_list_cut rather than modifying pointers.
2122 (nih_list_free): Use nih_list_cut for efficiency, no point fixing
2123 the pointers if we're just going to free it.
2124 (nih_list_add, nih_list_add_after): Use nih_list_cut as the pointers
2125 get modified afterwards anyway, more efficient this way.
2126
Scott James Remnant011adce2006-04-25 03:49:54 +010021272006-04-25 Scott James Remnant <scott@netsplit.com>
2128
Scott James Remnantf089f702006-04-25 21:36:49 +01002129 * nih/list.c: Remove unnecessary include of stdlib.h
2130
Scott James Remnant92a3c142006-04-25 19:43:04 +01002131 * nih/list.c (nih_list_new): Fix formatting of docstring.
2132 * nih/alloc.c (nih_alloc_using, nih_alloc_parent): Fix formatting
2133 of docstring.
2134 (nih_alloc_named): Fix docstring to mention NULL can be returned.
2135 * nih/tests/test_alloc.c, nih/tests/test_list.c: Add missing blank
2136 line before includes.
2137
Scott James Remnant9a1fb112006-04-25 03:52:14 +01002138 * nih/alloc.c (nih_alloc_using): Return NULL if the allocation
2139 fails.
2140 * nih/list.c (nih_list_new): Also return NULL if the allocation
2141 fails.
2142
Scott James Remnantd4b03b92006-08-02 08:15:26 +01002143 * nih/alloc.c (nih_alloc_set_allocator, nih_alloc_using)
2144 (nih_free, nih_alloc_set_name, nih_alloc_set_destructor)
2145 (nih_alloc_name, nih_alloc_size, nih_alloc_parent): Use assert
Scott James Remnant011adce2006-04-25 03:49:54 +01002146 to uncover programming errors.
Scott James Remnantd4b03b92006-08-02 08:15:26 +01002147 * nih/list.c (nih_list_init, nih_list_remove, nih_list_free)
2148 (nih_list_add, nih_list_add_after): Use assert to uncover
Scott James Remnant011adce2006-04-25 03:49:54 +01002149 programming errors.
2150 (nih_list_new): Comment that nih_new may return NULL and we need
2151 to make sure we catch that.
2152
Scott James Remnant12ffa342006-04-24 22:33:20 +010021532006-04-24 Scott James Remnant <scott@netsplit.com>
2154
Scott James Remnant220b43b2006-04-24 22:54:39 +01002155 * m4/Makefile.am (dist_aclocal_DATA): Add missing \
2156 * nih/Makefile.am (INCLUDES): Include top_srcdir otherwise we
2157 can't be built out of tree.
2158
Scott James Remnantc6e04442006-04-24 22:51:27 +01002159 * m4/Makefile.am (dist_aclocal_DATA): Install the m4 files into
2160 the aclocal directory, not a package specific one.
2161 * m4/compiler.m4, m4/linker.m4: Fix closing comment style.
2162
Scott James Remnant12ffa342006-04-24 22:33:20 +01002163 * TODO: Add TODO file.
2164 * nih/list.h (NIH_LIST_EMPTY): Document what this actually does.
2165
Scott James Remnantff10cd32006-04-19 10:12:23 +010021662006-04-19 Scott James Remnant <scott@netsplit.com>
2167
2168 * nih/list.c (nih_list_entry_new): Removed. This makes the list
2169 code more focussed and generic, but also we'll nearly always want
2170 the data member to be an nih_alloc child of the list, rather than
2171 the other way around!
Scott James Remnantd4b03b92006-08-02 08:15:26 +01002172 * nih/list.h (NihListEntry, nih_list_add_new)
2173 (nih_list_add_new_after): Likewise, remove the structure and helper
Scott James Remnantff10cd32006-04-19 10:12:23 +01002174 macros; if we find ourselves wanting this, we can put it in a new
2175 file and just make it polymorphic like we plan for hashes.
2176 * nih/tests/test_list.c: Replace all uses of NihListEntry with plain
2177 NihList, we never checked the data members anyway.
2178 (test_entry_new): Remove test case.
2179 (test_add): Remove test of nih_list_add_new macro.
2180 (test_add_after): Remove test of nih_list_add_new_after macro.
2181 (test_empty): Check macro works with any list entry.
2182 (test_remove): Test removal of the last list entry, and removal
2183 on an already empty list.
2184 (test_free): Don't check the pointers of a block we've just freed!
2185
Scott James Remnantf10cd872006-04-18 18:37:04 +010021862006-04-18 Scott James Remnant <scott@netsplit.com>
2187
2188 * nih/alloc.c (nih_alloc_init): Call nih_alloc_set_allocator.
2189 * nih/alloc.h (NihDestructor): Clarify docstring to not refer
2190 to internal structures.
2191 * nih/list.h (NIH_LIST_EMPTY): Add convenience macro for this
2192 common operation.
2193 * nih/tests/test_list.c (test_empty): Test the new macro.
2194
Scott James Remnantb365c5f2006-04-16 08:16:18 +010021952006-04-16 Scott James Remnant <scott@netsplit.com>
2196
Scott James Remnant84ccd442006-04-16 12:41:13 +01002197 * nih/list.c (nih_list_new, nih_list_entry_new): Call nih_new rather
2198 than malloc so the list can be a context for data members.
2199 (nih_list_free): Call nih_free rather than free.
2200 * nih/tests/test_list.c: Test cases should not be static.
2201 (test_new, test_entry_new): Check the new object was allocated using
2202 our nih_alloc function.
2203 (test_remove): Test a second removal.
2204 (destructor_called): Function to test whether destructor was called.
2205 (test_free): Test now that we can use an NihDestructor.
2206 * nih/Makefile.am (test_list_LDADD): Link alloc.o now that lists
2207 depend on the allocator.
2208
Scott James Remnant2a9b7652006-04-16 12:32:45 +01002209 * nih/list.c, nih/list.h: Fix docstrings to use references where
2210 useful. Split functions into blocks separated by a newline.
2211
Scott James Remnantf7c2d222006-04-16 12:28:24 +01002212 * nih/alloc.h: Update and fix formatting.
2213 (NihAllocDestructor): Rename to NihDestructor.
2214 * nih/alloc.c (nih_alloc_init): Make safe against repeated calls.
2215 (nih_alloc_set_allocator): New function to set the default allocator,
2216 overriding any set already.
2217 (nih_alloc_set_destructor): Update type of destructor argument..
2218 (NihAllocCtx): Update type of destructor member.
2219 * nih/tests/test_alloc.c (my_realloc): Wrapper around realloc so
2220 we can check custom allocators are called properly.
2221 (test_alloc_using): Test allocation with a custom allocator.
2222 (test_free): Check that the block is freed using the allocator,
2223 also update destructor checking.
2224 (test_set_allocator): Test new allocator is used.
2225
Scott James Remnantcf980f22006-04-16 12:00:16 +01002226 * nih/alloc.c (nih_alloc_using): New one-shot function to use a given
2227 realloc-style function to make a named block of memory of a given size.
2228 (nih_alloc_named): Replace with a thin-wrapper around nih_alloc_using
2229 that passes in the default allocator.
2230 (NihAllocCtx): Add new allocator member to store the allocator used,
2231 so we free with the right one.
2232 (nih_alloc_init): Set the default allocator to realloc(). Drop
2233 pool initialisation code.
2234 (nih_free): Call the context's original allocator with zero size.
2235 (used_pool, unused_pool, NIH_ALLOC_SMALLEST): Remove, these really
2236 belong in distinct memory handling code.
2237 (nih_alloc_set, nih_alloc_new): Drop functions only needed if we're
2238 doing our own memory management.
2239 (nih_alloc_size, nih_alloc_parent): Add a couple of useful functions.
2240 * nih/alloc.h (NihAllocator): Typedef for allocator function prototype.
2241 (nih_alloc): Rename to nih_new.
2242 (nih_alloc_size): Rename to nih_alloc.
2243 * nih/tests/test_alloc.c (test_alloc_named, test_new, test_alloc): Test
2244 behaviour of standard functions with and without parents.
2245 (destructor_called): Allow it to be called multiple times, change
2246 to static to enforce modularity.
2247 (child_destructor_called): Another function for testing multiple
2248 destructors.
2249 (test_free): Test nih_free using alloc destructors.
2250 (test_alloc_set_name): Rename to just test_set_name for consistency.
2251
Scott James Remnantb365c5f2006-04-16 08:16:18 +01002252 * nih/macros.h (NIH_STRINGIFY): Generic hack to turn a numeric
2253 macro into a string.
2254 * nih/alloc.h (nih_alloc, nih_alloc_size): Use generic NIH_STRINGIFY
2255 macro instead of our home-cooked one.
2256
Scott James Remnantf47c7cf2006-03-31 16:36:41 +010022572006-03-31 Scott James Remnant <scott@netsplit.com>
2258
2259 * nih/alloc.c, nih/alloc.h, nih/list.c, nih/list.h, nih/macros.h,
2260 nih/libnih.h, nih/tests/test_alloc.c,
2261 nih/tests/test_list.c: Update FSF address in GPL header.
2262
Scott James Remnant8baaefe2006-03-03 21:50:58 +000022632006-03-03 Scott James Remnant <scott@netsplit.com>
2264
2265 * nih/alloc.c, nih/alloc.h, nih/list.c, nih/list.h: Formatting fixes,
2266 correct erroneous references to d_* functions and D* structures.
2267 * nih/list.h: Correct docstring for nih_list_new and nih_list_entry_new
2268 functions so that @data is described for the right one.
2269 * nih/Makefile.am: Add blank line between SOURCES and LDFLAGS.
2270
Scott James Remnantdfb7d502005-09-29 06:06:03 +010022712005-09-29 Scott James Remnant <scott@netsplit.com>
2272
2273 * nih/alloc.c, nih/alloc.h, nih/list.c, nih/list.h: Fix docstring
2274 terminators to be **/ not */.
2275 * nih/alloc.h: Align function parameters.
2276 * nih/tests/test_alloc.c (test_alloc_set_name): Fix to return
2277 ret and not zero all the time.
2278
Scott James Remnant3b78a412005-08-29 10:46:19 +010022792005-08-29 Scott James Remnant <scott@netsplit.com>
2280
Scott James Remnant7f288312005-08-29 11:48:04 +01002281 * nih/alloc.c (NIH_ALLOC_SMALLEST): Set to the size of the
2282 NihAllocCtx structure shifted left twice; this will divide evenly
2283 into a page.
2284
Scott James Remnant3b2cccb2005-08-29 11:33:11 +01002285 * nih/alloc.c (nih_alloc_init): No need to pass NULL to nih_list_new.
2286 (nih_alloc_new): No need to initialise data member of NihList structs
2287 or cast children member.
2288 (nih_alloc_named): Can cast NihList directly to NihAllocCtx now,
2289 simplify difference test.
2290 (nih_free): Use iter as variable name for clarity.
2291 (nih_alloc_return_unused): Cast NihList directly to NihAllocCtx.
2292 * nih/tests/test_alloc.c: Output "BAD:" instead of "FAIL:"
2293
Scott James Remnant35e2b4e2005-08-29 11:10:36 +01002294 * nih/list.h (NihList): Remove data pointer, it'll save us 4 bytes
2295 where we want to make lists of structures that are always in lists.
2296 (NihListEntry): Define new structure for those still wanting data
2297 pointers.
2298 (nih_list_add_new, nih_list_add_new_after): Use nih_list_entry_new.
2299 * nih/list.c (nih_list_new): Remove argument and don't initialise
2300 data pointer, this simply allocates and initialises the two-pointer
2301 structure.
2302 (nih_list_entry_new): New function to allocate and initialise an
2303 NihListEntry structure.
2304 * nih/tests/test_list.c: Output "BAD:" instead of "FAIL:"
2305 (test_new): Test without data pointer.
2306 (test_entry_new): Test with data pointer.
2307 (test_add, test_add_after, test_remove): Mix and cast NihList and
2308 NihListEntry properly.
2309
Scott James Remnant3b78a412005-08-29 10:46:19 +01002310 * nih/alloc.c: Implement a heirarchial allocator in a similar
2311 style to halloc and talloc, but designed never to return data to
2312 the system and re-use it instead.
2313 * nih/alloc.h: Prototypes and macros for allocator.
2314 * nih/libnih.h: Include allocator header.
2315 * nih/tests/test_alloc.c: Test-cases for allocator.
2316 * nih/macros.h (MIN, MAX): Define MIN and MAC macros if not already
2317 available.
2318 * nih/Makefile.am (libnih_la_SOURCES): Compile and link alloc.c
2319 (nihinclude_HEADERS): Install alloc.h
2320 (TESTS): Build and run the allocator test-cases.
2321 (test_alloc_SOURCES, alloc_list_LDADD): Identify the test sources and
2322 objects it needs.
2323
Scott James Remnantc5e05392005-08-28 10:43:05 +010023242005-08-28 Scott James Remnant <scott@netsplit.com>
2325
2326 * nih/list.c (nih_list_init): Add new function for dealing with
2327 statically allocated list entries, and initialising them.
2328 (nih_list_new): Use nih_list_init() to initialise the list.
2329 (nih_list_new): Use nih_list_init() to re-initialise the list
2330 to a single-member.
2331 * nih/list.h: Add prototype for nih_list_init.
2332 (NihListIter): Remove the iterator structure, it turns
2333 out to be harder work to try and use lists in an "all nodes are
2334 interesting" manner; so we'll iterate them normally instead.
2335 (NIH_LIST_FIRST, NIH_LIST_LAST): Remove iterator test functions.
2336 (NIH_LIST_PREV, NIH_LIST_NEXT): Remove iterator change functions.
2337 * nih/tests/test_list.c: Use NULL for nih_list_new in all functions.
2338 (test_init): New test case for nih_list_init().
2339 (test_iterator): Removed iterator tests.
2340
Scott James Remnant4ece6652005-08-21 00:29:11 +010023412005-08-21 Scott James Remnant <scott@netsplit.com>
2342
Scott James Remnant717f4a02005-08-21 22:37:06 +01002343 * nih/list.c: Add code for generic circular doubly-linked lists.
2344 * nih/list.h: Prototypes and macros.
2345 * nih/macros.h: Some generic macros.
2346 * nih/libnih.h: Header to import everything.
2347 * nih/tests/test_list.c: Test-cases for linked-list code.
2348 * nih/Makefile.am (libnih_la_SOURCES): Link list.c in.
2349 (nihincludedir): Define directory to contain header files to be
2350 $includedir/nih.
2351 (include_HEADERS): Install libnih.h into the main include directory.
2352 (nihinclude_HEADERS): Install header files.
2353 (TESTS): Build and run the list test-cases.
2354 (test_list_SOURCES, test_list_LDADD): Identify the test sources and
2355 objects it needs.
2356
Scott James Remnant4ece6652005-08-21 00:29:11 +01002357 * nih/libnih.ver: Add simple "everything beginning nih_* is global"
2358 version script.
2359 * nih/Makefile.am (libnih_la_LDFLAGS): Use the version script
2360 if we can pass an argument to do that to the linker.
2361 (EXTRA_DIST): Distribute the version script.
2362
Scott James Remnanted1ca162005-07-09 00:00:47 +010023632005-07-09 Scott James Remnant <scott@netsplit.com>
2364
Scott James Remnanta5e7f302005-07-09 00:15:37 +01002365 * m4/compiler.m4 (NIH_COMPILER_WARNINGS): Macro to add -Wall,
2366 -Werror and -pedantic to CFLAGS and CXXFLAGS if using gcc or g++.
2367 (NIH_COMPILER_OPTIMISATIONS): Macro to remove any optimisation
2368 arguments from CFLAGS and CXXFLAGS and replace them with -O0 to
2369 override any default level.
2370 (NIH_COMPILER_COVERAGE): Macro to add compiler coverage testing
2371 arguments to CFLAGS and CXXFLAGS.
2372 * m4/linker.m4 (NIH_LINKER_OPTIMISATIONS): Macro to add -Wl,-O1
2373 to LDFLAGS to increase the optimisation of the linker hash tables.
2374 (NIH_LINKER_VERSION_SCRIPT): Macro to test for the right argument
2375 to pass a version script to the linker and define
2376 HAVE_VERSION_SCRIPT and VERSION_SCRIPT_ARG.
2377 * m4/Makefile.am (dist_pkgdata_DATA): Ship macros.
2378 * configure.ac: Use new macros.
2379
Scott James Remnanted1ca162005-07-09 00:00:47 +01002380 * ChangeLog: Initial project infrastructure created.
2381