~donmcc/ood

Check address family in init functions.

Add tests for `sa_from_sockaddr_in()`, `sa_from_sockaddr_in6()` and
`sa_from_sockaddr_un()` to verify that they fail if the respective
`sockaddr` struct variant doesn't contain the expected address family
discriminant.
Update example in comment to match current usage.

The comment before the `sa` union declaration was missing a call to
`sa_update()`.
Add `sa_update()` function.

The `sa_update()` function resets the string representation if needed
after a `sa` union is modified.  This is useful when passing an `sa`
union to `accept()`, `getpeername()` or `getsockname()`.

Updated the example in the readme file to call `sa_update()` and
extracted common static helper functions `update_ipv4_str()` and
`update_ipv6_str()` from `sa_from_sockaddr_in()` and
`sa_from_sockaddr_in6()` respectively.
Readme fix and improvements.

Fix broken `sockaddr` link, add a link to the POSIX docs for
`sockaddr_un` and add the `sa` union declaration.
Readme file tweaks.

Use Markdown [implicit link names][].

[implicit link names]: https://daringfireball.net/projects/markdown/syntax#link
Add `sa_family()` helper function.

The `sa_family()` function is a NULL-safe way to check the type of a
`sa` union.

Also filled out the `CMakeLists.txt` file for the `sa` lib as a step in
making it stand-alone.  Also added a readme and license file for `sa`
and fixed a typo in the main readme.
Don't dynamically allocate `sa` unions.

In `ood_inet_socket`, change the `address` field for a pointer to an
`sa` union.

In the `sa` library, replace the various `sa_alloc_from_x()` functions with
corresponding `sa_from_x()` functions that take an `sa` pointer as their
first parameter and return a boolean to indicate success or failure.

In place of `sa_alloc()`, add `sa_unspec()` to clear an `sa` union and
set its address family to `AF_UNSPEC`.

Drop the functions `sa_accept_alloc()`, sa_alloc_getpeername()`,
`sa_alloc_getsockname()`, `sa_bind()` and `sa_connect()` in favor of
using the corresponding standard functions directly.

Add `sa_prepare()` to initialize an `sa` union and a `socklen_t` length
variable for receiving a socket address from functions like `connect()`
and `getpeername()`.
Rename the `sa_address` union to simply `sa`.

Go very short on the name to match the library name.
Add more wrappers for functions that use `sockaddr` structs.

Added `sa_alloc()` to allocate an empty `sa_address` union.

Added `sa_accept_alloc()`, `sa_alloc_getpeername()` and
`sa_alloc_getsockname()` wrappers around `accept()`, `getpeername()` and
`getsockname()` respectively.

Updated `ood_inet_socket_accept()` to use `sa_accept_alloc()`.
Handle NULL values without segfaulting.

Test pointer arguments and return appropriate failure values.
Add functions that accept IP string addresses.

New functions `sa_alloc_from_ipv4_str_and_port()` and
`sa_alloc_from_ipv6_str_and_port()` take a IP address string as the
first argument and return NULL if the address cannot be parsed.
Renaming "sa" functions to match parameters.

Change `sa_alloc_from_ipv4_address_and_port()` to
`sa_alloc_from_in_addr_and_port()`.

Change `sa_alloc_from_ipv6_address_and_port()` to
`sa_alloc_from_in6_addr_and_port()`.

Change `sa_alloc_from_local_path()` to `sa_alloc_from_path()`.

In the `sa_address` union, shorten fields `ipv4_string` and
`ipv6_string` to `ipv4_str` and `ipv6_str` respectively.

Change test names to match.
Add function `sa_alloc_from_sockaddr()`.

Allow creation of an `sa_address` union from a generic socket address.
Use the term "local" consistently for Unix socket addresses.

Since `unix` is #defined in some Unix C compilers, use the term "local"
consistently.  Rename `sa_alloc_from_unix_path()` to
`sa_alloc_from_local_path()` and rename test functions accordingly.
Re-order function declarations and add comments.

Group different sets of "alloc" functions together and add comments
between different function groups in the header.

Rename `sa_alloc_from_path()` to `sa_alloc_from_unix_path()`.

Reorder function definitions and tests to match declaration order.
Change `sa_address` from a struct into a union.

The struct only held the anonymous union after removing the `formatted`
field, so simplify.
Add `sa_bind()` and `sa_connect()` inline wrappers.

These are convenience wrappers for calling `bind()` and `connect()`.
Add `sa_len()` function.

Socket functions like `bind()` and `connect()` take a `sockaddr` pointer
and the corresponding length of the given struct.  The `sa_len()`
function returns the correct length of the active union field in an
`sa_address` struct.

Some renames in test for consistency.
Rename `sa_alloc_from_address_and_port()`.

New name is `sa_alloc_from_ipv4_address_and_port()`.
Add `sockaddr_storage` to the union in `sa_address`.

Make the union memory in the `sa_address` struct easily available as any
of the `sockaddr` struct types.  Test that the "family" field is
available correctly as any of the types.

Remove an unneeded `const` from the
`sa_alloc_from_ipv6_address_and_port()` parameter list.

Rename `test_sa_str_for_generic()` to
`test_sa_str_for_unspecified_family()`.
Next